worked on changes in purchase module

This commit is contained in:
vadivel J 2024-10-24 17:58:48 +05:30
parent cd0c6437cc
commit f51aa8541e
7 changed files with 97 additions and 95 deletions

View File

@ -42,23 +42,23 @@ class Amendmentpurchaseorder extends BaseController
{
if ($this->request->getMethod() === 'GET')
{
$currentYear = date('Y');
$currentMonth = date('m');
if ($this->request->getMethod() === 'GET')
{
$currentYear = date('Y');
$currentMonth = date('m');
$startOfMonth = "$currentYear-$currentMonth-01";
$endOfMonth = date('Y-m-t');
$fromDate = $startOfMonth;
$toDate = $endOfMonth;
} elseif ($this->request->getMethod() === 'POST') {
$fromDate = $this->request->getPost('fromDate');
$toDate = $this->request->getPost('toDate');
$fromDate = $startOfMonth;
$toDate = $endOfMonth;
} elseif ($this->request->getMethod() === 'POST') {
$fromDate = $this->request->getPost('fromDate');
$toDate = $this->request->getPost('toDate');
$fromDate = date('Y-m-d', strtotime($fromDate));
$toDate = date('Y-m-d', strtotime($toDate));
}
// $this->load->library('pagination');
$forwhat = 'amendment';
$forwhat = 'amendment';
$data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat,$fromDate,$toDate);
$data['fromDate'] = date('d-m-Y', strtotime($fromDate));
@ -1340,8 +1340,6 @@ class Amendmentpurchaseorder extends BaseController
$createddt = get_current_date_time();
$updateddt = get_current_date_time();
$PaymentTerms = $this->request->getPost('PaymentTerms');
$beforePaymentTerms = $this->request->getPost('beforePaymentterms');
@ -1410,20 +1408,17 @@ class Amendmentpurchaseorder extends BaseController
}
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster, $CreateBy, $PONO);
$NewPO = '';
// if (count($LastPO) > 0) {
// $NewPO = $LastPO[0]['PONO'];
// }
// print_r($LastPO);die;
foreach ($LastPO as $PO) :
$NewPO = $PO['PONO'];
endforeach;
$PODetail = array('Status' => PO_AMENDED); //TO SET PARENT PO AS AMENDMENT STATUS
$APO = $this->purchaseorder_model->updateAmendPOMaster($PONO, $PODetail);
$APO = $this->purchaseorder_model->updateAmendPOMaster($PONO, $PODetail);
$LineItemStatus = REQITEM_NEW;
$LineItemStatus = REQITEM_NEW;
$igrvalue = $this->purchaseorder_model->selectigrmaster($PONO);
$igrvalue = $this->purchaseorder_model->selectigrmaster($PONO);
$po = '';
$igrno = '';

View File

@ -1670,64 +1670,72 @@ function updateIGRWeight(){
}
public function downloadFilesAsZip($igrno)
{
// 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/';
// Create a new ZIP archive
$zip = new ZipArchive();
// Define the name of the ZIP file
$zipFileName = $igrno . '.zip';
$zipFilePath = $rootPath . $zipFileName;
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
$filesAdded = false;
// 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;
}
}
// 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;
}
}
{
// Get all file details for the given IGR number
$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
$rootPath = ROOTPATH . 'public/uploads/Igrfiles/';
// Check if root path is valid
if (!is_dir($rootPath)) {
echo '<script>alert("Invalid file directory.");</script>';
return;
}
// Create a new ZIP archive
$zip = new ZipArchive();
$zipFileName = $igrno . '.zip';
$zipFilePath = $rootPath . $zipFileName;
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
$filesAdded = false;
// Add each file to the ZIP archive
foreach ($fileDetails as $file) {
$filePath = $rootPath . $file->file;
// Check if file exists
if (!file_exists($filePath)) {
log_message('error', 'File not found: ' . $filePath);
continue;
}
$sanitizedFilename = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $file->filename);
if (!$zip->addFile($filePath, $sanitizedFilename)) {
log_message('error', 'Failed to add file: ' . $sanitizedFilename);
$zip->close();
redirect('ViewIGR', 'refresh');
return;
}
$filesAdded = true;
}
// Close the ZIP archive
$zip->close();
if ($filesAdded) {
return $this->response->download($zipFilePath, null)->setFileName($zipFileName);
} else {
if (file_exists($zipFilePath)) {
unlink($zipFilePath);
}
echo '<script>alert("No files were added to the ZIP.");</script>';
redirect('ViewIGR', 'refresh');
return;
}
} else {
echo '<script>alert("Failed to create ZIP file");</script>';
redirect('ViewIGR', 'refresh');
return;
}
}
}

View File

