From 35d4bb71177f400fef302fe533ddbeb3f63ac3c5 Mon Sep 17 00:00:00 2001 From: gayathri1990 Date: Wed, 20 Dec 2017 20:43:02 +0530 Subject: [PATCH] cashbook report --- application/controllers/report.php | 39 ++++++- application/logs/log-2017-12-20.php | 6 + application/models/dahsboard_model.php | 145 +++++++++++++++++++++---- 3 files changed, 165 insertions(+), 25 deletions(-) diff --git a/application/controllers/report.php b/application/controllers/report.php index 4c830e06..2876f999 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -1044,6 +1044,7 @@ class report extends BaseController $data['yearincome']=$this->dahsboard_Model->yearwise_data($income); $data['yearexpense']=$this->dahsboard_Model->yearwise_data($expense); $data['gettoptotal1'] = $this->dahsboard_Model->gettoptotal(); + $data['tdy']=$this->dahsboard_Model->today(); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); //print_r($data['gettoptotal1']); // $data['monthlywiseincome']=$this->dahsboard_Model->monthwise_data_income(); @@ -1109,18 +1110,39 @@ class report extends BaseController } public function cashbookdepartment() { + $this->global['pageTitle'] = 'Cashbook - department - '; $sid=$_GET['sid']; $d=$_GET['d']; - $this->global['pageTitle'] = 'Cashbook - department - '; - $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d); + $c=$_GET['c']; + if ($c=='PAYMENT') + { + + $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d,$c); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); //print_r($data['departmentwise']); $this->loadviews("cashbookmonthlydep",$this->global,$data, NULL); } + else{ + $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d,$c); + $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); + $this->loadviews("cashbookmonthlyexp",$this->global,$data, NULL); + } + } + public function cashbookdepartmentexp() + { + $sid=$_GET['sid']; + $d=$_GET['d']; + $c=$_GET['c']; + $this->global['pageTitle'] = 'Cashbook - department - '; + $data['departmentwise']=$this->dahsboard_Model->departmentwise($sid,$d,$c); + $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); + //print_r($data['departmentwise']); + $this->loadviews("cashbookmonthlyexp",$this->global,$data, NULL); + } //for cashbook menu link// public function cashbookmonthmenu() { - + $this->global['pageTitle'] = 'Cashbook monthly '; $data['yearmonthwise']=$this->dahsboard_Model->yearmonthwise(); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); @@ -1140,15 +1162,20 @@ class report extends BaseController { $this->global['pageTitle'] = 'Cashbook - viewtoday '; $data['tdy']=$this->dahsboard_Model->today(); + //print_r($data['tdy']); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); $this->loadviews("cashbooktoday",$this->global,$data, NULL); } public function depmenu() { - $this->global['pageTitle'] = 'Cashbook - viewtoday '; - $data['depmenu']=$this->dahsboard_Model->departmentmenu(); + $this->global['pageTitle'] = 'Cashbook - AllReport '; + $fdate = $this->input->post('from_date'); + $tdate = $this->input->post('to_date'); + //echo $fdate; + //echo $tdate; + $data['depmenu']=$this->dahsboard_Model->departmentmenu($fdate,$tdate); $data['Indiancurrency']=$this->dahsboard_Model->INRSymbol(); - $this->loadviews("cashbookdepmenu",$this->global,$data, NULL); + $this->loadviews("cashbookall",$this->global,$data, NULL); } public function cashbookmenudepartment() { diff --git a/application/logs/log-2017-12-20.php b/application/logs/log-2017-12-20.php index 54378d1f..3e93e19a 100644 --- a/application/logs/log-2017-12-20.php +++ b/application/logs/log-2017-12-20.php @@ -155,3 +155,9 @@ ERROR - 2017-12-20 15:50:31 --> Severity: Notice --> Undefined variable: sid C: ERROR - 2017-12-20 15:50:45 --> Severity: Notice --> Use of undefined constant RECEIPT - assumed 'RECEIPT' C:\xampp\htdocs\siddharth_application\application\controllers\cashbook.php 315 ERROR - 2017-12-20 15:53:42 --> Severity: Warning --> Missing argument 1 for cashbook::editcashbook(), called in C:\xampp\htdocs\siddharth_application\system\core\CodeIgniter.php on line 360 and defined C:\xampp\htdocs\siddharth_application\application\controllers\cashbook.php 269 ERROR - 2017-12-20 15:53:42 --> Severity: Notice --> Undefined variable: sid C:\xampp\htdocs\siddharth_application\application\controllers\cashbook.php 272 +ERROR - 2017-12-20 16:10:07 --> Severity: Notice --> Undefined variable: ti C:\xampp\htdocs\siddharth_application\application\views\cashbookyearlyexpenses.php 75 +ERROR - 2017-12-20 16:10:07 --> Severity: Notice --> Undefined variable: tvt C:\xampp\htdocs\siddharth_application\application\views\cashbookyearlyexpenses.php 78 +ERROR - 2017-12-20 16:10:49 --> Severity: Notice --> Undefined variable: cash C:\xampp\htdocs\siddharth_application\application\views\cashbookyearmonthwise.php 83 +ERROR - 2017-12-20 16:10:49 --> Severity: Notice --> Trying to get property of non-object C:\xampp\htdocs\siddharth_application\application\views\cashbookyearmonthwise.php 83 +ERROR - 2017-12-20 16:10:49 --> Severity: Notice --> Undefined variable: cash C:\xampp\htdocs\siddharth_application\application\views\cashbookyearmonthwise.php 83 +ERROR - 2017-12-20 16:10:49 --> Severity: Notice --> Trying to get property of non-object C:\xampp\htdocs\siddharth_application\application\views\cashbookyearmonthwise.php 83 diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 432203ac..79b6a1a0 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -1953,15 +1953,49 @@ if ($fa and $aa != ''){ function monthexpensereport() { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,sum(tinc.total)as total,tinc.towhom,tinc.description,tinc.account_code,monthname(tinc.date)as month,ac.name FROM t_income_expense as tinc join t_accountcode ac on ac.code=tinc.account_code where tinc.type='PAYMENT' and month(tinc.date)= month(current_date()) group by account_code order by total desc limit 10 "; - $query = $this->db->query($sql); - return $query->result(); + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then sum(tinc.total) + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then sum(tinc.total) + end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + tinc.total,tinc.towhom,tinc.description,monthname(tinc.date)as month,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where month(tinc.date)= month(current_date())group by tinc.account_code"; + $query = $this->db->query($sql); + return $query->result(); } function yearexpensereport() { - $sql="SELECT date_format(date,'%d-%m-%Y')as date,type,sum(total)as total,towhom,description,account_code,monthname(date)as month FROM t_income_expense where type='PAYMENT' and year(date)= year(current_date()) group by month order by total desc limit 10 "; + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + date_format(date,'%d-%m-%Y')as date,tinc.type,sum(tinc.total)as total,tinc.towhom,tinc.description,tinc.account_code,monthname(tinc.date)as month FROM t_income_expense tinc where year(date)= year(current_date()) group by month order by total desc limit 10 "; $query = $this->db->query($sql); return $query->result(); @@ -1991,11 +2025,28 @@ if ($fa and $aa != ''){ return $query->result(); } - function departmentwise($sid='',$d='') + function departmentwise($sid='',$d='',$c='') { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,.tinc.description, ac.name FROM + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,.tinc.description, ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code - WHERE tinc.type='PAYMENT' and account_code = '$sid' and monthname(date)='$d'"; + WHERE account_code = '$sid' and monthname(date)='$d' and tinc.type='$c'"; $query = $this->db->query($sql); //print_r($this->db->last_query()); //echo $sql; @@ -2004,9 +2055,26 @@ if ($fa and $aa != ''){ } function yearmonthwise($sid='') { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,sum(tinc.total)as total,monthname(tinc.date)as month,tinc.description,tinc.towhom,tinc.account_code,ac.name FROM t_income_expense tinc + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then sum(tinc.total) + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then sum(tinc.total) + end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.account_code,sum(tinc.total)as total,monthname(tinc.date)as month,tinc.description,tinc.towhom,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code - WHERE tinc.type='PAYMENT' and monthname(date) = ? group by account_code"; + WHERE monthname(date) = ? group by tinc.account_code"; $query = $this->db->query($sql,array($sid)); //print_r($this->db->last_query()); return $query->result(); @@ -2040,12 +2108,33 @@ function INRSymbol() } function today() { - $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,tinc.description,tinc.account_code,tac.name FROM t_income_expense tinc - LEFT JOIN t_accountcode tac ON tac.code = tinc.account_code - WHERE DATE(date) = CURRENT_DATE"; - $query = $this->db->query($sql); - return $query->result(); - } + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code WHERE DATE(date) = CURRENT_DATE"; + $query = $this->db->query($sql); + return $query->result(); + } + // $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date,tinc.type,tinc.total,tinc.towhom,tinc.description,tinc.account_code,tac.name FROM t_income_expense tinc + // LEFT JOIN t_accountcode tac ON tac.code = tinc.account_code + // WHERE DATE(date) = CURRENT_DATE"; + // $query = $this->db->query($sql); + // return $query->result(); + //} //for menu link in monthly payments// function monthlypayments() { @@ -2055,12 +2144,30 @@ function INRSymbol() return $query->result(); } - function departmentmenu() + function departmentmenu($fdate,$tdate) { - $sql="SELECT tinc.type,sum(tinc.total)as total,tinc.account_code,ac.name FROM t_income_expense tinc - join t_accountcode ac on ac.code=tinc.account_code - group by account_code"; + $fdate= date("Y-m-d",strtotime($fdate)); + $tdate=date("Y-m-d",strtotime($tdate)); + $sql="SELECT date_format(tinc.date,'%d-%m-%Y')as date, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.total + end,'0') as expense, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.total + end, '0') as income, + ifnull(case + when tinc.type = 'PAYMENT' + then tinc.towhom + end,'-') as paymentname, + ifnull(case + when tinc.type = 'RECEIPT' + then tinc.towhom + end, '-') as receiptname, + tinc.total,tinc.towhom,tinc.description,tinc.type,tinc.account_code,ac.name FROM t_income_expense tinc join t_accountcode ac on ac.code=tinc.account_code where tinc.date >= '".$fdate."' and tinc.date <= '".$tdate."'"; $query = $this->db->query($sql); + //echo $fdate; //print_r($this->db->last_query()); return $query->result();