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 DateTime;
|
||||||
use DatePeriod;
|
use DatePeriod;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
use Directory;
|
||||||
|
|
||||||
class StockController extends BaseController
|
class StockController extends BaseController
|
||||||
{
|
{
|
||||||
@ -661,8 +662,14 @@ class StockController extends BaseController
|
|||||||
if ($file->isValid() && !$file->hasMoved()) {
|
if ($file->isValid() && !$file->hasMoved()) {
|
||||||
$clientGivenName = $file->getClientName(); // Original filename
|
$clientGivenName = $file->getClientName(); // Original filename
|
||||||
$newName = $file->getRandomName();
|
$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
|
// Insert file details into the database
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
$builder = $db->table('t_batchcard_files');
|
$builder = $db->table('t_batchcard_files');
|
||||||
@ -735,8 +742,13 @@ class StockController extends BaseController
|
|||||||
$clientGivenName = $file->getClientName(); // User-given filename
|
$clientGivenName = $file->getClientName(); // User-given filename
|
||||||
$newName = $file->getRandomName(); // Randomized unique filename
|
$newName = $file->getRandomName(); // Randomized unique filename
|
||||||
|
|
||||||
// Move the new file to storage
|
$path = WRITEPATH . 'uploads' . DIRECTORY_SEPARATOR . 'batchcard';
|
||||||
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
|
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
mkdir($path, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file->move($path, $newName)) {
|
||||||
// Insert new file record into the database
|
// Insert new file record into the database
|
||||||
$data = [
|
$data = [
|
||||||
'client_file_name' => $clientGivenName,
|
'client_file_name' => $clientGivenName,
|
||||||
@ -817,7 +829,12 @@ class StockController extends BaseController
|
|||||||
$fileRecord = $builder->select('filename')->where('id', $batchId)->get()->getRow();
|
$fileRecord = $builder->select('filename')->where('id', $batchId)->get()->getRow();
|
||||||
|
|
||||||
if ($fileRecord) {
|
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
|
// Step 2: Delete the file from storage
|
||||||
if (file_exists($filePath)) {
|
if (file_exists($filePath)) {
|
||||||
@ -856,8 +873,11 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
public function downloadBatchcardZip()
|
public function downloadBatchcardZip()
|
||||||
{
|
{
|
||||||
|
|
||||||
$coatingId = $this->request->getGet('coating_id');
|
$coatingId = $this->request->getGet('coating_id');
|
||||||
|
|
||||||
$date = $this->request->getGet('date');
|
$date = $this->request->getGet('date');
|
||||||
|
|
||||||
$batchCardFiles = $this->getBatchCardFiles($coatingId); // Fetch files from DB
|
$batchCardFiles = $this->getBatchCardFiles($coatingId); // Fetch files from DB
|
||||||
|
|
||||||
if (empty($batchCardFiles)) {
|
if (empty($batchCardFiles)) {
|
||||||
@ -865,16 +885,34 @@ class StockController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$zipFileName = 'batchcard_files_' . $date . '.zip';
|
$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();
|
$zip = new \ZipArchive();
|
||||||
if ($zip->open($zipFilePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === true) {
|
if ($zip->open($zipFilePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === true) {
|
||||||
|
|
||||||
foreach ($batchCardFiles as $file) {
|
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
|
$clientFileName = $file['client_file_name'] ?? $file['filename']; // Use client name if available
|
||||||
|
|
||||||
if (file_exists($originalFilePath)) {
|
if (file_exists($originalFilePath)) {
|
||||||
|
|
||||||
$zip->addFile($originalFilePath, $clientFileName); // Rename inside ZIP
|
$zip->addFile($originalFilePath, $clientFileName); // Rename inside ZIP
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|||||||
@ -78,7 +78,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -73,37 +73,50 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px; margin-bottom: -11px; margin-left: 33px;">
|
<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>
|
<label for="fromDate">From:</label>
|
||||||
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate"
|
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate"
|
||||||
placeholder="Select From Date" autocomplete="off">
|
placeholder="Select From Date" autocomplete="off">
|
||||||
|
|
||||||
<label for="toDate">To:</label>
|
</div>
|
||||||
<input class="form-control date_range to-date-search" id="toDate" name="toDate"
|
|
||||||
placeholder="Select To Date" autocomplete="off">
|
<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">
|
<div class="form-group">
|
||||||
<label for="category">Category:</label>
|
<label for="category">Category:</label>
|
||||||
<select class="form-control category-search" autocomplete="off" id="category" name="category">
|
<select class="form-control category-search" autocomplete="off" id="category" name="category">
|
||||||
<option value="">Select Category </option>
|
<option value="">Select Category </option>
|
||||||
<?php
|
<?php
|
||||||
if (!empty($materialCategoryList)) {
|
if (!empty($materialCategoryList)) {
|
||||||
foreach ($materialCategoryList as $record) {
|
foreach ($materialCategoryList as $record) {
|
||||||
?>
|
?>
|
||||||
<option value="<?php echo $record['category_name']?>"><?php echo $record['category_name']?></option>
|
<option value="<?php echo $record['category_name']?>"><?php echo $record['category_name']?></option>
|
||||||
<?php } } ?>
|
<?php } } ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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..!!
|
//recent work of adding gas shortage done here..!!
|
||||||
|
|
||||||
$("#Igrshow").on("shown.bs.modal", function(e) {
|
$("#Igrshow").on("shown.bs.modal", function(e) {
|
||||||
|
|
||||||
$('#Igrshow .modal-dialog').css({'max-width': '100%'});
|
$('#Igrshow .modal-dialog').css({'max-width': '100%'});
|
||||||
|
|
||||||
$('#Igrshow .modal-dialog').show();
|
$('#Igrshow .modal-dialog').show();
|
||||||
|
|
||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
|
|
||||||
var inx = $(e.relatedTarget).data('id');
|
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="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 + '">' ;
|
'<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();
|
$('#gasShortageHeader').show();
|
||||||
$('#gasShortageListHeader').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>' ;
|
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="file" id="txtWeightFile' + i + '" name="txtWeightFile' + i + '"value="' + item.WeightFile + '">' +
|
||||||
'<input type="hidden" id="txtWeightFileName' + i + '" name="txtWeightFileName' + 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();
|
$('#gasShortageHeader').show();
|
||||||
$('#gasShortageListHeader').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>' ;
|
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