FIX_issues : ps

This commit is contained in:
VE10-Sanjeev 2024-08-13 09:26:02 +00:00
parent c3e7e73142
commit 40a2cbc4d2
2 changed files with 77 additions and 55 deletions

View File

@ -1635,44 +1635,66 @@ function updateIGRWeight(){
}
}
}
public function downloadFilesAsZip($igrno)
{
// Get all file details for the given IGR number
$fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno);
if (empty($fileDetails)) {
{
// Get all file details for the given IGR number
$fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno);
if (empty($fileDetails)) {
// Display an alert message
echo '<script>alert("There are no files.");</script>';
redirect('ViewIGR', 'refresh');
return;
}
}
// Define the root path for files
$rootPath = ROOTPATH . 'public/uploads/Igrfiles/';
// Define the root path for files
$rootPath = ROOTPATH . 'public/uploads/Igrfiles/';
// Create a new ZIP archive
$zip = new ZipArchive();
// Create a new ZIP archive
$zip = new ZipArchive();
// Define the name of the ZIP file
$zipFileName = $igrno . '.zip';
$zipFilePath = ROOTPATH . 'public/uploads/Igrfiles/' . $zipFileName;
// Define the name of the ZIP file
$zipFileName = $igrno . '.zip';
$zipFilePath = $rootPath . $zipFileName;
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
// Add each file to the ZIP archive
foreach ($fileDetails as $file) {
$filePath = $rootPath . $file->file;
if (file_exists($filePath)) {
$zip->addFile($filePath, $file->filename);
}
}
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
$filesAdded = false;
// Close the ZIP archive
$zip->close();
// Add each file to the ZIP archive
foreach ($fileDetails as $file) {
$filePath = $rootPath . $file->file;
if (file_exists($filePath)) {
if (!$zip->addFile($filePath, $file->filename)) {
// Handle error when adding file to ZIP
echo '<script>alert("Failed to add file: ' . $file->filename . '");</script>';
$zip->close();
redirect('ViewIGR', 'refresh');
return;
}
$filesAdded = true;
}
}
// Return the ZIP file as a download
return $this->response->download($zipFilePath, null)->setFileName($zipFileName);
} else {
// Handle the error
echo 'Failed to create ZIP file';
}
// Close the ZIP archive
$zip->close();
if ($filesAdded) {
// Return the ZIP file as a download
return $this->response->download($zipFilePath, null)->setFileName($zipFileName);
} else {
// Delete the empty ZIP file
if (file_exists($zipFilePath)) {
unlink($zipFilePath);
}
echo '<script>alert("There are no files.");</script>';
redirect('ViewIGR', 'refresh');
return;
}
} else {
echo '<script>alert("Failed to create ZIP file");</script>';
redirect('ViewIGR', 'refresh');
return;
}
}
}

View File