@ -389,8 +389,6 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
function purchaseorderListing($forwhat ,$fromDate='',$toDate='')
{
$builder = $this->db->table('t_purchaseorder_master POMast')->distinct()
->select('POMast.PONO,POMast.CreatedDate,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Stat.StatusCode,POMast.POType as ReqType,DeliveryDate,DeliverySchedule,DeliveryOption,POMast.CapitalRange')
@ -1595,8 +1593,6 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
function getPOList($type, $fromDate , $toDate)
{
$builder = $this->db->table('t_purchaseorder_master mast')->distinct()
->select('mast.PODate,mast.PONO,mast.TotalOrderValue,st.StatusCode,st.StatusName,emp.FirstName,mast.CreatedDate,ccm.CostCenterName,ccm.CostCenterCode,mast.POType as RType,mast.Remarks,DepartmentName,mast.ApprovedBy,(select EmpID from tbl_users where userId=mast.ApprovedBy )as EID,rmast.ReqType,mast.Status,mast.CapitalRange,
(select FirstName from t_employee_details where EmpID=EID)as Approver,sup.SupplierName,sup.MSME')

View File

@ -110,7 +110,7 @@
<thead>
<tr>
<!-- <th>#</th> -->
<th>PO Date</th>
<th>Created Date</th>
<th>PONO</th>
<th>PO Type</th>
<th>Supplier Name</th>
@ -132,7 +132,7 @@
?>
<tr id="<?php echo $index; ?>">
<!-- <td align="left"><?php echo $index; ?></td> -->
<td><?php $Pdt = new DateTime($record->PODate);
<td><?php $Pdt = new DateTime($record->CreatedDate);
$PODate = $Pdt->format('d-m-Y');
echo $PODate
?></td>

View File

@ -202,7 +202,7 @@
<div class="col-md-3">
<label for="supplierid" class="col-form-label">Supplier </label>
</div>
<div class="col-md-5">
<div class="col">
<select name="supplierid" id="supplierid" class="form-control" required>
</select>
</div>
@ -211,7 +211,7 @@
<div class="col-md-3">
<label for="supplierid" class="col-form-label">Item Description </label>
</div>
<div class="col-md-5">
<div class="col">
<textarea name="item_description" id="item_description" class="form-control"></textarea>
</div>
</div>
@ -219,7 +219,7 @@
<div class="col-md-3">
<label for="cost" class="col-form-label">Cost</label>
</div>
<div class="col-md-5">
<div class="col">
<input type="number" name="cost" id="cost" class="form-control" required onchange="totalCalculate()">
</div>
</div>
@ -227,7 +227,7 @@
<div class="col-md-3">
<label for="cost" class="col-form-label">CGST</label>
</div>
<div class="col-md-5">
<div class="col">
<input type="number" name="cgst" id="cgst" class="form-control" onchange="totalCalculate()">
</div>
</div>
@ -235,7 +235,7 @@
<div class="col-md-3">
<label for="cost" class="col-form-label">SGST</label>
</div>
<div class="col-md-5">
<div class="col">
<input type="number" name="sgst" id="sgst" class="form-control" onchange="totalCalculate()">
</div>
</div>
@ -243,7 +243,7 @@
<div class="col-md-3">
<label for="igst" class="col-form-label">IGST</label>
</div>
<div class="col-md-5">
<div class="col">
<input type="number" name="igst" id="igst" class="form-control" onchange="totalCalculate()">
</div>
</div>
@ -251,7 +251,7 @@
<div class="col-md-3">
<label for="cost" class="col-form-label">Total</label>
</div>
<div class="col-md-5">
<div class="col">
<input type="number" name="total" id="total" class="form-control">
</div>
</div>
@ -260,7 +260,7 @@
<label for="transporterfile" class="col-form-label">Transporter File</label>
</div>
<div class="col-md-5">
<div class="col">
<input type="file" name="transporterfile" id="transporterfile" class="form-control">
<input type="hidden" name="transporterfile_name" id="transporterfile_name">
<small id="fileHelp" class="form-text text-muted">
@ -272,7 +272,7 @@
<div class="col-md-3">
<label for="note" class="col-form-label">Notes</label>
</div>
<div class="col-md-5">
<div class="col">
<textarea name="remarks" id="remarks" class="form-control"></textarea>
</div>
</div>

View File

@ -173,7 +173,7 @@ if (empty($Status)) {
<table id="po_release" class="table dt-responsive wrap w-100">
<thead>
<tr>
<th>PO Date</th>
<th>Created Date</th>
<th>PONO</th>
<th>PO Type</th>
<th>Cost Center</th>
@ -200,7 +200,7 @@ if (empty($Status)) {
//echo $index;
?>
<tr id="<?php echo $index ?>">
<td><?php $podt = new DateTime($record->PODate);
<td><?php $podt = new DateTime($record->CreatedDate);
$PODate = $podt->format('d-m-Y');
echo $PODate;
?></td>

View File

@ -245,10 +245,13 @@
<td><?php echo $record->TransporterName ?></td>
<td><?php echo $record->IGRStatus == 'ST074' ? 'Draft' : 'Completed'; ?></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>
&nbsp;
<?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)) { ?>