226 lines
9.1 KiB
PHP
226 lines
9.1 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Quality_model extends CI_Model
|
|
{
|
|
function getAllInvoiceNo()
|
|
{
|
|
$this->db->select('invoice_number');
|
|
$this->db->from('ip_invoices');
|
|
$result = $this->db->get();
|
|
return $result->result();
|
|
}
|
|
|
|
function getAllprodcuts()
|
|
{
|
|
$this->db->select('product_id,product_name,product_description');
|
|
$this->db->from('ip_products');
|
|
$result = $this->db->get();
|
|
return $result->result();
|
|
}
|
|
|
|
function getAllcustomers()
|
|
{
|
|
$this->db->select('client_id,client_name');
|
|
$this->db->from('ip_clients');
|
|
$result = $this->db->get();
|
|
return $result->result();
|
|
}
|
|
|
|
function checkExist($product,$customer,$name)
|
|
{
|
|
$this->db->select('count(*) as count');
|
|
$this->db->from('T_Prodcut_Specification_Master');
|
|
$this->db->where('product_id',$product);
|
|
$this->db->where('customer_id',$customer);
|
|
$this->db->where('testtype',$name);
|
|
$result = $this->db->get();
|
|
return $result->result();
|
|
}
|
|
|
|
|
|
function addSpecMast($data)
|
|
{
|
|
//print_r($data);
|
|
$this->db->insert('T_Prodcut_Specification_Master',$data);
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
function updateSpecMast($data,$product,$customer,$name)
|
|
{
|
|
//echo $product.$customer.$name;
|
|
//print_r($data);
|
|
$this->db->where('product_id',$product);
|
|
$this->db->where('customer_id',$customer);
|
|
$this->db->where('testtype',$name);
|
|
$this->db->update('T_Prodcut_Specification_Master',$data);
|
|
$r = $this->db->affected_rows();
|
|
//echo $r;die();
|
|
return $r;
|
|
}
|
|
|
|
function getAllspec()
|
|
{
|
|
$this->db->select('T_Prodcut_Specification_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name,count(*) as count');
|
|
$this->db->from('T_Prodcut_Specification_Master');
|
|
$this->db->join('ip_products','T_Prodcut_Specification_Master.product_id=ip_products.product_id');
|
|
$this->db->join('ip_clients','T_Prodcut_Specification_Master.customer_id=ip_clients.client_id');
|
|
$this->db->group_by('product_id,customer_id');
|
|
$result = $this->db->get();
|
|
return $result->result();
|
|
}
|
|
|
|
|
|
function getIndividualSpec($prodcutid,$customerid)
|
|
{
|
|
$this->db->select('T_Prodcut_Specification_Master.*,ip_products.product_name,ip_products.product_description,ip_clients.client_name');
|
|
$this->db->from('T_Prodcut_Specification_Master');
|
|
$this->db->join('ip_products','T_Prodcut_Specification_Master.product_id=ip_products.product_id');
|
|
$this->db->join('ip_clients','T_Prodcut_Specification_Master.customer_id=ip_clients.client_id');
|
|
$this->db->where('T_Prodcut_Specification_Master.product_id',$prodcutid);
|
|
$this->db->where('T_Prodcut_Specification_Master.customer_id',$customerid);
|
|
$result = $this->db->get();
|
|
return $result->result();
|
|
}
|
|
|
|
|
|
function deleteSpecification($spname,$product,$customer)
|
|
{
|
|
$this->db->where("testtype", $spname);
|
|
$this->db->where("product_id", $product);
|
|
$this->db->where("customer_id", $customer);
|
|
$this->db->delete('T_Prodcut_Specification_Master');
|
|
$r = $this->db->affected_rows();
|
|
return $r;
|
|
}
|
|
|
|
|
|
function getDataforReport()
|
|
{
|
|
$this->db->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');
|
|
$this->db->from('ip_invoices');
|
|
$this->db->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
|
|
$this->db->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
|
|
$this->db->join('ip_products','ip_invoice_items.item_product_id=ip_products.product_id');
|
|
$this->db->join('ip_invoice_custom','ip_invoices.invoice_id=ip_invoice_custom.invoice_id and invoice_custom_fieldid=62');
|
|
$this->db->where('ip_invoices.invoice_number NOT IN (SELECT invoiceid from T_Test_Report_Master)',NULL,false);
|
|
$this->db->order_by('ip_invoices.invoice_number','desc');
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
}
|
|
|
|
function getSpecifications($productid,$customerid)
|
|
{
|
|
$this->db->where('product_id',$productid);
|
|
$this->db->where('customer_id',$customerid);
|
|
$res = $this->db->get('T_Prodcut_Specification_Master');
|
|
return $res->result();
|
|
}
|
|
|
|
function getEmplistforReport()
|
|
{
|
|
$this->db->select('T_Employee_Details.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.Departmentcode,T_DepartmentDetails.shortName,');
|
|
$this->db->from('T_Employee_Details');
|
|
$this->db->join('T_DepartmentDetails','T_Employee_Details.Departmentcode=T_DepartmentDetails.DEPCode');
|
|
//$this->db->join('ip_invoice_items','ip_invoices.invoice_number=ip_invoice_items.invoice_number');
|
|
//$this->db->join('ip_products','ip_invoice_items.item_product_id=ip_products.product_id');
|
|
//$this->db->join('ip_invoice_custom','ip_invoices.invoice_number=ip_invoice_custom.invoice_number and invoice_custom_fieldid=62');
|
|
$this->db->order_by('T_Employee_Details.EmpID');
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
|
|
}
|
|
|
|
|
|
function saveMasterTestData($masterreportdata)
|
|
{
|
|
$this->db->insert('T_Test_Report_Master',$masterreportdata);
|
|
$id = $this->db->insert_id();
|
|
return $id;
|
|
}
|
|
|
|
function saveTestReportData($testreportdata)
|
|
{
|
|
$this->db->insert('T_Test_Report',$testreportdata);
|
|
$row = $this->db->affected_rows();
|
|
return $row;
|
|
}
|
|
|
|
function saveTestReportAFSData($afstabledata)
|
|
{
|
|
$this->db->insert('T_Test_Report_AFS',$afstabledata);
|
|
$row = $this->db->affected_rows();
|
|
return $row;
|
|
}
|
|
|
|
function saveTestReportLOIData($loitabledata)
|
|
{
|
|
$this->db->insert('T_Test_Report_LOI',$loitabledata);
|
|
$row = $this->db->affected_rows();
|
|
return $row;
|
|
}
|
|
|
|
function getIndividualReportData($reportid)
|
|
{
|
|
|
|
$this->db->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');
|
|
$this->db->from('T_Test_Report_Master');
|
|
$this->db->join('ip_invoices','T_Test_Report_Master.invoiceid=ip_invoices.invoice_number');
|
|
$this->db->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
|
|
$this->db->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
|
|
$this->db->join('ip_products','ip_products.product_id=ip_invoice_items.item_product_id');
|
|
$this->db->join('ip_invoice_custom','ip_invoices.invoice_id=ip_invoice_custom.invoice_id and invoice_custom_fieldid=62');
|
|
$this->db->join('tbl_users','T_Test_Report_Master.createdby=tbl_users.userid');
|
|
$this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID');
|
|
//$this->db->join('T_Employee_Details','T_Test_Report_Master.EmpID=T_Employee_Details.EmpID');
|
|
//$this->db->join('ip_invoice_custom','ip_invoices.invoice_number=ip_invoice_custom.invoice_number and invoice_custom_fieldid=62');
|
|
$this->db->where('testreport_id',$reportid);
|
|
// $this->db->join('T_Test_Report','T_Test_Report_Master.testreport_id=T_Test_Report.testreport_id');
|
|
// $this->db->join('T_Test_Report_loi','T_Test_Report_Master.testreport_id=T_Test_Report_loi.testreport_id');
|
|
// $this->db->join('T_Test_Report_afs','T_Test_Report_Master.testreport_id=T_Test_Report_afs.testreport_id');
|
|
|
|
$res = $this->db->get();
|
|
$reportdata['master'] = $res->result();
|
|
|
|
$this->db->select('T_Test_Report.*');
|
|
$this->db->from('T_Test_Report');
|
|
$this->db->where('testreport_id',$reportid);
|
|
$res1 = $this->db->get();
|
|
$reportdata['masterreport'] = $res1->result();
|
|
|
|
$this->db->select('T_Test_Report_LOI.*');
|
|
$this->db->from('T_Test_Report_LOI');
|
|
$this->db->where('testreport_id',$reportid);
|
|
$res1 = $this->db->get();
|
|
$reportdata['masterreportloi'] = $res1->result();
|
|
|
|
$this->db->select('T_Test_Report_AFS.*');
|
|
$this->db->from('T_Test_Report_AFS');
|
|
$this->db->where('testreport_id',$reportid);
|
|
$res1 = $this->db->get();
|
|
$reportdata['masterreportafs'] = $res1->result();
|
|
|
|
$this->db->select('T_Company_Details.CompanyName,T_Company_Details.Address,T_Company_Details.ProfilePic');
|
|
$this->db->from('T_Company_Details');
|
|
//$this->db->where('testreport_id',$reportid);
|
|
$res1 = $this->db->get();
|
|
$reportdata['company'] = $res1->result();
|
|
|
|
return $reportdata;
|
|
|
|
}
|
|
|
|
function getTestMasterforList()
|
|
{
|
|
$this->db->select('T_Test_Report_Master.testreport_id,T_Test_Report_Master.invoiceid,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');
|
|
$this->db->from('T_Test_Report_Master');
|
|
$this->db->join('ip_invoices','T_Test_Report_Master.invoiceid=ip_invoices.invoice_number');
|
|
$this->db->join('ip_clients','ip_invoices.client_id=ip_clients.client_id');
|
|
$this->db->join('ip_invoice_items','ip_invoices.invoice_id=ip_invoice_items.invoice_id');
|
|
$this->db->join('ip_products','ip_products.product_id=ip_invoice_items.item_product_id');
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
}
|
|
}
|
|
?>
|
|
|