diff --git a/application/controllers/cashbook.php b/application/controllers/cashbook.php index 04808b9d..3d256ffa 100755 --- a/application/controllers/cashbook.php +++ b/application/controllers/cashbook.php @@ -68,10 +68,40 @@ class cashbook extends BaseController } }else{ - $data['list'] = $this->cashbook_model->getIncomeExpenseList(); - $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing'; + // $data['list'] = $this->cashbook_model->getIncomeExpenseList(); + // $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing'; - $this->loadViews("income_expense_list", $this->global, $data , NULL); + // $this->loadViews("income_expense_list", $this->global, $data , NULL); + $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing'; + + if ($this->input->post('btn_submit')) { + + $fromdt = $this->input->post('from_date'); + $todt = $this->input->post('to_date'); + $ab=$this->input->post('financialyear'); + + $fromyear=substr($ab,0,-5); + $toyear=substr($ab,5,5); + + + $data['finyear']=$this->cashbook_model->finyear(); + $data['list'] = $this->cashbook_model->getIncomeExpense($fromyear,$toyear,$fromdt,$todt); + + } + else{ + + if (date('m') <= 3) { + $preyear = (date('Y')-1); + $currentyear = date('Y'); + } else { + $preyear = date('Y') ; + $currentyear = (date('Y') + 1); + } + + $data['list'] = $this->cashbook_model->getIncomeExpense($preyear,$currentyear); + $data['finyear']=$this->cashbook_model->finyear(); + } + $this->loadViews("income_expense_list", $this->global, $data , NULL); } @@ -115,10 +145,40 @@ class cashbook extends BaseController } }else{ - $data['list'] = $this->cashbook_model->getIncomeExpenseList(); - $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing'; + // $data['list'] = $this->cashbook_model->getIncomeExpenseList(); + // $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing'; - $this->loadViews("income_expense_list", $this->global, $data , NULL); + // $this->loadViews("income_expense_list", $this->global, $data , NULL); + $this->global['pageTitle'] = 'Siddharth : Cash Book: Listing'; + + if ($this->input->post('btn_submit')) { + + $fromdt = $this->input->post('from_date'); + $todt = $this->input->post('to_date'); + $ab=$this->input->post('financialyear'); + + $fromyear=substr($ab,0,-5); + $toyear=substr($ab,5,5); + + + $data['finyear']=$this->cashbook_model->finyear(); + $data['list'] = $this->cashbook_model->getIncomeExpense($fromyear,$toyear,$fromdt,$todt); + + } + else{ + + if (date('m') <= 3) { + $preyear = (date('Y')-1); + $currentyear = date('Y'); + } else { + $preyear = date('Y') ; + $currentyear = (date('Y') + 1); + } + + $data['list'] = $this->cashbook_model->getIncomeExpense($preyear,$currentyear); + $data['finyear']=$this->cashbook_model->finyear(); + } + $this->loadViews("income_expense_list", $this->global, $data , NULL); } diff --git a/application/controllers/inwardgateregister.php b/application/controllers/inwardgateregister.php index b22a9728..f0b68243 100644 --- a/application/controllers/inwardgateregister.php +++ b/application/controllers/inwardgateregister.php @@ -412,6 +412,38 @@ class inwardgateregister extends BaseController echo json_encode($data); } + + + function UpdateIGR() + { + + $IGRNo = $this->input->post('igr'); + + $DeliveryChellan = $this->input->post('invdate'); + $DeliveryChellanDate = $this->getDateformat($DeliveryChellan); + + $Mat_Rcvd_Dt = $this->input->post('mrc'); + $MaterialRcvdDt = $this->getDateformat($Mat_Rcvd_Dt); + + $updateby = $this->session->userdata('userId'); + + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updatedon = $dt->format('Y-m-d H:i:s'); + + + $igrarr = array('DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$MaterialRcvdDt,'UpdateBY'=>$updateby,'UpdatedOn'=>$updatedon); + + $data = $this->inwardgateregister_model->updateigr($igrarr,$IGRNo); + + if($data > 0){ + echo "Updated Succefully!"; + } + else{ + echo "Not Updated!"; + } + + } + function pageNotFound() { $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found'; diff --git a/application/models/cashbook_model.php b/application/models/cashbook_model.php index 14c1580e..08d7650b 100755 --- a/application/models/cashbook_model.php +++ b/application/models/cashbook_model.php @@ -55,7 +55,43 @@ class cashbook_model extends CI_Model $r = $this->db->get(); return $r->result(); } - + function getIncomeExpense($firstyear,$secondyear,$frmdt,$todt) + { + $this->db->select('t_accountcode.name,cashtype,T_Employee_Details.FirstName,T_Employee_Details.LastName,t_income_expense.*'); + $this->db->from('t_income_expense'); + $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code','left'); + $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId','left'); + $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID','left'); + + if ($firstyear and $secondyear != ''){ + $finyear = "t_income_expense.date >= '".$firstyear."-04-01' and t_income_expense.date <= '".$secondyear."-03-31'"; + $this->db->where($finyear); + } + if ($frmdt and $todt != ''){ + $fromdate= date("Y-m-d",strtotime($frmdt)); + $todate=date("Y-m-d",strtotime($todt)); + $date = "date(t_income_expense.date) >= '".$fromdate."' + and date(t_income_expense.date) <= '".$todate."'"; + $this->db->where($date); + } + $this->db->order_by("date","desc"); + $r = $this->db->get(); + return $r->result(); + } + +function 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(); + + } function getCompany() { $r = $this->db->get('T_Company_Details'); diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php index 24e86f74..616349f6 100755 --- a/application/models/inwardgateregister_model.php +++ b/application/models/inwardgateregister_model.php @@ -698,4 +698,13 @@ function getPOmaterial($PONO) return TRUE; } + function updateigr($igrarr,$IGRNo){ + + //$this->db->where('PONO',$PONO); + $this->db->where('IGRNO',$IGRNo); + $this->db->update('T_IGR_Master',$igrarr); + $r = $this->db->affected_rows(); + return $r; + } + } \ No newline at end of file diff --git a/application/views/income_expense_list.php b/application/views/income_expense_list.php index 5e3b20a2..e66c70b9 100755 --- a/application/views/income_expense_list.php +++ b/application/views/income_expense_list.php @@ -1,5 +1,30 @@ + + + +
@@ -16,8 +41,74 @@ Add New
- - + + +
+ +
+ +
+ + +
+ +
+ +
+ + + + +
+
+ + +
+ +
+ + + + +
+
+ +
+ + + + + + +
+ + +
+
+ + + +
+
+ +
+ +
+ +
+
@@ -78,23 +169,145 @@ - + + + + + + + + + + + + + + diff --git a/application/views/viewinwardgateregister.php b/application/views/viewinwardgateregister.php index 06e2021b..8ce86147 100755 --- a/application/views/viewinwardgateregister.php +++ b/application/views/viewinwardgateregister.php @@ -11,6 +11,24 @@ width: 800px ! important; } +

