465 lines
14 KiB
PHP
Executable File
465 lines
14 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use App\Models\Quality_model;
|
|
|
|
/**
|
|
* Module : Batch Card
|
|
* Resinbatchcard Class to control all Resinbatchcard related operations.
|
|
* @author : Venba
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Resinbatchcard 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();
|
|
helper('form'); //$this->load->library('form_validation');
|
|
$this->session = session();
|
|
//$this->load->library('dompdf_gen');
|
|
$this->isLoggedIn();
|
|
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
|
|
|
|
function addNewResinBatchCard()
|
|
{
|
|
|
|
$data['productsoutward'] = $this->quality_model->getAllprodcuts();
|
|
$data['customersoutward'] = $this->quality_model->getAllcustomers();
|
|
$data['emplist'] = $this->quality_model->getEmplistforReport();
|
|
$data['operatorslist'] = $this->quality_model->getOperatorsListforReport();
|
|
$data['machinelist'] = $this->quality_model->getMachineList();
|
|
$data['trpbatchcardnos'] = $this->quality_model->getTRPBatchcardNos();
|
|
$data['igrno'] = $this->quality_model->getIGRNos();
|
|
$this->global['pageTitle'] = 'Resin Batch Card';
|
|
$this->loadViews("newresinbatchcard", $this->global, $data, NULL);
|
|
}
|
|
|
|
function getIGRLineNo()
|
|
{
|
|
$igrno = $this->request->getPost('param1');
|
|
|
|
$sql = 'select IGRItemNo from t_igr_details where IGRNO = ?';
|
|
$res = $db->query($sql, array($igrno));
|
|
echo json_encode($res->result());
|
|
}
|
|
|
|
|
|
|
|
|
|
function resinBatchCardLisitng()
|
|
{
|
|
$data['records'] = $this->quality_model->getResinBatchCardTestMasterList();
|
|
|
|
$this->global['pageTitle'] = 'Prodcut Report List ';
|
|
$this->loadViews("resinbatchcardreportlist", $this->global, $data, NULL);
|
|
}
|
|
|
|
function saveTestReportData()
|
|
{
|
|
//echo "system soft";
|
|
|
|
date_default_timezone_get('Asia/Kolkata');
|
|
$productid = $this->request->getPost('param1');
|
|
$customerid = $this->request->getPost('param2');
|
|
$batchdate = $this->request->getPost('param3');
|
|
$batchdate = format_date($batchdate);//3rd
|
|
$plantname = $this->request->getPost('param4');
|
|
$macinecode = $this->request->getPost('param5');
|
|
$trpbatchcard = $this->request->getPost('param6');
|
|
$igrnos = $this->request->getPost('param7');
|
|
$igrlinenos = $this->request->getPost('param8');
|
|
$remarks = $this->request->getPost('param9');
|
|
$approvedby = $this->request->getPost('param10');
|
|
|
|
$masterdata = $this->request->getPost('param11');
|
|
$totaldata = $this->request->getPost('param12');
|
|
$masterdata = json_decode($masterdata, true);
|
|
$totaldata = json_decode($totaldata, true);
|
|
$createby = $this->session->get('userId');
|
|
$document = null;
|
|
|
|
$resinname = $this->request->getPost('param13');
|
|
$oplist = $this->request->getPost('param14');
|
|
$oplist = json_decode($oplist);
|
|
$operator = $this->request->getPost('param15');
|
|
$sandigrnos = $this->request->getPost('param16');
|
|
$Resinigrnos = $this->request->getPost('param17');
|
|
$Hexamineigrnos = $this->request->getPost('param18');
|
|
$CSigrnos = $this->request->getPost('param19');
|
|
$Catalystigrno = $this->request->getPost('param20');
|
|
$bagsigrnos = $this->request->getPost('param21');
|
|
$tonigrnos = $this->request->getPost('param22');
|
|
|
|
|
|
if (!empty($_FILES['rfile']['name'])) {
|
|
$fs = $this->uploadFile();
|
|
$document = $fs;
|
|
}
|
|
|
|
$sandtotal = 0;
|
|
$resintotal = 0;
|
|
$catalysttotal = 0;
|
|
$hextotal = 0;
|
|
$cstotal = 0;
|
|
$bags50total = 0;
|
|
$ton1bagstotal = 0;
|
|
$producitonloss = 0;
|
|
$finishedproduct = 0;
|
|
foreach ($totaldata as $key => $tot) {
|
|
if ($key != 0) {
|
|
$sandtotal = $tot['Sand'];
|
|
$resintotal = $tot['Resin'];
|
|
$hextotal = $tot['Hexamine'];
|
|
$catalysttotal = $tot['Catalyst'];
|
|
$cstotal = $tot['CS'];
|
|
$bags50total = $tot['50 Bags'];
|
|
$ton1bagstotal = $tot['1 ton Bag'];
|
|
$producitonloss = $tot['Production Loss Lump'];
|
|
$finishedproduct = $tot['Finished Prodcut PCS'];
|
|
}
|
|
}
|
|
|
|
$masterreportdata = array(
|
|
'productid' => $productid,
|
|
'customerid' => $customerid,
|
|
'batchdate' => $batchdate,
|
|
'plantname' => $plantname,
|
|
'resinname' => $resinname,
|
|
'machinecode' => $macinecode,
|
|
'trpbatchcardno' => $trpbatchcard,
|
|
'igrno' => $igrnos,
|
|
'igrlineno' => $igrlinenos,
|
|
'remarks' => $remarks,
|
|
'createdby' => $createby,
|
|
'approvedby' => $approvedby,
|
|
'document' => $document,
|
|
'sandtotal' => $sandtotal,
|
|
'resintotal' => $resintotal,
|
|
'hextotal' => $hextotal,
|
|
'cstotal' => $cstotal,
|
|
'catalysttotal' => $catalysttotal,
|
|
'bags50total' => $bags50total,
|
|
'ton1bagstotal' => $ton1bagstotal,
|
|
'producitonloss' => $producitonloss,
|
|
'finishedproduct' => $finishedproduct,
|
|
'operatedby' => $operator,
|
|
'igrno_for_sand' => $sandigrnos,
|
|
'igrno_for_resin' => $Resinigrnos,
|
|
'igrno_for_haxamine' => $Hexamineigrnos,
|
|
'igrno_for_cs' => $CSigrnos,
|
|
'igrno_for_catalyst' => $Catalystigrno,
|
|
'igrno_for_bags' => $bagsigrnos,
|
|
'igrno_for_tonbags' => $tonigrnos
|
|
);
|
|
|
|
|
|
// print_r($masterreportdata);
|
|
// die();
|
|
$MASTERID = $this->quality_model->saveResinBatchCardMasterTestData($masterreportdata);
|
|
// echo $MASTERID;die();
|
|
//$MASTERID = 56;
|
|
foreach ($masterdata as $key => $mas) {
|
|
if ($key > 2) {
|
|
|
|
|
|
$t = array_pop($mas);
|
|
array_pop($mas);
|
|
|
|
foreach ($mas as $key => $m) {
|
|
$newArray = array('master_report_id' => $MASTERID, 'i_time' => $t, 'spec_id' => $key, 'spec_value' => $m);
|
|
$res = $this->quality_model->saveResinBatchCardChildTestData($newArray);
|
|
//print_r($newArray);
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($oplist as $op) {
|
|
$nArray = array('master_id' => $MASTERID, 'EmpID' => $op);
|
|
$this->db->insert('T_ResinBatchCard_Operators', $nArray);
|
|
}
|
|
|
|
echo "Report Data Saved Successfully!";
|
|
}
|
|
|
|
function updateTestReportData()
|
|
{
|
|
|
|
date_default_timezone_get('Asia/Kolkata');
|
|
$productid = $this->request->getPost('param1');
|
|
$customerid = $this->request->getPost('param2');
|
|
$batchdate = $this->request->getPost('param3');
|
|
$batchdate = format_date($batchdate);//3rd
|
|
$plantname = $this->request->getPost('param4');
|
|
$machines = $this->request->getPost('param5');
|
|
$trpbatchcardno = $this->request->getPost('param6');
|
|
$igrnos = $this->request->getPost('param7');
|
|
$igrlinenos = $this->request->getPost('param8');
|
|
$remarks = $this->request->getPost('param9');
|
|
$approvedby = $this->request->getPost('param10');
|
|
|
|
$masterdata = $this->request->getPost('param11');
|
|
$totaldata = $this->request->getPost('param12');
|
|
$masterdata = json_decode($masterdata, true);
|
|
$totaldata = json_decode($totaldata, true);
|
|
$createby = $this->session->get('userId');
|
|
$document = $this->request->getPost('param13');
|
|
$MASTERID = $this->request->getPost('param14');
|
|
$opstoinsert = $this->request->getPost('param15');
|
|
$opstodelete = $this->request->getPost('param16');
|
|
$operatedby = $this->request->getPost('param17');
|
|
$sandigrnos = $this->request->getPost('param18');
|
|
$Resinigrnos = $this->request->getPost('param19');
|
|
$Hexamineigrnos = $this->request->getPost('param20');
|
|
$CSigrnos = $this->request->getPost('param21');
|
|
$Catalystigrno = $this->request->getPost('param22');
|
|
$bagsigrnos = $this->request->getPost('param23');
|
|
$tonigrnos = $this->request->getPost('param24');
|
|
$resinname = $this->request->getPost('param25');
|
|
|
|
$opstoinsert = json_decode($opstoinsert);
|
|
$opstodelete = json_decode($opstodelete);
|
|
|
|
// print_r($opstodelete);
|
|
// echo count($opstodelete);
|
|
|
|
//die();
|
|
//$oplist = json_decode($oplist);
|
|
if (!empty($_FILES['rfile']['name'])) {
|
|
|
|
if (!empty($document)) {
|
|
$file = getcwd() . "\\uploads\QAD\\" . $document;
|
|
|
|
|
|
if (unlink($file)) {
|
|
//echo "sucess";
|
|
} else {
|
|
//echo "Failed";
|
|
}
|
|
}
|
|
$fs = $this->uploadFile();
|
|
$document = $fs;
|
|
}
|
|
|
|
$sandtotal = 0;
|
|
$resintotal = 0;
|
|
$hextotal = 0;
|
|
$cstotal = 0;
|
|
$catalysttotal = 0;
|
|
$bags50total = 0;
|
|
$ton1bagstotal = 0;
|
|
$producitonloss = 0;
|
|
$finishedproduct = 0;
|
|
foreach ($totaldata as $key => $tot) {
|
|
if ($key != 0) {
|
|
$sandtotal = $tot['Sand'];
|
|
$resintotal = $tot['Resin'];
|
|
$hextotal = $tot['Hexamine'];
|
|
$cstotal = $tot['CS'];
|
|
$catalysttotal = $tot['Catalyst'];
|
|
$bags50total = $tot['50 Bags'];
|
|
$ton1bagstotal = $tot['1 ton Bag'];
|
|
$producitonloss = $tot['Production Loss Lump'];
|
|
$finishedproduct = $tot['Finished Prodcut PCS'];
|
|
}
|
|
}
|
|
|
|
|
|
$masterreportdata = array(
|
|
'batchdate' => $batchdate, 'plantname' => $plantname, 'machinecode' => $machines, 'trpbatchcardno' => $trpbatchcardno, 'igrno' => $igrnos, 'igrlineno' => $igrlinenos, 'resinname' => $resinname, 'remarks' => $remarks, 'updatedby' => $createby, 'approvedby' => $approvedby, 'document' => $document, 'sandtotal' => $sandtotal, 'resintotal' => $resintotal, 'hextotal' => $hextotal, 'cstotal' => $cstotal, 'catalysttotal' => $catalysttotal, 'bags50total' => $bags50total, 'ton1bagstotal' => $ton1bagstotal, 'producitonloss' => $producitonloss, 'finishedproduct' => $finishedproduct, 'operatedby' => $operatedby,
|
|
'igrno_for_sand' => $sandigrnos,
|
|
'igrno_for_resin' => $Resinigrnos,
|
|
'igrno_for_haxamine' => $Hexamineigrnos,
|
|
'igrno_for_cs' => $CSigrnos,
|
|
'igrno_for_catalyst' => $Catalystigrno,
|
|
'igrno_for_bags' => $bagsigrnos,
|
|
'igrno_for_tonbags' => $tonigrnos
|
|
);
|
|
//print_r($masterreportdata);
|
|
|
|
$this->quality_model->updateResinBatchCardMasterTestData($masterreportdata, $MASTERID);
|
|
//echo $MASTERID;die();
|
|
//$MASTERID = 56;
|
|
|
|
foreach ($masterdata as $key => $mas) {
|
|
if ($key > 2) {
|
|
|
|
|
|
$t = array_pop($mas);
|
|
array_pop($mas);
|
|
|
|
foreach ($mas as $key => $m) {
|
|
$newArray = array('master_report_id' => $MASTERID, 'i_time' => $t, 'spec_id' => $key, 'spec_value' => $m);
|
|
$res = $this->quality_model->updateResinBatchCardChildTestData($newArray);
|
|
//print_r($newArray);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty($opstoinsert)) {
|
|
foreach ($opstoinsert as $opstins) {
|
|
$tArray = array('master_id' => $MASTERID, 'EmpID' => $opstins);
|
|
$this->db->insert('T_ResinBatchCard_Operators', $tArray);
|
|
//print_r($tArray);
|
|
}
|
|
}
|
|
|
|
if (!empty($opstodelete)) {
|
|
|
|
foreach ($opstodelete as $key => $opstdel) {
|
|
//echo 'FROM CON'.'-'.$MASTERID.'-'.$opstdel[0];
|
|
$this->db->where('master_id', $MASTERID);
|
|
$this->db->where('EmpID', $opstdel[0]);
|
|
$this->db->delete('T_ResinBatchCard_Operators');
|
|
//print_r($tArray);
|
|
}
|
|
}
|
|
echo "Report Data Saved Successfully!";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
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 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 = 'RESINBCARD' . 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 viewIndReport()
|
|
{$uri = service('uri');
|
|
$rbcid = $uri->getSegment(3);
|
|
//echo $rbcid;
|
|
$data['emplist'] = $this->quality_model->getEmplistforReport();
|
|
$data['records'] = $this->quality_model->getResinBatchCardDetails($rbcid);
|
|
//print_r($data['records']);
|
|
$data['machinelist'] = $this->quality_model->getMachineList();
|
|
$data['igrno'] = $this->quality_model->getIGRNos();
|
|
$data['igrlineitem'] = $this->quality_model->getIGRItemNos();
|
|
$data['trpbatchcardnos'] = $this->quality_model->getTRPBatchcardNos();
|
|
$data['operatorslist'] = $this->quality_model->getOperatorsListforReport();
|
|
$data['existoperatorslist'] = $this->quality_model->getExistOperatorsListforReport($rbcid);
|
|
//print_r($data['records']);die();
|
|
$this->global['pageTitle'] = 'Edit Resin Batch Card';
|
|
$this->loadViews("editresinbatchcard", $this->global, $data, NULL);
|
|
}
|
|
|
|
//this function used to edit resinbatch card pdf
|
|
|
|
|
|
function printResinBatchReport()
|
|
{$uri = service('uri');
|
|
$rbcid = $uri->getSegment(3);
|
|
$data['records'] = $this->quality_model->getResinBatchCardDetails($rbcid);
|
|
//print_r( $data['records']);
|
|
|
|
$productid = $data['records']['masterdata'][0]->productid;
|
|
$customerid = $data['records']['masterdata'][0]->customerid;
|
|
$ttype = 'RESINBATCHCARD';
|
|
// echo $productid1;
|
|
// echo $customerid1;
|
|
$data['recordsheader'] = $this->quality_model->getSpecifications($productid, $customerid, $ttype);
|
|
//print_r($data['recordsheader']);
|
|
$data['existspec'] = $this->quality_model->getAllspec(); // values max 15 pdf include
|
|
$data['existoperatorslist'] = $this->quality_model->getExistOperatorsListforReport($rbcid);
|
|
// print_r( $data['existspec']);
|
|
|
|
|
|
// $filename = 'Siddharth :ResinBatchCard'.$rbcid;
|
|
|
|
$data['reportdata']['masterreport'] = $temparray;
|
|
$data['timearray'] = $time;
|
|
$data['emplist'] = $this->quality_model->getEmplistforReport();
|
|
|
|
$this->global['pageTitle'] = 'ResinBatchCardPDF';
|
|
$html = view("viewresinbatchpdf", $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(' :ResinBatchCard' . $rbcid);
|
|
$mpdf->list_indent_first_level = 1;
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
$mpdf->WriteHTML($html);
|
|
//$mpdf->SetJS('print();');
|
|
$mpdf->Output($filename . '.pdf', 'I');
|
|
}
|
|
}
|