From 8420fe8f50754b9fc5d75042148c2077d9339545 Mon Sep 17 00:00:00 2001 From: velz2020 Date: Fri, 6 Apr 2018 14:17:43 +0530 Subject: [PATCH] RESIN BATCH CARD CHANGE REQUIREMENT --- application/controllers/resinbatchcard.php | 62 +++++- application/models/quality_model.php | 15 +- application/views/editresinbatchcard.php | 229 ++++++++++++++++++--- application/views/newresinbatchcard.php | 197 +++++++++++++++--- 4 files changed, 439 insertions(+), 64 deletions(-) diff --git a/application/controllers/resinbatchcard.php b/application/controllers/resinbatchcard.php index 84b40218..a8d3a829 100644 --- a/application/controllers/resinbatchcard.php +++ b/application/controllers/resinbatchcard.php @@ -25,17 +25,19 @@ class resinbatchcard extends BaseController /** * This function used to load the first screen of the user */ + + function addNewResinBatchCard() { $data['productsoutward'] = $this->quality_model->getAllprodcuts(); $data['customersoutward'] = $this->quality_model->getAllcustomers(); $data['emplist'] = $this->quality_model->getEmplistforReport(); + $data['operatorslist'] = $this->quality_model->getOperatorsListforReport(); $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); } @@ -45,12 +47,13 @@ class resinbatchcard extends BaseController $sql = 'select IGRItemNo from T_IGR_Details where IGRNO = ?'; $res = $this->db->query($sql,array($igrno)); - echo json_encode($res->result()); + echo json_encode($res->result()); } + function resinBatchCardLisitng() { $data['records'] = $this->quality_model->getResinBatchCardTestMasterList(); @@ -82,9 +85,11 @@ class resinbatchcard extends BaseController $totaldata = json_decode($totaldata,true); $createby = $this->session->userdata ( 'userId' ); $document = null; + $resinname = $this->input->post('param13'); + $oplist = $this->input->post('param14'); + $oplist = json_decode($oplist); + - //print_r($masterdata);die(); - //print_r($totaldata); if(!empty($_FILES['rfile']['name'])) { $fs = $this->uploadFile(); @@ -93,6 +98,7 @@ class resinbatchcard extends BaseController $sandtotal = 0; $resintotal = 0; + $catalysttotal = 0; $hextotal = 0; $cstotal = 0; $bags50total = 0; @@ -106,6 +112,7 @@ class resinbatchcard extends BaseController $sandtotal = $tot['Sand']; $resintotal = $tot['Resin']; $hextotal = $tot['Hexamine']; + $catalysttotal = $tot['Catalyst']; $cstotal = $tot['CS']; $bags50total = $tot['50 Bags']; $ton1bagstotal = $tot['1 ton Bag']; @@ -114,8 +121,8 @@ class resinbatchcard extends BaseController } } - $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); + $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,'catalysttotal'=>$catalysttotal,'bags50total'=>$bags50total,'ton1bagstotal'=>$ton1bagstotal,'producitonloss'=>$producitonloss,'finishedproduct'=>$finishedproduct); + $MASTERID = $this->quality_model->saveResinBatchCardMasterTestData($masterreportdata); //echo $MASTERID;die(); @@ -138,6 +145,12 @@ class resinbatchcard extends BaseController } } + foreach($oplist as $op) + { + $nArray = array('master_id'=>$MASTERID,'EmpID'=>$op); + $this->db->insert('T_ResinBatchCard_Operators',$nArray); + } + echo "Report Data Saved Successfully!"; @@ -167,9 +180,15 @@ class resinbatchcard extends BaseController $createby = $this->session->userdata ( 'userId' ); $document = $this->input->post('param13'); $MASTERID = $this->input->post('param14'); + $opstoinsert = $this->input->post('param15'); + $opstodelete = $this->input->post('param16'); - //print_r($masterdata);die(); - //print_r($totaldata); + $opstoinsert = json_decode($opstoinsert); + $opstodelete = json_decode($opstodelete); + // print_r($opstoinsert); + // print_r($opstodelete); + // die(); + //$oplist = json_decode($oplist); if(!empty($_FILES['rfile']['name'])) { @@ -191,6 +210,7 @@ class resinbatchcard extends BaseController $resintotal = 0; $hextotal = 0; $cstotal = 0; + $catalysttotal = 0; $bags50total = 0; $ton1bagstotal = 0; $producitonloss = 0; @@ -203,6 +223,7 @@ class resinbatchcard extends BaseController $resintotal = $tot['Resin']; $hextotal = $tot['Hexamine']; $cstotal = $tot['CS']; + $catalysttotal = $tot['Catalyst']; $bags50total = $tot['50 Bags']; $ton1bagstotal = $tot['1 ton Bag']; $producitonloss = $tot['Production Loss Lump']; @@ -210,7 +231,7 @@ class resinbatchcard extends BaseController } } - $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); + $masterreportdata = array('remarks'=>$remarks,'updatedby'=>$createby,'approvedby'=>$approvedby,'document'=>$document,'sandtotal'=>$sandtotal,'resintotal'=>$resintotal,'hextotal'=>$hextotal,'cstotal'=>$cstotal,'catalysttotal'=>$catalysttotal,'bags50total'=>$bags50total,'ton1bagstotal'=>$ton1bagstotal,'producitonloss'=>$producitonloss,'finishedproduct'=>$finishedproduct); //print_r($masterreportdata); $this->quality_model->updateResinBatchCardMasterTestData($masterreportdata,$MASTERID); @@ -235,6 +256,27 @@ class resinbatchcard extends BaseController } } + if(!empty($opstoinsert)){ + foreach($opstoinsert as $opstins) + { + $tArray = array('master_id'=>$MASTERID,'EmpID'=>$opstins); + $this->db->insert('T_ResinBatchCard_Operators',$tArray); + //print_r($tArray); + } + + } + + if(!empty($opstodelete)){ + foreach($opstodelete as $key => $opstdel) + { + + $this->db->where('master_id',$MASTERID); + $this->db->where('EmpID',$opstdel[$key]); + $this->db->delete('T_ResinBatchCard_Operators'); + //print_r($tArray); + } + + } echo "Report Data Saved Successfully!"; @@ -322,6 +364,8 @@ class resinbatchcard extends BaseController //echo $rbcid; $data['emplist'] = $this->quality_model->getEmplistforReport(); $data['records'] = $this->quality_model->getResinBatchCardDetails($rbcid); + $data['operatorslist'] = $this->quality_model->getOperatorsListforReport(); + $data['existoperatorslist'] = $this->quality_model->getExistOperatorsListforReport($rbcid); //print_r($data['records']);die(); $this->global['pageTitle'] = 'Siddharth : Edit Resin Batch Card'; $this->loadViews("editresinbatchcard", $this->global, $data , NULL); diff --git a/application/models/quality_model.php b/application/models/quality_model.php index f52e30a7..41ba6492 100755 --- a/application/models/quality_model.php +++ b/application/models/quality_model.php @@ -4,7 +4,7 @@ class Quality_model extends CI_Model { function getAllInvoiceNo() { - $this->db->select('invoice_number'); + $this->db->select('invoice_number'); $this->db->from('ip_invoices'); $result = $this->db->get(); return $result->result(); @@ -182,7 +182,20 @@ class Quality_model extends CI_Model //print_r($res->result()); } + function getOperatorsListforReport() + { + $r = $this->db->select('EmpID,FirstName,LastName')->from('T_Employee_Details')->get(); + return $r->result(); + } + function getExistOperatorsListforReport($rbcid) + { + $sql = "select T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName + from T_ResinBatchCard_Operators join T_Employee_Details on T_ResinBatchCard_Operators.EmpID = + T_Employee_Details.EmpID where T_ResinBatchCard_Operators.master_id = ?"; + $r = $this->db->query($sql,array($rbcid)); + return $r->result(); + } function getEmplistforReport() { $this->db->select('T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.Departmentcode,T_DepartmentDetails.shortName,'); diff --git a/application/views/editresinbatchcard.php b/application/views/editresinbatchcard.php index ef324154..ad87abd6 100644 --- a/application/views/editresinbatchcard.php +++ b/application/views/editresinbatchcard.php @@ -23,6 +23,12 @@ background-color:#ada5d2 ; 'Select Employee'); +foreach($operatorslist as $re) +{ + + $operators[$re->EmpID] = $re->EmpID.'-'.$re->FirstName.'-'.$re->LastName; +} $approvedby = array(-1=>'Select Approver Name'); foreach($emplist as $r) { @@ -67,16 +73,16 @@ th{
-
+
-
+
-
+
@@ -85,49 +91,59 @@ th{ -
+
- -
+
+
+
+ + + +
+ + +
-
-
+ + -
+
-
+ +
+
+ +
- -
- -
+
+
-
+
- +

 



@@ -184,12 +200,12 @@ th{

Raw/Packing Material Consumption

- - + + - +
ParticularsSandResinHexamineCS50 Bags1 ton BagProduction Loss
Lump
Finished Prodcut
PCS
UnitKgsKgsKgsKgsKgsNosKgsKgs
ParticularsSandResinHexamineCSCatalyst50 Bags1 ton BagProduction Loss
Lump
Finished Prodcut
PCS
UnitKgsKgsKgsKgsKgsKgsNosKgsKgs
Qtysandtotal;?>resintotal;?>hextotal;?>cstotal;?>bags50total;?>ton1bagstotal;?>producitonloss;?>finishedproduct;?>
Qtysandtotal;?>resintotal;?>hextotal;?>cstotal;?>catalysttotal;?>bags50total;?>ton1bagstotal;?>producitonloss;?>finishedproduct;?>

@@ -220,7 +236,20 @@ th{
-
+
+ + + + +
+
@@ -230,12 +259,15 @@ th{
- +
- -
+
+ + +
+
@@ -296,7 +328,7 @@ $(document).ready(function(){ $('#approvedby').val('approvedby?>'); - + $('#operators').select2(); @@ -667,6 +699,48 @@ function masterCalculationCheck(id,val) } } + if(ide == 'catalyst') + { + 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('catalysttotal')) + { + document.getElementById('catalysttotal').textContent = parseFloat(totalsandqty); + } + } + else if(ide2 == 'catalyst') + { + for(i=1;i<=overallrows;i++) + { + var tid = i+''+ide2; + if(document.getElementById(tid)) + { + var currentvalue = document.getElementById(tid).textContent; + if(isNaN(currentvalue) || currentvalue == '') + { + currentvalue = 0.00; + } + totalsandqty +=parseFloat(currentvalue); + } + } + if(document.getElementById('catalysttotal')) + { + document.getElementById('catalysttotal').textContent = parseFloat(totalsandqty); + } + + } + //FOr total Hexamine Calculaiton @@ -767,7 +841,21 @@ function masterCalculationCheck(id,val) } +var listopsforstore = []; +var opstodelete = []; +var opstoinsert =[]; +var oldops = []; +EmpID."');"; + echo "oldops.push('".$ex->EmpID."');"; + + } +?> + +console.log(listopsforstore+'-'+oldops); function getAllData() { @@ -797,7 +885,7 @@ function masterCalculationCheck(id,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) + if(approvedby == -1 || listopsforstore.length == 0) { alert('Please Enter All Master Details..!'); return false; @@ -840,6 +928,9 @@ function masterCalculationCheck(id,val) var param12 = finaltable; var param13 = olddoc; var param14 = MASTERID; + var param15 = JSON.stringify(opstoinsert); + var param16 = JSON.stringify(opstodelete); + formData.append('param1',param1); formData.append('param2',param2); @@ -855,6 +946,8 @@ function masterCalculationCheck(id,val) formData.append('param12',param12); formData.append('param13',param13); formData.append('param14',param14); + formData.append('param15',param15); + formData.append('param16',param16); $('.content').loader('show'); @@ -880,7 +973,91 @@ function masterCalculationCheck(id,val) } - + $('#operators').change(function(){ + + var val = $('#operators').val(); + var text = $("#operators option:selected").text(); + //alert(val); + //alert(text); + var totalelements = listopsforstore.length + + if(totalelements != 0) + { + $.each(listopsforstore,function(key,value){ + //alert(value); + if(value == val) + { + alert('Operator Already Added..!Choose Another One.!'); + brea(); + } + + + }); + } + + listopsforstore.push(val); + + var locali = 0; + $.each(oldops,function(key,value){ + //alert(value); + if(value == val) + { + //nothing + } + else + { + //opstoinsert.push(val); + locali++; + } + }); + if(locali != 0) + { + opstoinsert.push(val); + } + + opstodelete = opstodelete.filter(item => item != val); + console.log('INSERT-'+opstoinsert); + console.log('OLD-'+oldops); + console.log('DELETE-'+opstodelete); + console.log('CURRENT-'+listopsforstore); + console.log('*************************'); + $("#listops").append(''); + + }); + + $("#listops").dblclick(function(){ + var text = $("#listops option:selected").text(); + var val = $('#listops').val(); + + //alert(text+'-'+val); + $('option:selected', this).remove(); + listopsforstore = listopsforstore.filter(item => item != val); + + var localj = 0; + // if(totalelements != 0) + // { + $.each(oldops,function(key,value){ + //alert(value); + if(value == val) + { + localj++; + } + + + }); + + if(localj != 0){ opstodelete.push(val);} + + opstoinsert = opstoinsert.filter(item => item != val); + // }else{opstodelete.push(val);} + console.log('INSERT-'+opstoinsert); + console.log('OLD-'+oldops); + console.log('DELETE-'+opstodelete); + console.log('CURRENT-'+listopsforstore); + console.log('*************************'); + + + }); diff --git a/application/views/newresinbatchcard.php b/application/views/newresinbatchcard.php index 28589a44..428d584f 100644 --- a/application/views/newresinbatchcard.php +++ b/application/views/newresinbatchcard.php @@ -24,6 +24,15 @@ background-color:#ada5d2 ; 'Select Employee'); +foreach($operatorslist as $re) +{ + + $operators[$re->EmpID] = $re->EmpID.'-'.$re->FirstName.'-'.$re->LastName; +} + $products = array(-1=>'Select Product'); foreach($productsoutward as $rec) { @@ -100,14 +109,15 @@ th{
-
-
+
+ +
-
+
@@ -119,48 +129,63 @@ th{
--> -
+
-
- - - -
+ +
+
+
-
+
+ + + +
+
+ + + +
-
+
-
+ + + +
+
+
+
- +
-
+
-
+
+ +
+ + - -

- -
+

 

@@ -184,12 +209,12 @@ th{

Raw/Packing Material Consumption

SNOTime
- - + + - +
ParticularsSandResinHexamineCS50 Bags1 ton BagProduction Loss
Lump
Finished Prodcut
PCS
UnitKgsKgsKgsKgsKgsNosKgsKgs
ParticularsSandResinHexamineCSCatalyst50 Bags1 ton BagProduction Loss
Lump
Finished Prodcut
PCS
UnitKgsKgsKgsKgsKgsKgsNosKgsKgs
Qty0.000.000.000.000.000.000.000.00
Qty0.000.000.000.000.000.000.000.000.00

@@ -219,7 +244,15 @@ th{
-
+
+ + + + +
+
@@ -229,12 +262,16 @@ th{
- +
+
+ + +
-
+
@@ -302,6 +339,7 @@ $(document).ready(function(){ $('#trpbatchnos').select2(); $('#approvedby').select2(); $('#igrlinenos').select2(); + $('#operators').select2(); //show_hide_column(13,false); @@ -708,6 +746,49 @@ function masterCalculationCheck(id,val) } + if(ide == 'catalyst') + { + 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('catalysttotal')) + { + document.getElementById('catalysttotal').textContent = parseFloat(totalsandqty); + } + } + else if(ide2 == 'catalyst') + { + for(i=1;i<=overallrows;i++) + { + var tid = i+''+ide2; + if(document.getElementById(tid)) + { + var currentvalue = document.getElementById(tid).textContent; + if(isNaN(currentvalue) || currentvalue == '') + { + currentvalue = 0.00; + } + totalsandqty +=parseFloat(currentvalue); + } + } + if(document.getElementById('catalysttotal')) + { + document.getElementById('catalysttotal').textContent = parseFloat(totalsandqty); + } + + } + + //FOr total Hexamine Calculaiton @@ -808,7 +889,7 @@ function masterCalculationCheck(id,val) - +var listopsforstore = []; //This one for Geeting all operators list function getAllData() { @@ -829,18 +910,26 @@ function masterCalculationCheck(id,val) var customerid = $('#customer').val(); var batchdate = $('#batchdate').val(); var plantname = $('#plantname').val(); + var resinname = $('#resinname').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) + if(productid == -1 || customerid == -1 || batchdate == '' || plantname == '' || macinecode == -1 || approvedby == -1 || listopsforstore.length == 0 || resinname == '') { alert('Please Enter All Master Details..!'); return false; } + + if(( igrnos == -1 || igrlinenos == -1) && trpbatchcard == -1 ) + { + alert('Please Enter All Master Details...!'); + return false; + } var f = 0; for(i=1;i<=overallrows;i++) { @@ -864,7 +953,19 @@ function masterCalculationCheck(id,val) - + listopsforstore = JSON.stringify(listopsforstore); + if(trpbatchcard == -1 ) + { + trpbatchcard =""; + } + if(igrnos == -1 ) + { + igrnos = ""; + } + if(igrlinenos == -1 ) + { + igrlinenos = ""; + } var formData = new FormData(); var reportfile = $("#reportfile").prop('files')[0]; formData.append('rfile',reportfile); @@ -881,6 +982,8 @@ function masterCalculationCheck(id,val) var param10 = approvedby; var param11 = testreportdata; var param12 = finaltable; + var param13 = resinname; + var param14 = listopsforstore; formData.append('param1',param1); @@ -895,6 +998,8 @@ function masterCalculationCheck(id,val) formData.append('param10',param10); formData.append('param11',param11); formData.append('param12',param12); + formData.append('param13',param13); + formData.append('param14',param14); $('.content').loader('show'); @@ -921,7 +1026,43 @@ function masterCalculationCheck(id,val) } + $('#operators').change(function(){ + + var val = $('#operators').val(); + var text = $("#operators option:selected").text(); + //alert(val); + //alert(text); + var totalelements = listopsforstore.length + + if(totalelements != 0) + { + $.each(listopsforstore,function(key,value){ + //alert(value); + if(value == val) + { + alert('Operator Already Added..!Choose Another One.!'); + brea(); + } + + + }); + } + listopsforstore.push(val); + //console.log(listopsforstore); + $("#listops").append(''); + + }); + $("#listops").dblclick(function(){ + var text = $("#listops option:selected").text(); + var val = $('#listops').val(); + + //alert(text+'-'+val); + $('option:selected', this).remove(); + listopsforstore = listopsforstore.filter(item => item != val); + //console.log(listopsforstore); + + });