diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index 37e495e0..ee88e2f2 100755 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -129,6 +129,7 @@ class cashbook extends BaseController { $data['dropdownvalues'] = $this->cashbook_model->getAccounTypes(); + $data['getsupplier'] = $this->cashbook_model->getsupplier(); //print_r($data['dropdownvalues']);die(); $this->global['pageTitle'] = 'Siddharth : Cash Book: Add New Income Expense '; $this->loadViews("addnewIncomeExpense", $this->global, $data , NULL); @@ -305,6 +306,7 @@ class cashbook extends BaseController $date = date_create($date);//,'Y-m-d'); $date = date_format($date,'Y-m-d'); $towhome = $this->input->post('towhome'); + $supplier = $this->input->post('supplier'); $gsttoggle = $this->input->post('gsttoggle'); $invoiceno = null; @@ -359,7 +361,7 @@ class cashbook extends BaseController } $balance=$totalbankamount-$totalamount; $created_by = $this->session->userdata('userId'); - $addincomexpense = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome,'invoice_no'=>$invoiceno,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$totalamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'cashtype'=>$option,'bankid'=>$bankid,'totalbankamount'=>$totalbankamount,'balance'=>$balance,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'amounttype'=>$amounttype); + $addincomexpense = array('type'=>$accounttype,'account_code'=>$accountcode,'date'=>$date,'towhom'=>$towhome,'Supplier_id'=>$supplier,'invoice_no'=>$invoiceno,'merchant'=>$merchantname,'merchant_gst'=>$mergstno,'HSN'=>$hsn ,'value_before_gst'=>$beforegst,'sgst'=>$sgst,'cgst'=>$cgst,'igst'=>$igst,'total'=>$totalamount,'description'=>$description,'document'=>$document,'Created_By'=>$created_by,'cashtype'=>$option,'bankid'=>$bankid,'totalbankamount'=>$totalbankamount,'balance'=>$balance,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'amounttype'=>$amounttype); //print_r($addincomexpense); //die(); if($balance=='0') @@ -613,6 +615,7 @@ class cashbook extends BaseController //$data['deletefile'] = $this->cashbook-model->deletefile($cash); $data['dropdownvalues'] = $this->cashbook_model->getAccounTypes(); + $data['getsupplier'] = $this->cashbook_model->getsupplier(); //print_r( $data['DepDetails']);die(); $this->global['pageTitle'] = 'Siddharth : Edit Cashbook'; $this->loadViews("editincomeexpenses", $this->global,$data, NULL); @@ -659,6 +662,7 @@ class cashbook extends BaseController $accountcode1 = $this->input->post('accode'); //echo $accountcode1;die(); $towhome1 = $this->input->post('towhome'); + $supplier = $this->input->post('supplier'); $Invoiceno1 = $this->input->post('Invoiceno'); $merchant1 = $this->input->post('merchant'); $Merchantgst1 = $this->input->post('Merchantgst'); @@ -707,7 +711,7 @@ class cashbook extends BaseController } - $updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$date,'towhom'=>$towhome1,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'description'=>$description1,'document'=>$document); + $updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$date,'towhom'=>$towhome1,'Supplier_id'=>$supplier,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'gststatus'=>(!empty($gsttoggle)?'1':'0'),'description'=>$description1,'document'=>$document); $res = $this->cashbook_model->updatedepartment($updateaccount,$id1); //print_r($updateaccount);die(); $cashbookamount=$this->cashbook_model->cashbookamount($bankid); diff --git a/application/controllers/report.php b/application/controllers/report.php index 062359fe..898111ca 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -1186,30 +1186,51 @@ class report extends BaseController } public function cashbook_cumulative_report() { - $this->global['pageTitle'] = 'Cashbook Cumulative - report '; + $this->global['pageTitle'] = 'Siddharth : Cashbook Cumulative - Report'; $data['datas']=$this->dahsboard_Model->report_cumulative_cashbook(); $this->loadviews("cashbook_cumulative_report",$this->global,$data, NULL); } - public function cashbook_month_cumulative_report() - { + // public function cashbook_month_cumulative_reported1() + // { - $this->global['pageTitle'] = 'Cashbook Cumulative(Monthwise) - report '; + // $this->global['pageTitle'] = 'Cashbook Cumulative(Monthwise) - report '; - 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); - $data['datas'] = $this->dahsboard_Model->report_cumulative_month_cashbook(); - $this->loadviews("cashbook_cumulative_month_report",$this->global,$data, NULL); + // $data['datas'] = $this->dahsboard_Model->report_cumulative_month_cashbook(); + // $this->loadviews("cashbook_cumulative_month_report1",$this->global,$data, NULL); - } + // } + + public function cashbook_month_cumulative_report() + { + $this->global['pageTitle'] = 'Siddharth : Cashbook Cumulative(Monthwise) - Report'; + if ($this->input->post('btn_submit')) { + $cname = $this->input->post('client_name'); + $ab=$this->input->post('financialyear'); + $fa=substr($ab,0,-5); + $aa=substr($ab,5,5); + + $data['accountname']=$this->dahsboard_Model->accountname(); + $data['finyear']=$this->dahsboard_Model->cashbook_finyear(); + // $data['spurchse']=$this->dahsboard_Model->rawi_report_consolidate($cname,$fa,$aa); + $data['datas'] = $this->dahsboard_Model->report_cumulative_month_cashbook($cname,$fa,$aa); + } + + $data['accountname']=$this->dahsboard_Model->accountname(); + $data['finyear']=$this->dahsboard_Model->cashbook_finyear(); + + $this->loadviews("cashbook_cumulative_month_report",$this->global,$data, NULL); + } } ?> diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 8a1b4f0d..f7ca0ba9 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -2164,15 +2164,17 @@ if ($cname!= ''){ function report_inwardcashbook($cname,$fa,$aa,$m,$frm,$t,$cat){ $sql="select tinex.account_code as AccountCode,date_format(tinex.date,'%d-%m-%Y') as Date,ac.name as AccountName, - tinex.type as type,tinex.cashtype as category ,tinex.merchant as Suppliername, tinex.sgst as sgst, + tinex.type as type,tinex.cashtype as category ,tinex.merchant as merchantname,tinex.Supplier_id as Supplierid,sup.SupplierName as Suppliername, tinex.sgst as sgst, tinex.value_before_gst as Value,tinex.cgst as cgst,tinex.igst as igst, tinex.total as Total FROM t_income_expense tinex join t_accountcode ac on ac.code = tinex.account_code + join T_SupplierDetailsN sup on sup.SupplierID = tinex.Supplier_id where tinex.gststatus = '1' "; if ($cname!= ''){ - $sql.="and tinex.merchant = '".$cname."'"; + // $sql.="and tinex.merchant = '".$cname."'"; + $sql.="and sup.SupplierName = '".$cname."'"; } if ($fa and $aa != ''){ @@ -2572,20 +2574,46 @@ function daybeforetotal($yesterday){ $query = $this->db->query($sql,array($yesterday)); return $query->result(); } + + function accountname() + { + $sql = "SELECT name from t_accountcode "; + $query = $this->db->query($sql); + return $query->result(); + } - - function report_cumulative_month_cashbook(){ + function cashbook_finyear(){ + + $sql="SELECT + CASE WHEN MONTH(date)>=4 THEN + concat(YEAR(date), '-',YEAR(date)+1) + ELSE concat(YEAR(date)-1,'-', YEAR(date)) END AS financial_year + FROM t_income_expense + GROUP BY financial_year"; + $query = $this->db->query($sql); + return $query->result(); - if (date('m') >= 4) { - $yearl = date('Y').'-'.(date('Y')+1); - } else { - $yearl = (date('Y')-1).'-'.date('Y'); + } + + //function report_cumulative_month_cashbook(){ + function report_cumulative_month_cashbook($cname,$yr1,$yr2){ + + if ($yr1 == '' && $yr2 == ''){ + 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); + } + else{ + $fa=$yr1; + $aa=$yr2; } - $ab=$yearl; - $fa=substr($ab,0,-5); - $aa=substr($ab,5,5); - $sql = "SELECT sub.name as name, + $sql = "SELECT sub.name as name,sub.tincyear, sub.expensetotal as Finyeartotalexpense, sub.incometotal as Finyeartotalincome, IF(month = 'Jan', sub.expensetotal, 0) AS 'Janexp', @@ -2613,7 +2641,7 @@ function daybeforetotal($yesterday){ IF(month = 'Nov', sub.incometotal, 0) AS 'Novinc', IF(month = 'Dec', sub.incometotal, 0) AS 'Decinc' FROM ( - select DATE_FORMAT(tinc1.date, '%b') AS month,ac1.name, + select DATE_FORMAT(tinc1.date, '%b') AS month,year(tinc1.date) as tincyear,ac1.name, ifnull(case when tinc1.type = 'PAYMENT' then sum(tinc1.total) @@ -2624,9 +2652,12 @@ function daybeforetotal($yesterday){ end, '0') as incometotal FROM t_income_expense tinc1 join t_accountcode ac1 on ac1.code = tinc1.account_code - WHERE (tinc1.date >='".$fa."-04-01' and tinc1.date <= '".$aa."-03-31') - GROUP BY ac1.name ) as sub - GROUP BY name "; + WHERE (tinc1.date >='".$fa."-04-01' and tinc1.date <= '".$aa."-03-31')"; + if ($cname!= ''){ + $sql.="and ac1.name = '".$cname."'"; + } + $sql.= "GROUP BY ac1.name ) as sub + GROUP BY name "; $query = $this->db->query($sql); return $query->result(); diff --git a/application/views/addnewIncomeExpense.php b/application/views/addnewIncomeExpense.php index 25f92f75..7fc428d9 100755 --- a/application/views/addnewIncomeExpense.php +++ b/application/views/addnewIncomeExpense.php @@ -4,6 +4,7 @@ $(function() { var t = []; var ex = []; var inc = []; + var supp =[]; t= ; $.each(t,function(i,item){ if(item.type == 'RECEIPT') @@ -11,6 +12,11 @@ $(function() { $("#accode").append( $('').val(item.code).html(item.name)); } }); + + supp = ; + $.each(supp,function(s,supp){ + $("#supplier").append( $('').val(supp.SupplierID).html(supp.SupplierID+' - '+supp.SupplierName)); + }); $('#gst').click(function(){ $('#gstarea').toggle(); @@ -125,7 +131,7 @@ function loadAccountType(id)
- Back + Back

@@ -184,6 +190,18 @@ function loadAccountType(id)
+ +
+
+
+ Select Supplier: *

+ +
+
+
+
@@ -369,6 +387,7 @@ function validate() var cgst = $('#CGST').val(); var igst = $('#IGST').val(); var total = $('#totalamount').val(); + var supplier = $('#supplier').val(); var errorflag = 0; @@ -391,6 +410,10 @@ function validate() { errorflag++; } + if(supplier == '') + { + errorflag++; + } if(gstcheck == true) { diff --git a/application/views/cashbook_cumulative_month_report.php b/application/views/cashbook_cumulative_month_report.php index dd77e2e9..ca668b69 100755 --- a/application/views/cashbook_cumulative_month_report.php +++ b/application/views/cashbook_cumulative_month_report.php @@ -44,8 +44,81 @@ if (date('m') >= 4) {
-

Cashbook - Cumulative Monthwise Report ( )

+

Cashbook - Cumulative Monthwise Report + + input->post('client_name')){ + $cl=$this->input->post('client_name'); + echo '('.$cl.')'; + } + if($this->input->post('financialyear')){ + $ab=$this->input->post('financialyear'); + echo '('.$ab.')'; + } + ?>

+
+ +
+ +
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
+ + +

+ +
+
+
+ + + +
@@ -126,38 +199,38 @@ if (date('m') >= 4) { - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + +
Marinc,2,'.',''); echo number_format($d->Marinc,2,'.',''); ?> Marexp,2,'.',''); echo number_format($d->Marexp,2,'.',''); ?>
diff --git a/application/views/cashbook_cumulative_report.php b/application/views/cashbook_cumulative_report.php index 9803ff3e..8cdae107 100755 --- a/application/views/cashbook_cumulative_report.php +++ b/application/views/cashbook_cumulative_report.php @@ -62,26 +62,43 @@ Payment  () + - - name; ?> - tinc)){ echo '0';}else{echo number_format($d->tinc,2,'.','');} ?> - texp)){ echo '0';}else{echo number_format($d->texp,2,'.','');} ?> - minc,2,'.',''); ?> - mexp,2,'.',''); ?> - yinc,2,'.',''); ?> - yexp,2,'.',''); ?> + tinc)){ echo '0';}else{$incdayttl = $incdayttl + round($d->tinc); echo number_format($d->tinc,2,'.','');} ?> + texp)){ echo '0';}else{$expdayttl = $expdayttl + round($d->texp); echo number_format($d->texp,2,'.','');} ?> + minc); echo number_format($d->minc,2,'.',''); ?> + mexp); echo number_format($d->mexp,2,'.',''); ?> + yinc); echo number_format($d->yinc,2,'.',''); ?> + yexp); echo number_format($d->yexp,2,'.',''); ?> - + + + + + + + + + + +
diff --git a/application/views/editincomeexpenses.php b/application/views/editincomeexpenses.php index f1f1456a..1f72282d 100755 --- a/application/views/editincomeexpenses.php +++ b/application/views/editincomeexpenses.php @@ -19,6 +19,7 @@ $towhom1=''; $id=''; $file1=''; $document = ''; +$supplier=''; //print_r( $DepDetails); //print_r($dropdownvalues);die(); if(!empty($DepDetails)) @@ -56,6 +57,7 @@ if(!empty($DepDetails)) $IGST1=$ded->igst; $Description1=$ded->description; $towhom1=$ded->towhom; + $supplier=$ded->Supplier_id; $balancetoupdate=($bankamount)-($alreadypaid+$alreadyreceived); //$file1=$ded->document; //echo $file1; @@ -155,10 +157,11 @@ $('#merchant').autocomplete({ $(function() { - + //$('#supplier').select2(); var t = []; var ex = []; var inc = []; + var supp = []; t= ; //$("#accode").prepend( $('').val('').html('')); @@ -171,7 +174,14 @@ $(function() { $('#accode option[value=""]').prop('selected', true); + supp = ; + $.each(supp,function(s,supp){ + $("#supplier").append( $('').val(supp.SupplierID).html(supp.SupplierID+' - '+supp.SupplierName)); + }); + $('#supplier option[value=""]').prop('selected', true); + + var gst = ''; //alert(gst); if(gst == '1'){ @@ -381,6 +391,16 @@ function loadAccountType(id)
+
+
+
+ Select Supplier: *

+ +
+
+