diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index da65cc4a..e300fe57 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -36,6 +36,7 @@ use CodeIgniter\HTTP\ResponseInterface; use DateTime; use DatePeriod; use DateInterval; +use Directory; class StockController extends BaseController { @@ -661,8 +662,14 @@ class StockController extends BaseController if ($file->isValid() && !$file->hasMoved()) { $clientGivenName = $file->getClientName(); // Original filename $newName = $file->getRandomName(); + + $path = WRITEPATH . 'uploads' . DIRECTORY_SEPARATOR . 'batchcard'; + + if (!is_dir($path)) { + mkdir($path, 0777, true); + } - if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) { + if ($file->move($path, $newName)) { // Insert file details into the database $db = \Config\Database::connect(); $builder = $db->table('t_batchcard_files'); @@ -735,8 +742,13 @@ class StockController extends BaseController $clientGivenName = $file->getClientName(); // User-given filename $newName = $file->getRandomName(); // Randomized unique filename - // Move the new file to storage - if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) { + $path = WRITEPATH . 'uploads' . DIRECTORY_SEPARATOR . 'batchcard'; + + if (!is_dir($path)) { + mkdir($path, 0777, true); + } + + if ($file->move($path, $newName)) { // Insert new file record into the database $data = [ 'client_file_name' => $clientGivenName, @@ -817,7 +829,12 @@ class StockController extends BaseController $fileRecord = $builder->select('filename')->where('id', $batchId)->get()->getRow(); if ($fileRecord) { - $filePath = WRITEPATH . 'uploads/batchcard/' . $fileRecord->filename; + $path = WRITEPATH . 'uploads' . DIRECTORY_SEPARATOR . 'batchcard'; + + if (!is_dir($path)) { + mkdir($path, 0777, true); + } + $filePath = $path . DIRECTORY_SEPARATOR . $fileRecord->filename; // Step 2: Delete the file from storage if (file_exists($filePath)) { @@ -856,8 +873,11 @@ class StockController extends BaseController public function downloadBatchcardZip() { + $coatingId = $this->request->getGet('coating_id'); + $date = $this->request->getGet('date'); + $batchCardFiles = $this->getBatchCardFiles($coatingId); // Fetch files from DB if (empty($batchCardFiles)) { @@ -865,16 +885,34 @@ class StockController extends BaseController } $zipFileName = 'batchcard_files_' . $date . '.zip'; - $zipFilePath = WRITEPATH . 'uploads/batchcard' . $zipFileName; // CI4 WRITEPATH safe directory - + + $zipPath = WRITEPATH . 'uploads' . DIRECTORY_SEPARATOR . 'batchcard'; + + if (!is_dir($zipPath)) + { + mkdir($zipPath, 0777, true); + } + + $zipFilePath = $zipPath . DIRECTORY_SEPARATOR . $zipFileName; // CI4 WRITEPATH safe directory + + + + + + $zip = new \ZipArchive(); if ($zip->open($zipFilePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === true) { + foreach ($batchCardFiles as $file) { - $originalFilePath = WRITEPATH . 'uploads/batchcard/' . $file['filename']; // Actual stored file + + $originalFilePath = $zipPath . DIRECTORY_SEPARATOR . $file['filename']; // Actual stored file + $clientFileName = $file['client_file_name'] ?? $file['filename']; // Use client name if available if (file_exists($originalFilePath)) { + $zip->addFile($originalFilePath, $clientFileName); // Rename inside ZIP + } } $zip->close(); diff --git a/app/Views/expense_list.php b/app/Views/expense_list.php index 7d9e8694..a0cf9635 100755 --- a/app/Views/expense_list.php +++ b/app/Views/expense_list.php @@ -78,7 +78,7 @@ - Add New Expense + Add New Expense diff --git a/app/Views/rawmaterialListing.php b/app/Views/rawmaterialListing.php index ce32ed3a..c5d11bbd 100755 --- a/app/Views/rawmaterialListing.php +++ b/app/Views/rawmaterialListing.php @@ -73,37 +73,50 @@
- - + +
+ - - + + - - +
+ +
+ + +
- +
- - + +
+ +
+ + + + + +
- - diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index ba73ec5f..bb32df5c 100755 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -1067,9 +1067,11 @@ //recent work of adding gas shortage done here..!! $("#Igrshow").on("shown.bs.modal", function(e) { + $('#Igrshow .modal-dialog').css({'max-width': '100%'}); $('#Igrshow .modal-dialog').show(); + $('#loader').show(); var inx = $(e.relatedTarget).data('id'); @@ -1322,7 +1324,9 @@ '' + '' ; - if(item.MaterialCategory == "gas"){ + let regex = /gas/i; + + if(regex.test(item.MaterialCategory) ){ $('#gasShortageHeader').show(); $('#gasShortageListHeader').show(); trIGRHTML += ' ' ; @@ -1366,7 +1370,9 @@ '' + ''; - if(item.MaterialCategory == "gas"){ + let regex = /gas/i; + + if(regex.test(item.MaterialCategory) ){ $('#gasShortageHeader').show(); $('#gasShortageListHeader').show(); trIGRHTML += ' ' ;