Commit 787233f1 by Jansa Jose

Notification Pagination Fix

parent 1a94108f
......@@ -5180,50 +5180,58 @@ print_r(date('H:i',$ms));exit();*/
$start = 0;
$page_no = 0;
}
$notificationResult = $this->Webservice_model->get_doctor_notification_list($authtoken->doctor_id, 0, 0);
$result = $this->Webservice_model->get_doctor_notification_list($authtoken->doctor_id,$start,$per_page);
$count = $this->Webservice_model->get_doctor_notification_list_unread_count($authtoken->doctor_id);
if($count){
$total_count = $count->count;
$unread_count = $count->count;
}else{
$unread_count = 0;
}
if($notificationResult != false){
$total_count = count($notificationResult);
}else{
$total_count = 0;
}
$notifArray = array();
if($result != false){
$total = count($result);
}else{
$total = 0;
}
if($total >= $per_page){
$totalPages = (int)($total / $per_page);
}
else{
$totalPages = 1;
}
//print_r($result);exit;
if($result != ''){
foreach (array_slice($result,$start,$per_page) as $key => $value) {
$value->read_status = $value->read_status!=0 ? true : false;
array_push($notifArray, $value);
}
$notifArray = array();
// if($result != false){
// $total = count($result);
// }else{
// $total = 0;
// }
if($total_count >= $per_page){
$totalPages = (int)($total_count / $per_page);
}
else{
$totalPages = 1;
}
//print_r($result);exit;
if($result != ''){
foreach (array_slice($result,$start,$per_page) as $key => $value) {
$value->read_status = $value->read_status!=0 ? true : false;
array_push($notifArray, $value);
}
}
if($result != false){
$res = array(
'status'=>'success',
'data'=>array('unread_count'=>$total_count,'notifications'=>$notifArray),
'data'=>array('unread_count'=>$unread_count,'notifications'=>$notifArray),
'meta' => array('total_pages' => $totalPages,
'total' => $total,
'total' => $total_count,
'current_page' =>$currentpage+1,
'per_page' => $per_page)
);
}else{
$res = array(
'status'=>'success',
'data'=>array('unread_count'=>$total_count,'notifications'=>[]),
'data'=>array('unread_count'=>$unread_count,'notifications'=>[]),
'meta' => array('total_pages' => $totalPages,
'total' => $total,
'total' => $total_count,
'current_page' =>$currentpage+1,
'per_page' => $per_page)
);
......
......@@ -3242,7 +3242,9 @@ class Webservice_model extends CI_Model {
//SELECT IIF(Obsolete = 'N' or InStock = 'Y', 1, 0) as Saleable, * FROM Product
$this->db->select("read_status,id,type,message");
$this->db->order_by('tbl_doctor_notifications.id','DESC');
$this->db->limit($per_page,$start);
if($start!=0 && $per_page!=0){
$this->db->limit($per_page,$start);
}
$result = $this->db->get_where('tbl_doctor_notifications',array('doctor_id'=>$doctorid))->result();
//echo $this->db->last_query();exit();
if(count($result) > 0){
......
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