latest commit 20-05-2025
This commit is contained in:
parent
215e4c4652
commit
7fea86773b
@ -501,6 +501,10 @@ class Inwardgateregister extends BaseController
|
|||||||
$IGRItemStatus = REQITEM_NEW;
|
$IGRItemStatus = REQITEM_NEW;
|
||||||
$TotalPendingQty = '';
|
$TotalPendingQty = '';
|
||||||
$TotalPendingQty = (int)$TotalPendingQty;
|
$TotalPendingQty = (int)$TotalPendingQty;
|
||||||
|
|
||||||
|
// $PONO_array = $this->inwardgateregister_model->getAllPONO($PONO);
|
||||||
|
|
||||||
|
|
||||||
#Step 7 To Update the Date PO MASTER , Material Master , Historydetails and IGR line Item Details Updating OGR Details
|
#Step 7 To Update the Date PO MASTER , Material Master , Historydetails and IGR line Item Details Updating OGR Details
|
||||||
for ($i = 1; $i <= (int)$RowCount; $i++) {
|
for ($i = 1; $i <= (int)$RowCount; $i++) {
|
||||||
$MaterialCode = $this->request->getPost('MaterialCode' . $i);
|
$MaterialCode = $this->request->getPost('MaterialCode' . $i);
|
||||||
@ -609,17 +613,19 @@ class Inwardgateregister extends BaseController
|
|||||||
$totalReceivedqty = 0 ;
|
$totalReceivedqty = 0 ;
|
||||||
|
|
||||||
|
|
||||||
if(!$IsThisOpenOrderPO && $PreIGRStatus == 1){
|
if(!$IsThisOpenOrderPO && $PreIGRStatus == "ST027"){
|
||||||
|
|
||||||
$quantitiesReceived = $this->inwardgateregister_model->getOldIgrReceivedQty($MaterialCode,$PONO);
|
// $quantitiesReceived = $this->inwardgateregister_model->getOldIgrReceivedQty($MaterialCode,$PONO_array);
|
||||||
|
|
||||||
|
$oldQuantityReceived = 0 ;
|
||||||
|
|
||||||
$newQuantitiesReceived = $QuantityAsPerInvoice;
|
$newQuantitiesReceived = $QuantityAsPerInvoice;
|
||||||
|
|
||||||
$changeInQuantities = $newQuantitiesReceived - $quantitiesReceived;
|
$changeInQuantities = $newQuantitiesReceived - $oldQuantityReceived;
|
||||||
|
|
||||||
$quantityToBeUpdated = $quantitiesReceived + $changeInQuantities;
|
$quantityToBeUpdated = $changeInQuantities;
|
||||||
|
|
||||||
$totalReceivedqty = $quantityToBeUpdated;
|
$totalReceivedqty = $oldQuantityReceived + $quantityToBeUpdated;
|
||||||
|
|
||||||
$POLineItem = array('ReceivedQuantity' => $totalReceivedqty, 'Status' => $ItemStatus, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt);
|
$POLineItem = array('ReceivedQuantity' => $totalReceivedqty, 'Status' => $ItemStatus, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt);
|
||||||
|
|
||||||
@ -909,6 +915,8 @@ function viewIGRDetails()
|
|||||||
$updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
|
$updateigrmaster = $this->inwardgateregister_model->updateigr($igrarr, $IGRNo);
|
||||||
log_message('error', "Master updated successfully: " . $updateigrmaster);
|
log_message('error', "Master updated successfully: " . $updateigrmaster);
|
||||||
|
|
||||||
|
// $PONO_array = $this->inwardgateregister_model->getAllPONO($PONo);
|
||||||
|
|
||||||
# Step 4 : loop starts here for IGRlineitem to save
|
# Step 4 : loop starts here for IGRlineitem to save
|
||||||
if(!empty($tableData )){
|
if(!empty($tableData )){
|
||||||
|
|
||||||
@ -960,15 +968,18 @@ function viewIGRDetails()
|
|||||||
|
|
||||||
# Step 4.3 : IGRlineitem affectedRow have value and MaterialCode have value means
|
# Step 4.3 : IGRlineitem affectedRow have value and MaterialCode have value means
|
||||||
# : updated the polineitem Qty
|
# : updated the polineitem Qty
|
||||||
if(!$IsThisOpenOrderPO && $PreIGRStatus){
|
if(!$IsThisOpenOrderPO && $PreIGRStatus == "ST027"){
|
||||||
|
|
||||||
$quantitiesReceived = $this->inwardgateregister_model->getOldIgrReceivedQty($MaterialCode,$PONo);
|
|
||||||
|
// $quantitiesReceived = $this->inwardgateregister_model->getOldIgrReceivedQty($MaterialCode,$PONO_array);d
|
||||||
|
|
||||||
|
$oldQuantityReceived = $this->inwardgateregister_model->getOldIgrReceivedIndividualQty($IGRNo , $MaterialCode );
|
||||||
|
|
||||||
$newQuantitiesReceived = $quantityAsPerInvoice;
|
$newQuantitiesReceived = $quantityAsPerInvoice;
|
||||||
|
|
||||||
$changeInQuantities = $newQuantitiesReceived - $quantitiesReceived;
|
$changeInQuantities = $newQuantitiesReceived - $oldQuantityReceived;
|
||||||
|
|
||||||
$quantityToBeUpdated = $quantitiesReceived + $changeInQuantities;
|
$quantityToBeUpdated = $oldQuantityReceived + $changeInQuantities;
|
||||||
|
|
||||||
$totalReceivedqty = $quantityToBeUpdated;
|
$totalReceivedqty = $quantityToBeUpdated;
|
||||||
|
|
||||||
|
|||||||
@ -721,20 +721,74 @@ class Inwardgateregister_model extends Model
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOldIgrReceivedQty( $MaterialCode, $PONO) {
|
|
||||||
|
function getAllPONO($PONO){
|
||||||
|
|
||||||
|
$sql_first = "SELECT
|
||||||
|
Distinct tpol.PONO
|
||||||
|
From t_purchaseorder_lineitem tpol
|
||||||
|
Where tpol.ReqNo = (
|
||||||
|
SELECT Distinct ReqNO from t_purchaseorder_lineitem tpol where tpol.PONO = ?
|
||||||
|
)";
|
||||||
|
|
||||||
|
$query_first = $this->db->query($sql_first, [$PONO]);
|
||||||
|
|
||||||
|
$relatedPonosResult = $query_first->getResultArray();
|
||||||
|
|
||||||
|
log_message('info', print_r($relatedPonosResult, true));
|
||||||
|
|
||||||
|
|
||||||
|
$PONO_array = [];
|
||||||
|
|
||||||
|
if (!empty($relatedPonosResult)) {
|
||||||
|
$PONO_array = array_column($relatedPonosResult, 'PONO');
|
||||||
|
return $PONO_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($PONO_array)) {
|
||||||
|
log_message('info', 'No related PONOs found for given PONO. Returning 0.');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getOldIgrReceivedQty( $MaterialCode, $PONO_array) {
|
||||||
|
|
||||||
|
|
||||||
$builder = $this->db->table('t_igr_details tigrd')
|
$builder = $this->db->table('t_igr_details tigrd')
|
||||||
->selectSum('tigrd.QuantityAsPerInvoice')
|
->selectSum('tigrd.QuantityAsPerInvoice')
|
||||||
->join('t_igr_master tigrm','tigrm.IGRNO = tigrd.IGRNO AND tigrm.PONO = ' . $this->db->escape($PONO),'inner')
|
->join('t_igr_master tigrm', 'tigrm.IGRNO = tigrd.IGRNO', 'inner')
|
||||||
->where('tigrm.IGRStatus', 'ST027')
|
->whereIn('tigrm.PONO', $PONO_array)
|
||||||
->where('tigrd.MaterialCode', $MaterialCode)
|
->where('tigrm.IGRStatus', 'ST027')
|
||||||
->groupBy('tigrd.MaterialCode');
|
->where('tigrd.MaterialCode', $MaterialCode)
|
||||||
|
->groupBy('tigrd.MaterialCode');
|
||||||
|
|
||||||
$query = $builder->get()->getRow();
|
$result = $builder->get()->getRow();
|
||||||
|
|
||||||
log_message('info', 'getOldIgrReceivedQty Query: ' . $this->db->getLastQuery()->getQuery());
|
log_message('info', 'getOldIgrReceivedQty Second Query: ' . $this->db->getLastQuery()->getQuery());
|
||||||
|
|
||||||
|
// Return the sum or 0 if no result from the second query
|
||||||
|
return $result ? $result->QuantityAsPerInvoice : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOldIgrReceivedIndividualQty($IGRNo , $MaterialCode){
|
||||||
|
|
||||||
|
$builder = $this->db->table('t_igr_details tigrd')
|
||||||
|
->selectSum('tigrd.QuantityAsPerInvoice')
|
||||||
|
->where('tigrd.IGRNO',$IGRNo)
|
||||||
|
->where('tigrd.mIGRStatus', 'ST027')
|
||||||
|
->where('tigrd.MaterialCode', $MaterialCode)
|
||||||
|
->groupBy('tigrd.MaterialCode');
|
||||||
|
|
||||||
|
$result = $builder->get()->getRow();
|
||||||
|
|
||||||
|
log_message('info', 'getOldIgrReceivedIndividualQty Query: ' . $this->db->getLastQuery()->getQuery());
|
||||||
|
|
||||||
|
// Return the sum or 0 if no result from the second query
|
||||||
|
return $result ? $result->QuantityAsPerInvoice : 0;
|
||||||
|
|
||||||
return $query ? $query->QuantityAsPerInvoice : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,7 @@
|
|||||||
|
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<label for="to_date">
|
<label for="to_date">
|
||||||
<?php echo 'year'; ?>
|
<?php echo 'Year'; ?>
|
||||||
</label>
|
</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<select class="form-control" id="financialyear" name="financialyear">
|
<select class="form-control" id="financialyear" name="financialyear">
|
||||||
|
|||||||
@ -1473,6 +1473,7 @@
|
|||||||
var pono = $("#PONO1").val();
|
var pono = $("#PONO1").val();
|
||||||
var status = 0;
|
var status = 0;
|
||||||
var tableData = [];
|
var tableData = [];
|
||||||
|
|
||||||
$('#tbleIGRAppend tr').each(function(index) {
|
$('#tbleIGRAppend tr').each(function(index) {
|
||||||
var row = $(this);
|
var row = $(this);
|
||||||
++index;
|
++index;
|
||||||
@ -1510,6 +1511,7 @@
|
|||||||
formData.append('hiddenIsOpenOrder', $("#hiddenIsOpenOrder").val());
|
formData.append('hiddenIsOpenOrder', $("#hiddenIsOpenOrder").val());
|
||||||
formData.append('MasterFile', $('#MasterFile')[0].files[0]);
|
formData.append('MasterFile', $('#MasterFile')[0].files[0]);
|
||||||
formData.append('file_name[]', $('#file_name').val());
|
formData.append('file_name[]', $('#file_name').val());
|
||||||
|
formData.append('MasterRemarks', $("#MasterRemarks").val());
|
||||||
var empFiles = $('#emp_file')[0] ? $('#emp_file')[0].files : null;
|
var empFiles = $('#emp_file')[0] ? $('#emp_file')[0].files : null;
|
||||||
if (empFiles) {
|
if (empFiles) {
|
||||||
for (var i = 0; i < empFiles.length; i++) {
|
for (var i = 0; i < empFiles.length; i++) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user