changes in stock module 13-03-2025
This commit is contained in:
parent
99782747e4
commit
0995e71540
@ -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();
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<a id="addExpense" class="btn btn-success" data-toggle="modal" href="#expenseModal">Add New Expense</a>
|
||||
<a id="addExpense" class="btn btn-success" data-toggle="modal" data-target="#expenseModal" href="">Add New Expense</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -73,37 +73,50 @@
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px; margin-bottom: -11px; margin-left: 33px;">
|
||||
|
||||
<input type="hidden" name="table" value="requisition">
|
||||
|
||||
<div class="form-group">
|
||||
<input type="hidden" name="table" value="requisition">
|
||||
|
||||
<label for="fromDate">From:</label>
|
||||
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate"
|
||||
placeholder="Select From Date" autocomplete="off">
|
||||
<label for="fromDate">From:</label>
|
||||
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate"
|
||||
placeholder="Select From Date" autocomplete="off">
|
||||
|
||||
<label for="toDate">To:</label>
|
||||
<input class="form-control date_range to-date-search" id="toDate" name="toDate"
|
||||
placeholder="Select To Date" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="toDate">To:</label>
|
||||
<input class="form-control date_range to-date-search" id="toDate" name="toDate"
|
||||
placeholder="Select To Date" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<!-- New Category Field -->
|
||||
<!-- New Category Field -->
|
||||
<div class="form-group">
|
||||
<label for="category">Category:</label>
|
||||
<select class="form-control category-search" autocomplete="off" id="category" name="category">
|
||||
<option value="">Select Category </option>
|
||||
<?php
|
||||
if (!empty($materialCategoryList)) {
|
||||
foreach ($materialCategoryList as $record) {
|
||||
?>
|
||||
<option value="<?php echo $record['category_name']?>"><?php echo $record['category_name']?></option>
|
||||
<?php } } ?>
|
||||
</select>
|
||||
<label for="category">Category:</label>
|
||||
<select class="form-control category-search" autocomplete="off" id="category" name="category">
|
||||
<option value="">Select Category </option>
|
||||
<?php
|
||||
if (!empty($materialCategoryList)) {
|
||||
foreach ($materialCategoryList as $record) {
|
||||
?>
|
||||
<option value="<?php echo $record['category_name']?>"><?php echo $record['category_name']?></option>
|
||||
<?php } } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-3">
|
||||
|
||||
<button type="submit" class="range_search_button ">
|
||||
<i class="fe-search" aria-hidden="true"
|
||||
class="icon-button" title="Search" ></i>
|
||||
</button>
|
||||
|
||||
<i class="fe-rotate-cw range_reset_button px-3" aria-hidden="true" class="icon-button" id="resetButton"
|
||||
title="Reset"></i>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true"
|
||||
class="icon-button" title="Search"></i></button>
|
||||
|
||||
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton"
|
||||
title="Reset"></i>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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 @@
|
||||
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '" style="display:none;">' +
|
||||
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">' ;
|
||||
|
||||
if(item.MaterialCategory == "gas"){
|
||||
let regex = /gas/i;
|
||||
|
||||
if(regex.test(item.MaterialCategory) ){
|
||||
$('#gasShortageHeader').show();
|
||||
$('#gasShortageListHeader').show();
|
||||
trIGRHTML += '<td style="width: 25px;"><a target="_blank" data-toggle="modal" data-target="#gasShortageCalculator" title="gas Shortage Calculator" data-index="' + i + '" data-material="' + item.MaterialName + '" data-igrstatus = "' + igrstatus + '"><i class="fa fa-solid fa-gas-pump" style="text-align: center;"></i></a> </td>' ;
|
||||
@ -1366,7 +1370,9 @@
|
||||
'<input type="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '">' +
|
||||
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + i + '"value="' + item.WeightFile + '">';
|
||||
|
||||
if(item.MaterialCategory == "gas"){
|
||||
let regex = /gas/i;
|
||||
|
||||
if(regex.test(item.MaterialCategory) ){
|
||||
$('#gasShortageHeader').show();
|
||||
$('#gasShortageListHeader').show();
|
||||
trIGRHTML += '<td style="width: 25px;"><a target="_blank" data-toggle="modal" data-target="#gasShortageCalculator" title="gas Shortage Calculator" data-index="' + i + '" data-material="' + item.MaterialName + '" data-igrstatus = "' + igrstatus + '"><i class="fa fa-solid fa-gas-pump" style="text-align: center;"></i></a> </td>' ;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user