504 lines
15 KiB
PHP
Executable File
504 lines
15 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
// require APPPATH . '/third_party/mpdf/mpdf.php';
|
|
|
|
use App\Models\Quality_model;
|
|
|
|
|
|
/**
|
|
* Module : Quality
|
|
* Quality Class to control all Quality related operations.
|
|
* @author : Venba
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Quality extends BaseController
|
|
{
|
|
protected $quality_model;
|
|
protected $session;
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->quality_model = new Quality_model();
|
|
$this->session = session();
|
|
helper('form'); //$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();
|
|
$data['existspecinward'] = $this->quality_model->getAllspecInward();
|
|
$this->global['pageTitle'] = 'Quality Master';
|
|
|
|
$this->loadViews("qualitymasterlistview", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
public function reportList()
|
|
{
|
|
$data['records'] = $this->quality_model->getTestMasterforList();
|
|
|
|
$this->global['pageTitle'] = 'Prodcut Report List ';
|
|
$this->loadViews("reportmasterlist", $this->global, $data, NULL);
|
|
}
|
|
|
|
public function reportListInward()
|
|
{
|
|
$data['records'] = $this->quality_model->getTestMasterforListInward();
|
|
|
|
$this->global['pageTitle'] = 'Report List Inward';
|
|
$this->loadViews("reportmasterlist_inward", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
|
|
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'] = 'Quality Master';
|
|
|
|
$this->loadViews("qualitymaster", $this->global, $data, NULL);
|
|
}
|
|
|
|
function saveSpectficationData()
|
|
{
|
|
$product = $this->request->getPost('param2');
|
|
$customer = $this->request->getPost('param3');
|
|
$jsondata = $this->request->getPost('param1');
|
|
$type = $this->request->getPost('param4');
|
|
|
|
|
|
//echo $type;die();
|
|
$createdby = $this->session->get('userId');
|
|
$phpdata = json_decode($jsondata, true);
|
|
$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'];
|
|
$rawsandtest = $data['Raw Sand Test'];
|
|
|
|
$res = 0;
|
|
if (strtolower($rawsandtest) == 'yes') {
|
|
$rawsandtest = 1;
|
|
} else {
|
|
$rawsandtest = 0;
|
|
}
|
|
|
|
|
|
|
|
$isExist = $this->quality_model->checkExist($product, $customer, $name, $type);
|
|
//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, 'type' => $type, 'subtype' => $rawsandtest, 'created_by' => $createdby);
|
|
//print_r($tostore);
|
|
$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, 'type' => $type, 'subtype' => $rawsandtest, 'updated_by' => $createdby);
|
|
$res = $this->quality_model->updateSpecMast($tostore, $product, $customer, $name, $type);
|
|
//echo 'u'.$res;
|
|
}
|
|
|
|
$total += $res;
|
|
}
|
|
|
|
echo $total . '- Specification Saved Successfully';
|
|
}
|
|
|
|
function deleteSpecification()
|
|
{
|
|
$spname = $this->request->getPost('param1');
|
|
$product = $this->request->getPost('param2');
|
|
$customer = $this->request->getPost('param3');
|
|
$type = $this->request->getPost('param4');
|
|
|
|
$res = $this->quality_model->deleteSpecification($spname, $product, $customer, $type);
|
|
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'] = 'Inspection Report Screen';
|
|
$this->loadViews("qualityreport", $this->global, $data, NULL);
|
|
}
|
|
|
|
function viewSpec()
|
|
{
|
|
$uri = service('uri');
|
|
$prodcutid = $uri->getSegment(3);
|
|
$customerid = $uri->getSegment(4);
|
|
$type = $uri->getSegment(5);
|
|
$data['specifications'] = $this->quality_model->getIndividualSpec($prodcutid, $customerid, $type);
|
|
$this->global['pageTitle'] = ' View reports Lists';
|
|
|
|
$this->loadViews("viewIndSpec", $this->global, $data, NULL);
|
|
}
|
|
|
|
function viewIndReport()
|
|
{
|
|
$uri = service('uri');
|
|
$reportid = $uri->getSegment(3);
|
|
|
|
$data['reportdata'] = $this->quality_model->getIndividualReportData($reportid);
|
|
$this->global['pageTitle'] = 'View Individual Report';
|
|
$this->loadViews("viewindreport", $this->global, $data, NULL);
|
|
}
|
|
|
|
function viewIndInwardReport()
|
|
{
|
|
$uri = service('uri');
|
|
$reportid = $uri->getSegment(3);
|
|
|
|
$data['reportdata'] = $this->quality_model->getIndividualInwardReportData($reportid);
|
|
$this->global['pageTitle'] = 'View Individual Report';
|
|
$this->loadViews("viewindInwardreport", $this->global, $data, NULL);
|
|
}
|
|
|
|
function printReportPDF()
|
|
{
|
|
$type = '';
|
|
$html = '';
|
|
$filename = '';
|
|
if ($this->request->getPost('type')) {
|
|
$type = $this->request->getPost('type');
|
|
}
|
|
$reportid = $this->request->getPost('rid');
|
|
|
|
if ($type != 'INWARD' or $type == '') {
|
|
$data['reportdata'] = $this->quality_model->getIndividualReportData($reportid);
|
|
$filename = 'PRE DESPATCH INSPECTION REPORT' . $reportid;
|
|
$html = view("viewindreportpdf", $data, true);
|
|
} else if ($type == 'INWARD') {
|
|
$data['reportdata'] = $this->quality_model->getIndividualInwardReportData($reportid);
|
|
$filename = 'INWARD MATERIAL INSPECTION REPORT' . $reportid;
|
|
$html = view("viewindinwardreportpdf", $data, true);
|
|
}
|
|
ob_end_clean();
|
|
$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 getAllSpecforReport()
|
|
{
|
|
$productid = $this->request->getPost('param1');
|
|
$customerid = $this->request->getPost('param2');
|
|
$res = '';
|
|
if ($this->request->getPost('param3')) {
|
|
$ttype = $this->request->getPost('param3');
|
|
$res = $this->quality_model->getSpecifications($productid, $customerid, $ttype);
|
|
} else {
|
|
|
|
$res = $this->quality_model->getSpecifications($productid, $customerid);
|
|
}
|
|
|
|
|
|
echo json_encode($res);
|
|
}
|
|
|
|
|
|
function saveTestReportData()
|
|
{
|
|
|
|
|
|
date_default_timezone_get('Asia/Kolkata');
|
|
$testjson = $this->request->getPost('param1');
|
|
$loijson = $this->request->getPost('param2');
|
|
$afsjson = $this->request->getPost('param3');
|
|
$invoiceno = $this->request->getPost('param4');
|
|
$batchno = $this->request->getPost('param5');
|
|
$chart = $this->request->getPost('param7');
|
|
$batchno = format_date($batchno);//3rd
|
|
|
|
$approver = $this->request->getPost('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->get('userId');
|
|
$document = null;
|
|
if (!empty($_FILES['rfile']['name'])) {
|
|
|
|
|
|
$fs = $this->uploadFile();
|
|
$document = $fs;
|
|
}
|
|
|
|
$masterreportdata = array('invoiceid' => $invoiceno, 'batchdate' => $batchno, 'createdby' => $createby, 'createdon' => $createdon, 'approvedby' => $approver, 'chartdata' => $chart, 'document' => $document);
|
|
$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 saveInwardTestReportData()
|
|
{
|
|
|
|
|
|
|
|
date_default_timezone_get('Asia/Kolkata');
|
|
$testjson = $this->request->getPost('param1');
|
|
$loijson = $this->request->getPost('param2');
|
|
$afsjson = $this->request->getPost('param3');
|
|
|
|
$igrno = $this->request->getPost('param4');
|
|
$igrlineitemno = $this->request->getPost('param5');
|
|
$chart = $this->request->getPost('param7');
|
|
$report_date = $this->request->getPost('param8');
|
|
$report_date = format_date($report_date, 0, 'Y-m-d');
|
|
|
|
$approver = $this->request->getPost('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->get('userId');
|
|
$document = null;
|
|
if (!empty($_FILES['rfile']['name'])) {
|
|
|
|
|
|
$fs = $this->uploadFile();
|
|
$document = $fs;
|
|
}
|
|
$masterreportdata = array('igrno' => $igrno, 'igrlineitemno' => $igrlineitemno, 'batchdate' => $report_date, 'createdby' => $createby, 'createdon' => $createdon, 'approvedby' => $approver, 'chartdata' => $chart, 'document' => $document);
|
|
//print_r($masterreportdata);die;
|
|
$MASTERID = $this->quality_model->saveMasterTestData($masterreportdata);
|
|
|
|
|
|
|
|
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'];
|
|
$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'] = 'Inward Inspection';
|
|
$this->loadViews("inward_report_create", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function getIGRLineItemNo()
|
|
{
|
|
$igrno = $this->request->getPost('param1');
|
|
$data['igrdetails'] = $this->quality_model->getIGRLineItemNo($igrno);
|
|
//print_r($data['igrdetails']);
|
|
echo json_encode($data['igrdetails']);
|
|
}
|
|
|
|
|
|
function getIGRDetails()
|
|
{
|
|
$igrno = $this->request->getPost('param1');
|
|
$igrlineitemno = $this->request->getPost('param2');
|
|
$data['igrdetails'] = $this->quality_model->getIGRDataforReport($igrno, $igrlineitemno);
|
|
//print_r($data['igrdetails']);
|
|
echo json_encode($data['igrdetails']);
|
|
}
|
|
|
|
|
|
|
|
function uploadFile()
|
|
{
|
|
|
|
$pathinfo = pathinfo($_FILES['rfile']['name']);
|
|
$config['upload_path'] = 'public/uploads/QAD/';
|
|
$config['allowed_types'] = '*';
|
|
$filename = $_FILES['rfile']['name'];
|
|
$ext = end(explode('.', $filename));
|
|
|
|
$ext = strtolower($ext);
|
|
$fn = 'qad' . 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;
|
|
}
|
|
}
|
|
}
|