@ -205,15 +205,15 @@
<table class="table table-bordered" id="Inwardgateregistertable1 table-hover" style="background-color:#fff; font-size:12px;">
<thead style="background-color:#ddd !important">
<tr>
<th>SNo</th>
<th>Item Code</th>
<th>Item Description</th>
<th>UOM</th>
<th>Ordred Qty</th>
<th>Received Qty</th>
<th id="pendingQuantityHeader" style="display:none;">Pending Qty</th>
<th>Remarks</th>
<th></th>
<th style="width: 50px;">SNo</th>
<th style="width: 100px;">Item Code</th>
<th style="width: 200px; word-wrap: break-word; word-break: break-all; white-space: normal;">Item Description</th>
<th style="width: 50px;">UOM</th>
<th style="width: 100px;">Ordered Qty</th>
<th style="width: 100px;">Received Qty</th>
<th id="pendingQuantityHeader" style="display:none; width: 100px;">Pending Qty</th>
<th style="width: 150px;">Remarks</th>
<th style="width: 50px;"></th>
</tr>
</thead>
<tbody id="tbleIGRAppend">
@ -610,15 +610,15 @@ console.log(parsedData);
$("#pendingQuantityHeader").css("display", "table-cell");
trIGRHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
'<td name="MaterialName" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td>' + item.MaterialName + '</td>' +
'<td name="UOM">' + item.UOM + '</td>' +
'<td align="right" id="Quantity' + i + '" name="Quantity">' + parseInt(item.Quantity) + '</td>' +
'<td align="right" data-name="sel" ><input type="text" onchange="validateReceivedQuantity(' + i + ')"id="QuantityAsPerInvoice' + i + '" name="QuantityAsPerInvoice' + i + '" value="' + parseInt(item.QuantityAsPerInvoice) + '" onkeypress="return isNumberKey(event);" style="width: 75px;"></td>' +
'<td name="PendingQuantity' + i + '" id="PendingQuantity' + i + '">' + parseInt(item.Quantity - item.QuantityAsPerInvoice) + '</td>' +
'<td><input type="text" id="Remark' + i + '" name="Remark' + i + '" class="form" onchange="SetRemarks(' + i + ')" style="width: 75px;"> </td>' +
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<td style="width: 50px;" align="right">' + i + '</td>' +
'<td style="width: 100px;" name="MaterialName" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td style="width: 200px; word-wrap: break-word; word-break: break-all; white-space: normal;">' + item.MaterialName + '</td>' +
'<td style="width: 50px;" name="UOM">' + item.UOM + '</td>' +
'<td style="width: 100px;" align="right" id="Quantity' + i + '" name="Quantity">' + parseInt(item.Quantity) + '</td>' +
'<td style="width: 100px;" align="right" data-name="sel" ><input type="text" onchange="validateReceivedQuantity(' + i + ')"id="QuantityAsPerInvoice' + i + '" name="QuantityAsPerInvoice' + i + '" value="' + parseInt(item.QuantityAsPerInvoice) + '" onkeypress="return isNumberKey(event);" style="width: 75px;"></td>' +
'<td style="width: 100px;" name="PendingQuantity' + i + '" id="PendingQuantity' + i + '">' + parseInt(item.Quantity - item.QuantityAsPerInvoice) + '</td>' +
'<td style="width: 150px;"><input type="text" id="Remark' + i + '" name="Remark' + i + '" class="form" onchange="SetRemarks(' + i + ')" style="width: 75px;"> </td>' +
'<td style="width: 50px;"><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
'<input type="hidden" id="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +
@ -641,14 +641,14 @@ console.log(parsedData);
} else {
$("#pendingQuantityHeader").css("display", "none");
trIGRHTML += '<tr>' +
'<td align="right">' + i + '</td>' +
'<td name="MaterialName" id="MaterialCode" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td>' + item.MaterialName + '</td>' +
'<td name="UOM">' + item.UOM + '</td>' +
'<td align="right" name="Quantity">' + item.Quantity + '</td>' +
'<td align="right" data-name="sel" >' + item.QuantityAsPerInvoice + '</td>' +
'<td>' + item.Remarks + '</td>' +
'<td><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<td style="width: 50px;" align="right">' + i + '</td>' +
'<td style="width: 100px;" name="MaterialName" id="MaterialCode" onchange="test(' + i + ')">' + item.MaterialCode + '</td>' +
'<td style="width: 200px; word-wrap: break-word; word-break: break-all; white-space: normal;">' + item.MaterialName + '</td>' +
'<td style="width: 50px;" name="UOM">' + item.UOM + '</td>' +
'<td style="width: 100px;" align="right" name="Quantity">' + item.Quantity + '</td>' +
'<td style="width: 100px;" align="right" data-name="sel" >' + item.QuantityAsPerInvoice + '</td>' +
'<td style="width: 150px;">' + item.Remarks + '</td>' +
'<td style="width: 50px;"><a target="_blank" data-toggle="modal" data-target="#WeightCalculator" title="Weight Calculator" data-index="'+i+'" data-material="'+item.MaterialName+'" data-igrstatus = "'+igrstatus+'"><i class="fa fa-solid fa-truck" style="text-align: center;"></i></a> </td>' +
'<input type="hidden" id="IGRNO' + i + '" name="IGRNO' + i + '" value="' + item.IGRNO + '">' +
'<input type="hidden" id="MaterialCode' + i + '" name="MaterialCode' + i + '" value="' + item.MaterialCode + '">' +
'<input type="hidden" id="txtQuantityAsPerInvoice' + i + '" name="txtQuantityAsPerInvoice' + i + '" value="' + item.QuantityAsPerInvoice + '">' +