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['products'] = $this->quality_model->getAllprodcuts(); $data['customers'] = $this->quality_model->getAllcustomers(); $data['existspec'] = $this->quality_model->getAllspec(); $this->global['pageTitle'] = 'Siddharth : Quality Master'; $this->loadViews("qualitymasterlistview", $this->global, $data , NULL); } public function reportList() { $data['records'] = $this->quality_model->getTestMasterforList(); $this->global['pageTitle'] = 'Siddharth : Quality Master'; $this->loadViews("reportmasterlist", $this->global, $data , NULL); } function addNewPage() { $data['products'] = $this->quality_model->getAllprodcuts(); $data['customers'] = $this->quality_model->getAllcustomers(); $this->global['pageTitle'] = 'Siddharth : Quality Master'; $this->loadViews("qualitymaster", $this->global, $data , NULL); } function saveSpectficationData() { $product = $this->input->post('param2'); $customer = $this->input->post('param3'); $jsondata = $this->input->post('param1'); $createdby = $this->session->userdata ( 'userId' ); $phpdata = json_decode($jsondata); $total = 0; // echo $product .'-'. $customer; // print_r($phpdata);die(); 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); //echo $isExist[0]->count;die(); if($isExist[0]->count == 0) { $tostore = array('customer_id'=>$customer,'product_id'=>$product,'testtype'=>$name,'uom'=>$uom,'min'=>$min,'max'=>$max,'temp'=>$temp,'created_by'=>$createdby); $res = $this->quality_model->addSpecMast($tostore); //echo 'i'.$res; } else if($isExist[0]->count == 1) { $tostore = array('uom'=>$uom,'min'=>$min,'max'=>$max,'temp'=>$temp,'updated_by'=>$createdby); $res = $this->quality_model->updateSpecMast($tostore,$product,$customer,$name); //echo 'u'.$res; } $total +=$res; } echo $total.'- Specification Saved Successfully'; } 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"; } } function report() { $data['records'] = $this->quality_model->getDataforReport(); $data['emplist'] = $this->quality_model->getEmplistforReport(); $this->global['pageTitle'] = 'Siddharth : Inspection Report Screen'; $this->loadViews("qualityreport", $this->global, $data, NULL); } function viewSpec() { $prodcutid = $this->uri->segment(3); $customerid =$this->uri->segment(4); $data['specifications'] = $this->quality_model->getIndividualSpec($prodcutid,$customerid); $this->global['pageTitle'] = 'Siddharth : View reports Lists'; $this->loadViews("viewIndSpec", $this->global, $data, NULL); } function viewIndReport() { $reportid = $this->uri->segment(3); $data['reportdata'] = $this->quality_model->getIndividualReportData($reportid); $this->global['pageTitle'] = 'Siddharth : View Individual Report'; $this->loadViews("viewindreport", $this->global, $data, NULL); } function printReportPDF() { $reportid = $this->input->post('rid'); $data['reportdata'] = $this->quality_model->getIndividualReportData($reportid); $filename = 'PRE DESPATCH INSPECTION REPORT'.$reportid; $html = $this->load->View("viewindreportpdf",$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',$php); } function getAllSpecforReport() { $productid = $this->input->post('param1'); $customerid = $this->input->post('param2'); //echo 'from cn'.$productid.'-'.$customerid; $res = $this->quality_model->getSpecifications($productid,$customerid); echo json_encode($res); } 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); //print_r($afsphpdata);die(); $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) { //print_r($data);die(); $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']; //echo $loip; //echo $remark;die(); $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 pageNotFound() { $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>