stock changes 06-04-2025

This commit is contained in:
vadivelJ96 2025-04-06 09:04:58 +05:30
parent 40ea479b73
commit 0289595c86

View File

@ -21,7 +21,8 @@ class Inwardgateregister_model extends Model
$afftectedRows = $this->db->affectedRows();
return $afftectedRows;
}
function getAdditionalIGRFile($igr){
function getAdditionalIGRFile($igr)
{
$builder = $this->db->table('t_inwardgateregister_fileupload')->select('*')
->where('IGRNO', $igr);
$query = $builder->get();
@ -169,7 +170,8 @@ class Inwardgateregister_model extends Model
return $temp;
}
public function checkdriverMobile($mobile,$driverName) {
public function checkdriverMobile($mobile, $driverName)
{
$builder = $this->db->table('t_igr_master')
->distinct()
->select('DriverMobileNumber')
@ -220,7 +222,8 @@ class Inwardgateregister_model extends Model
return $result; */
}
public function igr_history($hsty_arr) {
public function igr_history($hsty_arr)
{
$keysToRemove = ["UpdateBY", "UpdateBy", "MaterialRcvdDate", "DeliveryChellanDate"];
@ -257,11 +260,13 @@ class Inwardgateregister_model extends Model
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();
}
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
if ($igr_no) {
$builder->where('Child.IGRNO', $igr_no);
@ -462,7 +467,6 @@ class Inwardgateregister_model extends Model
$builder->where('Date(igr.CreatedDate) >=', "$fromDate")
->where('Date(igr.CreatedDate) <=', "$toDate")
->orderBy('igr.CreatedDate', 'desc');
}
@ -1073,7 +1077,8 @@ class Inwardgateregister_model extends Model
$r = $this->db->affectedRows();
return $r;
}
function updateIGRLineItem($igrlineitemarr, $IGRitemNo){
function updateIGRLineItem($igrlineitemarr, $IGRitemNo)
{
$this->db->table('t_igr_details')
->where('IGRItemNo', $IGRitemNo)
->update($igrlineitemarr);
@ -1127,7 +1132,6 @@ class Inwardgateregister_model extends Model
$query = $builder->get();
$result = $query->getResult();
return $result;
}
public function isFileExistsInIGRmaster($filename)
{
@ -1154,8 +1158,6 @@ class Inwardgateregister_model extends Model
$query = $builder->get();
$result = $query->getResult();
return $result;
}
public function getAllIgrFileDetails($igrno)
@ -1201,8 +1203,10 @@ class Inwardgateregister_model extends Model
public function findIgrDetailsForIncomingSilicaSand($materialCodes, $month, $remark)
{
$builder = $this->db->table('t_igr_details')
->select(
$builder = $this->db->table('t_igr_details');
// 1. Select the necessary columns
$builder->select(
't_igr_details.IGRNO,
t_igr_details.MaterialCode,
igrMast.DeliveryChellanOrInvoiceNo as invoiceNo,
@ -1212,32 +1216,47 @@ class Inwardgateregister_model extends Model
supplierDetails.SupplierName,
cd.ConfigValue as sandType,
t_igr_details.QuantityAsPerInvoice as Qty,
issd.*')
->whereIn('t_igr_details.MaterialCode', $materialCodes)
->where('t_igr_details.QuantityAsPerInvoice <>', 0)
->like('t_igr_details.CreatedDate', $month, 'after');
issd.*'
);
// remark needed for those who selected any remark.
// 2. Apply the most selective WHERE clause(s) first - in this case, the date range
$nowIST = new \DateTime('now', new \DateTimeZone('Asia/Kolkata'));
$builder->where('Date(t_igr_details.CreatedDate) >=', $nowIST->format('Y-m-01 00:00:00'));
$builder->where('Date(t_igr_details.CreatedDate) <=', $nowIST->format('Y-m-t 23:59:59'));
// 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);
}
$builder->groupBy('t_igr_details.IGRNO, t_igr_details.MaterialCode')
->join('t_igr_master igrMast', 'igrMast.IGRNO = t_igr_details.IGRNO')
->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 ');
// 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();
$result = $query->getResultArray();
return $result;
return $query->getResultArray();
}
public function getHistoryDetailsforEmail($igr){
public function getHistoryDetailsforEmail($igr)
{
$date = date('Y-m-d H:i:s');
$to = date('Y-m-d H:i:s', strtotime($date . ' +30 seconds'));
$from = date('Y-m-d H:i:s', strtotime($date . ' -30 seconds'));
@ -1315,21 +1334,25 @@ $builder = $this->db->table('t_igr_history')
FROM t_company_details");
$company = $query0->getRow();
$query1 = $this->db->query("
$query1 = $this->db->query(
"
SELECT CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName
FROM tbl_users
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();
$query2 = $this->db->query("
$query2 = $this->db->query(
"
SELECT email FROM tbl_users
WHERE isDeleted = 0 AND roleId =" . $roleId
);
$to_mails = $query2->getResult();
$query3 = $this->db->query("
$query3 = $this->db->query(
"
SELECT email FROM tbl_users
WHERE isDeleted = 0 AND userId =" . $userId
);
@ -1355,7 +1378,8 @@ $builder = $this->db->table('t_igr_history')
return $result;
}
public function getigrstatus($IGRNo){
public function getigrstatus($IGRNo)
{
$builder = $this->db->table('t_igr_master')
->select('IGRStatus')
@ -1365,7 +1389,8 @@ $builder = $this->db->table('t_igr_history')
return $result;
}
public function get_status($value){
public function get_status($value)
{
$builder = $this->db->table('t_status')
->select('StatusCode,StatusName')
->where('StatusCode', $value);
@ -1376,7 +1401,8 @@ $builder = $this->db->table('t_igr_history')
return $StatusName;
}
public function get_TransporterId($value){
public function get_TransporterId($value)
{
$builder = $this->db->table('t_transporter')
->select('id,name')
->where('id', $value);
@ -1388,7 +1414,8 @@ $builder = $this->db->table('t_igr_history')
}
//Mcat -materialCategory
public function getIgrDetailsListByMcatGas($gasMaterialCodes,$gas_status){
public function getIgrDetailsListByMcatGas($gasMaterialCodes, $gas_status)
{
@ -1482,7 +1509,6 @@ $builder = $this->db->table('t_igr_history')
->groupBy('t_igrd.IGRNO');
break;
}
@ -1491,10 +1517,5 @@ $builder = $this->db->table('t_igr_history')
return $result;
}
}