diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php index 0d2cce20..75d00545 100755 --- a/app/Controllers/Purchaseorder.php +++ b/app/Controllers/Purchaseorder.php @@ -1330,6 +1330,7 @@ class Purchaseorder extends BaseController } //echo "OUT"; + // print_r($this->request->getPost());die; for ($i = 1; $i <= $RowCount; $i++) { //echo "IN"; $MaterialCode = $this->request->getPost('materialCode' . $i); @@ -1444,7 +1445,20 @@ class Purchaseorder extends BaseController if ($SkipInsert == "False") { if (strlen((string)$POLineItemNo) == 0) { + $this->requistion_model = new requistion_model(); + $RetItemNo = $this->requistion_model->getItemNumber($Reqnumber, $MaterialCode); + + $ItemNo = ''; + if (count($RetItemNo) > 0) { + $ItemNo = $RetItemNo[0]['ItemNo']; + } + $POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'ReceivedQuantity' => $recqty, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $updatedBy, 'CreatedDate' => $updateddt, 'CostCenterCode' => $CostCenter); + + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + if (count($POLineItem) > 0) { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } } else { $LineItemNo = $POLineItemNo; @@ -1453,13 +1467,63 @@ class Purchaseorder extends BaseController $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO, $POLineItemNo, $POLineItemList); } - - $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); - - if (is_array($isExists) && count($isExists) == 0) { + $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); + + // Ensure $isExists is an array, or initialize it as an empty array + if (!is_array($isExists)) { + $isExists = []; + } + + if (count($isExists) == 0) { + $RevenueTaxList = array( + 'LineItemNo' => $LineItemNo, + 'DiscountType' => $DiscountType, + 'DiscountValue' => $DiscountValue, + 'AfterDiscount' => $AfterDiscount, + 'PackagingType' => $PackagingType, + 'PackagingValue' => $PackagingValue, + 'PackagingCalulatedOn' => $PackagingOption, + 'AfterPackagingValue' => $AfterPackagingValue, + 'FreightType' => $FreightType, + 'FreightValue' => $FreightValue, + 'AfterFreightValue' => $AfterFreightValue, + 'Insurance' => $InsuranceValue, + 'TotalValue' => $TotalOrderValue, + 'CGST' => $Cgst, + 'AfterCGST' => $AfterCgst, + 'SGST' => $Sgst, + 'AfterSGST' => $AfterSgst, + 'IGST' => $Igst, + 'AfterIGST' => $AfterIgst, + 'NoOfTrip' => $NOOfTrip + ); + $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); } else { - $RevenueTaxList = array('DiscountType' => $DiscountType, 'DiscountValue' => $DiscountValue, 'AfterDiscount' => $AfterDiscount, 'PackagingType' => $PackagingType, 'PackagingValue' => $PackagingValue, 'PackagingCalulatedOn' => $PackagingOption, 'AfterPackagingValue' => $AfterPackagingValue, 'FreightType' => $FreightType, 'FreightValue' => $FreightValue, 'AfterFreightValue' => $AfterFreightValue, 'Insurance' => $InsuranceValue, 'TotalValue' => $TotalOrderValue, 'UpdateBY' => $updatedBy, 'UpdatedOn' => $updateddt, 'CGST' => $Cgst, 'AfterCGST' => $AfterCgst, 'SGST' => $Sgst, 'AfterSGST' => $AfterSgst, 'IGST' => $Igst, 'AfterIGST' => $AfterIgst, 'CreatedBy' => $updatedBy, 'NoOfTrip' => $NOOfTrip); + $RevenueTaxList = array( + 'DiscountType' => $DiscountType, + 'DiscountValue' => $DiscountValue, + 'AfterDiscount' => $AfterDiscount, + 'PackagingType' => $PackagingType, + 'PackagingValue' => $PackagingValue, + 'PackagingCalulatedOn' => $PackagingOption, + 'AfterPackagingValue' => $AfterPackagingValue, + 'FreightType' => $FreightType, + 'FreightValue' => $FreightValue, + 'AfterFreightValue' => $AfterFreightValue, + 'Insurance' => $InsuranceValue, + 'TotalValue' => $TotalOrderValue, + 'UpdateBY' => $updatedBy, + 'UpdatedOn' => $updateddt, + 'CGST' => $Cgst, + 'AfterCGST' => $AfterCgst, + 'SGST' => $Sgst, + 'AfterSGST' => $AfterSgst, + 'IGST' => $Igst, + 'AfterIGST' => $AfterIgst, + 'CreatedBy' => $updatedBy, + 'NoOfTrip' => $NOOfTrip + ); $this->purchaseorder_model->updateRevenueTax($LineItemNo, $RevenueTaxList); } } @@ -2366,7 +2430,10 @@ class Purchaseorder extends BaseController // print_r($isExists); // die(); - if (is_array($isExists) && count($isExists) == 0) { + if (!is_array($isExists)) { + $isExists = []; + } + if (count($isExists) == 0) { // print_r(count($isExists)); // echo $isExists; // die(); @@ -2751,8 +2818,6 @@ class Purchaseorder extends BaseController /*Edit Capital po*/ function EditCapitalPurchaseOrder() { - - $PONO = $this->request->getPost('txtPONO'); $POdt = $this->request->getPost('PODate'); $PODate = get_date_time_format($POdt); @@ -2879,7 +2944,6 @@ class Purchaseorder extends BaseController } } } - $POMaster = $this->purchaseorder_model->updatePOMaster($PONO, $POList); $LineItemStatus = REQITEM_NEW; @@ -2901,7 +2965,7 @@ class Purchaseorder extends BaseController $this->purchaseorder_model->insertlogpo($logpo); } } - + // print_r($this->request->getPost());die; for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->request->getPost('materialCode' . $i); @@ -3056,7 +3120,7 @@ class Purchaseorder extends BaseController - + // print_r(strlen((string)$POLineItemNo));die; if ($SkipInsert == "False") { @@ -3064,6 +3128,11 @@ class Purchaseorder extends BaseController $POLineItemList = array('PONO' => $PONO, 'ReqNo' => $Reqnumber, 'MaterialCode' => $MaterialCode, 'Quantity' => $Quantity, 'Rate' => $itemRate, 'Status' => $LineItemStatus, 'CreatedBy' => $CreateBy, 'CreatedDate' => $createddt, 'CostCenterCode' => $CostCenter, 'ServiceMaterialDescription' => $CapitalItemDescription, 'Per' => $Per); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + // if($i != 1){ + // print_r(value:$POLineItem); + // die; + // } + $LineItemNo = ''; if (count($POLineItem) > 0) { diff --git a/app/Views/capitalpurchaseorder.php b/app/Views/capitalpurchaseorder.php index 75fb008c..95915c00 100755 --- a/app/Views/capitalpurchaseorder.php +++ b/app/Views/capitalpurchaseorder.php @@ -3306,26 +3306,26 @@ // })); var rowHtml = ` -