Commit e5cf251e by Jansa Jose

J : wallet transaction history pagination

parent 57942c8c
...@@ -2239,16 +2239,28 @@ class Webservice_model extends CI_Model { ...@@ -2239,16 +2239,28 @@ class Webservice_model extends CI_Model {
$user_id = $this->auth_token_get($data['auth_token']); $user_id = $this->auth_token_get($data['auth_token']);
if($user_id > 0){ if($user_id > 0){
$countryData = $this->getCountryData($user_id); $countryData = $this->getCountryData($user_id);
$sql = "SELECT transaction_code AS transaction_number,amount,transaction_type,created_date,status FROM wallet_transactions WHERE customer_id='$user_id'"; $sql = "SELECT id FROM wallet_transactions WHERE customer_id='$user_id'";
$query = $this->db->query($sql); $count = $this->db->query($sql)->num_rows();
if(empty($query) || empty($walletHistory = $query->result_array())){ if($count > 0){
$res = array('status'=>'error','message'=>'No History Found','code'=>'ER13'); $perPage = 10;
return $res; $page = (isset($data['page']) && $data['page'] != 0)?$data['page']:1;
} $limit = ($page - 1) * $perPage;
foreach($walletHistory AS $walletKey => $walletValue){ $meta = array('total_pages'=>ceil($count/$perPage),'total_items'=>$count,
$walletHistory[$walletKey]['currency_symbol'] = $countryData['currency_symbol']; 'current_page'=>$page,'items_per_page'=>$perPage);
$sql = "SELECT transaction_code AS transaction_number,amount,transaction_type,created_date,status FROM wallet_transactions WHERE customer_id='$user_id' LIMIT $limit,$perPage";
$query = $this->db->query($sql);
if(empty($query) || empty($walletHistory = $query->result_array())){
$res = array('status'=>'error','message'=>'No History Found','code'=>'ER13');
return $res;
}
foreach($walletHistory AS $walletKey => $walletValue){
$walletHistory[$walletKey]['currency_symbol'] = $countryData['currency_symbol'];
}
$res = array('status'=>'success','data'=>array('wallet'=>$walletHistory,'meta'=>$meta));
} else{
$res = array('status'=>'error','message'=>'No Data found','code'=>'ER10');
} }
$res = array('status'=>'success','data'=>$walletHistory);
}else{ }else{
$res = array('status'=>'error','message'=>'User authentication Error','code'=>'ER10'); $res = array('status'=>'error','message'=>'User authentication Error','code'=>'ER10');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment