'NEW_MODULE_RESINBATCHCARD'

This commit is contained in:
velz2020 2018-03-23 11:44:52 +05:30
parent e37aecc83c
commit 9072400ca5
6 changed files with 2292 additions and 6 deletions

View File

@ -0,0 +1,332 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : purchaseorder (PurchaseorderController)
* User Class to control all user related operations.
* @author : VenbaMail Mali
* @version : 1.1
* @since : 15 Feb 2016
*/
class resinbatchcard extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('quality_model');
$this->load->library('form_validation');
//$this->load->library('dompdf_gen');
$this->isLoggedIn();
}
/**
* This function used to load the first screen of the user
*/
public function index()
{
$data['productsoutward'] = $this->quality_model->getAllprodcuts();
$data['customersoutward'] = $this->quality_model->getAllcustomers();
$data['emplist'] = $this->quality_model->getEmplistforReport();
$data['machinelist'] = $this->quality_model->getMachineList();
$data['trpbatchcardnos'] = $this->quality_model->getTRPBatchcardNos();
$data['igrno'] = $this->quality_model->getIGRNos();
$this->global['pageTitle'] = 'Siddharth : Resin Batch Card';
$this->loadViews("newresinbatchcard", $this->global, $data , NULL);
}
function getIGRLineNo()
{
$igrno = $this->input->post('param1');
$sql = 'select IGRItemNo from T_IGR_Details where IGRNO = ?';
$res = $this->db->query($sql,array($igrno));
echo json_encode($res->result());
}
function resinBatchCardLisitng()
{
$data['records'] = $this->quality_model->getResinBatchCardTestMasterList();
$this->global['pageTitle'] = 'Siddharth : Prodcut Report List ';
$this->loadViews("resinbatchcardreportlist", $this->global, $data , NULL);
}
function saveTestReportData()
{
date_default_timezone_get('Asia/Kolkata');
$productid = $this->input->post('param1');
$customerid = $this->input->post('param2');
$batchdate = $this->input->post('param3');
$batchdate = date_format(date_create($batchdate),'Y-m-d');
$plantname = $this->input->post('param4');
$macinecode = $this->input->post('param5');
$trpbatchcard = $this->input->post('param6');
$igrnos = $this->input->post('param7');
$igrlinenos = $this->input->post('param8');
$remarks = $this->input->post('param9');
$approvedby = $this->input->post('param10');
$masterdata = $this->input->post('param11');
$totaldata = $this->input->post('param12');
$masterdata = json_decode($masterdata,true);
$totaldata = json_decode($totaldata,true);
$createby = $this->session->userdata ( 'userId' );
$document = null;
//print_r($masterdata);die();
//print_r($totaldata);
if(!empty($_FILES['rfile']['name']))
{
$fs = $this->uploadFile();
$document = $fs;
}
$sandtotal = 0;
$resintotal = 0;
$hextotal = 0;
$cstotal = 0;
$bags50total = 0;
$ton1bagstotal = 0;
$producitonloss = 0;
$finishedproduct = 0;
foreach($totaldata as $key => $tot)
{
if($key != 0)
{
$sandtotal = $tot['Sand'];
$resintotal = $tot['Resin'];
$hextotal = $tot['Hexamine'];
$cstotal = $tot['CS'];
$bags50total = $tot['50 Bags'];
$ton1bagstotal = $tot['1 ton Bag'];
$producitonloss = $tot['Production Loss Lump'];
$finishedproduct = $tot['Finished Prodcut PCS'];
}
}
$masterreportdata = array('productid'=>$productid,'customerid'=>$customerid,'batchdate'=>$batchdate,'plantname'=>$plantname,'machinecode'=>$macinecode,'trpbatchcardno'=>$trpbatchcard,'igrno'=>$igrnos,'igrlineno'=>$igrlinenos,'remarks'=>$remarks,'createdby'=>$createby,'approvedby'=>$approvedby,'document'=>$document,'sandtotal'=>$sandtotal,'resintotal'=>$resintotal,'hextotal'=>$hextotal,'cstotal'=>$cstotal,'bags50total'=>$bags50total,'ton1bagstotal'=>$ton1bagstotal,'producitonloss'=>$producitonloss,'finishedproduct'=>$finishedproduct);
//print_r($masterreportdata);
$MASTERID = $this->quality_model->saveResinBatchCardMasterTestData($masterreportdata);
//echo $MASTERID;die();
//$MASTERID = 56;
foreach($masterdata as $key => $mas)
{
if($key > 2){
$t = array_pop($mas);
array_pop($mas);
foreach($mas as $key => $m)
{
$newArray = array('master_report_id'=>$MASTERID,'i_time'=>$t,'spec_id'=>$key,'spec_value'=>$m);
$res = $this->quality_model->saveResinBatchCardChildTestData($newArray);
//print_r($newArray);
}
}
}
echo "Report Data Saved Successfully!";
}
function updateTestReportData()
{
date_default_timezone_get('Asia/Kolkata');
$productid = $this->input->post('param1');
$customerid = $this->input->post('param2');
$batchdate = $this->input->post('param3');
$batchdate = date_format(date_create($batchdate),'Y-m-d');
$plantname = $this->input->post('param4');
$macinecode = $this->input->post('param5');
$trpbatchcard = $this->input->post('param6');
$igrnos = $this->input->post('param7');
$igrlinenos = $this->input->post('param8');
$remarks = $this->input->post('param9');
$approvedby = $this->input->post('param10');
$masterdata = $this->input->post('param11');
$totaldata = $this->input->post('param12');
$masterdata = json_decode($masterdata,true);
$totaldata = json_decode($totaldata,true);
$createby = $this->session->userdata ( 'userId' );
$document = $this->input->post('param13');
$MASTERID = $this->input->post('param14');
//print_r($masterdata);die();
//print_r($totaldata);
if(!empty($_FILES['rfile']['name']))
{
if(!empty($document)){
$file = getcwd()."\\uploads\QAD\\".$document;
if(unlink($file)){
//echo "sucess";
}else{
//echo "Failed";
}
}
$fs = $this->uploadFile();
$document = $fs;
}
$sandtotal = 0;
$resintotal = 0;
$hextotal = 0;
$cstotal = 0;
$bags50total = 0;
$ton1bagstotal = 0;
$producitonloss = 0;
$finishedproduct = 0;
foreach($totaldata as $key => $tot)
{
if($key != 0)
{
$sandtotal = $tot['Sand'];
$resintotal = $tot['Resin'];
$hextotal = $tot['Hexamine'];
$cstotal = $tot['CS'];
$bags50total = $tot['50 Bags'];
$ton1bagstotal = $tot['1 ton Bag'];
$producitonloss = $tot['Production Loss Lump'];
$finishedproduct = $tot['Finished Prodcut PCS'];
}
}
$masterreportdata = array('remarks'=>$remarks,'updatedby'=>$createby,'approvedby'=>$approvedby,'document'=>$document,'sandtotal'=>$sandtotal,'resintotal'=>$resintotal,'hextotal'=>$hextotal,'cstotal'=>$cstotal,'bags50total'=>$bags50total,'ton1bagstotal'=>$ton1bagstotal,'producitonloss'=>$producitonloss,'finishedproduct'=>$finishedproduct);
//print_r($masterreportdata);
$this->quality_model->updateResinBatchCardMasterTestData($masterreportdata,$MASTERID);
//echo $MASTERID;die();
//$MASTERID = 56;
foreach($masterdata as $key => $mas)
{
if($key > 2){
$t = array_pop($mas);
array_pop($mas);
foreach($mas as $key => $m)
{
$newArray = array('master_report_id'=>$MASTERID,'i_time'=>$t,'spec_id'=>$key,'spec_value'=>$m);
$res = $this->quality_model->updateResinBatchCardChildTestData($newArray);
//print_r($newArray);
}
}
}
echo "Report Data Saved Successfully!";
}
function printReportPDF()
{
$type = '';
$html = '';
$filename = '';
if($this->input->post('type'))
{
$type = $this->input->post('type');
}
$reportid = $this->input->post('rid');
if($type != 'INWARD' or $type == ''){
$data['reportdata'] = $this->quality_model->getIndividualReportData($reportid);
$filename = 'PRE DESPATCH INSPECTION REPORT'.$reportid;
$html = $this->load->View("viewindreportpdf",$data,true);
}
else if($type == 'INWARD')
{
$data['reportdata'] = $this->quality_model->getIndividualInwardReportData($reportid);
$filename = 'INWARD MATERIAL INSPECTION REPORT'.$reportid;
$html = $this->load->View("viewindinwardreportpdf",$data,true);
}
require APPPATH . '/third_party/mpdf/mpdf.php';
$mpdf=new mPDF('utf-8','A4-P',7,10,10, 10, 10, 24, 4, 6);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
$mpdf->Output($filename.'.pdf','I');
}
function uploadFile()
{
$pathinfo = pathinfo($_FILES['rfile']['name']);
$config['upload_path'] = 'uploads/QAD/';
$config['allowed_types'] = '*';
$filename = $_FILES['rfile']['name'];
$ext = end(explode('.',$filename));
$ext = strtolower($ext);
$fn = 'RESINBCARD' . date('Y-m-d') . time() . '.' . $ext;
//print_r($fn);die();
$config['file_name'] = $fn;
//echo $config['file_name'];
$this->load->library('upload',$config);
$this->upload->initialize($config);
if($this->upload->do_upload('rfile'))
{
$uploadData = $this->upload->data();
$uploadfilename = $uploadData['file_name'];
return $uploadfilename;
}
else
{
$error = array('error' => $this->upload->display_errors());
$uploadfilename = '';
print_r($error);
return null;
}
}
function viewIndReport()
{
$rbcid = $this->uri->segment(3);
//echo $rbcid;
$data['emplist'] = $this->quality_model->getEmplistforReport();
$data['records'] = $this->quality_model->getResinBatchCardDetails($rbcid);
//print_r($data['records']);die();
$this->global['pageTitle'] = 'Siddharth : Edit Resin Batch Card';
$this->loadViews("editresinbatchcard", $this->global, $data , NULL);
}
}
?>

View File

@ -205,6 +205,107 @@ class Quality_model extends CI_Model
return $id;
}
function saveResinBatchCardMasterTestData($masterreportdata)
{
$this->db->insert('T_ResinBatchCard_Master',$masterreportdata);
$id = $this->db->insert_id();
return $id;
}
function updateResinBatchCardChildTestData($newArray)
{
$this->db->select('resinbatchcard_iter_id');
$this->db->from('T_ResinBatchCard_Child');
$this->db->where('master_report_id',$newArray['master_report_id']);
$this->db->where('i_time',$newArray['i_time']);
$this->db->where('spec_id',$newArray['spec_id']);
$res = $this->db->get();
$res = $res->result();
if(!empty($res[0]->resinbatchcard_iter_id))
{
$this->db->where('master_report_id',$newArray['master_report_id']);
$this->db->where('i_time',$newArray['i_time']);
$this->db->where('spec_id',$newArray['spec_id']);
$this->db->update('T_ResinBatchCard_Child',$newArray);
}
else
{
$this->saveResinBatchCardChildTestData($newArray);
}
}
function saveResinBatchCardChildTestData($newArray)
{
$this->db->insert('T_ResinBatchCard_Child',$newArray);
}
function updateResinBatchCardMasterTestData($masterreportdata,$MASTERID)
{
$this->db->where('resinbatch_id',$MASTERID);
$this->db->update('T_ResinBatchCard_Master',$masterreportdata);
}
function getResinBatchCardDetails($rbcid)
{
$sql = 'select T_ResinBatchCard_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name,T_Machine_Master.Machine_Name,T_Employee_Details.FirstName,T_Employee_Details.LastName from T_ResinBatchCard_Master
join ip_products on T_ResinBatchCard_Master.productid = ip_products.product_id
join ip_clients on T_ResinBatchCard_Master.customerid = ip_clients.client_id
join T_Machine_Master on T_ResinBatchCard_Master.machinecode = T_Machine_Master.Machine_Code
join tbl_users on T_ResinBatchCard_Master.createdby = tbl_users.userId
join T_Employee_Details on tbl_users.EmpID = T_Employee_Details.EmpID
where T_ResinBatchCard_Master.resinbatch_id = ?';
$res['masterdata'] = $this->db->query($sql,array($rbcid))->result();
//print_r($res['masterdata']);
$sql = 'select T_ResinBatchCard_Child.*,T_Prodcut_Specification_Master.testtype from T_ResinBatchCard_Child
join T_Prodcut_Specification_Master on T_ResinBatchCard_Child.spec_id = T_Prodcut_Specification_Master.productspecmaster_id
where master_report_id = ?;';
$res['childdata'] = $this->db->query($sql,array($rbcid))->result();
$sid = '';
//print_r($res['childdata']);
$index = 0;
$newArray = array();
$allspecs = array('TEST');
foreach($res['childdata'] as $c)
{
if($sid != $c->i_time)
{
$index++;
$newArray[$index] = array($c->i_time,$c->spec_value);
if($index == 1){
array_push($allspecs,strtolower($c->testtype));
}
}
else
{
array_push($newArray[$index],$c->spec_value);
if($index == 1){
array_push($allspecs,strtolower($c->testtype));
}
}
$sid = $c->i_time;
}
$res['childdata'] = $newArray;
//print_r($res['childdata']);
$res['allspec'] = $allspecs;
return $res;
}
function getResinBatchCardTestMasterList()
{
$sql = 'Select resinbatch_id,productid,ip_products.product_name,ip_products.product_description,customerid,client_name,batchdate,igrno,igrlineno,T_ResinBatchCard_Master.createdby,approvedby,document,T_Employee_Details.FirstName from T_ResinBatchCard_Master
join ip_products on T_ResinBatchCard_Master.productid=ip_products.product_id
join ip_clients on T_ResinBatchCard_Master.customerid=ip_clients.client_id
join tbl_users on T_ResinBatchCard_Master.createdby = tbl_users.userId
join T_Employee_Details on T_Employee_Details.EmpID = tbl_users.EmpID';
$res = $this->db->query($sql);
return $res->result();
}
function saveTestReportData($testreportdata)
{
$this->db->insert('T_Test_Report',$testreportdata);
@ -441,6 +542,27 @@ class Quality_model extends CI_Model
$res = $this->db->query($sql,array($igrno,$igrlineitemno));
return $res->result();
}
function getIGRNos()
{
$sql = 'select IGRNO from T_IGR_Master order by IGRNO desc';
$res = $this->db->query($sql);
return $res->result();
}
function getMachineList()
{
$sql = 'select Machine_Code,Machine_Name from T_Machine_Master';
$res = $this->db->query($sql);
return $res->result();
}
function getTRPBatchcardNos()
{
$sql = 'select dailyid from T_daily_batchcard_data';
$res = $this->db->query($sql);
return $res->result();
}
}
?>

View File

@ -0,0 +1,885 @@
<style>
.edit{
background-color:#ada5d2;
}
.editrst{
background-color:#b9b5b5 ;
}
.editcst{
background-color:#ada5d2 ;
}
.loader ,.loader-overlay ,.overlay{
height: 4000px !important;
}
</style>
<?php
//color:red ! important;
// foreach($records['childdata'] as $g)
// {
// print_r($g);
// }
// echo "************************";
// print_r($records['masterdata']);
// $products = array(-1=>'Select Product');
// foreach($productsoutward as $rec)
// {
// $products[$rec->product_id] = $rec->product_name;
// }
// $customers = array(-1=>'Select Customer');
// foreach($customersoutward as $rec)
// {
// $customers[$rec->client_id] = $rec->client_name;
// }
// //print_r($emplist);
$approvedby = array(-1=>'Select Approver Name');
foreach($emplist as $r)
{
$approvedby[$r->FirstName.' '.$r->LastName] = $r->FirstName.' '.$r->LastName.'-'.$r->shortName;
}
// $machines = array(-1=>'Select Machine Name');
// $trpbatchnos = array(-1=>'Select TRP Batch Card No');
// $igrnos = array(-1=>'Select IGRNO');
// $igrlinenos = array(-1=>'Select IGR Line Item');
// foreach($igrno as $r)
// {
// $igrnos[$r->IGRNO] = $r->IGRNO;
// }
// foreach($machinelist as $r)
// {
// $machines[$r->Machine_id] = $r->Machine_id.'-'.$r->Machine_Name;
// }
// foreach($trpbatchcardnos as $r)
// {
// $trpbatchnos[$r->dailyid] = $r->dailyid;
// }
?>
<style>
th{
text-align:center !important;
}
</style>
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
<script src="<?php echo base_url().'assets/jquery.plugin.js'?>"></script>
<script src="<?php echo base_url().'assets/jquery.timeentry.js'?>"></script>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Edit Resin Batch Card </center>
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<!--<center><h3 class="box-title">-->
<div class="box-tools">
<!-- <form action="<?php echo base_url() ?>assetListing" method="POST" id="searchList">-->
<form action="<?php echo base_url() ?>monthlypay/monthlyListing" method="POST" id="searchList">
</form>
</div><!--</h3></center>-->
</div><!-- /.box-header -->
<div class="box-body">
<div class="row">
<div class="col-md-3">
<label>Customer</label>
<input type="text" value="<?php echo $records['masterdata'][0]->client_name?>" class="form-control" readonly>
<input type="hidden" id="MASTERID" value="<?php echo $records['masterdata'][0]->resinbatch_id?>" >
<input type="hidden" id="customer" value="<?php echo $records['masterdata'][0]->customerid?>" >
</div>
<div class="col-md-3">
<label>Grade</label>
<input type="text" value="<?php echo $records['masterdata'][0]->client_name?>" class="form-control" readonly>
<input type="hidden" id="product" value="<?php echo $records['masterdata'][0]->productid?>" >
</div>
<!-- <div class="col-md-3">
<label>Resin Batch Card No</label>
<input type="text" id="batchno" name="batchno" class="form-control" >
</div> -->
<div class="col-md-3">
<label>Batch Date</label>
<input type="text" id="batchdate" name="batchdate" class="form-control" readonly value="<?php echo date_format(date_create($records['masterdata'][0]->batchdate),'d-m-Y');?>">
</div>
<div class="col-md-3">
<label>Shift Name</label>
<input type="text" id="plantname" name="plantname" class="form-control" readonly value="<?php echo $records['masterdata'][0]->plantname?>">
</div>
</div>
<div class="row">
<div class="col-md-3">
<label>Machine Name</label>
<input type="text" value="<?php echo $records['masterdata'][0]->machinecode;?>" class="form-control" readonly>
</div>
<div class="col-md-3">
<label>TRP Batch No(For TRP Sand)</label>
<input type="text" value="<?php echo $records['masterdata'][0]->trpbatchcardno;?>" class="form-control" readonly>
</div>
<div class="col-md-3">
<label>IGR No(For Fresh Sand)</label>
<input type="text" value="<?php echo $records['masterdata'][0]->igrno;?>" class="form-control" readonly>
</div>
<div class="col-md-3">
<label>IGR Line Item No</label>
<input type="text" value="<?php echo $records['masterdata'][0]->igrlineno;?>" class="form-control" readonly>
</div>
</div><br>
<div class="row">
<div class="col-md-offset-11 col-md-1" id="savebutton">
<input type="button" id="submit" value = "Add Row" class="btn btn-primary" onclick="addNewRow();">
</div>
</div>
<br/>
<table id="testreport" class="table table-bordered" style="background-color:#fff;font-size:12px;text-align:center;">
<thead style="background-color:#ddf;">
<tr id="firstrowheader"><th>SNO</th><th>Time</th></tr>
<tr id="specname"><th>Particulars</th><th>Time</th></tr>
<tr id="huom"><th rowspan="2" style="text-align:center;">SNO</th><th>Unit</th></tr>
<tr id="spec"><th >Spec</th></tr>
</thead>
<tbody id="specAppend">
<?php
if(!empty($records['childdata']))
{
foreach($records['childdata'] as $k => $value)
{
//print_r($value);
?>
<tr id="<?php echo $k;?>"><td><?php echo $k;?></td>
<?php
foreach($value as $key => $v)
{
if($key == 0){
?>
<td id="<?php echo 'time'.$k;?>" onblur="timeCheck(this.id,this.textContent)" contenteditable="false" ><?php echo $v?></td>
<?php }
else{
?>
<td id="<?php echo $k.$records['allspec'][$key];?>" onkeypress="return keyValidate(event);" onblur="masterCalculationCheck(this.id,this.textContent)" contenteditable="true" class="edit"><?php echo $v?></td>
<?php
}
}?>
</tr>
<?php
}
}
?>
</tbody>
</table>
<br>
<p><b>Raw/Packing Material Consumption<b></p>
<table id="finaltable" class="table table-bordered" style="background-color:#fff;font-size:12px;text-align:center;">
<thead style="background-color:#ddf;">
<tr><th>Particulars</th><th>Sand</th><th>Resin</th><th>Hexamine</th><th>CS</th><th>50 Bags</th><th>1 ton Bag</th><th>Production Loss <br> Lump</th><th>Finished Prodcut <br> PCS</th></tr>
<tr><th>Unit</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Nos</th><th>Kgs</th><th>Kgs</th></tr>
</thead>
<tbody id="">
<tr><td>Qty</td><td id="sandtotal"><?php echo $records['masterdata'][0]->sandtotal;?></td><td id="resintotal"><?php echo $records['masterdata'][0]->resintotal;?></td><td id="hextotal"><?php echo $records['masterdata'][0]->hextotal;?></td><td id="cstotal"><?php echo $records['masterdata'][0]->cstotal;?></td><td id="50bagtotal" contenteditable="true"><?php echo $records['masterdata'][0]->bags50total;?></td><td id="1tonbagtotal" contenteditable="true"><?php echo $records['masterdata'][0]->ton1bagstotal;?></td><td id="lumptotal" contenteditable="true"><?php echo $records['masterdata'][0]->producitonloss;?></td><td id="pcstotal" contenteditable="true"><?php echo $records['masterdata'][0]->finishedproduct;?></td></tr>
</tbody>
</table>
<hr>
</div>
<div class="col-md-12">
<div class="row">&nbsp;</div>
<div class="col-md-12">
<div class="col-md-3">
<label>File Upload:</label>
<form id="report_file" name="report_file" enctype="multipart/form-data" accept-charset="utf-8" method="POST" action="">
<input type="file" id="reportfile" name="reportfile">
<input type="hidden" id = "olddoc" value="<?php echo $records['masterdata'][0]->document?>">
</form>
</div>
<div class="col-md-9">
<label>Remarks:</label>
<textarea id="remarks" class="form-control" rows="1"><?php echo $records['masterdata'][0]->remarks; ?></textarea>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<label>Operated By :</label>
<input type="text" id="inspector" class="form-control" value="<?php echo $this->session->userdata ( 'name' );?>" readonly>
<input type="hidden" value="<?php echo $this->session->userdata ( 'userId' );?>">
</div>
<div class="col-md-3 col-md-offset-6 ">
<label>Production In charge :</label>
<?php echo form_dropdown('name="approvedby"',$approvedby,set_value('approvedby',$approvedby[-1]),'id="approvedby"' ,'class="form-control select2', 'style="text-align:center;"');?>
<!-- <input type="text" id="approvedby" class="form-control"> -->
</div>
</div>
<div class="row">&nbsp;</div>
<div>
<div class="row">&nbsp;</div>
<div class="row">
<div class="col-md-3" id="savebutton">
<input type="button" id="submit" value = "Save" class="btn btn-primary" onclick="getAllData();">
</div>
</div>
</div><!-- /.box-body -->
<!-- <div class="box-footer clearfix">
</div> -->
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
$(function () {
$('#monthlylisting').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"aaSorting": [[ 0, "asc" ]],
"info": true,
"autoWidth": true
});
});
</script>
<script>
$(document).ready(function(){
$("#loibutton").click(function(){
$("#loiarea").toggle("slow");
});
$("#afsbutton").click(function(){
$("#afsarea").toggle("slow");
});
$("#chartbutton").click(function(){
$("#chartarea").toggle("slow");
});
// $('#batchdate').datepicker({
// //minDate : 'year+16',
// maxDate : 'now',
// dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '0:+10'
// });
var p = "<?php echo $records['masterdata'][0]->productid;?>";
var c = "<?php echo $records['masterdata'][0]->customerid;?>";
getAllSpec(p,c);
// $('#approvedby').select2();
$('#approvedby').val('<?php echo $records['masterdata'][0]->approvedby?>');
//show_hide_column(13,false);
}); // End of document on ready funciton
function keyValidate(e)
{
if(((e.which || e.keyCode) == 8) || ((e.which || e.keyCode) == 9) || ((e.which || e.keyCode) == 46) || ((e.which || e.keyCode) == 37) || ((e.which || e.keyCode) == 39) || ((e.which || e.keyCode) == 45))
{
return true;
}
if(e.keyCode == 13)
{
return false;
}
if(((e.which || e.keyCode) < 48) || ((e.which || e.keyCode) > 57))
{
return false;
}
}
$('#product').change(function(){
getAllSpec();
});
$('#customer').change(function(){
getAllSpec();
});
var index = 0;
var allspecs = [];
var allspecvalues = [];
var flag = 0;
var totalcells = 0;
var overallrows = 0;
overallrows = $('#testreport').find('tr');
overallrows = ((overallrows.length)-4);
$('#igrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#igrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#igrlinenos').find('option').remove();
$('#igrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
function getAllSpec(p,c)
{
var p = p;
var c = c;
var type = 'RESINBATCHCARD';
if(p == -1 || c == -1)
{
return false;
}
else
{
$('.content').loader('show');
$.ajax({
data:{param1:p,param2:c,param3:type},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>quality/getAllSpecforReport",
success:function(data) {
// alert(data);
data = JSON.parse(data);
//alert(data);
// $('#testreport tbody').remove();
// $('#testreport').append('<tbody id="specAppend"></tbody>');
// $('#testreport2 tbody').remove();
// $('#testreport2').append('<tbody id="specAppend2"></tbody>');
if(data != '')
{
htmlspecname = '';
htmlspecid = '';
htmlspecuom = '';
htmlspec = '';
flag = 1;
$('.content').loader('hide');
$.each(data,function(i,item){
var ide='';
//console.log(item);
//console.log('master1');
ide = item.testtype;
ide = ide.replace(/\s/g, "");
ide = ide.toLowerCase();
htmlspecname +='<td>'+item.testtype+'</td>';
htmlspecid += '<td>'+item.productspecmaster_id+'</td>';
htmlspecuom += '<td>'+item.uom+'</td>';
htmlspec += '<td>'+item.min+'-'+item.max+'</td>';
allspecs.push(ide);
allspecvalues.push(item.min+'-'+item.max);
});
// console.log(allspecs);
//console.log(allspecvalues);
$("#specname").append(htmlspecname);
$("#firstrowheader").append(htmlspecid);
$("#huom").append(htmlspecuom);
$("#spec").append(htmlspec);
document.getElementById('firstrowheader').style.display = 'none';
totalcells = $('#testreport').find('tr').eq(1).find('td');
//console.log(totalcells);
// var childdata = "<?php echo JSON_encode($records['childdata']);?>";
// console.log(childdata['1']);
totalcells = totalcells.length;
//alert('totalcellsbefore'+totalcells);
totalcells+=2;
//alert('totalcells'+totalcells);
// index +=1;
// htmlbody = '';
// //var i = 0;
// for(i=1;i<=totalcells;i++)
// {
// if(i == 1)
// {
// htmlbody+='<tr id='+index+'><td>'+index+'</td>';
// //alert('1');
// }
// else if( i == 2)
// {
// htmlbody+='<td class="edit" id="time'+index+'" contenteditable="true" onblur="timeCheck(this.id,this.textContent)"></td>';
// //alert('not 1');
// }
// else
// {
// //var temp = index;
// //console.log(allspecs[temp]);
// var temp = index+''+allspecs[i-3];
// htmlbody+='<td class="edit" id="'+temp+'" contenteditable="true" onkeypress="return keyValidate(event);" onblur="masterCalculationCheck(this.id,this.textContent)"></td>';
// //temp++;
// }
// //alert('inside for loop'+i);
// }
// htmlbody+='</tr>'
// $("#testreport tbody").append(htmlbody);
//overallrows++;
// $("#testreport2 tbody").append(htmlmaster2);
}
else
{
alert('No Master Records Found..!');
$('.content').loader('hide');
}
}
});
}
}
function addNewRow()
{
//alert(flag);
if(flag != 1)
{
alert('There is no report,Cannot Save');
return false;
}
index = overallrows + 1
//var htmlrow = '<tr id='+index+'><td contenteditable="true" class="edit" id="time'+index+'">';
var htmlrow = '';
for(i=1;i<=totalcells;i++)
{
if(i == 1)
{
htmlrow+='<tr id='+index+'><td>'+index+'</td>';
//alert('1');
}
else if( i == 2)
{
htmlrow+='<td class="edit" id="time'+index+'" contenteditable="true" onblur="timeCheck(this.id,this.textContent)"></td>';
//alert('not 1');
}
else
{
//var temp = index;
//console.log(allspecs[temp]);
var temp = index+''+allspecs[i-3];
htmlrow+='<td class="edit" id="'+temp+'" contenteditable="true" onkeypress="return keyValidate(event);" onblur="masterCalculationCheck(this.id,this.textContent)"></td>';
//temp++;
}
//alert('inside for loop'+i);
}
htmlrow+='</tr>'
$("#testreport tbody").append(htmlrow);
overallrows++;
}
function timeCheck(id,val)
{
var id = id;
//alert('timecheck'+id);
if(val == '')
{
alert('Please Enter Time..!');
document.getElementById(id).textContent='';
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
return false;
}
if(val.length != 5)
{
alert('Please Enter Valid 24 Hrs Time..!');
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
document.getElementById(id).textContent='';
return false;
}
if(val.length == 5)
{
var cur = val.split(':');
if(isNaN(cur[0]) || isNaN(cur[1]) || cur[0] > 24 || cur[1] > 59)
{
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
document.getElementById(id).textContent='';
alert('Please Enter Valid 24Hrs Time Format..!');
return false;
}
}
}
function masterCalculationCheck(id,val)
{
//alert(id+'-'+val);
var totalsandqty = 0;
var totalhexqty = 0;
var totalresinqty = 0;
var totalcsqty = 0;
var ide = id.substr(1);
//alert(ide);
//For Total Sand Calculation
if(ide == 'sand')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalsandqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('sandtotal'))
{
document.getElementById('sandtotal').textContent = parseFloat(totalsandqty);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'hexamine')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalhexqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('hextotal'))
{
document.getElementById('hextotal').textContent = parseFloat(totalhexqty);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'resin')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalresinqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('resintotal'))
{
document.getElementById('resintotal').textContent = parseFloat(totalresinqty);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'cs')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalcsqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('cstotal'))
{
document.getElementById('cstotal').textContent = parseFloat(totalcsqty);
}
}
if(val == '')
{
//alert('Please Enter Time..!');
document.getElementById(id).textContent='0.00';
return false;
}
}
function getAllData()
{
// if(flag != 1)
// {
// alert('Cannot Save');
// return false;
// }
var testreportdata = $("#testreport").tableToJSON();
var finaltable = $("#finaltable").tableToJSON();
testreportdata=JSON.stringify(testreportdata);
// alert(testreportdata);
finaltable=JSON.stringify(finaltable);
//alert(finaltable);
var productid = $('#product').val();
var customerid = $('#customer').val();
var batchdate = $('#batchdate').val();
var plantname = $('#plantname').val();
var macinecode = $('#machines').val();
var trpbatchcard = $('#trpbatchnos').val();
var igrnos = $('#igrnos').val();
var igrlinenos = $('#igrlinenos').val();
var remarks = $('#remarks').val();
var approvedby = $('#approvedby').val();
var olddoc = $('#olddoc').val();
var MASTERID = $('#MASTERID').val();
if(productid == -1 || customerid == -1 || batchdate == '' || plantname == '' || macinecode == '' || trpbatchcard == -1 || igrlinenos == -1 ||igrnos == -1 || approvedby == -1)
{
alert('Please Enter All Master Details..!');
return false;
}
for(i=1;i<=overallrows;i++)
{
if(document.getElementById('time'+1).textContent == '')
{
alert('Please Enter Time for All Entry..! ');
return false;
}
}
var formData = new FormData();
var reportfile = $("#reportfile").prop('files')[0];
formData.append('rfile',reportfile);
var param1 = productid;
var param2 = customerid;
var param3= batchdate;
var param4 = plantname;
var param5 = macinecode;
var param6 = trpbatchcard;
var param7 = igrnos;
var param8 = igrlinenos;
var param9 = remarks;
var param10 = approvedby;
var param11 = testreportdata;
var param12 = finaltable;
var param13 = olddoc;
var param14 = MASTERID;
formData.append('param1',param1);
formData.append('param2',param2);
formData.append('param3',param3);
formData.append('param4',param4);
formData.append('param5',param5);
formData.append('param6',param6);
formData.append('param7',param7);
formData.append('param8',param8);
formData.append('param9',param9);
formData.append('param10',param10);
formData.append('param11',param11);
formData.append('param12',param12);
formData.append('param13',param13);
formData.append('param14',param14);
$('.content').loader('show');
$.ajax({
data:formData,
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/updateTestReportData",
//async : false,
cache : false,
contentType : false,
processData : false,
success:function(data) {
if(data){
alert(data);
$('.content').loader('hide');
window.location = "<?php echo base_url().'resinbatchcard/resinBatchCardLisitng';?>";
}
}
});
}
</script>

View File

@ -361,7 +361,8 @@ $(function() {
<?php }?>
<?php }?>
<!-- INPROCESS MODULE-->
<!-- INPROCESS MODULE-->
<?php if(empty($DepAccesslist)){?>
<?php if($DEPCode == QUALITY){?>
@ -388,6 +389,7 @@ $(function() {
<span>New Nissan In Process Inspection</span>
</a>
</li>
</ul>
</li>
@ -547,7 +549,7 @@ $(function() {
<!-- BATCH CARD MODULE-->
<!-- <?php print_r($DepAccesslist)?> -->
<?php if(empty($DepAccesslist)){ ?>
<?php if($DEPCode == FINANCE || $DEPCode == SALES || $DEPCode == HR || $DEPCode == SYSTEM_ADMIN || $DEPCode == ADMIN && $DEPCode != SECURITY){?>
@ -1241,7 +1243,7 @@ $(function() {
<?php }?>
<?php //if($DEPCode == QUALITY){?>
<?php if($DEPCode == QUALITY){?>
<li class="treeview">
<a href="<?php echo base_url(); ?>quality">
<i class="fa fa-list-alt"></i>
@ -1261,7 +1263,7 @@ $(function() {
<span>Inward Material Test Report</span>
</a>
</li>
<?php //}?>
<?php }?>
<!-- <li class="treeview">
@ -1331,7 +1333,7 @@ $(function() {
<span>View Material Inspection Report</span>
</a>
</li>
<?php if($DEPCode == QUALITY){?>
<?php //if($DEPCode == QUALITY){?>
<li class="treeview">
<a href="<?php echo base_url(); ?>quality">
<i class="fa fa-list-alt"></i>
@ -1344,7 +1346,7 @@ $(function() {
<span>Product Test Report</span>
</a>
</li>
<?php } ?>
<?php// } ?>
<li class="treeview">
<a href="<?php echo base_url(); ?>qualityreportlistinward">
<i class="fa fa-hand-o-down"></i>

View File

@ -0,0 +1,836 @@
<style>
.edit{
background-color:#ada5d2;
}
.editrst{
background-color:#b9b5b5 ;
}
.editcst{
background-color:#ada5d2 ;
}
.loader ,.loader-overlay ,.overlay{
height: 4000px !important;
}
</style>
<?php
//color:red ! important;
//print_r($igrno);
$products = array(-1=>'Select Product');
foreach($productsoutward as $rec)
{
$products[$rec->product_id] = $rec->product_name;
}
$customers = array(-1=>'Select Customer');
foreach($customersoutward as $rec)
{
$customers[$rec->client_id] = $rec->client_name;
}
//print_r($emplist);
$approvedby = array(-1=>'Select Approver Name');
foreach($emplist as $r)
{
$approvedby[$r->FirstName.' '.$r->LastName] = $r->FirstName.' '.$r->LastName.'-'.$r->shortName;
}
$machines = array(-1=>'Select Machine Name');
$trpbatchnos = array(-1=>'Select TRP Batch Card No');
$igrnos = array(-1=>'Select IGRNO');
$igrlinenos = array(-1=>'Select IGR Line Item');
foreach($igrno as $r)
{
$igrnos[$r->IGRNO] = $r->IGRNO;
}
foreach($machinelist as $r)
{
$machines[$r->Machine_Code] = $r->Machine_Code.'-'.$r->Machine_Name;
}
foreach($trpbatchcardnos as $r)
{
$trpbatchnos[$r->dailyid] = $r->dailyid;
}
?>
<style>
th{
text-align:center !important;
}
</style>
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.js"></script>
<script src="<?php echo base_url()?>assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js"></script>
<script src="<?php echo base_url().'assets/jquery.plugin.js'?>"></script>
<script src="<?php echo base_url().'assets/jquery.timeentry.js'?>"></script>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>New Resin Batch Card Screen</center>
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<!--<center><h3 class="box-title">-->
<div class="box-tools">
<!-- <form action="<?php echo base_url() ?>assetListing" method="POST" id="searchList">-->
<form action="<?php echo base_url() ?>monthlypay/monthlyListing" method="POST" id="searchList">
</form>
</div><!--</h3></center>-->
</div><!-- /.box-header -->
<div class="box-body">
<div class="row">
<div class="col-md-3">
<label>Customer</label>
<?php echo form_dropdown('customer',$customers,set_value('customer',$customers[-1]),'id="customer"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-3">
<label>Grade</label>
<?php echo form_dropdown('product',$products,set_value('product',$products[-1]),'id="product"' ,'class="form-control select2', 'style="text-align:center;"');?>
</div>
<!-- <div class="col-md-3">
<label>Resin Batch Card No</label>
<input type="text" id="batchno" name="batchno" class="form-control" >
</div> -->
<div class="col-md-3">
<label>Batch Date</label>
<input type="text" id="batchdate" name="batchdate" class="form-control" >
</div>
<div class="col-md-3">
<label>Shift Name</label>
<input type="text" id="plantname" name="plantname" class="form-control" >
</div>
</div>
<div class="row">
<div class="col-md-3">
<label>Machine Name</label>
<?php echo form_dropdown('machines',$machines,set_value('machines',$machines[-1]),'id="machines"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-3">
<label>TRP Batch No(For TRP Sand)</label>
<?php echo form_dropdown('trpbatchnos',$trpbatchnos,set_value('trpbatchnos',$trpbatchnos[-1]),'id="trpbatchnos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-3">
<label>IGR No(For Fresh Sand)</label>
<?php echo form_dropdown('igrnos',$igrnos,set_value('igrnos',$igrnos[-1]),'id="igrnos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
<div class="col-md-3">
<label>IGR Line Item No</label>
<?php echo form_dropdown('igrlinenos',$igrlinenos,set_value('igrlinenos',$igrlinenos[-1]),'id="igrlinenos"' ,'class="form-control select2','style="text-align:center;"');?>
</div>
</div><br>
<div class="row">
<div class="col-md-offset-11 col-md-1" id="savebutton">
<input type="button" id="submit" value = "Add Row" class="btn btn-primary" onclick="addNewRow();">
</div>
</div>
<br/>
<table id="testreport" class="table table-bordered" style="background-color:#fff;font-size:12px;text-align:center;">
<thead style="background-color:#ddf;">
<tr id="firstrowheader"><th>SNO</th><th>Time</th></tr>
<tr id="specname"><th>Particulars</th><th>Time</th></tr>
<tr id="huom"><th rowspan="2" style="text-align:center;">SNO</th><th>Unit</th></tr>
<tr id="spec"><th >Spec</th></tr>
</thead>
<tbody id="specAppend">
</tbody>
</table>
<br>
<p><b>Raw/Packing Material Consumption<b></p>
<table id="finaltable" class="table table-bordered" style="background-color:#fff;font-size:12px;text-align:center;">
<thead style="background-color:#ddf;">
<tr><th>Particulars</th><th>Sand</th><th>Resin</th><th>Hexamine</th><th>CS</th><th>50 Bags</th><th>1 ton Bag</th><th>Production Loss <br> Lump</th><th>Finished Prodcut <br> PCS</th></tr>
<tr><th>Unit</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Kgs</th><th>Nos</th><th>Kgs</th><th>Kgs</th></tr>
</thead>
<tbody id="">
<tr><td>Qty</td><td id="sandtotal">0.00</td><td id="resintotal">0.00</td><td id="hextotal">0.00</td><td id="cstotal">0.00</td><td id="50bagtotal" contenteditable="true">0.00</td><td id="1tonbagtotal" contenteditable="true">0.00</td><td id="lumptotal" contenteditable="true">0.00</td><td id="pcstotal" contenteditable="true">0.00</td></tr>
</tbody>
</table>
<hr>
</div>
<div class="col-md-12">
<div class="row">&nbsp;</div>
<div class="col-md-12">
<div class="col-md-3">
<label>File Upload:</label>
<form id="report_file" name="report_file" enctype="multipart/form-data" accept-charset="utf-8" method="POST" action="">
<input type="file" id="reportfile" name="reportfile">
</form>
</div>
<div class="col-md-9">
<label>Remarks:</label>
<textarea id="remarks" class="form-control" rows="1"></textarea>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<label>Operated By :</label>
<input type="text" id="inspector" class="form-control" value="<?php echo $this->session->userdata ( 'name' );?>" readonly>
<input type="hidden" value="<?php echo $this->session->userdata ( 'userId' );?>">
</div>
<div class="col-md-3 col-md-offset-6 ">
<label>Production In charge :</label>
<?php echo form_dropdown('name="approvedby"',$approvedby,set_value('approvedby',$approvedby[-1]),'id="approvedby"' ,'class="form-control select2', 'style="text-align:center;"');?>
<!-- <input type="text" id="approvedby" class="form-control"> -->
</div>
</div>
<div class="row">&nbsp;</div>
<div>
<div class="row">&nbsp;</div>
<div class="row">
<div class="col-md-3" id="savebutton">
<input type="button" id="submit" value = "Save" class="btn btn-primary" onclick="getAllData();">
</div>
</div>
</div><!-- /.box-body -->
<!-- <div class="box-footer clearfix">
</div> -->
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
$(function () {
$('#monthlylisting').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"aaSorting": [[ 0, "asc" ]],
"info": true,
"autoWidth": true
});
});
</script>
<script>
$(document).ready(function(){
$("#loibutton").click(function(){
$("#loiarea").toggle("slow");
});
$("#afsbutton").click(function(){
$("#afsarea").toggle("slow");
});
$("#chartbutton").click(function(){
$("#chartarea").toggle("slow");
});
$('#batchdate').datepicker({
//minDate : 'year+16',
maxDate : 'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '0:+10'
});
$('#customer').select2();
$('#product').select2();
$('#machines').select2();
$('#igrnos').select2();
$('#trpbatchnos').select2();
$('#approvedby').select2();
$('#igrlinenos').select2();
//show_hide_column(13,false);
}); // End of document on ready funciton
function keyValidate(e)
{
if(((e.which || e.keyCode) == 8) || ((e.which || e.keyCode) == 9) || ((e.which || e.keyCode) == 46) || ((e.which || e.keyCode) == 37) || ((e.which || e.keyCode) == 39) || ((e.which || e.keyCode) == 45))
{
return true;
}
if(e.keyCode == 13)
{
return false;
}
if(((e.which || e.keyCode) < 48) || ((e.which || e.keyCode) > 57))
{
return false;
}
}
$('#product').change(function(){
getAllSpec();
});
$('#customer').change(function(){
getAllSpec();
});
var index = 0;
var allspecs = [];
var allspecvalues = [];
var flag = 0;
var totalcells = 0;
var overallrows = 0;
$('#igrnos').change(function(){
var html = '<option value = -1>Select IGRItemNo</option>';
var igrno = $('#igrnos').val();
//alert(igrno);
$('.content').loader('show');
$.ajax({
data:{param1:igrno},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/getIGRLineNo",
success:function(data) {
$('.content').loader('hide');
// alert(data);
data = JSON.parse(data);
if(data != ''){
$.each(data,function(index,value){
html+='<option value='+value.IGRItemNo+'>'+value.IGRItemNo+'</option>';
});
$('#igrlinenos').find('option').remove();
$('#igrlinenos').append(html);
}
else{
alert('No Line Item Available');
}
}
});
});
function getAllSpec()
{
var p = $('#product').val();
var c = $('#customer').val();
var type = 'RESINBATCHCARD';
if(p == -1 || c == -1)
{
return false;
}
else
{
$('.content').loader('show');
$.ajax({
data:{param1:p,param2:c,param3:type},
//dataType:"json",
type:"POST",
url:"<?php echo base_url() ?>quality/getAllSpecforReport",
success:function(data) {
// alert(data);
data = JSON.parse(data);
//alert(data);
// $('#testreport tbody').remove();
// $('#testreport').append('<tbody id="specAppend"></tbody>');
// $('#testreport2 tbody').remove();
// $('#testreport2').append('<tbody id="specAppend2"></tbody>');
if(data != '')
{
htmlspecname = '';
htmlspecid = '';
htmlspecuom = '';
htmlspec = '';
flag = 1;
$('.content').loader('hide');
$.each(data,function(i,item){
var ide='';
//console.log(item);
//console.log('master1');
ide = item.testtype;
ide = ide.replace(/\s/g, "");
ide = ide.toLowerCase();
htmlspecname +='<td>'+item.testtype+'</td>';
htmlspecid += '<td>'+item.productspecmaster_id+'</td>';
htmlspecuom += '<td>'+item.uom+'</td>';
htmlspec += '<td>'+item.min+'-'+item.max+'</td>';
allspecs.push(ide);
allspecvalues.push(item.min+'-'+item.max);
});
// console.log(allspecs);
//console.log(allspecvalues);
$("#specname").append(htmlspecname);
$("#firstrowheader").append(htmlspecid);
$("#huom").append(htmlspecuom);
$("#spec").append(htmlspec);
document.getElementById('firstrowheader').style.display = 'none';
totalcells = $('#testreport').find('tr').eq(1).find('td');
//console.log(totalcells);
totalcells = totalcells.length;
//alert('totalcellsbefore'+totalcells);
totalcells+=2;
//alert('totalcells'+totalcells);
index +=1;
htmlbody = '';
//var i = 0;
for(i=1;i<=totalcells;i++)
{
if(i == 1)
{
htmlbody+='<tr id='+index+'><td>'+index+'</td>';
//alert('1');
}
else if( i == 2)
{
htmlbody+='<td class="edit" id="time'+index+'" contenteditable="true" onblur="timeCheck(this.id,this.textContent)"></td>';
//alert('not 1');
}
else
{
//var temp = index;
//console.log(allspecs[temp]);
var temp = index+''+allspecs[i-3];
htmlbody+='<td class="edit" id="'+temp+'" contenteditable="true" onkeypress="return keyValidate(event);" onblur="masterCalculationCheck(this.id,this.textContent)"></td>';
//temp++;
}
//alert('inside for loop'+i);
}
htmlbody+='</tr>'
$("#testreport tbody").append(htmlbody);
overallrows++;
// $("#testreport2 tbody").append(htmlmaster2);
}
else
{
alert('No Master Records Found..!');
$('.content').loader('hide');
}
}
});
}
}
function addNewRow()
{
//alert(flag);
if(flag != 1)
{
alert('There is no report,Cannot Save');
return false;
}
index++;
//var htmlrow = '<tr id='+index+'><td contenteditable="true" class="edit" id="time'+index+'">';
var htmlrow = '';
for(i=1;i<=totalcells;i++)
{
if(i == 1)
{
htmlrow+='<tr id='+index+'><td>'+index+'</td>';
//alert('1');
}
else if( i == 2)
{
htmlrow+='<td class="edit" id="time'+index+'" contenteditable="true" onblur="timeCheck(this.id,this.textContent)"></td>';
//alert('not 1');
}
else
{
//var temp = index;
//console.log(allspecs[temp]);
var temp = index+''+allspecs[i-3];
htmlrow+='<td class="edit" id="'+temp+'" contenteditable="true" onkeypress="return keyValidate(event);" onblur="masterCalculationCheck(this.id,this.textContent)"></td>';
//temp++;
}
//alert('inside for loop'+i);
}
htmlrow+='</tr>'
$("#testreport tbody").append(htmlrow);
overallrows++;
}
function timeCheck(id,val)
{
var id = id;
//alert('timecheck'+id);
if(val == '')
{
alert('Please Enter Time..!');
document.getElementById(id).textContent='';
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
return false;
}
if(val.length != 5)
{
alert('Please Enter Valid 24 Hrs Time..!');
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
document.getElementById(id).textContent='';
return false;
}
if(val.length == 5)
{
var cur = val.split(':');
if(isNaN(cur[0]) || isNaN(cur[1]) || cur[0] > 24 || cur[1] > 59)
{
var ide = '#'+id;
//alert(ide);
window.setTimeout(function() {
$(ide).focus();
}, 0);
document.getElementById(id).textContent='';
alert('Please Enter Valid 24Hrs Time Format..!');
return false;
}
}
}
function masterCalculationCheck(id,val)
{
//alert(id+'-'+val);
var totalsandqty = 0;
var totalhexqty = 0;
var totalresinqty = 0;
var totalcsqty = 0;
var ide = id.substr(1);
//alert(ide);
//For Total Sand Calculation
if(ide == 'sand')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalsandqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('sandtotal'))
{
document.getElementById('sandtotal').textContent = parseFloat(totalsandqty);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'hexamine')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalhexqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('hextotal'))
{
document.getElementById('hextotal').textContent = parseFloat(totalhexqty);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'resin')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalresinqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('resintotal'))
{
document.getElementById('resintotal').textContent = parseFloat(totalresinqty);
}
}
//FOr total Hexamine Calculaiton
if(ide == 'cs')
{
for(i=1;i<=overallrows;i++)
{
var tid = i+''+ide;
if(document.getElementById(tid))
{
var currentvalue = document.getElementById(tid).textContent;
if(isNaN(currentvalue) || currentvalue == '')
{
currentvalue = 0.00;
}
totalcsqty +=parseFloat(currentvalue);
}
}
if(document.getElementById('cstotal'))
{
document.getElementById('cstotal').textContent = parseFloat(totalcsqty);
}
}
if(val == '')
{
//alert('Please Enter Time..!');
document.getElementById(id).textContent='0.00';
return false;
}
}
function getAllData()
{
if(flag != 1)
{
alert('Cannot Save');
return false;
}
var testreportdata = $("#testreport").tableToJSON();
var finaltable = $("#finaltable").tableToJSON();
testreportdata=JSON.stringify(testreportdata);
// alert(testreportdata);
finaltable=JSON.stringify(finaltable);
//alert(finaltable);
var productid = $('#product').val();
var customerid = $('#customer').val();
var batchdate = $('#batchdate').val();
var plantname = $('#plantname').val();
var macinecode = $('#machines').val();
var trpbatchcard = $('#trpbatchnos').val();
var igrnos = $('#igrnos').val();
var igrlinenos = $('#igrlinenos').val();
var remarks = $('#remarks').val();
var approvedby = $('#approvedby').val();
if(productid == -1 || customerid == -1 || batchdate == '' || plantname == '' || macinecode == '' || trpbatchcard == -1 || igrlinenos == -1 ||igrnos == -1 || approvedby == -1)
{
alert('Please Enter All Master Details..!');
return false;
}
for(i=1;i<=overallrows;i++)
{
if(document.getElementById('time'+1).textContent == '')
{
alert('Please Enter Time for All Entry..! ');
return false;
}
}
var formData = new FormData();
var reportfile = $("#reportfile").prop('files')[0];
formData.append('rfile',reportfile);
var param1 = productid;
var param2 = customerid;
var param3= batchdate;
var param4 = plantname;
var param5 = macinecode;
var param6 = trpbatchcard;
var param7 = igrnos;
var param8 = igrlinenos;
var param9 = remarks;
var param10 = approvedby;
var param11 = testreportdata;
var param12 = finaltable;
formData.append('param1',param1);
formData.append('param2',param2);
formData.append('param3',param3);
formData.append('param4',param4);
formData.append('param5',param5);
formData.append('param6',param6);
formData.append('param7',param7);
formData.append('param8',param8);
formData.append('param9',param9);
formData.append('param10',param10);
formData.append('param11',param11);
formData.append('param12',param12);
$('.content').loader('show');
$.ajax({
data:formData,
type:"POST",
url:"<?php echo base_url() ?>resinbatchcard/saveTestReportData",
//async : false,
cache : false,
contentType : false,
processData : false,
success:function(data) {
if(data){
alert(data);
$('.content').loader('hide');
window.location = "<?php echo base_url().'resinbatchcard/resinBatchCardLisitng';?>";
}
}
});
}
</script>

View File

@ -0,0 +1,109 @@
<?php
//print_r($records);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Resin Batch Cards List</center>
</h1>
</section>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<!--<center><h3 class="box-title">-->
<div class="box-tools">
<!-- <form action="<?php echo base_url() ?>assetListing" method="POST" id="searchList">-->
<div class="col-md-3">
<a href=" <?php echo base_url().'resinbatchcard';?> " type="button" class="btn btn-primary">Add New</a>
</div>
</form>
</div><!--</h3></center>-->
</div><!-- /.box-header -->
<div class="box-body">
<br/>
<table id="testspecifications" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
<thead style="background-color:#ddf">
<tr>
<th>Resin Batch Card ID</th>
<th>Customer</th>
<th>Grade</th>
<th>Batch Date</th>
<th>IGR Details</th>
<th>Operated By</th>
<th>Production In Charge</th>
</tr>
</thead>
<tbody id="specAppend">
<?php
if(!empty($records))
{
foreach($records as $data)
{
//print_r($data);echo "</br></br>";
?>
<tr> <td><a href="<?php echo base_url()?>resinbatchcard/viewIndReport/<?php echo $data->resinbatch_id ?>"><?php echo $data->resinbatch_id?></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php if(!empty($data->document)){?>
<a target="_blank" href="<?php echo base_url()?>uploads/QAD/<?php echo $data->document ?>"><span class="fa fa-file-o"></span></a>
<?php }?>
</td> <td><?php echo $data->client_name?></td> <td><?php echo $data->product_name;?></td><td style="text-align:right;"><?php echo date_format(date_create($data->batchdate),'d-m-Y');?></td><td><?php echo $data->igrno.'-'.$data->igrlineno;?></td>
<td><?php echo $data->FirstName;?></td><td><?php echo $data->approvedby;?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<p>&nbsp;</p>
<div class="row">
</div>
</div><!-- /.box-body -->
<!-- <div class="box-footer clearfix">
</div> -->
</div><!-- /.box -->
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
$(function () {
$('#testspecifications').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"aaSorting": [[ 0, "asc" ]],
"info": true,
"autoWidth": true,
});
});
</script>