diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 00299d0a..354eca66 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -526,7 +526,7 @@ class StockController extends BaseController $startDate = "$month-01"; $endDate = date("Y-m-t", strtotime($startDate)); $data['coatingMachineDetails'] = $this->coatingMachineDetails_model - ->select('t_coatingMachineDetails.*, + ->select('t_coatingmachinedetails.*, JSON_ARRAYAGG( JSON_OBJECT( "client_given_name", t_batchcard_files.client_file_name, @@ -535,11 +535,11 @@ class StockController extends BaseController "coating_id", t_batchcard_files.coating_id ) ) as batchcard_files') - ->join('t_batchcard_files', 't_batchcard_files.coating_id = t_coatingMachineDetails.id', 'left') - ->where('t_coatingMachineDetails.date >=', $startDate) - ->where('t_coatingMachineDetails.date <=', $endDate) - ->groupBy('t_coatingMachineDetails.id') - ->orderBy('t_coatingMachineDetails.date', 'asc') + ->join('t_batchcard_files', 't_batchcard_files.coating_id = t_coatingmachinedetails.id', 'left') + ->where('t_coatingmachinedetails.date >=', $startDate) + ->where('t_coatingmachinedetails.date <=', $endDate) + ->groupBy('t_coatingmachinedetails.id') + ->orderBy('t_coatingmachinedetails.date', 'asc') ->findAll(); @@ -606,6 +606,7 @@ class StockController extends BaseController if (!empty($batchCardFiles) && !($batchCardFiles[0]->getError() === UPLOAD_ERR_NO_FILE)) { + foreach ($batchCardFiles as $file) { if ($file->isValid() && !$file->hasMoved()) { @@ -623,12 +624,14 @@ class StockController extends BaseController 'coating_id' => $insertedId ]; - $builder->insert($data); + $result = $builder->insert($data); + } } } } + } @@ -636,6 +639,7 @@ class StockController extends BaseController if ($this->db->transStatus() === false) { throw new \Exception('Transaction failed due to database errors.'); } + $this->db->transCommit(); @@ -905,7 +909,7 @@ class StockController extends BaseController $data['gasStockDetails'] = $this->gasStockDetails_model ->select( - 't_gasStockDetails.*, + 't_gasstockdetails.*, drier_summary.drierMachineGasconsumption AS drierMachineGasConsumption, drier_summary.driedSand AS sandDried, coating_summary.coatingMachineGasconsumption, @@ -916,31 +920,31 @@ class StockController extends BaseController '(SELECT date, SUM(totalGasconsumption) AS coatingMachineGasconsumption, SUM(totalCoatingSandInKg) / 1000 AS coatedSand - FROM t_coatingMachineDetails + FROM t_coatingmachinedetails WHERE is_active = 1 AND date >= ' . $this->db->escape($startDate) . ' AND date <= ' . $this->db->escape($endDate) . ' GROUP BY date ) AS coating_summary', - 'coating_summary.date = t_gasStockDetails.date', + 'coating_summary.date = t_gasstockdetails.date', 'left' ) ->join( '(SELECT date, SUM(total_gas_consumption) AS drierMachineGasconsumption, SUM(sand_dried_qty) AS driedSand - FROM t_drierMachineDetails + FROM t_driermachinedetails WHERE date >= ' . $this->db->escape($startDate) . ' AND date <= ' . $this->db->escape($endDate) . ' GROUP BY date ) AS drier_summary', - 'drier_summary.date = t_gasStockDetails.date', + 'drier_summary.date = t_gasstockdetails.date', 'left' ) - ->where('t_gasStockDetails.date >=', $startDate) - ->where('t_gasStockDetails.date <=', $endDate) - ->groupBy('t_gasStockDetails.date') + ->where('t_gasstockdetails.date >=', $startDate) + ->where('t_gasstockdetails.date <=', $endDate) + ->groupBy('t_gasstockdetails.date') ->findAll(); diff --git a/app/Models/CoatingMachineDetailsModel.php b/app/Models/CoatingMachineDetailsModel.php index 46819fe7..544478ba 100644 --- a/app/Models/CoatingMachineDetailsModel.php +++ b/app/Models/CoatingMachineDetailsModel.php @@ -6,7 +6,7 @@ use CodeIgniter\Model; class CoatingMachineDetailsModel extends Model { - protected $table = 't_coatingMachineDetails'; + protected $table = 't_coatingmachinedetails'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'array'; diff --git a/app/Models/FactoryMachineModel.php b/app/Models/FactoryMachineModel.php index 3e77c081..6c363b76 100644 --- a/app/Models/FactoryMachineModel.php +++ b/app/Models/FactoryMachineModel.php @@ -92,7 +92,7 @@ class FactoryMachineModel extends Model $result = $this->db->table('t_factorymachinemaster') ->where('is_active', 1) ->where('energy_type', 'diesel') - ->orderBy('id', 'asc') + ->orderBy('id', 'desc') ->get() ->getResultArray(); diff --git a/app/Models/GasStockModel.php b/app/Models/GasStockModel.php index 1f95543d..259807ce 100644 --- a/app/Models/GasStockModel.php +++ b/app/Models/GasStockModel.php @@ -6,7 +6,7 @@ use CodeIgniter\Model; class GasStockModel extends Model { - protected $table = 't_gasStockDetails'; + protected $table = 't_gasstockdetails'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'array'; diff --git a/app/Views/stock/CoatingMachineDetail.php b/app/Views/stock/CoatingMachineDetail.php index e22539d7..2e69cd0c 100644 --- a/app/Views/stock/CoatingMachineDetail.php +++ b/app/Views/stock/CoatingMachineDetail.php @@ -728,15 +728,13 @@
( Previously Uploaded File ${element.client_given_name} )
@@ -1680,7 +1675,7 @@ return; } - let string = `