@@ -165,15 +183,14 @@
'DeliveryChallan/InvoiceDate','value' => set_value('DeliveryChallan/InvoiceDate'),'id'=>'Invoice_Date', 'class' => 'form-control', 'required=>"true"' , 'readonly'=>'true' ); - + $data = array('name' => 'DeliveryChallan/InvoiceDate','value' => set_value('DeliveryChallan/InvoiceDate'),'id'=>'Invoice_Date', 'class' => 'form-control', 'required=>"true"'); echo form_input($data); ?>
'MaterialRcvdDate','value' => set_value('MaterialRcvdDate'),'id'=>'MaterialRcvdDate', 'class' => 'form-control' , 'readonly'=>'true' ); + $data = array('name' => 'MaterialRcvdDate','value' => set_value('MaterialRcvdDate'),'id'=>'MaterialRcvdDate', 'class' => 'form-control'); echo form_input($data); ?>
@@ -198,6 +215,7 @@
@@ -289,5 +307,21 @@ $("#Igrshow").on("shown.bs.modal", function(e) { } }); }); +$('#update').click(function(){ + //alert('updated function entered'); + $('#content').loader('show'); + var igrno = $("#IGRNO1").val(); + var materialrcv_date = $("#MaterialRcvdDate").val(); + var inv_date = $("#Invoice_Date").val(); + $.ajax({ + data:{igr:igrno,mrc:materialrcv_date,invdate:inv_date}, + type:"POST", + url:"inwardgateregister/UpdateIGR", + success:function(data) { + $('#content').loader('hide'); + alert(data); + } + }); +}); \ No newline at end of file