stock module latest today vadivel J 06-1-2025
This commit is contained in:
parent
afc9dd2c6b
commit
af24792316
@ -1305,20 +1305,98 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
$startDate = "$month-01";
|
$startDate = "$month-01";
|
||||||
$endDate = date("Y-m-t", strtotime($startDate));
|
$endDate = date("Y-m-t", strtotime($startDate));
|
||||||
|
|
||||||
$data['trpProductionDetails'] = $this->TrpProductionMaintenance_model
|
|
||||||
->select('tpmd.*, tpd.*, tpwd.*')
|
|
||||||
->from('t_trpProductionMaintenanceDetails tpmd')
|
|
||||||
->join('t_trpProductionDetails tpd', 'tpd.date = tpmd.date')
|
|
||||||
->join('t_trpProductionWasteDetails tpwd', 'tpwd.date = tpmd.date')
|
|
||||||
// ->join('ip_invoice_items', 'ip_invoice_items.item_date_added = tpmd.date',' AND ip_invoice_items.item_name = "Core Sand Reclaimed"')
|
|
||||||
->where('tpmd.date >=', $startDate)
|
|
||||||
->where('tpmd.date <=', $endDate)
|
|
||||||
->orderBy('tpmd.date', 'asc')
|
|
||||||
->get()
|
|
||||||
->getResultArray();
|
|
||||||
|
|
||||||
|
|
||||||
|
// Subquery definition
|
||||||
|
$subquery = $this->db->table('t_materialmaster')
|
||||||
|
->select('materialCode')
|
||||||
|
->where('Category', 'waste core')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
|
||||||
|
$materialCodes = array_column($subquery, 'materialCode'); // Extracts 'materialCode' values
|
||||||
|
|
||||||
|
// Convert the array of material codes to a comma-separated string
|
||||||
|
$materialCodesString = "'" . implode("','", $materialCodes) . "'";
|
||||||
|
|
||||||
|
// Main query
|
||||||
|
$sql = "SELECT
|
||||||
|
tpmd.*,
|
||||||
|
tpd.*,
|
||||||
|
tpwd.*,
|
||||||
|
tsu.*,
|
||||||
|
ip_invoice_items.*,
|
||||||
|
tigrd.* ,
|
||||||
|
(
|
||||||
|
SELECT ts.SupplierName
|
||||||
|
FROM t_supplierdetailsn ts
|
||||||
|
WHERE ts.SupplierID = (
|
||||||
|
SELECT tpom.SupplierID
|
||||||
|
FROM t_purchaseorder_master tpom
|
||||||
|
WHERE tpom.PONO = (
|
||||||
|
SELECT tigm.PONO
|
||||||
|
FROM t_igr_master tigm
|
||||||
|
WHERE tigm.IGRNo = tigrd.IGRNo
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) AS SupplierName
|
||||||
|
FROM
|
||||||
|
t_trpProductionMaintenanceDetails tpmd
|
||||||
|
JOIN
|
||||||
|
t_trpProductionDetails tpd ON tpd.date = tpmd.date
|
||||||
|
JOIN
|
||||||
|
t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
|
||||||
|
LEFT JOIN
|
||||||
|
t_coatingMachineDetails tcmd ON tcmd.date = tpmd.date
|
||||||
|
LEFT JOIN
|
||||||
|
t_drierMachineDetails tdmd ON tdmd.date = tpmd.date
|
||||||
|
LEFT JOIN
|
||||||
|
t_trp_sand_use tsu ON tsu.date = tpmd.date
|
||||||
|
LEFT JOIN
|
||||||
|
ip_invoice_items ON ip_invoice_items.item_date_added = tpmd.date
|
||||||
|
AND ip_invoice_items.item_name = 'Core Sand Reclaimed'
|
||||||
|
|
||||||
|
LEFT JOIN
|
||||||
|
t_igr_master tigm
|
||||||
|
ON tigm.IGRNo = tigrd.IGRNo
|
||||||
|
|
||||||
|
LEFT JOIN
|
||||||
|
t_purchaseorder_master tpom
|
||||||
|
ON tpom.PONO = tigm.PONO
|
||||||
|
|
||||||
|
LEFT JOIN
|
||||||
|
t_supplierdetailsn ts
|
||||||
|
ON ts.SupplierID = tpom.SupplierID
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
DATE(CreatedDate) AS GroupedDate,
|
||||||
|
IGRNo,
|
||||||
|
SUM(QuantityAsPerInvoice) AS GroupedQuantity
|
||||||
|
FROM
|
||||||
|
t_igr_details
|
||||||
|
WHERE
|
||||||
|
MaterialCode IN ($materialCodesString)
|
||||||
|
GROUP BY
|
||||||
|
IGRNo
|
||||||
|
) tigrd ON tigrd.GroupedDate = tpmd.date
|
||||||
|
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
tpmd.date >= ?
|
||||||
|
AND
|
||||||
|
tpmd.date <= ?
|
||||||
|
ORDER BY
|
||||||
|
tpmd.date ASC";
|
||||||
|
|
||||||
|
// Execute the query
|
||||||
|
$query = $this->db->query($sql, [$startDate, $endDate]);
|
||||||
|
$data['trpProductionDetails'] = $query->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
dd($data['trpProductionDetails']);
|
||||||
|
|
||||||
$date = DateTime::createFromFormat('Y-m', $month);
|
$date = DateTime::createFromFormat('Y-m', $month);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user