FIX_rcvqtyonlydisplayed

This commit is contained in:
VE10-Sanjeev 2024-08-19 11:33:00 +00:00
parent cc5bc95757
commit 7708d522c1
2 changed files with 89 additions and 73 deletions

View File

@ -371,11 +371,12 @@ class Inwardgateregister extends BaseController
foreach ($files['emp_file'] as $index => $file) { foreach ($files['emp_file'] as $index => $file) {
if ($file->isValid() && !$file->hasMoved()) { if ($file->isValid() && !$file->hasMoved()) {
// Move the file to the desired directory // Move the file to the desired directory
$finallyfilename = (!empty($fileNames[$index])) ? $fileNames[$index] : $file->getName();
$newName = $file->getRandomName(); $newName = $file->getRandomName();
$file->move($path, $newName); $file->move($path, $newName);
// Store the file information in the database // Store the file information in the database
$additionalFiles = array( $additionalFiles = array(
'Remarks' => $fileNames[$index], 'Remarks' => $finallyfilename,
'FilePath' => $newName, 'FilePath' => $newName,
'IGRNO' => $IGRNO, 'IGRNO' => $IGRNO,
'PONO' => $PONO 'PONO' => $PONO
@ -383,7 +384,7 @@ class Inwardgateregister extends BaseController
$lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles); $lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles);
if ($lastInsertFileId) { if ($lastInsertFileId) {
$fileupdated_count++; $fileupdated_count++;
$fileupdated_name[] = $fileNames[$index]; $fileupdated_name[] = $finallyfilename;
} }
} }
} }
@ -478,78 +479,90 @@ class Inwardgateregister extends BaseController
log_message('error', 'SaveIGR igrDetails result : ' . json_encode($igrDetails)); log_message('error', 'SaveIGR igrDetails result : ' . json_encode($igrDetails));
$igrlineno = ""; $igrlineno = "";
$igrD = $this->inwardgateregister_model->addigrD($igrDetails); if (strlen($QuantityAsPerInvoice) > 0 && $QuantityAsPerInvoice != '0' && ((int)$IsThisOpenOrderPO != 1)){
$igrlineno = !empty($igrD) ? $igrD : ''; $igrD = $this->inwardgateregister_model->addigrD($igrDetails);
$igrlineno = !empty($igrD) ? $igrD : '';
}else if((int)$IsThisOpenOrderPO == 1){
$igrD = $this->inwardgateregister_model->addigrD($igrDetails);
$igrlineno = !empty($igrD) ? $igrD : '';
}
if($igrlineno){
$itemvalue = '';
$SupplierId = '';
$itemvalue = ''; $polineitemvalue = $this->inwardgateregister_model->getitemvalue($PONO, $MaterialCode);
$SupplierId = ''; foreach ($polineitemvalue as $it) {
$polineitemvalue = $this->inwardgateregister_model->getitemvalue($PONO, $MaterialCode); $itemvalue = $it->Rate;
foreach ($polineitemvalue as $it) { $SupplierId = $it->SupplierID;
$itemvalue = $it->Rate; }
$SupplierId = $it->SupplierID; $historydetails = array('MaterialCode' => $MaterialCode, 'Transaction_type' => "Add", 'Ref_Type' => "IGR", 'Ref_No' => $igrlineno, 'Quantity' => $QuantityAsPerInvoice, 'CreatedBy' => $CreatedBy, 'CreatedOn' => $createddt, 'SupplierID' => $SupplierId, 'ItemValue' => $itemvalue);
} $this->inwardgateregister_model->addmaterialhistory($historydetails);
$historydetails = array('MaterialCode' => $MaterialCode, 'Transaction_type' => "Add", 'Ref_Type' => "IGR", 'Ref_No' => $igrlineno, 'Quantity' => $QuantityAsPerInvoice, 'CreatedBy' => $CreatedBy, 'CreatedOn' => $createddt, 'SupplierID' => $SupplierId, 'ItemValue' => $itemvalue); if($GrossWeight){
$this->inwardgateregister_model->addmaterialhistory($historydetails); $igr_history = array('field' => 'GrossWeight','is_add' => 1,'new_data' => $GrossWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno);
if($GrossWeight){ $history_id = $this->inwardgateregister_model->igr_history($igr_history);
$igr_history = array('field' => 'GrossWeight','is_add' => 1,'new_data' => $GrossWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno); log_message('error', "History updated successfully. History id: " . $history_id);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id); }
if($TareWeight){
} $igr_history = array('field' => 'TareWeight','is_add' => 1,'new_data' => $TareWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno);
if($TareWeight){ $history_id = $this->inwardgateregister_model->igr_history($igr_history);
$igr_history = array('field' => 'TareWeight','is_add' => 1,'new_data' => $TareWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno); log_message('error', "History updated successfully. History id: " . $history_id);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id); }
if($NetWeight){
} $igr_history = array('field' => 'NetWeight','is_add' => 1,'new_data' => $NetWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno);
if($NetWeight){ $history_id = $this->inwardgateregister_model->igr_history($igr_history);
$igr_history = array('field' => 'NetWeight','is_add' => 1,'new_data' => $NetWeight,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno); log_message('error', "History updated successfully. History id: " . $history_id);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id); }
if($GrossWeightDate){
} $igr_history = array('field' => 'GrossWeightDate','is_add' => 1,'new_data' => $GrossWeightDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno);
if($GrossWeightDate){ $history_id = $this->inwardgateregister_model->igr_history($igr_history);
$igr_history = array('field' => 'GrossWeightDate','is_add' => 1,'new_data' => $GrossWeightDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno); log_message('error', "History updated successfully. History id: " . $history_id);
$history_id = $this->inwardgateregister_model->igr_history($igr_history);
log_message('error', "History updated successfully. History id: " . $history_id); }
if($TareWeightDate){
} $igr_history = array('field' => 'TareWeightDate','is_add' => 1,'new_data' => $TareWeightDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno);
if($TareWeightDate){ $history_id = $this->inwardgateregister_model->igr_history($igr_history);
$igr_history = array('field' => 'TareWeightDate','is_add' => 1,'new_data' => $TareWeightDate,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno); log_message('error', "History updated successfully. History id: " . $history_id);
$history_id = $this->inwardgateregister_model->igr_history($igr_history); }
log_message('error', "History updated successfully. History id: " . $history_id); if($QuantityAsPerInvoice){
} $igr_history = array('field' => 'QuantityAsPerInvoice','is_add' => 1,'new_data' => $QuantityAsPerInvoice,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno);
if($QuantityAsPerInvoice){ $history_id = $this->inwardgateregister_model->igr_history($igr_history);
$igr_history = array('field' => 'QuantityAsPerInvoice','is_add' => 1,'new_data' => $QuantityAsPerInvoice,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno); log_message('error', "History updated successfully. History id: " . $history_id);
$history_id = $this->inwardgateregister_model->igr_history($igr_history); }
log_message('error', "History updated successfully. History id: " . $history_id); if($Remarks){
} $igr_history = array('field' => 'Remarks','is_add' => 1,'new_data' => $Remarks,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno);
if($Remarks){ $history_id = $this->inwardgateregister_model->igr_history($igr_history);
$igr_history = array('field' => 'Remarks','is_add' => 1,'new_data' => $Remarks,'old_data' => NULL,'history_dated' => get_current_date_time(),'by' => $this->session->get('userId'),'IGR_No' => $IGRNO,'IGRItem_No'=>$igrlineno); log_message('error', "History updated successfully. History id: " . $history_id);
$history_id = $this->inwardgateregister_model->igr_history($igr_history); }
log_message('error', "History updated successfully. History id: " . $history_id); $get_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode);
} $av_qty = 0; //$av_qty means Avaliable Quantity
$get_pre_qty = $this->inwardgateregister_model->get_CurrentQty($MaterialCode); if (!empty($get_pre_qty)) {
$av_qty = 0; //$av_qty means Avaliable Quantity foreach ($get_pre_qty as $gt) {
if (!empty($get_pre_qty)) { $av_qty = $gt->Current_stock;
foreach ($get_pre_qty as $gt) { }
$av_qty = $gt->Current_stock; }
$currentav_qty = (int)$QuantityAsPerInvoice + (int)$av_qty;
$current_qty = array('Current_stock' => $currentav_qty);
$this->inwardgateregister_model->addmaterialmaster($current_qty, $MaterialCode);
$Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO, $MaterialCode);
$ReceivedQuantity = 0.00;
if (count($Recqty) > 0) {
foreach ($Recqty as $key) {
$ReceivedQuantity = $key->ReceivedQuantity;
}
}
$totalReceivedqty = (int)$IsThisOpenOrderPO == 1 ? 0 : (int)$ReceivedQuantity + (int)$QuantityAsPerInvoice ;
// $totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice;
if(((int)$totalReceivedqty > 0) && ((int)$IsThisOpenOrderPO != 1)){
$POLineItem = array('ReceivedQuantity' => $totalReceivedqty, 'Status' => $ItemStatus, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt);
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem, $PONO, $MaterialCode);
}else if((int)$IsThisOpenOrderPO == 1){
$POLineItem = array('ReceivedQuantity' => $totalReceivedqty, 'Status' => $ItemStatus, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt);
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem, $PONO, $MaterialCode);
} }
} }
$currentav_qty = $QuantityAsPerInvoice + $av_qty;
$current_qty = array('Current_stock' => $currentav_qty);
$this->inwardgateregister_model->addmaterialmaster($current_qty, $MaterialCode);
$Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO, $MaterialCode);
$ReceivedQuantity = 0.00;
if (count($Recqty) > 0) {
foreach ($Recqty as $key) {
$ReceivedQuantity = $key->ReceivedQuantity;
}
}
$totalReceivedqty = (int)$IsThisOpenOrderPO == 1 ? 0 : $ReceivedQuantity + $QuantityAsPerInvoice ;
// $totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice;
$POLineItem = array('ReceivedQuantity' => $totalReceivedqty, 'Status' => $ItemStatus, 'UpdateBY' => $CreatedBy, 'UpdatedOn' => $createddt);
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem, $PONO, $MaterialCode);
} }
$this->inwardgateregister_model->UpdatePOMaster($PONO, $CreatedBy,$IGRStatus); $this->inwardgateregister_model->UpdatePOMaster($PONO, $CreatedBy,$IGRStatus);
@ -710,11 +723,12 @@ function viewIGRDetails()
if ($file->isValid() && !$file->hasMoved()) { if ($file->isValid() && !$file->hasMoved()) {
// Move the file to the desired directory // Move the file to the desired directory
$finallyfilename = (!empty($fileNames[$index])) ? $fileNames[$index] : $file->getName();
$newName = $file->getRandomName(); $newName = $file->getRandomName();
$file->move($path, $newName); $file->move($path, $newName);
// Store the file information in the database // Store the file information in the database
$additionalFiles = array( $additionalFiles = array(
'Remarks' => $fileNames[$index], 'Remarks' => $finallyfilename,
'FilePath' => $newName, 'FilePath' => $newName,
'IGRNO' => $IGRNo, 'IGRNO' => $IGRNo,
'PONO' => $PONo 'PONO' => $PONo
@ -722,7 +736,7 @@ function viewIGRDetails()
$lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles); $lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles);
if ($lastInsertFileId) { if ($lastInsertFileId) {
$fileupdated_count++; $fileupdated_count++;
$fileupdated_name[] = $fileNames[$index]; $fileupdated_name[] = $finallyfilename;
} }
} }
} }

