From 5a0f62dd4f70b1e0fb4ac4264f335026e6cbcf4e Mon Sep 17 00:00:00 2001 From: venbatechnologies Date: Mon, 16 Jul 2018 13:33:08 +0530 Subject: [PATCH] igrmulfile --- .../controllers/amendmentpurchaseorder.php | 169 ++++-- .../controllers/inwardgateregister.php | 1 + application/controllers/purchaseorder.php | 4 + application/models/dahsboard_model.php | 521 ++++++++++-------- .../models/inwardgateregister_model.php | 28 +- application/models/purchaseorder_model.php | 20 +- application/views/Report_attach_inward.php | 57 +- application/views/Report_purchase_inward.php | 2 +- application/views/alterpurchaseorder.php | 99 ++-- application/views/inwardgateregister.php | 154 +++++- application/views/viewIGRDetails.php | 63 ++- 11 files changed, 735 insertions(+), 383 deletions(-) diff --git a/application/controllers/amendmentpurchaseorder.php b/application/controllers/amendmentpurchaseorder.php index ec5d8c4a..1017964b 100755 --- a/application/controllers/amendmentpurchaseorder.php +++ b/application/controllers/amendmentpurchaseorder.php @@ -345,6 +345,7 @@ foreach ($igrvalue as $value) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); + $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); } @@ -543,26 +544,51 @@ foreach ($igrvalue as $value) { $RevenueList = $this->purchaseorder_model->addRevenueTax($RevenueTaxList); - if($Quantity == $RecQtyvalue ) - { + // if($Quantity == $RecQtyvalue ) + // { + + // $Newstatus = array('Status'=>IGR_CREATED); + // $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); + // $Newstat = array('Status'=>IGR_CREATED); + // $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); + + // } + // else if($Quantity != $RecQtyvalue ) + // { + // $Newstatus = array('Status'=>POLINEITEM_IGRPARTIAL_CREATED); + // $this->purchaseorder_model->POLineItemsupdatestatus($NewPO,$Newstatus); + // $Newstat = array('Status'=>PO_RELEASED); + // $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); + + // } + + + } + + $qty = $this->purchaseorder_model->getpolineqty($NewPO); + + + $ordqty =''; + $recqty =''; + // $POno=''; + // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec + + // foreach ($qty as $qtyvalue) + // { + $ordqty = $qty[0]->Qty; + $recqty = $qty[0]->rec; + // $POno = $qtyvalue->PONO; + + if($ordqty == $recqty) + { $Newstatus = array('Status'=>IGR_CREATED); $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); - $Newstat = array('Status'=>IGR_CREATED); - $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); + + $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); } - else if($Quantity != $RecQtyvalue ) - { - $Newstatus = array('Status'=>POLINEITEM_IGRPARTIAL_CREATED); - $this->purchaseorder_model->POLineItemsupdatestatus($NewPO,$Newstatus); - $Newstat = array('Status'=>PO_RELEASED); - $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); - - } - - - } + echo 'Purchase Order Amended Successfully! PO Number Is: '.$PONO .'- New PO Number is'.$NewPO; } @@ -697,6 +723,8 @@ foreach ($igrvalue as $value) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); + $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); + } @@ -798,27 +826,52 @@ foreach ($igrvalue as $value) { $ServiceTaxList = array('LineItemNo'=>$LineItemNo,'CGST'=>$CGST,'After_CGST'=>$AfterCGST,'SGST'=>$SGST,'After_SGST'=>$AfterSGST,'IGST'=>$IGST,'After_IGST'=>$AfterIGST,'otherallowance'=>$otherallowance, 'TotalValue'=>$TotalOrderValue, 'CreatedBy'=>$updatedBy,'CreatedDate'=>$updateddt); $ServiceList =$this->purchaseorder_model->addServiceTax($ServiceTaxList); - if($Quantity == $RecQtyvalue ) - { + // if($Quantity == $RecQtyvalue ) + // { - $Newstatus = array('Status'=>IGR_CREATED); - $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); - $Newstat = array('Status'=>IGR_CREATED); - $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); + // $Newstatus = array('Status'=>IGR_CREATED); + // $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); + // $Newstat = array('Status'=>IGR_CREATED); + // $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); - } - else if($Quantity != $RecQtyvalue ) - { - $Newstatus = array('Status'=>POLINEITEM_IGRPARTIAL_CREATED); - $this->purchaseorder_model->POLineItemsupdatestatus($NewPO,$Newstatus); - $Newstat = array('Status'=>PO_RELEASED); - $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); + // } + // else if($Quantity != $RecQtyvalue ) + // { + // $Newstatus = array('Status'=>POLINEITEM_IGRPARTIAL_CREATED); + // $this->purchaseorder_model->POLineItemsupdatestatus($NewPO,$Newstatus); + // $Newstat = array('Status'=>PO_RELEASED); + // $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstat); - } + // } } + + $qty = $this->purchaseorder_model->getpolineqty($NewPO); + + + $ordqty =''; + $recqty =''; + // $POno=''; + // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec + + // foreach ($qty as $qtyvalue) + // { + $ordqty = $qty[0]->Qty; + $recqty = $qty[0]->rec; + // $POno = $qtyvalue->PONO; + + if($ordqty == $recqty) + { + + $Newstatus = array('Status'=>IGR_CREATED); + $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); + + $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); + + } + echo 'PO Number is'.$PONO . ' is Amended Successfully! - New Amended PO Number is '.$NewPO; } @@ -987,6 +1040,7 @@ foreach ($igrvalue as $value) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); + $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); } @@ -1214,7 +1268,32 @@ foreach ($igrvalue as $value) { } } - } + } + + $qty = $this->purchaseorder_model->getpolineqty($NewPO); + + + $ordqty =''; + $recqty =''; + // $POno=''; + // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec + + // foreach ($qty as $qtyvalue) + // { + $ordqty = $qty[0]->Qty; + $recqty = $qty[0]->rec; + // $POno = $qtyvalue->PONO; + + if($ordqty == $recqty) + { + + $Newstatus = array('Status'=>IGR_CREATED); + $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); + + $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); + + } + echo 'Purchase Order'.$PONO.'Amended Successfully! New PO Number Is: '.$NewPO ; } @@ -1370,6 +1449,7 @@ foreach ($igrvalue as $value) { $NewPOno = array('PONO' =>$NewPO); // print_r($NewPOno); $this->purchaseorder_model->updateigrmaster($igrno,$NewPOno); + $this->purchaseorder_model->updateigrfile($igrno,$NewPOno); } @@ -1577,8 +1657,33 @@ foreach ($igrvalue as $value) { $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'=>$Assable,'SubTotal'=>$Subtotal,'IGST'=>$Igst,'AfterIGST'=>$AfterIgst,'DutyImpact'=>$DutyImpact,'NetValue'=>$NetValue,'ClearingCharge'=>$ClearingCharge); $ImportList = $this->purchaseorder_model->addImportTax($ImportTaxList); - } - + } + + + $qty = $this->purchaseorder_model->getpolineqty($NewPO); + + + $ordqty =''; + $recqty =''; + // $POno=''; + // sum(Quantity)as Qty,sum(ReceivedQuantity)as rec + + // foreach ($qty as $qtyvalue) + // { + $ordqty = $qty[0]->Qty; + $recqty = $qty[0]->rec; + // $POno = $qtyvalue->PONO; + + if($ordqty == $recqty) + { + + $Newstatus = array('Status'=>IGR_CREATED); + $this->purchaseorder_model-> POLineItemsupdatestatus($NewPO,$Newstatus); + + $this->purchaseorder_model->pomasterupdatestatus($NewPO,$Newstatus); + + } + echo 'Purchase Order is'.$PONO.'Amended Successfully! New PO Number is: '.$NewPO ; } diff --git a/application/controllers/inwardgateregister.php b/application/controllers/inwardgateregister.php index 014915f6..d8b8cd96 100644 --- a/application/controllers/inwardgateregister.php +++ b/application/controllers/inwardgateregister.php @@ -682,6 +682,7 @@ $prefile =array(); function ViewIGRfile() { $IGRNO= $this->input->post('id'); + $PO =$this->input->post('id1'); $data = $this->inwardgateregister_model->viewIGRFile($IGRNO); echo json_encode($data); diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index 543c1be3..14a8cd04 100644 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -385,8 +385,12 @@ function edited(){ function CreatePOPrint() { $PONO = $_GET['PONO']; + + // print_r($PONO); $ReqType = $_GET['ReqType']; + // print_r($ReqType); + if($ReqType == SERVICE) { diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 3515322b..abbdb5ae 100644 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -7,7 +7,7 @@ class dahsboard_Model extends CI_Model /* HR DASHBOART Model START*/ function totemp() { - $yes_date = date('Y-m-d',strtotime("-1 days")); + $yes_date = date('Y-m-d',strtotime("-1 days")); // $sql="select count(*) as emp_count from T_Employee_Details where date(T_Employee_Details.Created_date) <= ? and isActive = 1"; // $query =$this->db->query($sql,array($yes_date)); $this->db->select('count(*) as totemp'); @@ -29,6 +29,19 @@ function getfile($PONO) $this->db->where('PONO',$PONO); + $query = $this->db->get(); + // print_r( $this->db->last_query()); + $result = $query->result_array(); + return $result; + } +function getfiles($PONO) + { + //$this->db->distinct(); + $this->db->select('*'); + $this->db->from('T_Inwardgateregister_fileupload'); + $this->db->where('PONO',$PONO); + + $query = $this->db->get(); // print_r( $this->db->last_query()); $result = $query->result_array(); @@ -36,6 +49,20 @@ function getfile($PONO) } + function selectigrfiles() + { + $this->db->select('*'); + $this->db->from('T_Inwardgateregister_fileupload'); + //$this->db->where('PONO',$PONO); + + + $query = $this->db->get(); + // print_r( $this->db->last_query()); + $result = $query->result_array(); + return $result; + + } + function totloan() { @@ -270,25 +297,25 @@ GROUP BY financial_year"; return $query->result(); } function get_employee(){ - - $yes_date = date('Y-m-d',strtotime("-1 days")); - $sql = "select * from T_Employee_Details where date(created_date) <='".$yes_date."' and isActive =1"; - $query = $this->db->query($sql); - return $query->result(); + + $yes_date = date('Y-m-d',strtotime("-1 days")); + $sql = "select * from T_Employee_Details where date(created_date) <='".$yes_date."' and isActive =1"; + $query = $this->db->query($sql); + return $query->result(); } function per($fa,$aa,$m) { - //echo $m; - $cur_month = date('M'); - //echo $cur_month; - if($cur_month == $m ){ - - $cur_date = date('d'); - }else{ - - $cur_date = date('t',strtotime($m)); - } - //echo $cur_date;die; + //echo $m; + $cur_month = date('M'); + //echo $cur_month; + if($cur_month == $m ){ + + $cur_date = date('d'); + }else{ + + $cur_date = date('t',strtotime($m)); + } + //echo $cur_date;die; $sql= "SELECT month.Eid as Eid,month.ename as ename,month.active as active,month.days as monthdays,month.Days_Worked as monthworked,month.percentage as monthpercentage from (select em.EmpID as Eid,concat(em.FirstName,'.',em.LastName) as ename,em.IsActive as active,at.NoofDays as days, Days_Worked,round((Days_Worked/".$cur_date."*100)) as percentage from @@ -600,7 +627,7 @@ function totalimportpo () function importbudgt () { - if (date('m') >= 4) + if (date('m') >= 4) { $yearl = date('Y').'-'.(date('Y')+1); } else { @@ -616,7 +643,7 @@ function importbudgt () function capitalbud () { - if (date('m') >= 4) + if (date('m') >= 4) { $yearl = date('Y').'-'.(date('Y')+1); } else { @@ -632,7 +659,7 @@ function capitalbud () function servicebudgt () { - if (date('m') >= 4) + if (date('m') >= 4) { $yearl = date('Y').'-'.(date('Y')+1); } else { @@ -648,7 +675,7 @@ function servicebudgt () function revenuebudgt () { - if (date('m') >= 4) + if (date('m') >= 4) { $yearl = date('Y').'-'.(date('Y')+1); } else { @@ -685,7 +712,7 @@ Util_Amount,0)) as ca FROM cost_center where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31'; "; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); } @@ -849,9 +876,9 @@ FROM cost_center where Status !='ST030' and date(PODate) >= '".$fa."-04-01' and date(PODate) <= '".$aa."-03-31' group by Cost_Center_Code,BudgetYear,BudgetType"; $query = $this->db->query($sql); - //echo $sql; + //echo $sql; return $query->result(); - + } @@ -935,7 +962,7 @@ ifnull(sum(pl.Quantity * pl.Rate),0))) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -+ ifnull(rt.Insurance,0) ++ ifnull(rt.Insurance,0) - ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total FROM T_PurchaseOrder_Master pm join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO @@ -1011,7 +1038,7 @@ ifnull(sum(pl.Quantity * pl.Rate),0))) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) + ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -+ ifnull(rt.Insurance,0) ++ ifnull(rt.Insurance,0) - ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO @@ -1351,14 +1378,14 @@ if ($fa and $aa != ''){ return $query->result(); } function report_cumulative(){ - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); + if (date('m') >= 4) { + $yearl = date('Y').'-'.(date('Y')+1); + } else { + $yearl = (date('Y')-1).'-'.date('Y'); + } + $ab=$yearl; + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); $sql="SELECT year.sid as sid,year.mid as mid,year.supplier_name as supplier_name,year.material_name as material_name,year.quantity as quantity,year.total as total,month.mquantity as mquantity,month.mtotal as mtotal,today.tquantity as tquantity,today.ttotal as ttotal FROM (SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,ifnull(sum(pl.Quantity),0) as quantity,round(ifnull(sum(pl.Quantity * pl.Rate),0),2) as total @@ -1408,13 +1435,13 @@ group by supplier_name,material_name"; } function report_cum_year($sup=null,$mat=null){ if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); + $yearl = date('Y').'-'.(date('Y')+1); + } else { + $yearl = (date('Y')-1).'-'.date('Y'); + } + $ab=$yearl; + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); $sql="SELECT sd.SupplierID as sid,mm.MaterialCode as mid,sd.SupplierName as supplier_name,ifnull(mm.MaterialName,'-') as material_name,IF(pl.Quantity IS NULL or pl.Quantity = '', 0, sum(pl.Quantity)) as tquantity,ifnull(sum(pl.Quantity * pl.Rate),0) as ttotal FROM T_PurchaseOrder_Master pm left join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO @@ -1483,7 +1510,7 @@ ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) - round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file + im.file as ifile,pb.FilePath as file,infiles.FilePath as Infiles from T_IGR_Master im left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode @@ -1493,6 +1520,7 @@ left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO +left join T_Inwardgateregister_fileupload infiles on infiles.IGRNO = im.IGRNO where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1587,7 +1615,7 @@ ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) - round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file + im.file as ifile,pb.FilePath as file,infiles.FilePath as Infiles from T_IGR_Master im left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode @@ -1597,6 +1625,8 @@ left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO +left join T_Inwardgateregister_fileupload infiles on infiles.IGRNO = im.IGRNO + where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1682,7 +1712,11 @@ $sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo"; function ireport_attachment($cname,$fa,$aa,$m,$frm,$t){ - $sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, +// $sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, +// sum(total) as total,file,ifile +// from igr + + $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, sum(total) as total,file,ifile from igr where status != 'ST030' @@ -1723,7 +1757,36 @@ if ($cname!= ''){ // echo $sid; //echo $sql; $query = $this->db->query($sql); - return $query->result(); + + $filequery = $query->result(); + + $resultArray = array(); + + foreach ($filequery as $value) { + + $tempArray['pono'] = $value->pono; + $tempArray['potype'] =$value->potype; + $tempArray['supplier_name'] = $value->supplier_name; + $tempArray['materialrcvddate'] = $value->materialrcvddate; + $tempArray['total'] = $value->total; + $tempArray['created_date'] = $value->created_date; + $tempArray['file'] = $value->file; + $tempArray['ifile'] = $value->created_date; + $tempArray['igrn'] =$value->igrn; + + $sqli ="select FilePath as Infiles from T_Inwardgateregister_fileupload where PONO =? and IGRNO =? "; + $querys = $this->db->query($sqli,array( $tempArray['pono'],$tempArray['igrn'])); + + $filepath = $querys->result(); + $tempArray['Infiles'] = $filepath; + + $resultArray[] = $tempArray; + + } + + + return $resultArray; + } function ireport_year_wise($a,$b){ @@ -2240,39 +2303,12 @@ if ($cname!= ''){ } function monthly_gst_purchase($m,$frm,$t,$fa,$aa){ - $sql="select g.doc_no,g.date,g.doc_type,g.hsn_code,sum(g.value) as value,sum(g.others) as others,sum(g.sgst) as sgst,sum(g.cgst) as cgst,sum(g.igst) as igst,sum(g.total) as total from -(SELECT pm.PONO as doc_no,date_format(pm.PODate,'%d-%m-%Y') as date, -'Purchase' as doc_type,mm.HSNCODE as hsn_code, -mm.MaterialName as material_name,sd.SupplierName as supplier_name, -round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, -(ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) -+ifnull(rt.Insurance,0) --ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)) as others, -round(( - ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0)) -,2) as total - FROM T_PurchaseOrder_Master pm -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO -left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode -left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID -left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo -left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where -pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' -group by doc_no,material_name,supplier_name) as g -left join T_PurchaseOrder_Master p on p.PONO = g.doc_no -where g.doc_no != 'null' "; + $sql="select sum(sgst) as sgst,sum(cgst) as cgst,sum(igst) as igst,sum(sgst + cgst + igst) as total from igr +where pono != 'null' "; if ($m!= ''){ - $sql.="and monthname(p.PODate) = '".$m."'"; + $sql.="and monthname(materialrcvddate) = '".$m."'"; } @@ -2280,13 +2316,13 @@ where g.doc_no != 'null' "; $fromd= date("Y-m-d",strtotime($frm)); $tod=date("Y-m-d",strtotime($t)); - $sql.="and p.PODate >= '".$fromd."' - and p.PODate <= '".$tod."'"; + $sql.="and materialrcvddate >= '".$fromd."' + and materialrcvddate <= '".$tod."'"; } - if ($fa and $aa != ''){ + if ($fa and $aa != ''){ - $sql.=" and (p.PODate >= '".$fa."-04-01' and p.PODate <= '".$aa."-03-31')"; + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; } @@ -2295,159 +2331,187 @@ where g.doc_no != 'null' "; $query = $this->db->query($sql); return $query->result(); } - public function monthly_gst_sales($m=null,$frm=null,$t=null,$fa=null,$aa=null) - { - - $sql = "select ii.invoice_id as invoice_id,ii.invoice_number as invoice_number,date_format(ii.invoice_date_created,'%d-%m-%Y') as dates, - sum(ifnull(((sgst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100),0)) - as sgst, - sum(ifnull(((iit.item_quantity * iit.item_price) * cgst.tax_rate_percent)/100,0)) - as cgst, - sum(ifnull((igst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100,0)) - as igst, - sum((ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0) - + - ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0) - + - ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0))) - as total - from ip_invoices ii - join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id - join ip_invoice_items iit on iit.invoice_id = ii.invoice_id - join ip_invoice_item_amounts iia on iia.item_id = iit.item_id - join ip_clients ic on ic.client_id = ii.client_id - join ip_products ip on ip.product_id = iit.item_product_id - left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id - left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id - left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id - where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 "; - - - - - if ($m!= ''){ - - $sql.="and monthname(ii.invoice_date_created) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromdate= date("Y-m-d",strtotime($frm)); - $todate=date("Y-m-d",strtotime($t)); - - $sql.="and ii.invoice_date_created >= '".$fromdate."' + public function monthly_gst_sales($m=null,$frm=null,$t=null,$fa=null,$aa=null) + { + + $sql = "select ii.invoice_id as invoice_id,ifnull(iii.invnum,'-') as parent_invoice_id,ii.client_id as client_id,ii.invoice_number as invoice_number,date_format(ii.invoice_date_created,'%d-%m-%Y') as dates,TIME_FORMAT(ii.invoice_time_created,'%l:%i %p') as invoice_time_created,icf.invoice_custom_fieldvalue as vehicle_no,ip.product_description as product_description,concat(ic.client_name,'-',ic.client_surname)as client_name,sum(iit.item_quantity) as item_quantity,sum(iit.item_price) as item_price,sum(iia.item_subtotal) as item_subtotal, + sum(ifnull(((sgst.tax_rate_percent * (iia.item_subtotal))/100),0)) + as sgst, + sum(ifnull(((iia.item_subtotal) * cgst.tax_rate_percent)/100,0)) + as cgst, + sum(ifnull((igst.tax_rate_percent * (iia.item_subtotal))/100,0)) + as igst, + sum((ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0) + + + ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0) + + + ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0))) + as total + from ip_invoices ii + join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id + join ip_invoice_items iit on iit.invoice_id = ii.invoice_id + join ip_invoice_item_amounts iia on iia.item_id = iit.item_id + join ip_clients ic on ic.client_id = ii.client_id + join ip_products ip on ip.product_id = iit.item_product_id + left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id + left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id + left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id + left join (select inv.invoice_id as inv_id,inv.invoice_number,iii.invnum from ip_invoices inv + left join + (select ii.invoice_id as ii,ii.invoice_number as invnum,ic.invoice_number as icnum,ic.creditinvoice_parent_id as cp from ip_invoices as ii + left join ip_invoices as ic on ii.invoice_id = ic.creditinvoice_parent_id) as iii + on iii.icnum = inv.invoice_number) as iii on iii.inv_id = ii.invoice_id + where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 "; + + + + + if ($m!= ''){ + + $sql.="and monthname(ii.invoice_date_created) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromdate= date("Y-m-d",strtotime($frm)); + $todate=date("Y-m-d",strtotime($t)); + + $sql.="and ii.invoice_date_created >= '".$fromdate."' and ii.invoice_date_created <= '".$todate."'"; - - } - if ($fa and $aa != ''){ + + } + if ($fa and $aa != ''){ $sql.=" and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31')"; } - //echo $sql; - $query = $this->db->query($sql); - return $query->result(); - - - } - function sales_gst($m=null,$frm=null,$t=null,$fa=null,$aa=null) - { - - $sql = "select ii.invoice_id as invoice_id,ii.client_id as client_id,ip.product_sku as hsn_code,ii.invoice_number as doc_no,date_format(ii.invoice_date_created,'%d-%m-%Y') as date,'Sales' as doc_type,TIME_FORMAT(ii.invoice_time_created,'%l:%i %p') as invoice_time_created,icf.invoice_custom_fieldvalue as vehicle_no,ip.product_description as product_description,concat(ic.client_name,'-',ic.client_surname)as client_name,sum(iit.item_quantity) as item_quantity,sum(iit.item_price) as item_price,sum(iia.item_subtotal) as value, - sum(ifnull(((sgst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100),0)) - as sgst, - sum(ifnull(((iit.item_quantity * iit.item_price) * cgst.tax_rate_percent)/100,0)) - as cgst, - sum(ifnull((igst.tax_rate_percent * (iit.item_quantity * iit.item_price))/100,0)) - as igst, - round(sum((iia.item_subtotal + ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0) - + - ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0) - + - ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0))),2) - as total - from ip_invoices ii - join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id - join ip_invoice_items iit on iit.invoice_id = ii.invoice_id - join ip_invoice_item_amounts iia on iia.item_id = iit.item_id - join ip_clients ic on ic.client_id = ii.client_id - join ip_products ip on ip.product_id = iit.item_product_id - left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id - left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id - left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id - where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 "; - - - - if ($m!= ''){ - - $sql.="and monthname(ii.invoice_date_created) = '".$m."'"; - - } - - if ($frm and $t != ''){ - $fromdate= date("Y-m-d",strtotime($frm)); - $todate=date("Y-m-d",strtotime($t)); - - $sql.="and ii.invoice_date_created >= '".$fromdate."' - and ii.invoice_date_created <= '".$todate."'"; - - } - if ($fa and $aa != ''){ + //echo $sql; + $query = $this->db->query($sql); + return $query->result(); + + + } + function sales_gst($m=null,$frm=null,$t=null,$fa=null,$aa=null) + { + + $sql = "select ii.invoice_id as invoice_id,'Sales' as doc_type,ip.product_sku as hsn_code,ifnull(iii.invnum,'-') as parent_invoice_id,ii.client_id as client_id,ii.invoice_number as doc_no,date_format(ii.invoice_date_created,'%d-%m-%Y') as date,TIME_FORMAT(ii.invoice_time_created,'%l:%i %p') as invoice_time_created,icf.invoice_custom_fieldvalue as vehicle_no,ip.product_description as product_description,concat(ic.client_name,'-',ic.client_surname)as client_name,sum(iit.item_quantity) as item_quantity,sum(iit.item_price) as item_price,sum(iia.item_subtotal) as value, + sum(ifnull(((sgst.tax_rate_percent * (iia.item_subtotal))/100),0)) + as sgst, + sum(ifnull(((iia.item_subtotal) * cgst.tax_rate_percent)/100,0)) + as cgst, + sum(ifnull((igst.tax_rate_percent * (iia.item_subtotal))/100,0)) + as igst, + sum((iia.item_subtotal + ifnull(((sgst.tax_rate_percent * iia.item_subtotal)/100),0) + + + ifnull(((iia.item_subtotal * cgst.tax_rate_percent)/100),0) + + + ifnull(((igst.tax_rate_percent * iia.item_subtotal)/100),0))) + as total + from ip_invoices ii + join ip_invoice_custom icf on icf.invoice_id = ii.invoice_id + join ip_invoice_items iit on iit.invoice_id = ii.invoice_id + join ip_invoice_item_amounts iia on iia.item_id = iit.item_id + join ip_clients ic on ic.client_id = ii.client_id + join ip_products ip on ip.product_id = iit.item_product_id + left join ip_tax_rates sgst on sgst.tax_rate_id = iit.sgst_item_tax_rate_id + left join ip_tax_rates cgst on cgst.tax_rate_id = iit.cgst_item_tax_rate_id + left join ip_tax_rates igst on igst.tax_rate_id = iit.igst_item_tax_rate_id + left join (select inv.invoice_id as inv_id,inv.invoice_number,iii.invnum from ip_invoices inv + left join + (select ii.invoice_id as ii,ii.invoice_number as invnum,ic.invoice_number as icnum,ic.creditinvoice_parent_id as cp from ip_invoices as ii + left join ip_invoices as ic on ii.invoice_id = ic.creditinvoice_parent_id) as iii + on iii.icnum = inv.invoice_number) as iii on iii.inv_id = ii.invoice_id + where icf.invoice_custom_fieldid = '8' and ii.invoice_status_id != 1 and ii.invoice_status_id != 1 "; + + + + if ($m!= ''){ - $sql.=" and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31')"; - - } - - - // echo $fromdate; - //echo $sql; - $sql.="group by doc_no,product_description"; - $query = $this->db->query($sql); - return $query->result(); - - - } - function purchase_gst($m,$frm,$t,$fa,$aa){ + $sql.="and monthname(ii.invoice_date_created) = '".$m."'"; + + } + + if ($frm and $t != ''){ + $fromdate= date("Y-m-d",strtotime($frm)); + $todate=date("Y-m-d",strtotime($t)); + + $sql.="and ii.invoice_date_created >= '".$fromdate."' + and ii.invoice_date_created <= '".$todate."'"; + + } + if ($fa and $aa != ''){ + + $sql.=" and (ii.invoice_date_created >= '".$fa."-04-01' and ii.invoice_date_created <= '".$aa."-03-31')"; + + } - $sql="SELECT pm.PONO as doc_no,pm.POType as potype,date_format(pm.PODate,'%d-%m-%Y') as date, -TIME_FORMAT(pm.PODate,'%l:%i %p') as created_time,'Purchase' as doc_type,mm.HSNCODE as hsn_code, -mm.MaterialName as material_name,sd.SupplierName as supplier_name, -ifnull(sum(distinct pl.Quantity),0) as quantity,mm.UOM as UOM,ifnull(sum(distinct pl.Rate),0) as rate, -round(ifnull(sum(distinct pl.Quantity * pl.Rate),0),2) as value, -if(POType = 'IMPORT' or POType = 'CAPITAL',sum(distinct pm.ExchangeRate),0) as exchange_rate, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) as sgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) as cgst, -ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) as igst, -(ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -+ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) -+ifnull(rt.Insurance,0) --ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)) as others, + // echo $fromdate; + //echo $sql; + $sql.="group by doc_no,product_description"; + $query = $this->db->query($sql); + return $query->result(); + + + } + function purchase_gst($m,$frm,$t,$fa,$aa){ + + + $sql="select im.IGRNO as igrn,pm.POType as potype,im.PONO as doc_no,'Purchase' as doc_type,mm.HSNCODE as hsn_code,mm.MaterialName as material_name,mm.Category as category,sd.SupplierName as supplier_name,mm.UOM as UOM, id.QuantityAsPerInvoice as quantity,pl.Rate as rate,round(id.QuantityAsPerInvoice * pl.Rate,2) as value,if(POType = 'IMPORT' or POType = 'CAPITAL',pm.ExchangeRate,0) as exchange_rate,date_format(im.MaterialRcvdDate,'%d-%m-%Y') as date, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), +(id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) as sgst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), +(id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) as cgst, +round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), +(id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) as igst, +(round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) ++ round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), +(id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) +- round(ifnull(if(POType = 'REVENUE', +(id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), +(id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)) as others, round(( - if(POType = 'IMPORT',sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -if(POType = 'CAPITAL' && CapitalRange = 0,sum(distinct pm.ExchangeRate * (pl.Quantity * pl.Rate)), -ifnull(sum(pl.Quantity * pl.Rate),0))) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterSGST),sum(distinct st.After_SGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterCGST),sum(distinct st.After_CGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterIGST),sum(distinct st.After_IGST)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterFreightValue),sum(distinct st.AfterFreightValue)),0) -+ ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterPackagingValue),0),0) -+ ifnull(rt.Insurance,0) -- ifnull(if(POType = 'REVENUE',sum(distinct rt.AfterDiscount),sum(distinct st.Afterdiscountval)),0)),2) as total - FROM T_PurchaseOrder_Master pm -join T_PurchaseOrder_LineItem pl on pl.PONO = pm.PONO +if(POType = 'IMPORT',(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +if(POType = 'CAPITAL' && CapitalRange = 0,(pm.ExchangeRate * (id.QuantityAsPerInvoice * pl.Rate)), +ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterSGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_SGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterCGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_CGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterIGST / pl.Quantity), + (id.QuantityAsPerInvoice * st.After_IGST / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterFreightValue / pl.Quantity), + (id.QuantityAsPerInvoice * st.AfterFreightValue / pl.Quantity)),0),2) ++ round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterPackagingValue / pl.Quantity),0),0),2) +- round(ifnull(if(POType = 'REVENUE', + (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), + (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, + im.file as ifile,pb.FilePath as file +from T_IGR_Master im +left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO +join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode +join T_PurchaseOrder_Master pm on pm.PONO = pl.PONO left join T_MaterialMaster mm on mm.MaterialCode = pl.MaterialCode left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo -where -pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; +left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO +where pm.Status != 'ST030' "; if ($m!= ''){ - $sql.="and monthname(pm.PODate) = '".$m."'"; + $sql.="and monthname(materialrcvddate) = '".$m."'"; } @@ -2455,18 +2519,18 @@ pm.Status != 'ST030' and pm.Status != 'ST056' and pm.Status != 'ST027' "; $fromd= date("Y-m-d",strtotime($frm)); $tod=date("Y-m-d",strtotime($t)); - $sql.="and date(pm.PODate) >= '".$fromd."' - and date(pm.PODate) <= '".$tod."'"; + $sql.="and date(materialrcvddate) >= '".$fromd."' + and date(materialrcvddate) <= '".$tod."'"; } if ($fa and $aa != ''){ - $sql.=" and (pm.PODate >= '".$fa."-04-01' and pm.PODate <= '".$aa."-03-31')"; + $sql.=" and (materialrcvddate >= '".$fa."-04-01' and materialrcvddate <= '".$aa."-03-31')"; } -$sql.="group by doc_no,material_name,supplier_name"; +$sql.="group by doc_no,material_name,category,supplier_name,id.IGRItemNo"; //echo $sql; $query = $this->db->query($sql); return $query->result(); @@ -2590,14 +2654,14 @@ $sql.="group by doc_no,material_name,supplier_name"; } function yearwise_data($value='') { - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); - } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); + if (date('m') >= 4) { + $yearl = date('Y').'-'.(date('Y')+1); + } else { + $yearl = (date('Y')-1).'-'.date('Y'); + } + $ab=$yearl; + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); $sql="SELECT type,sum(total) as yearlydata from t_income_expense where @@ -3052,5 +3116,4 @@ function getDailyOpeningAmt($yesterday){ } } -?> - +?> \ No newline at end of file diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php index a5fbd806..cde61e96 100755 --- a/application/models/inwardgateregister_model.php +++ b/application/models/inwardgateregister_model.php @@ -112,12 +112,32 @@ return $afftectedRows; - function viewIGRFile($IGRNO) + // function viewIGRFile($IGRNO) + // { + // $this->db->distinct(); + // $this->db->select('*'); //BillNo,IGRNO,FilePath,PONO + // $this->db->from('T_Inwardgateregister_fileupload'); + // $this->db->where('IGRNO',$IGRNO); + + // $query = $this->db->get(); + + // $result = $query->result(); + // // print_r($result);die; + // //print_r($this->db->last_query()); + // return $result; + + + + // } + function viewIGRFile($IGRNO) { $this->db->distinct(); - $this->db->select('*'); //BillNo,IGRNO,FilePath,PONO - $this->db->from('T_Inwardgateregister_fileupload'); - $this->db->where('IGRNO',$IGRNO); + $this->db->select('igrm.file,igrf.*'); //BillNo,IGRNO,FilePath,PONO + $this->db->from('T_IGR_Master igrm'); + $this->db->join('T_Inwardgateregister_fileupload igrf','igrm.IGRNO = igrf.IGRNO','left'); + //$this->db->join('T_IGR_Details igrd','igrm.IGRNO = igrd.IGRNO','left'); + + $this->db->where('igrm.IGRNO',$IGRNO); $query = $this->db->get(); diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index 73c2c130..e452e97a 100644 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -180,6 +180,14 @@ function updateigrmaster($igrno,$NewPOno) $insert_id = $this->db->affected_rows(); return $insert_id; } +function updateigrfile($igrno,$NewPOno) +{ + $this->db->where('IGRNO',$igrno); + $this->db->update('T_Inwardgateregister_fileupload',$NewPOno); + $insert_id = $this->db->affected_rows(); + return $insert_id; + +} function selectigrmaster($PONO) { @@ -196,7 +204,7 @@ $this->db->where('PONO',$PONO); function getpolineqty($NewPO) { - $this->db->select('*'); + $this->db->select('sum(Quantity)as Qty,sum(ReceivedQuantity)as rec'); $this->db->from('T_PurchaseOrder_LineItem'); $this->db->where('PONO',$NewPO); @@ -205,19 +213,19 @@ function getpolineqty($NewPO) } -function POLineItemsupdatestatus($POno,$Newstatus) +function POLineItemsupdatestatus($NewPO,$Newstatus) { - $this->db->where('PONO',$POno); + $this->db->where('PONO',$NewPO); $this->db->update('T_PurchaseOrder_LineItem',$Newstatus); $update = $this->db->affected_rows(); return $update; } -function pomasterupdatestatus($POno,$Newstat) +function pomasterupdatestatus($NewPO,$Newstatus) { - $this->db->where('PONO',$POno); - $this->db->update('T_PurchaseOrder_Master',$Newstat); + $this->db->where('PONO',$NewPO); + $this->db->update('T_PurchaseOrder_Master',$Newstatus); $update = $this->db->affected_rows(); return $update; } diff --git a/application/views/Report_attach_inward.php b/application/views/Report_attach_inward.php index 70912441..8cc6f688 100755 --- a/application/views/Report_attach_inward.php +++ b/application/views/Report_attach_inward.php @@ -225,50 +225,61 @@ Attachments - + $v) { + // $newArray[$k] = $v; + // } + // } ?> - pono;?> + - created_date;?> - materialrcvddate;?> + + - supplier_name;?> + - total,2); - echo $rel->total; + + file)){ ?> - - ifile)) { ?> - - Infiles)){ ?> - - + + + + + + + @@ -342,7 +353,7 @@ $("#Fileshow").modal("show"); '' + item.BillNo+ '' + '' + item.PONO+ '' + - 'uploads/BillFiles/'+item.FilePath+'>'+ item.FilePath +'' + + 'uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'' + // '' +item.FilePath+""> +'' diff --git a/application/views/Report_purchase_inward.php b/application/views/Report_purchase_inward.php index 64acdd4e..d28fe845 100755 --- a/application/views/Report_purchase_inward.php +++ b/application/views/Report_purchase_inward.php @@ -582,7 +582,7 @@ $('.IGRfile').click(function() { '' + i + '' + '' + item.BillNo+ '' + '' + item.PONO+ '' + - 'uploads/BillFiles/'+item.FilePath+'>'+ item.FilePath +'' + + 'uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'' + ''; }); diff --git a/application/views/alterpurchaseorder.php b/application/views/alterpurchaseorder.php index 9ae1aa87..49e592f4 100755 --- a/application/views/alterpurchaseorder.php +++ b/application/views/alterpurchaseorder.php @@ -8733,21 +8733,22 @@ else{ var div = document.createElement('div'); div.id = "divid"+counter; div.className="row"; -div.innerHTML='
'+ +div.innerHTML='
'+ - '
'+ + '
'+ ''+ '
'+ '
'+ - '
'+ - ''+ - '
'+ - '
'+ + - '
'+ + '
'+ ''+ - '
'+ - '
'+ + '
'+ + + '
'+ + ''+ + '
'+ + '
'; $('#newdiv').append(div); @@ -8814,21 +8815,22 @@ else{ var div = document.createElement('div'); div.id = "divid"+counter; div.className="row"; -div.innerHTML='
'+ +div.innerHTML='
'+ - '
'+ + '
'+ ''+ '
'+ '
'+ - '
'+ - ''+ - '
'+ - '
'+ + - '
'+ + '
'+ ''+ - '
'+ + '
'+ + + '
'+ + ''+ + '
'+ '
'+ @@ -8861,8 +8863,12 @@ div.innerHTML='
'+ function rfilealert() { +//alert(counterConstant); + +var file = $('#imag').val(); //var file = $('#imag').val(); -var file = $('#imag'+counterConstant).val(); + +// alert(file); if (file=='') { @@ -8899,20 +8905,6 @@ function Copyfilename(id) } - -// function removeRow(input) { - -// var number = input.replace(/[^0-9]+/ig,""); - -// if(counter >= 1){ -// counter--; - -// $("#divid"+number).remove(); -// $('#hidecounter').val(counter); -// } - -// } - function removeRow(input) { // alert(input); var number = input.replace(/[^0-9]+/ig,""); @@ -8968,20 +8960,22 @@ else{ var div = document.createElement('div'); div.id = "divid"+counters; div.className="row"; -div.innerHTML='
'+ +div.innerHTML='
'+ - '
'+ + '
'+ ''+ '
'+ '
'+ - '
'+ + + + '
'+ ''+ - '
'+ - '
'+ - '
'+ + '
'+ + + '
'+ ''+ - '
'+ - '
'+ + '
'+ + '
'; $('#newsdiv').append(div); @@ -9035,23 +9029,26 @@ else{ var div = document.createElement('div'); div.id = "divid"+counters; div.className="row"; -div.innerHTML='
'+ +div.innerHTML='
'+ - '
'+ + '
'+ ''+ '
'+ '
'+ - '
'+ - ''+ - '
'+ - '
'+ + // '
'+ + // ''+ + // '
'+ + // '
'+ - '
'+ + '
'+ ''+ - '
'+ - '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ '
'; @@ -9082,8 +9079,8 @@ div.innerHTML='
'+ function sfilealert() { - -var file1 = $('#images1'+counterConstants).val(); +//alert(counterConstants); +var file1 = $('#images1').val(); //$('input[name='+id+']')[0].files[0].size; if (file1=='') { diff --git a/application/views/inwardgateregister.php b/application/views/inwardgateregister.php index 99e7fe69..3a595f84 100755 --- a/application/views/inwardgateregister.php +++ b/application/views/inwardgateregister.php @@ -1,4 +1,4 @@ - + @@ -232,6 +232,7 @@ Inputmask("A{2,3} 9{1,2} A{1,2} 9{4}").mask($("#VehicleNo"));
+ @@ -452,11 +453,15 @@ function validate() //alert(data); var trHTML = ''; + var j=0; + $.each(JSON.parse(data), function (i, item) { - + + if(item.PendingQty != 0){ i=i+1; + j=j+1; trHTML += '' + - '' + i + '' + + '' + j + '' + '' + item.MaterialCode + '' + '' + item.MaterialName + '' + '' + item.UOM + '' + @@ -515,7 +520,22 @@ $('').attr({ $('#QuantityAsPerInvoice'+i).attr('readonly', 'true'); // $('#txtEditFreight').attr('readonly', 'true'); } - + $("#IGRLink").show(); + + } else{ + + + if(JSON.parse(data).length == 1 && item.PendingQty == 0){ + + $("#IGRLink").hide(); + //alert('The Order is new completed!!'); + } + + } + + + + }); @@ -535,6 +555,7 @@ $('').attr({ if((status == '' || status == '' || status == '')) { alert('The Order is completed!!'); + $("#IGRLink").hide(); } else @@ -682,21 +703,24 @@ else{ counterConstants++; var div = document.createElement('div'); -div.id = "divid"+counterConstants; +div.id = "divid"+counters; div.className="row"; div.innerHTML='
'+ - // '
'+ - // ''+ - // ''+ - // '
'+ + '
'+ ''+ '
'+ '
'+ - '
'+ + + '
'+ ''+ - '
'+ - '
'+ + '
'+ + + '
'+ + ''+ + '
'+ + + '
'; $('#newsdiv').append(div); @@ -705,7 +729,15 @@ div.innerHTML='
'+ $('#hidecounters').val(counters); $('#hideconstants').val(counterConstants); - + if(counters > 1){ + alert("Add button click here");//this allows only 5 files; + return false; + } + else { + + $('#addemorebutton').hide(); + + } @@ -713,13 +745,78 @@ div.innerHTML='
'+ } }); +function addRow(inputs) +{ if(inputs <5){ + if(inputs ==0){ + inputs = inputs+1; + $("#addbtn"+inputs).hide(); + $("#removebtn"+inputs).hide(); + }else{ + $("#addbtn"+inputs).hide(); + $("#removebtn"+inputs).hide(); + } + }else{ + $("#addbtn"+inputs).show(); + $("#removebtn"+inputs).show(); + } + // alert(s); + if(counters>4){ + alert("No more files to add");//this allows only 5 files; + return false; + } +else{ + counters++; + counterConstants++; + //alert("count"+counterConstants); +var div = document.createElement('div'); +div.id = "divid"+counters; +div.className="row"; +div.innerHTML='
'+ + + '
'+ + ''+ + '
'+ + '
'+ + '
'+ + ''+ + '
'+ + + '
'+ + ''+ + '
'+ + '
'+ + '
'; + $('#newsdiv').append(div); + + + $('#hidecounters').val(counters); + $('#hideconstants').val(counterConstants); + + + if(counters > 1){ + //alert("Next File choose + button click here");//this allows only 5 files; + //return false; + $('#addbtn').hide(); + $("#removebtn").hide(); + } + else { + + $('#addemorebutton').hide(); + + + } + +} + +} + function filecheck() { //alert(counterConstants); - var file1 = $('#images'+counterConstants).val(); + var file1 = $('#images').val(); //alert(myfile); @@ -772,16 +869,33 @@ function Copyfilenames(id) -function removeRows(input) { - - var number = input.replace(/[^0-9]+/ig,""); - if(counters>= 1){ + +function removeRows(inputs) { + // alert(input); + var number = inputs.replace(/[^0-9]+/ig,""); + //alert(number); + if(counters >= 1){ counters --; $("#divid"+number).remove(); - $('#hidecounter').val(counters); + $('#hidecounters').val(counters); + } + + var rm_count = $("#hideconstants").val(); + if(counters !=0){ + if(number != rm_count){ + // alert("if"); + $("#addbtn"+counters).show(); + $("#removebtn"+counters).show(); +}else{ + //alert('else'); + $("#addbtn"+counters).show(); + $("#removebtn"+counters).show(); + +} + }else{ + $("#addemorebutton").show(); } - } \ No newline at end of file diff --git a/application/views/viewIGRDetails.php b/application/views/viewIGRDetails.php index 5a5087a1..af7928e3 100755 --- a/application/views/viewIGRDetails.php +++ b/application/views/viewIGRDetails.php @@ -21,8 +21,8 @@

Siddharth Industries -View Inward Gate Register

- -
+ +
@@ -83,7 +83,7 @@ - + ×

Inward Gate File Details

- + +
@@ -147,7 +148,7 @@ SNo BillNO - IGRNO + PONO FileName Action @@ -449,13 +450,23 @@ $("#Fileshow").on("shown.bs.modal",function(e) { var id = $(e.relatedTarget).data('userid'); // alert(id); -$("#hiddenIGRNO").val(id); + + // SIA/2018-2019/10243.01 + // IGRNO0505 + + var igr = id.substring(0, 9); + // alert(igr); + var po = id.substring(10, 33); + //alert(po); + +$("#hiddenIGRNO").val(igr); +$("#hiddenPONO").val(po); if(id !=''){ $.ajax({ - data:{id:id}, + data:{id:igr,id1:po}, type:"POST", //dataType: 'json', url:"inwardgateregister/ViewIGRfile", @@ -467,16 +478,33 @@ $("#hiddenIGRNO").val(id); var trHTML = ''; + var FilePath =''; + var Filename = ''; $.each(JSON.parse(file), function (i, item) { - + if(item.file == null) + { if(item.Remarks ==null) + { + //alert() + Filename =item.FilePath; + FilePath = "uploads/Igrfiles/"+item.FilePath; + }else{ + Filename ="BillDetails"; + FilePath = item.FilePath; + } + + }else{ + Filename = item.file; + FilePath =item.file; + } i=i+1; trHTML += '' + '' + i + '' + '' + item.BillNo+ '' + - '' + item.IGRNO+ '' + - 'uploads/Igrfiles/'+item.FilePath+'>'+ item.FilePath +'' + + '' + item.PONO+ '' + + + ''+ Filename +'' + '' + ''; @@ -530,13 +558,12 @@ $("#hiddenIGRNO").val(id); $(function () { $.fn.dataTable.moment( 'DD-MM-YYYY' ); - - $('#Inwardgateregistertable').DataTable({ + $('#Inwardgateregistertable').DataTable({ "paging": true, "lengthChange": true, "searching": true, "ordering": true, - "aaSorting": [[ 5, "desc" ]], + "aaSorting": [[ 4, "desc" ]], "info": true, "autoWidth": true @@ -625,9 +652,11 @@ $("#Igrshow").on("shown.bs.modal", function(e) { counter++; - var bil_count = +counter + +file_count; - + var bil_count = +counter+ +file_count; + +// alert(bil_count); +// alert(file_count); if(bil_count>=5){ alert("You have to upload five files only");//this allows only 5 files; @@ -725,10 +754,10 @@ counter++; // alert(file); var PONO =$('#hiddenPONO').val(); - // alert(PONO); + // alert(PONO); var igr =$('#hiddenIGRNO').val(); - // alert(igr); + //alert(igr); formData.append('file',file);