933 lines
30 KiB
PHP
933 lines
30 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use App\Models\Inprocess_model;
|
|
|
|
use App\Models\Quality_model;
|
|
|
|
|
|
/**
|
|
* Module : Inprocess
|
|
* Inprocess Class to control all inprocess related operations.
|
|
* @author : Venba
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Inprocess extends BaseController
|
|
{
|
|
protected $quality_model;
|
|
protected $inprocess_model;
|
|
protected $session;
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->isLoggedIn();
|
|
$this->quality_model = new Quality_model();
|
|
$this->inprocess_model = new Inprocess_model();
|
|
$this->session = session();
|
|
helper('form'); //$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'] = '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'] = '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'] = 'New Inprcess Test Report ';
|
|
$this->loadViews("newnissaninprocessreport", $this->global, $data, NULL);
|
|
}
|
|
|
|
function editIndInprocessReport()
|
|
{
|
|
$uri = service('uri');
|
|
$rid = $uri->getSegment(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'] = 'Edit Inprocess Report';
|
|
$this->loadViews("editInprocessReport", $this->global, $data, NULL);
|
|
} else {
|
|
//echo "Under Developing";
|
|
|
|
$this->global['pageTitle'] = 'Edit Nissan Inprocess Report';
|
|
$this->loadViews("editNissanInprocessReport", $this->global, $data, NULL);
|
|
}
|
|
}
|
|
|
|
|
|
function getAllSpecforReport()
|
|
{
|
|
$productid = $this->request->getPost('param1');
|
|
$customerid = $this->request->getPost('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->request->getPost('param1');
|
|
$testjson2 = $this->request->getPost('param2');
|
|
$afsjson = $this->request->getPost('param3');
|
|
$loijson = $this->request->getPost('param4');
|
|
|
|
$productid = $this->request->getPost('param5');
|
|
$customerid = $this->request->getPost('param6');
|
|
$batchno = $this->request->getPost('param7');
|
|
$batchdate = $this->request->getPost('param8');
|
|
$batchdate = format_date($batchdate);//3rd
|
|
$plantname = $this->request->getPost('param9');
|
|
$sanddesc = $this->request->getPost('param10');
|
|
$resindesc = $this->request->getPost('param11');
|
|
$qty = $this->request->getPost('param12');
|
|
$times = $this->request->getPost('param13');
|
|
$times = explode(",", $times);
|
|
$approvedby = $this->request->getPost('param14');
|
|
$remarks = $this->request->getPost('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->get('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->request->getPost('param1');
|
|
$testjson2 = $this->request->getPost('param2');
|
|
$afsjson = $this->request->getPost('param3');
|
|
$loijson = $this->request->getPost('param4');
|
|
|
|
$productid = $this->request->getPost('param5');
|
|
$customerid = $this->request->getPost('param6');
|
|
$batchno = $this->request->getPost('param7');
|
|
$batchdate = $this->request->getPost('param8');
|
|
|
|
$batchdate = format_date($batchdate);//3rd
|
|
$plantname = $this->request->getPost('param9');
|
|
$sanddesc = $this->request->getPost('param10');
|
|
$resindesc = $this->request->getPost('param11');
|
|
$qty = $this->request->getPost('param12');
|
|
$times = $this->request->getPost('param13');
|
|
$times = explode(",", $times);
|
|
$approvedby = $this->request->getPost('param14');
|
|
$remarks = $this->request->getPost('param15');
|
|
$masterid = $this->request->getPost('param16');
|
|
$olddoc = $this->request->getPost('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->get('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->request->getPost('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'] = 'Inprocess Report';
|
|
$html = 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->request->getPost('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'] = 'Inprocess Report';
|
|
$html = 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->request->getPost('param1');
|
|
$testjson2 = $this->request->getPost('param2');
|
|
$afsjson = $this->request->getPost('param3');
|
|
$loijson = $this->request->getPost('param4');
|
|
|
|
$productid = $this->request->getPost('param5');
|
|
$customerid = $this->request->getPost('param6');
|
|
$batchno = $this->request->getPost('param7');
|
|
$batchdate = $this->request->getPost('param8');
|
|
$batchdate = format_date($batchdate);//3rd
|
|
$plantname = $this->request->getPost('param9');
|
|
$sanddesc = $this->request->getPost('param10');
|
|
$resindesc = $this->request->getPost('param11');
|
|
$qty = $this->request->getPost('param12');
|
|
$times = $this->request->getPost('param13');
|
|
$times = explode(",", $times);
|
|
$approvedby = $this->request->getPost('param14');
|
|
$remarks = $this->request->getPost('param15');
|
|
$nissansubtype = $this->request->getPost('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->get('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'] = 'public/uploads/INPROCESS/';
|
|
$config['allowed_types'] = '*';
|
|
$filename = $_FILES['rfile']['name'];
|
|
$ext = end(explode('.', $filename));
|
|
|
|
$ext = strtolower($ext);
|
|
$fn = 'inprocess' . get_current_date() . 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()
|
|
{
|
|
$testjson = $this->request->getPost('param1');
|
|
$testjson2 = $this->request->getPost('param2');
|
|
$afsjson = $this->request->getPost('param3');
|
|
$loijson = $this->request->getPost('param4');
|
|
|
|
$productid = $this->request->getPost('param5');
|
|
$customerid = $this->request->getPost('param6');
|
|
$batchno = $this->request->getPost('param7');
|
|
$batchdate = $this->request->getPost('param8');
|
|
$batchdate = format_date($batchdate);//3rd
|
|
$plantname = $this->request->getPost('param9');
|
|
$sanddesc = $this->request->getPost('param10');
|
|
$resindesc = $this->request->getPost('param11');
|
|
$qty = $this->request->getPost('param12');
|
|
$times = $this->request->getPost('param13');
|
|
$times = explode(",",$times);
|
|
$approvedby = $this->request->getPost('param14');
|
|
$remarks = $this->request->getPost('param15');
|
|
$nissansubtype = $this->request->getPost('param16');
|
|
$masterid = $this->request->getPost('param17');
|
|
$olddoc = $this->request->getPost('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->get('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!";
|
|
}
|
|
}
|