worked on changes in purchase module
This commit is contained in:
parent
cd0c6437cc
commit
f51aa8541e
@ -42,23 +42,23 @@ class Amendmentpurchaseorder extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'GET')
|
if ($this->request->getMethod() === 'GET')
|
||||||
{
|
{
|
||||||
$currentYear = date('Y');
|
$currentYear = date('Y');
|
||||||
$currentMonth = date('m');
|
$currentMonth = date('m');
|
||||||
$startOfMonth = "$currentYear-$currentMonth-01";
|
$startOfMonth = "$currentYear-$currentMonth-01";
|
||||||
$endOfMonth = date('Y-m-t');
|
$endOfMonth = date('Y-m-t');
|
||||||
$fromDate = $startOfMonth;
|
$fromDate = $startOfMonth;
|
||||||
$toDate = $endOfMonth;
|
$toDate = $endOfMonth;
|
||||||
} elseif ($this->request->getMethod() === 'POST') {
|
} elseif ($this->request->getMethod() === 'POST') {
|
||||||
$fromDate = $this->request->getPost('fromDate');
|
$fromDate = $this->request->getPost('fromDate');
|
||||||
$toDate = $this->request->getPost('toDate');
|
$toDate = $this->request->getPost('toDate');
|
||||||
$fromDate = date('Y-m-d', strtotime($fromDate));
|
$fromDate = date('Y-m-d', strtotime($fromDate));
|
||||||
$toDate = date('Y-m-d', strtotime($toDate));
|
$toDate = date('Y-m-d', strtotime($toDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->load->library('pagination');
|
// $this->load->library('pagination');
|
||||||
$forwhat = 'amendment';
|
$forwhat = 'amendment';
|
||||||
|
|
||||||
$data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat,$fromDate,$toDate);
|
$data['POData'] = $this->purchaseorder_model->purchaseorderListing($forwhat,$fromDate,$toDate);
|
||||||
$data['fromDate'] = date('d-m-Y', strtotime($fromDate));
|
$data['fromDate'] = date('d-m-Y', strtotime($fromDate));
|
||||||
@ -1340,8 +1340,6 @@ class Amendmentpurchaseorder extends BaseController
|
|||||||
$createddt = get_current_date_time();
|
$createddt = get_current_date_time();
|
||||||
$updateddt = get_current_date_time();
|
$updateddt = get_current_date_time();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
$PaymentTerms = $this->request->getPost('PaymentTerms');
|
||||||
$beforePaymentTerms = $this->request->getPost('beforePaymentterms');
|
$beforePaymentTerms = $this->request->getPost('beforePaymentterms');
|
||||||
|
|
||||||
@ -1410,20 +1408,17 @@ class Amendmentpurchaseorder extends BaseController
|
|||||||
}
|
}
|
||||||
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster, $CreateBy, $PONO);
|
$LastPO = $this->purchaseorder_model->addAmendPOMaster($POMaster, $CreateBy, $PONO);
|
||||||
$NewPO = '';
|
$NewPO = '';
|
||||||
// if (count($LastPO) > 0) {
|
|
||||||
// $NewPO = $LastPO[0]['PONO'];
|
|
||||||
// }
|
|
||||||
// print_r($LastPO);die;
|
|
||||||
foreach ($LastPO as $PO) :
|
foreach ($LastPO as $PO) :
|
||||||
$NewPO = $PO['PONO'];
|
$NewPO = $PO['PONO'];
|
||||||
endforeach;
|
endforeach;
|
||||||
$PODetail = array('Status' => PO_AMENDED); //TO SET PARENT PO AS AMENDMENT STATUS
|
$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 = '';
|
$po = '';
|
||||||
$igrno = '';
|
$igrno = '';
|
||||||
|
|||||||
@ -1670,64 +1670,72 @@ 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)) {
|
if (empty($fileDetails)) {
|
||||||
// Display an alert message
|
echo '<script>alert("There are no files.");</script>';
|
||||||
echo '<script>alert("There are no files.");</script>';
|
redirect('ViewIGR', 'refresh');
|
||||||
redirect('ViewIGR', 'refresh');
|
return;
|
||||||
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
|
||||||
// Create a new ZIP archive
|
if (!is_dir($rootPath)) {
|
||||||
$zip = new ZipArchive();
|
echo '<script>alert("Invalid file directory.");</script>';
|
||||||
|
return;
|
||||||
// Define the name of the ZIP file
|
}
|
||||||
$zipFileName = $igrno . '.zip';
|
|
||||||
$zipFilePath = $rootPath . $zipFileName;
|
// Create a new ZIP archive
|
||||||
|
$zip = new ZipArchive();
|
||||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
|
$zipFileName = $igrno . '.zip';
|
||||||
$filesAdded = false;
|
$zipFilePath = $rootPath . $zipFileName;
|
||||||
|
|
||||||
// Add each file to the ZIP archive
|
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
|
||||||
foreach ($fileDetails as $file) {
|
$filesAdded = false;
|
||||||
$filePath = $rootPath . $file->file;
|
|
||||||
if (file_exists($filePath)) {
|
// Add each file to the ZIP archive
|
||||||
if (!$zip->addFile($filePath, $file->filename)) {
|
foreach ($fileDetails as $file) {
|
||||||
// Handle error when adding file to ZIP
|
$filePath = $rootPath . $file->file;
|
||||||
echo '<script>alert("Failed to add file: ' . $file->filename . '");</script>';
|
|
||||||
$zip->close();
|
// Check if file exists
|
||||||
redirect('ViewIGR', 'refresh');
|
if (!file_exists($filePath)) {
|
||||||
return;
|
log_message('error', 'File not found: ' . $filePath);
|
||||||
}
|
continue;
|
||||||
$filesAdded = true;
|
}
|
||||||
}
|
|
||||||
}
|
$sanitizedFilename = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $file->filename);
|
||||||
|
|
||||||
// Close the ZIP archive
|
if (!$zip->addFile($filePath, $sanitizedFilename)) {
|
||||||
$zip->close();
|
log_message('error', 'Failed to add file: ' . $sanitizedFilename);
|
||||||
|
$zip->close();
|
||||||
if ($filesAdded) {
|
redirect('ViewIGR', 'refresh');
|
||||||
// Return the ZIP file as a download
|
return;
|
||||||
return $this->response->download($zipFilePath, null)->setFileName($zipFileName);
|
}
|
||||||
} else {
|
$filesAdded = true;
|
||||||
// Delete the empty ZIP file
|
}
|
||||||
if (file_exists($zipFilePath)) {
|
|
||||||
unlink($zipFilePath);
|
// Close the ZIP archive
|
||||||
}
|
$zip->close();
|
||||||
echo '<script>alert("There are no files.");</script>';
|
|
||||||
redirect('ViewIGR', 'refresh');
|
if ($filesAdded) {
|
||||||
return;
|
return $this->response->download($zipFilePath, null)->setFileName($zipFileName);
|
||||||
}
|
} else {
|
||||||
} else {
|
if (file_exists($zipFilePath)) {
|
||||||
echo '<script>alert("Failed to create ZIP file");</script>';
|
unlink($zipFilePath);
|
||||||
redirect('ViewIGR', 'refresh');
|
}
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -389,8 +389,6 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
|
|||||||
|
|
||||||
function purchaseorderListing($forwhat ,$fromDate='',$toDate='')
|
function purchaseorderListing($forwhat ,$fromDate='',$toDate='')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$builder = $this->db->table('t_purchaseorder_master POMast')->distinct()
|
$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')
|
->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)
|
function getPOList($type, $fromDate , $toDate)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$builder = $this->db->table('t_purchaseorder_master mast')->distinct()
|
$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('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')
|
(select FirstName from t_employee_details where EmpID=EID)as Approver,sup.SupplierName,sup.MSME')
|
||||||
|
|||||||
@ -110,7 +110,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<!-- <th>#</th> -->
|
<!-- <th>#</th> -->
|
||||||
<th>PO Date</th>
|
<th>Created Date</th>
|
||||||
<th>PONO</th>
|
<th>PONO</th>
|
||||||
<th>PO Type</th>
|
<th>PO Type</th>
|
||||||
<th>Supplier Name</th>
|
<th>Supplier Name</th>
|
||||||
@ -132,7 +132,7 @@
|
|||||||
?>
|
?>
|
||||||
<tr id="<?php echo $index; ?>">
|
<tr id="<?php echo $index; ?>">
|
||||||
<!-- <td align="left"><?php echo $index; ?></td> -->
|
<!-- <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');
|
$PODate = $Pdt->format('d-m-Y');
|
||||||
echo $PODate
|
echo $PODate
|
||||||
?></td>
|
?></td>
|
||||||
|
|||||||
@ -202,7 +202,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="supplierid" class="col-form-label">Supplier </label>
|
<label for="supplierid" class="col-form-label">Supplier </label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<select name="supplierid" id="supplierid" class="form-control" required>
|
<select name="supplierid" id="supplierid" class="form-control" required>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -211,7 +211,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="supplierid" class="col-form-label">Item Description </label>
|
<label for="supplierid" class="col-form-label">Item Description </label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<textarea name="item_description" id="item_description" class="form-control"></textarea>
|
<textarea name="item_description" id="item_description" class="form-control"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -219,7 +219,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="cost" class="col-form-label">Cost</label>
|
<label for="cost" class="col-form-label">Cost</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<input type="number" name="cost" id="cost" class="form-control" required onchange="totalCalculate()">
|
<input type="number" name="cost" id="cost" class="form-control" required onchange="totalCalculate()">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -227,7 +227,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="cost" class="col-form-label">CGST</label>
|
<label for="cost" class="col-form-label">CGST</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<input type="number" name="cgst" id="cgst" class="form-control" onchange="totalCalculate()">
|
<input type="number" name="cgst" id="cgst" class="form-control" onchange="totalCalculate()">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -235,7 +235,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="cost" class="col-form-label">SGST</label>
|
<label for="cost" class="col-form-label">SGST</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<input type="number" name="sgst" id="sgst" class="form-control" onchange="totalCalculate()">
|
<input type="number" name="sgst" id="sgst" class="form-control" onchange="totalCalculate()">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -243,7 +243,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="igst" class="col-form-label">IGST</label>
|
<label for="igst" class="col-form-label">IGST</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<input type="number" name="igst" id="igst" class="form-control" onchange="totalCalculate()">
|
<input type="number" name="igst" id="igst" class="form-control" onchange="totalCalculate()">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -251,7 +251,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="cost" class="col-form-label">Total</label>
|
<label for="cost" class="col-form-label">Total</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<input type="number" name="total" id="total" class="form-control">
|
<input type="number" name="total" id="total" class="form-control">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -260,7 +260,7 @@
|
|||||||
<label for="transporterfile" class="col-form-label">Transporter File</label>
|
<label for="transporterfile" class="col-form-label">Transporter File</label>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<input type="file" name="transporterfile" id="transporterfile" class="form-control">
|
<input type="file" name="transporterfile" id="transporterfile" class="form-control">
|
||||||
<input type="hidden" name="transporterfile_name" id="transporterfile_name">
|
<input type="hidden" name="transporterfile_name" id="transporterfile_name">
|
||||||
<small id="fileHelp" class="form-text text-muted">
|
<small id="fileHelp" class="form-text text-muted">
|
||||||
@ -272,7 +272,7 @@
|
|||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label for="note" class="col-form-label">Notes</label>
|
<label for="note" class="col-form-label">Notes</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col">
|
||||||
<textarea name="remarks" id="remarks" class="form-control"></textarea>
|
<textarea name="remarks" id="remarks" class="form-control"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -173,7 +173,7 @@ if (empty($Status)) {
|
|||||||
<table id="po_release" class="table dt-responsive wrap w-100">
|
<table id="po_release" class="table dt-responsive wrap w-100">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>PO Date</th>
|
<th>Created Date</th>
|
||||||
<th>PONO</th>
|
<th>PONO</th>
|
||||||
<th>PO Type</th>
|
<th>PO Type</th>
|
||||||
<th>Cost Center</th>
|
<th>Cost Center</th>
|
||||||
@ -200,7 +200,7 @@ if (empty($Status)) {
|
|||||||
//echo $index;
|
//echo $index;
|
||||||
?>
|
?>
|
||||||
<tr id="<?php 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');
|
$PODate = $podt->format('d-m-Y');
|
||||||
echo $PODate;
|
echo $PODate;
|
||||||
?></td>
|
?></td>
|
||||||
|
|||||||
@ -245,10 +245,13 @@
|
|||||||
<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); ?>">
|
<a target="_blank" href="<?php echo base_url('download-files/' . $record->IGRNO); ?>">
|
||||||
<i class="fa fa-download" style="text-align: center;"></i>
|
<i class="fa fa-download" style="text-align: center;"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<?php if (!empty($record->FilePath)) { ?>
|
<?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> -->
|
<!-- <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)) { ?>
|
<?php } else if (!empty($record->file)) { ?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user