load->model('purchaseorder_model'); $this->load->library('session'); $this->load->library('form_validation'); $this->load->model('requistion_model'); $this->load->model('inwardgateregister_model'); $this->load->model('mrir_model'); $this->isLoggedIn(); $this->CompanyName = "RESICO"; } /** * This function used to load the first screen of the user */ public function index() { $this->global['pageTitle'] = $this->CompanyName.' : AddPO'; $this->loadViews("addPO", $this->global, NULL , NULL); } function requisition() { $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq(); $data['stList'] = $this->purchaseorder_model->getStatusListforAllReq(); $data['ReqList'] = $this->purchaseorder_model->getRequistionListbySearch(); $this->global['pageTitle'] = $this->CompanyName.' : Create PO from Requisition List'; $this->loadViews("createPOfromRequistion", $this->global, $data,Null); } function CreateEmergencyPO() { $RequestedBy = $this->session->userdata ('EmpID'); $this->global['pageTitle'] = $this->CompanyName.' : Create Emergency Purchase Order'; $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['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); //$data['Payment']=$this->purchaseorder_model->getSupplierPayment('C009'); $data['Payment']=$this->purchaseorder_model->getPaymentTermsDetails(); //$data['WorkStatus']=$this->purchaseorder_model->GetWorkStatus('C019'); $data['WorkStatus']=$this->purchaseorder_model->getStatus(7); $data['ServiceOption'] = $this->requistion_model->getConfigValue('C022'); $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); $this->loadViews("alterpurchaseorder", $this->global, $data, Null); } /** * this function used for get all material code using request type */ function getMaterialCode(){ $reqType = $this->input->post('input'); $materialList = $this->requistion_model->GetMaterialCode($reqType); echo json_encode($materialList); } /*This function is used for get cost center list using department code*/ function getCostCenterName(){ $CostList=''; $DeptCode = $this->input->post('id'); $CostList = $this->requistion_model->GetCostCenterByDept($DeptCode); // print_r($CostList); echo json_encode($CostList); } // function addfile() // { // $file = ''; // //Check whether user upload picture // if(!empty($_FILES['images']['name'])) // { // //echo 'true'; // $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(); // //print_r($uploadData); // $file = $uploadData['file_name']; // } // else // { // $error = array('error' => $this->upload->display_errors()); // //print_r($error); // $file = ''; // } // } // else // { // //echo 'false'; // $file = ''; // } // return $file ; // } // function addfile1() // { // $file = ''; // //Check whether user upload picture // if(!empty($_FILES['images1']['name'])) // { // //echo 'true'; // $config['upload_path'] = 'uploads/BillFiles/'; // $config['allowed_types'] = 'docx|pdf|doc|png|jpg'; // $config['file_name'] = $_FILES['images1']['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('images1')) // { // $uploadData = $this->upload->data(); // //print_r($uploadData); // $file = $uploadData['file_name']; // } // else // { // $error = array('error' => $this->upload->display_errors()); // //print_r($error); // $file = ''; // } // } // else // { // //echo 'false'; // $file = ''; // } // return $file ; // } function addfile($pathname) { // echo "add files"; // die(); //echo $pathname; die(); $picture = ''; if(!empty($_FILES[$pathname]['name'])) { $config['upload_path'] = 'uploads/BillFiles/'; $config['allowed_types'] = '*'; //$config['allowed_types'] = 'jpg|jpeg|png|gif'; $config['file_name'] = str_replace(" ","",$_FILES[$pathname]['name']); // echo $config['file_name']; // echo "if"; //Load upload library and initialize configuration $this->load->library('upload',$config); $this->upload->initialize($config); if($this->upload->do_upload($pathname)) { // echo "uploadif"; $uploadData = $this->upload->data(); $picture = $uploadData['file_name']; } else { $error = array('error' => $this->upload->display_errors()); $picture = ''; } } else { // echo "else"; $picture = ''; } return $picture ; } /*----------------------------------special po file upload service----------------------------------*/ function add($pathname) { // echo "add files"; // die(); //echo $pathname; die(); $picture = ''; if(!empty($_FILES[$pathname]['name'])) { $config['upload_path'] = 'uploads/BillFiles/'; $config['allowed_types'] = '*'; //$config['allowed_types'] = 'jpg|jpeg|png|gif'; $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)) { // echo "uploadif"; $uploadData = $this->upload->data(); $picture = $uploadData['file_name']; } else { $error = array('error' => $this->upload->display_errors()); $picture = ''; } } else { // echo "else"; $picture = ''; } return $picture ; } //This used to Create Service Purchase Order function addNewServicePurchaseOrder() { //echo "t54"; //die(); $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'); if($txtsplservice=='1') { $POStatus=SPECIAL_PO; } else { $POStatus=REQITEM_Emergency_PO_CREATED; } //echo $POStatus; //die(); $POType = $this->input->post('POType'); $SpcialInstruction = $this->input->post('ScopeOfWork'); $RequistionComments = "Created Emergency Service PO"; // $TotalOrderValueSummary = $this->input->post('TextTotalOrderValueSummaryService'); $TotalOrderValueSummary = $this->input->post('txtTotalOrderValueSummaryService'); //$POStatus = $this->input->post('TextStatus'); $CreateBy = $this->session->userdata ('userId'); $RequestedBy = $this->input->post('drpDepartment'); $ReqStatus = REQITEM_Emergency_PO_CREATED; // $RowCount = $this->input->post('TextRowCount'); $RowCount = $this->input->post('txtRowCount'); //$DeletedRow = $this->input->post('TextDeletedRowCount'); $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'); $PaymentTerms=$this->input->post('PaymentMethod'); $OtherPayment=$this->input->post('Otherpayment'); if($POStatus==SPECIAL_PO) { $ServiceWorkStatus=SERVICE_COMPLETED; } else { $ServiceWorkStatus=$this->input->post('txtworkstatus'); //$ServiceWorkStatus=$this->input->post('workstatusValue'); } //echo $ServiceWorkStatus; // echo "fveg"; //die(); $ServiceScheduleType = $this->input->post('ScheduleType'); $ServiceScheduleOptions = $this->input->post('ScheduleType'); //$ServiceServiceNo = $this->input->post('ServiceNo'); $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'); // $result = $_POST['browseFiles']; // $obj = json_decode($result, true); // echo ' ' . $obj . ' '; // die(); $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); //echo $Picture; $arr[] = array($Picture); } $prefile[] = $files; } } //print_r($arr); 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 'Emergency Service Purchase Order Saved Successfully!The PO NO Is: '.$PONO; echo ""; redirect('purchaseorder/PurchaseOrderList','refresh'); } else { // echo 'Emergency Service Purchase Order Created Successfully!The PO NO Is: '.$PONO; echo ""; redirect('purchaseorder/PurchaseOrderList','refresh'); } } //This used 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'); } 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; } //$POStatus = $this->input->post('TextStatus'); $RequestedBy = $this->input->post('drpDepartment'); $CreateBy = $this->session->userdata ( 'userId' ); // $RowCount = $this->input->post('TextRowCount'); $RowCount=$this->input->post('txtRowCount1'); $BudgetType = $this->input->post('Budget'); //echo $RowCount; // $DeletedRow = $this->input->post('TextDeletedRowCount'); $DeletedRow = $this->input->post('txtDeletedRow1'); $splRow = $this->input->post('splrow'); // echo $DeletedRow; $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']; } // 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']; } //echo $PONO; // PO Line Items $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); $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") { //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']; } //echo $LineItemNo; /*----------------------------*/ // $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo); // $logaddpo = $this->purchaseorder_model->newlogpo($logpo); /*----------------------------*/ 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) { //secho "cwwe"; //die(); $PONOigr = $PONO; //echo $PONOigr; //die(); //IGR Data Entry //$DeliveryChellanOrInvoiceNo = $this->input->post('ChallanInvNo'); $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'); $CreatedBy = $this->session->userdata('userId'); $Remarksmrir='Emergency PO without Quality Check'; //$Remarks = $this->input->post('Remarks'); //$RowCount = $this->input->post('TextRowCount'); //echo $RowCount; $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $IGRStatus = IGR_CREATED; $igr = array(); $paymentstatus = NO_PAIDIGR; $igr = array('PONO'=>$PONO,'VehicleNo'=>$Vehicle,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$DeliveryChellanDate,'CourierNo'=>$Courier,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt,'MaterialRcvdDate'=>$MaterialReceivedate,'Paymentstatus'=>$paymentstatus); //print_r($igr); $igrM = $this->inwardgateregister_model->addigrM($igr); $IGRNO = ''; if(count($igrM)>0) { foreach ($igrM as $key ) { $IGRNO=$key->IGRNO; } } // echo $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; } } for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->input->post('materialCode'.$i); $Quantity = $this->input->post('quantity'.$i); $Remarked = "Special PO Without Quality Check"; $MRIRStatus=MRIR_APPROVED; //this array to store the value in child table.. $mrirdetailvalues = array('MRIRNO'=>$MRIRNO,'MaterialCode'=>$MaterialCode,'ActualQuantityReceived'=>$Quantity,'Remarks'=>$Remarked,'MRIRStatus'=>$MRIRStatus); //print_r($mrirdetailvalues); //die(); $mrirdetails = $this->mrir_model->detail_mrir($mrirdetailvalues); $getAvailableqty = $this->mrir_model->getItemQuantityFromStock(trim($MaterialCode)); if(count($getAvailableqty)>0) { $avlQty = $getAvailableqty[0]['Quantity']; } $updatStock = array('Quantity'=>($Quantity+$avlQty),'Status'=>'0','UpdatedOn'=>$createddt,'UpdatedBy'=>$CreatedBy,'Remarks'=>'Stock added for '. $MRIRNO); $this->mrir_model->UpdateStock($updatStock,trim($MaterialCode)); } } $IGRItemStatus = REQITEM_NEW; for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = trim($this->input->post('materialCode'.$i)); $QuantityAsPerInvoice = $this->input->post('quantity'.$i); $OrderedQuantity = $this->input->post('quantity'.$i); $ReceivedQty = $this->input->post('AQuantity'.$i); $emergencyitemcode = $this->input->post('emergencyitemcode'); $PendingQty = 0; //echo $QuantityAsPerInvoice; //echo $PendingQty.'ReceivedQty'.$ReceivedQty; //echo ' '; if(strlen($QuantityAsPerInvoice)>0 && $QuantityAsPerInvoice != '0') { $Remarks = "Special PO Created"; $ItemStatus = ''; //if($QuantityAsPerInvoice == $OrderedQuantity) if($PendingQty == 0.00 ) { $ItemStatus = IGR_CREATED; } else { $ItemStatus = POLINEITEM_IGRPARTIAL_CREATED; } $CreatedBy = $this->session->userdata('userId'); $igrDetails = array('IGRNO'=>$IGRNO,'MaterialCode'=>$MaterialCode,'QuantityAsPerInvoice'=>$QuantityAsPerInvoice,'Remarks'=>$Remarks,'IGRItemStatus'=>$IGRItemStatus,'CreatedBy'=>$CreatedBy,'CreatedDate'=>$createddt); //print_r($igrDetails); $igrD = $this->inwardgateregister_model->addigrD($igrDetails); //print_r($igrD); //* ================================================== * / $IGRItemNo = ''; foreach($igrD as $value) { $IGRItemNo = $value->IGRItemNo; } //echo $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); //*=====================================================*/ //*===================================================*/ $get_pre_qty= $this->inwardgateregister_model->get_CurrentQty($MaterialCode); $av_qty=0; if(!empty($get_pre_qty)) { foreach($get_pre_qty as $gt) { $av_qty=$gt->Current_stock; } } $currentav_qty= $QuantityAsPerInvoice+$av_qty; $current_qty= array('Current_stock'=>$currentav_qty); $this->inwardgateregister_model->addmaterialmaster($current_qty,$MaterialCode); //*==================================================*/ $Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO,$MaterialCode); $ReceivedQuantity = 0.00; if(count($Recqty)>0) { foreach ($Recqty as $key ) { $ReceivedQuantity=$key->ReceivedQuantity; } } $totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice; //echo ''; $POLineItem = array('ReceivedQuantity'=>$totalReceivedqty,'Status'=>$ItemStatus,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt ); $this->inwardgateregister_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode); } //$myfile = array('FilePath'=>$filename); // $emergencyitemcode = $this->input->post('emergencyitemcode'.$i); // ($this->input->post('materialCode'.$i)); } $counts = $this->input->post('hidecounter'); $constants = $this->input->post('hideconstant'); // $arr = []; // for($i=1;$i<=$constants;$i++){ // $pathname = 'browseFiles'.$i; // if(!empty($_FILES[$pathname]['name'])) // { // $Picture = $this->addfile($pathname); // //echo $Picture; // $arr[$i] = array($Picture); // } // } $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; } } 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'); } /** * This function is used to load the purchaseorder list */ function PurchaseOrderList() { $this->load->library('pagination'); $count = $this->purchaseorder_model->purchaseorderListingCount(''); $returns = $this->paginationCompress ( "purchaseorderListing/", $count, 5 ); //$this->purchaseorder_model->UpdateRequistItemStatus(); $this->purchaseorder_model->UpdateRequistionStatus(); $data['POData'] = $this->purchaseorder_model->purchaseorderListing(); $this->global['pageTitle'] = $this->CompanyName.' : Purchase Orders'; $this->loadViews("POlist", $this->global, $data, NULL); } function Req_validate($selectValue) { //echo 'select_validate method called'; // 'none' is the first option and the text says something like "-Choose one-" if(strlen($selectValue) == 0) { $this->form_validation->set_message('Req_validate', 'Please Select Requisition Number to Create PO.'); return false; } else // user picked something { return true; } } /** * This function used to show the Purchase Order Screen */ function CreatePurchaseOrder() { $this->load->library('form_validation'); $this->form_validation->set_rules('txtReqNo', 'txtReqNo', 'callback_Req_validate'); if($this->form_validation->run() == FALSE) { $this->requisition(); //echo 'Validate method called'; } else { $this->global['pageTitle'] = $this->CompanyName.' : Purchase order form'; $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006'); $data['FreightType'] = $this->purchaseorder_model->getConfigValue('C018'); $data['Suplist'] = $this->purchaseorder_model->getSupplierName(); $SelectedReq = json_decode($this->input->post('txtReqNo')); $Req = $SelectedReq->Req; $data['ReqList'] = $Req ; $ReqArray = array(); $ReqType = ''; $result = array(); foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); $ReqType = $SID->ReqType; //echo $SID->ReqNo; endforeach; //print_r ($result); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $Year = $dt->format('Y'); $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$ReqType); $data['MaterialList'] = $result; //$this->purchaseorder_model->getRawMaterialList($ReqType,$ReqArray); //print_r ($data['MaterialList']); $data['RequistionDetails'] = $this->purchaseorder_model->getRequistDetails($ReqArray); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['MaxPODate'] = $this->purchaseorder_model->getLastCreatedPODate(); $ViewName = ''; if($ReqType == REVENUE) { $ViewName = 'Purchaseorder'; } else if($ReqType == SERVICE) { $ViewName = 'servicePurchaseorder'; } $this->loadViews($ViewName, $this->global,$data, NULL); } } function CreatePOPrint() { $PONO = $_GET['PONO']; $ReqType = $_GET['ReqType']; if($ReqType == SERVICE) { $this ->servicepoprint($PONO); } else if($ReqType == REVENUE) { $this ->revenuepoprint($PONO); } } //To View/Update Purchase Order function EditPurchaseOrder() { $PONO = $_GET['PONO']; $ReqType = $_GET['ReqType']; $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $Year = $dt->format('Y'); $data['CostList'] = $this->purchaseorder_model->getCostCenterbyRequist('',$Year,$ReqType); $Req = $this->purchaseorder_model->getRequistionNoFromPO($PONO); $data['ReqList'] = $Req ; $result = array(); $ReqArray = array(); foreach ($Req as $SID): $ReqArray[] = $SID->ReqNo ; $result[] = $this->purchaseorder_model->getRawPOMaterialList($SID->ReqNo); endforeach; $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'] = $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'] = $this->CompanyName.' : Edit Revenue Purchase order form'; $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); } } // To get the Material value based on the MaterialCode function getDetailsforReq() { $SearchFilter= $this->input->post('id'); // $reqDate= $this->input->post('ReqDate'); $DeptCode = $SearchFilter[0]; $MatType = $SearchFilter[1]; $ReqNo = $SearchFilter[2]; // $ReqDetai = $this->purchaseorder_model->getRequistDetails( $EmpID ); $CostList = $this->requistion_model->GetCostCenterByDept( $DeptCode); $HTML = ""; $BudAmount = ""; if(count($CostList) > 0) { for ($j = 0; $j < count($CostList); $j++) { $Code = $CostList[$j]['CostCenterCode']; $Name = $CostList[$j]['CostCenterName']; $HTML .=""; } } $MaterialDetails = $this->purchaseorder_model->getRawMaterialListForPO($MatType,$ReqNo); $HTML1 = ""; if(count($MaterialDetails) > 0) { for ($j = 0; $j < count($MaterialDetails); $j++) { $Code = $MaterialDetails[$j]['MaterialCode']; $Name = $MaterialDetails[$j]['MaterialName']; $HTML1 .=""; } } // print_r($HTML1); die(json_encode(array('MatDetail' =>$HTML1,'Cost'=> $HTML))); } /* This method to get the status based on the Department selection in th */ function getStatusByDepartment() { $DepId = $this->input->post('id'); $data = $this->purchaseorder_model->getStatusByDepartment($DepId); $HTML = ""; if(count($data) > 0) { for ($j = 0; $j < count($data); $j++) { $Code = $data[$j]['StatusCode']; $Name = $data[$j]['StatusName']; $HTML .=""; } } //echo $HTML; die(json_encode(array('depStaus' => $HTML))); } // To get the available Budget Amount function AvilBudgetAmount() { $SearchFilter= $this->input->post('id'); // $reqDate= $this->input->post('ReqDate'); $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); //print_r($result); $AvilBudAmt = ''; if(count($result)>0) { $AvilBudAmt = $result[0]['BudgetAmount'] - $result[0]['Totalvalue']; } // echo 'Test'; print_r($AvilBudAmt); //die(json_encode(array('Cost' => $AvilBudAmt))); } function getDateformat($Val) { $date = new DateTime($Val,new DateTimeZone('Asia/Kolkata')); // print_r($date); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } /* Method to get the Requistion list based on the search filter*/ function SearchListofRequistion() { $SearchFilter= $this->input->post('id'); // $reqDate= $this->input->post('ReqDate'); $DEPCode = $SearchFilter[0]; $Status = $SearchFilter[1]; $rng = $SearchFilter[2]; // $ToDate = $SearchFilter[3]; $FromDate =''; $ToDate = ''; // echo $rng; $Dt = explode("-",$rng); // print_r( $Dt); if(count( $Dt)>1) { $FDate = $Dt[0]; $TDate = $Dt[1]; $FromDate = $this->getDateformat($FDate); $ToDate = $this->getDateformat($TDate); } //echo $FromDate; // print_r($Dt); $result = $this->purchaseorder_model->getRequistionListbySearch($DEPCode,$Status,$FromDate,$ToDate); $HTML=""; for ($i = 0; $i < count($result); $i++) { $SNo = $i + 1; $ReqNo = $result[$i]['ReqNo']; $ReqType = $result[$i]['ReqType']; $Reqedby = $result[$i]['FirstName']; $ReqDate = $result[$i]['ReqDate']; $Status = $result[$i]['StatusName']; $Department = $result[$i]['DepartmentName']; $Designation = $result[$i]['Designation']; $HTML.=" ". $ReqNo." ".$ReqType." ".$Reqedby." ".$ReqDate." ".$Status." ".$Department." ".$Designation." "; } //print_r( $HTML); die(json_encode(array('ReqList' =>$HTML))); } /* To View the request details*/ function ListPORequistion() { $ReqNo= $this->input->post('id'); $result = $this->requistion_model->getRequistItemList($ReqNo); $ReqList = $this->requistion_model->getRequistDetails($ReqNo); $DepNo = $ReqList[0]['DEPCode']; $CostList = $this->requistion_model->GetCostCenterByDept($DepNo); $HTML=""; for ($i = 0; $i < count($result); $i++) { $SNo = $i + 1; $MaterialCode = $result[$i]['MaterialCode']; $MaterialName = $result[$i]['MaterialName']; $UOM = $result[$i]['UOM']; $Quantity = $result[$i]['Quantity']; $HTML.=" ".$SNo." ". $MaterialCode." ".$MaterialName." ".$UOM." ".$Quantity." "; //$index = $index + 1; } $CostCenter = ""; if(count($CostList) > 0) { for ($j = 0; $j < count($CostList); $j++) { $Code = $CostList[$j]['CostCenterCode']; $Name = $CostList[$j]['CostCenterName']; $CostCenter .=""; } } //echo $HTML; //echo $CostCenter; die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'Cost'=>$CostCenter))); } //This used to Create Revenue Purchase Order function addNewPurchaseOrder() { $POdt =$this->input->post('PODate'); $PODate = $this->getDateformat($POdt); $SupplierID = $this->input->post('drpSupplier'); $DeliveryAddr = $this->input->post('DeliveryAddr'); $dt = $this->input->post('Deliverydt'); $Deliverydt = $this->getDateformat($dt); $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); $SpcialInstruction = $this->input->post('txtSpcialInstruction'); $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'); $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 ); $POMaster = $this->purchaseorder_model->addPOMaster($POList); $PONO = ''; if(count($POMaster)>0) { $PONO = $POMaster[0]['PONO']; } //echo $PONO; //echo $POType; // PO Line Items $LineItemStatus = REQITEM_NEW; //echo ' test:'.REVENUE; //echo $RowCount; 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); $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); $ExciseOption = $this->input->post('ExciseOption'.$i); $ExciseValue = $this->input->post('ExciseVal'.$i); $AfterExciseValue = $this->input->post('AfterExciseVal'.$i); $VatOption = $this->input->post('VatOption'.$i); $VatValue = $this->input->post('VatVal'.$i); $AfterVatValue = $this->input->post('AfterVatVal'.$i); $CSTOption = $this->input->post('CSTOption'.$i); $CSTValue = $this->input->post('CSTVal'.$i); $AfterCSTValue = $this->input->post('AfterCSTVal'.$i); $GSTValue = $this->input->post('GSTVal'.$i); $AfterGSTValue = $this->input->post('AfterGSTVal'.$i); $OtherTaxValue = $this->input->post('OtherTaxVal'.$i); $AfterOtherTaxValue = $this->input->post('AfterOtherTaxVal'.$i); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$i); $InsuranceValue = $this->input->post('Insval'.$i); $TotalOrderValue = $this->input->post('TotalOrderValue'.$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] ; 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); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); $LineItemNo = ''; if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } //echo $LineItemNo; /*--------------*/ // $logpo =array('PONO'=>$PONO,'Date'=>$PODate,'POType'=>$POType,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$Rate,'SupplierID'=>$SupplierID,'LineItemNos'=>$LineItemNo); // $addlog= $this->purchaseorder_model->newlogpo($logpo); /*--------------*/ 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,'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); //echo 'Revenue tax Success'; } } } echo 'Purchase Order Created Successfully! PO Number Is: '.$PONO ; } //This used to Edit the Revenue Purchase Order function EditRevenuePurchaseOrder() { // echo "hi"; die; $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); /*-----------------------------------*/ $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); $POType = $this->input->post('POType'); $PoRange = $this->input->post('txtPoRange'); $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'); $Local_Interstate=$this->input->post('Range'); // PO Master // 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 ); $POMaster = $this->purchaseorder_model->updatePOMaster($PONO,$POList); $LineItemStatus = REQITEM_NEW; if($PODate != $b4podate ) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4podate,'newValue'=>$PODate,'entity'=>'PO DateChanged'); $this->purchaseorder_model->insertlogpo($logpo); } if(!empty($newSupId[0] )) { if($newSupId[0] != $b4supplier) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>'-','UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4supplier,'newValue'=>$newsup,'entity'=>'Supplier Changed'); $this->purchaseorder_model->insertlogpo($logpo); } } //echo $RowCount; 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); /*-----------------------------------*/ $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); $ExciseOption = $this->input->post('ExciseOption'.$i); $ExciseValue = $this->input->post('ExciseVal'.$i); $AfterExciseValue = $this->input->post('AfterExciseVal'.$i); $VatOption = $this->input->post('VatOption'.$i); $VatValue = $this->input->post('VatVal'.$i); $AfterVatValue = $this->input->post('AfterVatVal'.$i); $CSTOption = $this->input->post('CSTOption'.$i); $CSTValue = $this->input->post('CSTVal'.$i); $AfterCSTValue = $this->input->post('AfterCSTVal'.$i); $GSTValue = $this->input->post('GSTVal'.$i); $AfterGSTValue = $this->input->post('AfterGSTVal'.$i); $OtherTaxValue = $this->input->post('OtherTaxVal'.$i); $AfterOtherTaxValue = $this->input->post('AfterOtherTaxVal'.$i); $FreightType = $this->input->post('FreightType'.$i); $FreightValue = $this->input->post('FreightVal'.$i); $AfterFreightValue = $this->input->post('AfterFreightVal'.$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) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4qty,'newValue'=>$Quantity,'entity'=>'Quantity Changed'); $this->purchaseorder_model->insertlogpo($logpo); } if($itemRate != $b4rate) { $logpo =array('PONO'=>$PONO,'LineItemNos'=>$POLineItemNo,'UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt,'oldValue'=>$b4rate,'newValue'=>$itemRate,'entity'=>'Rate Changed'); $this->purchaseorder_model->insertlogpo($logpo); } /*---------start---------------------*/ // if(($PODate != $b4podate )||( $SupplierID != $b4supplier) || ($itemRate !=$b4rate) || // ($Quantity != $b4qty )) // { // $logpo =array('UpdateBy'=>$updatedBy,'UpdatedOn'=>$updateddt); // $this->purchaseorder_model->updatelogpo($MaterialCode,$POLineItemNo,$logpo); // } /*----------end--------------------*/ $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") { if(strlen($POLineItemNo) == 0) { $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt,'CostCenterCode'=>$CostCenter); $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); if(count($POLineItem)>0) { $LineItemNo = $POLineItem[0]['LineItemNo']; } } else { $LineItemNo = $POLineItemNo; $POLineItemList = array('PONO'=>$PONO, 'ReqNo'=>$Reqnumber,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Rate'=>$itemRate,'Status'=>$LineItemStatus,'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt,'CostCenterCode'=>$CostCenter); $POLineItem = $this->purchaseorder_model->updatePOLineItem($PONO,$POLineItemNo,$POLineItemList); } $isExists = $this->purchaseorder_model->LineItemExistsinRevenueTax($LineItemNo); if(count($isExists) == 0) { $RevenueTaxList = array('LineItemNo'=>$LineItemNo, 'DiscountType'=>$DiscountType,'DiscountValue'=>$DiscountValue,'AfterDiscount'=>$AfterDiscount,'PackagingType'=>$PackagingType,'PackagingValue'=>$PackagingValue,'PackagingCalulatedOn'=>$PackagingOption,'AfterPackagingValue'=>$AfterPackagingValue,'FreightType'=>$FreightType, 'FreightValue'=>$FreightValue,'AfterFreightValue'=>$AfterFreightValue,'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'=>$updatedBy,'CreatedDate'=>$updateddt); $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,'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, 'UpdateBY'=>$updatedBy,'UpdatedOn'=>$updateddt); $this->purchaseorder_model->updateRevenueTax($LineItemNo,$RevenueTaxList); } } } echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ; } function pageNotFound() { $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } public function revenuepoprint($PONO) { // Load all views as normal //$PONO = $_GET['PO']; $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['POItem'] = $this->purchaseorder_model->GetRevenuePurchaseOrderDetailsForPDF($PONO); // Add header to pdf //$this->load->view('includes/pdfheader'); // Load the pdf page with multiviews $this->load->View("revenuepopdf", $data); // Add header to pdf //$this->load->view('includes/pdffooter'); // Get output html $php = $this->output->get_output(); // Load library $this->load->library('dompdf_gen'); // Convert to PDF $this->dompdf->load_html($php); $this->dompdf->render(); $data['Attachment'] = FALSE; $this->dompdf->stream("RevenuePOReport.pdf",$data,$php); } public function servicepoprint($PONO) { // $this->load->view('includes/pdfheader'); // Load the pdf page with multiviews $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['POItem'] = $this->purchaseorder_model->GetServicePurchaseOrderDetailsForPrint($PONO); $this->load->View("servicepopdf", $data); // Add header to pdf //$this->load->view('includes/pdffooter'); // Get output html $php = $this->output->get_output(); // Load library $this->load->library('dompdf_gen'); // Convert to PDF $this->dompdf->load_html($php); $this->dompdf->render(); $data['Attachment'] = FALSE; $this->dompdf->stream("ServicePOReport.pdf",$data,$php); } /** * This function used to load the Delete the Requistion Items */ function DeletePODetails() { $ReqList= $this->input->post('id'); $LineItemNo = ''; $ReqNo =''; $MaterialCode = ''; $POType = ''; if(count($ReqList) > 0) { $LineItemNo = $ReqList[0]; $ReqNo = $ReqList[1]; $MaterialCode = $ReqList[2]; $POType = $ReqList[3]; } // print_r($ReqList); If($POType == REVENUE) { $this->purchaseorder_model->DeletePORevenueTax($LineItemNo); } else If($POType == SERVICE) { $this->purchaseorder_model->DeletePOServiceTax($LineItemNo); } $this->purchaseorder_model->DeletePOLineItem($LineItemNo , $ReqNo,$MaterialCode); echo "Successfully Deleted the Line item".$LineItemNo; } } ?>