diff --git a/application/controllers/resinbatchcard.php b/application/controllers/resinbatchcard.php new file mode 100644 index 00000000..7c49b6b6 --- /dev/null +++ b/application/controllers/resinbatchcard.php @@ -0,0 +1,332 @@ +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); + + } +} + +?> diff --git a/application/models/quality_model.php b/application/models/quality_model.php index 1305ae01..f52e30a7 100755 --- a/application/models/quality_model.php +++ b/application/models/quality_model.php @@ -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(); + } } ?> \ No newline at end of file diff --git a/application/views/editresinbatchcard.php b/application/views/editresinbatchcard.php new file mode 100644 index 00000000..64481fa2 --- /dev/null +++ b/application/views/editresinbatchcard.php @@ -0,0 +1,885 @@ + +'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; +// } + +?> + + + + + +
+ +
+

+
Edit Resin Batch Card
+

+
+
+ + +
+
+
+
+ +
+ +
+ +
+
+ +
+ + +
+ +
+ +
+ + + + +
+ +
+ + + +
+ + + + + +
+ + + +
+ +
+ + + +
+ +
+ +
+ + +
+ + + +
+ + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + +

+
+
+ +
+
+
+ + + + + + + + + + + + $value) + { + //print_r($value); + ?> + + $v) + { + if($key == 0){ + ?> + + + + + + + + + + +
SNOTime
ParticularsTime
SNOUnit
Spec
+
+

Raw/Packing Material Consumption

+ + + + + + + + + +
ParticularsSandResinHexamineCS50 Bags1 ton BagProduction Loss
Lump
Finished Prodcut
PCS
UnitKgsKgsKgsKgsKgsNosKgsKgs
Qtysandtotal;?>resintotal;?>hextotal;?>cstotal;?>bags50total;?>ton1bagstotal;?>producitonloss;?>finishedproduct;?>
+
+ + + + + +
+ + +
+ + + + + + + + + +
 
+
+
+ +
+ + +
+
+
+ + + + +
+
+
+ +
+ + + +
+ +
+ + + +
+ +
+ +
 
+
+
 
+
+
+ +
+
+
+ +
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/application/views/includes/header.php b/application/views/includes/header.php index 8aaba6a1..35c92080 100755 --- a/application/views/includes/header.php +++ b/application/views/includes/header.php @@ -361,7 +361,8 @@ $(function() { - + + @@ -388,6 +389,7 @@ $(function() { New Nissan In Process Inspection + @@ -547,7 +549,7 @@ $(function() { - + @@ -1241,7 +1243,7 @@ $(function() { - +
  • @@ -1261,7 +1263,7 @@ $(function() { Inward Material Test Report
  • - + +
    +

    +
    New Resin Batch Card Screen
    +

    +
    +
    + + +
    +
    +
    +
    + +
    + +
    + +
    +
    + +
    + + +
    + +
    + +
    + + +
    + +
    + + +
    + + + + + +
    + + + +
    + +
    + + + +
    + +
    + +
    + + +
    + + +
    + + +
    + + +
    + +
    + + +
    + +
    + + +
    + + +

    +
    +
    + +
    +
    +
    + + + + + + + + + + + + + +
    SNOTime
    ParticularsTime
    SNOUnit
    Spec
    +
    +

    Raw/Packing Material Consumption

    + + + + + + + + + +
    ParticularsSandResinHexamineCS50 Bags1 ton BagProduction Loss
    Lump
    Finished Prodcut
    PCS
    UnitKgsKgsKgsKgsKgsNosKgsKgs
    Qty0.000.000.000.000.000.000.000.00
    +
    + + + + + +
    + + +
    + + + + + + + + + +
     
    +
    +
    + +
    + +
    +
    +
    + + + + +
    +
    +
    + +
    + + + +
    + +
    + + + +
    + +
    + +
     
    +
    +
     
    +
    +
    + +
    +
    +
    + +
    +
    +
    + + + + + + + + + + + \ No newline at end of file diff --git a/application/views/resinbatchcardreportlist.php b/application/views/resinbatchcardreportlist.php new file mode 100644 index 00000000..5448b90c --- /dev/null +++ b/application/views/resinbatchcardreportlist.php @@ -0,0 +1,109 @@ + + +
    + +
    +

    +
    Resin Batch Cards List
    +

    +
    +
    + + +
    +
    +
    +
    + +
    + +
    + Add New +
    + + +
    + +
    + + +
    + + +
    + + + + + + + + + + + + + + + + + + +
    "; + ?> + + + + + +
    Resin Batch Card IDCustomerGradeBatch DateIGR DetailsOperated ByProduction In Charge
    resinbatch_id?>      + document)){?> + + + client_name?> product_name;?>batchdate),'d-m-Y');?>igrno.'-'.$data->igrlineno;?>FirstName;?>approvedby;?>
    +

     

    +
    + +
    +
    + +
    +
    +
    +
    +
    + +