From 34cbd1536ce28b0ea4b9fb65e2b06911819dbdc0 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Fri, 22 Jun 2018 11:24:04 +0530 Subject: [PATCH] code merged --- .../controllers/emergencypurchaseorder.php | 1115 +-- application/controllers/purchaseorder.php | 1300 ++-- .../controllers/servicepurchaseorder.php | 306 +- application/models/purchaseorder_model.php | 3360 +++++---- .../views/EditservicePurchaseorder.php | 751 +- application/views/alterpurchaseorder.php | 6326 ++++++++--------- application/views/editCapitalPo.php | 21 +- .../views/editRevenuepurchaseorder.php | 105 +- application/views/editimportpo.php | 16 +- application/views/editrequisitionform.php | 2 +- application/views/purchaseorder.php | 306 +- application/views/requisitionform.php | 2 +- 12 files changed, 6810 insertions(+), 6800 deletions(-) diff --git a/application/controllers/emergencypurchaseorder.php b/application/controllers/emergencypurchaseorder.php index a7a0fbf7..31a9b59a 100644 --- a/application/controllers/emergencypurchaseorder.php +++ b/application/controllers/emergencypurchaseorder.php @@ -42,11 +42,10 @@ class emergencypurchaseorder extends BaseController $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq(); $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq(); $data['ReqList'] = $this->purchaseorder_model->getRequistionListbySearch(); - //$this->global['pageTitle'] = 'Resico : Create PO from Requisition List'; $this->global['pageTitle'] = $this->CompanyName.' : Create Purchase Order from Requistion'; $this->loadViews("createPOfromRequistion", $this->global, $data,Null); } - + /** * To create new emergency po */ @@ -60,7 +59,7 @@ class emergencypurchaseorder extends BaseController $data['RequestType'] = $this->requistion_model->getConfigValue('C004'); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['INRSYMBOL']=$this->purchaseorder_model->GetINRCurrencytype('INR'); - $data['DeptList'] = $this->purchaseorder_model->getDepartmentAllList(); + $data['DeptList'] = $this->purchaseorder_model->getDepartmentAllList(); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); @@ -70,9 +69,7 @@ class emergencypurchaseorder extends BaseController $data['ServiceOption'] = $this->requistion_model->getConfigValue('C022'); $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); - - - $this->loadViews("alterpurchaseorder", $this->global, $data, Null); + $this->loadViews("alterpurchaseorder", $this->global, $data, Null); } @@ -101,480 +98,500 @@ class emergencypurchaseorder extends BaseController /** * To add file for inward po */ - function addfile() - { + function addfile($pathname) + { - $file = ''; - //Check whether user upload picture - if(!empty($_FILES['images']['name'])) + $picture = ''; + if(!empty($_FILES[$pathname]['name'])) + { + + $config['upload_path'] = 'uploads/BillFiles/'; + $config['allowed_types'] = '*'; + $config['file_name'] = str_replace(" ","",$_FILES[$pathname]['name']); + //Load upload library and initialize configuration + $this->load->library('upload',$config); + $this->upload->initialize($config); + if($this->upload->do_upload($pathname)) { - - $config['upload_path'] = 'uploads/BillFiles/'; - $config['allowed_types'] = 'docx|pdf|doc|png|jpg'; - $config['file_name'] = $_FILES['images']['name']; - - //Load upload library and initialize configuration - $this->load->library('upload',$config); - $this->upload->initialize($config); - - if($this->upload->do_upload('images')) - { - $uploadData = $this->upload->data(); - $file = $uploadData['file_name']; - } - else - { - $error = array('error' => $this->upload->display_errors()); - $file = ''; - } + // echo "uploadif"; + $uploadData = $this->upload->data(); + $picture = $uploadData['file_name']; } else { - - $file = ''; + $error = array('error' => $this->upload->display_errors()); + $picture = ''; } - - return $file ; + } + else + { + $picture = ''; + } + + return $picture ; } - function addfile1() +/*----------------------------------special po file upload service----------------------------------*/ + function add($pathname) { + $picture = ''; + if(!empty($_FILES[$pathname]['name'])) + { - $file = ''; - //Check whether user upload picture - if(!empty($_FILES['images1']['name'])) + $config['upload_path'] = 'uploads/BillFiles/'; + $config['allowed_types'] = '*'; + $config['file_name'] = str_replace(" ","",$_FILES[$pathname]['name']); + + $this->load->library('upload',$config); + $this->upload->initialize($config); + if($this->upload->do_upload($pathname)) { - - $config['upload_path'] = 'uploads/BillFiles/'; - $config['allowed_types'] = 'docx|pdf|doc|png|jpg'; - $config['file_name'] = $_FILES['images1']['name']; - - //Load upload library and initialize configuration - $this->load->library('upload',$config); - $this->upload->initialize($config); - - if($this->upload->do_upload('images1')) - { - $uploadData = $this->upload->data(); - - $file = $uploadData['file_name']; - } - else - { - $error = array('error' => $this->upload->display_errors()); - - $file = ''; - } + $uploadData = $this->upload->data(); + $picture = $uploadData['file_name']; } else - { - - $file = ''; + { + $error = array('error' => $this->upload->display_errors()); + $picture = ''; } - - return $file ; + } + else + { + $picture = ''; + } + return $picture ; } - - - /** * To Create Service Purchase Order */ function addNewServicePurchaseOrder() { - $txtRowCount=$this->input->post('txtRowCount'); - - $POdt =$this->input->post('PODate'); - $PODate = $this->getDateformat($POdt); - $SupplierID = $this->input->post('drpSupplier'); - $DeliveryAddr = $this->input->post('DeliveryAddr'); - - $CostCenterName = $this->input->post('CostCenterName'); - $DeliveryOption = $this->input->post('DateRange'); - $DeliverySchedule=''; - $Deliverydt = $this->getDateformat($POdt); + $txtRowCount=$this->input->post('txtRowCount'); + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('DeliveryAddr'); + $CostCenterName = $this->input->post('CostCenterName'); + $DeliveryOption = $this->input->post('DateRange'); + $DeliverySchedule=''; + $Deliverydt = $this->getDateformat($POdt); - $txtsplservice=$this->input->post('txtSpecialservice'); + $txtsplservice=$this->input->post('txtSpecialservice'); - if($txtsplservice=='1') - { - $POStatus=SPECIAL_PO; - } - else - { - $POStatus=REQITEM_Emergency_PO_CREATED; - } - - $POType = $this->input->post('POType'); - $SpcialInstruction = $this->input->post('ScopeOfWork'); - $RequistionComments = "Created Emergency Service PO"; - - $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummaryService'); - $CreateBy = $this->session->userdata ('userId'); - $RequestedBy = $this->input->post('drpDepartment'); + if($txtsplservice=='1') + { + $POStatus=SPECIAL_PO; + } + else + { + $POStatus=REQITEM_Emergency_PO_CREATED; + } - $ReqStatus = REQITEM_Emergency_PO_CREATED; - - $RowCount = $this->input->post('txtRowCount'); - $DeletedRow = $this->input->post('txtDeletedRow1'); - $comma_separated = explode(':', $DeletedRow); - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $createddt = $dt->format('Y-m-d H:i:s'); - - - $PaymentTerms=$this->input->post('PaymentMethod'); - $OtherPayment=$this->input->post('Otherpayment'); - - - if($POStatus==SPECIAL_PO) - { - $ServiceWorkStatus=SERVICE_COMPLETED; - } - else - { - $ServiceWorkStatus=$this->input->post('txtworkstatus'); - } - - $ServiceScheduleType = $this->input->post('ScheduleType'); - $ServiceScheduleOptions = $this->input->post('ScheduleType'); - $ServiceServiceNo = 1; - $ModeOfShipment=$this->input->post('emergmodeofshipment'); - $SupplierReference=$this->input->post('emergsupplierreference'); - $SuppliersOfferNo=$this->input->post('emergsupplierofferno'); - $OtherReferences=$this->input->post('emergotherreference'); - $Fincap=$this->input->post('emergfincap'); - $InsuranceOptions=$this->input->post('insuranceStatus'); - $InsuranceNo=$this->input->post('insuranceNo'); - $ServiceTypeOptions=$this->input->post('PoTypeOptions'); - $DescriptionOfPo = $this->input->post('emergdescofpo'); - - - $Request = array('ReqType'=>$POType, 'RequestedDept'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$RequistionComments,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'Schedule_Type'=>$ServiceScheduleType,'NumberOfService'=>$ServiceServiceNo,'Service_Period'=>$ServiceScheduleOptions); - - $Req = $this->requistion_model->addRequistion($Request); - - $RegNo=''; - if(count($Req)>0) - { - $RegNo = $Req[0]['ReqNo']; - } - - // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$ServiceWorkStatus,'POType'=>$POType,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'Description_Of_Service'=>$DescriptionOfPo,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions); - - $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$ServiceTypeOptions); - $PONO = ''; - if(count($POMaster)>0) - { - $PONO = $POMaster[0]['PONO']; - } - - $RegDetailsStatus=REQITEM_POCREATED; - - // PO Line Items - $LineItemStatus = REQITEM_NEW; - - for ($i = 1; $i <= $RowCount; $i++) - { - $Per = $this->input->post('Serviceper'.$i); - $MaterialCode = $this->input->post('materialCode'.$i); - $Quantity = $this->input->post('quantity'.$i); - $Reqnumber = $this->input->post('Reqnumber'.$i); - $itemRate = $this->input->post('itemRate'.$i); - $Cgst = $this->input->post('Cgst'.$i); - $Sgst = $this->input->post('Sgst'.$i); - $Igst = $this->input->post('Igst'.$i); - $AfterCgst = $this->input->post('AfterCgst'.$i); - $AfterSgst = $this->input->post('AfterSgst'.$i); - $AfterIgst = $this->input->post('AfterIgst'.$i); - $OtherAmt = $this->input->post('OtherAmt'.$i); - $CostCenter = $this->input->post('costCode'.$i); - - $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); - $ServiceFrequency=$this->input->post('Frequency'.$i).' - '.$this->input->post('FrequencyValue'.$i); - $ServiceMaterialDescription = $this->input->post('ItemServiceDescription'.$i); - $SkipInsert = "False"; - if( count($comma_separated) > 0) - { - for($j = 1; $j < count($comma_separated); $j++) - { - $deletedRow = $comma_separated[$j]; - - if($deletedRow == $i ) - { - $SkipInsert = "True"; - break; - } - } - } - if($SkipInsert == "False") - { - - //add requistion details - $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt); - $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails,$RegNo); - $ItemNo = ''; - if(count($ReqDetQuery)>0) - { - $ItemNo = $ReqDetQuery[0]['ItemNo']; - } - - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceMaterialDescription'=>$ServiceMaterialDescription,'ServiceFrequency'=>$ServiceFrequency,'Per'=>$Per,'ItemNo'=>$ItemNo); - $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - $LineItemNo = ''; - if(count($POLineItem)>0) - { - $LineItemNo = $POLineItem[0]['LineItemNo']; - } - if(trim($POType) == SERVICE ) - { - $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'otherallowance'=>$OtherAmt,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); - $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); - } - } - else {} - - if($POStatus==SPECIAL_PO){ - - $file =$this->addfile1(); - $myfile = array('FilePath'=>$file,'MaterialCode'=>$MaterialCode,'PONO'=>$PONO); - $result= $this->purchaseorder_model->fileupload($myfile); - } - } - if($POStatus == REQ_DRAFT) - { - echo ""; - redirect('purchaseorder/PurchaseOrderList','refresh'); - - } - else - { - echo ""; - redirect('purchaseorder/PurchaseOrderList','refresh'); - - } - + $POType = $this->input->post('POType'); + $SpcialInstruction = $this->input->post('ScopeOfWork'); + $RequistionComments = "Created Emergency Service PO"; + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummaryService'); + $CreateBy = $this->session->userdata ('userId'); + $RequestedBy = $this->input->post('drpDepartment'); + $ReqStatus = REQITEM_Emergency_PO_CREATED; + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow1'); + $comma_separated = explode(':', $DeletedRow); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $BudgetType = $this->input->post('Budget'); + $createddt = $dt->format('Y-m-d H:i:s'); + $PaymentTerms=$this->input->post('PaymentMethod'); + $OtherPayment=$this->input->post('Otherpayment'); + if($POStatus==SPECIAL_PO) + { + $ServiceWorkStatus=SERVICE_COMPLETED; } + else + { + $ServiceWorkStatus=$this->input->post('txtworkstatus'); + } + $ServiceScheduleType = $this->input->post('ScheduleType'); + $ServiceScheduleOptions = $this->input->post('ScheduleType'); + $ServiceServiceNo = 1; + $ModeOfShipment=$this->input->post('emergmodeofshipment'); + $SupplierReference=$this->input->post('emergsupplierreference'); + $SuppliersOfferNo=$this->input->post('emergsupplierofferno'); + $OtherReferences=$this->input->post('emergotherreference'); + $Fincap=$this->input->post('emergfincap'); + $InsuranceOptions=$this->input->post('insuranceStatus'); + $InsuranceNo=$this->input->post('insuranceNo'); + $ServiceTypeOptions=$this->input->post('PoTypeOptions'); + $DescriptionOfPo = $this->input->post('emergdescofpo'); + + //create T_Requestion_Master + $Request = array('ReqType'=>$POType, 'RequestedDept'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$RequistionComments,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy,'Schedule_Type'=>$ServiceScheduleType,'NumberOfService'=>$ServiceServiceNo,'Service_Period'=>$ServiceScheduleOptions); + + $Req = $this->requistion_model->addRequistion($Request); + + $RegNo=''; + if(count($Req)>0) + { + $RegNo = $Req[0]['ReqNo']; + } + + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$ServiceWorkStatus,'POType'=>$POType,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'Description_Of_Service'=>$DescriptionOfPo,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'BudgetType'=>$BudgetType); + $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$ServiceTypeOptions); + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + $RegDetailsStatus=REQITEM_POCREATED; + + // PO Line Items + $LineItemStatus = REQITEM_NEW; + + for ($i = 1; $i <= $RowCount; $i++) + { + $Per = $this->input->post('Serviceper'.$i); + $MaterialCode = $this->input->post('materialCode'.$i); + $Quantity = $this->input->post('quantity'.$i); + $Reqnumber = $this->input->post('Reqnumber'.$i); + $itemRate = $this->input->post('itemRate'.$i); + $Cgst = $this->input->post('Cgst'.$i); + $Sgst = $this->input->post('Sgst'.$i); + $Igst = $this->input->post('Igst'.$i); + $AfterCgst = $this->input->post('AfterCgst'.$i); + $AfterSgst = $this->input->post('AfterSgst'.$i); + $AfterIgst = $this->input->post('AfterIgst'.$i); + $OtherAmt = $this->input->post('OtherAmt'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); + $ServiceFrequency=$this->input->post('Frequency'.$i).' - '.$this->input->post('FrequencyValue'.$i); + $ServiceMaterialDescription = $this->input->post('ItemServiceDescription'.$i); + $SkipInsert = "False"; + if( count($comma_separated) > 0) + { + for($j = 1; $j < count($comma_separated); $j++) + { + $deletedRow = $comma_separated[$j]; + + if($deletedRow == $i ) + { + $SkipInsert = "True"; + break; + } + } + } + if($SkipInsert == "False") + { + + //add requistion details + $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt); + $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails,$RegNo); + $ItemNo = ''; + if(count($ReqDetQuery)>0) + { + $ItemNo = $ReqDetQuery[0]['ItemNo']; + } + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceMaterialDescription'=>$ServiceMaterialDescription,'ServiceFrequency'=>$ServiceFrequency,'Per'=>$Per,'ItemNo'=>$ItemNo); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + if(trim($POType) == SERVICE ) + { + $ServiceTaxList = array('LineItemNo'=>$LineItemNo, 'CGST'=>$Cgst,'After_CGST'=>$AfterCgst,'SGST'=>$Sgst,'After_SGST'=>$AfterSgst,'IGST'=>$Igst,'After_IGST'=>$AfterIgst,'otherallowance'=>$OtherAmt,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); + $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); + } + } + } + if($POStatus==SPECIAL_PO){ + $count = $this->input->post('hidecounters'); + $constant = $this->input->post('hideconstants'); + $arr = []; + $prefile =array(); + + for($i=1;$i<=$constant;$i++) + { + $pathname = 'browseFiles'.$i; + + if(!empty($_FILES[$pathname]['name'])) + { + + $files = str_replace(" ","",$_FILES[$pathname]['name']); + + $fcount = 0; + + foreach ($prefile as $value) + { + if($value == $files) + { + + + $fcount++; + } + } + if($fcount == 0) + { + $Picture = $this->add($pathname); + $arr[] = array($Picture); + } + + $prefile[] = $files; + + } + } + + if(!empty($arr)) + { + foreach($arr as $ma){ + + $index = 0; + foreach($ma as $key=>$value){ + $index++; + if($index == 1){ + $filename = $value; + } + } + if(!empty($filename)) + { + $myfile = array('FilePath'=>$filename,'PONO'=>$PONO); + $this->purchaseorder_model->fileupload($myfile); + } + } + } + } + if($POStatus == REQ_DRAFT) + { + echo ""; + redirect('purchaseorder/PurchaseOrderList','refresh'); + + } + else + { + echo ""; + redirect('purchaseorder/PurchaseOrderList','refresh'); + } + } /** * To Create Revenue Emergency Purchase Order **/ function addNewRevenuePurchaseOrder() { - - - $txtspl=$this->input->post('txtSpecial'); - $POdt =$this->input->post('PODate'); - $PODate = $this->getDateformat($POdt); - $SupplierID = $this->input->post('drpSupplier'); - $DeliveryAddr = $this->input->post('DeliveryAddr'); - $dt = $this->input->post('Deliverydt'); - $DeliveryOption = $this->input->post('DateRange'); - if($DeliveryOption==1){ - $Deliverydt = ''; - $DeliverySchedule = $this->input->post('Scheduleby'); - } + $txtspl=$this->input->post('txtSpecial'); + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('DeliveryAddr'); + $dt = $this->input->post('Deliverydt'); + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ + $Deliverydt = ''; + $DeliverySchedule = $this->input->post('Scheduleby'); + } else{ - $Deliverydt = $this->getDateformat($dt); - $DeliverySchedule = ''; - } - - $Modeofshipment=$this->input->post('emergmodeofshipment'); - $supplierreference=$this->input->post('emergsupplierreference'); - $supplieroffno=$this->input->post('emergsupplierofferno'); - $otherreference=$this->input->post('emergotherreference'); - $fincap=$this->input->post('emergfincap'); - $revenuetype=$this->input->post('PoTypeOptions'); - $insurancestatus=$this->input->post('insuranceStatus'); - if($insurancestatus == 1){ - $insuranceno=$this->input->post('insuranceNo'); - }else{ - $insuranceno=""; - } - $CostCenterName = $this->input->post('CostCenterName'); - $POType = $this->input->post('POType'); - $PoRange = $this->input->post('txtPoRange'); - - $SpcialInstruction = $this->input->post('txtSpcialInstruction'); - $RequistionComments = "Created Emergency Revenue PO"; - $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); - - if($txtspl==0) - { - $POStatus=REQITEM_Emergency_PO_CREATED; - } - else - { - $POStatus=SPECIAL_PO; - } - - $RequestedBy = $this->input->post('drpDepartment'); - $CreateBy = $this->session->userdata ( 'userId' ); - $RowCount=$this->input->post('txtRowCount1'); - $DeletedRow = $this->input->post('txtDeletedRow1'); - $splRow = $this->input->post('splrow'); - - $ReqStatus = REQITEM_Emergency_PO_CREATED; - $Local_Interstate=$this->input->post('Range'); - - $comma_separated = explode(':', $DeletedRow); - - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $createddt = $dt->format('Y-m-d H:i:s'); - $PaymentTerms=$this->input->post('PaymentMethod'); - $OtherPayment=$this->input->post('Otherpayment'); - - if($POStatus==SPECIAL_PO) - { - $Qualitycheck=$this->input->post('txtQuality'); - } - else - { - $Qualitycheck=1; - } - + $Deliverydt = $this->getDateformat($dt); + $DeliverySchedule = ''; + } + + $Modeofshipment=$this->input->post('emergmodeofshipment'); + $supplierreference=$this->input->post('emergsupplierreference'); + $supplieroffno=$this->input->post('emergsupplierofferno'); + $otherreference=$this->input->post('emergotherreference'); + $fincap=$this->input->post('emergfincap'); + $revenuetype=$this->input->post('PoTypeOptions'); + $insurancestatus=$this->input->post('insuranceStatus'); + + if($insurancestatus == 1){ + $insuranceno=$this->input->post('insuranceNo'); + }else{ + $insuranceno=""; + } + $CostCenterName = $this->input->post('CostCenterName'); + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); - $Request = array('ReqType'=>$POType, 'RequestedDept'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$RequistionComments,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); - - $Req = $this->requistion_model->addRequistion($Request); - - $RegNo=''; - if(count($Req)>0) + $SpcialInstruction = $this->input->post('txtSpcialInstruction'); + $RequistionComments = "Created Emergency Revenue PO"; + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + + if($txtspl==0) + { + $POStatus=REQITEM_Emergency_PO_CREATED; + } + else + { + $POStatus=SPECIAL_PO; + } + + $RequestedBy = $this->input->post('drpDepartment'); + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount=$this->input->post('txtRowCount1'); + $BudgetType = $this->input->post('Budget'); + $DeletedRow = $this->input->post('txtDeletedRow1'); + $splRow = $this->input->post('splrow'); + $ReqStatus = REQITEM_Emergency_PO_CREATED; + $Local_Interstate=$this->input->post('Range'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + $PaymentTerms=$this->input->post('PaymentMethod'); + $OtherPayment=$this->input->post('Otherpayment'); + + if($POStatus==SPECIAL_PO) + { + $Qualitycheck=$this->input->post('txtQuality'); + }else + { + $Qualitycheck=1; + } + //add requistion + $Request = array('ReqType'=>$POType, 'RequestedDept'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$RequistionComments,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); + + $Req = $this->requistion_model->addRequistion($Request); + + $RegNo=''; + if(count($Req)>0) { $RegNo = $Req[0]['ReqNo']; } - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Supplier_Reference'=>$supplierreference,'Other_Reference'=>$otherreference,'InsuranceNumber'=>$insuranceno,'InsuranceStatus'=>$insurancestatus,'Fincap'=>$fincap,'POSubType'=>$revenuetype,'IsQualityChkReqired'=>$Qualitycheck); - - $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$revenuetype); - - $PONO = ''; - if(count($POMaster)>0) - { - $PONO = $POMaster[0]['PONO']; - } - $RegDetailsStatus=REQITEM_POCREATED; - $LineItemStatus = REQITEM_NEW; - - for ($i = 1; $i <= $RowCount; $i++) - { - - $MaterialCode = $this->input->post('materialCode'.$i); - $Quantity = $this->input->post('quantity'.$i); - $Reqnumber = $this->input->post('Reqnumber'.$i); - $itemRate = $this->input->post('itemRate'.$i); - $per = $this->input->post('per'.$i); - - $DiscountType = $this->input->post('DisType'.$i); - $DiscountValue = $this->input->post('DisVal'.$i); - $AfterDiscount = $this->input->post('AfterDisVal'.$i); - $PackagingOption = $this->input->post('PackOption'.$i); - $PackagingType = $this->input->post('PackType'.$i); - $PackagingValue = $this->input->post('PackVal'.$i); - $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); - - $FreightType = $this->input->post('FreightType'.$i); - $FreightValue = $this->input->post('FreightVal'.$i); - $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Supplier_Reference'=>$supplierreference,'Other_Reference'=>$otherreference,'InsuranceNumber'=>$insuranceno,'InsuranceStatus'=>$insurancestatus,'Fincap'=>$fincap,'POSubType'=>$revenuetype,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); + //print_r($POList); + $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$revenuetype); + + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + $RegDetailsStatus=REQITEM_POCREATED; + $LineItemStatus = REQITEM_NEW; + + for ($i = 1; $i <= $RowCount; $i++) + { + + $MaterialCode = $this->input->post('materialCode'.$i); + $Quantity = $this->input->post('quantity'.$i); + $Reqnumber = $this->input->post('Reqnumber'.$i); + $itemRate = $this->input->post('itemRate'.$i); + $per = $this->input->post('per'.$i); + + $DiscountType = $this->input->post('DisType'.$i); + $DiscountValue = $this->input->post('DisVal'.$i); + $AfterDiscount = $this->input->post('AfterDisVal'.$i); + $PackagingOption = $this->input->post('PackOption'.$i); + $PackagingType = $this->input->post('PackType'.$i); + $PackagingValue = $this->input->post('PackVal'.$i); + $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); + + $FreightType = $this->input->post('FreightType'.$i); + $FreightValue = $this->input->post('FreightVal'.$i); + $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $NOOfTrip = $this->input->post('NoOfTrip'.$i); - $InsuranceValue = $this->input->post('Insval'.$i); - $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); - $revenuedescription = $this->input->post('service_description'.$i); - $CostCenter = $this->input->post('costCode'.$i); + $InsuranceValue = $this->input->post('Insval'.$i); + $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); + $revenuedescription = $this->input->post('service_description'.$i); + $CostCenter = $this->input->post('costCode'.$i); $Cgst = $this->input->post('RevenueCgst'.$i); $Sgst = $this->input->post('RevenueSgst'.$i); $Igst = $this->input->post('RevenueIgst'.$i); $AfterCgst = $this->input->post('RevenueAfterCgst'.$i); $AfterSgst = $this->input->post('RevenueAfterSgst'.$i); $AfterIgst = $this->input->post('RevenueAfterIgst'.$i); - $SkipInsert = "False"; - if( count($comma_separated) > 0) - { - for($j = 1; $j < count($comma_separated); $j++) - { - $deletedRow = $comma_separated[$j] ; - - if($deletedRow == $i ) - { - $SkipInsert = "True"; - break; - } - } - } - if($SkipInsert == "False") - { - $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt); - - $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails); - - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription); - - $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - - $LineItemNo = ''; - if(count($POLineItem)>0) - { - $LineItemNo = $POLineItem[0]['LineItemNo']; - } - - - if(trim($POType) == REVENUE ) - { - $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, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt, 'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'NoOfTrip'=>$NOOfTrip); - $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); - - } - } - } - if($txtspl==1 || $txtspl==2) - { + $SkipInsert = "False"; + if( count($comma_separated) > 0) + { + for($j = 1; $j < count($comma_separated); $j++) + { + $deletedRow = $comma_separated[$j] ; + + if($deletedRow == $i ) + { + $SkipInsert = "True"; + break; + } + } + } + if($SkipInsert == "False") + { + //add requistion details + $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt); + + $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails); + + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$RegNo,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription); + //print_r($POLineItemList); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + if(trim($POType) == REVENUE ) + { + // echo 'Success'; + $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, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt, 'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'NoOfTrip'=>$NOOfTrip); + //print_r($RevenueTaxList); + $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); + //echo 'Revenue tax Success'; + } + } + } + if($txtspl==1 || $txtspl==2) + { - $PONOigr = $PONO; + $PONOigr = $PONO; + $DeliveryChellanInvoiceNo=$this->input->post('ChallanInvNo'); + + $DeliveryChellan = $this->input->post('ChallanInvDate'); + $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); + + $MaterialReceive = $this->input->post('MRC'); + $MaterialReceivedate = $this->getDateformat($MaterialReceive); - $DeliveryChellanInvoiceNo=$this->input->post('ChallanInvNo'); - - $DeliveryChellan = $this->input->post('ChallanInvDate'); - $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); - - $MaterialReceive = $this->input->post('MRC'); - $MaterialReceivedate = $this->getDateformat($MaterialReceive); - - $Vehicle = $this->input->post('VehicleNo'); - $Courier = $this->input->post('CourierNo'); - + $Vehicle = $this->input->post('VehicleNo'); + $Courier = $this->input->post('CourierNo'); + - $CreatedBy = $this->session->userdata('userId'); + $CreatedBy = $this->session->userdata('userId'); - $Remarksmrir='Emergency PO without Quality Check'; - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $createddt = $dt->format('Y-m-d H:i:s'); + $Remarksmrir='Emergency PO without Quality Check'; + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); - $IGRStatus = IGR_CREATED; - $igr = array(); + $IGRStatus = IGR_CREATED; + $igr = array(); - $igr = array('PONO'=>$PONO,'VehicleNo'=>$Vehicle,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'CourierNo'=>$Courier,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt,'MaterialRcvdDate'=>$MaterialReceivedate); - $igrM = $this->inwardgateregister_model->addigrM($igr); - $IGRNO = ''; - if(count($igrM)>0) - { - foreach ($igrM as $key ) - { - $IGRNO=$key->IGRNO; - } - } - if($Qualitycheck==0) - { - $mrirmastervalues = array('MRIRStatus'=>MRIR_APPROVED,'IGRNO'=>$IGRNO,'PONO'=>$PONO,'CreatedBy'=>$CreatedBy,'Createdon'=>$createddt,'Remarks'=>$Remarksmrir); - $mrirmaster = $this->mrir_model->master_mrir($mrirmastervalues); + $igr = array('PONO'=>$PONO,'VehicleNo'=>$Vehicle,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$DeliveryChellanDate,'CourierNo'=>$Courier,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt,'MaterialRcvdDate'=>$MaterialReceivedate); + $igrM = $this->inwardgateregister_model->addigrM($igr); + $IGRNO = ''; + if(count($igrM)>0) + { + foreach ($igrM as $key ) + { + $IGRNO=$key->IGRNO; + } + } + if($Qualitycheck==0) + { + $mrirmastervalues = array('MRIRStatus'=>MRIR_APPROVED,'IGRNO'=>$IGRNO,'PONO'=>$PONO,'CreatedBy'=>$CreatedBy,'Createdon'=>$createddt,'Remarks'=>$Remarksmrir); + $mrirmaster = $this->mrir_model->master_mrir($mrirmastervalues); $MRIRNO = ''; - if(count($mrirmaster)>0) { foreach ($mrirmaster as $key ) { - $MRIRNO=$key->MRIRNo; - } + + $MRIRNO=$key->MRIRNo; } } @@ -585,12 +602,11 @@ class emergencypurchaseorder extends BaseController $Remarked = "Special PO Without Quality Check"; - $MRIRStatus=MRIR_APPROVED; + $MRIRStatus=MRIR_APPROVED; //this array to store the value in child table.. $mrirdetailvalues = array('MRIRNO'=>$MRIRNO,'MaterialCode'=>$MaterialCode,'ActualQuantityReceived'=>$Quantity,'Remarks'=>$Remarked,'MRIRStatus'=>$MRIRStatus); $mrirdetails = $this->mrir_model->detail_mrir($mrirdetailvalues); - $getAvailableqty = $this->mrir_model->getItemQuantityFromStock(trim($MaterialCode)); if(count($getAvailableqty)>0) @@ -626,7 +642,7 @@ class emergencypurchaseorder extends BaseController $Remarks = "Special PO Created"; $ItemStatus = ''; - if($PendingQty == 0.00 ) + if($PendingQty == 0.00 ) { $ItemStatus = IGR_CREATED; } @@ -638,8 +654,22 @@ class emergencypurchaseorder extends BaseController $CreatedBy = $this->session->userdata('userId'); - $igrDetails = array('IGRNO'=>$IGRNO,'MaterialCode'=>$MaterialCode,'QuantityAsPerInvoice'=>$QuantityAsPerInvoice,'Remarks'=>$Remarks,'IGRItemStatus'=>$IGRItemStatus,'CreatedBy'=>$CreatedBy,'CreatedDate'=>$createddt); + $igrDetails = array('IGRNO'=>$IGRNO,'MaterialCode'=>$MaterialCode,'QuantityAsPerInvoice'=>$QuantityAsPerInvoice,'Remarks'=>$Remarks,'IGRItemStatus'=>$IGRItemStatus,'CreatedBy'=>$CreatedBy,'CreatedDate'=>$createddt); $igrD = $this->inwardgateregister_model->addigrD($igrDetails); + + + $IGRItemNo = ''; + foreach($igrD as $value) + { + + $IGRItemNo = $value->IGRItemNo; + } + + + $MaterialstockHistoryadd= array('Ref_No'=>$IGRItemNo,'MaterialCode'=>$MaterialCode,'Transaction_type'=>'Add','Ref_Type'=>'IGR','SupplierID'=>$SupplierID,'Quantity'=>$QuantityAsPerInvoice,'ItemValue'=>$itemRate,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt); + + + $this->inwardgateregister_model->addMaterialStockHistory($MaterialstockHistoryadd); $Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO,$MaterialCode); $ReceivedQuantity = 0.00; @@ -650,24 +680,94 @@ class emergencypurchaseorder extends BaseController } } $totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice; - + $POLineItem = array('ReceivedQuantity'=>$totalReceivedqty,'Status'=>$ItemStatus,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt ); $this->inwardgateregister_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode); } - - } +} + + $counts = $this->input->post('hidecounter'); + $constants = $this->input->post('hideconstant'); - $file =$this->addfile(); - $emergencyitemcode = $this->input->post('materialCode'.$i); - $myfile = array('FilePath'=>$file,'MaterialCode'=>$emergencyitemcode,'PONO'=>$PONO,'IGRNO'=>$IGRNO); - $result= $this->purchaseorder_model->fileupload($myfile); + $arr = []; +$prefile =array(); + + for($i=1;$i<=$constants;$i++) + { + $pathname = 'browseFiles'.$i; + + if(!empty($_FILES[$pathname]['name'])) + { + + $files = str_replace(" ","",$_FILES[$pathname]['name']); + + $fcount = 0; + + foreach ($prefile as $value) + { + + + if($value == $files) + { + + + $fcount++; + } + + + + + } + + if($fcount == 0) + { + $Picture = $this->addfile($pathname); + //echo $Picture; + $arr[] = array($Picture); + + } + + $prefile[] = $files; + + } } - echo ""; - redirect('purchaseorder/PurchaseOrderList','refresh'); - - } + if(!empty($arr)) + { + foreach($arr as $ma) + { + + + $index = 0; + $filename = null; + foreach($ma as $key=>$value) + { + $index++; + if($index == 1){ + $filename = $value; + } + } + if(!empty($filename)) + { + + $myfile = array('FilePath'=>$filename,'PONO'=>$PONO,'IGRNO'=>$IGRNO); + $this->purchaseorder_model->fileupload($myfile); + } + + + } + + + } + + + +} + echo ""; + redirect('purchaseorder/PurchaseOrderList','refresh'); + + } /** * To load the purchaseorder list */ @@ -711,7 +811,6 @@ class emergencypurchaseorder extends BaseController function CreatePurchaseOrder() { - $this->load->library('form_validation'); $this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate'); @@ -796,37 +895,31 @@ class emergencypurchaseorder extends BaseController $data['ReqList'] = $Req ; $result = array(); $ReqArray = array(); - foreach ($Req as $SID): - $ReqArray[] = $SID->ReqNo ; + $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; - - $data['MaterialList'] = $result; + $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO); $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); - if($ReqType == SERVICE) { $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); - //$this->global['pageTitle'] = 'Resico : Edit Service Purchase order form'; - $this->global['pageTitle'] = $this->CompanyName.' : Edit Service Purchase Order '; + $this->global['pageTitle'] = $this->CompanyName.' : Edit Service Purchase order form'; $this->loadViews("EditservicePurchaseorder", $this->global, $data, NULL); } else if($ReqType == REVENUE) { $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); - //$this->global['pageTitle'] = 'Resico : Edit Revenue Purchase order form'; - $this->global['pageTitle'] = $this->CompanyName.' : Edit Revenue Purchase Order'; + $this->global['pageTitle'] = $this->CompanyName.' : Edit Revenue Purchase order form'; $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); } } - /** * To get the Material value based on the MaterialCode **/ @@ -836,7 +929,7 @@ class emergencypurchaseorder extends BaseController $DeptCode = $SearchFilter[0]; $MatType = $SearchFilter[1]; $ReqNo = $SearchFilter[2]; - + $CostList = $this->requistion_model->GetCostCenterByDept( $DeptCode); $HTML = ""; @@ -865,7 +958,7 @@ class emergencypurchaseorder extends BaseController } } - + die(json_encode(array('MatDetail' =>$HTML1,'Cost'=> $HTML))); } @@ -897,17 +990,14 @@ class emergencypurchaseorder extends BaseController function AvilBudgetAmount() { $SearchFilter= $this->input->post('id'); - $CostCode = $SearchFilter[0]; $ReqType = $SearchFilter[1]; print_r($SearchFilter); $CostCode= $this->input->post('id'); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $Year = $dt->format('Y'); $this->load->model('purchaseorder_model'); $result = $this->purchaseorder_model->GetAvailableBudgetAmount($CostCode,$Year,$ReqType); - $AvilBudAmt = ''; if(count($result)>0) { @@ -939,9 +1029,9 @@ class emergencypurchaseorder extends BaseController $rng = $SearchFilter[2]; $FromDate =''; $ToDate = ''; - + $Dt = explode("-",$rng); - + if(count( $Dt)>1) { $FDate = $Dt[0]; @@ -964,15 +1054,15 @@ class emergencypurchaseorder extends BaseController $Designation = $result[$i]['Designation']; $HTML.=" - - ". $ReqNo." - ".$ReqType." - ".$Reqedby." - ".$ReqDate." - ".$Status." - ".$Department." - ".$Designation." - "; + + ". $ReqNo." + ".$ReqType." + ".$Reqedby." + ".$ReqDate." + ".$Status." + ".$Department." + ".$Designation." + "; } die(json_encode(array('ReqList' =>$HTML))); } @@ -997,16 +1087,15 @@ class emergencypurchaseorder extends BaseController $UOM = $result[$i]['UOM']; $Quantity = $result[$i]['Quantity']; $HTML.=" - ".$SNo." - ". $MaterialCode." - - ".$MaterialName." - - ".$UOM." - ".$Quantity." - "; - - } + ".$SNo." + ". $MaterialCode." + + ".$MaterialName." + + ".$UOM." + ".$Quantity." + "; + } $CostCenter = ""; if(count($CostList) > 0) @@ -1047,7 +1136,7 @@ class emergencypurchaseorder extends BaseController $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); - $Local_Interstate=$this->input->post('Range'); + $Local_Interstate=$this->input->post('Range'); // PO Master $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt ,'CapitalRange'=>$Local_Interstate ); @@ -1092,14 +1181,14 @@ class emergencypurchaseorder extends BaseController $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $InsuranceValue = $this->input->post('Insval'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); - $CostCenter = $this->input->post('costCode'.$i); + $CostCenter = $this->input->post('costCode'.$i); $SkipInsert = "False"; if( count($comma_separated) > 0) { for($j = 1; $j < count($comma_separated); $j++) { - $deletedRow = $comma_separated[$j] ; + $deletedRow = $comma_separated[$j] ; if($deletedRow == $i ) { @@ -1120,15 +1209,14 @@ class emergencypurchaseorder extends BaseController { $LineItemNo = $POLineItem[0]['LineItemNo']; } - - + if(trim($POType) == REVENUE ) { - + $RevenueTaxList = array('LineItemNo'=>$LineItemNo, 'DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType, 'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'ExciseDuty'=>$ExciseValue,'ExciseDutyCalulatedOn'=>$ExciseOption,'AfterExciseDuty'=>$AfterExciseValue,'Vat'=>$VatValue,'AfterVAT'=>$AfterVatValue,'VatCalulatedOn'=>$VatOption, 'CST'=>$CSTValue,'AfterCST'=>$AfterCSTValue,'CSTCalulatedOn'=>$CSTOption,'GST'=>$GSTValue,'AfterGST'=>$AfterGSTValue,'OtherTaxes'=>$OtherTaxValue,'AfterOtherTaxes'=>$AfterOtherTaxValue,'Insurance'=>$InsuranceValue,'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt); $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); - + } } @@ -1136,7 +1224,6 @@ class emergencypurchaseorder extends BaseController echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; } - /** * This used to Edit the Revenue Purchase Order **/ @@ -1146,6 +1233,14 @@ class emergencypurchaseorder extends BaseController $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); + + $newsup=$this->input->post('newsup'); + $newSupId = split("[ - ]+", $newsup); + + $b4supplier=$this->input->post('b4supplier'); + $b4date=$this->input->post('b4podate'); + $b4podate = $this->getDateformat($b4date); + $DeliveryAddr = $this->input->post('txtDeliveryAddress'); $dt = $this->input->post('Deliverydt'); $Deliverydt = $this->getDateformat($dt); @@ -1163,7 +1258,7 @@ class emergencypurchaseorder extends BaseController $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updateddt = $dt->format('Y-m-d H:i:s'); - $Local_Interstate=$this->input->post('Range'); + $Local_Interstate=$this->input->post('Range'); // PO Master $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'CapitalRange'=>$Local_Interstate ); @@ -1171,6 +1266,25 @@ class emergencypurchaseorder extends BaseController $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); $LineItemStatus = REQITEM_NEW; + + if($PODate != $b4podate ) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>'-','UpdateBy'=>$updatedBy,'OldValue'=>$b4podate,'NewValue'=>$PODate,'Entity'=>'PO DateChanged'); + + + $this->purchaseorder_model->insertlogpo($logpo); + } + + if(!empty($newSupId[0] )) + { + if($newSupId[0] != $b4supplier) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>'-','UpdateBy'=>$updatedBy,'OldValue'=>$b4supplier,'NewValue'=>$newsup,'Entity'=>'Supplier Changed'); + + + $this->purchaseorder_model->insertlogpo($logpo); + } + } for ($i = 1; $i <= $RowCount; $i++) { @@ -1178,7 +1292,8 @@ class emergencypurchaseorder extends BaseController $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); - + $b4qty=$this->input->post('b4qty'.$i); + $b4rate=$this->input->post('b4rate'.$i); $DiscountType = $this->input->post('DisType'.$i); $DiscountValue = $this->input->post('DisVal'.$i); $AfterDiscount = $this->input->post('AfterDisVal'.$i); @@ -1205,16 +1320,32 @@ class emergencypurchaseorder extends BaseController $InsuranceValue = $this->input->post('Insval'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); - $CostCenter = $this->input->post('costCode'.$i); + $CostCenter = $this->input->post('costCode'.$i); $LineItemNo = ''; + if($Quantity != $b4qty) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'OldValue'=>$b4qty,'NewValue'=>$Quantity,'Entity'=>'Quantity Changed'); + + + $this->purchaseorder_model->insertlogpo($logpo); + } + + if($itemRate != $b4rate) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'OldValue'=>$b4rate,'NewValue'=>$itemRate,'Entity'=>'Rate Changed'); + + + $this->purchaseorder_model->insertlogpo($logpo); + } + $SkipInsert = "False"; if( count($comma_separated) > 0) { for($j = 1; $j < count($comma_separated); $j++) { - $deletedRow = $comma_separated[$j] ; + $deletedRow = $comma_separated[$j] ; if($deletedRow == $i ) { @@ -1265,7 +1396,6 @@ class emergencypurchaseorder extends BaseController echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; } - /** * To load pagenotfound view */ @@ -1281,7 +1411,7 @@ class emergencypurchaseorder extends BaseController */ public function revenuepoprint($PONO) { - + $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO); @@ -1314,7 +1444,6 @@ class emergencypurchaseorder extends BaseController public function servicepoprint($PONO) { - // $this->load->view('includes/pdfheader'); // Load the pdf page with multiviews $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); @@ -1338,7 +1467,6 @@ class emergencypurchaseorder extends BaseController $this->dompdf->stream("ServicePOReport.pdf",$data,$php); } - /** * To load the Delete the Requistion Items @@ -1358,7 +1486,6 @@ class emergencypurchaseorder extends BaseController $MaterialCode = $ReqList[2]; $POType = $ReqList[3]; } - if($POType == REVENUE) { $this->purchaseorder_model->DeletePORevenueTax($LineItemNo); diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index da726c96..f8f881c8 100644 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -27,7 +27,7 @@ class purchaseorder extends BaseController $this->CompanyName = $this->global['CompanyName']; } - /** + /** * Index Page for this controller (default function of the class) */ public function index() @@ -56,7 +56,7 @@ class purchaseorder extends BaseController $this->loadViews("advancerequest", $this->global, $data, NULL); } - /** + /** * To Create PO from Requisition Listing */ function requisition() @@ -74,8 +74,8 @@ class purchaseorder extends BaseController $this->loadViews("createPOfromRequistion", $this->global, $data,Null); } - - /** + + /** * To List the all PurchaseOrder */ function PurchaseOrderList() @@ -334,7 +334,7 @@ class purchaseorder extends BaseController $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; - $data['MaterialList'] = $result; + $data['MaterialList'] = $result;//$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); @@ -363,19 +363,19 @@ class purchaseorder extends BaseController $CostCode = ''; $this->load->model('costcenter_model'); $FYStart = ''; - $FYEnd = ''; - $FiscalYear = $this->costcenter_model->getFiscalYear(); - if(!empty($FiscalYear)) - { - foreach ($FiscalYear as $Fy) - { - $FYStart =$Fy->StartYear; - $FYEnd =$Fy->EndYear; - } - - } - - $FYdt = $FYStart." - ".$FYEnd ; + $FYEnd = ''; + $FiscalYear = $this->costcenter_model->getFiscalYear(); + if(!empty($FiscalYear)) + { + foreach ($FiscalYear as $Fy) + { + $FYStart =$Fy->StartYear; + $FYEnd =$Fy->EndYear; + } + + } + + $FYdt = $FYStart." - ".$FYEnd ; foreach ($ReqDetails as $Rs): $CostCode = $Rs->CostCenterCode; endforeach; @@ -387,7 +387,6 @@ class purchaseorder extends BaseController /* End Here */ $data['POMaster'] = $this->purchaseorder_model->GetServicePurchaseOrder($PONO); - foreach ($data['POMaster'] as $Exc) { $exRate=$Exc->ExchangeRate; @@ -397,35 +396,32 @@ class purchaseorder extends BaseController $PAYTERM=$TER->PaymentTerms; } - $data['getdata'] = $this->purchaseorder_model->getfunction($PONO); - //$data['billfile'] = $this->purchaseorder_model->getbillfiesr($PONO); + $data['getdata'] = $this->purchaseorder_model->getfunctionr($PONO); + $data['billfile'] = $this->purchaseorder_model->getbillfiesr($PONO); $data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); - if($ReqType == SERVICE) - { + if($ReqType == SERVICE) + { $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetails($PONO); - - $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); + $data['getdata'] = $this->purchaseorder_model->getfunction($PONO); - $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); + $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); + $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); - //$this->global['pageTitle'] = 'Resico : Edit Service Purchase order form'; $this->global['pageTitle'] = $this->CompanyName.' : Edit Service Purchase order form'; $this->loadViews("EditservicePurchaseorder", $this->global, $data, NULL); } else if($ReqType == REVENUE) { - $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); - $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); - $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); - $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); - //$this->global['pageTitle'] = 'Resico : Edit Revenue Purchase order form'; - $this->global['pageTitle'] = $this->CompanyName.' : Edit Revenue Purchase order form'; - $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); - + $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetails($PONO); + $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); + $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); + $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); + $this->global['pageTitle'] = $this->CompanyName.' : Edit Revenue Purchase order form'; + $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); } else if($ReqType == IMPORT) { @@ -436,20 +432,21 @@ class purchaseorder extends BaseController { $data['AvlBudAmt'] = $AvlBudget[0]['BudgetAmount'] - $AvlBudget[0]['Totalvalue']; } - + $data['POItem'] = $this->purchaseorder_model->GetImportPurchaseOrderDetails($PONO); $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); foreach($data['POMaster'] as $CUR) { - + $Currency=$CUR->CurrencyType; } $data['CurrencyDetail']=$this->purchaseorder_model->GetCurrencyDetail($Currency); $data['PaymentTerms']=$this->purchaseorder_model->GetPaymentTerms($PONO); $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); - + + $unicode =''; foreach ($data['CurrencyDetail'] as $Detail) { @@ -459,21 +456,20 @@ class purchaseorder extends BaseController { $currencycode=$Detail->Currency_Code; } - + $data['unicode']=$unicode; $data['currencycode']=$currencycode; - //$this->global['pageTitle'] = 'Resico : Edit Import Purchase order form'; - $this->global['pageTitle'] = $this->CompanyName.' : Edit Import Purchase order form'; + $this->global['pageTitle'] = $this->CompanyName.' : Edit Import Purchase order form'; $this->loadViews("editimportpo", $this->global, $data, NULL); } else if($ReqType == CAPITAL) { $CapitalRange = $_GET['CapitalRange']; - $CapitalAvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType); - - - if(count($CapitalAvlBudget)>0) + $CapitalAvlBudget = $this->purchaseorder_model->GetAvailableCapitalBudgetAmount($CostCode,$FYdt,$ReqType); + + + if(count($CapitalAvlBudget)>0) { @@ -487,10 +483,8 @@ class purchaseorder extends BaseController $data['POItem'] = $this->purchaseorder_model->getDomesticCapitalPurchaseOrderDetails($PONO); } $data['requestedBy'] = $this->purchaseorder_model->GetRequesedByDetails($PONO); - $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); - - - + $data['getlogpodtl']=$this->purchaseorder_model->getlogpodtl($PONO); + foreach($data['POItem'] as $Rate) { $exRate=$Rate->ExchangeRate; @@ -513,9 +507,8 @@ class purchaseorder extends BaseController $data['Currency']=$this->purchaseorder_model->GetCurrencytype(); } - - // $this->global['pageTitle'] = 'Resico : Edit Capital Purchase order form'; - $this->global['pageTitle'] = $this->CompanyName.' : Edit Capital Purchase order form'; + + $this->global['pageTitle'] = $this->CompanyName.' : Edit Capital Purchase order form'; $this->loadViews("editCapitalPo", $this->global, $data, NULL); } @@ -924,169 +917,158 @@ class purchaseorder extends BaseController * To store the new Revenue PO datas into DB */ function addNewPurchaseOrder() - { - - - - $POdt =$this->input->post('PODate'); - $PODate = $this->getDateformat($POdt); + { + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); - $DeliveryAddr = $this->input->post('DeliveryAddr'); - $dt = $this->input->post('Deliverydt'); - $POType = $this->input->post('POType'); - $DeliveryOption = $this->input->post('DateRange'); - if($DeliveryOption==1){ + $DeliveryAddr = $this->input->post('DeliveryAddr'); + $dt = $this->input->post('Deliverydt'); + $POType = $this->input->post('POType'); + $DeliveryOption = $this->input->post('DateRange'); + if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); - } - else{ + } + else{ $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; - } - - - $POType = $this->input->post('POType'); - $BudgetType = $this->input->post('Budget'); - - $Modeofshipment=$this->input->post('addmodeofshipment'); - $supplierreference=$this->input->post('addsupplierreference'); - $supplieroffno=$this->input->post('addsupplierofferno'); - $otherreference=$this->input->post('addotherreference'); - $fincap=$this->input->post('addfincap'); - $revenuetype=$this->input->post('PoTypeOptions'); - $insurancestatus=$this->input->post('insurance'); - if($insurancestatus == 1){ - $insuranceno=$this->input->post('insuranceno'); - }else{ - $insuranceno=$this->input->post('insuranceno'); - } - $SpcialInstruction = $this->input->post('SpcialInstruction'); - $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + } + $POType = $this->input->post('POType'); + $BudgetType = $this->input->post('Budget'); + $Modeofshipment=$this->input->post('addmodeofshipment'); + $supplierreference=$this->input->post('addsupplierreference'); + $supplieroffno=$this->input->post('addsupplierofferno'); + $otherreference=$this->input->post('addotherreference'); + $fincap=$this->input->post('addfincap'); + $revenuetype=$this->input->post('PoTypeOptions'); + $insurancestatus=$this->input->post('insurance'); + if($insurancestatus == 1){ + $insuranceno=$this->input->post('insuranceno'); + }else{ + $insuranceno=$this->input->post('insuranceno'); + } + $SpcialInstruction = $this->input->post('SpcialInstruction'); + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); $POStatus = $this->input->post('txtStatus'); $CreateBy = $this->session->userdata ( 'userId' ); - $RowCount = $this->input->post('txtRowCount'); - $DeletedRow = $this->input->post('txtDeletedRow'); - - $comma_separated = explode(':', $DeletedRow); - - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $createddt = $dt->format('Y-m-d H:i:s'); + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); - $PaymentTerms=$this->input->post('PaymentTerms'); + $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); - $Local_Interstate=$this->input->post('Range'); - $Qualitycheck=1; - // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$supplierreference,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Other_Reference'=>$otherreference,'Fincap'=>$fincap,'InsuranceStatus'=>$insurancestatus,'POSubType'=>$revenuetype,'InsuranceNumber'=>$insuranceno,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); + $Local_Interstate=$this->input->post('Range'); + $Qualitycheck=1; + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$supplierreference,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Other_Reference'=>$otherreference,'Fincap'=>$fincap,'InsuranceStatus'=>$insurancestatus,'POSubType'=>$revenuetype,'InsuranceNumber'=>$insuranceno,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); + + + $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$revenuetype); + + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + // PO Line Items + $LineItemStatus = REQITEM_NEW; + + for ($i = 1; $i <= $RowCount; $i++) + { - + $MaterialCode = $this->input->post('materialCode'.$i); + $Quantity = $this->input->post('quantity'.$i); + $Reqnumber = $this->input->post('Reqnumber'.$i); + $itemRate = $this->input->post('itemRate'.$i); + $per=$this->input->post('per'.$i); - - $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$revenuetype); - - $PONO = ''; - if(count($POMaster)>0) - { - $PONO = $POMaster[0]['PONO']; - } - - // PO Line Items - $LineItemStatus = REQITEM_NEW; - - for ($i = 1; $i <= $RowCount; $i++) - { - - $MaterialCode = $this->input->post('materialCode'.$i); - $Quantity = $this->input->post('quantity'.$i); - $Reqnumber = $this->input->post('Reqnumber'.$i); - $itemRate = $this->input->post('itemRate'.$i); - $per=$this->input->post('per'.$i); - - $DiscountType = $this->input->post('DisType'.$i); - $DiscountValue = $this->input->post('DisVal'.$i); - $AfterDiscount = $this->input->post('AfterDisVal'.$i); - $PackagingOption = $this->input->post('PackOption'.$i); - $PackagingType = $this->input->post('PackType'.$i); - $PackagingValue = $this->input->post('PackVal'.$i); - $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); - - $FreightType = $this->input->post('FreightType'.$i); - $FreightValue = $this->input->post('FreightVal'.$i); - $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); - $NOOfTrip = $this->input->post('NoOfTrip'.$i); - $InsuranceValue = $this->input->post('Insval'.$i); - $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); - $revenuedescription = $this->input->post('Service_Description'.$i); - $CostCenter = $this->input->post('costCode'.$i); - $Cgst = $this->input->post('RevenueCgst'.$i); + $DiscountType = $this->input->post('DisType'.$i); + $DiscountValue = $this->input->post('DisVal'.$i); + $AfterDiscount = $this->input->post('AfterDisVal'.$i); + $PackagingOption = $this->input->post('PackOption'.$i); + $PackagingType = $this->input->post('PackType'.$i); + $PackagingValue = $this->input->post('PackVal'.$i); + $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); + + $FreightType = $this->input->post('FreightType'.$i); + $FreightValue = $this->input->post('FreightVal'.$i); + $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); + $NOOfTrip = $this->input->post('NoOfTrip'.$i); + $InsuranceValue = $this->input->post('Insval'.$i); + $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); + $revenuedescription = $this->input->post('Service_Description'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $Cgst = $this->input->post('RevenueCgst'.$i); $Sgst = $this->input->post('RevenueSgst'.$i); $Igst = $this->input->post('RevenueIgst'.$i); $AfterCgst = $this->input->post('RevenueAfterCgst'.$i); $AfterSgst = $this->input->post('RevenueAfterSgst'.$i); $AfterIgst = $this->input->post('RevenueAfterIgst'.$i); - $SkipInsert = "False"; - if( count($comma_separated) > 0) - { - for($j = 1; $j < count($comma_separated); $j++) - { - $deletedRow = $comma_separated[$j] ; - - if($deletedRow == $i ) - { - $SkipInsert = "True"; - break; - } - - } - } - if($SkipInsert == "False") - { - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); - - $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - - $LineItemNo = ''; - if(count($POLineItem)>0) - { - $LineItemNo = $POLineItem[0]['LineItemNo']; - } - - - if(trim($POType) == REVENUE ) - { - - $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, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'NoOfTrip'=>$NOOfTrip); - - $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); - - } - } - - } - echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; - + $SkipInsert = "False"; + if( count($comma_separated) > 0) + { + for($j = 1; $j < count($comma_separated); $j++) + { + $deletedRow = $comma_separated[$j] ; + + if($deletedRow == $i ) + { + $SkipInsert = "True"; + break; + } + + } + } + if($SkipInsert == "False") + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter); + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + if(trim($POType) == REVENUE ) + { + + $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, 'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CGST'=>$Cgst,'AfterCGST'=>$AfterCgst,'SGST'=>$Sgst,'AfterSGST'=>$AfterSgst,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'NoOfTrip'=>$NOOfTrip); + + $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); + + } + } + + } + echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; + } - /** * To stored new values after edited Revenue datas. */ - function EditRevenuePurchaseOrder() - { - - $PONO =$this->input->post('txtPONO'); - $POdt =$this->input->post('PODate'); - $PODate = $this->getDateformat($POdt); - $SupplierID = $this->input->post('drpSupplier'); + function EditRevenuePurchaseOrder() + { + $PONO =$this->input->post('txtPONO'); + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $newsup=$this->input->post('newsup'); $newSupId = split("[ - ]+", $newsup); - $DeliveryAddr = $this->input->post('txtDeliveryAddress'); - $dt = $this->input->post('Deliverydt'); - - $DeliveryOption = $this->input->post('DateRange'); + $DeliveryAddr = $this->input->post('txtDeliveryAddress'); + $dt = $this->input->post('Deliverydt'); + + $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); @@ -1096,50 +1078,51 @@ class purchaseorder extends BaseController $DeliverySchedule = ''; } - $b4supplier=$this->input->post('b4supplier'); - $b4date=$this->input->post('b4podate'); - $b4podate = $this->getDateformat($b4date); + $b4supplier=$this->input->post('b4supplier'); + $b4date=$this->input->post('b4podate'); + $b4podate = $this->getDateformat($b4date); - $Modeofshipment=$this->input->post('editmodeofshipment'); - $supplierreference=$this->input->post('editsupplierreference'); - $supplieroffno=$this->input->post('editsupplierofferno'); - $otherreference=$this->input->post('editotherreference'); - $fincap=$this->input->post('editfincap'); - $revenuetype=$this->input->post('PoTypeOptions'); - $insurancestatus=$this->input->post('insurancestatus'); - if($insurancestatus == 1){ - $insuranceno=$this->input->post('insuranceno'); - }else{ - $insuranceno=""; - } + $Modeofshipment=$this->input->post('editmodeofshipment'); + $supplierreference=$this->input->post('editsupplierreference'); + $supplieroffno=$this->input->post('editsupplierofferno'); + $otherreference=$this->input->post('editotherreference'); + $fincap=$this->input->post('editfincap'); + $revenuetype=$this->input->post('PoTypeOptions'); + $insurancestatus=$this->input->post('insurancestatus'); + if($insurancestatus == 1){ + $insuranceno=$this->input->post('insuranceno'); + }else{ + $insuranceno=""; + } - $POType = $this->input->post('POType'); - $PoRange = $this->input->post('txtPoRange'); - $BudgetType = $this->input->post('Budget'); - $SpcialInstruction = $this->input->post('SpcialInstruction'); - $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); - $POStatus = $this->input->post('txtStatus'); + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); + $BudgetType = $this->input->post('Budget'); + $SpcialInstruction = $this->input->post('SpcialInstruction'); + $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); + $POStatus = $this->input->post('txtStatus'); + $updatedBy = $this->session->userdata('userId'); + $RowCount = $this->input->post('txtRowCount'); + $DeletedRow = $this->input->post('txtDeletedRow'); + + + $comma_separated = explode(':', $DeletedRow); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); - $updatedBy = $this->session->userdata ( 'userId' ); - $RowCount = $this->input->post('txtRowCount'); - $DeletedRow = $this->input->post('txtDeletedRow'); - - $comma_separated = explode(':', $DeletedRow); - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $updateddt = $dt->format('Y-m-d H:i:s'); - - $PaymentTerms=$this->input->post('PaymentTerms'); + $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); - $Local_Interstate=$this->input->post('Range'); + $Local_Interstate=$this->input->post('Range'); $Qualitycheck=1; - - // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$supplierreference,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Other_Reference'=>$otherreference,'Fincap'=>$fincap,'InsuranceStatus'=>$insurancestatus,'POSubType'=>$revenuetype,'InsuranceNumber'=>$insuranceno,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); - $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); - - $LineItemStatus = REQITEM_NEW; - if($PODate != $b4podate ) + + // PO Master + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'Status'=>$POStatus,'PORange'=>$Local_Interstate,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'CapitalRange'=>$Local_Interstate,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$supplierreference,'Mode_Of_Shipment'=>$Modeofshipment,'Supplier_Offer_No'=>$supplieroffno,'Other_Reference'=>$otherreference,'Fincap'=>$fincap,'InsuranceStatus'=>$insurancestatus,'POSubType'=>$revenuetype,'InsuranceNumber'=>$insuranceno,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); + + $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); + + $LineItemStatus = REQITEM_NEW; + if($PODate != $b4podate ) { $logpo =array('PONO'=>$PONO,'LineItemNo'=>'-','UpdateBy'=>$updatedBy,'OldValue'=>$b4podate,'NewValue'=>$PODate,'Entity'=>'PO DateChanged'); @@ -1151,55 +1134,55 @@ class purchaseorder extends BaseController { if($newSupId[0] != $b4supplier) { - //echo $b4supplier.'-'.$newSupId[0];die; + $logpo =array('PONO'=>$PONO,'LineItemNo'=>'-','UpdateBy'=>$updatedBy,'OldValue'=>$b4supplier,'NewValue'=>$newsup,'Entity'=>'Supplier Changed'); $this->purchaseorder_model->insertlogpo($logpo); } } - - for ($i = 1; $i <= $RowCount; $i++) - { - - $MaterialCode = $this->input->post('materialCode'.$i); - $Quantity = $this->input->post('quantity'.$i); + + + for ($i = 1; $i <= $RowCount; $i++) + { + + $MaterialCode = $this->input->post('materialCode'.$i); + $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); - + $b4qty=$this->input->post('b4qty'.$i); $b4rate=$this->input->post('b4rate'.$i); - $itemRate = $this->input->post('itemRate'.$i); - $per=$this->input->post('per'.$i); - $DiscountType = $this->input->post('DisType'.$i); - $DiscountValue = $this->input->post('DisVal'.$i); - $AfterDiscount = $this->input->post('AfterDisVal'.$i); - $PackagingOption = $this->input->post('PackOption'.$i); - $PackagingType = $this->input->post('PackType'.$i); - $PackagingValue = $this->input->post('PackVal'.$i); - $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); - $Cgst = $this->input->post('RevenueCgst'.$i); - $Sgst = $this->input->post('RevenueSgst'.$i); - $Igst = $this->input->post('RevenueIgst'.$i); - $AfterCgst = $this->input->post('RevenueAfterCgst'.$i); - $AfterSgst = $this->input->post('RevenueAfterSgst'.$i); - $AfterIgst = $this->input->post('RevenueAfterIgst'.$i); - $FreightType = $this->input->post('FreightType'.$i); - $FreightValue = $this->input->post('FreightVal'.$i); - $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); - $NOOfTrip = $this->input->post('NoOfTrip'.$i); - $revenuedescription = $this->input->post('service_description'.$i); + $itemRate = $this->input->post('itemRate'.$i); + $per=$this->input->post('per'.$i); + $DiscountType = $this->input->post('DisType'.$i); + $DiscountValue = $this->input->post('DisVal'.$i); + $AfterDiscount = $this->input->post('AfterDisVal'.$i); + $PackagingOption = $this->input->post('PackOption'.$i); + $PackagingType = $this->input->post('PackType'.$i); + $PackagingValue = $this->input->post('PackVal'.$i); + $AfterPackagingValue = $this->input->post('AfterPackVal'.$i); + $Cgst = $this->input->post('RevenueCgst'.$i); + $Sgst = $this->input->post('RevenueSgst'.$i); + $Igst = $this->input->post('RevenueIgst'.$i); + $AfterCgst = $this->input->post('RevenueAfterCgst'.$i); + $AfterSgst = $this->input->post('RevenueAfterSgst'.$i); + $AfterIgst = $this->input->post('RevenueAfterIgst'.$i); + $FreightType = $this->input->post('FreightType'.$i); + $FreightValue = $this->input->post('FreightVal'.$i); + $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); + $NOOfTrip = $this->input->post('NoOfTrip'.$i); + $revenuedescription = $this->input->post('service_description'.$i); $InsuranceValue = $this->input->post('Insval'.$i); - $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); - $POLineItemNo = $this->input->post('LineItemNo'.$i); - $CostCenter = $this->input->post('costCode'.$i); - $LineItemNo = ''; - - if($Quantity != $b4qty) + $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); + $POLineItemNo = $this->input->post('LineItemNo'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $LineItemNo = ''; + + if($Quantity != $b4qty) { $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'OldValue'=>$b4qty,'NewValue'=>$Quantity,'Entity'=>'Quantity Changed'); - - + $this->purchaseorder_model->insertlogpo($logpo); } @@ -1211,101 +1194,71 @@ class purchaseorder extends BaseController $this->purchaseorder_model->insertlogpo($logpo); } - - $SkipInsert = "False"; - if( count($comma_separated) > 0) - { - for($j = 1; $j < count($comma_separated); $j++) - { - $deletedRow = $comma_separated[$j] ; - - if($deletedRow == $i ) - { - $SkipInsert = "True"; - break; - } - - } - } + + $SkipInsert = "False"; + if( count($comma_separated) > 0) + { + for($j = 1; $j < count($comma_separated); $j++) + { + $deletedRow = $comma_separated[$j] ; + + if($deletedRow == $i ) + { + $SkipInsert = "True"; + break; + } + + } + } - $ReqDetails = array('Quantity'=>$Quantity,'UpdatedBy'=>$updatedBy,'UpdatedOn'=>$updateddt); + $ReqDetails = array('Quantity'=>$Quantity,'UpdatedBy'=>$updatedBy,'UpdatedOn'=>$updateddt); $this->purchaseorder_model->updateReqDetails($Reqnumber,$MaterialCode,$ReqDetails); - $recqty=0; - if($POStatus == SPECIAL_PO) - { + if($POStatus == SPECIAL_PO) + { $recqty= $Quantity; $IGRD= $this->purchaseorder_model->getIGRDetails($PONO); - $j = $i-1; - $IGRDs = array('QuantityAsPerInvoice'=>$Quantity,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); - - $this->purchaseorder_model->updateIGR($IGRD[$j]['IGRItemNo'],$IGRDs); - - //$MaterialstockHistoryupdate= array('SupplierID'=>$SupplierID,'Quantity'=>$Quantity,'ItemValue'=>$itemRate,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); - - //$itemNo = $IGRD[$j]['IGRItemNo']; + $IGRDs = array('QuantityAsPerInvoice'=>$Quantity,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); - //$this->purchaseorder_model->updateMatStock($itemNo,$MaterialstockHistoryupdate); + $this->purchaseorder_model->updateIGR($IGRD[$j]['IGRItemNo'],$IGRDs); - } - if($SkipInsert == "False") - { - - //if(strlen($POLineItemNo) == 0) - //{ - // $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription,'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 - //{ + if($SkipInsert == "False") + { - $LineItemNo = $POLineItemNo; - - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'ReceivedQuantity'=>$recqty,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); - - $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); + $LineItemNo = $POLineItemNo; - //} - $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); - //if(count($isExists) == 0) - // { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'ReceivedQuantity'=>$recqty,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); + + $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); + + $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); + // $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, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'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); - + $this->purchaseorder_model->updateRevenueTax($LineItemNo,$RevenueTaxList); - - // } + } - + } echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; } - - /** + + /** * To load pagenotfound view */ function pageNotFound() @@ -1319,46 +1272,40 @@ class purchaseorder extends BaseController /** * To load revenue po datas for pdf */ - public function revenuepoprint($PONO) + public function revenuepoprint($PONO) { // Load all views as normal - - - $PoStatus=''; + $PoStatus=''; $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformationforPDF(); $data['GetPoFormat'] = $this->purchaseorder_model->GetPoFormat($PONO); $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO); - $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); - $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); - $data['reveuetax']=$this->purchaseorder_model->getRevenueTaxinforforpdf($PONO); - $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); - $Currencycode=''; + $data['releasedetails'] = $this->purchaseorder_model->GetReleasedDetails($PONO); + $data['CurrencySymbol']=$this->purchaseorder_model->GerCurrencyCodeName('INR'); + $data['reveuetax']=$this->purchaseorder_model->getRevenueTaxinforforpdf($PONO); + $data['AmendmentPDF'] = $this->purchaseorder_model->amendpdf($PONO); + $Currencycode=''; - $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; -$AdvanceAmount=0.00; - foreach ($data['POItem'] as $POI) - { + $TotalOrderValue=$data['POItem'][0]->TotalOrderValue; + $AdvanceAmount=0.00; + + foreach ($data['POItem'] as $POI) + { $AdvanceAmount=$POI->AdvanceAmount; $PoStatus=$POI->Status; - } + } - $TotaltoPay=0.00; + $TotaltoPay=0.00; $TotaltoPay=$TotalOrderValue-$AdvanceAmount; - $totalAmt=sprintf("%.2f", $TotalOrderValue); - - - - $data['TotalAmountInWords']= $this->convertNumber($totalAmt); - $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); + $totalAmt=sprintf("%.2f", $TotalOrderValue); + + $data['TotalAmountInWords']= $this->convertNumber($totalAmt); + $data['RequistionDetails'] = $this->purchaseorder_model->GetPdfRequistionDetails($PONO); - - - $mpdf=new mPDF('utf-8','A4-P',7, 10,10, 10, 82, 38, 4, 6); @@ -1674,197 +1621,193 @@ public function importpoprint($PONO) /** * To store the new import PO datas into DB */ -function addNewImportPurchaseOrder() + function addNewImportPurchaseOrder() { - - $POdt =$this->input->post('PODate'); - $PODate = $this->getDateformat($POdt); - $SupplierID = $this->input->post('drpSupplier'); - $DeliveryAddr = $this->input->post('DeliveryAddr'); - - $POType = $this->input->post('POType'); - $PoRange = $this->input->post('txtPoRange'); - - $DeliveryOption = $this->input->post('DateRange'); - - $DeliverySchedule=''; - $Dispatch=''; - if($DeliveryOption==1) - { - $Dispatch=''; - $DeliverySchedule = $this->input->post('Scheduleby'); - } - - - else - { - $Dispatch = $this->input->post('Dispatch'); - $DeliverySchedule = ''; - } - - $SpcialInstruction = $this->input->post('txtSpcialInstruction'); - $TotalOrder = $this->input->post('txtToatlOrder'); - $POStatus = $this->input->post('textStatus'); - - - $BudgetType = $this->input->post('Budget'); - $CreateBy = $this->session->userdata ( 'userId' ); - $RowCount = $this->input->post('txtRowCount'); - - $DeletedRow = $this->input->post('txtDeletedRow'); - - $comma_separated = explode(':', $DeletedRow); - - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $createddt = $dt->format('Y-m-d H:i:s'); - $Exchangerate=$this->input->post('ExchangeRate'); - $Edt=$this->input->post('Exchangerateon'); - $ExchangeRateCalculatedon=$this->getDateformat($Edt); - - $CurrencyType=$this->input->post('currencytype'); - - $PaymentTerms=$this->input->post('PaymentTerms'); - $OtherPayment=$this->input->post('Otherpayment'); - $Palaceoforigin=$this->input->post('PlaceOforigin'); - - - $Shipmentmode=$this->input->post('addmodeofshipment'); - $SupplierRef=$this->input->post('addsupplierreference'); - $SupplierOffer=$this->input->post('addsupplierofferno'); - $otherRef=$this->input->post('addotherreference'); - $finCap=$this->input->post('addfincap'); - - $importoption=$this->input->post('Importoption'); - - $Insurance=$this->input->post('Insurance'); - - if($Insurance==1) - { - - $Insurancenumber=$this->input->post('insurancenumber'); - } - else - { - $Insurancenumber=''; - } - - - - $Qualitycheck=1; - - - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin,'PaymentOtherDescription'=>$OtherPayment,'Mode_Of_Shipment'=>$Shipmentmode,'Supplier_Reference'=>$SupplierRef,'Supplier_Offer_No'=>$SupplierOffer,'Other_Reference'=>$otherRef,'Fincap'=>$finCap,'InsuranceStatus'=>$Insurance,'InsuranceNumber'=>$Insurancenumber,'POSubType'=>$importoption); - // ,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType - - $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$importoption); - - $PONO = ''; - if(count($POMaster)>0) - { - $PONO = $POMaster[0]['PONO']; - } - $LineItemStatus = REQITEM_NEW; - for ($i = 1; $i <= $RowCount; $i++) - { - - $MaterialCode = $this->input->post('materialCode'.$i); - $Quantity = $this->input->post('quantity'.$i); - - $Reqnumber = $this->input->post('Reqnumber'.$i); - $itemRate = $this->input->post('itemRate'.$i); - - - $BasicPriceinmton = $this->input->post('BasicPriceinUS'.$i); - $Productprice = $this->input->post('BasicAmt'.$i); - $LandingCharge = $this->input->post('LandingChargee'.$i); - $AfterLandingCharge = $this->input->post('AfterLandingChargee'.$i); - $CustomDuty = $this->input->post('Customduty'.$i); - $AfterCustomDuty = $this->input->post('AfterCustomduty'.$i); - $CustomEd= $this->input->post('CustomEDcess'.$i); - $AfterCustomEd= $this->input->post('AfterCustomEDcess'.$i); - $CustomSH = $this->input->post('CustomSHcess'.$i); - $AfterCustomSH = $this->input->post('AfterCustomSHcess'.$i); - $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); - $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); - - $QuantityKG = $this->input->post('PurQuantity'.$i); - - - $Totalvalueitem=$this->input->post('TotalExp'.$i); - - - $CostCenter = $this->input->post('costCode'.$i); - - $AssessableValue=$this->input->post('AfterAssessable'.$i); - $Subtotal=$this->input->post('Subtotal'.$i); - $Igst=$this->input->post('Igst'.$i); - $AfterIgst=$this->input->post('AfterIgst'.$i); - $Dutyimpact=$this->input->post('Dutyimpact'.$i); - $Clearingcharge=$this->input->post('ClearingCharges'.$i); - $Nettvalue=$this->input->post('Nett'.$i); - - - - $FreightType=$this->input->post('FreightType'.$i); - $nooftrip=$this->input->post('NoofTrip'.$i); - $Freightrate=$this->input->post('FreightRate'.$i); - $Freightamount=$this->input->post('AfterFreightRate'.$i); - - - - $specialinstruction=$this->input->post('Addinstruction'.$i); - + $POdt =$this->input->post('PODate'); + $PODate = $this->getDateformat($POdt); + $SupplierID = $this->input->post('drpSupplier'); + $DeliveryAddr = $this->input->post('DeliveryAddr'); + + $POType = $this->input->post('POType'); + $PoRange = $this->input->post('txtPoRange'); + $DeliveryOption = $this->input->post('DateRange'); - $per=$this->input->post('Per'.$i); - - - - - $SkipInsert = "False"; - if( count($comma_separated) > 0) - { - for($j = 1; $j < count($comma_separated); $j++) - { - $deletedRow = $comma_separated[$j] ; - - if($deletedRow == $i ) - { - $SkipInsert = "True"; - break; - } - - } - } - if($SkipInsert == "False") - { - $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Per'=>$per,'ServiceMaterialDescription'=>$specialinstruction); - - - - $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); - - $LineItemNo = ''; - if(count($POLineItem)>0) - { - $LineItemNo = $POLineItem[0]['LineItemNo']; - } - - - if(trim($POType) == IMPORT ) - { - - $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$nooftrip,'FreightValue'=>$Freightrate,'AfterFreightValue'=>$Freightamount,'AssessableValue'=>$AssessableValue,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$Dutyimpact,'ClearingCharge'=>$Clearingcharge,'NetValue'=>$Nettvalue); - - - $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); - - } - } - - } - echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; + $DeliverySchedule=''; + $Dispatch=''; + if($DeliveryOption==1) + { + $Dispatch=''; + $DeliverySchedule = $this->input->post('Scheduleby'); } + else + { + $Dispatch = $this->input->post('Dispatch'); + $DeliverySchedule = ''; + } + + $SpcialInstruction = $this->input->post('txtSpcialInstruction'); + $TotalOrder = $this->input->post('txtToatlOrder'); + $POStatus = $this->input->post('textStatus'); + + $BudgetType = $this->input->post('Budget'); + $CreateBy = $this->session->userdata ( 'userId' ); + $RowCount = $this->input->post('txtRowCount'); + + $DeletedRow = $this->input->post('txtDeletedRow'); + + $comma_separated = explode(':', $DeletedRow); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + $Exchangerate=$this->input->post('ExchangeRate'); + $Edt=$this->input->post('Exchangerateon'); + $ExchangeRateCalculatedon=$this->getDateformat($Edt); + + $CurrencyType=$this->input->post('currencytype'); + + $PaymentTerms=$this->input->post('PaymentTerms'); + $OtherPayment=$this->input->post('Otherpayment'); + $Palaceoforigin=$this->input->post('PlaceOforigin'); + + $Shipmentmode=$this->input->post('addmodeofshipment'); + $SupplierRef=$this->input->post('addsupplierreference'); + $SupplierOffer=$this->input->post('addsupplierofferno'); + $otherRef=$this->input->post('addotherreference'); + $finCap=$this->input->post('addfincap'); + + $importoption=$this->input->post('Importoption'); + + $Insurance=$this->input->post('Insurance'); + + if($Insurance==1) + { + + $Insurancenumber=$this->input->post('insurancenumber'); + } + else + { + $Insurancenumber=''; + } + + + + $Qualitycheck=1; + + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin,'PaymentOtherDescription'=>$OtherPayment,'Mode_Of_Shipment'=>$Shipmentmode,'Supplier_Reference'=>$SupplierRef,'Supplier_Offer_No'=>$SupplierOffer,'Other_Reference'=>$otherRef,'Fincap'=>$finCap,'InsuranceStatus'=>$Insurance,'InsuranceNumber'=>$Insurancenumber,'POSubType'=>$importoption,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); + + + $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$importoption); + + $PONO = ''; + if(count($POMaster)>0) + { + $PONO = $POMaster[0]['PONO']; + } + + $LineItemStatus = REQITEM_NEW; + + for ($i = 1; $i <= $RowCount; $i++) + { + + $MaterialCode = $this->input->post('materialCode'.$i); + $Quantity = $this->input->post('quantity'.$i); + + $Reqnumber = $this->input->post('Reqnumber'.$i); + $itemRate = $this->input->post('itemRate'.$i); + + + $BasicPriceinmton = $this->input->post('BasicPriceinUS'.$i); + $Productprice = $this->input->post('BasicAmt'.$i); + $LandingCharge = $this->input->post('LandingChargee'.$i); + $AfterLandingCharge = $this->input->post('AfterLandingChargee'.$i); + $CustomDuty = $this->input->post('Customduty'.$i); + $AfterCustomDuty = $this->input->post('AfterCustomduty'.$i); + $CustomEd= $this->input->post('CustomEDcess'.$i); + $AfterCustomEd= $this->input->post('AfterCustomEDcess'.$i); + $CustomSH = $this->input->post('CustomSHcess'.$i); + $AfterCustomSH = $this->input->post('AfterCustomSHcess'.$i); + $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); + $CustomDutyExpensesPerKG = $this->input->post('CustomDutyExpenses'.$i); + + $QuantityKG = $this->input->post('PurQuantity'.$i); + + + $Totalvalueitem=$this->input->post('TotalExp'.$i); + + + $CostCenter = $this->input->post('costCode'.$i); + + $AssessableValue=$this->input->post('AfterAssessable'.$i); + $Subtotal=$this->input->post('Subtotal'.$i); + $Igst=$this->input->post('Igst'.$i); + $AfterIgst=$this->input->post('AfterIgst'.$i); + $Dutyimpact=$this->input->post('Dutyimpact'.$i); + $Clearingcharge=$this->input->post('ClearingCharges'.$i); + $Nettvalue=$this->input->post('Nett'.$i); + + + + $FreightType=$this->input->post('FreightType'.$i); + $nooftrip=$this->input->post('NoofTrip'.$i); + $Freightrate=$this->input->post('FreightRate'.$i); + $Freightamount=$this->input->post('AfterFreightRate'.$i); + + + + $specialinstruction=$this->input->post('Addinstruction'.$i); + + + + $per=$this->input->post('Per'.$i); + + + + + $SkipInsert = "False"; + if( count($comma_separated) > 0) + { + for($j = 1; $j < count($comma_separated); $j++) + { + $deletedRow = $comma_separated[$j] ; + + if($deletedRow == $i ) + { + $SkipInsert = "True"; + break; + } + + } + } + if($SkipInsert == "False") + { + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Per'=>$per,'ServiceMaterialDescription'=>$specialinstruction); + + + + $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + + $LineItemNo = ''; + if(count($POLineItem)>0) + { + $LineItemNo = $POLineItem[0]['LineItemNo']; + } + + + if(trim($POType) == IMPORT ) + { + + $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$nooftrip,'FreightValue'=>$Freightrate,'AfterFreightValue'=>$Freightamount,'AssessableValue'=>$AssessableValue,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$Dutyimpact,'ClearingCharge'=>$Clearingcharge,'NetValue'=>$Nettvalue); + + + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + + } + } + + } + echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; +} /** * To stored new values after edited import po. @@ -1882,7 +1825,7 @@ function addNewImportPurchaseOrder() $newsup=$this->input->post('newsup'); $newSupId = split("[ - ]+", $newsup); - + $b4supplier=$this->input->post('b4supplier'); $b4date=$this->input->post('b4podate'); $b4podate = $this->getDateformat($b4date); @@ -1935,7 +1878,6 @@ function addNewImportPurchaseOrder() $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); $Palaceoforigin=$this->input->post('PlaceOforigin'); - $Shipmentmode=$this->input->post('editmodeofshipment'); $SupplierRef=$this->input->post('editsupplierreference'); $SupplierOffer=$this->input->post('editsupplierofferno'); @@ -1947,7 +1889,7 @@ function addNewImportPurchaseOrder() $importoption=$this->input->post('Importoption'); $Insurance=$this->input->post('Insurance'); - + if($Insurance=='YES') { @@ -1959,13 +1901,12 @@ function addNewImportPurchaseOrder() $Insurancenumber=''; $insurestatus='0'; } - // $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$updateddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms); $Qualitycheck=1; $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'Import_DispatchDetails'=>$Dispatch,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ExchangeRate'=>$Exchangerate,'ExchangeRateCalculatedon'=>$ExchangeRateCalculatedon,'CurrencyType'=>$CurrencyType,'PaymentTerms'=>$PaymentTerms,'POType'=>$POType,'Import_PlaceofOrgin'=>$Palaceoforigin,'PaymentOtherDescription'=>$OtherPayment,'Mode_Of_Shipment'=>$Shipmentmode,'Supplier_Reference'=>$SupplierRef,'Supplier_Offer_No'=>$SupplierOffer,'Other_Reference'=>$otherRef,'Fincap'=>$finCap,'InsuranceStatus'=>$insurestatus,'InsuranceNumber'=>$Insurancenumber,'POSubType'=>$importoption,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); - + $LineItemStatus = REQITEM_NEW; if($PODate == $b4podate ) @@ -1988,17 +1929,16 @@ function addNewImportPurchaseOrder() } - for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); - + $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); - + $b4qty=$this->input->post('b4qty'.$i); $b4rate=$this->input->post('b4rate'.$i); @@ -2030,7 +1970,7 @@ function addNewImportPurchaseOrder() $AfterAddAdtional = $this->input->post('AfterAddlExciseDuty'.$i); $Grossdutypayable = $this->input->post('Grossdutypayable'.$i); - + $AvailableModvat = $this->input->post('AvailableModvat'.$i); $Grossexpensesduetocustomduty = $this->input->post('Grossexpensesduetocustomduty'.$i); @@ -2048,7 +1988,7 @@ function addNewImportPurchaseOrder() $CostCenter = $this->input->post('costCode'.$i); - + $Totalvalueitem=$this->input->post('TotalValue'.$i); @@ -2060,7 +2000,7 @@ function addNewImportPurchaseOrder() $AssessableValue=$this->input->post('AssessableValue'.$i); - + $Subtotal=$this->input->post('SubTotal'.$i); $Igst=$this->input->post('IGST'.$i); $AfterIgst=$this->input->post('AfterIGST'.$i); @@ -2073,13 +2013,12 @@ function addNewImportPurchaseOrder() $per=$this->input->post('Per'.$i); $LineItemNo = ''; -if($Quantity != $b4qty) - { - $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'OldValue'=>$b4qty,'NewValue'=>$Quantity,'Entity'=>'Quantity Changed'); + if($Quantity != $b4qty) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'OldValue'=>$b4qty,'NewValue'=>$Quantity,'Entity'=>'Quantity Changed'); - - $this->purchaseorder_model->insertlogpo($logpo); - } + $this->purchaseorder_model->insertlogpo($logpo); + } if($itemRate != $b4rate) @@ -2089,7 +2028,7 @@ if($Quantity != $b4qty) $this->purchaseorder_model->insertlogpo($logpo); } - + $currencytypeID = $this->input->post('currencytype'); $SkipInsert = "False"; if( count($comma_separated) > 0) @@ -2111,7 +2050,7 @@ if($Quantity != $b4qty) $this->purchaseorder_model->updateReqDetails($Reqnumber,$MaterialCode,$ReqDetails); - + if($SkipInsert == "False") { if(strlen($POLineItemNo) == 0) @@ -2130,26 +2069,21 @@ if($Quantity != $b4qty) $LineItemNo = $POLineItemNo; - + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter,'Per'=>$per,'ServiceMaterialDescription'=>$specialinstruction); $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); } $isExists = $this->purchaseorder_model->LineItemExistsinImportTax($LineItemNo); - - - if(count($isExists) == 0) { $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$Nosoftrip,'FreightValue'=>$FreightRate,'AfterFreightValue'=>$FreightAmount,'AssessableValue'=>$AssessableValue,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$Dutyimpact,'ClearingCharge'=>$Clearingcharge,'NetValue'=>$Nettvalue); - - $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); + $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); } else { $ImportTaxList = array('LineItemNo'=>$LineItemNo,'BasicPriceInMTon'=>$BasicPriceinmton,'ProductPrice'=>$Productprice,'LandingCharge'=>$LandingCharge,'AfterLandingCharge'=>$AfterLandingCharge,'CustomDuty'=>$CustomDuty,'AfterCustomDuty'=>$AfterCustomDuty,'CustomEdCess'=>$CustomEd,'CustomSHCess'=>$CustomSH,'CreatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt,'Grossdutypayable'=>$Grossdutypayable,'CustomDutyExpensesPerKG'=>$CustomDutyExpensesPerKG,'QuantityKG'=>$QuantityKG,'AfterCustomSHCess'=>$AfterCustomSH,'AfterCustomEdCess'=>$AfterCustomEd,'TotalValue'=>$Totalvalueitem,'FreightType'=>$FreightType,'NoOfTrip'=>$Nosoftrip,'FreightValue'=>$FreightRate,'AfterFreightValue'=>$FreightAmount,'AssessableValue'=>$AssessableValue,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$Dutyimpact,'ClearingCharge'=>$Clearingcharge,'NetValue'=>$Nettvalue); - $this->purchaseorder_model->updateImportTax($LineItemNo,$ImportTaxList); @@ -2162,7 +2096,7 @@ if($Quantity != $b4qty) echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; } - + /* All Function following This command for FINANCE TEAM PO APPROVAL SCREEN*/ /** * For po approval. functionalities handles by Finances dept. @@ -2289,7 +2223,7 @@ if($Quantity != $b4qty) /** * To store the new Capital PO datas into DB */ - function addNewCapitalPurchaseOrder() + function addNewCapitalPurchaseOrder() { @@ -2353,8 +2287,7 @@ if($Quantity != $b4qty) $PaymentMethod = $this->input->post('PaymentMethod'); $OtherPayment=$this->input->post('Otherpayment'); - $BudgetType = $this->input->post('Budget'); - + $BudgetType = $this->input->post('Budget'); @@ -2373,14 +2306,13 @@ if($Quantity != $b4qty) $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); - $currencytypeID = $this->input->post('currencytype'); - - - $Qualitycheck=1; + $currencytypeID = $this->input->post('currencytype'); + $Qualitycheck=1; + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrder,'PODate'=>$PODate,'Status'=>$POStatus,'PORange'=>$PoRange,'ExchangeRateCalculatedon'=>$ExchangeRateOn,'ExchangeRate'=>$ExchangeRate,'PaymentTerms'=>$PaymentMethod,'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'CreatedDate'=>$createddt,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'CapitalRange'=>$CapitalRange,'POType'=>$POType,'CurrencyType'=>$currencytypeID,'DeliverySchedule'=>$DeliverySchedule,'Import_PlaceofOrgin'=>$Palaceoforigin,'Import_DispatchDetails'=>$Dispatch,'DeliveryDate'=>$Deliverydt,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'IsQualityChkReqired'=>$Qualitycheck,'BudgetType'=>$BudgetType); - + $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$ServiceTypeOptions); @@ -2431,7 +2363,7 @@ if($Quantity != $b4qty) $Totalvalueitem=$this->input->post('PerKgExpense'.$i); - + $CostCenter = $this->input->post('CPCostCode'.$i); $TotalOrderValue = $this->input->post('basicvalInINR'.$i); @@ -2495,7 +2427,7 @@ if($Quantity != $b4qty) $LineItemNo = $POLineItem[0]['LineItemNo']; } - + if(trim($POType) == CAPITAL ) { if($CapitalRange=='1') @@ -2526,13 +2458,13 @@ if($Quantity != $b4qty) } } - } + } echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; } -/** + /** * To store the new Capital PO datas into DB */ function EditCapitalPurchaseOrder() @@ -2545,7 +2477,7 @@ if($Quantity != $b4qty) $SupplierID = $this->input->post('drpSupplier'); - $newsup=$this->input->post('newsup'); + $newsup=$this->input->post('newsup'); $newSupId = split("[ - ]+", $newsup); @@ -2555,10 +2487,9 @@ if($Quantity != $b4qty) $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); - - $b4supplier=$this->input->post('b4supplier'); - $b4date=$this->input->post('b4podate'); - $b4podate = $this->getDateformat($b4date); + $b4supplier=$this->input->post('b4supplier'); + $b4date=$this->input->post('b4podate'); + $b4podate = $this->getDateformat($b4date); $DeliveryOption = $this->input->post('DateRange'); @@ -2612,7 +2543,7 @@ if($Quantity != $b4qty) $TotalOrder = $this->input->post('CapitalToatlOrder'); $POStatus = $this->input->post('txtStatus'); $Palaceoforigin=$this->input->post('PlaceOforigin'); - $ModeOfShipment=$this->input->post('editmodeofshipment'); + $ModeOfShipment=$this->input->post('editmodeofshipment'); $SupplierReference=$this->input->post('editsupplierreference'); $SuppliersOfferNo=$this->input->post('editsupplierofferno'); $OtherReferences=$this->input->post('editotherreference'); @@ -2623,7 +2554,7 @@ if($Quantity != $b4qty) $BudgetType = $this->input->post('Budget'); - $CreateBy = $this->session->userdata ( 'userId' ); + $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); @@ -2713,7 +2644,7 @@ if($Quantity != $b4qty) $Totalvalueitem=$this->input->post('PerKgExpense'.$i); - + $CostCenter = $this->input->post('CPCostCode'.$i); $TotalOrderValue = $this->input->post('basicvalInINR'.$i); @@ -2750,12 +2681,12 @@ if($Quantity != $b4qty) $Freightrateloc=$this->input->post('Fvalue'.$i); $FreightAmountloc=$this->input->post('Afvalue'.$i); - + if($Quantity != $b4qty) { $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'OldValue'=>$b4qty,'NewValue'=>$Quantity,'Entity'=>'Quantity Changed'); - + $this->purchaseorder_model->insertlogpo($logpo); } @@ -2763,12 +2694,10 @@ if($Quantity != $b4qty) if($itemRate != $b4rate) { $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$CreateBy,'OldValue'=>$b4rate,'NewValue'=>$itemRate,'Entity'=>'Rate Changed'); - + $this->purchaseorder_model->insertlogpo($logpo); } - - $SkipInsert = "False"; if( count($comma_separated) > 0) { @@ -2785,11 +2714,11 @@ if($Quantity != $b4qty) } } + $ReqDetails = array('Quantity'=>$Quantity,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$updateddt); $this->purchaseorder_model->updateReqDetails($Reqnumber,$MaterialCode,$ReqDetails); - if($SkipInsert == "False") { if(strlen($POLineItemNo) == 0) @@ -2852,11 +2781,11 @@ if($Quantity != $b4qty) } - } - + } + echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; - } - + } + /** * To load capital po datas for pdf */ @@ -2970,14 +2899,6 @@ if($Quantity != $b4qty) } - - - - - - - - /** * To convert amount(digit) into words * */ @@ -3205,8 +3126,179 @@ if($advance > 0) } +function addloadfile() + { + + $pono= $this->input->post('PONO'); + + $igr= $this->input->post('igr'); + + $new_file_name =$_FILES['file']['name']; + $new_file_name = str_replace(" ","",$new_file_name); + + $files = $this->purchaseorder_model->getfies($pono); +$fcount = 0; + + foreach ($files as $value) + { + + $lastfile = $value->FilePath; + + + if($lastfile == $new_file_name) + { + $fcount ++; + + + } +} + + + + if($fcount == 0) + { + + if(!empty($new_file_name)) + { $Picture = $this->addfile(); + $filelist =array('PONO'=>$pono,'IGRNO'=>$igr,'FilePath'=>$Picture); + $uploadfiles = $this->purchaseorder_model->insertfile($filelist); + } + } + + if($uploadfiles > 0){ + echo "file updated successfully!"; + } + else + { + echo "No File Choose or File name already Exist"; + } + + } + + function splpodata() + { + + $invno= $this->input->post('param1'); + $invdate= $this->input->post('param2'); + $VehicleNo= $this->input->post('param3'); + $CourierNo= $this->input->post('param4'); + $MaterialRcvdDate =$this->input->post('param5'); + $PONO =$this->input->post('param6'); + $IGRNO =$this->input->post('param7'); + $invdate = date('Y-m-d',strtotime($invdate)); + $MaterialRcvdDate =date('Y-m-d',strtotime($MaterialRcvdDate)); + $CreatedBy = $this->session->userdata('userId'); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddt = $dt->format('Y-m-d H:i:s'); + + $igrMaster = array('VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$invno,'DeliveryChellanDate'=>$invdate, 'MaterialRcvdDate'=>$MaterialRcvdDate,'CourierNo'=>$CourierNo,'UpdateBY'=>$CreatedBy,'UpdatedOn' =>$createddt); + + $igrM = $this->purchaseorder_model->updateigrM($PONO,$IGRNO,$igrMaster); + + if($igrM > 0){ + echo "Updated successfully!"; + } + else{ + echo " Not Updated successfully!"; + } + + +} + +function uploadfile() + { + + + $bill= $this->input->post('param1'); + + $oldfile = $this->input->post('param2'); + + $newfile =$this->input->post('file'); + + $newfile = str_replace(" ","",$newfile); + + if(!empty($_FILES['file']['name'])) + { + $Picture = $this->add(); + }else{ + $Picture = $oldfile ; + } + + $uploadfile = $this->purchaseorder_model->updatefile($bill,$Picture,$oldfile); + + echo "Updated Successfully!"; + + } + +// function addfile($pathname) +// { + +// $picture = ''; +// if(!empty($_FILES[$pathname]['name'])) +// { + +// $config['upload_path'] = 'uploads/BillFiles/'; +// $config['allowed_types'] = '*'; +// $config['file_name'] = $_FILES[$pathname]['name']; + +// //Load upload library and initialize configuration +// $this->load->library('upload',$config); +// $this->upload->initialize($config); +// if($this->upload->do_upload($pathname)) +// { +// $uploadData = $this->upload->data(); +// $picture = $uploadData['file_name']; +// } +// else +// { +// $error = array('error' => $this->upload->display_errors()); +// $picture = ''; +// } +// } +// else +// { +// $picture = ''; +// } + +// return $picture ; +// } + + + //function adfile() + function addfile() + { + $picture = ''; + if(!empty($_FILES['file']['name'])) + { + $config['upload_path'] = 'uploads/BillFiles/'; + $config['allowed_types'] = 'docx|pdf|doc|png|jpg'; + $config['file_name'] = str_replace(" ","",$_FILES['file']['name']); + $this->load->library('upload',$config); + $this->upload->initialize($config); + + if($this->upload->do_upload('file')) + { + $uploadData = $this->upload->data(); + $picture = $uploadData['file_name']; + } + else + { + $error = array('error' => $this->upload->display_errors()); + $picture = ''; + } + + } + else + { + $picture = ''; + } + + return $picture ; + } + } ?> \ No newline at end of file diff --git a/application/controllers/servicepurchaseorder.php b/application/controllers/servicepurchaseorder.php index 8d2a72a5..d1d97a44 100644 --- a/application/controllers/servicepurchaseorder.php +++ b/application/controllers/servicepurchaseorder.php @@ -51,7 +51,7 @@ class servicepurchaseorder extends BaseController // $this->global['pageTitle'] = 'Resico : Update Service PO Status'; $this->global['pageTitle'] = $this->CompanyName.' : Update Service PO Status'; $data['PO'] = $this->purchaseorder_model->GetServicePOListforStatusUpdate(); - $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); + $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); $this->loadViews("statusofservicepurchaseorder", $this->global,$data,Null); } @@ -90,11 +90,10 @@ class servicepurchaseorder extends BaseController ".$SupplierID." ".$MaterialCode." ".$Description." - ".$UOM." - ".$Quantity." - ".$Rate." - - ".$Workstatus." + ".$UOM." + ".$Quantity." + ".$Rate." + ".$Workstatus." "; } @@ -208,11 +207,11 @@ class servicepurchaseorder extends BaseController $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); - $SupplierID = $this->input->post('drpSupplier'); + $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydt'); //$Deliverydt = $this->getDateformat($dt); - $DeliveryOption = $this->input->post('DateRange'); + $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1) { $Deliverydt = ''; @@ -222,28 +221,26 @@ class servicepurchaseorder extends BaseController $Deliverydt = $this->getDateformat($dt); $DeliverySchedule = ''; } - $ModeOfShipment=$this->input->post('addmodeofshipment'); - $SupplierReference=$this->input->post('addsupplierreference'); - $SuppliersOfferNo=$this->input->post('addsupplierofferno'); - $OtherReferences=$this->input->post('addotherreference'); - $Fincap=$this->input->post('addfincap'); - $InsuranceOptions=$this->input->post('insuranceStatus'); - $InsuranceNo=$this->input->post('insuranceNo'); - $ServiceTypeOptions=$this->input->post('PoTypeOptions'); - $DescriptionOfPo = $this->input->post('descofpo'); - $PaymentTerms=$this->input->post('PaymentTerms'); + $ModeOfShipment=$this->input->post('addmodeofshipment'); + $SupplierReference=$this->input->post('addsupplierreference'); + $SuppliersOfferNo=$this->input->post('addsupplierofferno'); + $OtherReferences=$this->input->post('addotherreference'); + $Fincap=$this->input->post('addfincap'); + $InsuranceOptions=$this->input->post('insuranceStatus'); + $InsuranceNo=$this->input->post('insuranceNo'); + $ServiceTypeOptions=$this->input->post('PoTypeOptions'); + $DescriptionOfPo = $this->input->post('descofpo'); + $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); - $POType = $this->input->post('POType'); - + $BudgetType = $this->input->post('Budget'); $SpcialInstruction = $this->input->post('ScopeOfWork'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); - $POStatus = $this->input->post('txtStatus'); - - $CreateBy = $this->session->userdata ( 'userId' ); + $POStatus = $this->input->post('txtStatus'); + $CreateBy = $this->session->userdata ( 'userId' ); $RowCount = $this->input->post('txtRowCount'); $DeletedRow = $this->input->post('txtDeletedRow'); - + $comma_separated = explode(':', $DeletedRow); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); @@ -251,11 +248,11 @@ class servicepurchaseorder extends BaseController $WorkStatus=$this->input->post('workstatus'); // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus, 'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption, 'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus,'POType'=>$POType,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'Description_Of_Service'=>$DescriptionOfPo,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus, 'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption, 'ServiceDescription'=>$SpcialInstruction,'CreatedBy'=>$CreateBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'CreatedDate'=>$createddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus,'POType'=>$POType,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'Description_Of_Service'=>$DescriptionOfPo,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'BudgetType'=>$BudgetType); - $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$ServiceTypeOptions); + $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$ServiceTypeOptions); - $PONO = ''; + $PONO = ''; if(count($POMaster)>0) { $PONO = $POMaster[0]['PONO']; @@ -266,7 +263,7 @@ class servicepurchaseorder extends BaseController for ($i = 1; $i <= $RowCount; $i++) { - $Per = $this->input->post('per'.$i); + $Per = $this->input->post('per'.$i); $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Reqnumber = $this->input->post('Reqnumber'.$i); @@ -280,7 +277,7 @@ class servicepurchaseorder extends BaseController $CostCenter = $this->input->post('costCode'.$i); $ServiceFrequency=$this->input->post('Frequency'.$i); $ItemDescription = $this->input->post('ItemDescription'.$i); - $OtherAmt = $this->input->post('OtherAmt'.$i); + $OtherAmt = $this->input->post('OtherAmt'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $SkipInsert = "False"; @@ -304,12 +301,12 @@ class servicepurchaseorder extends BaseController $RetItemNo = $this->requistion_model->getItemNumber($Reqnumber,$MaterialCode); - $ItemNo = ''; + $ItemNo = ''; if(count($RetItemNo)>0) { $ItemNo = $RetItemNo[0]['ItemNo']; } - + $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$CreateBy,'CreatedDate'=>$createddt,'CostCenterCode'=>$CostCenter,'ServiceFrequency'=>$ServiceFrequency,'ServiceMaterialDescription'=>$ItemDescription,'Per'=>$Per,'ItemNo'=>$ItemNo); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); @@ -320,7 +317,6 @@ class servicepurchaseorder extends BaseController { $LineItemNo = $POLineItem[0]['LineItemNo']; } - //echo $LineItemNo; if(trim($POType) == SERVICE ) { @@ -330,48 +326,58 @@ class servicepurchaseorder extends BaseController $ServiceTax = $this->purchaseorder_model->addServiceTax($ServiceTaxList); } - } + } } echo 'Service Purchase Order Created Successfully!The PO NO Is: '.$PONO; } + //update service po function UpdateServicePurchaseOrder() { $PONO =$this->input->post('txtPONO'); - //echo $PONO; + $newsup=$this->input->post('newsup'); + // $newSupId = split("[ - ]+", $newsup); + $newSupId = preg_split('[-]',$newsup); + $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); - + + $b4supplier=$this->input->post('b4supplier'); + $b4date=$this->input->post('b4podate'); + $b4podate = $this->getDateformat($b4date); + $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('txtDeliveryAddress'); $dt = $this->input->post('Deliverydt'); - $DeliveryOption = $this->input->post('DateRange'); + $DeliveryOption = $this->input->post('DateRange'); if($DeliveryOption==1){ $Deliverydt = ''; - $DeliverySchedule = $this->input->post('Scheduleby'); + $DeliverySchedule = $this->input->post('Scheduleby'); } else{ $Deliverydt = $this->getDateformat($dt); - $DeliverySchedule = ''; + $DeliverySchedule = ''; } - $ModeOfShipment=$this->input->post('editmodeofshipment'); - $SupplierReference=$this->input->post('editsupplierreference'); - $SuppliersOfferNo=$this->input->post('editsupplierofferno'); - $OtherReferences=$this->input->post('editotherreference'); - $Fincap=$this->input->post('editfincap'); - $InsuranceOptions=$this->input->post('insuranceStatus'); - $InsuranceNo=$this->input->post('insuranceNo'); - $ServiceTypeOptions=$this->input->post('PoTypeOptions'); - $DescriptionOfPo = $this->input->post('editdescofpo'); + $ModeOfShipment=$this->input->post('editmodeofshipment'); + $SupplierReference=$this->input->post('editsupplierreference'); + $SuppliersOfferNo=$this->input->post('editsupplierofferno'); + $OtherReferences=$this->input->post('editotherreference'); + $Fincap=$this->input->post('editfincap'); + $InsuranceOptions=$this->input->post('insuranceStatus'); + $InsuranceNo=$this->input->post('insuranceNo'); + $ServiceTypeOptions=$this->input->post('PoTypeOptions'); + $DescriptionOfPo = $this->input->post('editdescofpo'); - $PaymentTerms=$this->input->post('PaymentTerms'); + $PaymentTerms=$this->input->post('PaymentTerms'); $OtherPayment=$this->input->post('Otherpayment'); $POType = $this->input->post('POType'); + + $BudgetType = $this->input->post('Budget'); $SpcialInstruction = $this->input->post('ScopeofWork'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummary'); @@ -388,32 +394,69 @@ class servicepurchaseorder extends BaseController // PO Master - $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'Description_Of_Service'=>$DescriptionOfPo,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions); + $POList = array('SupplierID'=>$SupplierID, 'TotalOrderValue'=>$TotalOrderValueSummary,'PODate'=>$PODate,'Status'=>$POStatus,'DeliverySchedule'=>$DeliverySchedule,'DeliveryOption'=>$DeliveryOption,'ServiceDescription'=>$SpcialInstruction,'UpdateBY'=>$updatedBy,'DeliveryAddress'=>$DeliveryAddr,'DeliveryDate'=>$Deliverydt,'UpdatedOn'=>$updateddt,'PaymentTerms'=>$PaymentTerms,'ServiceWorkStatus'=>$WorkStatus,'PaymentOtherDescription'=>$OtherPayment,'Supplier_Reference'=>$SupplierReference,'Mode_Of_Shipment'=>$ModeOfShipment,'Supplier_Offer_No'=>$SuppliersOfferNo,'Other_Reference'=>$OtherReferences,'Fincap'=>$Fincap,'Description_Of_Service'=>$DescriptionOfPo,'InsuranceStatus'=>$InsuranceOptions,'InsuranceNumber'=>$InsuranceNo,'POSubType'=>$ServiceTypeOptions,'BudgetType'=>$BudgetType); $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); $LineItemStatus = REQITEM_NEW; + + + if($PODate != $b4podate ) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>'-','UpdateBy'=>$updatedBy,'OldValue'=>$b4podate,'NewValue'=>$PODate,'Entity'=>'PO DateChanged'); + + $this->purchaseorder_model->insertlogpo($logpo); + } + + if(!empty($newSupId[0] )) + { + if($newSupId[0] != $b4supplier) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>'-','UpdateBy'=>$updatedBy,'OldValue'=>$b4supplier,'NewValue'=>$newsup,'Entity'=>'Supplier Changed'); + $this->purchaseorder_model->insertlogpo($logpo); + } + } for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); + + $b4qty=$this->input->post('b4qty'.$i); + $b4rate=$this->input->post('b4rate'.$i); + $Reqnumber = $this->input->post('Reqnumber'.$i); $itemRate = $this->input->post('itemRate'.$i); $Cgst = $this->input->post('Cgst'.$i); - $Sgst = $this->input->post('Sgst'.$i); - $Igst = $this->input->post('Igst'.$i); - $AfterCgst = $this->input->post('AfterCgst'.$i); - $AfterSgst = $this->input->post('AfterSgst'.$i); - $AfterIgst = $this->input->post('AfterIgst'.$i); - $CostCenter = $this->input->post('costCode'.$i); - $ServiceFrequency=$this->input->post('Frequency'.$i); + $Sgst = $this->input->post('Sgst'.$i); + $Igst = $this->input->post('Igst'.$i); + $AfterCgst = $this->input->post('AfterCgst'.$i); + $AfterSgst = $this->input->post('AfterSgst'.$i); + $AfterIgst = $this->input->post('AfterIgst'.$i); + $CostCenter = $this->input->post('costCode'.$i); + $ServiceFrequency=$this->input->post('Frequency'.$i); $POLineItemNo = $this->input->post('LineItemNo'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$i); $ItemDescription = $this->input->post('ItemDescription'.$i); - $OtherAmt = $this->input->post('OtherAmt'.$i); - $Per = $this->input->post('per'.$i); - + $OtherAmt = $this->input->post('OtherAmt'.$i); + $Per = $this->input->post('per'.$i); + + $ReqDetails = array('Quantity'=>$Quantity,'UpdatedBy'=>$updatedBy,'UpdatedOn'=>$updateddt); + + $this->purchaseorder_model->updateReqDetails($Reqnumber,$MaterialCode,$ReqDetails); + + if($Quantity != $b4qty) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'OldValue'=>$b4qty,'NewValue'=>$Quantity,'Entity'=>'Quantity Changed'); + $this->purchaseorder_model->insertlogpo($logpo); + } + + if($itemRate != $b4rate) + { + $logpo =array('PONO'=>$PONO,'LineItemNo'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'OldValue'=>$b4rate,'NewValue'=>$itemRate,'Entity'=>'Rate Changed'); + $this->purchaseorder_model->insertlogpo($logpo); + } + $POLineItem = array(); $LineItemNo = ''; $SkipInsert = "False"; @@ -490,13 +533,146 @@ class servicepurchaseorder extends BaseController } echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO; } - function pageNotFound() - { - $this->global['pageTitle'] = 'Resico : 404 - Page Not Found'; - $this->global['pageTitle'] = $this->CompanyName.' : Edit Service Purchase order form'; - - $this->loadViews("404", $this->global, NULL, NULL); + +function uploadfile() +{ + $bill= $this->input->post('param1'); + $oldfile= $this->input->post('param2'); + // $new_file_name =$_FILES['file']['name']; + $new_file_name =$_FILES['file']['name']; + $new_file_name = str_replace(" ","",$new_file_name); + if(!empty($new_file_name)) + { + $Picture = $this->add(); + } + + $uploadfile = $this->purchaseorder_model->updatefile($bill,$Picture,$oldfile); + + if($uploadfile > 0){ + echo "file updated successfully!"; } + else{ + echo "file not updated!"; + } + } + + function add() + { + $picture = ''; + if(!empty($_FILES['file']['name'])) + { + $config['upload_path'] = 'uploads/BillFiles/'; + $config['allowed_types'] = 'docx|pdf|doc|png|jpg'; + //$config['file_name'] = $_FILES['file']['name']; + $config['file_name'] = str_replace(" ","",$_FILES['file']['name']); + //print_r($config) ; + //Load upload library and initialize configuration + $this->load->library('upload',$config); + $this->upload->initialize($config); + if($this->upload->do_upload('file')) + { + $uploadData = $this->upload->data(); + $picture = $uploadData['file_name']; + } + else + { + $error = array('error' => $this->upload->display_errors()); + $picture = ''; + } + } + else + { + $picture = ''; + } + + return $picture ; + } + +/*-----------------------------------*/ + + function addfileuplod() + { + + $pono= $this->input->post('PONO'); + + $new_file_name =$_FILES['file']['name']; + + $new_file_name = str_replace(" ","",$new_file_name); + + $files = $this->purchaseorder_model->getfies($pono); + + $fcount = 0; + + foreach ($files as $value) + { + + $lastfile = $value->FilePath; + if($lastfile == $new_file_name) + { + $fcount++; + } + } + $upfile=''; + + if($fcount == 0) + { + if(!empty($new_file_name)) + { + $Picture = $this->adfile(); + $filelist =array('PONO'=>$pono,'FilePath'=>$Picture); + $upfile = $this->purchaseorder_model->insertfile($filelist); + } + + } + if($upfile > 0){ + echo "file updated successfully!"; + } + else{ + echo " No File Choose or File name already Exist"; + } +} + +function adfile() +{ + $picture = ''; + if(!empty($_FILES['file']['name'])) + { + $config['upload_path'] = 'uploads/BillFiles/'; + $config['allowed_types'] = 'docx|pdf|doc|png|jpg'; + // $config['file_name'] = $_FILES['file']['name']; + $config['file_name'] = str_replace(" ","",$_FILES['file']['name']); + //print_r($config);die; + //Load upload library and initialize configuration + $this->load->library('upload',$config); + $this->upload->initialize($config); + + if($this->upload->do_upload('file')) + { + $uploadData = $this->upload->data(); + $picture = $uploadData['file_name']; + } + else + { + $error = array('error' => $this->upload->display_errors()); + $picture = ''; + } + + } + else + { + $picture = ''; + } + + return $picture ; +} + +function pageNotFound() + { + //$this->global['pageTitle'] = 'Resico : 404 - Page Not Found'; + $this->global['pageTitle'] = $this->CompanyName.' : Edit Service Purchase order form'; + + $this->loadViews("404", $this->global, NULL, NULL); + } } ?> diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index 35a6a8fb..4ce9fd9c 100755 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -23,68 +23,80 @@ class purchaseorder_model extends CI_Model $query = $this->db->get(); return $query->result(); } - - function updateReqDetails($Reqnumber,$MaterialCode,$ReqDetail){ - $this->db->where('ReqNo',$Reqnumber); - $this->db->where('MaterialCode',$MaterialCode); - // $this->db->where('Quantity',$Quantity); - $this->db->update('T_Requestion_Details',$ReqDetail); - $r = $this->db->affected_rows(); - return $r; + function getfies($pono) + { + + $this->db->select('*'); + + $this->db->from('T_PurchaseOrder_BillUpload bill'); + + $this->db->where('PONO',$pono); + + $query = $this->db->get(); + + return $query->result(); } - - function getIGRDetails($PONO) - { - $subQuery ='select IGRM.PONO,IGRD.IGRItemNo,IGRD.IGRNO from +function updateReqDetails($Reqnumber,$MaterialCode,$ReqDetail){ +$this->db->where('ReqNo',$Reqnumber); +$this->db->where('MaterialCode',$MaterialCode); +$this->db->update('T_Requestion_Details',$ReqDetail); +$r = $this->db->affected_rows(); +return $r; +} + + +//function IGRDetailsupdate($PONO) +function getIGRDetails($PONO) +{ + +$subQuery ='select IGRM.PONO,IGRD.IGRItemNo,IGRD.IGRNO from T_IGR_Master IGRM join T_IGR_Details IGRD on IGRD.IGRNO = IGRM.IGRNO Where IGRM.PONO = ? '; - - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result_array(); + +$query = $this->db->query($subQuery,array($PONO)); + +return $query->result_array(); - } +} - function updateIGR($IGRItemNo,$IGRDs) //,$MaterialCode, - { - - $this->db->where('IGRItemNo',$IGRItemNo); //,'IGRNO',$IGRNO,'MaterialCode',$MaterialCode); - //$this->db->where('IGRNO',$IGRNO); - // $this->db->where('MaterialCode',$MaterialCode); - $this->db->update('T_IGR_Details',$IGRDs); - - $r = $this->db->affected_rows(); +function updateIGR($IGRItemNo,$IGRDs) //,$MaterialCode, +{ - return $r; - } +$this->db->where('IGRItemNo',$IGRItemNo); //,'IGRNO',$IGRNO,'MaterialCode',$MaterialCode); +$this->db->update('T_IGR_Details',$IGRDs); + +$r = $this->db->affected_rows(); + +return $r; +} - function fileupload($myfile) - { - $this->db->insert('T_PurchaseOrder_BillUpload',$myfile); - $myfile=$this->db->affected_rows(); - return $myfile; - } +function fileupload($myfile) +{ +$this->db->insert('T_PurchaseOrder_BillUpload',$myfile); +$myfile=$this->db->affected_rows(); +return $myfile; +} - function getfunction($pono) - { - $this->db->distinct(); - $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); - $this->db->from('T_PurchaseOrder_BillUpload bill'); - $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); - $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); - $this->db->where('bill.PONO',$pono); - //$this->db->or_where('pom.status',SPECIAL_PO); - $this->db->group_by('bill.BillNo'); +function getfunction($pono) +{ +$this->db->distinct(); + $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); + $this->db->from('T_PurchaseOrder_BillUpload bill'); + $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); + $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); + // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); + $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); + $this->db->where('bill.PONO',$pono); +//$this->db->or_where('pom.status',SPECIAL_PO); +$this->db->group_by('bill.BillNo'); @@ -100,868 +112,863 @@ Where IGRM.PONO = ? '; // // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); // $this->db->where('mstr.PONO',$pono); - - $query = $this->db->get(); - - return $query->result(); - } + + $query = $this->db->get(); + + return $query->result(); +} function getfunctionr($pono) - { - $this->db->distinct(); - // $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); - // $this->db->from('T_PurchaseOrder_BillUpload bill'); - // $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); - // $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); - // $this->db->where('bill.PONO',$pono); - // //$this->db->or_where('pom.status',SPECIAL_PO); - // $this->db->group_by('bill.BillNo'); +{ +$this->db->distinct(); +// $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); +// $this->db->from('T_PurchaseOrder_BillUpload bill'); +// $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); +// $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); +// // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); +// $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); +// $this->db->where('bill.PONO',$pono); +// //$this->db->or_where('pom.status',SPECIAL_PO); +// $this->db->group_by('bill.BillNo'); - - $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo, + + $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo, mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.MaterialRcvdDate, mstr.CourierNo,pom.Status,pom.POType'); //,bill.BillNo,bill.FilePath, - $this->db->from('T_IGR_Master mstr'); - //$this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left'); - $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); - $this->db->where('mstr.PONO',$pono); - - $query = $this->db->get(); - - return $query->result(); - } + $this->db->from('T_IGR_Master mstr'); + //$this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left'); + $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); + // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); + $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); + $this->db->where('mstr.PONO',$pono); + + $query = $this->db->get(); + + return $query->result(); +} function getbillfiesr($pono) - { - $this->db->distinct(); - // $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); - // $this->db->from('T_PurchaseOrder_BillUpload bill'); - // $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); - // $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - // $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); - // $this->db->where('bill.PONO',$pono); - // //$this->db->or_where('pom.status',SPECIAL_PO); - // $this->db->group_by('bill.BillNo'); +{ +$this->db->distinct(); +// $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType'); +// $this->db->from('T_PurchaseOrder_BillUpload bill'); +// $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left'); +// $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); +// // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); +// $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO'); +// $this->db->where('bill.PONO',$pono); +// //$this->db->or_where('pom.status',SPECIAL_PO); +// $this->db->group_by('bill.BillNo'); - - $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo, + + $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo, mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.MaterialRcvdDate, mstr.CourierNo,bill.BillNo,bill.FilePath,pom.Status,pom.POType'); - $this->db->from('T_IGR_Master mstr'); - $this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left'); - $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); - // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); - $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); - $this->db->where('mstr.PONO',$pono); - - $query = $this->db->get(); - - return $query->result(); - } + $this->db->from('T_IGR_Master mstr'); + $this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left'); + $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left'); + // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode'); + $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO'); + $this->db->where('mstr.PONO',$pono); + + $query = $this->db->get(); + + return $query->result(); +} - function GetPODetailforBillingServicePO($PONO) - { - - $subQuery ='select mast.ReqNo,mast.ReqDate,supp.SupplierName,PODate,st.StatusName as WorkStatus,ServiceWorkStatus,POMast.PaymentTerms, - POMast.ServiceWorkStatus,LineItem.*,mat.MaterialName,mat.UOM,emp.FirstName,emp.LastName,POMast.TotalOrderValue - from T_PurchaseOrder_Master POMast - join T_PurchaseOrder_LineItem LineItem on LineItem.PONO = POMast.PONO - join T_SupplierDetailsN supp on supp.SupplierID = POMast.SupplierID - join T_MaterialMaster mat on mat.MaterialCode = LineItem.MaterialCode - join T_Status Stat on Stat.StatusCode = POMast.Status - join T_Status st on st.StatusCode = POMast.ServiceWorkStatus - join T_Requestion_Master mast on mast.ReqNo = LineItem.ReqNo - join tbl_users users on users.userId = mast.CreatedBy - join T_Employee_Details emp on emp.EmpID = users.EmpID - where POMast.POType=? and POMast.PONO=?'; +function GetPODetailforBillingServicePO($PONO) +{ - $query = $this->db->query($subQuery,array(SERVICE,$PONO)); - - return $query->result_array(); - - } - - function GetServicePOListforBilling() - { - $subQuery ='select POMast.PONO,supp.SupplierName,PODate,POMast.PaymentTerms,POMast.ServiceWorkStatusRemarks,StatusName,POMast.CapitalRange,POType, - LineItem.*,mat.MaterialName,mat.UOM,emp.FirstName,emp.LastName,Tax.TotalValue,Cost.CostCenterName,AdvanceAmount - ,Dept.DepartmentName from T_PurchaseOrder_Master POMast - join T_PurchaseOrder_LineItem LineItem on LineItem.PONO = POMast.PONO - join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - left join T_PurchaseOrder_AdvanceRequest PUADV on POMast.PONO=PUADV.PONO - join T_SupplierDetailsN supp on supp.SupplierID = POMast.SupplierID - join T_MaterialMaster mat on mat.MaterialCode = LineItem.MaterialCode - join T_Status Stat on Stat.StatusCode = POMast.Status - join T_Requestion_Master mast on mast.ReqNo = LineItem.ReqNo - join tbl_users users on users.userId = POMast.CreatedBy - left join T_Employee_Details emp on emp.EmpID = mast.Requestedby - join T_DepartmentDetails Dept on Dept.DEPCode = mast.RequestedDept - join T_CostCenter_Master Cost on Cost.CostCenterCode=LineItem.CostCenterCode - where POMast.POType=? and ServiceWorkStatus=? order by POMast.UpdatedOn desc'; - - $query = $this->db->query($subQuery,array(SERVICE,SERVICE_COMPLETED)); +$subQuery ='select mast.ReqNo,mast.ReqDate,supp.SupplierName,PODate,st.StatusName as WorkStatus,ServiceWorkStatus,POMast.PaymentTerms, + POMast.ServiceWorkStatus,LineItem.*,mat.MaterialName,mat.UOM,emp.FirstName,emp.LastName,POMast.TotalOrderValue + from T_PurchaseOrder_Master POMast + join T_PurchaseOrder_LineItem LineItem on LineItem.PONO = POMast.PONO + join T_SupplierDetailsN supp on supp.SupplierID = POMast.SupplierID + join T_MaterialMaster mat on mat.MaterialCode = LineItem.MaterialCode + join T_Status Stat on Stat.StatusCode = POMast.Status + join T_Status st on st.StatusCode = POMast.ServiceWorkStatus + join T_Requestion_Master mast on mast.ReqNo = LineItem.ReqNo + join tbl_users users on users.userId = mast.CreatedBy + join T_Employee_Details emp on emp.EmpID = users.EmpID + where POMast.POType=? and POMast.PONO=?'; - //print_r( $this->db->last_query()); - return $query->result(); +$query = $this->db->query($subQuery,array(SERVICE,$PONO)); - } - - /** - * This function is used to get the user listing count - * @param string $searchText : This is optional search text - * @return number $count : This is row count - */ - function purchaseorderListingCount() - { - $this->db->distinct(); - $this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Req.ReqType,DeliveryDate'); - $this->db->from('T_PurchaseOrder_Master POMast'); - $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); - $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); - $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); - $this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); - // print_r( $this->db->last_query()); - $query = $this->db->get(); - - return count($query->result()); - } - - /** - * This function is used to get the user listing count - * @param string $searchText : This is optional search text - * @param number $page : This is pagination offset - * @param number $segment : This is pagination limit - * @return array $result : This is result - */ - -function purchaseorderListing($forwhat='') - { - $this->db->distinct(); - $this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Stat.StatusCode,POMast.POType as ReqType,DeliveryDate,DeliverySchedule,DeliveryOption,POMast.CapitalRange'); - $this->db->from('T_PurchaseOrder_Master POMast'); - $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); - $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); - $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); - $this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); - if($forwhat=='amendment') - { - $this->db->where('POMast.Status',PO_RELEASED); - } - else - { - $this->db->where('POMast.Status !=',PO_AMENDED); - // $this->db->order_by('POMast.Status !=',PO_AMENDED); - } - $this->db->order_by('POMast.UpdatedOn','desc'); - $query = $this->db->get(); - //print_r( $this->db->last_query()); - $result = $query->result(); - return $result; - } - - /** - * This function is used to get the SupplierID and SupplierName information - * @return array $result : This is result of the query - */ - function getSupplierName($supID='') - { - $this->db->select('SupplierID, SupplierName,Address,PaymentID'); - $this->db->from('T_SupplierDetailsN'); - $this->db->where('IsActive', 1); - if($supID != '') - { - $this->db->where('SupplierID',$supID); - } - //$this->db->where('roleId !=', 1); - $query = $this->db->get(); - - return $query->result(); - } - /** - * This function is used to get the userId information - * @return array $result : This is result of the query - */ - function getusers() - { - $this->db->select('userId, name'); - $this->db->from('tbl_users'); - //$this->db->where('roleId !=', 1); - $query = $this->db->get(); - - return $query->result(); - } +return $query->result_array(); +} - function getqtycheck($PONO) - { - $this->db->select('IsQualityChkReqired'); - $this->db->from('T_PurchaseOrder_Master'); - $this->db->where('PONO',$PONO); - $query = $this->db->get(); - - return $query->result(); +function GetServicePOListforBilling() +{ +$subQuery ='select POMast.PONO,supp.SupplierName,PODate,POMast.PaymentTerms,POMast.ServiceWorkStatusRemarks,StatusName,POMast.CapitalRange,POType, + LineItem.*,mat.MaterialName,mat.UOM,emp.FirstName,emp.LastName,Tax.TotalValue,Cost.CostCenterName,AdvanceAmount + ,Dept.DepartmentName from T_PurchaseOrder_Master POMast + join T_PurchaseOrder_LineItem LineItem on LineItem.PONO = POMast.PONO + join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + left join T_PurchaseOrder_AdvanceRequest PUADV on POMast.PONO=PUADV.PONO + join T_SupplierDetailsN supp on supp.SupplierID = POMast.SupplierID + join T_MaterialMaster mat on mat.MaterialCode = LineItem.MaterialCode + join T_Status Stat on Stat.StatusCode = POMast.Status + join T_Requestion_Master mast on mast.ReqNo = LineItem.ReqNo + join tbl_users users on users.userId = POMast.CreatedBy + left join T_Employee_Details emp on emp.EmpID = mast.Requestedby + join T_DepartmentDetails Dept on Dept.DEPCode = mast.RequestedDept + join T_CostCenter_Master Cost on Cost.CostCenterCode=LineItem.CostCenterCode + where POMast.POType=? and ServiceWorkStatus=? order by POMast.UpdatedOn desc'; + +$query = $this->db->query($subQuery,array(SERVICE,SERVICE_COMPLETED)); + +//print_r( $this->db->last_query()); +return $query->result(); + +} - } /** - * This function is used to get the Raw Material information - * @return array $result : This is result of the query - */ - function getRawPOMaterialList($ReqNo,$IsArray='') - { - - $result = $this->db-> query("CALL P_GET_REQUISTIONLIST('".$ReqNo."')") or die(mysql_error()); - - $result ->next_result(); - - if ($result->num_rows > 0) - { - - if($IsArray != '') - { - return $result->result_array(); - } - else - { - return $result->result(); - } - } - - } - - /** - *This Function to get the List of Requistion which require to create PO - */ - function getAllRequistionListToCreatePO() - { - $result = $this->db-> query("CALL P_PURCHASEORDER_DETAILS()") or die(mysql_error()); - - $result ->next_result(); - - - if ($result->num_rows > 0) - { - - return $result->result(); - } - } - - /** - * This function is used to get the Raw Material information - * @return array $result : This is result of the query - */ - function getRawMaterialList($MatType='',$ReqNoList='') - { - - $this->db->select('ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity'); - $this->db->from('T_Requestion_Details Req'); - $this->db->join('T_MaterialMaster mat', 'Req.MaterialCode = mat.MaterialCode'); - $this->db->where('mat.MaterialType', $MatType); - $this->db->where_in('Req.ReqNo', $ReqNoList); - - $query = $this->db->get(); - //print_r($this->db->last_query()); - return $query->result(); - } - /** - * This function is used to get the Raw Material information - * @return array $result : This is result of the query - */ - function getRawMaterialListForPO($MatType='',$ReqNo='') - { - $subQuery ='SELECT ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity - FROM T_Requestion_Details Req - JOIN T_MaterialMaster mat ON Req.MaterialCode = mat.MaterialCode - where mat.MaterialType = ? - AND Req.ReqNo = ? - AND mat.MaterialCode != (SELECT MaterialCode FROM T_PurchaseOrder_LineItem WHERE ReqNo =? - )'; +* This function is used to get the user listing count +* @param string $searchText : This is optional search text +* @return number $count : This is row count +*/ +function purchaseorderListingCount() +{ +$this->db->distinct(); +$this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Req.ReqType,DeliveryDate'); +$this->db->from('T_PurchaseOrder_Master POMast'); +$this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); +$this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); +$this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); +$this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); +// print_r( $this->db->last_query()); +$query = $this->db->get(); - $query = $this->db->query($subQuery,array($MatType,$ReqNo,$ReqNo)); - - return $query->result_array(); - - - } - //Import PO Available Budget Amount - function GetAvailableImportBudgetAmount($CostCode,$Year,$BudgetType) - { - $subQuery='select BudgetAmount,(select ifnull(sum((Quantity*Rate*ExchangeRate)),0)as TValue from T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master Mast on Mast.PONO=LineItem.PONO where POType=? - and CostCenterCode=? and Mast.status not in (?) )as Totalvalue from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and BudgetYear=? and BudgetType=?'; - $query = $this->db->query($subQuery,array($BudgetType,$CostCode,PO_AMENDED,$CostCode,$Year,$BudgetType)); - //print_r($this->db->last_query()); - return $query->result_array(); +return count($query->result()); +} + +/** +* This function is used to get the user listing count +* @param string $searchText : This is optional search text +* @param number $page : This is pagination offset +* @param number $segment : This is pagination limit +* @return array $result : This is result +*/ + +function purchaseorderListing($forwhat='') +{ +$this->db->distinct(); +$this->db->select('POMast.PONO,supp.SupplierName,TotalOrderValue,PODate,Stat.StatusName,Stat.StatusCode,POMast.POType as ReqType,DeliveryDate,DeliverySchedule,DeliveryOption,POMast.CapitalRange'); +$this->db->from('T_PurchaseOrder_Master POMast'); +$this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); +$this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); +$this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); +$this->db->join('T_Requestion_Master Req', 'Req.ReqNo = LineItem.ReqNo'); +if($forwhat=='amendment') +{ +$this->db->where('POMast.Status',PO_RELEASED); +} +else +{ + $this->db->where('POMast.Status !=',PO_AMENDED); + // $this->db->order_by('POMast.Status !=',PO_AMENDED); +} +$this->db->order_by('POMast.UpdatedOn','desc'); +$query = $this->db->get(); +//print_r( $this->db->last_query()); +$result = $query->result(); +return $result; +} + +/** +* This function is used to get the SupplierID and SupplierName information +* @return array $result : This is result of the query +*/ +function getSupplierName($supID='') +{ +$this->db->select('SupplierID, SupplierName,Address,PaymentID'); +$this->db->from('T_SupplierDetailsN'); +$this->db->where('IsActive', 1); +if($supID != '') +{ + $this->db->where('SupplierID',$supID); +} +//$this->db->where('roleId !=', 1); +$query = $this->db->get(); + +return $query->result(); +} +/** +* This function is used to get the userId information +* @return array $result : This is result of the query +*/ +function getusers() +{ +$this->db->select('userId, name'); +$this->db->from('tbl_users'); +//$this->db->where('roleId !=', 1); +$query = $this->db->get(); + +return $query->result(); +} - } - //get available budget for capital - function GetAvailableCapitalBudgetAmount($CostCode,$Year,$BudgetType) - { - - $subQuery ='select BudgetAmount, (select ifnull(sum(IF(POMaster.ExchangeRate>0,Quantity*Rate*POMaster.ExchangeRate,Quantity*Rate-tax.Afterdiscountval)),0) as Totalvalue from - T_PurchaseOrder_LineItem Item join T_Requestion_Master mast - on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POMaster on POMaster.PONO=Item.PONO left join T_Service_Tax tax on tax.LineItemNo=Item.LineItemNo where Item.CostCenterCode=? and POMaster.POType=? and POMaster.status not in (?))as Totalvalue - from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and - BudgetYear = ? and BudgetType =?'; - - $query = $this->db->query($subQuery,array($CostCode,$BudgetType,PO_AMENDED,$CostCode,$Year,$BudgetType)); - - return $query->result_array(); +function getqtycheck($PONO) +{ +$this->db->select('IsQualityChkReqired'); +$this->db->from('T_PurchaseOrder_Master'); +$this->db->where('PONO',$PONO); +$query = $this->db->get(); - } - function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType) - { - $subQuery ='select distinct Bud.CostCenterCode,BudgetAmount, case WHEN BudgetType = ? then (select - round(ifnull(sum((Quantity*Rate)-ifnull(tax.AfterDiscount,0)),0),2) as - Totalvalue from T_PurchaseOrder_LineItem Item join T_Requestion_Master mast - on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POM on POM.PONO = Item.PONO left join T_Revenue_Tax tax on - tax.LineItemNo = Item.LineItemNo - where Item.CostCenterCode=? and POM.POType=? and POM.status not in (?)) else (select - round(ifnull(sum(Quantity*Rate*ifnull(case when mast.NumberOfService=? - then 1 else mast.NumberOfService end ,1)),0),2) as - Totalvalue from T_PurchaseOrder_LineItem Item join T_Requestion_Master mast - on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POM on POM.PONO = Item.PONO left join T_Requestion_Master ReqMas on ReqMas.ReqNo= Item.ReqNo - where Item.CostCenterCode=? and POM.POType=? and POM.status not in (?) ) end as Totalvalue - from T_CostCenter_Budget Bud join T_CostCenter_Departments dept on dept.CostCenterCode = Bud.CostCenterCode - where Bud.CostCenterCode=? and - BudgetYear = ? and BudgetType =?'; - - - $query = $this->db->query($subQuery,array(REVENUE,$CostCode,$BudgetType,PO_AMENDED,'0.00',$CostCode,$BudgetType,PO_AMENDED,$CostCode,$Year,$BudgetType)); - - - //print_r($this->db->last_query()); - return $query->result_array(); - - } - - //to get POTYpe from ReqNo +return $query->result(); + +} +/** +* This function is used to get the Raw Material information +* @return array $result : This is result of the query +*/ +function getRawPOMaterialList($ReqNo,$IsArray='') +{ + +$result = $this->db-> query("CALL P_GET_REQUISTIONLIST('".$ReqNo."')") or die(mysql_error()); + +$result ->next_result(); + +if ($result->num_rows > 0) +{ + + if($IsArray != '') + { + return $result->result_array(); + } + else + { + return $result->result(); + } +} + +} + +/** +*This Function to get the List of Requistion which require to create PO +*/ +function getAllRequistionListToCreatePO() +{ +$result = $this->db-> query("CALL P_PURCHASEORDER_DETAILS()") or die(mysql_error()); + +$result ->next_result(); + + +if ($result->num_rows > 0) +{ + + return $result->result(); +} +} + +/** +* This function is used to get the Raw Material information +* @return array $result : This is result of the query +*/ +function getRawMaterialList($MatType='',$ReqNoList='') +{ + +$this->db->select('ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity'); +$this->db->from('T_Requestion_Details Req'); +$this->db->join('T_MaterialMaster mat', 'Req.MaterialCode = mat.MaterialCode'); +$this->db->where('mat.MaterialType', $MatType); +$this->db->where_in('Req.ReqNo', $ReqNoList); + +$query = $this->db->get(); +//print_r($this->db->last_query()); +return $query->result(); +} +/** +* This function is used to get the Raw Material information +* @return array $result : This is result of the query +*/ +function getRawMaterialListForPO($MatType='',$ReqNo='') +{ +$subQuery ='SELECT ReqNo,Req.MaterialCode,MaterialName,UOM,Req.Quantity + FROM T_Requestion_Details Req + JOIN T_MaterialMaster mat ON Req.MaterialCode = mat.MaterialCode + where mat.MaterialType = ? + AND Req.ReqNo = ? + AND mat.MaterialCode != (SELECT MaterialCode FROM T_PurchaseOrder_LineItem WHERE ReqNo =? + )'; + +$query = $this->db->query($subQuery,array($MatType,$ReqNo,$ReqNo)); + +return $query->result_array(); + + +} +//Import PO Available Budget Amount +function GetAvailableImportBudgetAmount($CostCode,$Year,$BudgetType) +{ +$subQuery='select BudgetAmount,(select ifnull(sum((Quantity*Rate*ExchangeRate)),0)as TValue from T_PurchaseOrder_LineItem LineItem + join T_PurchaseOrder_Master Mast on Mast.PONO=LineItem.PONO where POType=? + and CostCenterCode=? and Mast.status not in (?) )as Totalvalue from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and BudgetYear=? and BudgetType=?'; +$query = $this->db->query($subQuery,array($BudgetType,$CostCode,PO_AMENDED,$CostCode,$Year,$BudgetType)); +//print_r($this->db->last_query()); +return $query->result_array(); + + +} +//get available budget for capital +function GetAvailableCapitalBudgetAmount($CostCode,$Year,$BudgetType) + { + + $subQuery ='select BudgetAmount, (select ifnull(sum(IF(POMaster.ExchangeRate>0,Quantity*Rate*POMaster.ExchangeRate,Quantity*Rate-tax.Afterdiscountval)),0) as Totalvalue from + T_PurchaseOrder_LineItem Item join T_Requestion_Master mast + on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POMaster on POMaster.PONO=Item.PONO left join T_Service_Tax tax on tax.LineItemNo=Item.LineItemNo where Item.CostCenterCode=? and POMaster.POType=? and POMaster.status not in (?))as Totalvalue + from T_CostCenter_Budget Bud where Bud.CostCenterCode=? and + BudgetYear = ? and BudgetType =?'; + + $query = $this->db->query($subQuery,array($CostCode,$BudgetType,PO_AMENDED,$CostCode,$Year,$BudgetType)); + +return $query->result_array(); + + } +function GetAvailableBudgetAmount($CostCode,$Year,$BudgetType) +{ +$subQuery ='select distinct Bud.CostCenterCode,BudgetAmount, case WHEN BudgetType = ? then (select + round(ifnull(sum((Quantity*Rate)-ifnull(tax.AfterDiscount,0)),0),2) as + Totalvalue from T_PurchaseOrder_LineItem Item join T_Requestion_Master mast + on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POM on POM.PONO = Item.PONO left join T_Revenue_Tax tax on + tax.LineItemNo = Item.LineItemNo + where Item.CostCenterCode=? and POM.POType=? and POM.status not in (?)) else (select + round(ifnull(sum(Quantity*Rate*ifnull(case when mast.NumberOfService=? + then 1 else mast.NumberOfService end ,1)),0),2) as + Totalvalue from T_PurchaseOrder_LineItem Item join T_Requestion_Master mast + on mast.ReqNo = Item.ReqNo join T_PurchaseOrder_Master POM on POM.PONO = Item.PONO left join T_Requestion_Master ReqMas on ReqMas.ReqNo= Item.ReqNo + where Item.CostCenterCode=? and POM.POType=? and POM.status not in (?) ) end as Totalvalue + from T_CostCenter_Budget Bud join T_CostCenter_Departments dept on dept.CostCenterCode = Bud.CostCenterCode + where Bud.CostCenterCode=? and + BudgetYear = ? and BudgetType =?'; + + + $query = $this->db->query($subQuery,array(REVENUE,$CostCode,$BudgetType,PO_AMENDED,'0.00',$CostCode,$BudgetType,PO_AMENDED,$CostCode,$Year,$BudgetType)); + + + //print_r($this->db->last_query()); + return $query->result_array(); + +} + +//to get POTYpe from ReqNo function GetPOType($ReqNo) { - $this->db->select('POType'); - $this->db->from('T_PurchaseOrder_Master mast'); - $this->db->join('T_PurchaseOrder_LineItem Line', 'mast.PONO=Line.PONO'); - $this->db->where('Line.ReqNo', $ReqNo); - $query = $this->db->get(); - return $query->result_array(); +$this->db->select('POType'); +$this->db->from('T_PurchaseOrder_Master mast'); +$this->db->join('T_PurchaseOrder_LineItem Line', 'mast.PONO=Line.PONO'); +$this->db->where('Line.ReqNo', $ReqNo); +$query = $this->db->get(); +return $query->result_array(); } - - /** - * This function is used to get the Requsition List for the login user - * @return array $result : This is result of the query - */ - function getRequistDetails($ReqNoList='') - { - $ReqDeatis = $this->GetRequistionMasterUsingReqNo($ReqNoList); - - foreach ($ReqDeatis as $SID): - $ReqBy = $SID->Requestedby ; - - endforeach; - if($ReqBy=='' || $ReqBy==null){ - $this->db->distinct(); - $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period, - Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); - $this->db->from('T_Requestion_Master mast'); - - $this->db->join('T_DepartmentDetails Dept', 'mast.RequestedDept = Dept.DEPCode'); - $this->db->where_in('mast.ReqNo', $ReqNoList); - } - else if($ReqBy!='') { - $this->db->distinct(); - $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); - $this->db->from('T_Requestion_Master mast'); - $this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); - $this->db->join('T_DepartmentDetails Dept', 'mast.RequestedDept = Dept.DEPCode'); - $this->db->where_in('mast.ReqNo', $ReqNoList); - } - - - $query = $this->db->get(); - - return $query->result(); - } - /** - * This function is used to get the Requsition List for the login user - * @return array $result : This is result of the query - */ - function getRequistDetailsForPO($ReqNoList='') - { - $this->db->distinct(); - $this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate'); - $this->db->from('T_Requestion_Master mast'); - $this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); - $this->db->join('T_DepartmentDetails Dept', 'emp.Departmentcode = Dept.DEPCode'); - $this->db->where_in('mast.ReqNo', $ReqNoList); - - $query = $this->db->get(); - - return $query->result(); - } - /** - * This function is used to get the Cost center information - * @return array $result : This is result of the query - */ - function getCostCenter() - { - - $this->db->select('CostName, Description'); - $this->db->from('T_CostCentre'); - - $query = $this->db->get(); - - return $query->result(); - } - - - /** - * This function is used to get the CostCenter for the Selected Requistion Number - * @return array $result : This is result of the query - */ - function getCostCenterbyRequist($ReqNo='',$BudYear='',$ReqType='') - { - - $this->db->distinct(); - $this->db->select('Mast.CostCenterCode,Mast.CostCenterName,Bud.BudgetAmount,ReqNo'); - $this->db->from('T_CostCenter_Master Mast'); - $this->db->join('T_CostCenter_Departments CostDept', 'CostDept.CostCenterCode = Mast.CostCenterCode'); - $this->db->join('T_CostCenter_Budget Bud', 'Bud.CostCenterCode = Mast.CostCenterCode'); - $this->db->join('T_Employee_Details emp', 'CostDept.DEPCode = emp.Departmentcode'); - $this->db->join('T_Requestion_Master req', 'req.Requestedby = emp.EmpID'); - - $this->db->where('BudgetType ',$ReqType ); - $this->db->where('BudgetYear ',$BudYear ); - if($ReqNo != '') - { - $this->db->where('ReqNo ',$ReqNo); - } - - $query = $this->db->get(); - return $query->result(); - } - /** - * This function is used to get the Config value from configuration table - * @return array $result : This is result of the query - */ - function getRequistionNoFromPO($PONO='') - { - $this->db->distinct(); - $this->db->select('ReqNo,'); - $this->db->from('T_PurchaseOrder_LineItem'); - if($PONO != '') - { - $this->db->where('PONO ',$PONO ); - } - - $query = $this->db->get(); - - return $query->result(); - } - +* This function is used to get the Requsition List for the login user +* @return array $result : This is result of the query +*/ +function getRequistDetails($ReqNoList='') +{ + $ReqDeatis = $this->GetRequistionMasterUsingReqNo($ReqNoList); + +foreach ($ReqDeatis as $SID): + $ReqBy = $SID->Requestedby ; + + endforeach; + if($ReqBy=='' || $ReqBy==null){ + $this->db->distinct(); +$this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period, +Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); +$this->db->from('T_Requestion_Master mast'); - /** - * This function is used to get the Config value from configuration table - * @return array $result : This is result of the query - */ - function getConfigValue($ConfigID ,$ConfigValue = '') - { - - $this->db->select('ConfigValue'); - $this->db->from('T_ConfigDetails'); - $this->db->where('Config_id ',$ConfigID ); - if($ConfigValue != '') - { - $this->db->where('ConfigValue != ',$ConfigValue ); - } - $query = $this->db->get(); - - return $query->result(); - } +$this->db->join('T_DepartmentDetails Dept', 'mast.RequestedDept = Dept.DEPCode'); +$this->db->where_in('mast.ReqNo', $ReqNoList); + } - - - - /** - * This function is used to get the Company information from T_Company_Details table - * @return array $result : This is result of the query - */ - function getCompanyInformation() - { - - $subQuery = "select CompanyName,replace(Address,'
','') as Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode - from T_Company_Details "; - - - - $query = $this->db->query($subQuery); - - - //print_r($this->db->last_query()); - return $query->result(); - // return $query->result(); - } - /** - * This function is used to get the Company information from T_Company_Details table - * @return array $result : This is result of the query - */ - function getCompanyInformationforPDF() - { - - $subQuery = "select CompanyName,Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode - from T_Company_Details "; - - - - $query = $this->db->query($subQuery); - - - //print_r($this->db->last_query()); - return $query->result(); - // return $query->result(); - } - - /** - * This function is used to get the Employee List - * @return array $result : This is result of the query - */ - function getAllEmployees() - { - $this->db->select('EmpID,FirstName,LastName'); - $this->db->from('T_Employee_Details'); - $query = $this->db->get(); - - return $query->result(); - } - - /** - * This function is used to get the Employee List - * @return array $result : This is result of the query - */ - function getLastCreatedPODate() - { - $this->db->select('max(PODate) as PODate'); - $this->db->from('T_PurchaseOrder_Master'); - $query = $this->db->get(); - - return $query->result(); - } + else if($ReqBy!='') { + $this->db->distinct(); +$this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,mast.Schedule_Type,mast.NumberOfService,mast.Service_Period,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate,mast.CostCenterCode,mast.Status'); +$this->db->from('T_Requestion_Master mast'); +$this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); +$this->db->join('T_DepartmentDetails Dept', 'mast.RequestedDept = Dept.DEPCode'); +$this->db->where_in('mast.ReqNo', $ReqNoList); + } - function getLastReleasedPODate() - { - $this->db->select('max(ReleasedOn) as PODate'); - $this->db->from('T_PurchaseOrder_Master'); - $query = $this->db->get(); - - return $query->result(); - } - /** - * This function is used to add New Purchase order to the system - - */ - function addPOMaster($POMaster,$POType,$POSubtype) - { - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_Master', $POMaster); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - // print_r($this->db->last_query()); - if($insert_id>0) - { - $subQuery = 'select PONO from T_PurchaseOrder_Master where POType=? and POSubType=? and isnull(ParentPO) order by CreatedDate desc limit 1 '; - - $query = $this->db->query($subQuery,array($POType,$POSubtype)); - - return $query->result_array(); - } - } - function addAmendPOMaster($POMaster,$CreatedBy,$ParentPO) - { +$query = $this->db->get(); - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_Master', $POMaster); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); +return $query->result(); +} +/** +* This function is used to get the Requsition List for the login user +* @return array $result : This is result of the query +*/ +function getRequistDetailsForPO($ReqNoList='') +{ +$this->db->distinct(); +$this->db->select('ReqNo,ReqType,Status,Requestedby,mast.CreatedDate,emp.FirstName,emp.EmpID,emp.Designation, Dept.DEPCode,Dept.DepartmentName,mast.ReqDate'); +$this->db->from('T_Requestion_Master mast'); +$this->db->join('T_Employee_Details emp', 'mast.Requestedby = emp.EmpID'); +$this->db->join('T_DepartmentDetails Dept', 'emp.Departmentcode = Dept.DEPCode'); +$this->db->where_in('mast.ReqNo', $ReqNoList); - if($insert_id>0) - { - $subQuery = 'select PONO from T_PurchaseOrder_Master where CreatedBy=? and ParentPO=? order by CreatedDate desc limit 1'; - - $query = $this->db->query($subQuery,array($CreatedBy,$ParentPO)); - - return $query->result_array(); - } - } - - /** - * This function is used to add New Purchase order Line Item to the system - */ - function addPOLineItem($POLineItem) - { - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_LineItem', $POLineItem); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); +$query = $this->db->get(); - if($insert_id>0) - { - $subQuery = 'select max(LineItemNo) as LineItemNo from T_PurchaseOrder_LineItem'; - - $query = $this->db->query($subQuery); - - return $query->result_array(); - } - } - - /** - * This function is used to add Revenue Tax to the system - */ - function addRevenueTax($RevenueTaxList) - { - $this->db->trans_start(); - $this->db->insert('T_Revenue_Tax', $RevenueTaxList); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - } - /** - * This function is used to add Service Tax to the system - */ - function addServiceTax($ServiceTaxList) - { - $this->db->trans_start(); - $this->db->insert('T_Service_Tax', $ServiceTaxList); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - } - - - /** - * This function is used to add Service Tax to the system - */ - function addImportTax($ImportTaxList) - { - $this->db->trans_start(); - $this->db->insert('T_Import_Tax', $ImportTaxList); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - } +return $query->result(); +} +/** +* This function is used to get the Cost center information +* @return array $result : This is result of the query +*/ +function getCostCenter() +{ + +$this->db->select('CostName, Description'); +$this->db->from('T_CostCentre'); + +$query = $this->db->get(); + +return $query->result(); +} + + +/** +* This function is used to get the CostCenter for the Selected Requistion Number +* @return array $result : This is result of the query +*/ +function getCostCenterbyRequist($ReqNo='',$BudYear='',$ReqType='') +{ + +$this->db->distinct(); +$this->db->select('Mast.CostCenterCode,Mast.CostCenterName,Bud.BudgetAmount,ReqNo'); +$this->db->from('T_CostCenter_Master Mast'); +$this->db->join('T_CostCenter_Departments CostDept', 'CostDept.CostCenterCode = Mast.CostCenterCode'); +$this->db->join('T_CostCenter_Budget Bud', 'Bud.CostCenterCode = Mast.CostCenterCode'); +$this->db->join('T_Employee_Details emp', 'CostDept.DEPCode = emp.Departmentcode'); +$this->db->join('T_Requestion_Master req', 'req.Requestedby = emp.EmpID'); + +$this->db->where('BudgetType ',$ReqType ); +$this->db->where('BudgetYear ',$BudYear ); +if($ReqNo != '') +{ +$this->db->where('ReqNo ',$ReqNo); +} + +$query = $this->db->get(); +return $query->result(); +} + +/** +* This function is used to get the Config value from configuration table +* @return array $result : This is result of the query +*/ +function getRequistionNoFromPO($PONO='') +{ +$this->db->distinct(); +$this->db->select('ReqNo,'); +$this->db->from('T_PurchaseOrder_LineItem'); +if($PONO != '') +{ +$this->db->where('PONO ',$PONO ); +} + +$query = $this->db->get(); + +return $query->result(); +} + + +/** +* This function is used to get the Config value from configuration table +* @return array $result : This is result of the query +*/ +function getConfigValue($ConfigID ,$ConfigValue = '') +{ + +$this->db->select('ConfigValue'); +$this->db->from('T_ConfigDetails'); +$this->db->where('Config_id ',$ConfigID ); +if($ConfigValue != '') +{ + $this->db->where('ConfigValue != ',$ConfigValue ); +} +$query = $this->db->get(); + +return $query->result(); +} - function addadvanceRequest($advance) - { - $this->db->trans_start(); - $this->db->insert('T_PurchaseOrder_AdvanceRequest', $advance); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; - - } +/** +* This function is used to get the Company information from T_Company_Details table +* @return array $result : This is result of the query +*/ +function getCompanyInformation() +{ - function PONOExists($PONO) - { - - $this->db->select('PONO'); - $this->db->from('T_PurchaseOrder_AdvanceRequest'); - $this->db->where('PONO ',$PONO); - $query = $this->db->get(); - - if ($query->num_rows > 0) { - return $query->result_array(); - } - - - } +$subQuery = "select CompanyName,replace(Address,'
','') as Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode + from T_Company_Details "; - function updateadvanceRequest($advance,$PONO) - { - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_AdvanceRequest',$advance); - $insert_id = $this->db->affected_rows(); - return $insert_id; - } - - - /** - * This function used to get user information by id - * @param number $userId : This is user id - * @return array $result : This is user information - */ - function getuserInfo($PO) - { - $this->db->select('POType, PODate, SupplierID,SpecialOrder,UserID,RequestedDate,RequesterEmail,RequesterPh, PurchasingCategory,BudgetManager,BudgetManagerDepartment,'); - $this->db->from('T_PurchaseOrderDetails'); - $this->db->where('PONO', $PO); - $query = $this->db->get(); - - return $query->result(); - } - - // This Method to get the Service PO Details for Edit the Item - - function GetServicePurchaseOrder($PONO = '') - { - $this->db->distinct(); - $this->db->select('ReqNo,POMast.PONO,POMast.PaymentTerms,POMast.PaymentOtherDescription,ServiceDescription,supp.SupplierID,supp.SupplierName,supp.Address,PODate,Stat.StatusName,DeliveryOption,DeliverySchedule,DeliveryDate,DeliveryAddress,POMast.PaymentTerms,POMast.ExchangeRate,POMast.UpdatedOn,Stat.StatusCode,POMast.ServiceWorkStatus,POMast.*,POMast.TotalOrderValue,POMast.BudgetType'); - $this->db->from('T_PurchaseOrder_Master POMast'); - $this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); - $this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); - $this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); - - $this->db->where('POMast.PONO', $PONO); - $query = $this->db->get(); - - $result = $query->result(); - - return $result; - } - - // This Method to get the Service PO Child Details for Edit the Item - - +$query = $this->db->query($subQuery); + + + //print_r($this->db->last_query()); + return $query->result(); +// return $query->result(); +} +/** +* This function is used to get the Company information from T_Company_Details table +* @return array $result : This is result of the query +*/ +function getCompanyInformationforPDF() +{ + +$subQuery = "select CompanyName,Address,GSTNO,PAN,ContactNumber,EmailAddress,AlternateContactNumber,companyWebsite,StateCode + from T_Company_Details "; + +$query = $this->db->query($subQuery); + + return $query->result(); +} + +/** +* This function is used to get the Employee List +* @return array $result : This is result of the query +*/ +function getAllEmployees() +{ +$this->db->select('EmpID,FirstName,LastName'); +$this->db->from('T_Employee_Details'); +$query = $this->db->get(); + +return $query->result(); +} + +/** +* This function is used to get the Employee List +* @return array $result : This is result of the query +*/ +function getLastCreatedPODate() +{ +$this->db->select('max(PODate) as PODate'); +$this->db->from('T_PurchaseOrder_Master'); +$query = $this->db->get(); + +return $query->result(); +} + +function getLastReleasedPODate() +{ +$this->db->select('max(ReleasedOn) as PODate'); +$this->db->from('T_PurchaseOrder_Master'); +$query = $this->db->get(); + +return $query->result(); +} +/** +* This function is used to add New Purchase order to the system + +*/ +function addPOMaster($POMaster,$POType,$POSubtype) +{ + $this->db->trans_start(); + $this->db->insert('T_PurchaseOrder_Master', $POMaster); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + + if($insert_id>0) + { + $subQuery = 'select PONO from T_PurchaseOrder_Master where POType=? and POSubType=? and isnull(ParentPO) order by CreatedDate desc limit 1 '; + + $query = $this->db->query($subQuery,array($POType,$POSubtype)); + + return $query->result_array(); + } +} + +function addAmendPOMaster($POMaster,$CreatedBy,$ParentPO) +{ + + $this->db->trans_start(); + $this->db->insert('T_PurchaseOrder_Master', $POMaster); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + + if($insert_id>0) + { + $subQuery = 'select PONO from T_PurchaseOrder_Master where CreatedBy=? and ParentPO=? order by CreatedDate desc limit 1'; + + $query = $this->db->query($subQuery,array($CreatedBy,$ParentPO)); + + return $query->result_array(); + } +} + +/** +* This function is used to add New Purchase order Line Item to the system +*/ +function addPOLineItem($POLineItem) +{ + $this->db->trans_start(); + $this->db->insert('T_PurchaseOrder_LineItem', $POLineItem); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + if($insert_id>0) + { + $subQuery = 'select max(LineItemNo) as LineItemNo from T_PurchaseOrder_LineItem'; + + $query = $this->db->query($subQuery); + + return $query->result_array(); + } +} + +/** +* This function is used to add Revenue Tax to the system +*/ +function addRevenueTax($RevenueTaxList) +{ + $this->db->trans_start(); + $this->db->insert('T_Revenue_Tax', $RevenueTaxList); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; +} +/** +* This function is used to add Service Tax to the system +*/ +function addServiceTax($ServiceTaxList) +{ + $this->db->trans_start(); + $this->db->insert('T_Service_Tax', $ServiceTaxList); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; +} + + +/** +* This function is used to add Service Tax to the system +*/ +function addImportTax($ImportTaxList) +{ + $this->db->trans_start(); + $this->db->insert('T_Import_Tax', $ImportTaxList); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; +} + + + +function addadvanceRequest($advance) +{ + $this->db->trans_start(); + $this->db->insert('T_PurchaseOrder_AdvanceRequest', $advance); + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; + + +} + +function PONOExists($PONO) +{ + +$this->db->select('PONO'); +$this->db->from('T_PurchaseOrder_AdvanceRequest'); +$this->db->where('PONO ',$PONO); +$query = $this->db->get(); + +if ($query->num_rows > 0) { + return $query->result_array(); +} + + +} + + + +function updateadvanceRequest($advance,$PONO) +{ +$this->db->where('PONO', $PONO); +$this->db->update('T_PurchaseOrder_AdvanceRequest',$advance); +$insert_id = $this->db->affected_rows(); +return $insert_id; +} + + +/** +* This function used to get user information by id +* @param number $userId : This is user id +* @return array $result : This is user information +*/ +function getuserInfo($PO) +{ +$this->db->select('POType, PODate, SupplierID,SpecialOrder,UserID,RequestedDate,RequesterEmail,RequesterPh, PurchasingCategory,BudgetManager,BudgetManagerDepartment,'); +$this->db->from('T_PurchaseOrderDetails'); +$this->db->where('PONO', $PO); +$query = $this->db->get(); + +return $query->result(); +} + +// This Method to get the Service PO Details for Edit the Item + +function GetServicePurchaseOrder($PONO = '') +{ +$this->db->distinct(); +$this->db->select('ReqNo,POMast.PONO,POMast.PaymentTerms,POMast.PaymentOtherDescription,ServiceDescription,supp.SupplierID,supp.SupplierName,supp.Address,PODate,Stat.StatusName,DeliveryOption,DeliverySchedule,DeliveryDate,DeliveryAddress,POMast.PaymentTerms,POMast.ExchangeRate,POMast.UpdatedOn,Stat.StatusCode,POMast.ServiceWorkStatus,POMast.*,POMast.TotalOrderValue,POMast.BudgetType,IGR.IGRNO'); +$this->db->from('T_PurchaseOrder_Master POMast'); +$this->db->join('T_SupplierDetailsN supp', 'supp.SupplierID = POMast.SupplierID'); +$this->db->join('T_Status Stat', 'Stat.StatusCode = POMast.Status'); +$this->db->join('T_PurchaseOrder_LineItem LineItem', 'POMast.PONO = LineItem.PONO'); +$this->db->join('T_IGR_Master IGR','POMast.PONO = IGR.PONO','left'); + +$this->db->where('POMast.PONO', $PONO); +$query = $this->db->get(); + +$result = $query->result(); + +return $result; +} + // This Method to get the Service PO Child Details for Edit the Item - function GetServicePurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,LineItem.Per,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,LineItem.Quantity,ReceivedQuantity,Rate,LineItem.Status,(LineItem.Quantity *Rate) as BasicValue ,(After_CGST + After_SGST + After_IGST) as Taxamount,Dept.DepartmentName - ,TotalValue,CGST,After_CGST,SGST,After_SGST,IGST,After_IGST,otherallowance,LineItem.CostCenterCode,LineItem.ServiceFrequency,LineItem.ServiceMaterialDescription,Req.Schedule_Type,Req.NumberOfService,Req.Service_Period,ReqDet.MaterialDescription - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - join T_Requestion_Details ReqDet on ReqDet.ReqNo = LineItem.ReqNo and LineItem.MaterialCode = ReqDet.MaterialCode - left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode - where LineItem.PONO =?'; - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - // This Method to get the Service PO Child Details for Edit the Item - function GetServicePurchaseOrderDetailsforPdf($PONO = '') - { - - - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,LineItem.Per,LineItem.ServiceMaterialDescription,Mat.MaterialCode,Mat.MaterialName,POMaster.ParentPO, - Mat.UOM,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue,POMaster.AmendedDetails,LineItem.AmendedDetails as lineamenddetails, - ROUND(( Tax.After_SGST + Tax.After_CGST + Tax.After_IGST ) ,2)as Taxamount,ReqMat.NumberOfService,ReqMat.Schedule_Type,ReqMat.Service_Period, - TotalValue,Tax.*,LineItem.CostCenterCode ,POMaster.*,sup.SupplierName,sup.SupplierID,sup.Address,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,Payment.PaymentTerms,AdvanceAmount - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms - join T_Requestion_Master ReqMat on ReqMat.ReqNo = LineItem.ReqNo - left join T_PurchaseOrder_AdvanceRequest PurAdv on POMaster.PONO=PurAdv.PONO - where LineItem.PONO =?'; - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - - - // This Method to get the Revenue PO Child Details for Edit the Item - function GetRevenuePurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,Per,ServiceMaterialDescription,ReceivedQuantity,Rate,Req.Status,(Quantity *Rate) as BasicValue , (( AfterSGST + AfterCGST + - AfterIGST )) as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode - where LineItem.PONO =?'; +// This Method to get the Service PO Child Details for Edit the Item +function GetServicePurchaseOrderDetails($PONO = '') +{ - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - // This Method to get the Revenue PO Child Details for Edit the Item - function GetRevenuePurchaseOrderDetailsForPDF($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,ReqNo,Mat.MaterialCode,Mat.MaterialName,POMaster.PaymentOtherDescription,LineItem.ServiceMaterialDescription, - Mat.UOM,Mat.HSNCODE,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , - ROUND(((AfterSGST + AfterCGST + - AfterIGST)) ,2)as Taxamount,AdvanceAmount, - TotalValue,Tax.*,LineItem.CostCenterCode ,POMaster.*,sup.SupplierName,sup.Address,sup.SupplierID,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,LineItem.AmendedDetails as LineAmend,Payment.PaymentTerms - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms - left join T_PurchaseOrder_AdvanceRequest PurAdv on POMaster.PONO=PurAdv.PONO - where LineItem.PONO =?'; +$subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,LineItem.Per,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,LineItem.Quantity,ReceivedQuantity,Rate,LineItem.Status,(LineItem.Quantity *Rate) as BasicValue ,(After_CGST + After_SGST + After_IGST) as Taxamount,Dept.DepartmentName + ,TotalValue,CGST,After_CGST,SGST,After_SGST,IGST,After_IGST,otherallowance,LineItem.CostCenterCode,LineItem.ServiceFrequency,LineItem.ServiceMaterialDescription,Req.Schedule_Type,Req.NumberOfService,Req.Service_Period,ReqDet.MaterialDescription + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo + join T_Requestion_Details ReqDet on ReqDet.ReqNo = LineItem.ReqNo and LineItem.MaterialCode = ReqDet.MaterialCode + left join T_Employee_Details emp on Req.Requestedby = emp.EmpID + join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode + where LineItem.PONO =?'; - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - function getRevenueTaxinforforpdf($PONO) - { - $subQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode,rt.CGST,rt.SGST,rt.IGST,rt.FreightValue,rt.AfterFreightValue,rt.PackagingValue,rt.AfterPackagingValue,rt.DiscountValue,rt.AfterDiscount FROM T_Revenue_Tax rt +$query = $this->db->query($subQuery,array($PONO)); - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=rt.LineItemNo +return $query->result(); - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO + +} +// This Method to get the Service PO Child Details for Edit the Item +function GetServicePurchaseOrderDetailsforPdf($PONO = '') +{ + + + + $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,LineItem.Per,LineItem.ServiceMaterialDescription,Mat.MaterialCode,Mat.MaterialName,POMaster.ParentPO, + Mat.UOM,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue,POMaster.AmendedDetails,LineItem.AmendedDetails as lineamenddetails, + ROUND(( Tax.After_SGST + Tax.After_CGST + Tax.After_IGST ) ,2)as Taxamount,ReqMat.NumberOfService,ReqMat.Schedule_Type,ReqMat.Service_Period, + TotalValue,Tax.*,LineItem.CostCenterCode ,POMaster.*,sup.SupplierName,sup.SupplierID,sup.Address,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,Payment.PaymentTerms,AdvanceAmount + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Service_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO + join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID + join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms + join T_Requestion_Master ReqMat on ReqMat.ReqNo = LineItem.ReqNo + left join T_PurchaseOrder_AdvanceRequest PurAdv on POMaster.PONO=PurAdv.PONO + where LineItem.PONO =?'; + + $query = $this->db->query($subQuery,array($PONO)); + + return $query->result(); + + +} - where pm.POType=? and pm.PONO=? - group by rt.CGST,rt.SGST,rt.IGST,rt.FreightValue,rt.PackagingValue,rt.AfterDiscount,rt.AfterFreightValue,rt.AfterPackagingValue ORDER BY rt.LineItemNo ASC'; - $query = $this->db->query($subQuery,array("REVENUE",$PONO)); - - return $query->result(); - - } // This Method to get the Revenue PO Child Details for Edit the Item - +function GetRevenuePurchaseOrderDetails($PONO = '') +{ + +$subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,Mat.UOM,Quantity,Per,ServiceMaterialDescription,ReceivedQuantity,Rate,Req.Status,(Quantity *Rate) as BasicValue , (( AfterSGST + AfterCGST + + AfterIGST )) as Taxamount ,TotalValue,Tax.*,Req.CostCenterCode,Dept.DepartmentName + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo + left join T_Employee_Details emp on Req.Requestedby = emp.EmpID + join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode + where LineItem.PONO =?'; + +$query = $this->db->query($subQuery,array($PONO)); + +return $query->result(); + + +} + +// This Method to get the Revenue PO Child Details for Edit the Item +function GetRevenuePurchaseOrderDetailsForPDF($PONO = '') +{ + + $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,ReqNo,Mat.MaterialCode,Mat.MaterialName,POMaster.PaymentOtherDescription,LineItem.ServiceMaterialDescription, + Mat.UOM,Mat.HSNCODE,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , + ROUND(((AfterSGST + AfterCGST + + AfterIGST)) ,2)as Taxamount,AdvanceAmount, + TotalValue,Tax.*,LineItem.CostCenterCode ,POMaster.*,sup.SupplierName,sup.Address,sup.SupplierID,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,LineItem.AmendedDetails as LineAmend,Payment.PaymentTerms + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + join T_Revenue_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo + join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO + join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID + join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms + left join T_PurchaseOrder_AdvanceRequest PurAdv on POMaster.PONO=PurAdv.PONO + where LineItem.PONO =?'; + +$query = $this->db->query($subQuery,array($PONO)); + +return $query->result(); + + +} + +function getRevenueTaxinforforpdf($PONO) +{ +$subQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode,rt.CGST,rt.SGST,rt.IGST,rt.FreightValue,rt.AfterFreightValue,rt.PackagingValue,rt.AfterPackagingValue,rt.DiscountValue,rt.AfterDiscount FROM T_Revenue_Tax rt + +join T_PurchaseOrder_LineItem pl on pl.LineItemNo=rt.LineItemNo + +join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO + +where pm.POType=? and pm.PONO=? + +group by rt.CGST,rt.SGST,rt.IGST,rt.FreightValue,rt.PackagingValue,rt.AfterDiscount,rt.AfterFreightValue,rt.AfterPackagingValue ORDER BY rt.LineItemNo ASC'; + +$query = $this->db->query($subQuery,array("REVENUE",$PONO)); + +return $query->result(); + +} +// This Method to get the Revenue PO Child Details for Edit the Item + function GetImportPurchaseOrderDetailsForPDF($PONO = '') - { - - $subQuery='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName,Import_DispatchDetails,LineItem.Per,LineItem.ServiceMaterialDescription, +{ + +$subQuery='SELECT distinct LineItem.LineItemNo,LineItem.ReqNo,Mat.MaterialCode,Mat.MaterialName,Import_DispatchDetails,LineItem.Per,LineItem.ServiceMaterialDescription, Mat.UOM,Quantity,ReqMas.Requestedby,Rate,ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount , ProductPrice,Tax.*,LineItem.CostCenterCode ,Date(ReqMast.ReqDate) as ReqDate,POMaster.*,sup.SupplierName,sup.Address,LineItem.AmendedDetails as LineAmend,AdvanceAmount, Pay.PaymentTerms as Pay,ROUND((Quantity *Rate),2 ) as BasicValue,HSNCODE,sup.EmailAddress,sup.SupplierID,sup.PAN,sup.ContactNumber,sup.GSTNO FROM T_PurchaseOrder_LineItem LineItem @@ -975,899 +982,893 @@ join T_Requestion_Master ReqMast on LineItem.ReqNo=ReqMast.ReqNo join T_PaymentTerms Pay on POMaster.PaymentTerms=Pay.PaymentID where LineItem.PONO =?'; - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } +$query = $this->db->query($subQuery,array($PONO)); + +return $query->result(); + + +} - function GetCurrencyDetail($Currency='') - { +function GetCurrencyDetail($Currency='') +{ - $subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; - $query=$this->db->query($subQuery,array($Currency)); - return $query->result(); +$subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; +$query=$this->db->query($subQuery,array($Currency)); +return $query->result(); - } +} - function GerRequesterName($Requester='') - { - $subQuery='SELECT EmpID,FirstName,Departmentcode from T_Employee_Details where EmpID=?'; +function GerRequesterName($Requester='') +{ +$subQuery='SELECT EmpID,FirstName,Departmentcode from T_Employee_Details where EmpID=?'; - $query=$this->db->query($subQuery,array($Requester)); +$query=$this->db->query($subQuery,array($Requester)); - return $query->result(); - } +return $query->result(); +} - function GerRequesterDep($Depcode='') - { - $subQuery='SELECT DepartmentName from T_DepartmentDetails where DEPCode=?'; - $query=$this->db->query($subQuery,array($Depcode)); +function GerRequesterDep($Depcode='') +{ +$subQuery='SELECT DepartmentName from T_DepartmentDetails where DEPCode=?'; +$query=$this->db->query($subQuery,array($Depcode)); - return $query->result(); +return $query->result(); - } +} - function GerCurrencyCodeName($Currencycode='') - { - $subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; - $query=$this->db->query($subQuery,array($Currencycode)); - return $query->result(); - - } +function GerCurrencyCodeName($Currencycode='') +{ +$subQuery='SELECT * from T_Currency_Details where Currency_Code=?'; +$query=$this->db->query($subQuery,array($Currencycode)); + return $query->result(); + +} - function GetPOStatus($Status='') - { - $subQuery='SELECT StatusName from T_Status where StatusCode=?'; - $query=$this->db->query($subQuery,array($Status)); - return $query->result(); +function GetPOStatus($Status='') +{ +$subQuery='SELECT StatusName from T_Status where StatusCode=?'; +$query=$this->db->query($subQuery,array($Status)); +return $query->result(); - } +} - function GetPaymentTerms($PONO='') - { - $subQuery='SELECT PaymentTerms from T_PurchaseOrder_Master where PONO=?'; - $query=$this->db->query($subQuery,array($PONO)); - return $query->result(); +function GetPaymentTerms($PONO='') +{ +$subQuery='SELECT PaymentTerms from T_PurchaseOrder_Master where PONO=?'; +$query=$this->db->query($subQuery,array($PONO)); +return $query->result(); - } +} - function getSupplierPayment($Config_ID='') - { +function getSupplierPayment($Config_ID='') +{ - // $subQuery='select distinct PaymentTerms from T_SupplierDetailsN'; - $subQuery='select ConfigValue from T_ConfigDetails where Config_ID=?'; - $query=$this->db->query($subQuery,array($Config_ID)); - - return $query->result(); +// $subQuery='select distinct PaymentTerms from T_SupplierDetailsN'; +$subQuery='select ConfigValue from T_ConfigDetails where Config_ID=?'; +$query=$this->db->query($subQuery,array($Config_ID)); +return $query->result(); - } +} + +function GetWorkStatus($Config_ID='') +{ +$subQuery = 'select ConfigValue from T_ConfigDetails where Config_ID=?'; +$query=$this->db->query($subQuery,array($Config_ID)); +return $query->result(); +} - function GetWorkStatus($Config_ID='') - { - $subQuery = 'select ConfigValue from T_ConfigDetails where Config_ID=?'; - $query=$this->db->query($subQuery,array($Config_ID)); - - return $query->result(); - } - function GetImportPurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName, +{ + +$subQuery ='SELECT distinct LineItem.LineItemNo,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName, Mat.UOM,Quantity,Rate,Req.Status,ROUND((Quantity *Rate),2 ) as BasicValue,ReceivedQuantity, QuantityRejected,ROUND(Quantity-ReceivedQuantity)as PendingQty,Per, - ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess, - AfterCustomEdCess,ROUND((Quantity *Rate),2)as TotalOrderValue,ROUND((POMast.ExchangeRate*BasicPriceInMTon),2) as BasicINRValue,TotalValue,CurrencyType,ReceivedQuantity,Tax.*,LineItem.ServiceMaterialDescription, - - Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - - left join T_MRIR_Master Mast on POMast.PONO=Mast.PONO - - left join T_MRIR_Details Det on Det.MaterialCode=LineItem.MaterialCode and Mast.MRIRNO=Det.MRIRNO - - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode where LineItem.PONO =?'; - //print_r($subQuery); +ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess, +AfterCustomEdCess,ROUND((Quantity *Rate),2)as TotalOrderValue,ROUND((POMast.ExchangeRate*BasicPriceInMTon),2) as BasicINRValue,TotalValue,CurrencyType,ReceivedQuantity,Tax.*,LineItem.ServiceMaterialDescription, + +Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem +join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO +join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode +join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo +join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo +left join T_Employee_Details emp on Req.Requestedby = emp.EmpID + +left join T_MRIR_Master Mast on POMast.PONO=Mast.PONO + +left join T_MRIR_Details Det on Det.MaterialCode=LineItem.MaterialCode and Mast.MRIRNO=Det.MRIRNO + +join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode where LineItem.PONO =?'; + //print_r($subQuery); + +$query = $this->db->query($subQuery,array($PONO)); + +return $query->result(); + + +} + - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - - function GetCurrencytype() - { - - $subQuery = 'select * from T_Currency_Details'; - - $query = $this->db->query($subQuery); - - return $query->result(); - } +{ + +$subQuery = 'select * from T_Currency_Details'; - function GetINRCurrencytype($Currency_Code='') - { - $subQuery='select * from T_Currency_Details where Currency_Code=?'; - $query=$this->db->query($subQuery,array($Currency_Code)); - //print_r($this->db->last_query()); +$query = $this->db->query($subQuery); + +return $query->result(); +} + +function GetINRCurrencytype($Currency_Code='') +{ +$subQuery='select * from T_Currency_Details where Currency_Code=?'; +$query=$this->db->query($subQuery,array($Currency_Code)); +//print_r($this->db->last_query()); +return $query->result(); + +} + + + + + + +// To Update the PO +function updatePOMaster($PONO,$PODetails) +{ +$this->db->where('PONO', $PONO); +$this->db->update('T_PurchaseOrder_Master', $PODetails); + +return TRUE; +} + + +// To update Parent PO as Amended PO +function updateAmendPOMaster($PONO,$PODetail) +{ +//echo $PONO."from model"; + + +$this->db->where('PONO', $PONO); +$this->db->update('T_PurchaseOrder_Master', $PODetail); +$insert_id = $this->db->affected_rows(); + +return $insert_id; +} +/** +* This function is used to check the Line Item is already available in the database +* @return array $result : This is result of the query +*/ +function LineItemExists($LineItemNo) +{ +$this->db->select('LineItemNo,TaxID'); +$this->db->from('T_Service_Tax'); +$this->db->where('LineItemNo ',$LineItemNo ); +//$this->db->where('Requestedby ',$ReqBy ); +$query = $this->db->get(); + +if ($query->num_rows > 0) { + //echo $result->num_rows; + return $query->result_array(); +} +} +/** +* This function is used to check the Revenue Line Item is already available in the database +* @return array $result : This is result of the query +*/ +function LineItemExistsinRevenueTax($LineItemNo) +{ +$this->db->select('LineItemNo'); +$this->db->from('T_Revenue_Tax'); +$this->db->where('LineItemNo ',$LineItemNo ); +$query = $this->db->get(); + +if ($query->num_rows > 0) { + return $query->result_array(); +} +} + + +function LineItemExistsinImportTax($LineItemNo) +{ +$this->db->select('LineItemNo'); +$this->db->from('T_Import_Tax'); +$this->db->where('LineItemNo ',$LineItemNo ); +$query = $this->db->get(); + +if ($query->num_rows > 0) { + return $query->result_array(); +} +} +// To Update the PO Line Item +function updatePOLineItem($PONO,$LineItemNo,$PODetails) +{ +$this->db->where('PONO', $PONO); +$this->db->where('LineItemNo', $LineItemNo); +$this->db->update('T_PurchaseOrder_LineItem', $PODetails); + +return TRUE; +} +/*// To Update the Service Tax Item */ +function updateServiceTax($LineItemNo,$PODetails) +{ + + $this->db->where('LineItemNo', $LineItemNo); +$this->db->update('T_Service_Tax', $PODetails); + +// print_r($this->db->last_query()); + +return TRUE; +} + +/*// To Update the Revenue Tax Item */ +function updateRevenueTax($LineItemNo,$PODetails) +{ +$this->db->where('LineItemNo', $LineItemNo); +$this->db->update('T_Revenue_Tax', $PODetails); + +// print_r($this->db->last_query()); + +return TRUE; +} + +function updateImportTax($LineItemNo,$PODetails) +{ +$this->db->where('LineItemNo', $LineItemNo); +$this->db->update('T_Import_Tax', $PODetails); + +// print_r($this->db->last_query()); + +return TRUE; +} + +function getLastInsertedPO() +{ +$this->db->select('max(PONO) as PO'); +$this->db->from('T_PurchaseOrderDetails'); +$query = $this->db->get(); + +return $query->result_array(); +} + + +/* This Method to get all the Department name for the requistion */ +function getDepartmentListForAllReq() +{ +$subQuery ='SELECT DISTINCT DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ + JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID + JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode WHERE REQ.Status not in(?,?,?,?)'; + +$query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); +//print_r($query); +return $query->result(); +} +/* +This Method to get all department list +*/ +function getDepartmentAllList() +{ +$subQuery ='SELECT DISTINCT DEPCode,DepartmentName FROM T_DepartmentDetails'; + +$query = $this->db->query($subQuery); +//print_r($query); +return $query->result(); +} + + +function getStatusListforAllReq() +{ +$subQuery ='SELECT DISTINCT STAT.StatusCode, STAT.StatusName FROM T_Requestion_Master REQ + JOIN T_Status STAT on REQ.Status = STAT.StatusCode where STAT.StatusCode not in (?,?,?,?)'; +$query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); + +// print_r( $this->db->last_query()); + +return $query->result(); +} + +function getStatusByDepartment($DepNo='') +{ + +$subQuery ='SELECT DISTINCT STAT.StatusCode ,STAT.StatusName FROM T_Requestion_Master REQ + JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID + JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode + JOIN T_Status STAT ON REQ.Status = STAT.StatusCode + WHERE DEPT.DEPCode=? AND REQ.Status NOT IN (?,?,?,?)'; +$query = $this->db->query($subQuery,array($DepNo,REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); + +return $query->result_array(); +} + +function getRequistionListbySearch($Depid='',$Status='',$FromDate='',$ToDate='') +{ +$subQuery =' SELECT ReqNo,ReqType,Requestedby,EMP.FirstName,EMP.Designation,STAT.StatusCode ,STAT.StatusName,ReqDate,DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ + JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID +JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode +JOIN T_Status STAT on REQ.Status = STAT.StatusCode +where REQ.Status NOT IN (?,?,?,?,?)'; + +$appendQuery = $subQuery ; + +if($Depid != '' && $Status != '' && $FromDate != '' && $ToDate != '') +{ +$appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; +//echo "$appendQuery";die(); +$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status,$FromDate,$ToDate)); +//print_r($this->db->last_query()); +return $query->result_array(); +} +else if($Depid != '' && $Status == '' && $FromDate == '' && $ToDate == '') +{ + $appendQuery .= ' AND DEPT.DEPCode=?'; + +$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid)); +//print_r($this->db->last_query()); +return $query->result_array(); +} +else if($Depid == '' && $Status != '' && $FromDate == '' && $ToDate == '') +{ + $appendQuery .= ' AND STAT.StatusCode=?'; + +$query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status)); +//print_r($this->db->last_query()); +return $query->result_array(); +} +else if($Depid == '' && $Status == '' && $FromDate != '' && $ToDate != '') +{ + $appendQuery .= ' AND ReqDate >= ? AND ReqDate <= ?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$FromDate,$ToDate)); +//print_r($this->db->last_query()); + return $query->result_array(); +} +else if($Depid != '' && $Status != '' && $FromDate == '' && $ToDate == '') +{ + $appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status)); +// print_r($this->db->last_query()); + return $query->result_array(); +} +else if($Depid != '' && $Status == '' && $FromDate != '' && $ToDate != '') +{ + $appendQuery .= ' AND DEPT.DEPCode=? AND ReqDate >= ? AND ReqDate <= ?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$FromDate,$ToDate)); +//print_r($this->db->last_query()); + return $query->result_array(); +} +else if($Depid == '' && $Status != '' && $FromDate != '' && $ToDate != '') +{ + $appendQuery .= ' AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; + + $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status ,$FromDate,$ToDate)); +// print_r($this->db->last_query()); + return $query->result_array(); +} +else +{ + $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED)); + //print_r($this->db->last_query()); return $query->result(); +} - } +} + +function UpdateRequistItemStatus() +{ +$query = $this->db->query("update T_Requestion_Details REQ + JOIN T_PurchaseOrder_LineItem line ON REQ.ReqNo = line.ReqNo + JOIN T_PurchaseOrder_Master PO ON PO.PONO = line.PONO + set REQ.Status = CASE WHEN REQ.Quantity = line.Quantity THEN 'ST022' WHEN REQ.Quantity > line.Quantity THEN 'ST023' ELSE 'ST003' END , + REQ.updatedOn= CURRENT_TIMESTAMP + where PO.Status ='".PO_CREATED."'"); + +//$query ->next_result(); + +} +function UpdateRequistionStatus() +{ +$result = $this->db-> query("CALL P_UPDATE_REQUISTIONSTATUS_New()") or die(mysql_error()); + +$result ->next_result(); + +} +/** +* This function is used to delete the Line item from details into Database +* @return array $result : This is result of the query +*/ +function DeletePOLineItem( $LineItem='',$ReqNo='',$MaterialCode='') +{ +$this->db->where('LineItemNo', $LineItem); +$this->db->where('ReqNo', $ReqNo); +$this->db->where('MaterialCode', $MaterialCode); +$this->db->delete('T_PurchaseOrder_LineItem'); + +return TRUE; +} + +/** +* This function is used to delete the Revenue item from details into Database +* @return array $result : This is result of the query +*/ +function DeletePORevenueTax( $LineItem='') +{ +$this->db->where('LineItemNo', $LineItem); +$this->db->delete('T_Revenue_Tax'); + +return TRUE; +} + +/** +* This function is used to delete Service Tax from details into Database +* @return array $result : This is result of the query +*/ +function DeletePOServiceTax( $LineItem='') +{ +$this->db->where('LineItemNo', $LineItem); +$this->db->delete('T_Service_Tax'); + +return TRUE; +} +function DeletePOImportTax( $LineItem='') +{ +$this->db->where('LineItemNo', $LineItem); +$this->db->delete('T_Import_Tax'); +return TRUE; +} +/** +* This function is used to get the List of PO details to the approver +* @return array $result : This is result of the query +join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode +*/ +function getPOList($type) +{ - - // To Update the PO - function updatePOMaster($PONO,$PODetails) - { - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_Master', $PODetails); - - return TRUE; - } - - - // To update Parent PO as Amended PO - function updateAmendPOMaster($PONO,$PODetail) - { - //echo $PONO."from model"; - - - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_Master', $PODetail); - $insert_id = $this->db->affected_rows(); - - return $insert_id; - } - /** - * This function is used to check the Line Item is already available in the database - * @return array $result : This is result of the query - */ - function LineItemExists($LineItemNo) - { - $this->db->select('LineItemNo,TaxID'); - $this->db->from('T_Service_Tax'); - $this->db->where('LineItemNo ',$LineItemNo ); - //$this->db->where('Requestedby ',$ReqBy ); - $query = $this->db->get(); - - if ($query->num_rows > 0) { - //echo $result->num_rows; - return $query->result_array(); - } - } - /** - * This function is used to check the Revenue Line Item is already available in the database - * @return array $result : This is result of the query - */ - function LineItemExistsinRevenueTax($LineItemNo) - { - $this->db->select('LineItemNo'); - $this->db->from('T_Revenue_Tax'); - $this->db->where('LineItemNo ',$LineItemNo ); - $query = $this->db->get(); - - if ($query->num_rows > 0) { - return $query->result_array(); - } - } - - - function LineItemExistsinImportTax($LineItemNo) - { - $this->db->select('LineItemNo'); - $this->db->from('T_Import_Tax'); - $this->db->where('LineItemNo ',$LineItemNo ); - $query = $this->db->get(); - - if ($query->num_rows > 0) { - return $query->result_array(); - } - } - // To Update the PO Line Item - function updatePOLineItem($PONO,$LineItemNo,$PODetails) - { - $this->db->where('PONO', $PONO); - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_PurchaseOrder_LineItem', $PODetails); - - return TRUE; - } - /*// To Update the Service Tax Item */ - function updateServiceTax($LineItemNo,$PODetails) - { - - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_Service_Tax', $PODetails); - - // print_r($this->db->last_query()); - - return TRUE; - } - - /*// To Update the Revenue Tax Item */ - function updateRevenueTax($LineItemNo,$PODetails) - { - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_Revenue_Tax', $PODetails); - - // print_r($this->db->last_query()); - - return TRUE; - } - - function updateImportTax($LineItemNo,$PODetails) - { - $this->db->where('LineItemNo', $LineItemNo); - $this->db->update('T_Import_Tax', $PODetails); - - // print_r($this->db->last_query()); - - return TRUE; - } - - function getLastInsertedPO() - { - $this->db->select('max(PONO) as PO'); - $this->db->from('T_PurchaseOrderDetails'); - $query = $this->db->get(); - - return $query->result_array(); - } - - - /* This Method to get all the Department name for the requistion */ - function getDepartmentListForAllReq() - { - $subQuery ='SELECT DISTINCT DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ - JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID - JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode WHERE REQ.Status not in(?,?,?,?)'; - - $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); - //print_r($query); - return $query->result(); - } - /* - This Method to get all department list - */ - function getDepartmentAllList() - { - $subQuery ='SELECT DISTINCT DEPCode,DepartmentName FROM T_DepartmentDetails'; - - $query = $this->db->query($subQuery); - //print_r($query); - return $query->result(); - } - - - function getStatusListforAllReq() - { - $subQuery ='SELECT DISTINCT STAT.StatusCode, STAT.StatusName FROM T_Requestion_Master REQ - JOIN T_Status STAT on REQ.Status = STAT.StatusCode where STAT.StatusCode not in (?,?,?,?)'; - $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); - - // print_r( $this->db->last_query()); - - return $query->result(); - } - - function getStatusByDepartment($DepNo='') - { - - $subQuery ='SELECT DISTINCT STAT.StatusCode ,STAT.StatusName FROM T_Requestion_Master REQ - JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID - JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode - JOIN T_Status STAT ON REQ.Status = STAT.StatusCode - WHERE DEPT.DEPCode=? AND REQ.Status NOT IN (?,?,?,?)'; - $query = $this->db->query($subQuery,array($DepNo,REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED)); - - return $query->result_array(); - } - - function getRequistionListbySearch($Depid='',$Status='',$FromDate='',$ToDate='') - { - $subQuery =' SELECT ReqNo,ReqType,Requestedby,EMP.FirstName,EMP.Designation,STAT.StatusCode ,STAT.StatusName,ReqDate,DEPT.DEPCode,DEPT.DepartmentName FROM T_Requestion_Master REQ - JOIN T_Employee_Details EMP ON REQ.Requestedby = EMP.EmpID - JOIN T_DepartmentDetails DEPT ON EMP.Departmentcode = DEPT.DEPCode - JOIN T_Status STAT on REQ.Status = STAT.StatusCode - where REQ.Status NOT IN (?,?,?,?,?)'; - - $appendQuery = $subQuery ; - - if($Depid != '' && $Status != '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; - //echo "$appendQuery";die(); - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status,$FromDate,$ToDate)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid != '' && $Status == '' && $FromDate == '' && $ToDate == '') - { - $appendQuery .= ' AND DEPT.DEPCode=?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid == '' && $Status != '' && $FromDate == '' && $ToDate == '') - { - $appendQuery .= ' AND STAT.StatusCode=?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid == '' && $Status == '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND ReqDate >= ? AND ReqDate <= ?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$FromDate,$ToDate)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid != '' && $Status != '' && $FromDate == '' && $ToDate == '') - { - $appendQuery .= ' AND DEPT.DEPCode=? AND STAT.StatusCode=?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$Status)); - // print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid != '' && $Status == '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND DEPT.DEPCode=? AND ReqDate >= ? AND ReqDate <= ?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Depid ,$FromDate,$ToDate)); - //print_r($this->db->last_query()); - return $query->result_array(); - } - else if($Depid == '' && $Status != '' && $FromDate != '' && $ToDate != '') - { - $appendQuery .= ' AND STAT.StatusCode=? AND ReqDate >= ? AND ReqDate <= ?'; - - $query = $this->db->query($appendQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED,$Status ,$FromDate,$ToDate)); - // print_r($this->db->last_query()); - return $query->result_array(); - } - else - { - $query = $this->db->query($subQuery,array(REQ_DRAFT,REQ_PENDING_APPROVAL,REQ_DELETED,REQ_REJECTED,REQ_PO_CREATED)); - //print_r($this->db->last_query()); - return $query->result(); - } - - } - - function UpdateRequistItemStatus() - { - $query = $this->db->query("update T_Requestion_Details REQ - JOIN T_PurchaseOrder_LineItem line ON REQ.ReqNo = line.ReqNo - JOIN T_PurchaseOrder_Master PO ON PO.PONO = line.PONO - set REQ.Status = CASE WHEN REQ.Quantity = line.Quantity THEN 'ST022' WHEN REQ.Quantity > line.Quantity THEN 'ST023' ELSE 'ST003' END , - REQ.updatedOn= CURRENT_TIMESTAMP - where PO.Status ='".PO_CREATED."'"); - - //$query ->next_result(); - - } - function UpdateRequistionStatus() - { - $result = $this->db-> query("CALL P_UPDATE_REQUISTIONSTATUS_New()") or die(mysql_error()); - - $result ->next_result(); - - } - /** - * This function is used to delete the Line item from details into Database - * @return array $result : This is result of the query - */ - function DeletePOLineItem( $LineItem='',$ReqNo='',$MaterialCode='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->where('ReqNo', $ReqNo); - $this->db->where('MaterialCode', $MaterialCode); - $this->db->delete('T_PurchaseOrder_LineItem'); - - return TRUE; - } - - /** - * This function is used to delete the Revenue item from details into Database - * @return array $result : This is result of the query - */ - function DeletePORevenueTax( $LineItem='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->delete('T_Revenue_Tax'); - - return TRUE; - } - - /** - * This function is used to delete Service Tax from details into Database - * @return array $result : This is result of the query - */ - function DeletePOServiceTax( $LineItem='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->delete('T_Service_Tax'); - - return TRUE; - } - - - function DeletePOImportTax( $LineItem='') - { - $this->db->where('LineItemNo', $LineItem); - $this->db->delete('T_Import_Tax'); - - return TRUE; - } - - /** - * This function is used to get the List of PO details to the approver - * @return array $result : This is result of the query - join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode - */ - function getPOList($type) - { - - $this->db->distinct(); - $this->db->select('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, +$this->db->distinct(); +$this->db->select('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'); - $this->db->from('T_PurchaseOrder_Master mast'); - // $this->db->order_by('mast.Status',"PO_CREATED"); - $this->db->join('T_Status st', 'st.StatusCode=mast.Status'); - - $this->db->join('T_PurchaseOrder_LineItem req', 'req.PONO= mast.PONO'); - $this->db->join('T_Requestion_Master rmast','rmast.ReqNo=req.ReqNo'); - //$this->db->join('T_CostCenter_Budget bud','bud.CostCenterCode = req.CostCenterCode and bud.BudgetType = rmast.ReqType'); - $this->db->join('T_CostCenter_Master ccm','ccm.CostCenterCode = req.CostCenterCode','left'); - $this->db->join('tbl_users tbl', 'rmast.createdby=tbl.userid'); - $this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid'); - $this->db->join('T_DepartmentDetails as Dep','Dep.DEPCode=emp.Departmentcode'); - - if($type=='APPROVAL'){ - $this->db->or_where('mast.Status',PO_CREATED); - $this->db->or_where('mast.Status',PO_APPROVER_ONHOLD); - $this->db->or_where('mast.Status',PO_AWAITING_RELEASE); - $this->db->or_where('mast.Status',PO_RELEASED); - $this->db->or_where('mast.Status',REQITEM_Emergency_PO_CREATED); - $this->db->order_by('mast.Status'); - - } - else if($type=='RELEASE'){ - $this->db->or_where('mast.Status',PO_AWAITING_RELEASE); - $this->db->or_where('mast.Status',PO_RELEASER_ONHOLD); - $this->db->or_where('mast.Status',PO_RELEASED); - $this->db->order_by('mast.Status'); - - - - } - $result=$this->db->get(); - // print_r($this->db->last_query()); - return $result->result(); - - } - - - function UpdatePO($store, $PONO) - { - - $this->db->where('PONO', $PONO); - $this->db->update('T_PurchaseOrder_Master', $store); - - return TRUE; - } - - function GetReleasedDetails($PONO){ - $this->db->select('mast.ReleasedOn,re.FirstName'); - $this->db->from('T_PurchaseOrder_Master mast'); - $this->db->join('tbl_users tbl','mast.ReleasedBy=tbl.userid'); - $this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); - $this->db->where('mast.PONO',$PONO); - $result=$this->db->get(); - //print_r($this->db->last_query()); +$this->db->from('T_PurchaseOrder_Master mast'); +// $this->db->order_by('mast.Status',"PO_CREATED"); +$this->db->join('T_Status st', 'st.StatusCode=mast.Status'); + +$this->db->join('T_PurchaseOrder_LineItem req', 'req.PONO= mast.PONO'); +$this->db->join('T_Requestion_Master rmast','rmast.ReqNo=req.ReqNo'); +//$this->db->join('T_CostCenter_Budget bud','bud.CostCenterCode = req.CostCenterCode and bud.BudgetType = rmast.ReqType'); +$this->db->join('T_CostCenter_Master ccm','ccm.CostCenterCode = req.CostCenterCode','left'); +$this->db->join('tbl_users tbl', 'rmast.createdby=tbl.userid'); +$this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid'); +$this->db->join('T_DepartmentDetails as Dep','Dep.DEPCode=emp.Departmentcode'); + +if($type=='APPROVAL'){ +$this->db->or_where('mast.Status',PO_CREATED); +$this->db->or_where('mast.Status',PO_APPROVER_ONHOLD); +$this->db->or_where('mast.Status',PO_AWAITING_RELEASE); +$this->db->or_where('mast.Status',PO_RELEASED); +$this->db->or_where('mast.Status',REQITEM_Emergency_PO_CREATED); +$this->db->order_by('mast.Status'); + +} +else if($type=='RELEASE'){ +$this->db->or_where('mast.Status',PO_AWAITING_RELEASE); +$this->db->or_where('mast.Status',PO_RELEASER_ONHOLD); + $this->db->or_where('mast.Status',PO_RELEASED); + $this->db->order_by('mast.Status'); + + + +} +$result=$this->db->get(); +// print_r($this->db->last_query()); +return $result->result(); + +} + + +function UpdatePO($store, $PONO) +{ + +$this->db->where('PONO', $PONO); +$this->db->update('T_PurchaseOrder_Master', $store); + +return TRUE; +} + +function GetReleasedDetails($PONO){ +$this->db->select('mast.ReleasedOn,re.FirstName'); +$this->db->from('T_PurchaseOrder_Master mast'); +$this->db->join('tbl_users tbl','mast.ReleasedBy=tbl.userid'); +$this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); +$this->db->where('mast.PONO',$PONO); +$result=$this->db->get(); +//print_r($this->db->last_query()); //die(); - return $result->result(); - - } - //This is get the capital po list for edit +return $result->result(); + +} +//This is get the capital po list for edit function getCapitalPurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.ServiceMaterialDescription,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription,LineItem.ServiceFrequency, +{ + +$subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.ServiceMaterialDescription,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription,LineItem.ServiceFrequency, Mat.UOM,Quantity,ReceivedQuantity,Rate,Req.Status,Tax.*, - ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((POMast.ExchangeRate*BasicPriceInMTon*Quantity),2) as BasicINRValue,Tax.TotalValue as ImportTotalValue,Tax.FreightType,Tax.NoOfTrip,Tax.FreightValue,Tax.AfterFreightValue,POMast.CurrencyType, - - Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO +ROUND((RMCIncludingCustomersPerKG*Quantity),2)as Taxamount,LandingCharge,HighSeasSalesCharge,CustomDuty,ExciseDuty,ExciseDutyEdCess,CustomEdCess,POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,AfterLandingCharge,AfterHighSeasSalesCharge,AfterCustomDuty,AfterExciseDuty,AfterExciseDutyEdCess,AddlExciseDuty,AfterAddlExciseDuty,Grossdutypayable,AvailableModvat,Grossexpensesduetocustomduty,purchaseratePerKG,CustomDutyExpensesPerKG,RMCIncludingCustomersPerKG,QuantityKG,BasicPriceInMTon,ProductPrice,CustomSHCess,AfterCustomSHCess,AfterExciseDutySHCess,ExciseDutySHCess,AfterCustomEdCess,ROUND((POMast.ExchangeRate*BasicPriceInMTon*Quantity),2) as BasicINRValue,Tax.TotalValue as ImportTotalValue,Tax.FreightType,Tax.NoOfTrip,Tax.FreightValue,Tax.AfterFreightValue,POMast.CurrencyType, + +Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem +join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo +join T_Import_Tax Tax on Tax.LineItemNo = LineItem.LineItemNo +join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo left join T_Employee_Details emp on Req.Requestedby = emp.EmpID - join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode where LineItem.PONO =?'; - //print_r($subQuery); +join T_DepartmentDetails Dept on Req.RequestedDept = Dept.DEPCode where LineItem.PONO =?'; + //print_r($subQuery); - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } +$query = $this->db->query($subQuery,array($PONO)); + +return $query->result(); + + +} // This Method to get the Capital PO Details for pdf - function GetCapitalPurchaseOrderDetailsForPDF($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.AmendedDetails as lineamd,ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription, - Mat.UOM,Mat.HSNCODE,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , - LineItem.CostCenterCode , POMaster.*,sup.SupplierName,sup.SupplierID,sup.Address,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,Payment.PaymentID,Payment.PaymentTerms,AdvanceAmount,HSNCODE - FROM T_PurchaseOrder_LineItem LineItem - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - - join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO - join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID - join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms - left join T_PurchaseOrder_AdvanceRequest Adv on POMaster.PONO=Adv.PONO - where LineItem.PONO =?'; - $query = $this->db->query($subQuery,array($PONO)); - - return $query->result(); - - - } - // get requested by details - function GetRequesedByDetails($PONO){ - $this->db->select('mast.CreatedBy,re.FirstName,Dept.DEPCode,Dept.DepartmentName'); - $this->db->from('T_PurchaseOrder_Master mast'); - $this->db->join('tbl_users tbl','mast.CreatedBy=tbl.userid'); - $this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); - $this->db->join('T_DepartmentDetails Dept', 're.Departmentcode = Dept.DEPCode'); - - $this->db->where('mast.PONO',$PONO); - $result=$this->db->get(); - - return $result->result(); - - } - - // get domestic capital po list +function GetCapitalPurchaseOrderDetailsForPDF($PONO = '') +{ - - function getDomesticCapitalPurchaseOrderDetails($PONO = '') - { - - $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.ServiceMaterialDescription,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription,LineItem.ServiceFrequency, - Mat.UOM,Quantity,ReceivedQuantity,Rate,Req.Status,ROUND((ServiceTax.After_CGST + ServiceTax.After_SGST + ServiceTax.After_IGST),2) as ServiceTaxamount - ,ServiceTax.TotalValue,ServiceTax.CGST,ServiceTax.After_CGST,ServiceTax.SGST,ServiceTax.After_SGST,ServiceTax.IGST,ServiceTax.After_IGST,ServiceTax.otherallowance,ServiceTax.discount,ServiceTax.discountval,ServiceTax.Afterdiscountval, - POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,ROUND((POMast.TotalOrderValue),2) as BasicINRValue,POMast.CurrencyType,FreightType as Ftype,NoOfTrip as NoTrip,FreightValue as Fvalue,AfterFreightValue as Afvalue, + $subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.AmendedDetails as lineamd,ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription, + Mat.UOM,Mat.HSNCODE,Quantity,Rate,ROUND((Quantity *Rate),2 ) as BasicValue , + LineItem.CostCenterCode , POMaster.*,sup.SupplierName,sup.SupplierID,sup.Address,sup.ContactNumber,sup.EmailAddress,sup.PAN,sup.GSTNO,Payment.PaymentID,Payment.PaymentTerms,AdvanceAmount,HSNCODE + FROM T_PurchaseOrder_LineItem LineItem + join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode + + join T_PurchaseOrder_Master POMaster on POMaster.PONO = LineItem.PONO + join T_SupplierDetailsN sup on sup.SupplierID = POMaster.SupplierID + join T_PaymentTerms Payment on Payment.PaymentID = POMaster.PaymentTerms + left join T_PurchaseOrder_AdvanceRequest Adv on POMaster.PONO=Adv.PONO + where LineItem.PONO =?'; +$query = $this->db->query($subQuery,array($PONO)); - Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem - join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO - join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode - join T_Service_Tax ServiceTax on ServiceTax.LineItemNo = LineItem.LineItemNo - join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo - join T_Employee_Details emp on Req.Requestedby = emp.EmpID +return $query->result(); - join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode where LineItem.PONO =?'; - //print_r($subQuery); + +} +// get requested by details +function GetRequesedByDetails($PONO){ +$this->db->select('mast.CreatedBy,re.FirstName,Dept.DEPCode,Dept.DepartmentName'); +$this->db->from('T_PurchaseOrder_Master mast'); +$this->db->join('tbl_users tbl','mast.CreatedBy=tbl.userid'); +$this->db->join('T_Employee_Details re','re.EmpID=tbl.EmpID'); +$this->db->join('T_DepartmentDetails Dept', 're.Departmentcode = Dept.DEPCode'); - $query = $this->db->query($subQuery,array($PONO)); +$this->db->where('mast.PONO',$PONO); +$result=$this->db->get(); + +return $result->result(); + +} + +// get domestic capital po list + + +function getDomesticCapitalPurchaseOrderDetails($PONO = '') +{ + +$subQuery ='SELECT distinct LineItem.LineItemNo,LineItem.Per,LineItem.ServiceMaterialDescription,Req.ReqNo,Mat.MaterialCode,Mat.MaterialName,LineItem.ServiceMaterialDescription,LineItem.ServiceFrequency, +Mat.UOM,Quantity,ReceivedQuantity,Rate,Req.Status,ROUND((ServiceTax.After_CGST + ServiceTax.After_SGST + ServiceTax.After_IGST),2) as ServiceTaxamount + ,ServiceTax.TotalValue,ServiceTax.CGST,ServiceTax.After_CGST,ServiceTax.SGST,ServiceTax.After_SGST,ServiceTax.IGST,ServiceTax.After_IGST,ServiceTax.otherallowance,ServiceTax.discount,ServiceTax.discountval,ServiceTax.Afterdiscountval, +POMast.ExchangeRate,POMast.ExchangeRateCalculatedon,POMast.TotalOrderValue as BasicValue,POMast.CapitalRange,ROUND((POMast.TotalOrderValue),2) as BasicINRValue,POMast.CurrencyType,FreightType as Ftype,NoOfTrip as NoTrip,FreightValue as Fvalue,AfterFreightValue as Afvalue, + +Req.CostCenterCode,Dept.DepartmentName FROM T_PurchaseOrder_LineItem LineItem +join T_PurchaseOrder_Master POMast on POMast.PONO = LineItem.PONO +join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode +join T_Service_Tax ServiceTax on ServiceTax.LineItemNo = LineItem.LineItemNo +join T_Requestion_Master Req on Req.ReqNo = LineItem.ReqNo +join T_Employee_Details emp on Req.Requestedby = emp.EmpID + +join T_DepartmentDetails Dept on emp.Departmentcode = Dept.DEPCode where LineItem.PONO =?'; + //print_r($subQuery); + +$query = $this->db->query($subQuery,array($PONO)); + +return $query->result(); + + +} +//get pdf po requistion details + + +function GetPdfRequistionDetails($PONO){ + $this->db->select('LineItem.ReqNo'); + $this->db->from('T_PurchaseOrder_LineItem LineItem'); + $this->db->where('LineItem.PONO',$PONO); + $result=$this->db->get(); + $ReqNo=''; + + foreach ($result->result() as $res){ - return $query->result(); - - - } - //get pdf po requistion details + if($ReqNo==$res->ReqNo){ + + } + else{ + $ReqNo = $res->ReqNo; + $this->db->select('ReqMast.ReqNo,ReqMast.CostCenterCode,ReqMast.ReqDate,ReqMast.Schedule_Type,ReqMast.NumberOfService,ReqMast.Service_Period,Dept.DEPCode,Dept.DepartmentName,Dept.shortName'); + $this->db->from('T_Requestion_Master ReqMast'); + + $this->db->join('T_DepartmentDetails Dept', 'ReqMast.RequestedDept = Dept.DEPCode'); + $this->db->where('ReqMast.ReqNo',$ReqNo); + $Reqresult=$this->db->get(); + $Details['RequistionNo']= $Reqresult->result()[0]->ReqNo; + $Detaisl['ReqDate']=$Reqresult->result()[0]->ReqDate; + + $Details['RequestedDept']= $Reqresult->result()[0]->shortName; + $Details['CostCenterCode']= $Reqresult->result()[0]->CostCenterCode; + $date = new DateTime($Reqresult->result()[0]->ReqDate,new DateTimeZone('Asia/Kolkata')); + $retDate = $date->format('d-m-Y'); + $Details['ReqDate']= $retDate; + $ScheduleType = $Reqresult->result()[0]->Schedule_Type; + if($ScheduleType!='Recurring'){ + $Details['Frequency']= $Reqresult->result()[0]->Schedule_Type; + + } + else{ + $Details['Frequency']= $Reqresult->result()[0]->Service_Period.' - '.$Reqresult->result()[0]->NumberOfService; + } + + $ResultArray[]=$Details; + } + + } - - function GetPdfRequistionDetails($PONO){ - $this->db->select('LineItem.ReqNo'); - $this->db->from('T_PurchaseOrder_LineItem LineItem'); - $this->db->where('LineItem.PONO',$PONO); - $result=$this->db->get(); - $ReqNo=''; - - foreach ($result->result() as $res){ - - if($ReqNo==$res->ReqNo){ - - } - else{ - $ReqNo = $res->ReqNo; - $this->db->select('ReqMast.ReqNo,ReqMast.CostCenterCode,ReqMast.ReqDate,ReqMast.Schedule_Type,ReqMast.NumberOfService,ReqMast.Service_Period,Dept.DEPCode,Dept.DepartmentName,Dept.shortName'); - $this->db->from('T_Requestion_Master ReqMast'); - - $this->db->join('T_DepartmentDetails Dept', 'ReqMast.RequestedDept = Dept.DEPCode'); - $this->db->where('ReqMast.ReqNo',$ReqNo); - $Reqresult=$this->db->get(); - $Details['RequistionNo']= $Reqresult->result()[0]->ReqNo; - $Detaisl['ReqDate']=$Reqresult->result()[0]->ReqDate; - - $Details['RequestedDept']= $Reqresult->result()[0]->shortName; - $Details['CostCenterCode']= $Reqresult->result()[0]->CostCenterCode; - $date = new DateTime($Reqresult->result()[0]->ReqDate,new DateTimeZone('Asia/Kolkata')); - $retDate = $date->format('d-m-Y'); - $Details['ReqDate']= $retDate; - $ScheduleType = $Reqresult->result()[0]->Schedule_Type; - if($ScheduleType!='Recurring'){ - $Details['Frequency']= $Reqresult->result()[0]->Schedule_Type; - - } - else{ - $Details['Frequency']= $Reqresult->result()[0]->Service_Period.' - '.$Reqresult->result()[0]->NumberOfService; - } - - $ResultArray[]=$Details; - } - - } - - $RequistionDetails = $ResultArray; - return $RequistionDetails; - } - function GetLineItemReceivedQty($ParentPO,$MaterialCode) - { - $this->db->select('ReceivedQuantity'); - $this->db->from('T_PurchaseOrder_LineItem'); - - $this->db->where('PONO',$ParentPO); - $this->db->where('MaterialCode',$MaterialCode); - $result=$this->db->get(); - - return $result->result_array(); - } - - //get paymentTerms details + $RequistionDetails = $ResultArray; + return $RequistionDetails; + } +function GetLineItemReceivedQty($ParentPO,$MaterialCode) +{ +$this->db->select('ReceivedQuantity'); +$this->db->from('T_PurchaseOrder_LineItem'); - function getPaymentTermsDetails($Payment_ID='') - { +$this->db->where('PONO',$ParentPO); +$this->db->where('MaterialCode',$MaterialCode); +$result=$this->db->get(); +return $result->result_array(); +} + + +function getPaymentTermsDetails($Payment_ID='') +{ + + +$getpaymentQuery='select distinct PaymentID,PaymentTerms,Details from T_PaymentTerms'; +$paymentQuery=$this->db->query($getpaymentQuery); + +return $paymentQuery->result(); + +} +/** +* This function is used to get status in status table +*/ +function getStatus($StatusType = '') +{ +$this->db->select('StatusCode,StatusName '); +$this->db->from('T_Status'); +$this->db->where('StatusType', $StatusType); +$query = $this->db->get(); + +return $query->result(); +} + + +function edit_mrir($MrirNo) +{ +$this->db->distinct(); +$this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMM.Createdon,TMD.ActualQuantityReceived,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,IGRM.CreatedDate,IGRD.QuantityAsPerInvoice,SUPP.SupplierName,SUPP.Address,POMR.PODate,POMR.DeliveryDate,POMR.ServiceDescription,TMD.MaterialCode,MM.MaterialName,MM.UOM,POLT.Quantity,POLT.ReceivedQuantity,ED.FirstName as PORasiedbyName,ED1.FirstName as MRIRRasiedbyName, ED2.FirstName as IGRRasiedbyName,TMM.MRIRStatus,TMM.Createdon as MRIRCreatedon,POLT.CostCenterCode,CostCenterName,QuantityAccepted,QuantityRejected,TMD.Remarks'); +$this->db->from ('T_MRIR_Master TMM'); +$this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO = TMD.MRIRNO','left');//to get IGRNO,PONO,MRIRNO,mrirdate, +$this->db->join ('T_IGR_Master IGRM', 'IGRM.IGRNO = TMM.IGRNO','left');//to get actualquantity,deliverydate,Invoicedate,vechileno,courierno,igrdate, +$this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO = POMR.PONO','left');//to get podate,deliverydate,servicedescription +$this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO','left');//to get receivedquantity,quantity +$this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO = IGRM.IGRNO','left');//to get invoicequantity +$this->db->join ('T_MaterialMaster MM','IGRD.MaterialCode = MM.MaterialCode','left'); +$this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID = SUPP.SupplierID','left');//to get suppliername,supplieraddress +$this->db->join ('tbl_users user','user.userid = POMR.CreatedBy','left');//to get poraisedby +$this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left'); +$this->db->join ('tbl_users user1','user1.userid=TMM.CreatedBy','left');//to get mrirraisedby +$this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID','left'); +$this->db->join ('tbl_users user2','user2.userid=IGRM.CreatedBy','left');//to get igrraisedby +$this->db->join ('T_Employee_Details ED2','ED2.EmpID = user2.EmpID','left'); +$this->db->join('T_CostCenter_Master TCOST','POLT.CostCenterCode=TCOST.CostCenterCode'); +$this->db->where('TMM.MRIRNO',$MrirNo); +$this->db->group_by('TMM.MRIRNO,TMD.MaterialCode'); +$query = $this->db->get(); +$result = $query->result(); +//print_r( $this->db->last_query()); +return $result; + +} + + + + + +function getadvancePONO($Status='') +{ +$this->db->select ('Mast.PONO,POType,Mast.CreatedDate,Mast.ReleasedOn,Mast.TotalOrderValue,Mast.SupplierID,DeliveryDate,DeliverySchedule,DeliveryOption,Mast.PaymentTerms as Paycode,Payterm.PaymentTerms,LineItem.ReqNo,Requestedby,Departmentcode,DepartmentName,LineItem.CostCenterCode,SupDet.SupplierName,Import_DispatchDetails,CurrencyType,AdvancePercentage,AdvanceAmount,POAdv.Remarks,Mast.CapitalRange,Mast.PaymentOtherDescription,RequestedDept'); +$this->db->from('T_PurchaseOrder_Master Mast'); +$this->db->join('T_PurchaseOrder_LineItem LineItem','Mast.PONO=LineItem.PONO'); +$this->db->join('T_Requestion_Master ReqMa','LineItem.ReqNo=ReqMa.ReqNo'); +$this->db->join('T_Employee_Details EmpDet','ReqMa.Requestedby=EmpDet.EmpID','left'); +$this->db->join('T_DepartmentDetails DepDet','EmpDet.Departmentcode=DepDet.DEPCode or ReqMa.RequestedDept=DepDet.DEPCode','left'); +$this->db->join('T_SupplierDetailsN SupDet','Mast.SupplierID=SupDet.SupplierID'); +$this->db->join('T_PurchaseOrder_AdvanceRequest POAdv','Mast.PONO=POAdv.PONO','left'); +$this->db->join('T_PaymentTerms Payterm','Mast.PaymentTerms=Payterm.PaymentID'); +$this->db->where('Mast.Status',$Status); +$query = $this->db->get(); +// print_r($this->db->last_query()); +return $query->result(); + +} + +// update req deatail if work status is completed + +function updateReqDetail($PONO,$POStatus,$MaterialCode) +{ + +$this->db->set('Req.Status',$POStatus); +$this->db->where('Item.PONO',$PONO); +$this->db->where('Req.MaterialCode',$MaterialCode); +$this->db->update('T_PurchaseOrder_LineItem Item JOIN T_Requestion_Details Req ON Item.ReqNo= Req.ReqNo'); +return TRUE; +} + +function UpdateReceivedQtyforServicePO($PONO,$updateddt,$updatedBy) +{ + $this->db->select('LineItemNo,MaterialCode'); + $this->db->from('T_PurchaseOrder_LineItem'); + $this->db->where('PONO ',$PONO ); + $query = $this->db->get(); + $result = $query->result(); - $getpaymentQuery='select distinct PaymentID,PaymentTerms,Details from T_PaymentTerms'; - $paymentQuery=$this->db->query($getpaymentQuery); + if(!empty($result)) + { + foreach ($result as $res) + { + $LineItemNo =$res->LineItemNo; + $MaterialCode = $res->MaterialCode; + //echo $LineItemNo; + + $subQuery = 'update T_PurchaseOrder_LineItem + set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=? and LineItemNo=?'; + + $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$LineItemNo)); + $finddot = strpos($PONO,'.'); + if($finddot = true) + { + $subQuery = 'update T_PurchaseOrder_LineItem + set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=substring(?,1,(case when INstr(?,?) > 0 then INstr(?,?)-1 else 0 end)) and MaterialCode=?'; + + $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$PONO,'.',$PONO,'.',$MaterialCode)); + } - return $paymentQuery->result(); + } + + } + +} +//get service tax listusing po number +function GetServiceTaxDetails($PONO = ''){ - } - /** - * This function is used to get status in status table - - */ - function getStatus($StatusType = '') - { - $this->db->select('StatusCode,StatusName '); - $this->db->from('T_Status'); - $this->db->where('StatusType', $StatusType); - $query = $this->db->get(); - - return $query->result(); - } + $taxQuery ='SELECT group_concat(@count:=@count+1) Itemcode, +st.CGST,st.SGST,st.IGST,st.otherallowance FROM T_Service_Tax st + join T_PurchaseOrder_LineItem pl on pl.LineItemNo=st.LineItemNo + join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO JOIN + (SELECT @count := 0) count + where pm.POType=? and pm.PONO=? + group by st.CGST,st.SGST,st.IGST,st.otherallowance + ORDER BY Itemcode ASC '; + +$query = $this->db->query($taxQuery,array("SERVICE",$PONO)); - function edit_mrir($MrirNo) - { - $this->db->distinct(); - $this->db->select('TMM.MRIRNO,TMM.PONO,TMM.IGRNO,TMM.Createdon,TMD.ActualQuantityReceived,IGRM.DeliveryChellanOrInvoiceNo,IGRM.DeliveryChellanDate,IGRM.VehicleNo,IGRM.CourierNo,IGRM.CreatedDate,IGRD.QuantityAsPerInvoice,SUPP.SupplierName,SUPP.Address,POMR.PODate,POMR.DeliveryDate,POMR.ServiceDescription,TMD.MaterialCode,MM.MaterialName,MM.UOM,POLT.Quantity,POLT.ReceivedQuantity,ED.FirstName as PORasiedbyName,ED1.FirstName as MRIRRasiedbyName, ED2.FirstName as IGRRasiedbyName,TMM.MRIRStatus,TMM.Createdon as MRIRCreatedon,POLT.CostCenterCode,CostCenterName,QuantityAccepted,QuantityRejected,TMD.Remarks'); - $this->db->from ('T_MRIR_Master TMM'); - $this->db->join ('T_MRIR_Details TMD','TMM.MRIRNO = TMD.MRIRNO','left');//to get IGRNO,PONO,MRIRNO,mrirdate, - $this->db->join ('T_IGR_Master IGRM', 'IGRM.IGRNO = TMM.IGRNO','left');//to get actualquantity,deliverydate,Invoicedate,vechileno,courierno,igrdate, - $this->db->join ('T_PurchaseOrder_Master POMR ','IGRM.PONO = POMR.PONO','left');//to get podate,deliverydate,servicedescription - $this->db->join ('T_PurchaseOrder_LineItem POLT','IGRM.PONO=POLT.PONO','left');//to get receivedquantity,quantity - - $this->db->join ('T_IGR_Details IGRD','IGRD.IGRNO = IGRM.IGRNO','left');//to get invoicequantity - $this->db->join ('T_MaterialMaster MM','IGRD.MaterialCode = MM.MaterialCode','left'); - $this->db->join ('T_SupplierDetailsN SUPP','POMR.SupplierID = SUPP.SupplierID','left');//to get suppliername,supplieraddress - $this->db->join ('tbl_users user','user.userid = POMR.CreatedBy','left');//to get poraisedby - $this->db->join ('T_Employee_Details ED','ED.EmpID = user.EmpID','left'); - $this->db->join ('tbl_users user1','user1.userid=TMM.CreatedBy','left');//to get mrirraisedby - $this->db->join ('T_Employee_Details ED1','ED1.EmpID = user1.EmpID','left'); - $this->db->join ('tbl_users user2','user2.userid=IGRM.CreatedBy','left');//to get igrraisedby - $this->db->join ('T_Employee_Details ED2','ED2.EmpID = user2.EmpID','left'); - $this->db->join('T_CostCenter_Master TCOST','POLT.CostCenterCode=TCOST.CostCenterCode'); - $this->db->where('TMM.MRIRNO',$MrirNo); - $this->db->group_by('TMM.MRIRNO,TMD.MaterialCode'); - $query = $this->db->get(); - $result = $query->result(); - //print_r( $this->db->last_query()); - return $result; +return $query->result(); +} +// get capital tax listing by po no +function GetCapitalTaxListDetails($PONO = '',$CapitalRange=''){ + +if($CapitalRange==1){ +$taxQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode,SUM(st.`After_CGST`) AS TotalCGST,SUM(st.`After_SGST`) AS TotalSGST,SUM(st.`After_IGST`) AS TotalIGST,SUM(st.`otherallowance`) AS TotalOtherAllowance,SUM(st.`Afterdiscountval`) AS TotalDiscount,st.discountval,st.Afterdiscountval,st.CGST,st.SGST,st.IGST,st.otherallowance,SUM(st.`AfterFreightValue`) AS TotalFreight,st.FreightValue FROM T_Service_Tax st + join T_PurchaseOrder_LineItem pl on pl.LineItemNo=st.LineItemNo + join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO + where pm.POType=? and pm.PONO=? + group by st.Afterdiscountval,st.CGST,st.SGST,st.IGST,st.otherallowance ORDER BY st.LineItemNo ASC'; +$query = $this->db->query($taxQuery,array("CAPITAL",$PONO)); + +return $query->result(); + } +else if($CapitalRange==0){ +$taxQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode, +SUM(it.`AfterFreightValue`) AS TotalFreight,it.FreightValue,it.AfterFreightValue, +it.IGST AS TotalIGSTPer,SUM(it.AfterIGST) as AfterIGST1,it.AfterIGST as AIgst FROM T_Import_Tax it + join T_PurchaseOrder_LineItem pl on pl.LineItemNo=it.LineItemNo + join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO + where pm.POType=? and pm.PONO=? + group by it.AfterFreightValue ORDER BY it.LineItemNo ASC'; +$query = $this->db->query($taxQuery,array("CAPITAL",$PONO)); + +return $query->result(); } +} +// get po format for acedamic year based +function GetPoFormat($PONO=''){ +$poQuery ='select PONO from T_PurchaseOrder_Master where PONO=?'; +$query = $this->db->query($poQuery,array($PONO)); - - - - function getadvancePONO($Status='') - { - $this->db->select ('Mast.PONO,POType,Mast.CreatedDate,Mast.ReleasedOn,Mast.TotalOrderValue,Mast.SupplierID,DeliveryDate,DeliverySchedule,DeliveryOption,Mast.PaymentTerms as Paycode,Payterm.PaymentTerms,LineItem.ReqNo,Requestedby,Departmentcode,DepartmentName,LineItem.CostCenterCode,SupDet.SupplierName,Import_DispatchDetails,CurrencyType,AdvancePercentage,AdvanceAmount,POAdv.Remarks,Mast.CapitalRange,Mast.PaymentOtherDescription,RequestedDept'); - $this->db->from('T_PurchaseOrder_Master Mast'); - $this->db->join('T_PurchaseOrder_LineItem LineItem','Mast.PONO=LineItem.PONO'); - $this->db->join('T_Requestion_Master ReqMa','LineItem.ReqNo=ReqMa.ReqNo'); - $this->db->join('T_Employee_Details EmpDet','ReqMa.Requestedby=EmpDet.EmpID','left'); - $this->db->join('T_DepartmentDetails DepDet','EmpDet.Departmentcode=DepDet.DEPCode or ReqMa.RequestedDept=DepDet.DEPCode','left'); - $this->db->join('T_SupplierDetailsN SupDet','Mast.SupplierID=SupDet.SupplierID'); - $this->db->join('T_PurchaseOrder_AdvanceRequest POAdv','Mast.PONO=POAdv.PONO','left'); - $this->db->join('T_PaymentTerms Payterm','Mast.PaymentTerms=Payterm.PaymentID'); - $this->db->where('Mast.Status',$Status); - $query = $this->db->get(); - // print_r($this->db->last_query()); - return $query->result(); - - } - - // update req deatail if work status is completed - - function updateReqDetail($PONO,$POStatus,$MaterialCode) - { - - $this->db->set('Req.Status',$POStatus); - $this->db->where('Item.PONO',$PONO); - $this->db->where('Req.MaterialCode',$MaterialCode); - $this->db->update('T_PurchaseOrder_LineItem Item JOIN T_Requestion_Details Req ON Item.ReqNo= Req.ReqNo'); - return TRUE; - } - - function UpdateReceivedQtyforServicePO($PONO,$updateddt,$updatedBy) - { - $this->db->select('LineItemNo,MaterialCode'); - $this->db->from('T_PurchaseOrder_LineItem'); - $this->db->where('PONO ',$PONO ); - $query = $this->db->get(); - $result = $query->result(); - - if(!empty($result)) - { - foreach ($result as $res) - { - $LineItemNo =$res->LineItemNo; - $MaterialCode = $res->MaterialCode; - //echo $LineItemNo; - - $subQuery = 'update T_PurchaseOrder_LineItem - set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=? and LineItemNo=?'; - - $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$LineItemNo)); - $finddot = strpos($PONO,'.'); - if($finddot = true) - { - $subQuery = 'update T_PurchaseOrder_LineItem - set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=substring(?,1,(case when INstr(?,?) > 0 then INstr(?,?)-1 else 0 end)) and MaterialCode=?'; - - $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$PONO,'.',$PONO,'.',$MaterialCode)); - } - - } - - } - - } -//get service tax listusing po number - function GetServiceTaxDetails($PONO = ''){ - - $taxQuery ='SELECT group_concat(@count:=@count+1) Itemcode, -st.CGST,st.SGST,st.IGST,st.otherallowance FROM T_Service_Tax st - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=st.LineItemNo - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO JOIN - (SELECT @count := 0) count - where pm.POType=? and pm.PONO=? - group by st.CGST,st.SGST,st.IGST,st.otherallowance - ORDER BY Itemcode ASC '; - - - $query = $this->db->query($taxQuery,array("SERVICE",$PONO)); - - return $query->result(); - } - // get capital tax listing by po no - - function GetCapitalTaxListDetails($PONO = '',$CapitalRange=''){ - - if($CapitalRange==1){ - $taxQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode,SUM(st.`After_CGST`) AS TotalCGST,SUM(st.`After_SGST`) AS TotalSGST,SUM(st.`After_IGST`) AS TotalIGST,SUM(st.`otherallowance`) AS TotalOtherAllowance,SUM(st.`Afterdiscountval`) AS TotalDiscount,st.discountval,st.Afterdiscountval,st.CGST,st.SGST,st.IGST,st.otherallowance,SUM(st.`AfterFreightValue`) AS TotalFreight,st.FreightValue FROM T_Service_Tax st - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=st.LineItemNo - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO - where pm.POType=? and pm.PONO=? - group by st.Afterdiscountval,st.CGST,st.SGST,st.IGST,st.otherallowance ORDER BY st.LineItemNo ASC'; - $query = $this->db->query($taxQuery,array("CAPITAL",$PONO)); - - return $query->result(); - } - else if($CapitalRange==0){ - $taxQuery ='SELECT group_concat(pl.MaterialCode ORDER BY pl.MaterialCode ASC) as Itemcode, - SUM(it.`AfterFreightValue`) AS TotalFreight,it.FreightValue,it.AfterFreightValue, - it.IGST AS TotalIGSTPer,SUM(it.AfterIGST) as AfterIGST1,it.AfterIGST as AIgst FROM T_Import_Tax it - join T_PurchaseOrder_LineItem pl on pl.LineItemNo=it.LineItemNo - join T_PurchaseOrder_Master pm on pm.PONO=pl.PONO - where pm.POType=? and pm.PONO=? - group by it.AfterFreightValue ORDER BY it.LineItemNo ASC'; - $query = $this->db->query($taxQuery,array("CAPITAL",$PONO)); - - return $query->result(); - } - - } - // get po format for acedamic year based - function GetPoFormat($PONO=''){ - $poQuery ='select PONO from T_PurchaseOrder_Master where PONO=?'; - $query = $this->db->query($poQuery,array($PONO)); - - return $query->result(); +return $query->result(); } //get Dept Emp Name function getDepartmentEmpList($DepCode=''){ - $this->db->select('EmpID'); - $this->db->from('T_Employee_Details'); - $this->db->where('Departmentcode', $DepCode); - $this->db->limit('1'); - $query = $this->db->get(); - - return $query->result(); +$this->db->select('EmpID'); +$this->db->from('T_Employee_Details'); +$this->db->where('Departmentcode', $DepCode); +$this->db->limit('1'); +$query = $this->db->get(); + +return $query->result(); } //get req master details using reqno function GetRequistionMasterUsingReqNo($Req){ - $this->db->select('Requestedby'); - $this->db->from('T_Requestion_Master'); - $this->db->where('ReqNo', $Req[0]); - $query = $this->db->get(); - - return $query->result(); +$this->db->select('Requestedby'); +$this->db->from('T_Requestion_Master'); +$this->db->where('ReqNo', $Req[0]); +$query = $this->db->get(); + +return $query->result(); } function amendpdf($PONO='') { - $Amend ='select p.PONO,p.ParentPO,p.Status,p.TotalOrderValue, - m.Status as parentpostatus, - m.TotalOrderValue as partenttotalorder - from T_PurchaseOrder_Master as p - join T_PurchaseOrder_Master as m - on m.PONO = p.ParentPO - where p.PONO = ?'; - $amendment = $this->db->query($Amend,array($PONO)); - - return $amendment->result(); +$Amend ='select p.PONO,p.ParentPO,p.Status,p.TotalOrderValue, +m.Status as parentpostatus, +m.TotalOrderValue as partenttotalorder +from T_PurchaseOrder_Master as p +join T_PurchaseOrder_Master as m +on m.PONO = p.ParentPO +where p.PONO = ?'; +$amendment = $this->db->query($Amend,array($PONO)); + +return $amendment->result(); } function updatefile($bill,$Picture,$oldfile) { - // if($oldfile != ''){ - // //unlink("uploads/BillFiles/".$oldfile);//this deletes the file on particular folder too - // } - +// if($oldfile != ''){ +// //unlink("uploads/BillFiles/".$oldfile);//this deletes the file on particular folder too +// } $this->db->set('FilePath', $Picture); //value that used to update column $this->db->where('BillNo', $bill); //which row want to upgrade $this->db->update('T_PurchaseOrder_BillUpload'); @@ -1881,59 +1882,50 @@ function insertlogpo($logpo){ $this->db->trans_start(); $this->db->insert('T_POlog_Details',$logpo); - $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - return $insert_id; + $insert_id = $this->db->affected_rows(); + $this->db->trans_complete(); + return $insert_id; } function getlogpodtl($PONO){ -$SQL = "select log.*,sup.SupplierName,emp.FirstName from - T_POlog_Details log - join tbl_users user on user.userId = log.UpdateBy - left join T_Employee_Details emp on emp.EmpID= user.EmpID - left join T_SupplierDetailsN sup on sup.SupplierID = log.OldValue - where PONO ='".$PONO."'"; + $SQL = "select log.*,sup.SupplierName,emp.FirstName from + T_POlog_Details log + join tbl_users user on user.userId = log.UpdateBy + left join T_Employee_Details emp on emp.EmpID= user.EmpID + left join T_SupplierDetailsN sup on sup.SupplierID = log.OldValue + where PONO ='".$PONO."'"; -$logpodtl = $this->db->query($SQL); - - return $logpodtl->result(); + $logpodtl = $this->db->query($SQL); + + return $logpodtl->result(); } +function insertfile($filelist) +{ + $this->db->insert('T_PurchaseOrder_BillUpload',$filelist); + $myfile=$this->db->affected_rows(); + return $myfile; +} - - - function insertfile($filelist) - { - - $this->db->insert('T_PurchaseOrder_BillUpload',$filelist); - $myfile=$this->db->affected_rows(); - return $myfile; - } - - - function updateigrM($PONO,$IGRNo,$igrMaster){ + $this->db->where('PONO',$PONO); + $this->db->where('IGRNO',$IGRNo); + $this->db->update('T_IGR_Master',$igrMaster); - - $this->db->where('PONO',$PONO); - $this->db->where('IGRNO',$IGRNo); - - $this->db->update('T_IGR_Master',$igrMaster); - - $r = $this->db->affected_rows(); - return $r; + $r = $this->db->affected_rows(); + return $r; } function getigrno($bill){ - $subQuery ='select bill.BillNo,IGR.IGRNO, IGR.PONO FROM T_IGR_Master IGR - join T_PurchaseOrder_BillUpload bill on bill.IGRNO = IGR.IGRNO - where bill.BillNO = ? '; - - $query = $this->db->query($subQuery,array($bill)); - - return $query->result_array(); - } + $subQuery ='select bill.BillNo,IGR.IGRNO, IGR.PONO FROM T_IGR_Master IGR + join T_PurchaseOrder_BillUpload bill on bill.IGRNO = IGR.IGRNO + where bill.BillNO = ? '; + + $query = $this->db->query($subQuery,array($bill)); + + return $query->result_array(); +} } diff --git a/application/views/EditservicePurchaseorder.php b/application/views/EditservicePurchaseorder.php index e9474a0f..2f3552a9 100755 --- a/application/views/EditservicePurchaseorder.php +++ b/application/views/EditservicePurchaseorder.php @@ -1,8 +1,10 @@ "NO","value"=>"0"),array("name"=>"YES","value"=>"1") ); - $DeliverOption=''; +$insuranceStatus = array( +array("name"=>"NO","value"=>"0"),array("name"=>"YES","value"=>"1") +); + $DeliverOption=''; $SupId = ''; - $SupName = ''; + $SupName = ''; $Address = ''; $PODate = ''; @@ -16,7 +18,7 @@ $TotalSummary = 0.0; $TotalBasicAmount = 0.0; $ServiceDescription = ''; - $OtherAmt = 0.0; + $OtherAmt = 0.0; $Deliverydt=''; $DeliverSchedule=''; @@ -39,9 +41,11 @@ if(!empty($INRSYMBOL)) { + foreach($INRSYMBOL as $INRS) { $INRSYM=$INRS->FontCode2000; + } } @@ -53,19 +57,18 @@ if(!empty($MaxPODate)) } } - if(!empty($POMaster)) { foreach ($POMaster as $Req) { $SupId = $Req->SupplierID; - $SupName = $Req->SupplierName; + $SupName = $Req->SupplierName; $Address = $Req->Address; $pdt = new DateTime($Req->PODate); $PODate = $pdt->format('d-m-Y'); $DeliverOption = $Req->DeliveryOption; - $DeliverSchedule = $Req->DeliverySchedule; + $DeliverSchedule = $Req->DeliverySchedule; $Ddt = new DateTime($Req->DeliveryDate); $Deliverydt = $Ddt->format('d-m-Y'); @@ -73,20 +76,19 @@ if(!empty($POMaster)) $PONOStatus = $Req->StatusCode; $PONO = $Req->PONO; $ServiceDescription = $Req->ServiceDescription; - - $WrkStatus=$Req->ServiceWorkStatus; - $StatusName=$Req->StatusName; - $otherPayment = $Req->PaymentOtherDescription; - $ModeOfShipment=$Req->Mode_Of_Shipment; - $SupplierReference=$Req->Supplier_Reference; - $SuppliersOfferNo=$Req->Supplier_Offer_No; - $OtherReferences=$Req->Other_Reference; - $Fincap=$Req->Fincap; - $InsuranceOptions=$Req->InsuranceStatus; - $InsuranceNo=$Req->InsuranceNumber; - $ServiceTypeOptions=$Req->POSubType; - $DescriptionOfPo = $Req->Description_Of_Service; - $BudgetType = $Req->BudgetType; + $WrkStatus=$Req->ServiceWorkStatus; + $StatusName=$Req->StatusName; + $otherPayment = $Req->PaymentOtherDescription; + $ModeOfShipment=$Req->Mode_Of_Shipment; + $SupplierReference=$Req->Supplier_Reference; + $SuppliersOfferNo=$Req->Supplier_Offer_No; + $OtherReferences=$Req->Other_Reference; + $Fincap=$Req->Fincap; + $InsuranceOptions=$Req->InsuranceStatus; + $InsuranceNo=$Req->InsuranceNumber; + $ServiceTypeOptions=$Req->POSubType; + $DescriptionOfPo = $Req->Description_Of_Service; + $BudgetType = $Req->BudgetType; } } @@ -107,7 +109,7 @@ if(!empty($RequistionDetails)) if(!empty($AvlBudAmt)) -{ +{ $AvlAmount = number_format($AvlBudAmt, 2, '.', ''); } @@ -119,10 +121,10 @@ foreach ($PaymentTerms as $TER) if(!empty($getlogpodtl )) { - foreach ($getlogpodtl as $values ) - { +foreach ($getlogpodtl as $values ) +{ $update=$values->FirstName; - } +} } // foreach ($POSTATUS as $PST ) @@ -167,72 +169,72 @@ if(!empty($getlogpodtl )) statusbar: false, toolbar: false }); - + - - - - + \ No newline at end of file diff --git a/application/views/alterpurchaseorder.php b/application/views/alterpurchaseorder.php index 5a13fa27..4de80664 100644 --- a/application/views/alterpurchaseorder.php +++ b/application/views/alterpurchaseorder.php @@ -13,7 +13,7 @@ if(!empty($MaxPODate)) { $MaxPoDate = $date->PODate; } -} +} if(!empty($CompanyDetails)) { foreach ($CompanyDetails as $Req) @@ -25,11 +25,11 @@ if(!empty($CompanyDetails)) if(!empty($INRSYMBOL)) { - foreach($INRSYMBOL as $INRS) - { + foreach($INRSYMBOL as $INRS) + { $INRSYM=$INRS->FontCode2000; - } + } } ?> @@ -41,11 +41,11 @@ if(!empty($INRSYMBOL)) margin-top:200px; z-index: 1080 !important; } - #submitmodel { + #submitmodel { margin-top:200px; z-index: 1080 !important; } - #freightmodel { + #freightmodel { margin-top:200px; z-index: 1080 !important; } @@ -69,12 +69,12 @@ if(!empty($INRSYMBOL)) { text-align:left; } - .nopad { - padding:0px; - } - .select2 { - width:100% ! important; - } + .nopad { + padding:0px; + } + .select2 { + width:100% ! important; + } @@ -116,14 +116,14 @@ if(!empty($INRSYMBOL)) statusbar: false, toolbar: false }); - tinymce.init({ + tinymce.init({ selector: "textarea#Add_Service_Description", //service Edit model description service menubar: false, statusbar: false, toolbar: false }); - tinymce.init({ + tinymce.init({ selector: "textarea#Edit_Service_Description", //service Edit model description service menubar: false, @@ -188,146 +188,15 @@ if(!empty($INRSYMBOL)) dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '0:+10' }); - $("#MRC").datepicker({ + $("#MRC").datepicker({ // minDate : 'now', dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '0:+10' }); - var SelectedMaterialList = { Mat: [] }; - /* $('#drpSupplier').change(function() { - - var id = $('#drpSupplier').val(); - $("#SupAddress").val(''); - - if(id != '0') - { - var y = ; - - - $.each(y, function(idx, obj) { - if(obj.SupplierID === id) - { - $("#SupAddress").val(obj.Address); - - } - - }); - - } - else - { - swal('Please select the SupplierID'); - return false; - } - - }); - - $('#ReqNo').change(function() { - - var id = $('#ReqNo').val(); - $("#deptName").val(''); - $("#CostCenter").empty(); - $("#MaterialCode").empty(); - resetTaxField(); - if(id != '0') - { - var y = ; - var cost = ; - var Material = ; - - // For Binding DepartmentName - $.each(y, function(idx, obj) { - if(obj.ReqNo === id) - { - $("#deptName").val(obj.DepartmentName); - - } - }); - // For Binding Cost center for the selected department - $("#CostCenter").append( $('').val("0").html("Select Cost Center") ); - $.each(cost, function(idx, obj) { - if(obj.ReqNo === id) - { - $("#CostCenter").append( $('').val(obj.CostCenterCode).html(obj.CostCenterCode + "-" + obj.CostCenterName) ); - - } - - }); - // For Binding Material list center for the selected Requistion Number - $("#MaterialCode").append( $('').val("0").html("Select Material Code") ); - $.each(Material, function(idx, obj) { - if(obj.ReqNo === id) - { - $("#MaterialCode").append( $('').val(obj.MaterialCode).html(obj.MaterialCode + "-" + obj.MaterialName) ); - - } - - }); - - } - else - { - swal('Please select the Requisition Number'); - return false; - } - - }); - $('#MaterialCode').change(function() { - - var id = $('#MaterialCode').val(); - RequistQuantity = ''; - resetTaxField(); - if(id != '0') - { - var y = ; - - - $.each(y, function(idx, obj) { - if(obj.MaterialCode === id) - { - $("#ItemName").val(obj.MaterialName); - $("#UOM").val(obj.UOM); - $("#Quantity").val(obj.Quantity); - RequistQuantity = obj.Quantity; - } - }); - } - else - { - swal('Please select the MaterialCode'); - return false; - } - - }); - - $('#CostCenter').change(function() { - - var id = $('#CostCenter').val(); - $("#AvlBudAmt").val(''); - - if(id != '0') - { - var cost = ; - - $.each(cost, function(idx, obj) { - if(obj.CostCenterCode === id) - { - $("#AvlBudAmt").val(obj.BudgetAmount); - } - - }); - } - else - { - swal('Please select the MaterialCode'); - return false; - } - - }); */ /* Revenue Tax calcualation */ $('#DiscountType').change(function() { @@ -340,7 +209,7 @@ var SelectedMaterialList = { $('#txtDiscount').attr('readonly', 'true'); $('#txtDiscount').val('0.00'); $('#txtAfterDiscount').val('0.00'); - change(); + change(); } else @@ -353,34 +222,34 @@ var SelectedMaterialList = { }); $('#EditDiscountType').change(function() { - if($('#EditRevenueRate').val() != '' && $('#EditRevenueMaterialCode').val() != "0" ) - { + if($('#EditRevenueRate').val() != '' && $('#EditRevenueMaterialCode').val() != "0" ) + { selValue = $("#EditDiscountType").val(); - $('#txtEditDiscount').val(''); - $('#txtEditAfterDiscount').val(''); - if (selValue == NilType) - { + $('#txtEditDiscount').val(''); + $('#txtEditAfterDiscount').val(''); + if (selValue == NilType) + { - $('#txtEditDiscount').attr('readonly', 'true'); - $('#txtEditDiscount').val('0.00'); - $('#txtEditAfterDiscount').val('0.00'); - change(); - - } - else - { - $('#txtEditDiscount').removeAttr( 'readonly','true' ); - $('#txtEditDiscount').val(''); - $('#txtEditAfterDiscount').val(''); - change(); - } - } + $('#txtEditDiscount').attr('readonly', 'true'); + $('#txtEditDiscount').val('0.00'); + $('#txtEditAfterDiscount').val('0.00'); + change(); + + } + else + { + $('#txtEditDiscount').removeAttr( 'readonly','true' ); + $('#txtEditDiscount').val(''); + $('#txtEditAfterDiscount').val(''); + change(); + } + } else - { - swal('Please Select MaterialCode and Rate Field Value'); - $('#EditDiscountType').val("0"); - $('#EditRate').focus(); - } + { + swal('Please Select MaterialCode and Rate Field Value'); + $('#EditDiscountType').val("0"); + $('#EditRate').focus(); + } Editchange(); }); @@ -402,7 +271,7 @@ var SelectedMaterialList = { $('#txtPackaging').attr('readonly', 'true'); $('#txtPackaging').val('0.00'); $('#txtAfterPackaging').val('0.00'); - change(); + change(); } else { @@ -412,30 +281,30 @@ var SelectedMaterialList = { //change(); }); $('#EditPackagingType').change(function() { - $('#txtEditPackaging').val(''); - $('#txtEditAfterPackaging').val(''); + $('#txtEditPackaging').val(''); + $('#txtEditAfterPackaging').val(''); selValue = $("#EditPackagingType").val() ; - if(selValue == PercentageType) - { + if(selValue == PercentageType) + { var PackagingCalculation = ''; - $('#packagingcalmodel').modal('show'); - $('#txtEditPackaging').removeAttr( 'readonly','true' ); - } - else - { - if (selValue == NilType) - { + $('#packagingcalmodel').modal('show'); + $('#txtEditPackaging').removeAttr( 'readonly','true' ); + } + else + { + if (selValue == NilType) + { - $('#txtEditPackaging').attr('readonly', 'true'); - $('#txtEditPackaging').val('0.00'); - $('#txtEditAfterPackaging').val('0.00'); - Editchange(); - } - else - { - $('#txtEditPackaging').removeAttr( 'readonly','true' ); - } - } + $('#txtEditPackaging').attr('readonly', 'true'); + $('#txtEditPackaging').val('0.00'); + $('#txtEditAfterPackaging').val('0.00'); + Editchange(); + } + else + { + $('#txtEditPackaging').removeAttr( 'readonly','true' ); + } + } //change(); }); @@ -465,33 +334,33 @@ var SelectedMaterialList = { }); $('#drpEditFreight').change(function() { - $('#txtEditFreight').val(''); - $('#txtEditAfterFreight').val(''); - var FreightType =$("#drpEditFreight").val(); - // selValue = $("#drpFreight").val() ; + $('#txtEditFreight').val(''); + $('#txtEditAfterFreight').val(''); + var FreightType =$("#drpEditFreight").val(); + // selValue = $("#drpFreight").val() ; - if (FreightType == "PER TRIP") - { - - $('#EditTripsValue').show(); - } - else { - - $('#EditTripsValue').hide(); - } - if(FreightType == PercentageType) - { + if (FreightType == "PER TRIP") + { + + $('#EditTripsValue').show(); + } + else { + + $('#EditTripsValue').hide(); + } + if(FreightType == PercentageType) + { var freightCalculation = ''; - $('#freightmodel').modal('show'); - $('#txtEditFreight').removeAttr( 'readonly','true'); - } - else if (selValue == NilType) + $('#freightmodel').modal('show'); + $('#txtEditFreight').removeAttr( 'readonly','true'); + } + else if (selValue == NilType) { $('#txtEditFreight').attr('readonly', 'true'); $('#txtEditFreight').val('0.00'); $('#txtEditAfterFreight').val('0.00'); - Editchange(); + Editchange(); } else { @@ -500,37 +369,37 @@ var SelectedMaterialList = { } - // selValue = $("#drpEditFreight").val() ; + // selValue = $("#drpEditFreight").val() ; - }); - //add // + }); + //add // $('#drpFreight').change(function() { - var FreightType =$("#drpFreight").val(); - - if (FreightType == "PER TRIP") - { - - $('#TripsValue').show(); - } - else { - - $('#TripsValue').hide(); - } + var FreightType =$("#drpFreight").val(); + + if (FreightType == "PER TRIP") + { + + $('#TripsValue').show(); + } + else { + + $('#TripsValue').hide(); + } selValue = $("#drpFreight").val() ; if(selValue == PercentageType) - { + { var freightCalculation = ''; - $('#freightmodel').modal('show'); - $('#txtFreight').removeAttr( 'readonly','true' ); - } + $('#freightmodel').modal('show'); + $('#txtFreight').removeAttr( 'readonly','true' ); + } else if (selValue == NilType) { $('#txtFreight').attr('readonly', 'true'); $('#txtFreight').val('0.00'); $('#txtAfterFreight').val('0.00'); - change(); + change(); } else { @@ -549,1058 +418,1058 @@ var SelectedMaterialList = { function calculateDiscount(isEdit) { - if(isEdit == '0') - { + if(isEdit == '0') + { if($('#MaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtDiscount').val(''); - return false; - } - else if($('#Rate').val() == '') - { - swal('Please Enter the Rate value'); - $('#Rate').focus(); - $('#txtDiscount').val(''); - return false; - } + { + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtDiscount').val(''); + return false; + } + else if($('#Rate').val() == '') + { + swal('Please Enter the Rate value'); + $('#Rate').focus(); + $('#txtDiscount').val(''); + return false; + } if($('#Rate').val() != '' && $('#MaterialCode').val() != "0" ) - { - - var basicValue = parseFloat($('#txtBasicValue').val()); - var DiscountType =$("#DiscountType").val(); + { + + var basicValue = parseFloat($('#txtBasicValue').val()); + var DiscountType =$("#DiscountType").val(); - if(DiscountType == "0") - { - swal('Please Select the discount Type'); - $('#txtDiscount').val(''); - $("#DiscountType").focus(); - } - else if ($('#txtDiscount').val() != '' && $('#txtDiscount').val() != '0') - { - var AfterDiscount = 0.0; - var Discountval = parseFloat($('#txtDiscount').val()); - if(DiscountType == PercentageType) - { - - AfterDiscount = ; - - } - else if(DiscountType == NilType ) - { - AfterDiscount = "0.00"; - - } - else - { - AfterDiscount = ; - } - var discount = parseFloat(AfterDiscount).toFixed(2); - $('#txtAfterDiscount').val(discount); - } - else - { - $('#txtAfterDiscount').val("0.00"); - } - } - - calculateTotalValue(); - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - $('#txtEditDiscount').val(''); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRevenueRate').focus(); - $('#txtEditDiscount').val(''); - return false; - } - if($('#EditRevenueRate').val() != '' && $('#EditRevenueMaterialCode').val() != "0" ) - { - - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - var DiscountType =$("#EditDiscountType").val(); - - if(DiscountType == "0") - { - swal('Please Select the discount Type'); - $('#txtEditDiscount').val(''); - $("#EditDiscountType").focus(); - } - else if ($('#txtEditDiscount').val() != '' && $('#txtEditDiscount').val() != '0') - { - var AfterDiscount = 0.0; - var Discountval = parseFloat($('#txtEditDiscount').val()); - if(DiscountType == PercentageType) - { - - AfterDiscount = ; - - } - else if(DiscountType == NilType ) - { - AfterDiscount = "0.00"; - } - else - { - AfterDiscount = ; - } - var discount = parseFloat(AfterDiscount).toFixed(2); - - $('#txtEditAfterDiscount').val(discount); - } - else - { - $('#txtEditAfterDiscount').val("0.00"); - } - } + if(DiscountType == "0") + { + swal('Please Select the discount Type'); + $('#txtDiscount').val(''); + $("#DiscountType").focus(); + } + else if ($('#txtDiscount').val() != '' && $('#txtDiscount').val() != '0') + { + var AfterDiscount = 0.0; + var Discountval = parseFloat($('#txtDiscount').val()); + if(DiscountType == PercentageType) + { + + AfterDiscount = ; + + } + else if(DiscountType == NilType ) + { + AfterDiscount = "0.00"; + + } + else + { + AfterDiscount = ; + } + var discount = parseFloat(AfterDiscount).toFixed(2); + $('#txtAfterDiscount').val(discount); + } + else + { + $('#txtAfterDiscount').val("0.00"); + } + } + + calculateTotalValue(); + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + $('#txtEditDiscount').val(''); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRevenueRate').focus(); + $('#txtEditDiscount').val(''); + return false; + } + if($('#EditRevenueRate').val() != '' && $('#EditRevenueMaterialCode').val() != "0" ) + { + + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + var DiscountType =$("#EditDiscountType").val(); + + if(DiscountType == "0") + { + swal('Please Select the discount Type'); + $('#txtEditDiscount').val(''); + $("#EditDiscountType").focus(); + } + else if ($('#txtEditDiscount').val() != '' && $('#txtEditDiscount').val() != '0') + { + var AfterDiscount = 0.0; + var Discountval = parseFloat($('#txtEditDiscount').val()); + if(DiscountType == PercentageType) + { + + AfterDiscount = ; + + } + else if(DiscountType == NilType ) + { + AfterDiscount = "0.00"; + } + else + { + AfterDiscount = ; + } + var discount = parseFloat(AfterDiscount).toFixed(2); + + $('#txtEditAfterDiscount').val(discount); + } + else + { + $('#txtEditAfterDiscount').val("0.00"); + } + } calculateEditVatValue(); - calculateEditTotalValue(); - } + calculateEditTotalValue(); + } } /* * To calcuate the Packaging */ function calculatePackaging(isEdit) { - if(isEdit == '0') - { - if($('#MaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtPackaging').val(''); - return false; - } - else if($('#Rate').val() == '') - { - swal('Please Enter the Rate value'); - $('#Rate').focus(); - $('#txtPackaging').val(''); - return false; - } - else - { - - var basicValue = parseFloat($('#txtBasicValue').val()); - - var PackagingType =$("#PackagingType").val(); - - if(PackagingType == "0") - { - swal('Please select the Packaging Type'); - $('#txtPackaging').val(''); - $("#PackagingType").focus(); - } - - else if($('#txtPackaging').val() != '' && $('#txtPackaging').val() !='0') - { - var Packagingvalue = parseFloat($('#txtPackaging').val()); - var AfterPackaging = 0.0; - - if(PackagingType == PercentageType) - { - if($(PackagingCalculation != 0 && '#txtAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#txtPackaging').val(''); - $('#DiscountType').focus(); - - return false; - } - else - { - var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); - AfterPackaging = PackagingCalculation == 0 ? : ; - } - - } - else if(PackagingType == NilType ) - { - AfterPackaging = 0.00; - //Change(); - - } - else - { - - - AfterPackaging = PackagingCalculation == 0 ? : ; - - } - var Packaging = parseFloat(AfterPackaging).toFixed(2); - - $('#txtAfterPackaging').val(Packaging); - //RevenueChangeSgst(); - } - else - { - $('#txtAfterPackaging').val("0.00"); - } - } - - calculateTotalValue(); - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - $('#txtEditPackaging').val(''); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRate').focus(); - $('#txtEditPackaging').val(''); - return false; - } - - else - { - - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - - var PackagingType =$("#EditPackagingType").val(); - - if(PackagingType == "0") - { - swal('Please select the Packaging Type'); - $('#txtEditPackaging').val(''); - $("#EditPackagingType").focus(); - } - - else if($('#txtEditPackaging').val() != '' && $('#txtEditPackaging').val() !='0') - { - var Packagingvalue = parseFloat($('#txtEditPackaging').val()); - var AfterPackaging = 0.0; - - if(PackagingType == PercentageType) - { - if(PackagingCalculation != 0 &&$('#txtEditAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#EditDiscountType').focus(); - $('#txtEditPackaging').val(''); - return false; - } - else - { - var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); - AfterPackaging = PackagingCalculation == 0 ? : ; - } - - } - else if(PackagingType == NilType ) - { - AfterPackaging = "0.00"; - // $('#txtEditAfterPackaging').val(AfterPackaging); - //RevenueChangeSgst(); - } - else - { - - AfterPackaging = PackagingCalculation == 0 ? : ; - - } - var Packaging = parseFloat(AfterPackaging).toFixed(2); - - $('#txtEditAfterPackaging').val(Packaging); - //RevenueChangeEditSgst(); - } - else - { - $('#txtEditAfterPackaging').val("0.00"); - } - } - calculateEditVatValue(); - calculateEditTotalValue(); - } + if(isEdit == '0') + { + if($('#MaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtPackaging').val(''); + return false; + } + else if($('#Rate').val() == '') + { + swal('Please Enter the Rate value'); + $('#Rate').focus(); + $('#txtPackaging').val(''); + return false; + } + else + { + + var basicValue = parseFloat($('#txtBasicValue').val()); + + var PackagingType =$("#PackagingType").val(); + + if(PackagingType == "0") + { + swal('Please select the Packaging Type'); + $('#txtPackaging').val(''); + $("#PackagingType").focus(); + } + + else if($('#txtPackaging').val() != '' && $('#txtPackaging').val() !='0') + { + var Packagingvalue = parseFloat($('#txtPackaging').val()); + var AfterPackaging = 0.0; + + if(PackagingType == PercentageType) + { + if($(PackagingCalculation != 0 && '#txtAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#txtPackaging').val(''); + $('#DiscountType').focus(); + + return false; + } + else + { + var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); + AfterPackaging = PackagingCalculation == 0 ? : ; + } + + } + else if(PackagingType == NilType ) + { + AfterPackaging = 0.00; + //Change(); + + } + else + { + + + AfterPackaging = PackagingCalculation == 0 ? : ; + + } + var Packaging = parseFloat(AfterPackaging).toFixed(2); + + $('#txtAfterPackaging').val(Packaging); + //RevenueChangeSgst(); + } + else + { + $('#txtAfterPackaging').val("0.00"); + } + } + + calculateTotalValue(); + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + $('#txtEditPackaging').val(''); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRate').focus(); + $('#txtEditPackaging').val(''); + return false; + } + + else + { + + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + + var PackagingType =$("#EditPackagingType").val(); + + if(PackagingType == "0") + { + swal('Please select the Packaging Type'); + $('#txtEditPackaging').val(''); + $("#EditPackagingType").focus(); + } + + else if($('#txtEditPackaging').val() != '' && $('#txtEditPackaging').val() !='0') + { + var Packagingvalue = parseFloat($('#txtEditPackaging').val()); + var AfterPackaging = 0.0; + + if(PackagingType == PercentageType) + { + if(PackagingCalculation != 0 &&$('#txtEditAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#EditDiscountType').focus(); + $('#txtEditPackaging').val(''); + return false; + } + else + { + var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); + AfterPackaging = PackagingCalculation == 0 ? : ; + } + + } + else if(PackagingType == NilType ) + { + AfterPackaging = "0.00"; + + //RevenueChangeSgst(); + } + else + { + + AfterPackaging = PackagingCalculation == 0 ? : ; + + } + var Packaging = parseFloat(AfterPackaging).toFixed(2); + + $('#txtEditAfterPackaging').val(Packaging); + //RevenueChangeEditSgst(); + } + else + { + $('#txtEditAfterPackaging').val("0.00"); + } + } + calculateEditVatValue(); + calculateEditTotalValue(); + } } function calculateExcise(isEdit) { - if(isEdit == '0') - { - - - if($('#MaterialCode').val() == "0") - { - - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtExciseDuty').val(''); - return false; - } - else if($('#Rate').val() == '') - { - swal('Please Enter the Rate value'); - $('#txtExciseDuty').val(''); - $('#Rate').focus(); - return false; - } - - else - { - - var basicValue = parseFloat($('#txtBasicValue').val()); - - - if($('#txtExciseDuty').val() != '' && $('#txtExciseDuty').val() != '0' && ExciseCalculation!='') - { - var AfterExciseDuty = 0.0; - var ExciseDuty = parseFloat($('#txtExciseDuty').val()); - - if(ExciseCalculation == '0') - { - AfterExciseDuty = ; - } - else if(ExciseCalculation == '1') - { - if($('#txtAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#DiscountType').focus(); - $('#txtExciseDuty').val(''); - return false; - } - else - { - var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); - AfterExciseDuty = ; - } - } - else if(ExciseCalculation == '2') - { - if($('#txtAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#DiscountType').focus(); - $('#txtExciseDuty').val(''); - return false; - } - else if($('#txtAfterPackaging').val() == '') - { - swal('Please Enter the Packaging value'); - $('#PackagingType').focus(); - $('#txtExciseDuty').val(''); - return false; - - } - else - { - var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); - var AfterPackaging = parseFloat($('#txtAfterPackaging').val()); - AfterExciseDuty = ; - } - } - else - { - if($('#txtAfterPackaging').val() == '') - { - swal('Please Enter the Packaging value'); - $('#PackagingType').focus(); - $('#txtExciseDuty').val(''); - return false; - } - else - { - AfterExciseDuty = ; - var AfterPackaging = parseFloat($('#txtAfterPackaging').val()); - } - } - var ExciseVal = parseFloat(AfterExciseDuty).toFixed(2); - - $('#txtAfterExciseDuty').val(ExciseVal); - } - else - { - $('#txtAfterExciseDuty').val("0.00"); - } - - } + if(isEdit == '0') + { + + + if($('#MaterialCode').val() == "0") + { + + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtExciseDuty').val(''); + return false; + } + else if($('#Rate').val() == '') + { + swal('Please Enter the Rate value'); + $('#txtExciseDuty').val(''); + $('#Rate').focus(); + return false; + } + + else + { + + var basicValue = parseFloat($('#txtBasicValue').val()); + + + if($('#txtExciseDuty').val() != '' && $('#txtExciseDuty').val() != '0' && ExciseCalculation!='') + { + var AfterExciseDuty = 0.0; + var ExciseDuty = parseFloat($('#txtExciseDuty').val()); + + if(ExciseCalculation == '0') + { + AfterExciseDuty = ; + } + else if(ExciseCalculation == '1') + { + if($('#txtAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#DiscountType').focus(); + $('#txtExciseDuty').val(''); + return false; + } + else + { + var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); + AfterExciseDuty = ; + } + } + else if(ExciseCalculation == '2') + { + if($('#txtAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#DiscountType').focus(); + $('#txtExciseDuty').val(''); + return false; + } + else if($('#txtAfterPackaging').val() == '') + { + swal('Please Enter the Packaging value'); + $('#PackagingType').focus(); + $('#txtExciseDuty').val(''); + return false; + + } + else + { + var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); + var AfterPackaging = parseFloat($('#txtAfterPackaging').val()); + AfterExciseDuty = ; + } + } + else + { + if($('#txtAfterPackaging').val() == '') + { + swal('Please Enter the Packaging value'); + $('#PackagingType').focus(); + $('#txtExciseDuty').val(''); + return false; + } + else + { + AfterExciseDuty = ; + var AfterPackaging = parseFloat($('#txtAfterPackaging').val()); + } + } + var ExciseVal = parseFloat(AfterExciseDuty).toFixed(2); + + $('#txtAfterExciseDuty').val(ExciseVal); + } + else + { + $('#txtAfterExciseDuty').val("0.00"); + } + + } - calculateTotalValue(); - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRevenueRate').focus(); - return false; - } - - else - { - - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - - - - if($('#txtEditExciseDuty').val() != '' && $('#txtEditExciseDuty').val() != '0') - { - var AfterExciseDuty = 0.0; - var ExciseDuty = parseFloat($('#txtEditExciseDuty').val()); - if(ExciseCalculation == '0') - { - AfterExciseDuty = ; - } - else if(ExciseCalculation == '1') - { - if($('#txtEditAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#EditDiscountType').focus(); - $('#txtEditExciseDuty').val(''); - return false; - } - else - { - var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); - AfterExciseDuty = ; - } - } - else if(ExciseCalculation == '2') - { - if($('#txtEditAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#EditDiscountType').focus(); - $('#txtEditExciseDuty').val(''); - return false; - } - else if($('#txtEditAfterPackaging').val() == '') - { - swal('Please Enter the Packaging value'); - $('#EditPackagingType').focus(); - $('#txtEditExciseDuty').val(''); - return false; - } - else - { - var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); - var AfterPackaging = parseFloat($('#txtEditAfterPackaging').val()); - AfterExciseDuty = ; - } - } - else - { - if($('#txtEditAfterPackaging').val() == '') - { - swal('Please Enter the Packaging value'); - $('#EditPackagingType').focus(); - $('#txtEditExciseDuty').val(''); - return false; - } - else - { - var AfterPackaging = parseFloat($('#txtEditAfterPackaging').val()); - AfterExciseDuty = ; - } - } - var ExciseVal = parseFloat(AfterExciseDuty).toFixed(2); - - $('#txtEditAfterExciseDuty').val(ExciseVal); - } - else - { - $('#txtEditAfterExciseDuty').val("0.00"); - } - - } - - calculateEditTotalValue(); - } - + calculateTotalValue(); + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRevenueRate').focus(); + return false; + } + + else + { + + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + + + + if($('#txtEditExciseDuty').val() != '' && $('#txtEditExciseDuty').val() != '0') + { + var AfterExciseDuty = 0.0; + var ExciseDuty = parseFloat($('#txtEditExciseDuty').val()); + if(ExciseCalculation == '0') + { + AfterExciseDuty = ; + } + else if(ExciseCalculation == '1') + { + if($('#txtEditAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#EditDiscountType').focus(); + $('#txtEditExciseDuty').val(''); + return false; + } + else + { + var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); + AfterExciseDuty = ; + } + } + else if(ExciseCalculation == '2') + { + if($('#txtEditAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#EditDiscountType').focus(); + $('#txtEditExciseDuty').val(''); + return false; + } + else if($('#txtEditAfterPackaging').val() == '') + { + swal('Please Enter the Packaging value'); + $('#EditPackagingType').focus(); + $('#txtEditExciseDuty').val(''); + return false; + } + else + { + var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); + var AfterPackaging = parseFloat($('#txtEditAfterPackaging').val()); + AfterExciseDuty = ; + } + } + else + { + if($('#txtEditAfterPackaging').val() == '') + { + swal('Please Enter the Packaging value'); + $('#EditPackagingType').focus(); + $('#txtEditExciseDuty').val(''); + return false; + } + else + { + var AfterPackaging = parseFloat($('#txtEditAfterPackaging').val()); + AfterExciseDuty = ; + } + } + var ExciseVal = parseFloat(AfterExciseDuty).toFixed(2); + + $('#txtEditAfterExciseDuty').val(ExciseVal); + } + else + { + $('#txtEditAfterExciseDuty').val("0.00"); + } + + } + + calculateEditTotalValue(); + } + } function calculateVat(isEdit) { - if(isEdit == '0') - { - if($('#MaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtVat').val(''); - return false; - } - else if($('#Rate').val() == '') - { - - swal('Please Enter the Rate value'); - $('#Rate').focus(); - $('#txtVat').val(''); - return false; - } + if(isEdit == '0') + { + if($('#MaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtVat').val(''); + return false; + } + else if($('#Rate').val() == '') + { + + swal('Please Enter the Rate value'); + $('#Rate').focus(); + $('#txtVat').val(''); + return false; + } else if($('#txtAfterDiscount').val() == '') - { - - // swal('Please Enter the Rate value'); - $('#txtDiscount').focus(); - $('#txtVat').val(''); - return false; - } + { + + // swal('Please Enter the Rate value'); + $('#txtDiscount').focus(); + $('#txtVat').val(''); + return false; + } else if($('#txtAfterPackaging').val() == '') - { - - //swal('Please Enter the Rate value'); - $('#txtPackaging').focus(); - $('#txtVat').val(''); - return false; - } + { + + //swal('Please Enter the Rate value'); + $('#txtPackaging').focus(); + $('#txtVat').val(''); + return false; + } else if($('#txtAfterExciseDuty').val() == '') - { - - //swal('Please Enter the Rate value'); - $('#txtExciseDuty').focus(); - $('#txtVat').val(''); - return false; - } + { + + //swal('Please Enter the Rate value'); + $('#txtExciseDuty').focus(); + $('#txtVat').val(''); + return false; + } - - - else - { - - var basicValue = parseFloat($('#txtBasicValue').val()); - var AfterVat = 0.0; - - if(VatCalculation != 0 && $('#txtVat').val() != '' ) - { - - if($('#txtAfterExciseDuty').val() == '') - { - - swal('Please Enter the Excise value'); - $('#txtExciseDuty').focus(); - $('#txtVat').val(''); - return false; - } - else - { - - var ExciseDuty = parseFloat($('#txtAfterExciseDuty').val()); - vatValue = parseFloat($('#txtVat').val()); + + + else + { + + var basicValue = parseFloat($('#txtBasicValue').val()); + var AfterVat = 0.0; + + if(VatCalculation != 0 && $('#txtVat').val() != '' ) + { + + if($('#txtAfterExciseDuty').val() == '') + { + + swal('Please Enter the Excise value'); + $('#txtExciseDuty').focus(); + $('#txtVat').val(''); + return false; + } + else + { + + var ExciseDuty = parseFloat($('#txtAfterExciseDuty').val()); + vatValue = parseFloat($('#txtVat').val()); - var discountValue = parseFloat($('#txtAfterDiscount').val()); + var discountValue = parseFloat($('#txtAfterDiscount').val()); var packageValue = parseFloat($('#txtAfterPackaging').val()); - AfterVat = ; - - var Vatval = parseFloat(AfterVat).toFixed(2); - - $('#txtAfterVat').val(Vatval); - } - } - else if(VatCalculation == 0 && $('#txtVat').val() != '') - { - - var ExciseDuty = parseFloat($('#txtAfterExciseDuty').val()); - vatValue = parseFloat($('#txtVat').val()); - - var discountValue = parseFloat($('#txtAfterDiscount').val()); + AfterVat = ; + + var Vatval = parseFloat(AfterVat).toFixed(2); + + $('#txtAfterVat').val(Vatval); + } + } + else if(VatCalculation == 0 && $('#txtVat').val() != '') + { + + var ExciseDuty = parseFloat($('#txtAfterExciseDuty').val()); + vatValue = parseFloat($('#txtVat').val()); + + var discountValue = parseFloat($('#txtAfterDiscount').val()); var packageValue = parseFloat($('#txtAfterPackaging').val()); - AfterVat = ; - - - var Vatval = parseFloat(AfterVat).toFixed(2); - - $('#txtAfterVat').val(Vatval); - } - - else - { - - $('#txtAfterVat').val("0.00"); - } - - calculateTotalValue(); - } - - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - $('#txtEditVat').val(''); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRevenueRate').focus(); - $('#txtEditVat').val(''); - return false; - } - - else - { - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - - var discountValue = parseFloat($('#txtEditAfterDiscount').val()); - var packageValue = parseFloat($('#txtEditAfterPackaging').val()); - - var AfterVat = 0.0; - if(VatCalculation != 0 && $('#txtEditVat').val() != '' ) - { - - if($('#txtEditAfterExciseDuty').val() == '') - { - swal('Please Enter the Excise value'); - $('#txtEditAfterExciseDuty').focus(); - $('#txtEditVat').val(''); - return false; - } - else - { - var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); - vatValue = parseFloat($('#txtEditVat').val()); - AfterVat = ; - var Vatval = parseFloat(AfterVat).toFixed(2); - - $('#txtEditAfterVat').val(Vatval); - } - } - else if(VatCalculation == 0 && $('#txtEditVat').val() != '') - { - var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); - vatValue = parseFloat($('#txtEditVat').val()); - AfterVat = ; - var Vatval = parseFloat(AfterVat).toFixed(2); - - $('#txtEditAfterVat').val(Vatval); - } - - else - { - $('#txtEditAfterVat').val("0.00"); - } - - calculateEditTotalValue(); - } - - } + AfterVat = ; + + + var Vatval = parseFloat(AfterVat).toFixed(2); + + $('#txtAfterVat').val(Vatval); + } + + else + { + + $('#txtAfterVat').val("0.00"); + } + + calculateTotalValue(); + } + + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + $('#txtEditVat').val(''); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRevenueRate').focus(); + $('#txtEditVat').val(''); + return false; + } + + else + { + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + + var discountValue = parseFloat($('#txtEditAfterDiscount').val()); + var packageValue = parseFloat($('#txtEditAfterPackaging').val()); + + var AfterVat = 0.0; + if(VatCalculation != 0 && $('#txtEditVat').val() != '' ) + { + + if($('#txtEditAfterExciseDuty').val() == '') + { + swal('Please Enter the Excise value'); + $('#txtEditAfterExciseDuty').focus(); + $('#txtEditVat').val(''); + return false; + } + else + { + var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); + vatValue = parseFloat($('#txtEditVat').val()); + AfterVat = ; + var Vatval = parseFloat(AfterVat).toFixed(2); + + $('#txtEditAfterVat').val(Vatval); + } + } + else if(VatCalculation == 0 && $('#txtEditVat').val() != '') + { + var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); + vatValue = parseFloat($('#txtEditVat').val()); + AfterVat = ; + var Vatval = parseFloat(AfterVat).toFixed(2); + + $('#txtEditAfterVat').val(Vatval); + } + + else + { + $('#txtEditAfterVat').val("0.00"); + } + + calculateEditTotalValue(); + } + + } } function calculateCST(isEdit) { - if(isEdit == '0') - { - - if($('#MaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtCST').val(''); - return false; - } - else if($('#Rate').val() == '') - { - swal('Please Enter the Rate value'); - $('#Rate').focus(); - $('#txtCST').val(''); - return false; - } + if(isEdit == '0') + { + + if($('#MaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtCST').val(''); + return false; + } + else if($('#Rate').val() == '') + { + swal('Please Enter the Rate value'); + $('#Rate').focus(); + $('#txtCST').val(''); + return false; + } else if($('#txtAfterDiscount').val() == '') - { - - // swal('Please Enter the Rate value'); - $('#txtDiscount').focus(); - $('#txtCST').val(''); - return false; - } + { + + // swal('Please Enter the Rate value'); + $('#txtDiscount').focus(); + $('#txtCST').val(''); + return false; + } else if($('#txtAfterPackaging').val() == '') - { - - //swal('Please Enter the Rate value'); - $('#txtPackaging').focus(); - $('#txtCST').val(''); - return false; - } + { + + //swal('Please Enter the Rate value'); + $('#txtPackaging').focus(); + $('#txtCST').val(''); + return false; + } else if($('#txtAfterExciseDuty').val() == '') - { - - //swal('Please Enter the Rate value'); - $('#txtExciseDuty').focus(); - $('#txtCST').val(''); - return false; - } - - else - { - var basicValue = parseFloat($('#txtBasicValue').val()); - var discountValue = parseFloat($('#txtAfterDiscount').val()); + { + + //swal('Please Enter the Rate value'); + $('#txtExciseDuty').focus(); + $('#txtCST').val(''); + return false; + } + + else + { + var basicValue = parseFloat($('#txtBasicValue').val()); + var discountValue = parseFloat($('#txtAfterDiscount').val()); var packageValue = parseFloat($('#txtAfterPackaging').val()); - var AfterCST = 0.0; - if(CSTCalculation != 0 && $('#txtCST').val() != '' ) - { - - if($('#txtAfterExciseDuty').val() == '') - { - swal('Please Enter the Excise value'); - $('#txtExciseDuty').focus(); - $('#txtAfterCST').val(''); - return false; - } - else - { - var ExciseDuty = parseFloat($('#txtAfterExciseDuty').val()); - var CSTValue= parseFloat($('#txtCST').val()); - AfterCST = ; - - var Vatval = parseFloat(AfterCST).toFixed(2); - - $('#txtAfterCST').val(Vatval); - } - } - else if(CSTCalculation == 0 && $('#txtCST').val() != '') - { - + var AfterCST = 0.0; + if(CSTCalculation != 0 && $('#txtCST').val() != '' ) + { + + if($('#txtAfterExciseDuty').val() == '') + { + swal('Please Enter the Excise value'); + $('#txtExciseDuty').focus(); + $('#txtAfterCST').val(''); + return false; + } + else + { + var ExciseDuty = parseFloat($('#txtAfterExciseDuty').val()); + var CSTValue= parseFloat($('#txtCST').val()); + AfterCST = ; + + var Vatval = parseFloat(AfterCST).toFixed(2); + + $('#txtAfterCST').val(Vatval); + } + } + else if(CSTCalculation == 0 && $('#txtCST').val() != '') + { + var ExciseDuty = parseFloat($('#txtAfterExciseDuty').val()); - var CSTValue= parseFloat($('#txtCST').val()); - - AfterCST = ; - var Vatval = parseFloat(AfterCST).toFixed(2); - - $('#txtAfterCST').val(Vatval); - } - - else - { - $('#txtAfterCST').val("0.00"); - } - calculateTotalValue(); - } - - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - $('#txtEditCST').val(''); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRevenueRate').focus(); - $('#txtEditCST').val(''); - return false; - } - - else - { - - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - var discountValue = parseFloat($('#txtEditAfterDiscount').val()); - var packageValue = parseFloat($('#txtEditAfterPackaging').val()); - var AfterCST = 0.0; - if(CSTCalculation != 0 && $('#txtEditCST').val() != '' ) - { - - if($('#txtEditAfterExciseDuty').val() == '') - { - swal('Please Enter the Excise value'); - $('#txtEditAfterExciseDuty').focus(); - $('#txtEditCST').val(''); - return false; - } - else - { - var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); - var CSTValue= parseFloat($('#txtEditCST').val()); - AfterCST = ; - var Vatval = parseFloat(AfterCST).toFixed(2); - - $('#txtEditAfterCST').val(Vatval); - } - } - else if(CSTCalculation == 0 && $('#txtEditCST').val() != '') - { - var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); - var CSTValue= parseFloat($('#txtEditCST').val()); - AfterCST = ; - var Vatval = parseFloat(AfterCST).toFixed(2); - - $('#txtEditAfterCST').val(Vatval); - } - - else - { - $('#txtEditAfterCST').val("0.00"); - } - - calculateEditTotalValue(); - } - - } + var CSTValue= parseFloat($('#txtCST').val()); + + AfterCST = ; + var Vatval = parseFloat(AfterCST).toFixed(2); + + $('#txtAfterCST').val(Vatval); + } + + else + { + $('#txtAfterCST').val("0.00"); + } + calculateTotalValue(); + } + + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + $('#txtEditCST').val(''); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRevenueRate').focus(); + $('#txtEditCST').val(''); + return false; + } + + else + { + + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + var discountValue = parseFloat($('#txtEditAfterDiscount').val()); + var packageValue = parseFloat($('#txtEditAfterPackaging').val()); + var AfterCST = 0.0; + if(CSTCalculation != 0 && $('#txtEditCST').val() != '' ) + { + + if($('#txtEditAfterExciseDuty').val() == '') + { + swal('Please Enter the Excise value'); + $('#txtEditAfterExciseDuty').focus(); + $('#txtEditCST').val(''); + return false; + } + else + { + var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); + var CSTValue= parseFloat($('#txtEditCST').val()); + AfterCST = ; + var Vatval = parseFloat(AfterCST).toFixed(2); + + $('#txtEditAfterCST').val(Vatval); + } + } + else if(CSTCalculation == 0 && $('#txtEditCST').val() != '') + { + var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); + var CSTValue= parseFloat($('#txtEditCST').val()); + AfterCST = ; + var Vatval = parseFloat(AfterCST).toFixed(2); + + $('#txtEditAfterCST').val(Vatval); + } + + else + { + $('#txtEditAfterCST').val("0.00"); + } + + calculateEditTotalValue(); + } + + } } function calculateGST(isEdit) { - if(isEdit == '0') - { - if($('#MaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtGST').val(''); - return false; - } - else if($('#Rate').val() == '') - { - swal('Please Enter the Rate value'); - $('#Rate').focus(); - $('#txtGST').val(''); - return false; - } - else - { - var basicValue = parseFloat($('#txtBasicValue').val()); - - if($('#txtGST').val() != "0" && $('#txtGST').val() != '') - { - var GSTValue = parseFloat($('#txtGST').val()); - - var AfterGST = 0.0; - AfterGST = ; - - var GSTval = parseFloat(AfterGST).toFixed(2); - - $('#txtAfterGST').val(GSTval); - } - else - { - $('#txtAfterGST').val("0.00"); - } - - } - calculateTotalValue(); - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - $('#txtEditGST').val(''); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRevenueRate').focus(); - $('#txtEditGST').val(''); - return false; - } - else - { - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - - if($('#txtEditGST').val() != "0" && $('#txtEditGST').val() != '') - { - var GSTValue = parseFloat($('#txtEditGST').val()); - - var AfterGST = 0.0; - AfterGST = ; - - var GSTval = parseFloat(AfterGST).toFixed(2); - - $('#txtEditAfterGST').val(GSTval); - } - else - { - $('#txtEditAfterGST').val("0.00"); - } - - } - calculateEditTotalValue(); - - } + if(isEdit == '0') + { + if($('#MaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtGST').val(''); + return false; + } + else if($('#Rate').val() == '') + { + swal('Please Enter the Rate value'); + $('#Rate').focus(); + $('#txtGST').val(''); + return false; + } + else + { + var basicValue = parseFloat($('#txtBasicValue').val()); + + if($('#txtGST').val() != "0" && $('#txtGST').val() != '') + { + var GSTValue = parseFloat($('#txtGST').val()); + + var AfterGST = 0.0; + AfterGST = ; + + var GSTval = parseFloat(AfterGST).toFixed(2); + + $('#txtAfterGST').val(GSTval); + } + else + { + $('#txtAfterGST').val("0.00"); + } + + } + calculateTotalValue(); + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + $('#txtEditGST').val(''); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRevenueRate').focus(); + $('#txtEditGST').val(''); + return false; + } + else + { + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + + if($('#txtEditGST').val() != "0" && $('#txtEditGST').val() != '') + { + var GSTValue = parseFloat($('#txtEditGST').val()); + + var AfterGST = 0.0; + AfterGST = ; + + var GSTval = parseFloat(AfterGST).toFixed(2); + + $('#txtEditAfterGST').val(GSTval); + } + else + { + $('#txtEditAfterGST').val("0.00"); + } + + } + calculateEditTotalValue(); + + } } function calculateOtherTaxes(isEdit) { - if(isEdit == '0') - { - if($('#MaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtOtherTax').val(''); - return false; - } - else if($('#Rate').val() == '') - { - swal('Please Enter the Rate value'); - $('#Rate').focus(); - $('#txtOtherTax').val(''); - return false; - } - else - { - var basicValue = parseFloat($('#txtBasicValue').val()); - - - if($('#txtOtherTax').val() != "0" && $('#txtOtherTax').val() != '') - { - var OtherTaxValue = parseFloat($('#txtOtherTax').val()); - - var AfterOtherTaxes = 0.0; - AfterOtherTaxes = ; - - var Otherval = parseFloat(AfterOtherTaxes).toFixed(2); - - $('#txtAfterOtherTax').val(Otherval); - } - else - { - $('#txtAfterOtherTax').val("0.00"); - } - calculateTotalValue(); - - } - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - $('#txtEditOtherTax').val(''); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRevenueRate').focus(); - $('#txtEditOtherTax').val(''); - return false; - } - else - { - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - - - if($('#txtEditOtherTax').val() != "0" && $('#txtEditOtherTax').val() != '') - { - var OtherTaxValue = parseFloat($('#txtEditOtherTax').val()); - - var AfterOtherTaxes = 0.0; - AfterOtherTaxes = ; - - var Otherval = parseFloat(AfterOtherTaxes).toFixed(2); - - $('#txtEditAfterOtherTax').val(Otherval); - } - else - { - $('#txtEditAfterOtherTax').val("0.00"); - } - calculateEditTotalValue(); - - } - - } + if(isEdit == '0') + { + if($('#MaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtOtherTax').val(''); + return false; + } + else if($('#Rate').val() == '') + { + swal('Please Enter the Rate value'); + $('#Rate').focus(); + $('#txtOtherTax').val(''); + return false; + } + else + { + var basicValue = parseFloat($('#txtBasicValue').val()); + + + if($('#txtOtherTax').val() != "0" && $('#txtOtherTax').val() != '') + { + var OtherTaxValue = parseFloat($('#txtOtherTax').val()); + + var AfterOtherTaxes = 0.0; + AfterOtherTaxes = ; + + var Otherval = parseFloat(AfterOtherTaxes).toFixed(2); + + $('#txtAfterOtherTax').val(Otherval); + } + else + { + $('#txtAfterOtherTax').val("0.00"); + } + calculateTotalValue(); + + } + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + $('#txtEditOtherTax').val(''); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRevenueRate').focus(); + $('#txtEditOtherTax').val(''); + return false; + } + else + { + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + + + if($('#txtEditOtherTax').val() != "0" && $('#txtEditOtherTax').val() != '') + { + var OtherTaxValue = parseFloat($('#txtEditOtherTax').val()); + + var AfterOtherTaxes = 0.0; + AfterOtherTaxes = ; + + var Otherval = parseFloat(AfterOtherTaxes).toFixed(2); + + $('#txtEditAfterOtherTax').val(Otherval); + } + else + { + $('#txtEditAfterOtherTax').val("0.00"); + } + calculateEditTotalValue(); + + } + + } } function calculateFreight(isEdit) { - if(isEdit == '0') - { - if($('#MaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#MaterialCode').focus(); - $('#txtFreight').val('') ; - return false; - } - else if($('#Rate').val() == '') - { - swal('Please Enter the Rate value'); - $('#Rate').focus(); - $('#txtFreight').val(''); - return false; - } - else - { - var basicValue = parseFloat($('#txtBasicValue').val()); - var FreightType =$("#drpFreight").val(); - - if(FreightType == "0") - { - swal('Please select Freight Type'); - $('#txtFreight').val(''); - $("#drpFreight").focus(); - } - else if( $('#txtFreight').val() != "0" && $('#txtFreight').val() != '') - { - var FreightValue = parseFloat($('#txtFreight').val()); - var UOM = parseFloat($('#UOM').val()); - var Quantity = parseFloat($('#Quantity').val()); - //swal(FreightType); - var AfterFreight = 0.0; - // if(FreightType == PercentageType) - // { - // AfterFreight = ; - // } - if(FreightType == PercentageType) - { - if($(freightCalculation != 0 && '#txtAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#txtFreight').val(''); - $('#DiscountType').focus(); - - return false; - } - else - { - var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); - AfterFreight = freightCalculation == 0 ? : ; - } - } - else if(FreightType == NilType) - { - AfterFreight = 0.0; - - } - else if(FreightType == '') - { - AfterFreight = ; - } - else if(FreightType == '') - { - AfterFreight = ; - } - else if(FreightType == '') - { + if(isEdit == '0') + { + if($('#MaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#MaterialCode').focus(); + $('#txtFreight').val('') ; + return false; + } + else if($('#Rate').val() == '') + { + swal('Please Enter the Rate value'); + $('#Rate').focus(); + $('#txtFreight').val(''); + return false; + } + else + { + var basicValue = parseFloat($('#txtBasicValue').val()); + var FreightType =$("#drpFreight").val(); + + if(FreightType == "0") + { + swal('Please select Freight Type'); + $('#txtFreight').val(''); + $("#drpFreight").focus(); + } + else if( $('#txtFreight').val() != "0" && $('#txtFreight').val() != '') + { + var FreightValue = parseFloat($('#txtFreight').val()); + var UOM = parseFloat($('#UOM').val()); + var Quantity = parseFloat($('#Quantity').val()); + //swal(FreightType); + var AfterFreight = 0.0; + // if(FreightType == PercentageType) + // { + // AfterFreight = ; + // } + if(FreightType == PercentageType) + { + if($(freightCalculation != 0 && '#txtAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#txtFreight').val(''); + $('#DiscountType').focus(); + + return false; + } + else + { + var AfterDiscount =parseFloat($('#txtAfterDiscount').val()); + AfterFreight = freightCalculation == 0 ? : ; + } + } + else if(FreightType == NilType) + { + AfterFreight = 0.0; + + } + else if(FreightType == '') + { + AfterFreight = ; + } + else if(FreightType == '') + { + AfterFreight = ; + } + else if(FreightType == '') + { if($('#NOOfTrips').val()==''){ swal('Please Enter No of Trip'); - - $("#NOOfTrips").focus(); + + $("#NOOfTrips").focus(); $('#txtFreight').val(0) AfterFreight=0; $('#txtAfterFreight').val("0.00"); @@ -1612,97 +1481,97 @@ function calculatePackaging(isEdit) AfterFreight = parseFloat(AfterFreight * noOftrip).toFixed(2); } - - } - else { - AfterFreight = $("#txtFreight").val(); - } - var AfterFreightval = parseFloat(AfterFreight).toFixed(2); - - $('#txtAfterFreight').val(AfterFreightval); - - } - else - { - $('#txtAfterFreight').val("0.00"); - } - - } - - - calculateTotalValue(); - } - else - { - if($('#EditRevenueMaterialCode').val() == "0") - { - swal('Please Select the Material Code'); - $('#EditRevenueMaterialCode').focus(); - $('#txtEditFreight').val(''); - return false; - } - else if($('#EditRevenueRate').val() == '') - { - swal('Please Enter the Rate value'); - $('#EditRevenueRate').focus(); - $('#txtEditFreight').val(''); - return false; - } - else - { - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - var FreightType =$("#drpEditFreight").val(); - if(FreightType == "0") - { - swal('Please select Freight Type'); - $('#txtEditFreight').val(''); - $("#drpEditFreight").focus(); - } - else if( $('#txtEditFreight').val() != "0" && $('#txtEditFreight').val() != '') - { - var FreightValue = parseFloat($('#txtEditFreight').val()); - var UOM = parseFloat($('#EditRevenueUOM').val()); - var Quantity = parseFloat($('#EditRevenueQuantity').val()); - //swal(FreightType); - var AfterFreight = 0.0; - // if(FreightType == PercentageType) - // { - // AfterFreight = ; - // } - if(FreightType == PercentageType) - { - if($(freightCalculation != 0 && '#txtEditAfterDiscount').val() == '') - { - swal('Please Enter the Discount value'); - $('#txtEditFreight').val(''); - $('#DiscountType').focus(); - - return false; - } - else - { - var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); - AfterFreight = freightCalculation == 0 ? : ; - } - } - else if(FreightType == NilType) - { - AfterFreight = 0.0; - } - else if(FreightType == '') - { - AfterFreight = ; - } - else if(FreightType == '') - { - AfterFreight = ; - } - else if(FreightType == '') - { - if($('#EditNOOfTrips').val()==''){ + + } + else { + AfterFreight = $("#txtFreight").val(); + } + var AfterFreightval = parseFloat(AfterFreight).toFixed(2); + + $('#txtAfterFreight').val(AfterFreightval); + + } + else + { + $('#txtAfterFreight').val("0.00"); + } + + } + + + calculateTotalValue(); + } + else + { + if($('#EditRevenueMaterialCode').val() == "0") + { + swal('Please Select the Material Code'); + $('#EditRevenueMaterialCode').focus(); + $('#txtEditFreight').val(''); + return false; + } + else if($('#EditRevenueRate').val() == '') + { + swal('Please Enter the Rate value'); + $('#EditRevenueRate').focus(); + $('#txtEditFreight').val(''); + return false; + } + else + { + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + var FreightType =$("#drpEditFreight").val(); + if(FreightType == "0") + { + swal('Please select Freight Type'); + $('#txtEditFreight').val(''); + $("#drpEditFreight").focus(); + } + else if( $('#txtEditFreight').val() != "0" && $('#txtEditFreight').val() != '') + { + var FreightValue = parseFloat($('#txtEditFreight').val()); + var UOM = parseFloat($('#EditRevenueUOM').val()); + var Quantity = parseFloat($('#EditRevenueQuantity').val()); + //swal(FreightType); + var AfterFreight = 0.0; + // if(FreightType == PercentageType) + // { + // AfterFreight = ; + // } + if(FreightType == PercentageType) + { + if($(freightCalculation != 0 && '#txtEditAfterDiscount').val() == '') + { + swal('Please Enter the Discount value'); + $('#txtEditFreight').val(''); + $('#DiscountType').focus(); + + return false; + } + else + { + var AfterDiscount =parseFloat($('#txtEditAfterDiscount').val()); + AfterFreight = freightCalculation == 0 ? : ; + } + } + else if(FreightType == NilType) + { + AfterFreight = 0.0; + } + else if(FreightType == '') + { + AfterFreight = ; + } + else if(FreightType == '') + { + AfterFreight = ; + } + else if(FreightType == '') + { + if($('#EditNOOfTrips').val()==''){ swal('Please Enter No of Trip'); - - $("#EditNOOfTrips").focus(); + + $("#EditNOOfTrips").focus(); $('#txtEditFreight').val(0) AfterFreight=0; $('#txtEditAfterFreight').val("0.00"); @@ -1712,60 +1581,33 @@ function calculatePackaging(isEdit) var noOftrip = $("#EditNOOfTrips").val(); AfterFreight = ; AfterFreight = parseFloat(AfterFreight * noOftrip).toFixed(2); - } - } - else { - AfterFreight = $("#txtEditFreight").val(); - } - var AfterFreightval = parseFloat(AfterFreight).toFixed(2); - - $('#txtEditAfterFreight').val(AfterFreightval); - //Editchange(); - } - else - { - $('#txtEditAfterFreight').val("0.00"); - } - - } - calculateEditTotalValue(); + } + } + else { + AfterFreight = $("#txtEditFreight").val(); + } + var AfterFreightval = parseFloat(AfterFreight).toFixed(2); + + $('#txtEditAfterFreight').val(AfterFreightval); + //Editchange(); + } + else + { + $('#txtEditAfterFreight').val("0.00"); + } + + } + calculateEditTotalValue(); - } + } } -function rfilealert() -{ -var file = $('#imag').val(); - - if (file=='') - { - swal('File not found'); - SpecialPOcheck(); - } - else{ - SpecialPOcheck(); - } -} -function sfilealert() -{ - -var file1 = $('#images1').val(); - if (file1=='') - { - swal('File not found'); - SpecialPOcheck(); - } - else{ - SpecialPOcheck(); - } -} - function SpecialPOcheck() { // swal('splpo') - //$('#content').loader('show'); + //$('#content').loader('show'); POcheck=$("input:radio[name='Quality']:checked").val(); console.log(POcheck); @@ -1774,18 +1616,15 @@ function SpecialPOcheck() var row=$('#txtRowCount1').val(); var PO=$('#POType').val(); - // if(splrow!=row) - // { - // swal("You havent add all the material details") - // return false; - // } + + var file1 = $('#images1'+counterConstants).val() + var file = $('#imag'+counterConstant).val() - // else - // { + if(PO=='REVENUE') { - var images = $('#images').val(); + var images = $('#imag').val(); $('#content').loader('show'); @@ -1793,7 +1632,7 @@ function SpecialPOcheck() { $('#txtSpecial').val(1); $('#txtQuality').val(1); - //addtable(); + // addtable(); RevenueSave(3); } @@ -1821,14 +1660,14 @@ function SpecialPOcheck() Save(2) } - //} + } /* Set the Packaging calculation option for calculating Packaging */ - function submitoption() + function submitoption() { submitoptionvalue = $("input:radio[name='optsubmit']:checked").val(); - //swal(submitoptionvalue); + //swal(submitoptionvalue); var PO=$('#POType').val(); @@ -1838,19 +1677,19 @@ function SpecialPOcheck() { $('#submitmodel').modal('hide'); - if(submitoptionvalue==0) - { - - //swal('normalemergency'); + if(submitoptionvalue==0) + { + + //swal('normalemergency'); $('#txtSpecial').val(0); $('#content').loader('show'); RevenueSave(1) - } - else - { - //window.location.href ="purchaseorder/addNewPurchaseOrder"; - $('#filemodel').modal('show'); - } + } + else + { + //window.location.href ="purchaseorder/addNewPurchaseOrder"; + $('#filemodel').modal('show'); + } } @@ -1879,52 +1718,28 @@ function SpecialPOcheck() } - - - -// function ServiceCheck() -// { -// submitoptionvalue = $("input:radio[name='optsubmit']:checked").val(); -// //swal(submitoptionvalue); -// $('#submitmodel').modal('hide'); -// if(submitoptionvalue==0) -// { - -// swal('normal Service emergency'); -// $('#txtSpecialservice').val(0); -// Save(1) -// } -// else -// { -// //window.location.href ="purchaseorder/addNewPurchaseOrder"; -// $('#filemodel').modal('show'); -// } -// } - - - - function qualitycheckoption() + function qualitycheckoption() { qualityoptionvalue = $("input:radio[name='Quality']:checked").val(); - //swal(submitoptionvalue); + //swal(submitoptionvalue); $('#submitmodel').modal('hide'); - if(qualityoptionvalue==0) - { - - swal('Igr'); - } - else - { - //window.location.href ="purchaseorder/addNewPurchaseOrder"; - swal('Billing'); - } + if(qualityoptionvalue==0) + { + + swal('Igr'); + } + else + { + //window.location.href ="purchaseorder/addNewPurchaseOrder"; + swal('Billing'); + } } function SetPackagingOption() { PackagingCalculation = $("input:radio[name='optPackaging']:checked").val(); $('#packagingcalmodel').modal('hide'); } - function setfreightOption() + function setfreightOption() { freightCalculation = $("input:radio[name='optfreight']:checked").val(); $('#freightmodel').modal('hide'); @@ -1932,19 +1747,19 @@ function SpecialPOcheck() /* Set the Packaging calculation option for calculating Packaging */ function SetExciseCalculation() { - ExciseCalculation = $("input:radio[name='optExcise']:checked").val(); + ExciseCalculation = $("input:radio[name='optExcise']:checked").val(); - $('#ExciseDutyCalModel').modal('hide'); - - calculateExcise($('#isEdit').val()); + $('#ExciseDutyCalModel').modal('hide'); + + calculateExcise($('#isEdit').val()); } function SetExciseCalculationCancel() { - + - $('#txtExciseDuty').val(''); + $('#txtExciseDuty').val(''); $('#txtAfterExciseDuty').val(''); - + } /* Set the Packaging calculation option for calculating Packaging */ function SetVatorCST() @@ -1973,84 +1788,84 @@ function SetExciseCalculationCancel() function SetVatCalculation() { - VatCalculation = $("input:radio[name='optVat']:checked").val(); - $('#VatCalModel').modal('hide'); - calculateVat($('#isEdit').val()); + VatCalculation = $("input:radio[name='optVat']:checked").val(); + $('#VatCalModel').modal('hide'); + calculateVat($('#isEdit').val()); } function SetCSTCalculation() { - CSTCalculation = $("input:radio[name='optCST']:checked").val(); - $('#CSTCalModel').modal('hide'); - calculateCST($('#isEdit').val()); + CSTCalculation = $("input:radio[name='optCST']:checked").val(); + $('#CSTCalModel').modal('hide'); + calculateCST($('#isEdit').val()); } function Editchange(){ - var isEdit=1; - // ExceedEditQuantityCheck(); - if($('#EditRevenueQuantity').val() != '' && $('#EditRevenueRate').val() != '') - { - var txtQuantity = parseFloat( $('#EditRevenueQuantity').val()); - var txtUnitPrice = parseFloat($('#EditRevenueRate').val()); - var Tot = txtQuantity * txtUnitPrice - $('#txtEditRevenueBasicValue').val(Tot); + var isEdit=1; + // ExceedEditQuantityCheck(); + if($('#EditRevenueQuantity').val() != '' && $('#EditRevenueRate').val() != '') + { + var txtQuantity = parseFloat( $('#EditRevenueQuantity').val()); + var txtUnitPrice = parseFloat($('#EditRevenueRate').val()); + var Tot = txtQuantity * txtUnitPrice + $('#txtEditRevenueBasicValue').val(Tot); if($("#EditDiscountType").val()!=0){ - calculateDiscount(isEdit); + calculateDiscount(isEdit); } - + - if ($("#EditPackagingType").val()!=0) { - calculatePackaging(1); - } + if ($("#EditPackagingType").val()!=0) { + calculatePackaging(1); + } if ($("#drpEditFreight").val()!=0) { - calculateFreight(1); - } - var discount = $('#txtEditAfterDiscount').val() == '' ? '0.00' : $('#txtEditAfterDiscount').val(); + calculateFreight(1); + } + var discount = $('#txtEditAfterDiscount').val() == '' ? '0.00' : $('#txtEditAfterDiscount').val(); var basic = $('#txtEditRevenueBasicValue').val() == '' ? '0.00' : $('#txtEditRevenueBasicValue').val(); var basicValue1 = parseFloat(basic-discount); - //swal(basicValue1); - var packaging = $('#txtEditAfterPackaging').val() == '' ? '0.00' : $('#txtEditAfterPackaging').val(); - //swal(packaging); - var freight =$('#txtEditAfterFreight').val() == '' ? '0.00' : $('#txtEditAfterFreight').val(); - //swal(freight); - var packfreight = parseFloat(packaging)+parseFloat(freight); - var basicValue = parseFloat(basicValue1+packfreight); - //swal(basicValue); - - if($("#RevenueEditCgst").val()!=''){ - - $('#RevenueEditAfterCgst').val(calculateCgstTax(basicValue,$('#RevenueEditCgst').val())); - } + //swal(basicValue1); + var packaging = $('#txtEditAfterPackaging').val() == '' ? '0.00' : $('#txtEditAfterPackaging').val(); + //swal(packaging); + var freight =$('#txtEditAfterFreight').val() == '' ? '0.00' : $('#txtEditAfterFreight').val(); + //swal(freight); + var packfreight = parseFloat(packaging)+parseFloat(freight); + var basicValue = parseFloat(basicValue1+packfreight); + //swal(basicValue); + + if($("#RevenueEditCgst").val()!=''){ + + $('#RevenueEditAfterCgst').val(calculateCgstTax(basicValue,$('#RevenueEditCgst').val())); + } else{ $('#RevenueEditAfterCgst').val(0.00); } - if($("#RevenueEditSgst").val()!=''){ - - $('#RevenueEditAfterSgst').val(calculateSgstTax(basicValue,$('#RevenueEditSgst').val())); - } + if($("#RevenueEditSgst").val()!=''){ + + $('#RevenueEditAfterSgst').val(calculateSgstTax(basicValue,$('#RevenueEditSgst').val())); + } else{ $('#RevenueEditAfterSgst').val(0.00); } if($("#RevenueEditIgst").val()!=''){ - - $('#RevenueEditAfterIgst').val(calculateIgstTax(basicValue,$('#RevenueEditIgst').val())); - } - else{ + + $('#RevenueEditAfterIgst').val(calculateIgstTax(basicValue,$('#RevenueEditIgst').val())); + } + else{ $('#RevenueEditAfterIgst').val(0.00); } - - calculateEditTotalValue(); + + calculateEditTotalValue(); - } - + } + } function RevenueChangeSgst() { - + var getTypeOfTax= $("input:radio[name='Range']:checked").val(); if(getTypeOfTax==0){ - + $('#RevenueSgst').val($('#RevenueCgst').val()); change(); } @@ -2065,61 +1880,61 @@ Editchange(); } function change(){ - var isEdit=0; - //ExceedEditQuantityCheck(); - if($('#Quantity').val() != '' && $('#Rate').val() != '') - { - var txtQuantity = parseFloat( $('#Quantity').val()); - var txtUnitPrice = parseFloat($('#Rate').val()); - var Tot = txtQuantity * txtUnitPrice - $('#txtBasicValue').val(parseFloat(Tot).toFixed(2)); + var isEdit=0; + //ExceedEditQuantityCheck(); + if($('#Quantity').val() != '' && $('#Rate').val() != '') + { + var txtQuantity = parseFloat( $('#Quantity').val()); + var txtUnitPrice = parseFloat($('#Rate').val()); + var Tot = txtQuantity * txtUnitPrice + $('#txtBasicValue').val(parseFloat(Tot).toFixed(2)); - if ($("#DiscountType").val()!=0) { - calculateDiscount(isEdit); - } - if ($("#PackagingType").val()!=0) { - calculatePackaging(isEdit); - } - if($("#drpFreight").val()!=0){ - calculateFreight(isEdit); - - - } + if ($("#DiscountType").val()!=0) { + calculateDiscount(isEdit); + } + if ($("#PackagingType").val()!=0) { + calculatePackaging(isEdit); + } + if($("#drpFreight").val()!=0){ + calculateFreight(isEdit); + + + } - var discount = $('#txtAfterDiscount').val() == '' ? '0.00' : $('#txtAfterDiscount').val(); + var discount = $('#txtAfterDiscount').val() == '' ? '0.00' : $('#txtAfterDiscount').val(); var basic = $('#txtBasicValue').val() == '' ? '0.00' : $('#txtBasicValue').val(); var basicValue1 = parseFloat(basic-discount); - var packaging = $('#txtAfterPackaging').val()== '' ? '0.00' : $('#txtAfterPackaging').val(); - var freight =$('#txtAfterFreight').val()== '' ? '0.00' : $('#txtAfterFreight').val(); - var packfreight = parseFloat(packaging)+parseFloat(freight); - var basicValue = parseFloat(basicValue1+packfreight); - //swal(basicValue); - if($("#RevenueCgst").val()!=''){ + var packaging = $('#txtAfterPackaging').val()== '' ? '0.00' : $('#txtAfterPackaging').val(); + var freight =$('#txtAfterFreight').val()== '' ? '0.00' : $('#txtAfterFreight').val(); + var packfreight = parseFloat(packaging)+parseFloat(freight); + var basicValue = parseFloat(basicValue1+packfreight); + //swal(basicValue); + if($("#RevenueCgst").val()!=''){ - $('#RevenueAfterCgst').val(calculateCgstTax(basicValue,$('#RevenueCgst').val())); - } + $('#RevenueAfterCgst').val(calculateCgstTax(basicValue,$('#RevenueCgst').val())); + } else{ $('#RevenueAfterCgst').val(0.00); } - if($("#RevenueSgst").val()!=''){ - - $('#RevenueAfterSgst').val(calculateSgstTax(basicValue,$('#RevenueSgst').val())); - } + if($("#RevenueSgst").val()!=''){ + + $('#RevenueAfterSgst').val(calculateSgstTax(basicValue,$('#RevenueSgst').val())); + } else{ $('#RevenueAfterSgst').val(0.00); } if($("#RevenueIgst").val()!=''){ - - $('#RevenueAfterIgst').val(calculateIgstTax(basicValue,$('#RevenueIgst').val())); - } + + $('#RevenueAfterIgst').val(calculateIgstTax(basicValue,$('#RevenueIgst').val())); + } else{ $('#RevenueAfterIgst').val(0.00); } - calculateTotalValue($('#isEdit').val()); + calculateTotalValue($('#isEdit').val()); - } - + } + } @@ -2139,42 +1954,42 @@ Editchange(); function calculateEditTotalValue() { - var Packaging = $('#txtEditAfterPackaging').val() == '' ? '0.00' : $('#txtEditAfterPackaging').val(); - var Cgst = $('#RevenueEditAfterCgst').val() == '' ? '0.00' : $('#RevenueEditAfterCgst').val(); - var Sgst = $('#RevenueEditAfterSgst').val() == '' ? '0.00' : $('#RevenueEditAfterSgst').val(); - var Igst = $('#RevenueEditAfterIgst').val() == '' ? '0.00' : $('#RevenueEditAfterIgst').val(); + var Packaging = $('#txtEditAfterPackaging').val() == '' ? '0.00' : $('#txtEditAfterPackaging').val(); + var Cgst = $('#RevenueEditAfterCgst').val() == '' ? '0.00' : $('#RevenueEditAfterCgst').val(); + var Sgst = $('#RevenueEditAfterSgst').val() == '' ? '0.00' : $('#RevenueEditAfterSgst').val(); + var Igst = $('#RevenueEditAfterIgst').val() == '' ? '0.00' : $('#RevenueEditAfterIgst').val(); - var Freight = $('#txtEditAfterFreight').val() == '' ? '0.00' : $('#txtEditAfterFreight').val(); - var Insurance = $('#txtEditInsurance').val() == '' ? '0.00' : $('#txtEditInsurance').val(); - var Discount = $('#txtEditAfterDiscount').val() == '' ? '0.00' : $('#txtEditAfterDiscount').val(); - var BasicVal = $('#txtEditRevenueBasicValue').val() == '' ? '0.00' : $('#txtEditRevenueBasicValue').val(); + var Freight = $('#txtEditAfterFreight').val() == '' ? '0.00' : $('#txtEditAfterFreight').val(); + var Insurance = $('#txtEditInsurance').val() == '' ? '0.00' : $('#txtEditInsurance').val(); + var Discount = $('#txtEditAfterDiscount').val() == '' ? '0.00' : $('#txtEditAfterDiscount').val(); + var BasicVal = $('#txtEditRevenueBasicValue').val() == '' ? '0.00' : $('#txtEditRevenueBasicValue').val(); - var totvalue = ( parseFloat(BasicVal) + parseFloat(Packaging) + parseFloat(Cgst) + parseFloat(Sgst)+ parseFloat(Igst) + parseFloat(Freight) + parseFloat(Insurance)) - parseFloat(Discount); - - var tot = parseFloat(totvalue).toFixed(2); - - $('#txtEditRevenueTotalOrderValue').val(tot); - // validateEditExceedLimit(); + var totvalue = ( parseFloat(BasicVal) + parseFloat(Packaging) + parseFloat(Cgst) + parseFloat(Sgst)+ parseFloat(Igst) + parseFloat(Freight) + parseFloat(Insurance)) - parseFloat(Discount); + + var tot = parseFloat(totvalue).toFixed(2); + + $('#txtEditRevenueTotalOrderValue').val(tot); + // validateEditExceedLimit(); } // calculate vat rate function calculateEditVatValue() { - var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); - - var discountValue = parseFloat($('#txtEditAfterDiscount').val()); - var packageValue = parseFloat($('#txtEditAfterPackaging').val()); - - - var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); - vatValue = parseFloat($('#txtEditVat').val()); - AfterVat = ; - var Vatval = parseFloat(AfterVat).toFixed(2); - - $('#txtEditAfterVat').val(Vatval); - - + var basicValue = parseFloat($('#txtEditRevenueBasicValue').val()); + + var discountValue = parseFloat($('#txtEditAfterDiscount').val()); + var packageValue = parseFloat($('#txtEditAfterPackaging').val()); + + + var ExciseDuty = parseFloat($('#txtEditAfterExciseDuty').val()); + vatValue = parseFloat($('#txtEditVat').val()); + AfterVat = ; + var Vatval = parseFloat(AfterVat).toFixed(2); + + $('#txtEditAfterVat').val(Vatval); + + } // To Reset the Tax calculation function resetTaxField() @@ -2207,19 +2022,19 @@ Editchange(); $('#txtTotalOrderValue').val(''); ExciseCalculation = ''; PackagingCalculation = ''; - freightCalculation=''; + freightCalculation=''; VatCalculation = ''; CSTCalculation = ''; } - function showsubmit() - { - - $('#submitmodel').modal('show'); + function showsubmit() + { + + $('#submitmodel').modal('show'); - - } + + } function showmodel() { @@ -2239,12 +2054,12 @@ Editchange(); else if(avaBud==''){ swal ("Select Cost Center Name"); } - else if($('#drpSupplier').val() == "0") - { - swal('Please Select the Supplier details'); - $('#drpSupplier').focus(); - return false; - } + else if($('#drpSupplier').val() == "0") + { + swal('Please Select the Supplier details'); + $('#drpSupplier').focus(); + return false; + } else if($('#PoTypeOptions').val()== "0") { @@ -2264,37 +2079,28 @@ Editchange(); - else if(input=='REVENUE' && $('#Deliverydate').val()=='' && radioValue==0){ - swal('Please Select the Delivery Date'); - $('#Deliverydate').focus(); - return false; - } - else if(input=='REVENUE' && $('#Scheduleby').val().trim()=='' && radioValue==1){ - swal('Please Enter the Schedule By'); - $('#Scheduleby').focus(); - return false; - } + else if(input=='REVENUE' && $('#Deliverydate').val()=='' && radioValue==0){ + swal('Please Select the Delivery Date'); + $('#Deliverydate').focus(); + return false; + } + else if(input=='REVENUE' && $('#Scheduleby').val().trim()=='' && radioValue==1){ + swal('Please Enter the Schedule By'); + $('#Scheduleby').focus(); + return false; + } else { $("#" + input ).modal('show'); $('#isEdit').val(0); if(StateTaxCheck == "0") { - // style="display:none;" - // $('#Vat').removeAttr("style"); - // $('#TotVat').removeAttr("style"); - // $('#CST').attr("style","display:none;"); - // $('#TotCST').attr("style","display:none;"); $('#Vat').show(); $('#CST').hide(); } else { - // $('#CST').removeAttr("style"); - // $('#TotCST').removeAttr("style"); - // $('#Vat').attr("style","display:none;"); - // $('#TotVat').attr("style","display:none;"); $('#Vat').hide(); $('#CST').show(); @@ -2302,14 +2108,14 @@ Editchange(); } } $(document).ready(function(){ - - $("#PaymentMethod").select2(); - + + $("#PaymentMethod").select2(); + //Initialize Select2 Elements $("#purpose").select2(); $("#DepartmentName").select2(); $("#CostCenterName").select2(); - + $("#EditMaterialCode").select2(); $("#EditRevenueMaterialCode").select2(); $("#MaterialCode").select2(); @@ -2326,109 +2132,109 @@ Editchange(); function DeleteRevenueRow(rowid) { - var DelRows = $('#txtDeletedRow1').val(); - - //swalMaterialListrowid); - - var answer = confirm(" Do you want to delete the Item from the List?") - if (answer) - { - var td = document.getElementById(rowid); - td.parentNode.removeChild(td); - var materialCode = $('#materialCode'+rowid).val(); - var removeItem = $('#materialCode'+rowid).val(); - - + var DelRows = $('#txtDeletedRow1').val(); + + //swalMaterialListrowid); + + var answer = confirm(" Do you want to delete the Item from the List?") + if (answer) + { + var td = document.getElementById(rowid); + td.parentNode.removeChild(td); + var materialCode = $('#materialCode'+rowid).val(); + var removeItem = $('#materialCode'+rowid).val(); + + //This function is used to add material list after delete $.each(JSON.parse(materialData), function (index, value) { - if (value.MaterialCode==materialCode) { - $("#MaterialCode").append( $('').val(value.MaterialCode).html(value.MaterialCode + "-" + value.MaterialName) ); - } - }); + if (value.MaterialCode==materialCode) { + $("#MaterialCode").append( $('').val(value.MaterialCode).html(value.MaterialCode + "-" + value.MaterialName) ); + } + }); SelectedMaterialCode.splice( SelectedMaterialCode.indexOf('removeItem'), 1 ); - - - if(DelRows != '') - { - DelRows = DelRows + ":" + rowid; - } - else - { - DelRows= "0" + ":" + rowid; - } - - $('#txtDeletedRow1').val(DelRows); - populateValueMainFormForDeleteItem(rowid); - - } - + + + if(DelRows != '') + { + DelRows = DelRows + ":" + rowid; + } + else + { + DelRows= "0" + ":" + rowid; + } + + $('#txtDeletedRow1').val(DelRows); + populateValueMainFormForDeleteItem(rowid); + + } + } function populateValueMainFormForDeleteItem(rowid) { - - + + // swal(rows); - var totBasicAmt = $('#txtTotBasicAmountRevenue').val(); - var totDiscountAmt = $('#txtTotalDiscount').val(); - var totPackagingAmt = $('#txtTotalPackaing').val(); - - var totCgst = $('#txtTotalCGST').val(); - var totSgst = $('#txtTotalSGST').val(); - var totIgst = $('#txtTotalIGST').val(); - - var totFreightAmt = $('#txtTotalFreight').val(); - var totInsuranceAmt = $('#txtTotalInsurance').val(); - var totOrderSummaryAmt = $('#txtTotalOrderValueSummary').val(); - - - var Packaging = $('#AfterPackVal'+rowid).val() == '' ? '0.00' : $('#AfterPackVal'+rowid).val(); - - var Cgst = $('#RevenueAfterCgst'+rowid).val() == '' ? '0.00' : $('#RevenueAfterCgst'+rowid).val(); - var Sgst =$('#RevenueAfterSgst'+rowid).val() == '' ? '0.00' : $('#RevenueAfterSgst'+rowid).val(); - var Igst = $('#RevenueAfterIgst'+rowid).val() == '' ? '0.00' : $('#RevenueAfterIgst'+rowid).val(); - - var Freight = $('#AfterFreightVal'+rowid).val() == '' ? '0.00' : $('#AfterFreightVal'+rowid).val(); - var Insurance = $('#Insval'+rowid).val() == '' ? '0.00' : $('#Insval'+rowid).val(); - var Discount =$('#AfterDisVal'+rowid).val() == '' ? '0.00' : $('#AfterDisVal'+rowid).val(); - var BasicVal = $('#basicval'+rowid).val() == '' ? '0.00' : $('#basicval'+rowid).val(); - var TotalVal =$('#TotalOrderValue'+rowid).val() == '' ? '0.00' : $('#TotalOrderValue'+rowid).val(); - //swal(TotalVal); - - - totBasicAmt = parseFloat(totBasicAmt ) - parseFloat(BasicVal); - totDiscountAmt = parseFloat(totDiscountAmt ) - parseFloat(Discount); - totPackagingAmt = parseFloat(totPackagingAmt) - parseFloat(Packaging); - - totCgst = parseFloat(totCgst ) - parseFloat(Cgst); - totSgst = parseFloat(totSgst ) - parseFloat(Sgst); - totIgst = parseFloat(totIgst ) - parseFloat(Igst); - - totFreightAmt = parseFloat(totFreightAmt ) - parseFloat(Freight); - totInsuranceAmt = parseFloat(totInsuranceAmt ) - parseFloat(Insurance); - totOrderSummaryAmt = parseFloat(totOrderSummaryAmt ) - parseFloat(TotalVal); - - - + var totBasicAmt = $('#txtTotBasicAmountRevenue').val(); + var totDiscountAmt = $('#txtTotalDiscount').val(); + var totPackagingAmt = $('#txtTotalPackaing').val(); + + var totCgst = $('#txtTotalCGST').val(); + var totSgst = $('#txtTotalSGST').val(); + var totIgst = $('#txtTotalIGST').val(); + + var totFreightAmt = $('#txtTotalFreight').val(); + var totInsuranceAmt = $('#txtTotalInsurance').val(); + var totOrderSummaryAmt = $('#txtTotalOrderValueSummary').val(); + + + var Packaging = $('#AfterPackVal'+rowid).val() == '' ? '0.00' : $('#AfterPackVal'+rowid).val(); + + var Cgst = $('#RevenueAfterCgst'+rowid).val() == '' ? '0.00' : $('#RevenueAfterCgst'+rowid).val(); + var Sgst =$('#RevenueAfterSgst'+rowid).val() == '' ? '0.00' : $('#RevenueAfterSgst'+rowid).val(); + var Igst = $('#RevenueAfterIgst'+rowid).val() == '' ? '0.00' : $('#RevenueAfterIgst'+rowid).val(); + + var Freight = $('#AfterFreightVal'+rowid).val() == '' ? '0.00' : $('#AfterFreightVal'+rowid).val(); + var Insurance = $('#Insval'+rowid).val() == '' ? '0.00' : $('#Insval'+rowid).val(); + var Discount =$('#AfterDisVal'+rowid).val() == '' ? '0.00' : $('#AfterDisVal'+rowid).val(); + var BasicVal = $('#basicval'+rowid).val() == '' ? '0.00' : $('#basicval'+rowid).val(); + var TotalVal =$('#TotalOrderValue'+rowid).val() == '' ? '0.00' : $('#TotalOrderValue'+rowid).val(); + //swal(TotalVal); + + + totBasicAmt = parseFloat(totBasicAmt ) - parseFloat(BasicVal); + totDiscountAmt = parseFloat(totDiscountAmt ) - parseFloat(Discount); + totPackagingAmt = parseFloat(totPackagingAmt) - parseFloat(Packaging); + + totCgst = parseFloat(totCgst ) - parseFloat(Cgst); + totSgst = parseFloat(totSgst ) - parseFloat(Sgst); + totIgst = parseFloat(totIgst ) - parseFloat(Igst); + + totFreightAmt = parseFloat(totFreightAmt ) - parseFloat(Freight); + totInsuranceAmt = parseFloat(totInsuranceAmt ) - parseFloat(Insurance); + totOrderSummaryAmt = parseFloat(totOrderSummaryAmt ) - parseFloat(TotalVal); + + + - $('#txtTotBasicAmountRevenue').val(parseFloat(totBasicAmt).toFixed(2) ); - $('#txtTotalDiscount').val(parseFloat(totDiscountAmt).toFixed(2) ); - $('#txtTotalPackaing').val(parseFloat(totPackagingAmt).toFixed(2) ); - - $('#txtTotalCGST').val(parseFloat(totCgst).toFixed(2) ); - $('#txtTotalSGST').val(parseFloat(totSgst).toFixed(2) ); - $('#txtTotalIGST').val(parseFloat(totIgst).toFixed(2) ); - - $('#txtTotalFreight').val(parseFloat(totFreightAmt).toFixed(2) ); - $('#txtTotalInsurance').val(parseFloat(totInsuranceAmt).toFixed(2) ); - $('#txtTotalOrderValueSummary').val(parseFloat(totOrderSummaryAmt).toFixed(2) ); - + $('#txtTotBasicAmountRevenue').val(parseFloat(totBasicAmt).toFixed(2) ); + $('#txtTotalDiscount').val(parseFloat(totDiscountAmt).toFixed(2) ); + $('#txtTotalPackaing').val(parseFloat(totPackagingAmt).toFixed(2) ); + + $('#txtTotalCGST').val(parseFloat(totCgst).toFixed(2) ); + $('#txtTotalSGST').val(parseFloat(totSgst).toFixed(2) ); + $('#txtTotalIGST').val(parseFloat(totIgst).toFixed(2) ); + + $('#txtTotalFreight').val(parseFloat(totFreightAmt).toFixed(2) ); + $('#txtTotalInsurance').val(parseFloat(totInsuranceAmt).toFixed(2) ); + $('#txtTotalOrderValueSummary').val(parseFloat(totOrderSummaryAmt).toFixed(2) ); + } @@ -2439,12 +2245,10 @@ function populateValueMainFormForDeleteItem(rowid) echo form_open($this->config->base_url().'/purchaseorder/addalterPO/',$attributes); ?>
-
+
- -

-
+

@@ -2473,7 +2277,7 @@ function populateValueMainFormForDeleteItem(rowid)
- +
'PODate','value' => set_value('PODate',$CurrentDate),'id'=>'PODate', 'class' => 'form-control num' ,'required' => 'true'); @@ -2493,7 +2297,7 @@ function populateValueMainFormForDeleteItem(rowid)
- -
+
@@ -2576,18 +2380,18 @@ function populateValueMainFormForDeleteItem(rowid)
-
+ + \ No newline at end of file diff --git a/application/views/editCapitalPo.php b/application/views/editCapitalPo.php index f7ae87fa..51fd870f 100644 --- a/application/views/editCapitalPo.php +++ b/application/views/editCapitalPo.php @@ -471,12 +471,8 @@ $("#PaymentMethod").select2();
- -

+

-
@@ -3803,18 +3799,15 @@ $("#PaymentMethod").select2(); - - +
- + - - - + @@ -3829,7 +3822,7 @@ $("#PaymentMethod").select2(); LineItemNo;?> - entity =='PO DateChanged'){ + Entity =='PO DateChanged'){ $oldValue = date('d-m-Y',strtotime($oldpo->OldValue)); }else{ $oldValue = $oldpo->OldValue; }?> - entity =='PO DateChanged'){ + Entity =='PO DateChanged'){ $newValue = date('d-m-Y',strtotime($oldpo->NewValue)); }else{ $newValue = $oldpo->NewValue; diff --git a/application/views/editRevenuepurchaseorder.php b/application/views/editRevenuepurchaseorder.php index cc213e26..5f33a7a4 100755 --- a/application/views/editRevenuepurchaseorder.php +++ b/application/views/editRevenuepurchaseorder.php @@ -68,7 +68,7 @@ $totIgst = 0.0; $ServiceDescription = ''; $CapitalRange = ''; $otherPayment=''; -$BudgetType = ''; +$BudgetType = ''; if(!empty($POMaster)) { //print_r($POMaster); @@ -103,28 +103,19 @@ $otherPayment = $Req->PaymentOtherDescription; $insurencestatus = $Req->InsuranceStatus; $insurenceno = $Req->InsuranceNumber; $BudgetType = $Req->BudgetType; - + $IGRNO = $Req->IGRNO; } } -//echo $BudgetType; if(!empty($RequistionDetails)) { foreach ($RequistionDetails as $ReqDet) { $Reqonn=new DateTime($ReqDet->ReqDate); $Reqon=$Reqonn->format('d-m-Y'); - - // $Pdt = new DateTime($Req->PODate); - // $PODate = $Pdt->format('Y-m-d'); $Requestedby=$ReqDet->Requestedby; $RequesterName=$ReqDet->FirstName; -//$Status=$ReqDet->Status; } } -// foreach ($POSTATUS as $PST ) -// { -// $POStatus=$PST->StatusName; -// } if(!empty($getlogpodtl )) { foreach ($getlogpodtl as $values ) @@ -135,7 +126,7 @@ $update=$values->FirstName; ?> + @@ -122,7 +115,7 @@ if(!empty($INRSYMBOL)) - function openModal() +function openModal() { if(vaildateBeforeOpenModal()) { @@ -173,21 +166,18 @@ function vaildateBeforeOpenModal() $('#Deliverydate').focus(); return false; } - - else if($('#PoTypeOptions').val()==0) + else if($('#PoTypeOptions').val()=="0") { - swal('Please Select POType'); - $('#PoTypeOptions').focus(); - return false; - } - else if($('#BudgetType').val()=="0") - { - swal('Please Select Budget Type'); - $('#BudgetType').focus(); - return false; - - } - + swal('Please Select POType'); + $('#PoTypeOptions').focus(); + return false; + } + else if($('#BudgetType').val()=="0") + { + swal('Please Select Budget Type'); + $('#BudgetType').focus(); + return false; + } else { return true; @@ -219,16 +209,14 @@ $(function() minDate : d, maxDate : 'now', dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '-100:+0' -}); - $("#Deliverydt").datepicker({ + }); + $("#Deliverydt").datepicker({ minDate : 'now', dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '0:+10' -}); + }); - - -$('#PoTypeOptions').change(function() -{ + $('#PoTypeOptions').change(function() + { var potypeval=$('#PoTypeOptions').val(); var poopt= ; var config=poopt[0].ConfigValue; @@ -244,19 +232,14 @@ $('#PoTypeOptions').change(function() if(obj.PaymentID=='PT05') { - $("#PaymentTerms").append( $('').val(obj.PaymentID).html(obj.PaymentTerms)); + $("#PaymentTerms").append( $('').val(obj.PaymentID).html(obj.PaymentTerms)); } }); $.each(Payment,function(idx,obj) { - if(obj.PaymentID=='PT05') - { - - } - - + if(obj.PaymentID=='PT05'){} else { $("#PaymentTerms").append( $('').val(obj.PaymentID).html(obj.PaymentTerms)); @@ -267,9 +250,6 @@ $('#PoTypeOptions').change(function() } }); - - - $('#drpSupplier').change(function() { var id = $('#drpSupplier').val(); @@ -621,77 +601,6 @@ $('#EditPackagingType').change(function() { }); -//for freight type// -// $('#drpFreight').change(function() { - // if($('#Rate').val() != '' && $('#MaterialCode').val() != "0" ) - // { - // swal(); - // $('#txtFreight').val(''); - // $('#txtAfterFreight').val(''); - // selValue = $("#drpFreight").val() ; - // if(selValue == PercentageType) - // { - // var PackagingCalculation = ''; - // $('#freightcalmodel').modal('show'); - // //$('#freightcalmodel').modal('blur'); - // $('#txtFreight').removeAttr( 'readonly','true' ); - // } - // else - // { - // if (selValue == NilType) - // { - - // $('#txtFreight').attr('readonly', 'true'); - // $('#txtFreight').val('0.00'); - // } - - // else - // { - // $('#txtFreight').removeAttr( 'readonly','true' ); - // } - // } - // } - // else - // { - // swal('Please Select MaterialCode and Rate Field Value'); - // $('#drpFreight').val("0"); - // $('#Rate').focus(); - // } - // calculateFreight(0); - - -//}); -//for edit freight type// -// $('#drpEditFreight').change(function() { - - // $('#txtEditFreight').val(''); - // $('#txtEditAfterFreight').val(''); - // selValue = $("#drpEditFreight").val() ; - - // if(selValue == PercentageType) - // { - // var PackagingCalculation = ''; - // // $('#freight').modal('show'); - // $('#freightcalmodel').modal('show'); - // $('#txtEditFreight').removeAttr( 'readonly','true' ); - // } - // else - // { - // if (selValue == NilType) - // { - - // $('#txtEditFreight').attr('readonly', 'true'); - // $('#txtEditFreight').val('0.00'); - // } - // else - // { - // $('#txtEditFreight').removeAttr( 'readonly','true' ); - // } - // } - // //calculatePackaging(1); - -// }); - $('#txtExciseDuty').change(function() { if($('#Rate').val() != '' && $('#MaterialCode').val() != "0" ) @@ -2129,22 +2038,11 @@ return true; function validateEditExceedLimit() { - //swal(" Edit Budget Check"); + var avalbudAmt = parseFloat($('#EditAvlBudAmt').val()); var basicAmountRate = parseFloat($('#txtEditBasicValue').val()); - //swal(basicAmountRate); - // var totalAmount = parseFloat($('#txtEditTotalOrderValue').val()); - // if(basicAmountRate > avalbudAmt)// || totalAmount > avalbudAmt) - // { - // swal('Basic amount is exceeding the Budget Limit.Please adjust the product value.'); - // $('#EditRate').focus(); - // return false; - // } - // else - // { - return true; - // } + return true; } function calculateEditTotalValue() @@ -2224,13 +2122,11 @@ function calculateEditTaxValue()
- -

+

- -
+
@@ -2292,7 +2188,7 @@ function calculateEditTaxValue()
-
+
Select Tax Range
Sno PONOLineItemNoLineItemNo Entity OldValue NewValue Entity?>SupplierName)){echo $oldValue.'-'.$oldpo->SupplierName;}else{echo $oldValue;} ?>
@@ -2440,8 +2336,7 @@ function calculateEditTaxValue()
- - +
-
- - + + 'Select','1'=>'REVENUE','2'=>'CAPITAL'); - echo form_dropdown('BudgetType', $optionsnew,set_value('BudgetType'),'id="BudgetType"' ,'required="true"' ,'class="form-control select2'); + $optionsnew=array('0'=>'Select','1'=>'REVENUE','2'=>'CAPITAL'); + echo form_dropdown('BudgetType', $optionsnew,set_value('BudgetType'),'id="BudgetType"' ,'required="true"' ,'class="form-control select2'); - ?> + ?> - -
+ +
@@ -3660,9 +3555,9 @@ $("#insurance").change(function(){ }); $("#BudgetType").change(function(){ -var aa = $("#BudgetType option:selected").text(); + var aa = $("#BudgetType option:selected").text(); -$('#Budget').val(aa); + $('#Budget').val(aa); }); @@ -3782,7 +3677,7 @@ $("#EDITREVENUE").on("shown.bs.modal", function(e) { }); $('.AddRevenue').click(function(){ tinyMCE.triggerSave(); - if(validateRevenueTax() && ExceedQuantityCheck()) + if(validateRevenueTax() && ExceedQuantityCheck()) { var temp = index; var Reqnumber = $('#ReqNo').val(); @@ -4184,7 +4079,6 @@ function validateEditRevenueTax() function DeleteRow(rowid) { var DelRows = $('#txtDeletedRow').val(); - //alertMaterialListrowid); var answer = confirm(" Do you want to delete the Item from the List?") if (answer) @@ -4294,65 +4188,55 @@ var AvlBudAmt = ''; //swal(txtTotBasicAmount+"--"+txtTotalDiscount+"--"+finalBasicAmount+"--"+AvlBudAmt); if(validate()) { - if(document.getElementById('revenueTax').rows.length < 3) + if(document.getElementById('revenueTax').rows.length < 3) { swal('Please Select Line item to Create PO'); $('#Deliverydt').focus(); return false; } - // else if(parseInt(AvlBudAmt) < parseInt(finalBasicAmount)) { - // swal('Total Order Amount is exceeding the Budget Limit.Please adjust the product value.'); - - // return false; - // } - else if($('#Otherpayment').val()=='' && $('#PaymentTerms').val()=='PT08'){ - swal('Please Enter Payable Terms Description'); + else if($('#Otherpayment').val()=='' && $('#PaymentTerms').val()=='PT08'){ + swal('Please Enter Payable Terms Description'); $('#Otherpayment').focus(); return false; - } - else if($('#insurance').val() == 1 && $('#insuranceno').val() == ''){ - swal('Please Enter Insurance No..!'); - $('#insurance').focus(); - return false; - } - - - else if($('#PoTypeOptions').val()=="0") - { - alert('Please Select POType'); - $('#PoTypeOptions').focus(); - return false; - - } + } + else if($('#insurance').val() == 1 && $('#insuranceno').val() == ''){ + swal('Please Enter Insurance No..!'); + $('#insurance').focus(); + return false; + } + else if($('#PoTypeOptions').val()=="0") + { + swal('Please Select POType'); + $('#PoTypeOptions').focus(); + return false; + } else { - - - $('#content').loader('show'); - $.ajax({ - data:$('.CreatePO').serialize(), - type:"POST", - url:"purchaseorder/addNewPurchaseOrder", - success:function(data) { - if(data) - { - $('#content').loader('hide'); - alert(data); - $('#txtRowCount').val(''); - $('#txtDeletedRow').val(''); - //$('#SpcialInstruction').val(''); - //$('#txtDeliveryAddress').val(''); - window.location = "purchaseorderListing"; + $('#content').loader('show'); + $.ajax({ + data:$('.CreatePO').serialize(), + type:"POST", + url:"purchaseorder/addNewPurchaseOrder", + success:function(data) { + if(data) + { + $('#content').loader('hide'); + swal(data); + $('#txtRowCount').val(''); + $('#txtDeletedRow').val(''); + //$('#SpcialInstruction').val(''); + //$('#txtDeliveryAddress').val(''); + window.location = "purchaseorderListing"; - } - else - { - alert("Error"); - } + } + else + { + swal("Error"); + } - } + } - }); + }); } } @@ -4430,7 +4314,6 @@ function change(){ $('#AfterCgst').val(calculateCgstTax($('#txtBasicValue').val(),$('#Cgst').val(),$('#txtAfterDiscount').val ()== '' ? '0.00' : $('#txtAfterDiscount').val(),$('#txtAfterPackaging').val() == '' ? '0.00' :$('#txtAfterPackaging').val(),$('#txtAfterFreight').val() == '' ? '0.00' :$('#txtAfterFreight').val())); } - //alert($('#Cgst').val()); if($("#Sgst").val()!=''){ $('#AfterSgst').val(calculateCgstTax($('#txtBasicValue').val(),$('#Sgst').val(),$('#txtAfterDiscount').val ()== '' ? '0.00' : $('#txtAfterDiscount').val(),$('#txtAfterPackaging').val() == '' ? '0.00' :$('#txtAfterPackaging').val(),$('#txtAfterFreight').val() == '' ? '0.00' :$('#txtAfterFreight').val())); @@ -4471,18 +4354,16 @@ function calculateTotalValue() function calculateCgstTax(varBasicValue,Cgst,discount,pack,freight) { - //alert('hai'); var discount = discount; var packaging = pack; var freight = freight; var packfreight =parseFloat(packaging)+parseFloat(freight); - // alert( packfreight); + var basicValue1 = parseFloat(varBasicValue-discount); - // alert("basicValue1:"+basicValue1); + var basicValue =parseFloat(basicValue1+packfreight); var Cgst = parseFloat(Cgst); - // alert("Cgst:"+Cgst); - // alert ("basicValue:"+basicValue); + var ServiceTaxValue = 0.0; @@ -4499,7 +4380,7 @@ function calculateTotalValue() var packaging = pack; var freight = freight; var packfreight =parseFloat(packaging)+parseFloat(freight); - // alert( packfreight); + var basicValue1 = parseFloat(varBasicValue-discount); var basicValue =parseFloat(basicValue1+packfreight) var Sgst = parseFloat(Sgst); @@ -4515,19 +4396,19 @@ function calculateTotalValue() function calculateIgstTax(varBasicValue,Igst,discount,pack1,freight1) { var discount = discount; - // alert(discount); + var packaging=parseFloat(pack1); - //alert(packaging); + var freight=parseFloat(freight1); - //alert(freight); + var packfreight=parseFloat(packaging)+parseFloat(freight); - //alert(packfreight); + var basicValue1 = parseFloat(varBasicValue-discount); - // alert(basicValue1); - var basicValue =parseFloat(basicValue1+packfreight) - // alert(basicValue); + + var basicValue =parseFloat(basicValue1+packfreight) + var Igst = parseFloat(Igst); - //alert(Igst); + var ServiceTaxValue = 0.0; ServiceTaxValue = ; @@ -4554,7 +4435,7 @@ function calculateTotalValue() var totvalue = parseFloat(AfterCgst)+ parseFloat(AfterSgst) + parseFloat(AfterIgst) ; var tot = parseFloat(totvalue).toFixed(2); - //alert('tot:'+tot); + return tot; } @@ -4591,7 +4472,4 @@ location.reload(); } - - - - + \ No newline at end of file diff --git a/application/views/requisitionform.php b/application/views/requisitionform.php index db2d5f37..4a467c9a 100644 --- a/application/views/requisitionform.php +++ b/application/views/requisitionform.php @@ -289,7 +289,7 @@ if(!empty($Emp))