ria/app/Models/Quality_model.php
2024-09-11 08:54:25 +05:30

574 lines
24 KiB
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class Quality_model extends Model
{
function getAllInvoiceNo()
{
$builder = $this->db->table('ip_invoices')->select('invoice_number');
$result = $builder->get();
return $result->getResult();
}
function getAllprodcuts()
{
$builder = $this->db->table('ip_products')->select('product_id,product_name,product_description');
$result = $builder->get();
return $result->getResult();
}
function getAllprodcutsInward()
{
$builder = $this->db->table('t_materialmaster')
->select('MaterialCode,MaterialName')
->like('t_materialmaster.Category', 'raw material');
$result = $builder->get();
return $result->getResult();
}
function getAllcustomers()
{
$builder = $this->db->table('ip_clients')
->select('client_id,client_name');
$result = $builder->get();
return $result->getResult();
}
function getAllcustomersInward()
{
$builder = $this->db->table('t_supplierdetailsn')
->select('SupplierID,SupplierName')
->where('IsActive', 1);
$result = $builder->get();
return $result->getResult();
}
function checkExist($product, $customer, $name, $type)
{
$builder = $this->db->table('T_Prodcut_Specification_Master')
->select('count(*) as count')
->where('product_id', $product)
->where('customer_id', $customer)
->where('testtype', $name)
->where('type', $type);
$result = $builder->get();
return $result->getResult();
}
function addSpecMast($data)
{
//print_r($data);
$builder = $this->db->table('T_Prodcut_Specification_Master');
$builder->insert($data);
$r = $this->db->affectedRows();
return $r;
}
function updateSpecMast($data, $product, $customer, $name, $type)
{
//echo $product.$customer.$name;
//print_r($data);
$this->db->table('T_Prodcut_Specification_Master')
->where('product_id', $product)
->where('customer_id', $customer)
->where('testtype', $name)
->where('type', $type)
->update($data);
$r = $this->db->affectedRows();
//echo $r;die();
return $r;
}
function getAllspec()
{
$builder = $this->db->table('T_Prodcut_Specification_Master')
->select('T_Prodcut_Specification_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name,count(*) as count')
->join('ip_products', 'T_Prodcut_Specification_Master.product_id=ip_products.product_id')
->join('ip_clients', 'T_Prodcut_Specification_Master.customer_id=ip_clients.client_id')
->groupBy('product_id,customer_id,T_Prodcut_Specification_Master.type');
$result = $builder->get();
return $result->getResult();
}
function getAllspecInward()
{
$builder = $this->db->table('T_Prodcut_Specification_Master')
->select('T_Prodcut_Specification_Master.*,t_materialmaster.MaterialCode,t_materialmaster.MaterialName,t_supplierdetailsn.SupplierID,t_supplierdetailsn.SupplierName,count(*) as count')
->join('t_materialmaster', 'T_Prodcut_Specification_Master.product_id=t_materialmaster.MaterialCode')
->join('t_supplierdetailsn', 'T_Prodcut_Specification_Master.customer_id=t_supplierdetailsn.SupplierID')
->groupBy('product_id,customer_id,T_Prodcut_Specification_Master.type');
$result = $builder->get();
return $result->getResult();
}
function getIndividualSpec($prodcutid, $customerid, $type)
{
$builder = $this->db->table('T_Prodcut_Specification_Master')
->select('T_Prodcut_Specification_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name')
->join('ip_products', 'T_Prodcut_Specification_Master.product_id=ip_products.product_id')
->join('ip_clients', 'T_Prodcut_Specification_Master.customer_id=ip_clients.client_id')
->where('T_Prodcut_Specification_Master.product_id', $prodcutid)
->where('T_Prodcut_Specification_Master.customer_id', $customerid)
->where('T_Prodcut_Specification_Master.type', $type);
$result = $builder->get();
//print_r($result->getResult());
if (empty($result->getResult())) {
$builders = $this->db->table('T_Prodcut_Specification_Master')
->select('T_Prodcut_Specification_Master.*,t_materialmaster.MaterialCode,t_materialmaster.MaterialName as product_name,t_supplierdetailsn.SupplierID,t_supplierdetailsn.SupplierName as client_name')
->join('t_materialmaster', 'T_Prodcut_Specification_Master.product_id=t_materialmaster.MaterialCode')
->join('t_supplierdetailsn', 'T_Prodcut_Specification_Master.customer_id=t_supplierdetailsn.SupplierID')
->where('T_Prodcut_Specification_Master.product_id', $prodcutid)
->where('T_Prodcut_Specification_Master.customer_id', $customerid)
->where('T_Prodcut_Specification_Master.type', $type);
$results = $builders->get();
}
//exit();
return $results->getResult();
}
function deleteSpecification($spname, $product, $customer, $type)
{
$this->db->table('T_Prodcut_Specification_Master')
->delete(["testtype" => $spname, "product_id" => $product, "customer_id" => $customer, "type" => $type]);
$r = $this->db->affectedRows();
return $r;
}
function getDataforReport()
{
$builder = $this->db->table('ip_invoices')
->select('ip_invoices.invoice_number,ip_invoices.client_id,ip_invoice_custom.invoice_custom_fieldvalue,ip_clients.client_name,ip_invoices.invoice_date_created,ip_invoice_items.item_product_id,ip_products.product_name,ip_products.product_description,ip_invoice_items.item_quantity')
->join('ip_clients', 'ip_invoices.client_id=ip_clients.client_id')
->join('ip_invoice_items', 'ip_invoices.invoice_id=ip_invoice_items.invoice_id')
->join('ip_products', 'ip_invoice_items.item_product_id=ip_products.product_id')
->join('ip_invoice_custom', 'ip_invoices.invoice_id=ip_invoice_custom.invoice_id and invoice_custom_fieldid=62')
->where('ip_invoices.invoice_number NOT IN (SELECT invoiceid from T_Test_Report_Master where invoiceid is not null)', NULL, false)
->orderBy('ip_invoices.invoice_number', 'desc');
$res = $builder->get();
//print_r($res->getResult());die();
return $res->getResult();
}
function getSpecifications($productid, $customerid, $ttype = "")
{
//echo 'from model'.$productid.'-'.$customerid;
// $this->db->where('product_id',$productid);
// $this->db->where('customer_id',$customerid);
// $res = $this->db->get('T_Prodcut_Specification_Master');
$sql = '';
$res = "";
if (!empty($ttype)) {
$sql = "Select * from T_Prodcut_Specification_Master where product_id = ? and customer_id = ? and type = ?";
$res = $this->db->query($sql, array($productid, $customerid, $ttype));
} else {
$sql = "Select * from T_Prodcut_Specification_Master where product_id = ? and customer_id = ?";
$res = $this->db->query($sql, array($productid, $customerid));
}
return $res->getResult();
//print_r($res->getResult());
}
function getOperatorsListforReport()
{
$builder = $this->db->table('t_employee_details')->select('EmpID,FirstName,LastName');
return $builder->get()->getResult();
}
function getExistOperatorsListforReport($rbcid)
{
$sql = "select t_employee_details.EmpID,t_employee_details.FirstName,t_employee_details.LastName
from T_ResinBatchCard_Operators join t_employee_details on T_ResinBatchCard_Operators.EmpID =
t_employee_details.EmpID where T_ResinBatchCard_Operators.master_id = ?";
$r = $this->db->query($sql, array($rbcid));
return $r->getResult();
}
function getEmplistforReport()
{
$builder = $this->db->table('t_employee_details')
->select('t_employee_details.EmpID,t_employee_details.FirstName,t_employee_details.LastName,t_employee_details.Departmentcode,t_departmentdetails.shortName')
->join('t_departmentdetails', 't_employee_details.Departmentcode=t_departmentdetails.DEPCode')
//->join('ip_invoice_items','ip_invoices.invoice_number=ip_invoice_items.invoice_number')
//->join('ip_products','ip_invoice_items.item_product_id=ip_products.product_id')
//->join('ip_invoice_custom','ip_invoices.invoice_number=ip_invoice_custom.invoice_number and invoice_custom_fieldid=62')
->orderBy('t_employee_details.EmpID');
$res = $builder->get();
return $res->getResult();
}
function saveMasterTestData($masterreportdata)
{
$builder = $this->db->table('T_Test_Report_Master');
$builder->insert($masterreportdata);
$id = $this->db->insertId();
return $id;
}
function saveResinBatchCardMasterTestData($masterreportdata)
{
$builder = $this->db->table('T_ResinBatchCard_Master');
$builder->insert($masterreportdata);
$id = $this->db->insertId();
return $id;
}
function updateResinBatchCardChildTestData($newArray)
{
$builder = $this->db->table('T_ResinBatchCard_Child')->select('resinbatchcard_iter_id')
->where('master_report_id', $newArray['master_report_id'])
->where('i_time', $newArray['i_time'])
->where('spec_id', $newArray['spec_id']);
$res = $builder->get()->getResult();
if (!empty($res[0]->resinbatchcard_iter_id)) {
$this->db->table('T_ResinBatchCard_Child')
->where('master_report_id', $newArray['master_report_id'])
->where('i_time', $newArray['i_time'])
->where('spec_id', $newArray['spec_id'])
->update($newArray);
} else {
$this->saveResinBatchCardChildTestData($newArray);
}
}
function saveResinBatchCardChildTestData($newArray)
{
$builder = $this->db->table('T_ResinBatchCard_Child');
$builder->insert($newArray);
}
function updateResinBatchCardMasterTestData($masterreportdata, $MASTERID)
{
$this->db->table('T_ResinBatchCard_Master')
->where('resinbatch_id', $MASTERID)
->update($masterreportdata);
}
function getResinBatchCardDetails($rbcid)
{
$sql = 'select T_ResinBatchCard_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name,T_Machine_Master.Machine_Name,t_employee_details.EmpID,t_employee_details.FirstName,t_employee_details.LastName,a.FirstName as name from T_ResinBatchCard_Master
join ip_products on T_ResinBatchCard_Master.productid = ip_products.product_id
join ip_clients on T_ResinBatchCard_Master.customerid = ip_clients.client_id
join T_Machine_Master on T_ResinBatchCard_Master.machinecode = T_Machine_Master.Machine_Code
join tbl_users on T_ResinBatchCard_Master.createdby = tbl_users.userId
join t_employee_details on tbl_users.EmpID = t_employee_details.EmpID
join t_employee_details as a on a.EmpID = T_ResinBatchCard_Master.operatedby
where T_ResinBatchCard_Master.resinbatch_id = ?';
$res['masterdata'] = $this->db->query($sql, array($rbcid))->getResult();
//print_r($res['masterdata']);
$sql = 'select T_ResinBatchCard_Child.*,T_Prodcut_Specification_Master.testtype from T_ResinBatchCard_Child
join T_Prodcut_Specification_Master on T_ResinBatchCard_Child.spec_id = T_Prodcut_Specification_Master.productspecmaster_id
where master_report_id = ?;';
$res['childdata'] = $this->db->query($sql, array($rbcid))->getResult();
$sid = '';
//print_r($res['childdata']);
$index = 0;
$newArray = array();
$allspecs = array('TEST');
foreach ($res['childdata'] as $c) {
if ($sid != $c->i_time) {
$index++;
$newArray[$index] = array($c->i_time, $c->spec_value);
if ($index == 1) {
array_push($allspecs, strtolower($c->testtype));
}
} else {
array_push($newArray[$index], $c->spec_value);
if ($index == 1) {
array_push($allspecs, strtolower($c->testtype));
}
}
$sid = $c->i_time;
}
$res['childdata'] = $newArray;
//print_r($res['childdata']);
$res['allspec'] = $allspecs;
return $res;
}
function getResinBatchCardTestMasterList()
{
$sql = 'Select resinbatch_id,productid,ip_products.product_name,ip_products.product_description,customerid,client_name,batchdate,igrno,igrlineno,operatedby,T_ResinBatchCard_Master.createdby,approvedby,document,ED.FirstName from T_ResinBatchCard_Master
join ip_products on T_ResinBatchCard_Master.productid=ip_products.product_id
join ip_clients on T_ResinBatchCard_Master.customerid=ip_clients.client_id
join tbl_users on T_ResinBatchCard_Master.createdby = tbl_users.userId
join t_employee_details ED on ED.EmpID = T_ResinBatchCard_Master.operatedby
join t_employee_details EmpDtl on EmpDtl.EmpID = tbl_users.EmpID';
$res = $this->db->query($sql);
return $res->getResult();
}
function saveTestReportData($testreportdata)
{
$builder = $this->db->table('T_Test_Report');
$builder->insert($testreportdata);
$row = $this->db->affectedRows();
return $row;
}
function saveTestReportAFSData($afstabledata)
{
$builder = $this->db->table('T_Test_Report_AFS');
$builder->insert($afstabledata);
$row = $this->db->affectedRows();
return $row;
}
function saveTestReportLOIData($loitabledata)
{
$builder = $this->db->table('T_Test_Report_LOI');
$builder->insert($loitabledata);
$row = $this->db->affectedRows();
return $row;
}
function getIndividualReportData($reportid)
{
$builder = $this->db->table('T_Test_Report_Master')->select('T_Test_Report_Master.testreport_id,ip_invoices.invoice_date_created,T_Test_Report_Master.invoiceid,T_Test_Report_Master.batchdate,T_Test_Report_Master.chartdata,ip_clients.client_id,ip_clients.client_name,invoice_custom_fieldvalue,ip_products.product_id,ip_products.product_name,ip_products.product_description,t_employee_details.FirstName,t_employee_details.LastName,ip_invoice_items.item_quantity,T_Test_Report_Master.approvedby')
->join('ip_invoices', 'T_Test_Report_Master.invoiceid=ip_invoices.invoice_number')
->join('ip_clients', 'ip_invoices.client_id=ip_clients.client_id')
->join('ip_invoice_items', 'ip_invoices.invoice_id=ip_invoice_items.invoice_id')
->join('ip_products', 'ip_products.product_id=ip_invoice_items.item_product_id')
->join('ip_invoice_custom', 'ip_invoices.invoice_id=ip_invoice_custom.invoice_id and invoice_custom_fieldid=62')
->join('tbl_users', 'T_Test_Report_Master.createdby=tbl_users.userid')
->join('t_employee_details', 'tbl_users.EmpID=t_employee_details.EmpID')
//->join('t_employee_details','T_Test_Report_Master.EmpID=t_employee_details.EmpID');
//->join('ip_invoice_custom','ip_invoices.invoice_number=ip_invoice_custom.invoice_number and invoice_custom_fieldid=62');
->where('testreport_id', $reportid);
// ->join('T_Test_Report','T_Test_Report_Master.testreport_id=T_Test_Report.testreport_id');
// ->join('T_Test_Report_loi','T_Test_Report_Master.testreport_id=T_Test_Report_loi.testreport_id');
// ->join('T_Test_Report_afs','T_Test_Report_Master.testreport_id=T_Test_Report_afs.testreport_id');
$res = $builder->get();
$reportdata['master'] = $res->getResult();
$builders = $this->db->table('T_Test_Report')
->select('T_Test_Report.*')
->where('testreport_id', $reportid);
$ress = $builders->get();
$reportdata['masterreport'] = $ress->getResult();
$builder1 = $this->db->table('T_Test_Report_LOI')
->select('T_Test_Report_LOI.*')
->where('testreport_id', $reportid);
$res1 = $builder1->get();
$reportdata['masterreportloi'] = $res1->getResult();
$builder2 = $this->db->table('T_Test_Report_AFS')
->select('T_Test_Report_AFS.*')
->where('testreport_id', $reportid);
$res2 = $builder2->get();
$reportdata['masterreportafs'] = $res2->getResult();
$builder3 = $this->db->table('t_company_details')
->select('t_company_details.CompanyName,t_company_details.Address,t_company_details.ProfilePic');
//->where('testreport_id',$reportid)
$res3 = $builder3->get();
$reportdata['company'] = $res3->getResult();
return $reportdata;
}
function getIndividualInwardReportData($reportid)
{
$builder = $this->db->table('T_Test_Report_Master')
->select('T_Test_Report_Master.chartdata,T_Test_Report_Master.batchdate,T_Test_Report_Master.testreport_id,t_igr_master.IGRNO,t_igr_master.DeliveryChellanOrInvoiceNo,t_igr_master.DeliveryChellanDate,t_igr_details.IGRItemNo,t_igr_details.QuantityAsPerInvoice,t_materialmaster.MaterialCode,t_materialmaster.Materialname,t_supplierdetailsn.SupplierID,t_supplierdetailsn.SupplierName,T_Test_Report_Master.approvedby,t_employee_details.EmpID,t_employee_details.FirstName,t_employee_details.LastName')
->join('t_igr_master', 'T_Test_Report_Master.igrno=t_igr_master.IGRNO')
->join('t_igr_details', 'T_Test_Report_Master.igrlineitemno=t_igr_details.IGRItemNo')
->join('t_purchaseorder_master', 't_igr_master.PONO=t_purchaseorder_master.PONO')
->join('t_materialmaster', 't_igr_details.MaterialCode=t_materialmaster.MaterialCode')
->join('t_supplierdetailsn', 't_purchaseorder_master.SupplierID=t_supplierdetailsn.SupplierID')
->join('tbl_users', 'T_Test_Report_Master.createdby=tbl_users.userid')
->join('t_employee_details', 'tbl_users.EmpID=t_employee_details.EmpID')
->where('T_Test_Report_Master.testreport_id', $reportid);
$res = $builder->get();
$reportdata['master'] = $res->getResult();
$builder1 = $this->db->table('T_Test_Report')
->select('T_Test_Report.*')
->where('testreport_id', $reportid);
$res1 = $builder1->get();
$reportdata['masterreport'] = $res1->getResult();
$builder2 = $this->db->table('T_Test_Report_LOI')
->select('T_Test_Report_LOI.*')
->where('testreport_id', $reportid);
$res2 = $builder2->get();
$reportdata['masterreportloi'] = $res2->getResult();
$builder3 = $this->db->table('T_Test_Report_AFS')
->select('T_Test_Report_AFS.*')
->where('testreport_id', $reportid);
$res3 = $builder3->get();
$reportdata['masterreportafs'] = $res3->getResult();
$builder4 = $this->db->table('t_company_details')
->select('t_company_details.CompanyName,t_company_details.Address,t_company_details.ProfilePic');
//->where('testreport_id',$reportid);
$res4 = $builder4->get()->getResult();
$reportdata['company'] = $res4;
return $reportdata;
}
function getTestMasterforList()
{
$builder = $this->db->table('T_Test_Report_Master')->select('T_Test_Report_Master.testreport_id,T_Test_Report_Master.invoiceid,T_Test_Report_Master.batchdate,T_Test_Report_Master.document,ip_clients.client_id,ip_clients.client_name,ip_products.product_id,ip_products.product_name,ip_products.product_description')
->join('ip_invoices', 'T_Test_Report_Master.invoiceid=ip_invoices.invoice_number')
->join('ip_clients', 'ip_invoices.client_id=ip_clients.client_id')
->join('ip_invoice_items', 'ip_invoices.invoice_id=ip_invoice_items.invoice_id')
->join('ip_products', 'ip_products.product_id=ip_invoice_items.item_product_id');
//$this->db->where('T_Test_Report_Master.invoiceid','!=0');
$res = $builder->get()->getResult();
return $res;
}
function getTestMasterforListInward()
{
// ->select('T_Test_Report_Master.testreport_id,T_Test_Report_Master.igrno,T_Test_Report_Master.igrlineitemno,T_Test_Report_Master.batchdate,ip_clients.client_id,ip_clients.client_name,ip_products.product_id,ip_products.product_name,ip_products.product_description');
// $builder = $this->db->table('T_Test_Report_Master');
// ->join('ip_invoices','T_Test_Report_Master.invoiceid=ip_invoices.invoice_number');
// ->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
// ->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
// ->join('ip_products','ip_products.product_id=ip_invoice_items.item_product_id');
// $res = $builder->get();
// return $res->getResult();
$builder = $this->db->table('T_Test_Report_Master')->select('T_Test_Report_Master.batchdate,T_Test_Report_Master.testreport_id,t_igr_master.IGRNO,t_igr_master.DeliveryChellanOrInvoiceNo,t_igr_master.DeliveryChellanDate,t_igr_details.IGRItemNo,t_igr_details.QuantityAsPerInvoice,t_materialmaster.MaterialCode,t_materialmaster.Materialname,t_supplierdetailsn.SupplierID,t_supplierdetailsn.SupplierName,T_Test_Report_Master.approvedby,T_Test_Report_Master.document,t_employee_details.EmpID,t_employee_details.FirstName,t_employee_details.LastName')
->join('t_igr_master', 'T_Test_Report_Master.igrno=t_igr_master.IGRNO')
->join('t_igr_details', 'T_Test_Report_Master.igrlineitemno=t_igr_details.IGRItemNo')
->join('t_purchaseorder_master', 't_igr_master.PONO=t_purchaseorder_master.PONO')
->join('t_materialmaster', 't_igr_details.MaterialCode=t_materialmaster.MaterialCode')
->join('t_supplierdetailsn', 't_purchaseorder_master.SupplierID=t_supplierdetailsn.SupplierID')
->join('tbl_users', 'T_Test_Report_Master.createdby=tbl_users.userid')
->join('t_employee_details', 'tbl_users.EmpID=t_employee_details.EmpID')
->orderBy('testreport_id', 'desc');
$res = $builder->get();
return $res->getResult();
}
function getIGRNOforReport()
{
// $this->db->distinct();
// ->select('IGRNO');
// $builder = $this->db->table('t_igr_details');
// ->join('t_materialmaster','t_igr_details.MaterialCode=t_materialmaster.MaterialCode');
// $this->db->like('t_materialmaster.Category','raw material');
$sql = 'select distinct IGRNO from t_igr_details
join t_materialmaster on t_igr_details.MaterialCode = t_materialmaster.MaterialCode
where t_materialmaster.Category like "%Raw Material%"and date(t_igr_details.CreatedDate)
between date(SUBDATE(CURRENT_DATE,1)) and date(CURRENT_DATE)
order by IGRNO desc';
$result = $this->db->query($sql);
return $result->getResult();
}
function getIGRLineItemNo($igrno)
{
// ->select('IGRItemNo');
// $builder = $this->db->table('t_igr_details');
// $this->db->where('IGRNO',$igrno);
$sql = 'select IGRItemNo from t_igr_details
join t_materialmaster on t_igr_details.MaterialCode = t_materialmaster.MaterialCode
where IGRNO = ? and t_materialmaster.Category like "%Raw Material%"';
$result = $this->db->query($sql, array($igrno));
return $result->getResult();
}
function getIGRNOReport()
{
$builder = $this->db->table('T_Test_Report_Master')
->select('igrno,igrlineitemno');
$res['generated'] = ($builder->get()->getResult());
// ->select('IGRNO,IGRItemNo');
// $builder = $this->db->table('t_igr_details');
// $this->db->where('IGRNO NOT IN (SELECT IGRNO from T_Test_Report_Master)',NULL,false);
// $this->db->orWhere('IGRItemNo NOT IN (SELECT IGRItemNo from T_Test_Report_Master)',NULL,false);
$sql = 'select distinct IGRNO,IGRItemNo from t_igr_details join t_materialmaster on t_igr_details.MaterialCode = t_materialmaster.MaterialCode
where (t_igr_details.IGRNO not in (select igrno from T_Test_Report_Master where igrno != "")
or t_igr_details.IGRItemNo not in (select igrlineitemno from T_Test_Report_Master where igrno != "") )
and t_materialmaster.Category like "%Raw Material%"
order by t_igr_details.IGRNO DESC';
$r = $this->db->query($sql);
$res['notgenerated'] = ($r->getResult());
return $res;
}
function getIGRDataforReport($igrno, $igrlineitemno)
{
//echo $igrno.'-'.$igrlineitemno;die();
// ->select('t_igr_master.DeliveryChellanOrInvoiceNo,t_igr_master.DeliveryChellanDate,t_supplierdetailsn.SupplierID,t_supplierdetailsn.SupplierName,t_materialmaster.MaterialCode,t_materialmaster.MaterialName,t_igr_details.QuantityAsPerInvoice');
// $builder = $this->db->table('t_igr_master');
// ->join('t_igr_details','t_igr_master.IGRNO=t_igr_details.IGRNO');
// ->join('t_materialmaster','t_igr_details.MaterialCode=t_materialmaster.MaterialCode');
// ->join('t_purchaseorder_master','t_igr_master.PONO=t_purchaseorder_master.PONO');
// ->join('t_supplierdetailsn','t_purchaseorder_master.SupplierID=t_supplierdetailsn.SupplierID');
// $this->db->where('t_igr_details.IGRNO',$igrno);
// $this->db->where('t_igr_details.IGRItemNo',$igrlineitemno);
// $this->db->orderBy('t_igr_master.IGRNO');
// $res = $builder->get();
// return $res->getResult();
$sql = 'select t_igr_master.DeliveryChellanOrInvoiceNo, date_format(t_igr_master.DeliveryChellanDate,"%d-%m-%Y") as DeliveryChellanDate,t_supplierdetailsn.SupplierID,t_supplierdetailsn.SupplierName,t_materialmaster.MaterialCode,
t_materialmaster.MaterialName,t_igr_details.QuantityAsPerInvoice
from t_igr_master
join t_igr_details on t_igr_master.IGRNO=t_igr_details.IGRNO
join t_materialmaster on t_igr_details.MaterialCode=t_materialmaster.MaterialCode
join t_purchaseorder_master on t_igr_master.PONO=t_purchaseorder_master.PONO
join t_supplierdetailsn on t_purchaseorder_master.SupplierID=t_supplierdetailsn.SupplierID
where t_igr_master.IGRNO = ? and t_igr_details.IGRItemNo = ?';
$res = $this->db->query($sql, array($igrno, $igrlineitemno));
return $res->getResult();
}
function getIGRNos()
{
$sql = 'select IGRNO from t_igr_master order by IGRNO desc';
$res = $this->db->query($sql);
return $res->getResult();
}
function getMachineList()
{
$sql = 'select Machine_Code,Machine_Name from T_Machine_Master';
$res = $this->db->query($sql);
return $res->getResult();
}
function getTRPBatchcardNos()
{
$sql = 'select dailyid from T_daily_batchcard_data';
$res = $this->db->query($sql);
return $res->getResult();
}
function getIGRItemNos()
{
$sql = 'select IGRItemNo from t_igr_details order by IGRItemNo desc';
$res = $this->db->query($sql);
return $res->getResult();
}
}