load->model('quality_model'); $this->load->library('form_validation'); $this->isLoggedIn(); $this->CompanyName = $this->global['CompanyName']; } /** * Index Page for this controller(default function of the class) */ public function index() { $data['products'] = $this->quality_model->getAllprodcuts(); $data['customers'] = $this->quality_model->getAllcustomers(); $data['existspec'] = $this->quality_model->getAllspec(); $data['existspecinward'] = $this->quality_model->getAllspecInward(); // $this->global['pageTitle'] = 'Resico : Quality Master'; $this->global['pageTitle'] = $this->CompanyName.' : Quality Master'; $this->loadViews("qualitymasterlistview", $this->global, $data , NULL); } /** * For load the report list */ public function reportList() { $data['records'] = $this->quality_model->getTestMasterforList(); // $this->global['pageTitle'] = 'Resico : Prodcut Report List '; $this->global['pageTitle'] = $this->CompanyName.' : Report List'; $this->loadViews("reportmasterlist", $this->global, $data , NULL); } /** * For quality Inward Report list */ public function reportListInward() { $data['records'] = $this->quality_model->getTestMasterforListInward(); //$this->global['pageTitle'] = 'Resico : Report List Inward'; $this->global['pageTitle'] = $this->CompanyName.' : Report List Inward'; $this->loadViews("reportmasterlist_inward", $this->global, $data , NULL); } /** * To add new Specifications */ function addNewPage() { $data['productsoutward'] = $this->quality_model->getAllprodcuts(); $data['customersoutward'] = $this->quality_model->getAllcustomers(); $data['productsinward'] = $this->quality_model->getAllprodcutsInward(); $data['customersinward'] = $this->quality_model->getAllcustomersInward(); //$this->global['pageTitle'] = 'Resico : Quality Master'; $this->global['pageTitle'] = $this->CompanyName.' : Quality Master'; $this->loadViews("qualitymaster", $this->global, $data , NULL); } /** * To save specification information based on customerid and productid */ function saveSpectficationData() { $product = $this->input->post('param2'); $customer = $this->input->post('param3'); $jsondata = $this->input->post('param1'); $type = $this->input->post('param4'); $createdby = $this->session->userdata ( 'userId' ); $phpdata = json_decode($jsondata); $total = 0; foreach($phpdata as $data) { $name = $data->Name; $name = strtoupper($name); $uom = $data->UOM; $min = $data->Min; $max = $data->Max; $temp = $data->Temp; $isExist = $this->quality_model->checkExist($product,$customer,$name); if($isExist[0]->count == 0) { $tostore = array('customer_id'=>$customer,'product_id'=>$product,'testtype'=>$name,'uom'=>$uom,'min'=>$min,'max'=>$max,'temp'=>$temp,'type'=>$type,'created_by'=>$createdby); $res = $this->quality_model->addSpecMast($tostore); } else if($isExist[0]->count == 1) { $tostore = array('uom'=>$uom,'min'=>$min,'max'=>$max,'temp'=>$temp,'type'=>$type,'updated_by'=>$createdby); $res = $this->quality_model->updateSpecMast($tostore,$product,$customer,$name); } $total +=$res; } echo $total.'- Specification Saved Successfully'; } /** * To delete specification based on Specification name, customerid and productid */ function deleteSpecification() { $spname = $this->input->post('param1'); $product = $this->input->post('param2'); $customer = $this->input->post('param3'); $res = $this->quality_model->deleteSpecification($spname,$product,$customer); if($res == 1) { echo "Deleted Successfully..!"; } else { echo "Something Went Wrong..!Try later"; } } /** * To view inspection reports */ function report() { $data['records'] = $this->quality_model->getDataforReport(); $data['emplist'] = $this->quality_model->getEmplistforReport(); //$this->global['pageTitle'] = 'Resico : Inspection Report Screen'; $this->global['pageTitle'] = $this->CompanyName.' : Inspection Report Screen'; $this->loadViews("qualityreport", $this->global, $data, NULL); } /** * To view the report list */ function viewSpec() { $prodcutid = $this->uri->segment(3); $customerid =$this->uri->segment(4); $data['specifications'] = $this->quality_model->getIndividualSpec($prodcutid,$customerid); //$this->global['pageTitle'] = 'Resico : View reports Lists'; $this->global['pageTitle'] = $this->CompanyName.' : View reports Lists'; $this->loadViews("viewIndSpec", $this->global, $data, NULL); } /** * To view the indiviual report */ function viewIndReport() { $reportid = $this->uri->segment(3); $data['reportdata'] = $this->quality_model->getIndividualReportData($reportid); //$this->global['pageTitle'] = 'Resico : View Individual Report'; $this->global['pageTitle'] = $this->CompanyName.' : View Individual Report'; $this->loadViews("viewindreport", $this->global, $data, NULL); } function viewIndInwardReport() { $reportid = $this->uri->segment(3); $data['reportdata'] = $this->quality_model->getIndividualInwardReportData($reportid); //$this->global['pageTitle'] = 'Resico : View Individual Report'; $this->global['pageTitle'] = $this->CompanyName.' : View Individual Report'; $this->loadViews("viewindInwardreport", $this->global, $data, NULL); } /** * To Generate the Reports as pdf */ 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->SetTitle('Resico : PDF');*/ $mpdf->list_indent_first_level = 1; $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; $mpdf->WriteHTML($html); $mpdf->Output($filename.'.pdf','I'); } /** * To get all data based on product id and customer id */ function getAllSpecforReport() { $productid = $this->input->post('param1'); $customerid = $this->input->post('param2'); $res = $this->quality_model->getSpecifications($productid,$customerid); echo json_encode($res); } /** * To save report data */ function saveTestReportData() { date_default_timezone_get('Asia/Kolkata'); $testjson = $this->input->post('param1'); $loijson = $this->input->post('param2'); $afsjson = $this->input->post('param3'); $invoiceno = $this->input->post('param4'); $batchno = $this->input->post('param5'); $chart = $this->input->post('param7'); $batchno = date_format(date_create($batchno),'Y-m-d'); $approver = $this->input->post('param6'); $testphpdata = json_decode($testjson,true); $loiphpdata = json_decode($loijson,true); $afsphpdata = json_decode($afsjson,true); $createdon = date('Y-m-d H:i:s'); $createby = $this->session->userdata ( 'userId' ); $masterreportdata = array('invoiceid'=>$invoiceno,'batchdate'=>$batchno,'createdby'=>$createby,'createdon'=>$createdon,'approvedby'=>$approver,'chartdata'=>$chart); $MASTERID = $this->quality_model->saveMasterTestData($masterreportdata); $descrition = ''; $min = ''; $max = ''; $uom = ''; $act1 = ''; $act2 = ''; $act3 = ''; $average = ''; $results = ''; $remarks1 = ''; foreach($testphpdata as $data) { $descrition = $data['Description']; $min = $data['SpecificationMin']; $max = $data['SpecificationMax']; $uom = $data['SpecificationUOM']; $act1 = $data['ACT X1']; $act2 = $data['ACT X2']; $act3 = $data['ACT X3']; $average = $data['Average']; $results = $data['Results']; $remarks1 = $data['Remarks']; $testreportdata = array('testreport_id'=>$MASTERID,'description'=>$descrition,'min'=>$min,'max'=>$max,'UOM'=>$uom,'act1'=>$act1,'act2'=>$act2,'act3'=>$act3,'average'=>$average,'result'=>$results,'remarks'=>$remarks1); $reportid = $this->quality_model->saveTestReportData($testreportdata); } $start = ''; $end = ''; $temp = ''; $w1 = ''; $w2 = ''; $w3 = ''; $loip = ''; $remark = ''; foreach($loiphpdata as $loi) { $start = $loi['Heating Timestart']; $end = $loi['Heating Timeend']; $temp = $loi['Temp *c']; $w1 = $loi['Crucible Weight w1(g)']; $w2 = $loi['Before Heatingw2(g)']; $w3 = $loi['After Heatingw3(g)']; $loip = $loi['L.O.I %']; $remark = $loi['Remarks']; $loitabledata = array('testreport_id'=>$MASTERID,'start_time'=>$start,'end_time'=>$end,'temp'=>$temp,'w1'=>$w1,'w2'=>$w2,'w3'=>$w3,'loi_percentage'=>$loip,'remarks'=>$remark); $loiid = $this->quality_model->saveTestReportLOIData($loitabledata); } $count =0; foreach($afsphpdata as $afs) { $count++; if($count != 12){ $ssize = $afs['Sieve Size µm']; $sandweight = $afs['Sand Weight']; $Percentage = $afs['Percentage']; $Multiplier = $afs['Multiplier']; $Product = $afs['Product']; $afstabledata = array('testreport_id'=>$MASTERID,'sieve_size'=>$ssize,'sandweight'=>$sandweight,'percentage'=>$Percentage,'multiplier'=>$Multiplier,'product'=>$Product); $afsid = $this->quality_model->saveTestReportAFSData($afstabledata); } } echo "Report Data Saved Successfully!"; } function saveInwardTestReportData() { date_default_timezone_get('Asia/Kolkata'); $testjson = $this->input->post('param1'); $loijson = $this->input->post('param2'); $afsjson = $this->input->post('param3'); $igrno = $this->input->post('param4'); $igrlineitemno = $this->input->post('param5'); $chart = $this->input->post('param7'); $report_date = $this->input->post('param8'); $report_date = date_format(date_create($report_date),'Y-m-d'); $approver = $this->input->post('param6'); $testphpdata = json_decode($testjson,true); $loiphpdata = json_decode($loijson,true); $afsphpdata = json_decode($afsjson,true); $createdon = date('Y-m-d H:i:s'); $createby = $this->session->userdata ( 'userId' ); $masterreportdata = array('igrno'=>$igrno,'igrlineitemno'=>$igrlineitemno,'batchdate'=>$report_date,'createdby'=>$createby,'createdon'=>$createdon,'approvedby'=>$approver,'chartdata'=>$chart); $MASTERID = $this->quality_model->saveMasterTestData($masterreportdata); foreach($testphpdata as $data) { $descrition = $data['Description']; $min = $data['SpecificationMin']; $max = $data['SpecificationMax']; $uom = $data['SpecificationUOM']; $act1 = $data['ACT X1']; $act2 = $data['ACT X2']; $act3 = $data['ACT X3']; $average = $data['Average']; $results = $data['Results']; $remarks1 = $data['Remarks']; $testreportdata = array('testreport_id'=>$MASTERID,'description'=>$descrition,'min'=>$min,'max'=>$max,'UOM'=>$uom,'act1'=>$act1,'act2'=>$act2,'act3'=>$act3,'average'=>$average,'result'=>$results,'remarks'=>$remarks1); $reportid = $this->quality_model->saveTestReportData($testreportdata); } foreach($loiphpdata as $loi) { $start = $loi['Heating Timestart']; $end = $loi['Heating Timeend']; $temp = $loi['Temp *c']; $w1 = $loi['Crucible Weight w1(g)']; $w2 = $loi['Before Heatingw2(g)']; $w3 = $loi['After Heatingw3(g)']; $loip = $loi['L.O.I %']; $remark = $loi['Remarks']; $loitabledata = array('testreport_id'=>$MASTERID,'start_time'=>$start,'end_time'=>$end,'temp'=>$temp,'w1'=>$w1,'w2'=>$w2,'w3'=>$w3,'loi_percentage'=>$loip,'remarks'=>$remark); $loiid = $this->quality_model->saveTestReportLOIData($loitabledata); } $count =0; foreach($afsphpdata as $afs) { $count++; if($count != 12){ $ssize = $afs['Sieve Size µm']; $mesh_size = $afs['Mesh Size']; $sandweight = $afs['Sand Weight']; $Percentage = $afs['Percentage']; $Multiplier = $afs['Multiplier']; $Product = $afs['Product']; $afstabledata = array('testreport_id'=>$MASTERID,'sieve_size'=>$ssize,'mesh_size'=>$mesh_size,'sandweight'=>$sandweight,'percentage'=>$Percentage,'multiplier'=>$Multiplier,'product'=>$Product); $afsid = $this->quality_model->saveTestReportAFSData($afstabledata); } } echo "Report Data Saved Successfully!"; } function addNewInward_Report() { $data['records'] = $this->quality_model->getIGRNOforReport(); $data['reports'] = $this->quality_model->getIGRNOReport(); $data['emplist'] = $this->quality_model->getEmplistforReport(); //$this->global['pageTitle'] = 'Resico : Inward Inspection'; $this->global['pageTitle'] = $this->CompanyName.' : Inward Inspection'; $this->loadViews("inward_report_create", $this->global,$data,NULL); } function getIGRLineItemNo() { $igrno = $this->input->post('param1'); $data['igrdetails'] = $this->quality_model->getIGRLineItemNo($igrno); echo json_encode($data['igrdetails']); } function getIGRDetails() { $igrno = $this->input->post('param1'); $igrlineitemno = $this->input->post('param2'); $data['igrdetails'] = $this->quality_model->getIGRDataforReport($igrno,$igrlineitemno); echo json_encode($data['igrdetails']); } /** * To load pagenotfound view */ function pageNotFound() { //$this->global['pageTitle'] = 'Resico : 404 - Page Not Found'; $this->global['pageTitle'] = $this->CompanyName.': 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>