+
diff --git a/application/config/routes.php b/application/config/routes.php index e7babaef..1e77053a 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -206,8 +206,10 @@ $route['ViewMRIR'] = "MRIRcontroller/viewmaterialinspectionreport"; $route['Viewigr'] = "MRIRcontroller/viewinwardgateregister"; $route['Distribution'] = "MRIRcontroller/viewmMaterialDistributionList"; $route['ViewIncomeExpense'] = "cashbook/incomeExpenseList"; +$route['EditIncomeExpense'] = "cashbook/editcashbook"; $route['addNewIncomeExpense'] = "cashbook/addNewIncomeExpenseLoad"; $route['addIncomeExpense'] = "cashbook/addIncomeExpense"; +$route['updateExpense'] = "cashbook/updateExpense"; $route['qualityreportlist'] = "quality/reportList"; $route['qualityreportlistinward'] = "quality/reportListInward"; //<-------------Store page-----------------> diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index a608d390..775001d0 100755 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -266,19 +266,99 @@ class cashbook extends BaseController } - public function editcashbook() + public function editcashbook($sid) { + + if($sid == '') + { + $cash = $_GET['sid']; + } + else + { + $cash = $sid; + } - + $this->load->model('cashbook_model'); - - // $data['cashbook'] = $this->cashbook_model->Selectcash(); - - // $this->global['pageTitle'] = 'Siddharth : Cashbook Listing'; - - $this->loadViews("editincomeexpenses", $this->global, NULL); + + $data['DepDetails'] = $this->cashbook_model->viewdepartment($cash); + //$data['deletefile'] = $this->cashbook-model->deletefile($cash); + $data['dropdownvalues'] = $this->cashbook_model->getAccounTypes(); + //print_r( $data['DepDetails']);die(); + $this->global['pageTitle'] = 'Siddharth : Edit Cashbook'; + $this->loadViews("editincomeexpenses", $this->global,$data, NULL); } + public function deletefile() + { + $cashfile = $this->input->post('id'); + $cashid = $this->input->post('ide'); + //echo 'dsmkjsn'; + //echo $cashid; + + //echo $cashfile; + //die(); + //$this->load->model('cashbook_model'); + $this->cashbook_model->deletefile($cashid); + + //print_r( $data['DepDetails']);die(); + //$this->global['pageTitle'] = 'Siddharth : Edit Cashbook'; + //$this->loadViews("income_expense_list", $this->global,$data, NULL); + + } + function updateExpense() + { + $id1=$this->input->post('id1'); + $myradio1= $this->input->post('myradio'); + $option=''; + if($myradio1==1) + { + $option=RECEIPT; + } + else + { + $option=PAYMENT; + } + //echo $option;die(); + $ans1 = $this->input->post('ans'); + $Date1 = $this->input->post('Date'); + $accountcode1 = $this->input->post('accode'); + //echo $accountcode1;die(); + $towhome1 = $this->input->post('towhome'); + $Invoiceno1 = $this->input->post('Invoiceno'); + $merchant1 = $this->input->post('merchant'); + $Merchantgst1 = $this->input->post('Merchantgst'); + $hsn1 = $this->input->post('hsn'); + $valuebeforegST1 = $this->input->post('valuebeforegST'); + $SGST1 = $this->input->post('SGST'); + $CGST1 = $this->input->post('CGST'); + $IGST1 = $this->input->post('IGST'); + $totalamount1 = $this->input->post('totalamount'); + $description1 = $this->input->post('description'); + //$document1=$this->input->post('myfile'); + $fs = 0; + if(!empty($_FILES['myfile']['name'])) + { + //echo "FILE AVAILABLE"; + $config['file_name'] = $_FILES['myfile']['name']; + $config['upload_path'] = 'uploads/cashbook/'; + $path = $config['upload_path']; + //$filename = $config['file_name']; + $document = $path.$filename; + //echo $document; + $fs = $this->uploadFile(); + $document = $path.$fs; + + } + $updateaccount = array('type'=>$option,'account_code'=>$accountcode1,'date'=>$Date1,'towhom'=>$towhome1,'invoice_no'=>$Invoiceno1,'merchant'=>$merchant1,'merchant_gst'=>$Merchantgst1,'HSN'=>$hsn1,'value_before_gst'=>$valuebeforegST1,'sgst'=>$SGST1,'cgst'=>$CGST1,'igst'=>$IGST1,'total'=>$totalamount1,'description'=>$description1,'document'=>$document); + //print_r($updateaccount);die(); + $res = $this->cashbook_model->updatedepartment($updateaccount,$id1); + + //if( $res == 1 ){ + echo ""; + //} + } + public function convertNumber($amt){ diff --git a/application/controllers/report.php b/application/controllers/report.php index 0651a3e1..2ad40135 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -1040,6 +1040,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(); @@ -1105,18 +1106,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(); @@ -1136,15 +1158,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/models/cashbook_model.php b/application/models/cashbook_model.php index 3ef6f47d..d33aaa17 100755 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -62,6 +62,38 @@ class cashbook_model extends CI_Model return $result; } + function viewdepartment($sid='') + { + $sql="SELECT ie.*,ac.name FROM t_income_expense ie + join t_accountcode ac on ac.code=ie.account_code + WHERE ie.id = ?"; + $query = $this->db->query($sql,array($sid)); + //print_r($this->db->last_query()); + //echo $sql; + return $query->result(); + } + function deletefile($cashid) + { + + //echo $cashid; + $sql="UPDATE t_income_expense SET document = NULL + WHERE id = ?"; + $query = $this->db->query($sql,array($cashid)); + //print_r($this->db->last_query()); + //echo $sql; + return $query->result(); + } + + + function updatedepartment($updateaccount,$id1) + { + $this->db->where('id', $id1); + $this->db->update('t_income_expense',$updateaccount); + $r = $this->db->affected_rows(); + return $r; + + } + function Cashbook($cashbookdatas) { diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 58f26060..5476cbc7 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -1935,15 +1935,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(); @@ -1973,11 +2007,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; @@ -1986,9 +2037,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(); @@ -2022,12 +2090,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() { @@ -2037,12 +2126,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(); diff --git a/application/views/cashbookall.php b/application/views/cashbookall.php new file mode 100644 index 00000000..3a87726f --- /dev/null +++ b/application/views/cashbookall.php @@ -0,0 +1,285 @@ + + +FontCode2000; + }} + + +?> + + + + + + + + + + + + + + +
Report (DEP:)
| Date | + +Account Name | +Type | +Received From | + +Receipt | + +Description | + + +
|---|---|---|---|---|---|
| date?> | + +name?> | +type?> | +receiptname?> | + +income,2,'.',''); + echo number_format($dw->income,2,'.','');?> | + + +description?> | + + + +
| Total | ++ | + | + + | + + + | + + ++ + + + + |
Month Report()
YEAR REPORTS(2017-2018)
| Month | - -Paid Type | + +Amount | - - +month?> | - -type?> | + +total,2,'.','');?> | - + @@ -87,12 +99,14 @@ if(!empty($Indiancurrency)) - - - - - - + + + + + + + + - - - - + + + + + + + + +Account Name | Amount | Details | - +Action | @@ -47,11 +49,11 @@name;?> | total;?> | description;?> | - + @@ -153,7 +130,7 @@ collection:{container:"DTTT_dropdown dropdown-menu",buttons:{normal:"",disabled:
|---|
| date?> | -name?> | -type?> | -receiptname?> | -paymentname?> | +date?> | +name?> | +type?> | +receiptname?> | +paymentname?> | income,2,'.',''); - echo number_format($cash->income,2,'.','');?> | + $ti= $ti + number_format($t->income,2,'.',''); + echo number_format($t->income,2,'.','');?>expense,2,'.',''); - echo number_format($cash->expense,2,'.','');?> | + $tvt= $tvt + number_format($t->expense,2,'.',''); + echo number_format($t->expense,2,'.','');?> -description?> | +description?> | @@ -333,14 +309,13 @@ collection:{container:"DTTT_dropdown dropdown-menu",buttons:{normal:"",disabled: - - - - - - - - + + + + + + +