stock module latest today vadivel J 04-02-2025
This commit is contained in:
parent
7d3ad14ef1
commit
e0adcd1a9f
@ -149,11 +149,11 @@ 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['coatingMachineDetails'] = $this->coatingMachineDetails_model
|
$data['coatingMachineDetails'] = $this->coatingMachineDetails_model
|
||||||
->select('coating_machine_details.*, t_batchcard_files.filename') // Select required fields
|
->select('t_coatingMachineDetails.*, t_batchcard_files.*') // Select required fields
|
||||||
->join('t_batchcard_files', 't_batchcard_files.coating_id = coating_machine_details.id', 'left')
|
->join('t_batchcard_files', 't_batchcard_files.coating_id = t_coatingMachineDetails.id', 'left')
|
||||||
->where('coating_machine_details.date >=', $startDate)
|
->where('t_coatingMachineDetails.date >=', $startDate)
|
||||||
->where('coating_machine_details.date <=', $endDate)
|
->where('t_coatingMachineDetails.date <=', $endDate)
|
||||||
->orderBy('coating_machine_details.date', 'asc')
|
->orderBy('t_coatingMachineDetails.date', 'asc')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$date = DateTime::createFromFormat('Y-m', $month);
|
$date = DateTime::createFromFormat('Y-m', $month);
|
||||||
@ -224,6 +224,7 @@ class StockController extends BaseController
|
|||||||
foreach ($batchCardFiles as $file) {
|
foreach ($batchCardFiles as $file) {
|
||||||
|
|
||||||
if ($file->isValid() && !$file->hasMoved()) {
|
if ($file->isValid() && !$file->hasMoved()) {
|
||||||
|
$clientGivenName = $file->getClientName(); // User-given filename
|
||||||
$newName = $file->getRandomName();
|
$newName = $file->getRandomName();
|
||||||
|
|
||||||
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
|
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
|
||||||
@ -232,6 +233,7 @@ class StockController extends BaseController
|
|||||||
$builder = $db->table('t_batchcard_files');
|
$builder = $db->table('t_batchcard_files');
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
'client_file_name' => $clientGivenName,
|
||||||
'filename' => $newName,
|
'filename' => $newName,
|
||||||
'coating_id' => $insertedId
|
'coating_id' => $insertedId
|
||||||
];
|
];
|
||||||
@ -287,7 +289,7 @@ class StockController extends BaseController
|
|||||||
$dateToBeUpdated = $putData['date'];
|
$dateToBeUpdated = $putData['date'];
|
||||||
|
|
||||||
$existingCoatingGasConsumption = $putData['existingTotalGasConsumption'];
|
$existingCoatingGasConsumption = $putData['existingTotalGasConsumption'];
|
||||||
$updatedCoatingGasConsumption = $putData['totalGasConsumption'];
|
$updatedCoatingGasConsumption = $putData['totalGasConsumption'];
|
||||||
|
|
||||||
if ($existingCoatingGasConsumption != $updatedCoatingGasConsumption) {
|
if ($existingCoatingGasConsumption != $updatedCoatingGasConsumption) {
|
||||||
|
|
||||||
@ -335,6 +337,7 @@ class StockController extends BaseController
|
|||||||
// Step 2: Upload new files and save them in the database
|
// Step 2: Upload new files and save them in the database
|
||||||
foreach ($batchCardFiles as $file) {
|
foreach ($batchCardFiles as $file) {
|
||||||
if ($file->isValid() && !$file->hasMoved()) {
|
if ($file->isValid() && !$file->hasMoved()) {
|
||||||
|
$clientGivenName = $file->getClientName(); // User-given filename
|
||||||
$newName = $file->getRandomName();
|
$newName = $file->getRandomName();
|
||||||
|
|
||||||
// Check if the new file is different from the old ones (if needed)
|
// Check if the new file is different from the old ones (if needed)
|
||||||
@ -350,6 +353,7 @@ class StockController extends BaseController
|
|||||||
// Move the new file and save to DB
|
// Move the new file and save to DB
|
||||||
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
|
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
|
||||||
$data = [
|
$data = [
|
||||||
|
'client_file_name' => $clientGivenName,
|
||||||
'filename' => $newName,
|
'filename' => $newName,
|
||||||
'coating_id' => $id
|
'coating_id' => $id
|
||||||
];
|
];
|
||||||
@ -359,9 +363,7 @@ class StockController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optional: Remove old files only if necessary (based on your criteria)
|
|
||||||
// Example: Delete old files if you no longer need them
|
|
||||||
// In this example, we're keeping old files that were not replaced.
|
|
||||||
foreach ($oldFiles as $oldFile) {
|
foreach ($oldFiles as $oldFile) {
|
||||||
$filePath = WRITEPATH . 'uploads/batchcard/' . $oldFile['filename'];
|
$filePath = WRITEPATH . 'uploads/batchcard/' . $oldFile['filename'];
|
||||||
if (file_exists($filePath)) {
|
if (file_exists($filePath)) {
|
||||||
@ -369,10 +371,7 @@ class StockController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// After this, you would have:
|
|
||||||
// - New files uploaded
|
|
||||||
// - Only new files added to the database
|
|
||||||
// - Optionally, old files removed
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -341,7 +341,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!empty($coatingMachineDetails)) {
|
if (!empty($coatingMachineDetails)) {
|
||||||
|
|
||||||
$summary = [] ;
|
$summary = [] ;
|
||||||
|
|
||||||
foreach ($coatingMachineDetails as $record) {
|
foreach ($coatingMachineDetails as $record) {
|
||||||
@ -698,10 +697,10 @@
|
|||||||
<label for="">Upload Batch Card</label>
|
<label for="">Upload Batch Card</label>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<input type="file" class="batchfile" name="batchCard[]" >
|
<input type="file" class="batchfile" name="batchCard[]">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-success btn-sm mt-2" id="batchCardAddBtnId">Add More</button>
|
<button type="button" class="btn btn-success btn-sm mt-2" id="batchCardAddBtnId">Add More</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user