Commit aa8d5669 by Jansa Jose

temp

parent 6efa2cf5
...@@ -3031,37 +3031,40 @@ print_r(date('H:i',$ms));exit();*/ ...@@ -3031,37 +3031,40 @@ print_r(date('H:i',$ms));exit();*/
$currentpage = (int)$_GET['page']; $currentpage = (int)$_GET['page'];
$currentpage = $currentpage==0 ? $currentpage : $currentpage-1; $currentpage = $currentpage==0 ? $currentpage : $currentpage-1;
$start = $currentpage * $per_page; $start = $currentpage * $per_page;
$page_no = $_GET['page'];
} }
else{ else{
$currentpage = 0; $currentpage = 0;
$start = 0; $start = 0;
$page_no = 0;
} }
$notificationResult = $this->Webservice_model->notification($auth_result->userid, 0, 0);
$result = $this->Webservice_model->notification($auth_result->userid,$start,$per_page); $result = $this->Webservice_model->notification($auth_result->userid,$start,$per_page);
$count = $this->Webservice_model->notification_list_unread_count($auth_result->userid); $count = $this->Webservice_model->notification_list_unread_count($auth_result->userid);
if($count){ if($count){
$total_count = $count->count; $unread_count = $count->count;
}else{ }else{
$total_count = 0; $unread_count = 0;
} }
$notiArray = array(); $notiArray = array();
if($result != false){
$total = count($result); if($notificationResult != false){
$total_count = count($notificationResult);
}else{ }else{
$total =0; $total_count = 0;
} }
if($total >= $per_page){ if($total >= $per_page){
$totalPages = (int)($total / $per_page); $totalPages = (int)($total_count % $per_page ==0
? $total_count / $per_page
:($total_count / $per_page)+1);
} }
else{ else{
$totalPages = 0; $totalPages = 1;
} }
if($result != false){ if($result != false){
foreach (array_slice($result,$start,$per_page) as $key => $value) { foreach ($result as $key => $value) {
array_push($notiArray, $value); array_push($notiArray, $value);
...@@ -3072,11 +3075,11 @@ print_r(date('H:i',$ms));exit();*/ ...@@ -3072,11 +3075,11 @@ print_r(date('H:i',$ms));exit();*/
$res = array('status' => 'success', $res = array('status' => 'success',
'data' => array( 'data' => array(
'unread_count'=>$total_count, 'unread_count'=>$unread_count,
'notification_list' => $notiArray 'notification_list' => $notiArray
), ),
'meta' => array('total_pages' => $totalPages, 'meta' => array('total_pages' => $totalPages,
'total' => $total, 'total' => $total_count,
'current_page' => $currentpage+1, 'current_page' => $currentpage+1,
'per_page' => $per_page) 'per_page' => $per_page)
); );
...@@ -3084,9 +3087,9 @@ print_r(date('H:i',$ms));exit();*/ ...@@ -3084,9 +3087,9 @@ print_r(date('H:i',$ms));exit();*/
}else{ }else{
$res = array( $res = array(
"status"=>"success", "status"=>"success",
"data"=>array('unread_count'=>$total_count,'notification_list'=>[]), "data"=>array('unread_count'=>$unread_count,'notification_list'=>[]),
'meta' => array('total_pages' => $totalPages, 'meta' => array('total_pages' => $totalPages,
'total' => $total, 'total' => $total_count,
'current_page' => $currentpage+1, 'current_page' => $currentpage+1,
'per_page' => $per_page) 'per_page' => $per_page)
); );
......
...@@ -1905,7 +1905,9 @@ class Webservice_model extends CI_Model { ...@@ -1905,7 +1905,9 @@ class Webservice_model extends CI_Model {
$this->db->join('tbl_booking','tbl_booking.id = tbl_patient_notification.booking_id'); $this->db->join('tbl_booking','tbl_booking.id = tbl_patient_notification.booking_id');
$this->db->join('tbl_doctors','tbl_doctors.id = tbl_booking.doctor_id'); $this->db->join('tbl_doctors','tbl_doctors.id = tbl_booking.doctor_id');
$this->db->join('tbl_specialization','tbl_specialization.id = tbl_doctors.specialization'); $this->db->join('tbl_specialization','tbl_specialization.id = tbl_doctors.specialization');
$this->db->limit($per_page,$start); if($start!=0 || $per_page!=0){
$this->db->limit($per_page,$start);
}
$this->db->order_by('tbl_patient_notification.id','DESC'); $this->db->order_by('tbl_patient_notification.id','DESC');
$query = $this->db->get_where('tbl_patient_notification',array('tbl_patient_notification.patient_id'=>$id))->result(); $query = $this->db->get_where('tbl_patient_notification',array('tbl_patient_notification.patient_id'=>$id))->result();
if(count($query) > 0){ if(count($query) > 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