Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme
This commit is contained in:
commit
b7211345ea
@ -67,8 +67,26 @@ class Inwardgateregister extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
$this->global['pageTitle'] = 'View Inward Gate Register';
|
$this->global['pageTitle'] = 'View Inward Gate Register';
|
||||||
$result = $this->inwardgateregister_model->ViewigrListing($fromDate,$toDate);
|
$result = $this->inwardgateregister_model->ViewigrListing($fromDate, $toDate);
|
||||||
$data['IGR'] = $result[0];
|
$igrList = $result[0];
|
||||||
|
|
||||||
|
foreach ($igrList as &$igr) {
|
||||||
|
$igrNo = $igr->IGRNO;
|
||||||
|
$fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrNo);
|
||||||
|
$igr->isIgrFilePresent = false; // Initialize the key
|
||||||
|
|
||||||
|
foreach ($fileDetails as $file) {
|
||||||
|
if (!empty($file->file)) {
|
||||||
|
$igr->isIgrFilePresent = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unset reference to avoid side effects
|
||||||
|
unset($igr);
|
||||||
|
|
||||||
|
$data['IGR'] = $igrList;
|
||||||
$data['IGRDownload'] = $result[1];
|
$data['IGRDownload'] = $result[1];
|
||||||
$data['userRole'] = $this->session->get('role');
|
$data['userRole'] = $this->session->get('role');
|
||||||
$data['transporter'] = $this->inwardgateregister_model->transporter();
|
$data['transporter'] = $this->inwardgateregister_model->transporter();
|
||||||
@ -1672,19 +1690,22 @@ function updateIGRWeight(){
|
|||||||
public function downloadFilesAsZip($igrno)
|
public function downloadFilesAsZip($igrno)
|
||||||
{
|
{
|
||||||
// Get all file details for the given IGR number
|
// Get all file details for the given IGR number
|
||||||
$fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno);
|
$fileDetails = $this->inwardgateregister_model->getAllIgrFileDetails($igrno);
|
||||||
if (empty($fileDetails)) {
|
|
||||||
echo '<script>alert("There are no files.");</script>';
|
|
||||||
redirect('ViewIGR', 'refresh');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the root path for files
|
// Define the root path for files
|
||||||
$rootPath = ROOTPATH . 'public/uploads/Igrfiles/';
|
$rootPath = ROOTPATH . 'public/uploads/Igrfiles/';
|
||||||
|
|
||||||
// Check if root path is valid
|
// Check if the directory exists, create if it doesn't
|
||||||
if (!is_dir($rootPath)) {
|
if (!is_dir($rootPath)) {
|
||||||
echo '<script>alert("Invalid file directory.");</script>';
|
if (!mkdir($rootPath, 0755, true)) {
|
||||||
|
echo '<script>alert("Failed to create the directory.");</script>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the directory is writable
|
||||||
|
if (!is_writable($rootPath)) {
|
||||||
|
echo '<script>alert("Directory is not writable.");</script>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1693,49 +1714,50 @@ function updateIGRWeight(){
|
|||||||
$zipFileName = $igrno . '.zip';
|
$zipFileName = $igrno . '.zip';
|
||||||
$zipFilePath = $rootPath . $zipFileName;
|
$zipFilePath = $rootPath . $zipFileName;
|
||||||
|
|
||||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
|
// Attempt to open the ZIP file
|
||||||
$filesAdded = false;
|
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== TRUE) {
|
||||||
|
echo '<script>alert("Failed to create ZIP file.");</script>';
|
||||||
|
return redirect()->to('/ViewIGR');
|
||||||
|
}
|
||||||
|
|
||||||
// Add each file to the ZIP archive
|
$filesAdded = false;
|
||||||
foreach ($fileDetails as $file) {
|
|
||||||
$filePath = $rootPath . $file->file;
|
|
||||||
|
|
||||||
// Check if file exists
|
// Add each file to the ZIP archive
|
||||||
if (!file_exists($filePath)) {
|
foreach ($fileDetails as $file) {
|
||||||
log_message('error', 'File not found: ' . $filePath);
|
$filePath = $rootPath . $file->file;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Ensure file exists and is not a directory
|
||||||
|
if (file_exists($filePath) && is_file($filePath)) {
|
||||||
|
// Sanitize filename for ZIP
|
||||||
$sanitizedFilename = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $file->filename);
|
$sanitizedFilename = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $file->filename);
|
||||||
|
|
||||||
if (!$zip->addFile($filePath, $sanitizedFilename)) {
|
if (!$zip->addFile($filePath, $sanitizedFilename)) {
|
||||||
log_message('error', 'Failed to add file: ' . $sanitizedFilename);
|
echo '<script>alert("Failed to add file: ' . $file->filename . '");</script>';
|
||||||
$zip->close();
|
$zip->close();
|
||||||
redirect('ViewIGR', 'refresh');
|
return redirect()->to('/ViewIGR');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$filesAdded = true;
|
$filesAdded = true;
|
||||||
}
|
|
||||||
|
|
||||||
// Close the ZIP archive
|
|
||||||
$zip->close();
|
|
||||||
|
|
||||||
if ($filesAdded) {
|
|
||||||
return $this->response->download($zipFilePath, null)->setFileName($zipFileName);
|
|
||||||
} else {
|
} else {
|
||||||
if (file_exists($zipFilePath)) {
|
echo '<script> alert("File not found or is a directory: ' . $filePath . '");</script>';
|
||||||
unlink($zipFilePath);
|
continue;
|
||||||
}
|
|
||||||
echo '<script>alert("No files were added to the ZIP.");</script>';
|
|
||||||
redirect('ViewIGR', 'refresh');
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close ZIP archive if files were added
|
||||||
|
if ($filesAdded) {
|
||||||
|
$zip->close(); // Close ZIP only if files were added
|
||||||
|
return $this->response->download($zipFilePath, null)->setFileName($zipFileName);
|
||||||
} else {
|
} else {
|
||||||
echo '<script>alert("Failed to create ZIP file");</script>';
|
// Close and remove any empty ZIP file created
|
||||||
redirect('ViewIGR', 'refresh');
|
$zip->close();
|
||||||
return;
|
if (file_exists($zipFilePath)) {
|
||||||
|
unlink($zipFilePath);
|
||||||
|
}
|
||||||
|
echo '<script>alert("No files were added to the ZIP.");</script>';
|
||||||
|
return redirect()->to('/ViewIGR');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -165,6 +165,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<?php if (session()->getFlashdata('message')): ?>
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
<?= esc(session()->getFlashdata('message')); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@ -245,21 +251,7 @@
|
|||||||
<td><?php echo $record->TransporterName ?></td>
|
<td><?php echo $record->TransporterName ?></td>
|
||||||
<td><?php echo $record->IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?></td>
|
<td><?php echo $record->IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php if(!empty($record->IGRNO)){ ?>
|
|
||||||
<a target="_blank" href="<?php echo base_url('download-files/' . $record->IGRNO); ?>">
|
|
||||||
<i class="fa fa-download" style="text-align: center;"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<?php if (!empty($record->FilePath)) { ?>
|
|
||||||
<!-- <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Files" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><i class="fa fa-clone" style="text-align: center;"></i></a> -->
|
|
||||||
<?php } else if (!empty($record->file)) { ?>
|
|
||||||
<!-- <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Files" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><i class="fa fa-clone" style="text-align: center;"></i></a> -->
|
|
||||||
<?php } else { ?>
|
|
||||||
<!-- <a target="_blank" data-toggle="modal" data-target="#Fileshow" data-id="<%=index%>" title="Files" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>"><i class="fa fa-clone" style="text-align: center;"></i></a> -->
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<a target="_blank" data-toggle="modal" data-target="#Historyshow" data-id="<%=index%>" title="IGR History" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>">
|
<a target="_blank" data-toggle="modal" data-target="#Historyshow" data-id="<%=index%>" title="IGR History" data-igrno="<?php echo $record->IGRNO ?>" data-pono="<?php echo $record->PONO ?>">
|
||||||
<i class="fa fa-history" style="text-align: center;"></i>
|
<i class="fa fa-history" style="text-align: center;"></i>
|
||||||
</a>
|
</a>
|
||||||
@ -267,7 +259,13 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- <a class="a_tag_for_mrir" href="<?php echo base_url().'MRIRcontroller/igrdatavalues?IGRNO='.$record->IGRNO; ?>" target="_blank" data-id="<%=index%>" title="Generate MRIR"><i class="fa fa-external-link" style="text-align: center;"></i></a> -->
|
<!-- <a class="a_tag_for_mrir" href="<?php echo base_url().'MRIRcontroller/igrdatavalues?IGRNO='.$record->IGRNO; ?>" target="_blank" data-id="<%=index%>" title="Generate MRIR"><i class="fa fa-external-link" style="text-align: center;"></i></a> -->
|
||||||
</td>
|
<?php if(($record->isIgrFilePresent)){ ?>
|
||||||
|
<a target="_blank" href="<?php echo base_url('download-files/' . $record->IGRNO); ?>">
|
||||||
|
<i class="fa fa-download" style="text-align: center;"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@ -670,8 +668,7 @@
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo base_url() ?>ViewIGRDetails",
|
url: "<?php echo base_url() ?>ViewIGRDetails",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
// success:function(data) {
|
|
||||||
// $('#content').loader('hide');
|
|
||||||
var parsedData = JSON.parse(data);
|
var parsedData = JSON.parse(data);
|
||||||
console.log(parsedData);
|
console.log(parsedData);
|
||||||
if (parsedData['details'].length === 0) {
|
if (parsedData['details'].length === 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user