siddharth_application/application/controllers/inprocess.php
2018-02-24 13:06:23 +05:30

897 lines
29 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : purchaseorder (PurchaseorderController)
* User Class to control all user related operations.
* @author : VenbaMail Mali
* @version : 1.1
* @since : 15 Feb 2016
*/
class inprocess extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->isLoggedIn();
$this->load->model('quality_model');
$this->load->model('inprocess_model');
$this->load->library('form_validation');
//$this->load->library('dompdf_gen');
}
/**
* This function used to load the first screen of the user
*/
public function index()
{
$data['reportlist'] = $this->inprocess_model->getAllTestReports();
$this->global['pageTitle'] = 'Siddharth : Inprocess Test Reports List';
$this->loadViews("reportlist_inprocesstest", $this->global, $data , NULL);
}
public function addNewInprocessInspection()
{
$data['productsoutward'] = $this->quality_model->getAllprodcuts();
$data['customersoutward'] = $this->quality_model->getAllcustomers();
$data['emplist'] = $this->quality_model->getEmplistforReport();
$this->global['pageTitle'] = 'Siddharth : New Inprcess Test Report ';
$this->loadViews("newinprocessreport", $this->global, $data , NULL);
}
function addNewNissanInprocessInspection()
{
$data['productsoutward'] = $this->quality_model->getAllprodcuts();
$data['customersoutward'] = $this->quality_model->getAllcustomers();
$data['emplist'] = $this->quality_model->getEmplistforReport();
$this->global['pageTitle'] = 'Siddharth : New Inprcess Test Report ';
$this->loadViews("newnissaninprocessreport", $this->global, $data , NULL);
}
function editIndInprocessReport()
{
$rid = $this->uri->segment(3);
$data['reportdata'] = $this->inprocess_model->getIndividualInprocessReportData($rid);
$pspecid = null;
$psubtype = null;
$time = null;
$temparray = array();
$time = array();
$index = 0;
foreach($data['reportdata']['masterreport'] as $key => $d)
{
if($pspecid != $d->specid){
$index++;
$temparray[$index] = array('specid'=>$d->specid,'specname'=>$d->testtype,'smin'=>$d->min,'smax'=>$d->max,'suom'=>$d->uom,'stype'=>$d->subtype,$d->ivalue);
$time = array_merge($time,array($d->itime));
}
else{
array_push($temparray[$index],$d->ivalue);
$time = array_merge($time,array($d->itime));
}
$pspecid = $d->specid;
}
$data['reportdata']['masterreport'] = $temparray;
$data['timearray'] = $time;
$data['emplist'] = $this->quality_model->getEmplistforReport();
if($data['reportdata']['master'][0]->test_type == 0 )
{
$this->global['pageTitle'] = 'Siddharth : Edit Inprocess Report';
$this->loadViews("editInprocessReport", $this->global, $data , NULL);
}
else
{
//echo "Under Developing";
$this->global['pageTitle'] = 'Siddharth : Edit Nissan Inprocess Report';
$this->loadViews("editNissanInprocessReport", $this->global, $data , NULL);
}
}
function getAllSpecforReport()
{
$productid = $this->input->post('param1');
$customerid = $this->input->post('param2');
//echo 'from cn'.$productid.'-'.$customerid;exit();
$res = $this->quality_model->getSpecifications($productid,$customerid);
echo json_encode($res);
}
function saveTestReportData()
{
date_default_timezone_get('Asia/Kolkata');
$testjson = $this->input->post('param1');
$testjson2 = $this->input->post('param2');
$afsjson = $this->input->post('param3');
$loijson = $this->input->post('param4');
$productid = $this->input->post('param5');
$customerid = $this->input->post('param6');
$batchno = $this->input->post('param7');
$batchdate = $this->input->post('param8');
$batchdate = date_format(date_create($batchdate),'Y-m-d');
$plantname = $this->input->post('param9');
$sanddesc = $this->input->post('param10');
$resindesc = $this->input->post('param11');
$qty = $this->input->post('param12');
$times = $this->input->post('param13');
$times = explode(",",$times);
$approvedby = $this->input->post('param14');
$remarks = $this->input->post('param15');
$testphpdata = json_decode($testjson,true);
$testphpdata2 = json_decode($testjson2,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' );
$document = null;
if(!empty($_FILES['rfile']['name']))
{
$fs = $this->uploadFile();
$document = $fs;
}
$masterreportdata = array('productid'=>$productid,'customerid'=>$customerid,'batchno'=>$batchno,'batchdate'=>$batchdate,'plantname'=>$plantname,'sand_description'=>$sanddesc,'resin_description'=>$resindesc,'qty'=>$qty,'remarks'=>$remarks,'document'=>$document,'createdby'=>$createby,'approvedby'=>$approvedby);
$MASTERID = $this->inprocess_model->saveMasterTestData($masterreportdata);
//$MASTERID = 1;
foreach($testphpdata as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 0;
$actarray = array($data['ACT X1'],$data['ACT X2'],$data['ACT X3'],$data['ACT X4'],$data['ACT X5'],$data['ACT X6'],$data['ACT X7'],$data['ACT X8']);
for($i=1;$i<=8;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-1],'ivalue'=>$actarray[$i-1]);
}
$this->inprocess_model->saveTestReportData($temparray);
}
foreach($testphpdata2 as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 1;
$cstarray = array($data['CST X1'],$data['CST X2'],$data['CST X3'],$data['CST X4'],$data['CST X5'],$data['CST X6'],$data['CST X7'],$data['CST X8']);
$rstarray = array($data['RST Y1'],$data['RST Y2'],$data['RST Y3']);
for($i=1;$i<=3;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>'','ivalue'=>$rstarray[$i-1]);
}
for($i=4;$i<=11;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-4],'ivalue'=>$cstarray[$i-4]);
}
$this->inprocess_model->saveTestReportData($temparray);
}
$count =0;
foreach($afsphpdata as $afs)
{
//print_r($afs);
$count++;
if($count != 12){
$ssize = $afs['Sieve Size µm'];
$spec = $afs['Spec'];
$factor = $afs['Factor'];
$rst1 = $afs['RST Y1'];$rst2 = $afs['RST Y2'];$rst3 = $afs['RST Y3'];
$cst1 = $afs['CST X1'];$cst2 = $afs['CST X2'];$cst3 = $afs['CST X3'];$cst4 = $afs['CST X4'];
$cst5 = $afs['CST X5'];$cst6 = $afs['CST X6'];$cst7 = $afs['CST X7'];$cst8 = $afs['CST X8'];
$afstabledata = array('masterreport_id'=>$MASTERID,'sieve_size'=>$ssize,'factor'=>$factor,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
//print_r($afstabledata);
$afsid = $this->inprocess_model->saveTestReportAFSData($afstabledata);
}
}
//die();
foreach($loiphpdata as $loi)
{
//print_r($loi);
$loidetails = $loi['Description'];
$spec = $loi['Spec'];
$rst1 = $loi['RST Y1'];
$rst2 = $loi['RST Y2'];
$rst3 = $loi['RST Y3'];
$cst1 = $loi['CST X1'];$cst2 = $loi['CST X2'];$cst3 = $loi['CST X3'];$cst4 = $loi['CST X4'];
$cst5 = $loi['CST X5'];$cst6 = $loi['CST X6'];$cst7 = $loi['CST X7'];$cst8 = $loi['CST X8'];
$loitabledata = array('masterreport_id'=>$MASTERID,'loidetails'=>$loidetails,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
$loiid = $this->inprocess_model->saveTestReportLOIData($loitabledata);
}
echo "Report Data Saved Successfully!";
}
function updateTestReportData()
{
date_default_timezone_get('Asia/Kolkata');
$testjson = $this->input->post('param1');
$testjson2 = $this->input->post('param2');
$afsjson = $this->input->post('param3');
$loijson = $this->input->post('param4');
$productid = $this->input->post('param5');
$customerid = $this->input->post('param6');
$batchno = $this->input->post('param7');
$batchdate = $this->input->post('param8');
$batchdate = date_format(date_create($batchdate),'Y-m-d');
$plantname = $this->input->post('param9');
$sanddesc = $this->input->post('param10');
$resindesc = $this->input->post('param11');
$qty = $this->input->post('param12');
$times = $this->input->post('param13');
$times = explode(",",$times);
$approvedby = $this->input->post('param14');
$remarks = $this->input->post('param15');
$masterid = $this->input->post('param16');
$olddoc = $this->input->post('param17');
$testphpdata = json_decode($testjson,true);
$testphpdata2 = json_decode($testjson2,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' );
$document = $olddoc;
if(!empty($_FILES['rfile']['name']))
{
if(!empty($document)){
$file = getcwd()."\\uploads\INPROCESS\\".$document;
if(unlink($file)){
//echo "sucess";
}else{
//echo "Failed";
}
}
$fs = $this->uploadFile();
$document = $fs;
}
$masterreportdata = array('productid'=>$productid,'customerid'=>$customerid,'batchno'=>$batchno,'batchdate'=>$batchdate,'plantname'=>$plantname,'sand_description'=>$sanddesc,'resin_description'=>$resindesc,'qty'=>$qty,'remarks'=>$remarks,'document'=>$document,'updatedby'=>$createby,'approvedby'=>$approvedby);
$this->inprocess_model->updateMasterTestData($masterreportdata,$masterid);
foreach($testphpdata as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 0;
$actarray = array($data['ACT X1'],$data['ACT X2'],$data['ACT X3'],$data['ACT X4'],$data['ACT X5'],$data['ACT X6'],$data['ACT X7'],$data['ACT X8']);
for($i=1;$i<=8;$i++)
{
//$temparray[$i] = array('itime'=>$times[$i-1],'ivalue'=>$actarray[$i-1]);
$temparray[$i] = array('masterreport_id'=>$masterid,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-1],'ivalue'=>$actarray[$i-1]);
}
$this->inprocess_model->updateTestReportData($temparray,$masterid,$specid);
}
foreach($testphpdata2 as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 1;
$cstarray = array($data['CST X1'],$data['CST X2'],$data['CST X3'],$data['CST X4'],$data['CST X5'],$data['CST X6'],$data['CST X7'],$data['CST X8']);
$rstarray = array($data['RST Y1'],$data['RST Y2'],$data['RST Y3']);
for($i=1;$i<=3;$i++)
{
$temparray[$i] = array('masterreport_id'=>$masterid,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>'','ivalue'=>$rstarray[$i-1]);
}
for($i=4;$i<=11;$i++)
{
$temparray[$i] = array('masterreport_id'=>$masterid,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-4],'ivalue'=>$cstarray[$i-4]);
}
$this->inprocess_model->updateTestReportData($temparray,$masterid,$specid);
}
$count =0;
foreach($afsphpdata as $afs)
{
//print_r($afs);
$count++;
if($count != 12){
$ssize = $afs['Sieve Size µm'];
$spec = $afs['Spec'];
$factor = $afs['Factor'];
$rst1 = $afs['RST Y1'];$rst2 = $afs['RST Y2'];$rst3 = $afs['RST Y3'];
$cst1 = $afs['CST X1'];$cst2 = $afs['CST X2'];$cst3 = $afs['CST X3'];$cst4 = $afs['CST X4'];
$cst5 = $afs['CST X5'];$cst6 = $afs['CST X6'];$cst7 = $afs['CST X7'];$cst8 = $afs['CST X8'];
$afstabledata = array('spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
$this->inprocess_model->updateTestReportAFSData($afstabledata,$masterid,$ssize,$factor);
}
}
foreach($loiphpdata as $loi)
{
//print_r($loi);
$loidetails = $loi['Description'];
$spec = $loi['Spec'];
$rst1 = $loi['RST Y1'];
$rst2 = $loi['RST Y2'];
$rst3 = $loi['RST Y3'];
$cst1 = $loi['CST X1'];$cst2 = $loi['CST X2'];$cst3 = $loi['CST X3'];$cst4 = $loi['CST X4'];
$cst5 = $loi['CST X5'];$cst6 = $loi['CST X6'];$cst7 = $loi['CST X7'];$cst8 = $loi['CST X8'];
$loitabledata = array('spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
$loiid = $this->inprocess_model->updateTestReportLOIData($loitabledata,$masterid,$loidetails);
}
echo "Report Data Saved Successfully!";
}
function printIndInprocessReport()
{
$rid = $this->input->post('masterreportid');
$data['reportdata'] = $this->inprocess_model->getIndividualInprocessReportData($rid);
$pspecid = null;
$psubtype = null;
$time = null;
$temparray = array();
$time = array();
$index = 0;
foreach($data['reportdata']['masterreport'] as $key => $d)
{
if($pspecid != $d->specid){
$index++;
$temparray[$index] = array('specid'=>$d->specid,'specname'=>$d->testtype,'smin'=>$d->min,'smax'=>$d->max,'suom'=>$d->uom,'stype'=>$d->subtype,$d->ivalue);
$time = array_merge($time,array($d->itime));
}
else{
array_push($temparray[$index],$d->ivalue);
$time = array_merge($time,array($d->itime));
}
$pspecid = $d->specid;
}
$data['reportdata']['masterreport'] = $temparray;
$data['timearray'] = $time;
$data['emplist'] = $this->quality_model->getEmplistforReport();
$this->global['pageTitle'] = 'Siddharth :Inprocess Report';
$html = $this->load->View("viewindinprocesspdf",$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 printIndNissanInprocessReport()
{
$rid = $this->input->post('masterreportid');
$data['reportdata'] = $this->inprocess_model->getIndividualInprocessReportData($rid);
//print_r($data['reportdata'] );die();
$pspecid = null;
$psubtype = null;
$time = null;
$temparray = array();
$time = array();
$index = 0;
foreach($data['reportdata']['masterreport'] as $key => $d)
{
if($pspecid != $d->specid){
$index++;
$temparray[$index] = array('specid'=>$d->specid,'specname'=>$d->testtype,'smin'=>$d->min,'smax'=>$d->max,'suom'=>$d->uom,'stype'=>$d->subtype,$d->ivalue);
$time = array_merge($time,array($d->itime));
}
else{
array_push($temparray[$index],$d->ivalue);
$time = array_merge($time,array($d->itime));
}
$pspecid = $d->specid;
}
$data['reportdata']['masterreport'] = $temparray;
$data['timearray'] = $time;
$data['emplist'] = $this->quality_model->getEmplistforReport();
$this->global['pageTitle'] = 'Siddharth :Inprocess Report';
$html = $this->load->View("viewindnissaninprocesspdf",$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 saveNissanTestReportData()
{
date_default_timezone_get('Asia/Kolkata');
$testjson = $this->input->post('param1');
$testjson2 = $this->input->post('param2');
$afsjson = $this->input->post('param3');
$loijson = $this->input->post('param4');
$productid = $this->input->post('param5');
$customerid = $this->input->post('param6');
$batchno = $this->input->post('param7');
$batchdate = $this->input->post('param8');
$batchdate = date_format(date_create($batchdate),'Y-m-d');
$plantname = $this->input->post('param9');
$sanddesc = $this->input->post('param10');
$resindesc = $this->input->post('param11');
$qty = $this->input->post('param12');
$times = $this->input->post('param13');
$times = explode(",",$times);
$approvedby = $this->input->post('param14');
$remarks = $this->input->post('param15');
$nissansubtype = $this->input->post('param16');
//echo $nissansubtype;
$testphpdata = json_decode($testjson,true);
$testphpdata2 = json_decode($testjson2,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' );
$document = null;
if(!empty($_FILES['rfile']['name']))
{
$fs = $this->uploadFile();
$document = $fs;
}
$masterreportdata = array('productid'=>$productid,'customerid'=>$customerid,'batchno'=>$batchno,'batchdate'=>$batchdate,'plantname'=>$plantname,'sand_description'=>$sanddesc,'resin_description'=>$resindesc,'qty'=>$qty,'test_type'=>1,'subtype'=>$nissansubtype,'remarks'=>$remarks,'document'=>$document,'createdby'=>$createby,'approvedby'=>$approvedby);
$MASTERID = $this->inprocess_model->saveMasterTestData($masterreportdata);
//$MASTERID = 1;
foreach($testphpdata as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 0;
$actarray = array($data['ACT X1'],$data['ACT X2'],$data['ACT X3'],$data['ACT X4'],$data['ACT X5'],$data['ACT X6'],$data['ACT X7'],$data['ACT X8']);
for($i=1;$i<=8;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-1],'ivalue'=>$actarray[$i-1]);
}
$this->inprocess_model->saveTestReportData($temparray);
}
foreach($testphpdata2 as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 1;
$cstarray = array($data['CST X1'],$data['CST X2'],$data['CST X3'],$data['CST X4'],$data['CST X5'],$data['CST X6'],$data['CST X7'],$data['CST X8']);
$rstarray = array($data['RST Y1'],$data['RST Y2'],$data['RST Y3']);
for($i=1;$i<=3;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>'','ivalue'=>$rstarray[$i-1]);
}
for($i=4;$i<=11;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-4],'ivalue'=>$cstarray[$i-4]);
}
$this->inprocess_model->saveTestReportData($temparray);
}
foreach($afsphpdata as $key => $afs)
{
if($nissansubtype == 0){
if(($key != 3) && ($key != 9) && ($key != 12) && ($key != 14)){
$ssize = $afs['Sieve Size µm'];
$spec = $afs['Spec'];
$factor = $afs['Factor'];
$rst1 = $afs['RST Y1'];$rst2 = $afs['RST Y2'];$rst3 = $afs['RST Y3'];
$cst1 = $afs['CST X1'];$cst2 = $afs['CST X2'];$cst3 = $afs['CST X3'];$cst4 = $afs['CST X4'];
$cst5 = $afs['CST X5'];$cst6 = $afs['CST X6'];$cst7 = $afs['CST X7'];$cst8 = $afs['CST X8'];
$afstabledata = array('masterreport_id'=>$MASTERID,'sieve_size'=>$ssize,'factor'=>$factor,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
//print_r($afstabledata);
$afsid = $this->inprocess_model->saveTestReportAFSData($afstabledata);
}
}
else
{
if(($key != 6) && ($key != 9) && ($key != 12) && ($key != 14)){
$ssize = $afs['Sieve Size µm'];
$spec = $afs['Spec'];
$factor = $afs['Factor'];
$rst1 = $afs['RST Y1'];$rst2 = $afs['RST Y2'];$rst3 = $afs['RST Y3'];
$cst1 = $afs['CST X1'];$cst2 = $afs['CST X2'];$cst3 = $afs['CST X3'];$cst4 = $afs['CST X4'];
$cst5 = $afs['CST X5'];$cst6 = $afs['CST X6'];$cst7 = $afs['CST X7'];$cst8 = $afs['CST X8'];
$afstabledata = array('masterreport_id'=>$MASTERID,'sieve_size'=>$ssize,'factor'=>$factor,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
//print_r($afstabledata);
$afsid = $this->inprocess_model->saveTestReportAFSData($afstabledata);
}
}
}
foreach($loiphpdata as $loi)
{
//print_r($loi);
$loidetails = $loi['Description'];
$spec = $loi['Spec'];
$rst1 = $loi['RST Y1'];
$rst2 = $loi['RST Y2'];
$rst3 = $loi['RST Y3'];
$cst1 = $loi['CST X1'];$cst2 = $loi['CST X2'];$cst3 = $loi['CST X3'];$cst4 = $loi['CST X4'];
$cst5 = $loi['CST X5'];$cst6 = $loi['CST X6'];$cst7 = $loi['CST X7'];$cst8 = $loi['CST X8'];
$loitabledata = array('masterreport_id'=>$MASTERID,'loidetails'=>$loidetails,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
$loiid = $this->inprocess_model->saveTestReportLOIData($loitabledata);
}
echo "Report Data Saved Successfully!";
}
function uploadFile()
{
$pathinfo = pathinfo($_FILES['rfile']['name']);
$config['upload_path'] = 'uploads/INPROCESS/';
$config['allowed_types'] = '*';
$filename = $_FILES['rfile']['name'];
$ext = end(explode('.',$filename));
$ext = strtolower($ext);
$fn = 'inprocess' . 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 updateNissanInprocessTestReportData()
{
//echo "controller";die();
date_default_timezone_get('Asia/Kolkata');
$testjson = $this->input->post('param1');
$testjson2 = $this->input->post('param2');
$afsjson = $this->input->post('param3');
$loijson = $this->input->post('param4');
$productid = $this->input->post('param5');
$customerid = $this->input->post('param6');
$batchno = $this->input->post('param7');
$batchdate = $this->input->post('param8');
$batchdate = date_format(date_create($batchdate),'Y-m-d');
$plantname = $this->input->post('param9');
$sanddesc = $this->input->post('param10');
$resindesc = $this->input->post('param11');
$qty = $this->input->post('param12');
$times = $this->input->post('param13');
$times = explode(",",$times);
$approvedby = $this->input->post('param14');
$remarks = $this->input->post('param15');
$nissansubtype = $this->input->post('param16');
$masterid = $this->input->post('param17');
$olddoc = $this->input->post('param18');
//echo $nissansubtype;
$testphpdata = json_decode($testjson,true);
$testphpdata2 = json_decode($testjson2,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' );
$document = $olddoc;
if(!empty($_FILES['rfile']['name']))
{
if(!empty($document)){
$file = getcwd()."\\uploads\INPROCESS\\".$document;
if(unlink($file)){ //echo "success";
}else{// echo "Failed";
}
}
$fs = $this->uploadFile();
$document = $fs;
}
//echo 'From COn'.$masterid;
$masterreportdata = array('productid'=>$productid,'customerid'=>$customerid,'batchno'=>$batchno,'batchdate'=>$batchdate,'plantname'=>$plantname,'sand_description'=>$sanddesc,'resin_description'=>$resindesc,'qty'=>$qty,'test_type'=>1,'subtype'=>$nissansubtype,'remarks'=>$remarks,'document'=>$document,'updatedby'=>$createby,'approvedby'=>$approvedby);
//print_r($masterreportdata);
$this->inprocess_model->updateNissanMasterTestData($masterreportdata,$masterid);
$MASTERID = $masterid;
foreach($testphpdata as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 0;
$actarray = array($data['ACT X1'],$data['ACT X2'],$data['ACT X3'],$data['ACT X4'],$data['ACT X5'],$data['ACT X6'],$data['ACT X7'],$data['ACT X8']);
for($i=1;$i<=8;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-1],'ivalue'=>$actarray[$i-1]);
}
$this->inprocess_model->updateNissanTestReportData($temparray,$masterid,$specid);
}
foreach($testphpdata2 as $data)
{
//print_r($data);
$temparray = array();
$specid = $data['SPECID'];
$subtype = 1;
$cstarray = array($data['CST X1'],$data['CST X2'],$data['CST X3'],$data['CST X4'],$data['CST X5'],$data['CST X6'],$data['CST X7'],$data['CST X8']);
$rstarray = array($data['RST Y1'],$data['RST Y2'],$data['RST Y3']);
for($i=1;$i<=3;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>'','ivalue'=>$rstarray[$i-1]);
}
for($i=4;$i<=11;$i++)
{
$temparray[$i] = array('masterreport_id'=>$MASTERID,'specid'=>$specid,'subtype'=>$subtype,'iteration'=>$i,'itime'=>$times[$i-4],'ivalue'=>$cstarray[$i-4]);
}
$this->inprocess_model->updateNissanTestReportData($temparray,$masterid,$specid);
}
foreach($afsphpdata as $key => $afs)
{
if($nissansubtype == 0){
if(($key != 3) && ($key != 9) && ($key != 12) && ($key != 14)){
$ssize = $afs['Sieve Size µm'];
$spec = $afs['Spec'];
$factor = $afs['Factor'];
$rst1 = $afs['RST Y1'];$rst2 = $afs['RST Y2'];$rst3 = $afs['RST Y3'];
$cst1 = $afs['CST X1'];$cst2 = $afs['CST X2'];$cst3 = $afs['CST X3'];$cst4 = $afs['CST X4'];
$cst5 = $afs['CST X5'];$cst6 = $afs['CST X6'];$cst7 = $afs['CST X7'];$cst8 = $afs['CST X8'];
$afstabledata = array('masterreport_id'=>$MASTERID,'sieve_size'=>$ssize,'factor'=>$factor,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
//print_r($afstabledata);
$afsid = $this->inprocess_model->updateNissanTestReportAFSData($afstabledata,$masterid,$ssize,$factor);
}
}
else
{
if(($key != 6) && ($key != 9) && ($key != 12) && ($key != 14)){
$ssize = $afs['Sieve Size µm'];
$spec = $afs['Spec'];
$factor = $afs['Factor'];
$rst1 = $afs['RST Y1'];$rst2 = $afs['RST Y2'];$rst3 = $afs['RST Y3'];
$cst1 = $afs['CST X1'];$cst2 = $afs['CST X2'];$cst3 = $afs['CST X3'];$cst4 = $afs['CST X4'];
$cst5 = $afs['CST X5'];$cst6 = $afs['CST X6'];$cst7 = $afs['CST X7'];$cst8 = $afs['CST X8'];
$afstabledata = array('masterreport_id'=>$MASTERID,'sieve_size'=>$ssize,'factor'=>$factor,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
//print_r($afstabledata);
$afsid = $this->inprocess_model->updateNissanTestReportAFSData($afstabledata,$masterid,$ssize,$factor);
}
}
}
foreach($loiphpdata as $loi)
{
//print_r($loi);
$loidetails = $loi['Description'];
$spec = $loi['Spec'];
$rst1 = $loi['RST Y1'];
$rst2 = $loi['RST Y2'];
$rst3 = $loi['RST Y3'];
$cst1 = $loi['CST X1'];$cst2 = $loi['CST X2'];$cst3 = $loi['CST X3'];$cst4 = $loi['CST X4'];
$cst5 = $loi['CST X5'];$cst6 = $loi['CST X6'];$cst7 = $loi['CST X7'];$cst8 = $loi['CST X8'];
$loitabledata = array('masterreport_id'=>$MASTERID,'loidetails'=>$loidetails,'spec'=>$spec,'rst1'=>$rst1,'rst2'=>$rst2,'rst3'=>$rst3,
'cst1'=>$cst1,'cst2'=>$cst2,'cst3'=>$cst3,'cst4'=>$cst4,'cst5'=>$cst5,'cst6'=>$cst6,'cst7'=>$cst7,'cst8'=>$cst8,);
$loiid = $this->inprocess_model->updateNissanTestReportLOIData($loitabledata,$masterid,$loidetails);
}
echo "Report Data Saved Successfully!";
}
}
?>