stock changes 06-04-2025
This commit is contained in:
parent
40ea479b73
commit
0289595c86
@ -21,9 +21,10 @@ class Inwardgateregister_model extends Model
|
|||||||
$afftectedRows = $this->db->affectedRows();
|
$afftectedRows = $this->db->affectedRows();
|
||||||
return $afftectedRows;
|
return $afftectedRows;
|
||||||
}
|
}
|
||||||
function getAdditionalIGRFile($igr){
|
function getAdditionalIGRFile($igr)
|
||||||
|
{
|
||||||
$builder = $this->db->table('t_inwardgateregister_fileupload')->select('*')
|
$builder = $this->db->table('t_inwardgateregister_fileupload')->select('*')
|
||||||
->where('IGRNO', $igr);
|
->where('IGRNO', $igr);
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
@ -40,8 +41,8 @@ class Inwardgateregister_model extends Model
|
|||||||
{
|
{
|
||||||
$arr = array('Isactive' => 0);
|
$arr = array('Isactive' => 0);
|
||||||
$this->db->table('t_inwardgateregister_fileupload')
|
$this->db->table('t_inwardgateregister_fileupload')
|
||||||
->where('BillNo', $fileid)
|
->where('BillNo', $fileid)
|
||||||
->update($arr);
|
->update($arr);
|
||||||
$aff = $this->db->affectedRows();
|
$aff = $this->db->affectedRows();
|
||||||
return $aff > 0 ? true : false;
|
return $aff > 0 ? true : false;
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ class Inwardgateregister_model extends Model
|
|||||||
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
||||||
->join('t_inwardgateregister_fileupload fileup', ' igr.IGRNO = fileup.IGRNO', 'left')
|
->join('t_inwardgateregister_fileupload fileup', ' igr.IGRNO = fileup.IGRNO', 'left')
|
||||||
->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID')
|
->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID')
|
||||||
->orderBy('igr.IGRID','desc')
|
->orderBy('igr.IGRID', 'desc')
|
||||||
->groupBy('igr.IGRNO', 'desc');
|
->groupBy('igr.IGRNO', 'desc');
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
@ -136,10 +137,10 @@ class Inwardgateregister_model extends Model
|
|||||||
->join('t_ogr_master OGM ', 'POM.PONO = OGM.PONO_INV', 'left')
|
->join('t_ogr_master OGM ', 'POM.PONO = OGM.PONO_INV', 'left')
|
||||||
// ->where('POM.POType !=', SERVICE) // due to client requirements - he wants to remove the conidition.
|
// ->where('POM.POType !=', SERVICE) // due to client requirements - he wants to remove the conidition.
|
||||||
->where('POM.Status', PO_RELEASED)
|
->where('POM.Status', PO_RELEASED)
|
||||||
->orWhere('POM.Status',REQITEM_Emergency_PO_CREATED)
|
->orWhere('POM.Status', REQITEM_Emergency_PO_CREATED)
|
||||||
->orWhere('POM.Status',IGR_CREATED)
|
->orWhere('POM.Status', IGR_CREATED)
|
||||||
->orWhere('POM.Status', IGR_DRAFT )
|
->orWhere('POM.Status', IGR_DRAFT)
|
||||||
->where( 'POM.IsOpenOrder', 1)
|
->where('POM.IsOpenOrder', 1)
|
||||||
->orWhere('POM.Status', MRIR_CREATED)
|
->orWhere('POM.Status', MRIR_CREATED)
|
||||||
->orWhere('POM.Status', MRIR_APPROVED)
|
->orWhere('POM.Status', MRIR_APPROVED)
|
||||||
->orWhere('POM.Status', OGR_COMPLETE)
|
->orWhere('POM.Status', OGR_COMPLETE)
|
||||||
@ -169,25 +170,26 @@ class Inwardgateregister_model extends Model
|
|||||||
return $temp;
|
return $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkdriverMobile($mobile,$driverName) {
|
public function checkdriverMobile($mobile, $driverName)
|
||||||
|
{
|
||||||
$builder = $this->db->table('t_igr_master')
|
$builder = $this->db->table('t_igr_master')
|
||||||
->distinct()
|
->distinct()
|
||||||
->select('DriverMobileNumber')
|
->select('DriverMobileNumber')
|
||||||
->like('DriverMobileNumber', $mobile);
|
->like('DriverMobileNumber', $mobile);
|
||||||
if($driverName){
|
if ($driverName) {
|
||||||
$builder->where('DriverName', $driverName);
|
$builder->where('DriverName', $driverName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$temparr[] = '';
|
$temparr[] = '';
|
||||||
foreach ($query->getResult() as $arr) {
|
foreach ($query->getResult() as $arr) {
|
||||||
$temparr[] = $arr->DriverMobileNumber;
|
$temparr[] = $arr->DriverMobileNumber;
|
||||||
}
|
}
|
||||||
// echo $this->db->getLastQuery()->getQuery();die;
|
// echo $this->db->getLastQuery()->getQuery();die;
|
||||||
$temp['suggestions'] = $temparr;
|
$temp['suggestions'] = $temparr;
|
||||||
|
|
||||||
return $temp;
|
return $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function viewpurchaseorder($PO)
|
function viewpurchaseorder($PO)
|
||||||
@ -220,9 +222,10 @@ class Inwardgateregister_model extends Model
|
|||||||
return $result; */
|
return $result; */
|
||||||
}
|
}
|
||||||
|
|
||||||
public function igr_history($hsty_arr) {
|
public function igr_history($hsty_arr)
|
||||||
|
{
|
||||||
|
|
||||||
$keysToRemove = ["UpdateBY","UpdateBy", "MaterialRcvdDate", "DeliveryChellanDate"];
|
$keysToRemove = ["UpdateBY", "UpdateBy", "MaterialRcvdDate", "DeliveryChellanDate"];
|
||||||
|
|
||||||
foreach ($keysToRemove as $key) {
|
foreach ($keysToRemove as $key) {
|
||||||
if (isset($hsty_arr[$key])) {
|
if (isset($hsty_arr[$key])) {
|
||||||
@ -235,33 +238,35 @@ class Inwardgateregister_model extends Model
|
|||||||
return $this->db->insertID();
|
return $this->db->insertID();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_igr_history($col,$IGR,$IGRITEM = null)
|
function get_igr_history($col, $IGR, $IGRITEM = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_history Hist')
|
$builder = $this->db->table('t_igr_history Hist')
|
||||||
->select("Hist.*")
|
->select("Hist.*")
|
||||||
->where('Hist.field', $col);
|
->where('Hist.field', $col);
|
||||||
|
|
||||||
if ($IGR) {
|
if ($IGR) {
|
||||||
$builder->where('Hist.IGR_No', $IGR);
|
$builder->where('Hist.IGR_No', $IGR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($IGRITEM !== null) {
|
if ($IGRITEM !== null) {
|
||||||
$builder->where('Hist.IGRItem_No', $IGRITEM);
|
$builder->where('Hist.IGRItem_No', $IGRITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->orderBy('Hist.history_dated', 'DESC');
|
$builder->orderBy('Hist.history_dated', 'DESC');
|
||||||
$builder->limit(1);
|
$builder->limit(1);
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getRow();
|
$result = $query->getRow();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_igr_master_for_history($igr_no) {
|
function get_igr_master_for_history($igr_no)
|
||||||
|
{
|
||||||
return $this->db->table('t_igr_master Master')->where('Master.IGRNO', $igr_no)->get()->getRow();
|
return $this->db->table('t_igr_master Master')->where('Master.IGRNO', $igr_no)->get()->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_igr_child_for_history($igr_no, $igr_item_no) {
|
function get_igr_child_for_history($igr_no, $igr_item_no)
|
||||||
|
{
|
||||||
$builder = $this->db->table('t_igr_details Child'); // Select only the required field
|
$builder = $this->db->table('t_igr_details Child'); // Select only the required field
|
||||||
if ($igr_no) {
|
if ($igr_no) {
|
||||||
$builder->where('Child.IGRNO', $igr_no);
|
$builder->where('Child.IGRNO', $igr_no);
|
||||||
@ -293,34 +298,34 @@ class Inwardgateregister_model extends Model
|
|||||||
$result = [];
|
$result = [];
|
||||||
if ($YesIAmAffected > 0) {
|
if ($YesIAmAffected > 0) {
|
||||||
$result = $this->db->table('t_igr_master')
|
$result = $this->db->table('t_igr_master')
|
||||||
->select('IGRNO')
|
->select('IGRNO')
|
||||||
->orderBy('CreatedDate', 'desc')
|
->orderBy('CreatedDate', 'desc')
|
||||||
->get()
|
->get()
|
||||||
->getRow();
|
->getRow();
|
||||||
// $result->IGRNO;
|
// $result->IGRNO;
|
||||||
}
|
}
|
||||||
|
|
||||||
$igrno = ($YesIAmAffected && !empty($result)) ? $result->IGRNO : '';
|
$igrno = ($YesIAmAffected && !empty($result)) ? $result->IGRNO : '';
|
||||||
return $igrno;
|
return $igrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addigrD($igrD)
|
function addigrD($igrD)
|
||||||
{
|
{
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
$builder = $this->db->table('t_igr_details');
|
$builder = $this->db->table('t_igr_details');
|
||||||
$builder->insert($igrD);
|
$builder->insert($igrD);
|
||||||
$aff_row = $this->db->affectedRows();
|
$aff_row = $this->db->affectedRows();
|
||||||
log_message('error', 'addigrD Query: ' . $this->db->getLastQuery()->getQuery());
|
log_message('error', 'addigrD Query: ' . $this->db->getLastQuery()->getQuery());
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
$result = $this->db->table('t_igr_details')
|
$result = $this->db->table('t_igr_details')
|
||||||
->select('IGRItemNo')
|
->select('IGRItemNo')
|
||||||
->orderBy('CreatedDate', 'desc')
|
->orderBy('CreatedDate', 'desc')
|
||||||
->get()
|
->get()
|
||||||
->getRow();
|
->getRow();
|
||||||
|
|
||||||
$res = ($aff_row > 0) ? $result->IGRItemNo : 0;
|
$res = ($aff_row > 0) ? $result->IGRItemNo : 0;
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -371,40 +376,40 @@ class Inwardgateregister_model extends Model
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
function ViewigrListing_old()
|
function ViewigrListing_old()
|
||||||
{
|
{
|
||||||
|
|
||||||
// $builder = $this->db->table('t_igr_master igr')
|
// $builder = $this->db->table('t_igr_master igr')
|
||||||
// ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName')
|
// ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName')
|
||||||
// ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
// ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
||||||
// ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID')
|
// ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID')
|
||||||
// ->join('t_transporter` trans', 'igr.TransporterId = trans.id' , 'left')
|
// ->join('t_transporter` trans', 'igr.TransporterId = trans.id' , 'left')
|
||||||
// ->where('igr.IGRStatus !=', MRIR_CREATED)
|
// ->where('igr.IGRStatus !=', MRIR_CREATED)
|
||||||
// ->orderBy('igr.CreatedDate', 'desc');
|
// ->orderBy('igr.CreatedDate', 'desc');
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_details igr_details')
|
$builder = $this->db->table('t_igr_details igr_details')
|
||||||
->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight')
|
->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight')
|
||||||
->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo')
|
->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo')
|
||||||
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
||||||
->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID')
|
->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID')
|
||||||
->join('t_transporter` trans', 'igr.TransporterId = trans.id' , 'left')
|
->join('t_transporter` trans', 'igr.TransporterId = trans.id', 'left')
|
||||||
->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left')
|
->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode', 'left')
|
||||||
->where('igr.IGRStatus !=', MRIR_CREATED)
|
->where('igr.IGRStatus !=', MRIR_CREATED)
|
||||||
->orderBy('igr.CreatedDate', 'desc');
|
->orderBy('igr.CreatedDate', 'desc');
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// echo $this->db->getLastQuery()->getQuery();die;
|
// echo $this->db->getLastQuery()->getQuery();die;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ViewigrListing($fromDate,$toDate)
|
function ViewigrListing($fromDate, $toDate)
|
||||||
{
|
{
|
||||||
$subQuery1 = $this->db->table('t_igr_remarkes')
|
$subQuery1 = $this->db->table('t_igr_remarkes')
|
||||||
->select('COUNT(id)')
|
->select('COUNT(id)')
|
||||||
->where('igr_no = igr.IGRNo')
|
->where('igr_no = igr.IGRNo')
|
||||||
->getCompiledSelect();
|
->getCompiledSelect();
|
||||||
|
|
||||||
// Build subQuery2 dynamically for rate and tax based on POType
|
// Build subQuery2 dynamically for rate and tax based on POType
|
||||||
$subQuery2 = "(CASE
|
$subQuery2 = "(CASE
|
||||||
@ -453,17 +458,16 @@ class Inwardgateregister_model extends Model
|
|||||||
->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo')
|
->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo')
|
||||||
->where('igr.IGRStatus !=', MRIR_CREATED)
|
->where('igr.IGRStatus !=', MRIR_CREATED)
|
||||||
->groupBy('IGRD.IGRNo');
|
->groupBy('IGRD.IGRNo');
|
||||||
if(session()->get('roleText') == 'Auditor'){
|
if (session()->get('roleText') == 'Auditor') {
|
||||||
|
|
||||||
$builder->where('Date(igr.DeliveryChellanDate) >=', "$fromDate")
|
$builder->where('Date(igr.DeliveryChellanDate) >=', "$fromDate")
|
||||||
->where('Date(igr.DeliveryChellanDate) <=', "$toDate")
|
->where('Date(igr.DeliveryChellanDate) <=', "$toDate")
|
||||||
->orderBy('igr.DeliveryChellanDate', 'desc');
|
->orderBy('igr.DeliveryChellanDate', 'desc');
|
||||||
}else{
|
} else {
|
||||||
$builder->where('Date(igr.CreatedDate) >=', "$fromDate")
|
$builder->where('Date(igr.CreatedDate) >=', "$fromDate")
|
||||||
->where('Date(igr.CreatedDate) <=', "$toDate")
|
->where('Date(igr.CreatedDate) <=', "$toDate")
|
||||||
->orderBy('igr.CreatedDate', 'desc');
|
->orderBy('igr.CreatedDate', 'desc');
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -473,11 +477,11 @@ class Inwardgateregister_model extends Model
|
|||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
|
|
||||||
|
|
||||||
// echo $this->db->getLastQuery()->getQuery();die;
|
// echo $this->db->getLastQuery()->getQuery();die;
|
||||||
// dd($result);
|
// dd($result);
|
||||||
|
|
||||||
|
|
||||||
// old - issue in t_igr_remarkes join
|
// old - issue in t_igr_remarkes join
|
||||||
// $builder = $this->db->table('t_igr_master igr')
|
// $builder = $this->db->table('t_igr_master igr')
|
||||||
// ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount , count(remark.id) as remark_count')
|
// ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount , count(remark.id) as remark_count')
|
||||||
// ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
// ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
||||||
@ -498,58 +502,58 @@ class Inwardgateregister_model extends Model
|
|||||||
|
|
||||||
|
|
||||||
// $builder2 = $this->db->table('t_igr_details igr_details')
|
// $builder2 = $this->db->table('t_igr_details igr_details')
|
||||||
// ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight')
|
// ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight')
|
||||||
// ->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo')
|
// ->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo')
|
||||||
// ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
// ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
||||||
// ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID')
|
// ->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID')
|
||||||
// ->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left')
|
// ->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left')
|
||||||
// ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left')
|
// ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left')
|
||||||
// ->where('igr.IGRStatus !=', MRIR_CREATED)
|
// ->where('igr.IGRStatus !=', MRIR_CREATED)
|
||||||
// ->orderBy('igr.CreatedDate', 'desc');
|
// ->orderBy('igr.CreatedDate', 'desc');
|
||||||
// $query2 = $builder2->get();
|
// $query2 = $builder2->get();
|
||||||
// $result2 = $query2->getResult();
|
// $result2 = $query2->getResult();
|
||||||
// echo $this->db->getLastQuery()->getQuery();die;
|
// echo $this->db->getLastQuery()->getQuery();die;
|
||||||
return [$result,[]];
|
return [$result, []];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function customViewigrListing($fromDate,$toDate)
|
function customViewigrListing($fromDate, $toDate)
|
||||||
{
|
{
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_master igr')
|
$builder = $this->db->table('t_igr_master igr')
|
||||||
->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount')
|
->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName , SUM(IGRD.QuantityAsPerInvoice) as ReceivedQuantity, SUM(IGRD.NetWeight) as NetWeight , count(IGRD.IGRNo) as itemCount')
|
||||||
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
||||||
->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID')
|
->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID')
|
||||||
->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left')
|
->join('t_transporter trans', 'igr.TransporterId = trans.id', 'left')
|
||||||
->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo')
|
->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo')
|
||||||
->where('igr.IGRStatus !=', MRIR_CREATED)
|
->where('igr.IGRStatus !=', MRIR_CREATED)
|
||||||
->groupStart()
|
->groupStart()
|
||||||
->where('Date(igr.CreatedDate) >=', $fromDate)
|
->where('Date(igr.CreatedDate) >=', $fromDate)
|
||||||
->orWhere('Date(igr.UpdatedOn) >=', $fromDate)
|
->orWhere('Date(igr.UpdatedOn) >=', $fromDate)
|
||||||
->groupEnd()
|
->groupEnd()
|
||||||
->groupStart()
|
->groupStart()
|
||||||
->where('Date(igr.CreatedDate) <=', $toDate)
|
->where('Date(igr.CreatedDate) <=', $toDate)
|
||||||
->orWhere('Date(igr.UpdatedOn) <=', $toDate)
|
->orWhere('Date(igr.UpdatedOn) <=', $toDate)
|
||||||
->groupEnd()
|
->groupEnd()
|
||||||
->groupBy('igr.IGRNo')
|
->groupBy('igr.IGRNo')
|
||||||
->orderBy('igr.CreatedDate', 'desc');
|
->orderBy('igr.CreatedDate', 'desc');
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
|
|
||||||
$builder2 = $this->db->table('t_igr_details igr_details')
|
$builder2 = $this->db->table('t_igr_details igr_details')
|
||||||
->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight')
|
->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight')
|
||||||
->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo')
|
->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo')
|
||||||
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO')
|
||||||
->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID')
|
->join('t_supplierdetailsn sup', 'PO.SupplierID = sup.SupplierID')
|
||||||
->join('t_transporter trans', 'igr.TransporterId = trans.id' , 'left')
|
->join('t_transporter trans', 'igr.TransporterId = trans.id', 'left')
|
||||||
->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left')
|
->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode', 'left')
|
||||||
->where('igr.IGRStatus !=', MRIR_CREATED)
|
->where('igr.IGRStatus !=', MRIR_CREATED)
|
||||||
->orderBy('igr.CreatedDate', 'desc');
|
->orderBy('igr.CreatedDate', 'desc');
|
||||||
$query2 = $builder2->get();
|
$query2 = $builder2->get();
|
||||||
$result2 = $query2->getResult();
|
$result2 = $query2->getResult();
|
||||||
// echo $this->db->getLastQuery()->getQuery();die;
|
// echo $this->db->getLastQuery()->getQuery();die;
|
||||||
return [$result,$result2];
|
return [$result, $result2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -579,10 +583,10 @@ class Inwardgateregister_model extends Model
|
|||||||
->join('t_purchaseorder_lineitem POL', 'igr.PONO = POL.PONO and POL.MaterialCode=igrd.MaterialCode ')
|
->join('t_purchaseorder_lineitem POL', 'igr.PONO = POL.PONO and POL.MaterialCode=igrd.MaterialCode ')
|
||||||
->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID')
|
->join('t_supplierdetailsn sup', 'sup.SupplierID = POM.SupplierID')
|
||||||
->join('t_materialmaster MM', 'MM.MaterialCode = igrd.MaterialCode')
|
->join('t_materialmaster MM', 'MM.MaterialCode = igrd.MaterialCode')
|
||||||
->join('t_service_tax st', 'st.LineItemNo = POL.LineItemNo' , 'left')
|
->join('t_service_tax st', 'st.LineItemNo = POL.LineItemNo', 'left')
|
||||||
->join('t_revenue_tax rt', 'rt.LineItemNo = POL.LineItemNo' , 'left')
|
->join('t_revenue_tax rt', 'rt.LineItemNo = POL.LineItemNo', 'left')
|
||||||
->join('t_import_tax it', 'it.LineItemNo = POL.LineItemNo' , 'left')
|
->join('t_import_tax it', 'it.LineItemNo = POL.LineItemNo', 'left')
|
||||||
->join('t_configdetails cd','cd.key = MM.Category','left')
|
->join('t_configdetails cd', 'cd.key = MM.Category', 'left')
|
||||||
->where('igr.IGRNO', $IGRNO);
|
->where('igr.IGRNO', $IGRNO);
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
@ -637,7 +641,7 @@ class Inwardgateregister_model extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdatePOMaster($PONO, $updatedBy,$IGRStatus)
|
function UpdatePOMaster($PONO, $updatedBy, $IGRStatus)
|
||||||
{
|
{
|
||||||
|
|
||||||
$builder = $this->db->table('t_purchaseorder_lineitem')->select('*')
|
$builder = $this->db->table('t_purchaseorder_lineitem')->select('*')
|
||||||
@ -969,13 +973,13 @@ class Inwardgateregister_model extends Model
|
|||||||
// $query = $this->db->query($subQuery);
|
// $query = $this->db->query($subQuery);
|
||||||
// return $query->getResult();
|
// return $query->getResult();
|
||||||
$result = $this->db->table('t_ogr_master')
|
$result = $this->db->table('t_ogr_master')
|
||||||
->select('OGRNO')
|
->select('OGRNO')
|
||||||
->orderBy('CreatedOn', 'desc')
|
->orderBy('CreatedOn', 'desc')
|
||||||
->get()
|
->get()
|
||||||
->getRow();
|
->getRow();
|
||||||
|
|
||||||
$OGRNO = ($aff_row && $result !== null) ? $result->OGRNO : 0;
|
$OGRNO = ($aff_row && $result !== null) ? $result->OGRNO : 0;
|
||||||
return $OGRNO;
|
return $OGRNO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,7 +1077,8 @@ class Inwardgateregister_model extends Model
|
|||||||
$r = $this->db->affectedRows();
|
$r = $this->db->affectedRows();
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
function updateIGRLineItem($igrlineitemarr, $IGRitemNo){
|
function updateIGRLineItem($igrlineitemarr, $IGRitemNo)
|
||||||
|
{
|
||||||
$this->db->table('t_igr_details')
|
$this->db->table('t_igr_details')
|
||||||
->where('IGRItemNo', $IGRitemNo)
|
->where('IGRItemNo', $IGRitemNo)
|
||||||
->update($igrlineitemarr);
|
->update($igrlineitemarr);
|
||||||
@ -1112,133 +1117,147 @@ class Inwardgateregister_model extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function ViewIGRHistory($igr)
|
public function ViewIGRHistory($igr)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('t_igr_history');
|
$builder = $this->db->table('t_igr_history');
|
||||||
|
|
||||||
$builder->select('t_igr_history.*, DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName,t_materialmaster.MaterialName,t_materialmaster.MaterialName,t_materialmaster.MaterialCode');
|
$builder->select('t_igr_history.*, DATE_FORMAT(t_igr_history.history_dated, "%d-%m-%Y") AS indian_date, DATE_FORMAT(t_igr_history.history_dated, "%h:%i:%s %p") AS indian_time, CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) AS FullName,t_materialmaster.MaterialName,t_materialmaster.MaterialName,t_materialmaster.MaterialCode');
|
||||||
$builder->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left');
|
$builder->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left');
|
||||||
$builder->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left');
|
$builder->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left');
|
||||||
$builder->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left');
|
$builder->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left');
|
||||||
$builder->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left');
|
$builder->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left');
|
||||||
$builder->where('CONVERT(IGR_No USING utf8)', $igr);
|
$builder->where('CONVERT(IGR_No USING utf8)', $igr);
|
||||||
$builder->orderBy('t_igr_history.history_dated', 'asc');
|
$builder->orderBy('t_igr_history.history_dated', 'asc');
|
||||||
// $builder->where('IGR_No', $igr);
|
// $builder->where('IGR_No', $igr);
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
return $result;
|
return $result;
|
||||||
|
}
|
||||||
}
|
|
||||||
public function isFileExistsInIGRmaster($filename)
|
public function isFileExistsInIGRmaster($filename)
|
||||||
{
|
{
|
||||||
$result = $this->db->table('t_igr_master')->where('MasterFile', $filename);
|
$result = $this->db->table('t_igr_master')->where('MasterFile', $filename);
|
||||||
$query = $result->get();
|
$query = $result->get();
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
public function isFileExistsInIGRdetails($filename)
|
public function isFileExistsInIGRdetails($filename)
|
||||||
{
|
{
|
||||||
$result = $this->db->table('t_igr_details')->where('WeightFile', $filename);
|
$result = $this->db->table('t_igr_details')->where('WeightFile', $filename);
|
||||||
$query = $result->get();
|
$query = $result->get();
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCostCenterData($pono)
|
public function getCostCenterData($pono)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('t_purchaseorder_lineitem');
|
$builder = $this->db->table('t_purchaseorder_lineitem');
|
||||||
|
|
||||||
$builder->select('t_purchaseorder_lineitem.ReqNo,reqMaster.CostCenterCode,CSMaster.CostCenterName');
|
$builder->select('t_purchaseorder_lineitem.ReqNo,reqMaster.CostCenterCode,CSMaster.CostCenterName');
|
||||||
$builder->join('t_requestion_master reqMaster', 't_purchaseorder_lineitem.ReqNo = reqMaster.ReqNo', 'left');
|
$builder->join('t_requestion_master reqMaster', 't_purchaseorder_lineitem.ReqNo = reqMaster.ReqNo', 'left');
|
||||||
$builder->join('t_costcenter_master CSMaster', 'reqMaster.CostCenterCode = CSMaster.CostCenterCode', 'left');
|
$builder->join('t_costcenter_master CSMaster', 'reqMaster.CostCenterCode = CSMaster.CostCenterCode', 'left');
|
||||||
$builder->where('PONO', $pono);
|
$builder->where('PONO', $pono);
|
||||||
$builder->groupBy('t_purchaseorder_lineitem.ReqNo');
|
$builder->groupBy('t_purchaseorder_lineitem.ReqNo');
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
return $result;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllIgrFileDetails($igrno)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Query 1: Get FilePath and Remarks from t_inwardgateregister_fileupload
|
|
||||||
$builder1 = $this->db->table('t_inwardgateregister_fileupload IFU');
|
|
||||||
$query1 = $builder1->select('IFU.FilePath as file, IFU.Remarks as filename')
|
|
||||||
->where('IFU.IGRNO', $igrno)
|
|
||||||
->where('IFU.Isactive', 1)
|
|
||||||
->get();
|
|
||||||
$result1 = $query1->getResult();
|
|
||||||
|
|
||||||
// Query 2: Get MasterFile from t_igr_master
|
|
||||||
$builder2 = $this->db->table('t_igr_master IM');
|
|
||||||
$query2 = $builder2->select('IM.MasterFile as file, IM.MasterFile as filename')
|
|
||||||
->where('IM.IGRNO', $igrno)
|
|
||||||
->where('IM.MasterFile IS NOT NULL')
|
|
||||||
->get();
|
|
||||||
$result2 = $query2->getResult();
|
|
||||||
|
|
||||||
// Query 3: Get WeightFile from t_igr_details
|
|
||||||
$builder3 = $this->db->table('t_igr_details ID');
|
|
||||||
$query3 = $builder3->select('ID.WeightFile as file, ID.WeightFile as filename')
|
|
||||||
->where('ID.IGRNO', $igrno)
|
|
||||||
->where('ID.WeightFile IS NOT NULL')
|
|
||||||
->get();
|
|
||||||
$result3 = $query3->getResult();
|
|
||||||
|
|
||||||
// Merging results into a single array
|
|
||||||
$results = array_merge($result1, $result2, $result3);
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function transporter()
|
|
||||||
{
|
|
||||||
$builder = $this->db->table('t_transporter t');
|
|
||||||
$query = $builder->select('t.*')->get();
|
|
||||||
$result = $query->getResult();
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findIgrDetailsForIncomingSilicaSand($materialCodes, $month ,$remark)
|
public function getAllIgrFileDetails($igrno)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('t_igr_details')
|
|
||||||
->select(
|
// Query 1: Get FilePath and Remarks from t_inwardgateregister_fileupload
|
||||||
't_igr_details.IGRNO,
|
$builder1 = $this->db->table('t_inwardgateregister_fileupload IFU');
|
||||||
|
$query1 = $builder1->select('IFU.FilePath as file, IFU.Remarks as filename')
|
||||||
|
->where('IFU.IGRNO', $igrno)
|
||||||
|
->where('IFU.Isactive', 1)
|
||||||
|
->get();
|
||||||
|
$result1 = $query1->getResult();
|
||||||
|
|
||||||
|
// Query 2: Get MasterFile from t_igr_master
|
||||||
|
$builder2 = $this->db->table('t_igr_master IM');
|
||||||
|
$query2 = $builder2->select('IM.MasterFile as file, IM.MasterFile as filename')
|
||||||
|
->where('IM.IGRNO', $igrno)
|
||||||
|
->where('IM.MasterFile IS NOT NULL')
|
||||||
|
->get();
|
||||||
|
$result2 = $query2->getResult();
|
||||||
|
|
||||||
|
// Query 3: Get WeightFile from t_igr_details
|
||||||
|
$builder3 = $this->db->table('t_igr_details ID');
|
||||||
|
$query3 = $builder3->select('ID.WeightFile as file, ID.WeightFile as filename')
|
||||||
|
->where('ID.IGRNO', $igrno)
|
||||||
|
->where('ID.WeightFile IS NOT NULL')
|
||||||
|
->get();
|
||||||
|
$result3 = $query3->getResult();
|
||||||
|
|
||||||
|
// Merging results into a single array
|
||||||
|
$results = array_merge($result1, $result2, $result3);
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transporter()
|
||||||
|
{
|
||||||
|
$builder = $this->db->table('t_transporter t');
|
||||||
|
$query = $builder->select('t.*')->get();
|
||||||
|
$result = $query->getResult();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findIgrDetailsForIncomingSilicaSand($materialCodes, $month, $remark)
|
||||||
|
{
|
||||||
|
$builder = $this->db->table('t_igr_details');
|
||||||
|
|
||||||
|
// 1. Select the necessary columns
|
||||||
|
$builder->select(
|
||||||
|
't_igr_details.IGRNO,
|
||||||
t_igr_details.MaterialCode,
|
t_igr_details.MaterialCode,
|
||||||
igrMast.DeliveryChellanOrInvoiceNo as invoiceNo,
|
igrMast.DeliveryChellanOrInvoiceNo as invoiceNo,
|
||||||
igrMast.DeliveryChellanDate as invoiceDate,
|
igrMast.DeliveryChellanDate as invoiceDate,
|
||||||
igrMast.MaterialRcvdDate as materialRecievedDate,
|
igrMast.MaterialRcvdDate as materialRecievedDate,
|
||||||
igrMast.VehicleNo,
|
igrMast.VehicleNo,
|
||||||
supplierDetails.SupplierName,
|
supplierDetails.SupplierName,
|
||||||
cd.ConfigValue as sandType ,
|
cd.ConfigValue as sandType,
|
||||||
t_igr_details.QuantityAsPerInvoice as Qty,
|
t_igr_details.QuantityAsPerInvoice as Qty,
|
||||||
issd.*')
|
issd.*'
|
||||||
->whereIn('t_igr_details.MaterialCode', $materialCodes)
|
);
|
||||||
->where('t_igr_details.QuantityAsPerInvoice <>', 0)
|
|
||||||
->like('t_igr_details.CreatedDate', $month, 'after');
|
|
||||||
|
|
||||||
// remark needed for those who selected any remark.
|
// 2. Apply the most selective WHERE clause(s) first - in this case, the date range
|
||||||
if ($remark != "noRemark") {
|
$nowIST = new \DateTime('now', new \DateTimeZone('Asia/Kolkata'));
|
||||||
$builder->where('issd.remark', $remark);
|
|
||||||
}
|
|
||||||
|
|
||||||
$builder->groupBy('t_igr_details.IGRNO, t_igr_details.MaterialCode')
|
$builder->where('Date(t_igr_details.CreatedDate) >=', $nowIST->format('Y-m-01 00:00:00'));
|
||||||
->join('t_igr_master igrMast', 'igrMast.IGRNO = t_igr_details.IGRNO')
|
$builder->where('Date(t_igr_details.CreatedDate) <=', $nowIST->format('Y-m-t 23:59:59'));
|
||||||
->join('t_incomingsilicasanddetails issd','issd.igrNo_fk = t_igr_details.IGRNO AND issd.materialCode = t_igr_details.MaterialCode','left')
|
|
||||||
->join('t_materialmaster materialMaster', 'materialMaster.MaterialCode = t_igr_details.MaterialCode')
|
|
||||||
->join('t_configdetails cd','cd.key = materialMaster.Category','left')
|
|
||||||
->join('t_purchaseorder_master poMaster', 'poMaster.PONO = igrMast.PONO', 'left')
|
|
||||||
->join('t_supplierdetailsn supplierDetails', 'supplierDetails.SupplierID = poMaster.SupplierID', 'left')
|
|
||||||
->orderBy('t_igr_details.CreatedDate', 'asc ');
|
|
||||||
|
|
||||||
|
// 3. Apply other WHERE clause conditions
|
||||||
|
$builder->whereIn('t_igr_details.MaterialCode', $materialCodes);
|
||||||
|
$builder->where('t_igr_details.QuantityAsPerInvoice <>', 0);
|
||||||
|
|
||||||
|
// Conditional WHERE clause for remark
|
||||||
|
if ($remark != "noRemark") {
|
||||||
|
$builder->where('issd.remark', $remark);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Apply JOIN clauses
|
||||||
|
$builder->join('t_igr_master igrMast', 'igrMast.IGRNO = t_igr_details.IGRNO');
|
||||||
|
$builder->join('t_incomingsilicasanddetails issd', 'issd.igrNo_fk = t_igr_details.IGRNO AND issd.materialCode = t_igr_details.MaterialCode', 'left');
|
||||||
|
$builder->join('t_materialmaster materialMaster', 'materialMaster.MaterialCode = t_igr_details.MaterialCode');
|
||||||
|
$builder->join('t_configdetails cd', 'cd.key = materialMaster.Category', 'left');
|
||||||
|
$builder->join('t_purchaseorder_master poMaster', 'poMaster.PONO = igrMast.PONO', 'left');
|
||||||
|
$builder->join('t_supplierdetailsn supplierDetails', 'supplierDetails.SupplierID = poMaster.SupplierID', 'left');
|
||||||
|
|
||||||
|
// 5. Apply GROUP BY clause
|
||||||
|
$builder->groupBy('t_igr_details.IGRNO, t_igr_details.MaterialCode');
|
||||||
|
|
||||||
|
// 6. Apply ORDER BY clause
|
||||||
|
$builder->orderBy('t_igr_details.CreatedDate', 'asc ');
|
||||||
|
|
||||||
|
// 7. Get the query results
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResultArray();
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
|
return $query->getResultArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHistoryDetailsforEmail($igr){
|
public function getHistoryDetailsforEmail($igr)
|
||||||
$date = date('Y-m-d H:i:s');
|
{
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
$to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds'));
|
$to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds'));
|
||||||
$from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds'));
|
$from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds'));
|
||||||
|
|
||||||
@ -1247,13 +1266,13 @@ class Inwardgateregister_model extends Model
|
|||||||
from t_igr_history
|
from t_igr_history
|
||||||
LEFT JOIN tbl_users ON tbl_users.userId = t_igr_history.by
|
LEFT JOIN tbl_users ON tbl_users.userId = t_igr_history.by
|
||||||
LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID
|
LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID
|
||||||
where is_add = 1 and IGR_No = '".$igr."'");
|
where is_add = 1 and IGR_No = '" . $igr . "'");
|
||||||
$first_line = $query3->getRow();
|
$first_line = $query3->getRow();
|
||||||
|
|
||||||
// 392 po
|
// 392 po
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_history')
|
$builder = $this->db->table('t_igr_history')
|
||||||
->select('
|
->select('
|
||||||
t_igr_history.id,
|
t_igr_history.id,
|
||||||
t_igr_history.field,
|
t_igr_history.field,
|
||||||
t_igr_history.is_add,
|
t_igr_history.is_add,
|
||||||
@ -1288,15 +1307,15 @@ $builder = $this->db->table('t_igr_history')
|
|||||||
END AS old_data,
|
END AS old_data,
|
||||||
t_igr_history.old_data as original_old_data,t_materialmaster.MaterialName,t_materialmaster.MaterialCode
|
t_igr_history.old_data as original_old_data,t_materialmaster.MaterialName,t_materialmaster.MaterialCode
|
||||||
')
|
')
|
||||||
// ->join('t_igr_details IGRD', 'IGRD.IGRItemNo = t_igr_history.IGRItem_No','left')
|
// ->join('t_igr_details IGRD', 'IGRD.IGRItemNo = t_igr_history.IGRItem_No','left')
|
||||||
// ->join('t_materialmaster MM','MM.MaterialCode = IGRD.MaterialCode','left')
|
// ->join('t_materialmaster MM','MM.MaterialCode = IGRD.MaterialCode','left')
|
||||||
->join('tbl_users', 'tbl_users.userId = t_igr_history.by','left')
|
->join('tbl_users', 'tbl_users.userId = t_igr_history.by', 'left')
|
||||||
->join('t_employee_details','tbl_users.EmpID = t_employee_details.EmpID','left')
|
->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left')
|
||||||
->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left')
|
->join('t_igr_details', 'CONVERT(t_igr_history.IGRItem_No USING utf8) = CONVERT(t_igr_details.IGRItemNo USING utf8)', 'left')
|
||||||
->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left')
|
->join('t_materialmaster', 'CONVERT(t_materialmaster.MaterialCode USING utf8) = CONVERT(t_igr_details.MaterialCode USING utf8)', 'left')
|
||||||
->where('CONVERT(t_igr_history.IGR_No USING utf8)', $igr)
|
->where('CONVERT(t_igr_history.IGR_No USING utf8)', $igr)
|
||||||
->where('t_igr_history.is_edit', 1)
|
->where('t_igr_history.is_edit', 1)
|
||||||
->where('t_igr_history.history_dated BETWEEN "'.$from.'" AND "'.$to.'"');
|
->where('t_igr_history.history_dated BETWEEN "' . $from . '" AND "' . $to . '"');
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
@ -1304,50 +1323,54 @@ $builder = $this->db->table('t_igr_history')
|
|||||||
// echo $this->db->getLastQuery()->getQuery(); die;
|
// echo $this->db->getLastQuery()->getQuery(); die;
|
||||||
return [
|
return [
|
||||||
'history' => $result,
|
'history' => $result,
|
||||||
'first_line' => $first_line ? $first_line->IGR_No ." was Created by ". $first_line->history_by ." on ". $first_line->indian_date ." at ". $first_line->indian_time : null,
|
'first_line' => $first_line ? $first_line->IGR_No . " was Created by " . $first_line->history_by . " on " . $first_line->indian_date . " at " . $first_line->indian_time : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDetailsforEmail($userId,$roleId)
|
public function getDetailsforEmail($userId, $roleId)
|
||||||
{
|
{
|
||||||
$query0 = $this->db->query("
|
$query0 = $this->db->query("
|
||||||
SELECT CompanyName,EmailAddress
|
SELECT CompanyName,EmailAddress
|
||||||
FROM t_company_details");
|
FROM t_company_details");
|
||||||
$company = $query0->getRow();
|
$company = $query0->getRow();
|
||||||
|
|
||||||
$query1 = $this->db->query("
|
$query1 = $this->db->query(
|
||||||
|
"
|
||||||
SELECT CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName
|
SELECT CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName
|
||||||
FROM tbl_users
|
FROM tbl_users
|
||||||
LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID
|
LEFT JOIN t_employee_details ON tbl_users.EmpID = t_employee_details.EmpID
|
||||||
WHERE tbl_users.userId = ?", [$userId]
|
WHERE tbl_users.userId = ?",
|
||||||
);
|
[$userId]
|
||||||
$fullName = $query1->getRow();
|
);
|
||||||
|
$fullName = $query1->getRow();
|
||||||
|
|
||||||
$query2 = $this->db->query("
|
$query2 = $this->db->query(
|
||||||
|
"
|
||||||
SELECT email FROM tbl_users
|
SELECT email FROM tbl_users
|
||||||
WHERE isDeleted = 0 AND roleId =".$roleId
|
WHERE isDeleted = 0 AND roleId =" . $roleId
|
||||||
);
|
);
|
||||||
$to_mails = $query2->getResult();
|
$to_mails = $query2->getResult();
|
||||||
|
|
||||||
$query3 = $this->db->query("
|
$query3 = $this->db->query(
|
||||||
|
"
|
||||||
SELECT email FROM tbl_users
|
SELECT email FROM tbl_users
|
||||||
WHERE isDeleted = 0 AND userId =".$userId
|
WHERE isDeleted = 0 AND userId =" . $userId
|
||||||
);
|
);
|
||||||
$from_mails = $query3->getRow();
|
$from_mails = $query3->getRow();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'company' => $company ? $company->CompanyName : null,
|
'company' => $company ? $company->CompanyName : null,
|
||||||
'company_mail' => $company ? $company->EmailAddress : null,
|
'company_mail' => $company ? $company->EmailAddress : null,
|
||||||
'full_name' => $fullName ? $fullName->FullName : null,
|
'full_name' => $fullName ? $fullName->FullName : null,
|
||||||
'from_mails' => $from_mails ? $from_mails->email : null ,
|
'from_mails' => $from_mails ? $from_mails->email : null,
|
||||||
'to_mails' => $to_mails,
|
'to_mails' => $to_mails,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getdriverlist()
|
public function getdriverlist()
|
||||||
{
|
{
|
||||||
|
|
||||||
$query = $this->db->query('SELECT DriverName,DriverMobileNumber
|
$query = $this->db->query('SELECT DriverName,DriverMobileNumber
|
||||||
FROM t_igr_master
|
FROM t_igr_master
|
||||||
WHERE DriverName != ""
|
WHERE DriverName != ""
|
||||||
GROUP BY DriverName,DriverMobileNumber');
|
GROUP BY DriverName,DriverMobileNumber');
|
||||||
@ -1355,51 +1378,55 @@ $builder = $this->db->table('t_igr_history')
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getigrstatus($IGRNo){
|
public function getigrstatus($IGRNo)
|
||||||
|
{
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_master')
|
$builder = $this->db->table('t_igr_master')
|
||||||
->select('IGRStatus')
|
->select('IGRStatus')
|
||||||
->where('IGRNO',$IGRNo)
|
->where('IGRNO', $IGRNo)
|
||||||
->get();
|
->get();
|
||||||
$result = $builder->getRow();
|
$result = $builder->getRow();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_status($value){
|
public function get_status($value)
|
||||||
|
{
|
||||||
$builder = $this->db->table('t_status')
|
$builder = $this->db->table('t_status')
|
||||||
->select('StatusCode,StatusName')
|
->select('StatusCode,StatusName')
|
||||||
->where('StatusCode', $value);
|
->where('StatusCode', $value);
|
||||||
|
|
||||||
$query = $builder->get()->getRow();
|
$query = $builder->get()->getRow();
|
||||||
|
|
||||||
$StatusName = $query ? $query->StatusName : null;
|
$StatusName = $query ? $query->StatusName : null;
|
||||||
return $StatusName;
|
return $StatusName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_TransporterId($value){
|
public function get_TransporterId($value)
|
||||||
|
{
|
||||||
$builder = $this->db->table('t_transporter')
|
$builder = $this->db->table('t_transporter')
|
||||||
->select('id,name')
|
->select('id,name')
|
||||||
->where('id', $value);
|
->where('id', $value);
|
||||||
|
|
||||||
$query = $builder->get()->getRow();
|
$query = $builder->get()->getRow();
|
||||||
|
|
||||||
$transportername = $query ? $query->name : null;
|
$transportername = $query ? $query->name : null;
|
||||||
return $transportername;
|
return $transportername;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Mcat -materialCategory
|
//Mcat -materialCategory
|
||||||
public function getIgrDetailsListByMcatGas($gasMaterialCodes,$gas_status){
|
public function getIgrDetailsListByMcatGas($gasMaterialCodes, $gas_status)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch ($gas_status) {
|
switch ($gas_status) {
|
||||||
|
|
||||||
|
|
||||||
case "gas_entered":
|
case "gas_entered":
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_details as t_igrd')
|
$builder = $this->db->table('t_igr_details as t_igrd')
|
||||||
->select("
|
->select("
|
||||||
t_igrd.IGRNO as IGRNO-,
|
t_igrd.IGRNO as IGRNO-,
|
||||||
(t_igrd.QuantityAsPerInvoice) as gasCylinderCount,
|
(t_igrd.QuantityAsPerInvoice) as gasCylinderCount,
|
||||||
t_sd.SupplierName,
|
t_sd.SupplierName,
|
||||||
@ -1407,25 +1434,25 @@ $builder = $this->db->table('t_igr_history')
|
|||||||
t_mm.MaterialName,
|
t_mm.MaterialName,
|
||||||
t_gsd.*
|
t_gsd.*
|
||||||
")
|
")
|
||||||
->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO')
|
->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO')
|
||||||
->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left')
|
->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left')
|
||||||
->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID')
|
->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID')
|
||||||
|
|
||||||
->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left')
|
->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left')
|
||||||
|
|
||||||
->join('t_materialmaster t_mm','t_mm.MaterialCode = t_igrd.MaterialCode','left')
|
->join('t_materialmaster t_mm', 't_mm.MaterialCode = t_igrd.MaterialCode', 'left')
|
||||||
->whereIn('t_igrd.MaterialCode', $gasMaterialCodes)
|
->whereIn('t_igrd.MaterialCode', $gasMaterialCodes)
|
||||||
->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ")
|
->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ")
|
||||||
|
|
||||||
->where('t_gsd.gas_cylinder_status IS NULL');
|
->where('t_gsd.gas_cylinder_status IS NULL');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "gas_pending":
|
case "gas_pending":
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_details as t_igrd')
|
$builder = $this->db->table('t_igr_details as t_igrd')
|
||||||
->select("
|
->select("
|
||||||
t_igrd.IGRNO as IGRNO-,
|
t_igrd.IGRNO as IGRNO-,
|
||||||
(t_igrd.QuantityAsPerInvoice) as gasCylinderCount,
|
(t_igrd.QuantityAsPerInvoice) as gasCylinderCount,
|
||||||
t_sd.SupplierName,
|
t_sd.SupplierName,
|
||||||
@ -1433,26 +1460,26 @@ $builder = $this->db->table('t_igr_history')
|
|||||||
t_mm.MaterialName,
|
t_mm.MaterialName,
|
||||||
t_gsd.*
|
t_gsd.*
|
||||||
")
|
")
|
||||||
->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO')
|
->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO')
|
||||||
->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left')
|
->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left')
|
||||||
->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID')
|
->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID')
|
||||||
|
|
||||||
->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left')
|
->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left')
|
||||||
|
|
||||||
->join('t_materialmaster t_mm','t_mm.MaterialCode = t_igrd.MaterialCode','left')
|
->join('t_materialmaster t_mm', 't_mm.MaterialCode = t_igrd.MaterialCode', 'left')
|
||||||
->whereIn('t_igrd.MaterialCode', $gasMaterialCodes)
|
->whereIn('t_igrd.MaterialCode', $gasMaterialCodes)
|
||||||
->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ")
|
->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ")
|
||||||
|
|
||||||
->where('t_gsd.gas_cylinder_status','gas_pending');
|
->where('t_gsd.gas_cylinder_status', 'gas_pending');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case "gas_returned":
|
case "gas_returned":
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_details as t_igrd')
|
$builder = $this->db->table('t_igr_details as t_igrd')
|
||||||
->select("
|
->select("
|
||||||
t_igrd.IGRNO as IGRNO-,
|
t_igrd.IGRNO as IGRNO-,
|
||||||
(t_igrd.QuantityAsPerInvoice) as gasCylinderCount,
|
(t_igrd.QuantityAsPerInvoice) as gasCylinderCount,
|
||||||
t_sd.SupplierName,
|
t_sd.SupplierName,
|
||||||
@ -1467,34 +1494,28 @@ $builder = $this->db->table('t_igr_history')
|
|||||||
Count(t_gsd.gas_cylinder_status) as gasCylinderCompletedCount,
|
Count(t_gsd.gas_cylinder_status) as gasCylinderCompletedCount,
|
||||||
(t_igrd.QuantityAsPerInvoice - Count(t_gsd.gas_cylinder_status)) as gasCylinderPendingCount
|
(t_igrd.QuantityAsPerInvoice - Count(t_gsd.gas_cylinder_status)) as gasCylinderPendingCount
|
||||||
")
|
")
|
||||||
->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO')
|
->join('t_igr_master t_igrm', 't_igrm.IGRNO = t_igrd.IGRNO')
|
||||||
->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left')
|
->join('t_purchaseorder_master t_pom', 't_igrm.PONO = t_pom.PONO', 'left')
|
||||||
->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID')
|
->join('t_supplierdetailsn t_sd', 't_sd.SupplierID = t_pom.SupplierID')
|
||||||
|
|
||||||
->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left')
|
->join('t_gasshortagedetails t_gsd', 't_gsd.IGRNO = t_igrm.IGRNO', 'left')
|
||||||
|
|
||||||
->join('t_materialmaster t_mm','t_mm.MaterialCode = t_igrd.MaterialCode','left')
|
->join('t_materialmaster t_mm', 't_mm.MaterialCode = t_igrd.MaterialCode', 'left')
|
||||||
->whereIn('t_igrd.MaterialCode', $gasMaterialCodes)
|
->whereIn('t_igrd.MaterialCode', $gasMaterialCodes)
|
||||||
->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ")
|
->where("DATE(t_igrd.CreatedDate) >= '2025-04-01' ")
|
||||||
|
|
||||||
->where('t_gsd.gas_cylinder_status','gas_returned')
|
->where('t_gsd.gas_cylinder_status', 'gas_returned')
|
||||||
|
|
||||||
->groupBy('t_igrd.IGRNO');
|
->groupBy('t_igrd.IGRNO');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$result = $builder->get()->getResultArray();
|
$result = $builder->get()->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user