diff --git a/application/controllers/emergencypurchaseorder.php b/application/controllers/emergencypurchaseorder.php index e9a05868..648a815e 100644 --- a/application/controllers/emergencypurchaseorder.php +++ b/application/controllers/emergencypurchaseorder.php @@ -597,14 +597,14 @@ $prefile =array(); log_message('error'," Revenue Emr-po FNS."); $txtspl=$this->input->post('txtSpecial'); - - + // echo "\n *** txtspl".$txtspl; $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'); + // echo "\n DeliveryOption ".$DeliveryOption; if($DeliveryOption==1){ $Deliverydt = ''; $DeliverySchedule = $this->input->post('Scheduleby'); @@ -635,7 +635,7 @@ $prefile =array(); if($txtspl==0) $POStatus=REQITEM_Emergency_PO_CREATED; else $POStatus=SPECIAL_PO; - + // echo "\n *** POStatus ".$POStatus; //$POStatus = $this->input->post('TextStatus'); $RequestedBy = $this->input->post('drpDepartment'); $CreateBy = $this->session->userdata ( 'userId' ); @@ -667,9 +667,11 @@ $prefile =array(); //add requistion $Request = array('ReqType'=>$POType, 'RequestedDept'=>$RequestedBy,'CostCenterCode'=>$CostCenterName,'Status'=>$ReqStatus,'Comments'=>$RequistionComments,'ReqDate'=>$createddt,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); - // print_r($Request);die(); + // print_r($Request); + // echo "\n *** "; $Req = $this->requistion_model->addRequistion($Request); + //$RegNo='01'; $RegNo=''; if(count($Req)>0) { @@ -682,6 +684,7 @@ $prefile =array(); $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); + //echo "\n *** "; $POMaster = $this->purchaseorder_model->addPOMaster($POList,$POType,$revenuetype); $PONO = ''; @@ -745,13 +748,16 @@ $prefile =array(); { //add requistion details $ReqDetails = array('ReqNo'=>$RegNo, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'Status'=>$RegDetailsStatus,'UpdatedBy'=>$CreateBy,'UpdatedOn'=>$createddt); + // print_r($ReqDetails); $ReqDetQuery = $this->requistion_model->addRequistionDetails($ReqDetails); log_message('error'," Revenue Emr-po RequistionDetails count . ".count($ReqDetQuery)." ReqNo".isset($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,'Per'=>$per,'ServiceMaterialDescription'=>$revenuedescription); //print_r($POLineItemList); + //echo "\n *** "; $POLineItem = $this->purchaseorder_model->addPOLineItem($POLineItemList); + //$LineItemNo = 'LI000'; $LineItemNo = ''; if(count($POLineItem)>0) { @@ -773,6 +779,7 @@ $prefile =array(); // 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); + //echo "\n"; $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); //echo 'Revenue tax Success'; log_message('error'," Revenue Emr-po tax Successfully . "); @@ -819,8 +826,10 @@ $prefile =array(); $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); + //echo "\n"; $igrM = $this->inwardgateregister_model->addigrM($igr); + //$IGRNO = 'igr001'; $IGRNO = ''; if(count($igrM)>0) { @@ -839,6 +848,7 @@ $prefile =array(); $mrirmaster = $this->mrir_model->master_mrir($mrirmastervalues); + // $MRIRNO = 'MRIR001'; $MRIRNO = ''; @@ -865,18 +875,21 @@ $prefile =array(); //this array to store the value in child table.. $mrirdetailvalues = array('MRIRNO'=>$MRIRNO,'MaterialCode'=>$MaterialCode,'ActualQuantityReceived'=>$Quantity,'Remarks'=>$Remarked,'MRIRStatus'=>$MRIRStatus); - + // print_r($mrirdetailvalues); + // echo 'MRIRItemNo001'; $mrirdetails = $this->mrir_model->detail_mrir($mrirdetailvalues); log_message('error'," Revenue Emr-po MRIR Item Number.".$mrirdetails[0]['MRIRItemNo']); $getAvailableqty = $this->mrir_model->getItemQuantityFromStock(trim($MaterialCode)); - + // print_r($getAvailableqty); + // echo "\n get available Qty"; if(count($getAvailableqty)>0) { $avlQty = $getAvailableqty[0]['Quantity']; } $updatStock = array('Quantity'=>($Quantity+$avlQty),'Status'=>'0','UpdatedOn'=>$createddt,'UpdatedBy'=>$CreatedBy,'Remarks'=>'Stock added for '. $MRIRNO); - + // print_r($updatStock); + // echo "\n updat Stock"; $this->mrir_model->UpdateStock($updatStock,trim($MaterialCode)); } @@ -927,11 +940,12 @@ $prefile =array(); //print_r($igrDetails); - + //echo "\n **** "; $igrD = $this->inwardgateregister_model->addigrD($igrDetails); //print_r($igrD); //* ================================================== * / + //$IGRItemNo = 'IGRItemNo001'; $IGRItemNo = ''; foreach($igrD as $value) { @@ -945,6 +959,7 @@ $prefile =array(); $MStockHistory = $this->inwardgateregister_model->addMaterialStockHistory($MaterialstockHistoryadd); + //print_r($MaterialstockHistoryadd); log_message('error'," Revenue Emr-po Material Stock History added. count ".count($MStockHistory)); //*=====================================================*/ @@ -965,7 +980,8 @@ $prefile =array(); $current_qty= array('Current_stock'=>$currentav_qty); - + // print_r($current_qty); + // echo "\n ****"; $mMaster = $this->inwardgateregister_model->addmaterialmaster($current_qty,$MaterialCode); log_message('error'," Revenue Emr-po Material Master Qty added.".$mMaster); @@ -1073,6 +1089,7 @@ $prefile =array(); if(!empty($filename)){ $myfile = array('FilePath'=>$filename,'PONO'=>$PONO,'IGRNO'=>$IGRNO); + //print_r($myfile); $fileno = $this->purchaseorder_model->fileupload($myfile); log_message('error'," Revenue Emr-po File Number.".$fileno); } diff --git a/application/controllers/quality.php b/application/controllers/quality.php index e4af9e6c..86bc84e9 100644 --- a/application/controllers/quality.php +++ b/application/controllers/quality.php @@ -212,10 +212,11 @@ class quality extends BaseController $filename = 'INWARD MATERIAL INSPECTION REPORT'.$reportid; $html = $this->load->View("viewindinwardreportpdf",$data,true); } + // echo $html;die; ob_end_clean(); $mpdf=new mPDF('utf-8','A4-P',7,10,10, 10, 10, 24, 4, 6); $mpdf->SetDisplayMode('fullpage'); - + $mpdf->showImageErrors = true; $mpdf->list_indent_first_level = 1; $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; @@ -540,7 +541,7 @@ class quality extends BaseController function zohobooks_api_fetch_all(){ //echo 'scuess';die(); - + log_message('error'," ***ZOHO***"); if (isset($_POST['sync'])) { $con = new mysqli($this->db->hostname,$this->db->username,$this->db->password,$this->db->database); @@ -555,6 +556,7 @@ class quality extends BaseController $date_today = date('Y-m-d'); $date_yesterday = date('Y-m-d',strtotime('-7 day',strtotime($date_today))); + log_message('error'," ***ZOHO***".$date_today."**".$date_yesterday); // $date_yesterday = '2022-09-01'; // echo $date_yesterday.'-'.$date_today;//die(); @@ -594,14 +596,14 @@ class quality extends BaseController curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result=curl_exec($ch); - + log_message('error'," Response ".$result); $res = json_decode($result); if($res->code=="57") { - log('error'," IF cond. "); + log_message('error'," IF condition "); $url_getauthtoken = 'https://accounts.zoho.com/oauth/v2/token?refresh_token='.$refresh_token.'&client_id='.$client_id.'&client_secret='.$client_secret.'&redirect_uri='.$redirect_uri.'&grant_type=refresh_token'; curl_setopt($ch, CURLOPT_URL, $url_getauthtoken); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); @@ -667,17 +669,18 @@ class quality extends BaseController $res2[] = $resall['invoice']; log_message('error', "Zoho URL Invoice ( " . $invoice_id . " )"); log_message('error', "Response : ".$result2); - print_r($result2); - exit(); + // print_r($result2); + // exit(); } } //echo count($res2); - + log_message('error', "Zoho URL Invoice ( " . $invoice_id . " ) count ".count($res2)); $insert_count = 0; $update_count = 0; + foreach($res2 as $rs) { @@ -743,6 +746,7 @@ class quality extends BaseController $gst_sql = "SELECT * FROM ip_clients WHERE client_tax_code='$gst_no'"; $res_gst = $con->query($gst_sql); + // $r_gst[] = $res_gst->fetch_assoc()['client_id']; $client_id = $res_gst->fetch_assoc()['client_id']; @@ -751,14 +755,14 @@ class quality extends BaseController $res_sku = $con->query($sku_sql); // $r_sku[] = $res_sku->fetch_assoc()['product_id']; $product_id = $res_sku->fetch_assoc()['product_id']; - + log_message('error invoice_number',$invoice_number); $sql_invoice_chk = "SELECT * FROM ip_invoices WHERE invoice_number='$invoice_number' AND invoice_date_created='$invoice_date'"; $res_invoice = $con->query($sql_invoice_chk); - - + log_message('error invoice chk ',$sql_invoice_chk); + log_message('error return rows ',$res_invoice->num_rows); if($res_invoice->num_rows<=0) { - + log_message('error ',$res_invoice->num_rows); $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); @@ -774,7 +778,10 @@ class quality extends BaseController $sql_invoice_insert = "INSERT INTO ip_invoices(user_id,client_id,invoice_group_id,invoice_status_id,invoice_date_created,invoice_time_created,invoice_date_due,invoice_number,invoice_url_key,receivedstatus,credit_status)VALUES(1,'$client_id',6,2,'$invoice_date','$invoice_time','$due_date','$invoice_number','$url_key','ST066',0)"; $result_invoice_insert = $con->query($sql_invoice_insert); - + log_message('error'," Invoice Inserted ".$result_invoice_insert); + log_message('error'," Invoice Inserted id ".$con->insert_id); + log_message('error',"query invoice => ",$sql_invoice_insert); + //exit(); $invoice_insert_id=$con->insert_id; $sql_invoiceitem_insert = "INSERT INTO ip_invoice_items(invoice_id,item_product_id,item_date_added,item_name,item_description,item_quantity,item_price,item_order,item_product_unit,Sgst_item_tax_rate_id,Cgst_item_tax_rate_id) diff --git a/application/views/viewindreportpdf.php b/application/views/viewindreportpdf.php index 2dc9c34c..4616aa9b 100644 --- a/application/views/viewindreportpdf.php +++ b/application/views/viewindreportpdf.php @@ -37,6 +37,8 @@ foreach($reportdata['company'] as $c) $pic = $c->ProfilePic; } } +// echo $pic;die; +// echo base_url().'uploads/images/'.$pic;die; ?>