View File

@ -700,6 +700,7 @@ console.log(parsedData);
if (item.MasterFile !== null && item.MasterFile !== undefined && item.MasterFile.trim() !== "") { if (item.MasterFile !== null && item.MasterFile !== undefined && item.MasterFile.trim() !== "") {
modal.find('#MasterFileLabel a').attr('href', '<?php echo base_url() ?>' + 'public/uploads/Igrfiles/' + item.MasterFile); modal.find('#MasterFileLabel a').attr('href', '<?php echo base_url() ?>' + 'public/uploads/Igrfiles/' + item.MasterFile);
modal.find('#MasterFileLabel a').attr('title', 'previously uploaded IGR Master File'); modal.find('#MasterFileLabel a').attr('title', 'previously uploaded IGR Master File');
modal.find('#MasterFileLabel a').attr('target', '_blank');
modal.find('#MasterFileLabel a span').text('previously uploaded - '); modal.find('#MasterFileLabel a span').text('previously uploaded - ');
modal.find('#MasterFileLabel a small').text(item.MasterFile); modal.find('#MasterFileLabel a small').text(item.MasterFile);
modal.find('#MasterFileLabel').show(); modal.find('#MasterFileLabel').show();
@ -1283,6 +1284,7 @@ function deleteBill(Billno,i){
if (fileName !== 'null' && fileName !== undefined && fileName.trim() !== "") { if (fileName !== 'null' && fileName !== undefined && fileName.trim() !== "") {
modal.find('#WeightFileLabel a').attr('title', 'previously uploaded IGR Weight File'); modal.find('#WeightFileLabel a').attr('title', 'previously uploaded IGR Weight File');
modal.find('#WeightFileLabel a').attr('href', '<?php echo base_url() ?>'+'public/uploads/Igrfiles/'+fileName); modal.find('#WeightFileLabel a').attr('href', '<?php echo base_url() ?>'+'public/uploads/Igrfiles/'+fileName);
modal.find('#WeightFileLabel a').attr('target', '_blank');
modal.find('#WeightFileLabel a span').text('previously uploaded - '); modal.find('#WeightFileLabel a span').text('previously uploaded - ');
modal.find('#WeightFileLabel a small').text(fileName); modal.find('#WeightFileLabel a small').text(fileName);
modal.find('#WeightFileLabel').show(); modal.find('#WeightFileLabel').show();