db->where('status',1); $r = $this->db->get('t_accountcode'); return $r->result(); } /** * To Save Recepit and Payment datas * array $data - Recepit/Payment array datas * return $last_id - last inserted id */ function saveIncomeExpense($data) { $this->db->insert('t_income_expense',$data); //$r = $this->db->affected_rows(); //return $r; $last_id = $this->db->insert_id(); return $last_id; } function getIncomeExpenseList($i="") { $this->db->select('t_accountcode.code,t_accountcode.name,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'); $this->db->join('tbl_users','t_income_expense.Created_By=tbl_users.userId'); $this->db->join('T_Employee_Details','tbl_users.EmpID=T_Employee_Details.EmpID'); if(!empty($i)) { $this->db->where('t_income_expense.id',$i); } $r = $this->db->get(); return $r->result(); } // function getIncomeExpenseList($i="",$type) // { // $sql="SELECT `t_accountcode`.`name`, `T_Employee_Details`.`FirstName`, // `T_Employee_Details`.`LastName`, `t_income_expense`.* // FROM (`t_income_expense`) // JOIN `t_accountcode` ON `t_income_expense`.`account_code`=`t_accountcode`.`code` or `t_income_expense`.`account_code` = '999' // JOIN `tbl_users` ON `t_income_expense`.`Created_By`=`tbl_users`.`userId` // JOIN `T_Employee_Details` ON `tbl_users`.`EmpID`=`T_Employee_Details`.`EmpID` // WHERE `t_income_expense`.`id` = ".$i." // and t_income_expense.type = '".$type."' // group by t_income_expense.id"; // $query = $this->db->query($sql); // $result = $query->result(); // return $result; // } /** * To Get Recepit and Payment datas for list * string $aid - Recepit/Payment id * return $query->result() - Recepit/Payment datas based on id */ function getreceiptpaymentlist($aid = '') { $sql="SELECT `t_accountcode`.`name`, `T_Employee_Details`.`FirstName`,`T_Employee_Details`.`LastName`, `t_income_expense`.* FROM (`t_income_expense`) JOIN `t_accountcode` ON `t_income_expense`.`account_code`=`t_accountcode`.`code` or `t_income_expense`.`account_code` = '999' JOIN `tbl_users` ON `t_income_expense`.`Created_By`=`tbl_users`.`userId` JOIN `T_Employee_Details` ON `tbl_users`.`EmpID`=`T_Employee_Details`.`EmpID` group by t_income_expense.id"; $query = $this->db->query($sql); return $query->result(); } function getCompany() { $r = $this->db->get('T_Company_Details'); return $r->result(); } function getAccounutInfo($i) { $this->db->select('t_accountcode.name,t_income_expense.*'); $this->db->from('t_income_expense'); $this->db->join('t_accountcode','t_income_expense.account_code=t_accountcode.code'); //$this->db->where('t_income_expense.id') $r = $this->db->get(); return $r->result(); } function Selectcash() { $this->db->select('*'); $this->db->from('t_accountcode'); $query = $this->db->get(); $result = $query->result(); return $result; } function viewdepartment($sid='') { $sql="SELECT ie.*,ac.name,date_format(ie.date,'%d-%m-%Y')as date 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) { $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; $r = $this->db->affected_rows(); return $r; } function updatedepartment($updateaccount,$id1) { $this->db->where('id', $id1); $this->db->update('t_income_expense',$updateaccount); $r = $this->db->affected_rows(); return $r; } /** * To Update Payment Master datas * array $updateaccount - Payment Master datas * string $id1 - Payment's id * return $ar - it return how many rows will affected */ function updatepaymentmaster($updateaccount,$id1) { $this->db->where('id', $id1); $this->db->update('t_income_expense',$updateaccount); //$ar = $this->db->affected_rows(); //return $ar; $last_id = $this->db->insert_id(); return $last_id; } /** * To Get Payment Master for edit * string $sid - Payment id * return $query->result() - Payment datas based on id return as an array */ function viewpaymentmaster($sid='') { $sql="SELECT ie.*,ac.name,date_format(ie.date,'%d-%m-%Y')as date FROM T_Paymentdetails pd JOIN t_income_expense ie ON ie.id = pd.Payment_id JOIN t_accountcode ac ON ac.code = pd.account_code WHERE ie.id = ? group by pd.Payment_id"; $query = $this->db->query($sql,array($sid)); return $query->result(); } /** * To Get Payment lineitem Details for list (list dialog box) * string $paymentid - Payment id * return $result - Payment lineitem datas based on id return as an array */ function viewpaymentdetails($paymentid) { $sql="SELECT ac.name,pd.*,ie.* FROM T_Paymentdetails pd JOIN t_income_expense ie ON ie.id = pd.Payment_id JOIN t_accountcode ac ON ac.code = pd.account_code WHERE pd.Payment_id = ".$paymentid ; $query = $this->db->query($sql); $result = $query->result(); return $result; } /** * To Add and Update Payment Lineitem datas * array $PaymentDetails - Payment lineitem datas * return $i - To insert Payment datas based on id if new data means * return $u - To update Payment datas based on id if already have means */ function addpaymentdetails($addPaymentDetails){ $this->db->insert('T_Paymentdetails',$addPaymentDetails); $r = $this->db->affected_rows(); return $r; // $this->db->set($addPaymentDetails); // $this->db->insert($this->db->dbprefix . 'T_Paymentdetails'); } function updatepaymentdetails($UpdatePaymentsdetails,$hidekey){ $this->db->where('ID', $hidekey); $this->db->update('T_Paymentdetails',$UpdatePaymentsdetails); $ar = $this->db->affected_rows(); return $ar; } //function addupdatepaymentdetails($PaymentDetails,$hidekey=''){ // $paymentid = $PaymentDetails['Payment_id']; // //$key = $PaymentDetails['ID']; // $count=0; // $this->db->select('count(*) as count'); // $this->db->from('T_Paymentdetails'); // $this->db->where('Payment_id',$paymentid); // $this->db->where('ID',$hidekey); // $isExits = $this->db->get(); // $res = $isExits->result_array(); // if(!empty($res)) // { // $count = $res[0]['count']; // } // if($count == 0 )//for insert // { // $i = $this->db->insert('T_Paymentdetails',$PaymentDetails); // return $i; // } // elseif($count == 1)//for update // { // $this->db->where('Payment_id', $paymentid); // $this->db->where('ID', $hidekey); // $u = $this->db->update('T_Paymentdetails',$PaymentDetails); // return $u; // } // } /** * To Delete Payment Lineitem datas * string $acc - Payment's accountcode * string $id - Payment's id * return $ar - It returns how many rows will affetected */ function deletepaymentdetails($id){ $sql = "DELETE FROM T_Paymentdetails WHERE ID =".$id; $query = $this->db->query($sql); $ar = $this->db->affected_rows(); return $ar; } function Cashbook($cashbookdatas) { $code=$cashbookdatas['code']; $type=$cashbookdatas['type']; $count=0; $this->db->select('count(*) as count'); $this->db->from('t_accountcode'); $this->db->where('type',$type); $this->db->where('code',$code); $isExits = $this->db->get(); $res = $isExits->result_array(); if(!empty($res)) { $count = $res[0]['count']; } if($count == 0 )//for cashbook_insert { $cbi = $this->db->insert('t_accountcode', $cashbookdatas); return $cbi; } elseif($count == 1)//for cashbook_update { $this->db->where('code',$code); $cbu = $this->db->update('t_accountcode',$cashbookdatas); return $cbu; } } } ?>