stock module latest today vadivel J 04-02-2025

This commit is contained in:
vadivelJ96 2025-02-04 10:06:22 +05:30
parent 7d3ad14ef1
commit e0adcd1a9f
2 changed files with 18 additions and 20 deletions

View File

@ -149,11 +149,11 @@ class StockController extends BaseController
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$data['coatingMachineDetails'] = $this->coatingMachineDetails_model
->select('coating_machine_details.*, t_batchcard_files.filename') // Select required fields
->join('t_batchcard_files', 't_batchcard_files.coating_id = coating_machine_details.id', 'left')
->where('coating_machine_details.date >=', $startDate)
->where('coating_machine_details.date <=', $endDate)
->orderBy('coating_machine_details.date', 'asc')
->select('t_coatingMachineDetails.*, t_batchcard_files.*') // Select required fields
->join('t_batchcard_files', 't_batchcard_files.coating_id = t_coatingMachineDetails.id', 'left')
->where('t_coatingMachineDetails.date >=', $startDate)
->where('t_coatingMachineDetails.date <=', $endDate)
->orderBy('t_coatingMachineDetails.date', 'asc')
->findAll();
$date = DateTime::createFromFormat('Y-m', $month);
@ -182,8 +182,8 @@ class StockController extends BaseController
$sameShiftOnDateExists = $this->coatingMachineDetails_model
->where('date', $date)
->where('shift', $shift)
->where('is_active', 1)
->first();
->where('is_active', 1)
->first();
if (!empty($sameShiftOnDateExists)) {
return redirect()->back()->with('error', 'Already same shift exists on the same date ..!!');
@ -224,6 +224,7 @@ class StockController extends BaseController
foreach ($batchCardFiles as $file) {
if ($file->isValid() && !$file->hasMoved()) {
$clientGivenName = $file->getClientName(); // User-given filename
$newName = $file->getRandomName();
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
@ -232,6 +233,7 @@ class StockController extends BaseController
$builder = $db->table('t_batchcard_files');
$data = [
'client_file_name' => $clientGivenName,
'filename' => $newName,
'coating_id' => $insertedId
];
@ -287,7 +289,7 @@ class StockController extends BaseController
$dateToBeUpdated = $putData['date'];
$existingCoatingGasConsumption = $putData['existingTotalGasConsumption'];
$updatedCoatingGasConsumption = $putData['totalGasConsumption'];
$updatedCoatingGasConsumption = $putData['totalGasConsumption'];
if ($existingCoatingGasConsumption != $updatedCoatingGasConsumption) {
@ -335,6 +337,7 @@ class StockController extends BaseController
// Step 2: Upload new files and save them in the database
foreach ($batchCardFiles as $file) {
if ($file->isValid() && !$file->hasMoved()) {
$clientGivenName = $file->getClientName(); // User-given filename
$newName = $file->getRandomName();
// 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
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
$data = [
'client_file_name' => $clientGivenName,
'filename' => $newName,
'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) {
$filePath = WRITEPATH . 'uploads/batchcard/' . $oldFile['filename'];
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
}
}

View File

@ -341,7 +341,6 @@
<?php
if (!empty($coatingMachineDetails)) {
$summary = [] ;
foreach ($coatingMachineDetails as $record) {
@ -695,16 +694,16 @@
<!-- batch card file upload -->
<div class="form-group col-md-3">
<label for="">Upload Batch Card</label>
<label for="">Upload Batch Card</label>
<div>
<input type="file" class="batchfile" name="batchCard[]" >
<input type="file" class="batchfile" name="batchCard[]">
</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>