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 */ 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); } 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; $resinname = $this->input->post('param13'); $oplist = $this->input->post('param14'); $oplist = json_decode($oplist); if(!empty($_FILES['rfile']['name'])) { $fs = $this->uploadFile(); $document = $fs; } $sandtotal = 0; $resintotal = 0; $catalysttotal = 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']; $catalysttotal = $tot['Catalyst']; $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,'resinname'=>$resinnname,'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(); //$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); } } } foreach($oplist as $op) { $nArray = array('master_id'=>$MASTERID,'EmpID'=>$op); $this->db->insert('T_ResinBatchCard_Operators',$nArray); } 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'); $opstoinsert = $this->input->post('param15'); $opstodelete = $this->input->post('param16'); $opstoinsert = json_decode($opstoinsert); $opstodelete = json_decode($opstodelete); // print_r($opstoinsert); // print_r($opstodelete); // die(); //$oplist = json_decode($oplist); 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; $catalysttotal = 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']; $catalysttotal = $tot['Catalyst']; $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,'catalysttotal'=>$catalysttotal,'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); } } } 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!"; } 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); $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); } } ?>