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

280 lines
8.3 KiB
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class Inprocess_model extends Model
{
function getAllprodcuts()
{
$builder = $this->db->table('ip_products')
->select('product_id,product_name,product_description');
$query =$builder->get();
return $query->getResult();
}
function getAllcustomers()
{
$builder = $this->db->table('ip_clients')
->select('client_id,client_name');
$query =$builder->get();
return $query->getResult();
}
function getAllTestReports()
{
$builder = $this->db->table('T_Inprocess_Testreport_Master')
->select('masterreport_id,productid,ip_products.product_name,customerid,ip_clients.client_name,batchno,batchdate,document')
->join('ip_products','T_Inprocess_Testreport_Master.productid=ip_products.product_id')
->join('ip_clients','T_Inprocess_Testreport_Master.customerid=ip_clients.client_id');
$query =$builder->get();
return $query->getResult();
}
function getSpecifications($productid,$customerid)
{
//echo 'from model'.$productid.'-'.$customerid;
// ->where('product_id',$productid);
// ->where('customer_id',$customerid);
// $res = $this->db->get('T_Prodcut_Specification_Master');
$sql = "Select * from T_Prodcut_Specification_Master where product_id = ? and customer_id = ?";
$res = $this->db->query($sql,array($productid,$customerid));
// print_r($this->db->last_query());
return $res->getResult();
//print_r($res->result());
}
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');
$query =$builder->get();
return $query->getResult();
}
function saveMasterTestData($masterreportdata)
{
$builder = $this->db->table('T_Inprocess_Testreport_Master');
$builder->insert($masterreportdata);
$row = $this->db->affectedRows();
$id = $this->db->insertId();
return $id;
}
function saveTestReportData($testreportdata)
{
foreach($testreportdata as $data)
{
$builder = $this->db->table('T_Inprocess_Testreport');
$builder->insert($data);
$row = $this->db->affectedRows();
$id = $this->db->insertId();
}
}
function saveTestReportAFSData($afstabledata)
{
$builder = $this->db->table('T_Inprocess_AFSTestreport');
$builder->insert($afstabledata);
$row = $this->db->affectedRows();
//return $row;
}
function saveTestReportLOIData($loitabledata)
{
$builder = $this->db->table('T_Inprocess_LOITestreport');
$builder->insert($loitabledata);
$row = $this->db->affectedRows();
//return $row;
}
function getIndividualInprocessReportData($reportid)
{
$builder = $this->db->table('T_Inprocess_Testreport_Master')->select('T_Inprocess_Testreport_Master.*,ip_clients.client_name,ip_products.product_name,ip_products.product_description,t_employee_details.FirstName,t_employee_details.LastName')
->join('ip_clients','T_Inprocess_Testreport_Master.customerid=ip_clients.client_id')
->join('ip_products','T_Inprocess_Testreport_Master.productid=ip_products.product_id')
->join('tbl_users','T_Inprocess_Testreport_Master.createdby=tbl_users.userid')
->join('t_employee_details','tbl_users.EmpID=t_employee_details.EmpID')
->where('T_Inprocess_Testreport_Master.masterreport_id',$reportid);
$res =$builder->get();
$reportdata['master'] = $res->getResult();
$builder = $this->db->table('T_Inprocess_Testreport')
->select('T_Inprocess_Testreport.*,T_Prodcut_Specification_Master.testtype,T_Prodcut_Specification_Master.min,T_Prodcut_Specification_Master.max,T_Prodcut_Specification_Master.uom')
->join('T_Prodcut_Specification_Master','T_Inprocess_Testreport.specid=T_Prodcut_Specification_Master.productspecmaster_id')
->where('masterreport_id',$reportid);
$res1 = $builder->get();
$reportdata['masterreport'] = $res1->getResult();
$builder = $this->db->table('T_Inprocess_LOITestreport')
->select('T_Inprocess_LOITestreport.*')
->where('masterreport_id',$reportid);
$res1 = $builder->get();
$reportdata['masterreportloi'] = $res1->getResult();
$builder = $this->db->table('T_Inprocess_AFSTestreport')
->select('T_Inprocess_AFSTestreport.*')
->where('masterreport_id',$reportid);
$res1 = $builder->get();
$reportdata['masterreportafs'] = $res1->getResult();
$builder = $this->db->table('t_company_details')
->select('t_company_details.CompanyName,t_company_details.Address,t_company_details.ProfilePic');
//->where('testreport_id',$reportid);
$res1 = $builder->get();
$reportdata['company'] = $res1->getResult();
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');
//->where('T_Test_Report_Master.invoiceid','!=0');
$res = $builder->get();
return $res->getResult();
}
function updateMasterTestData($masterreportdata,$masterid)
{
$this->db->table('T_Inprocess_Testreport_Master')
->where('masterreport_id',$masterid)
->update($masterreportdata);
}
function updateTestReportData($testreportdata,$masterid,$specid)
{
foreach($testreportdata as $data)
{
$this->db->table('T_Inprocess_Testreport')
->where('masterreport_id',$masterid)
->where('specid',$specid)
->where('iteration',$data['iteration'])
->where('subtype',$data['subtype'])
->update($data);
//echo $this->db->last_query();
}
}
function updateTestReportAFSData($afstabledata,$masterid,$ssize,$factor)
{
$this->db->table('T_Inprocess_AFSTestreport')
->where('masterreport_id',$masterid)
->where('sieve_size',$ssize)
->where('factor',$factor)
->update($afstabledata);
// echo $this->db->last_query();
}
function updateTestReportLOIData($loitabledata,$masterid,$loidetails)
{
$this->db->table('T_Inprocess_LOITestreport')
->where('masterreport_id',$masterid)
->where('loidetails',$loidetails)
->update($loitabledata);
//echo $this->db->last_query();
}
//FOR NISSAN INPROCESS
function updateNissanMasterTestData($masterreportdata,$masterid)
{
//echo "from model";
//print_r($masterreportdata);die();
$this->db->table('T_Inprocess_Testreport_Master')
->where('masterreport_id',$masterid)
->update($masterreportdata);
}
function updateNissanTestReportData($testreportdata,$masterid,$specid)
{
foreach($testreportdata as $data)
{
$this->db->table('T_Inprocess_Testreport')
->where('masterreport_id',$masterid)
->where('specid',$specid)
->where('iteration',$data['iteration'])
->where('subtype',$data['subtype'])
->update($data);
//echo $this->db->last_query();
}
}
function updateNissanTestReportAFSData($afstabledata,$masterid,$ssize,$factor)
{
$this->db->table('T_Inprocess_AFSTestreport')
->where('masterreport_id',$masterid)
->where('sieve_size',$ssize)
->where('factor',$factor)
->update($afstabledata);
// echo $this->db->last_query();
}
function updateNissanTestReportLOIData($loitabledata,$masterid,$loidetails)
{
$this->db->table('T_Inprocess_LOITestreport')
->where('masterreport_id',$masterid)
->where('loidetails',$loidetails)
->update($loitabledata);
//echo $this->db->last_query();
}
}
?>