| Server IP : 162.214.74.102 / Your IP : 216.73.217.103 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_projetos/sopizzas/application/models/ |
Upload File : |
<?php
Class dashboard_model extends CI_Model {
function isDriverAssigned($orderid) {
$this->db->select('driverid');
$this->db->from('rt_order');
$this->db->where('orderid', $orderid);
$query = $this->db->get();
if ($query->num_rows() > 0) {
$data = $query->row()->driverid;
return $data;
}
else {
return false;
}
}
function get_total_customer($status='',$addeddate='')
{
$today = date('Y-m-d');
$date = strtotime($today);
$startingSunday = strtotime('-' . date('w', $date) . ' days', $date);
$previousSaturday = strtotime('-1 day', $startingSunday);
$nextWeekSaturday = strtotime('+6 days', $startingSunday);
$startingSunday = date('Y-m-d',$startingSunday);
$nextSaturday = date('Y-m-d',$nextWeekSaturday);
$first_day_this_month = date('Y-m-01');
$last_day_this_month = date('Y-m-t');
$first_day_this_year = date('Y-01-01');
$last_day_this_year = date('Y-12-31');
$this -> db -> select('*');
$this -> db -> from('rt_customer');
if($status!=''){ $this -> db -> where('status',$status); }
if($addeddate=='week')
{
$this->db->where('date(addeddate) >=', $startingSunday);
$this->db->where('date(addeddate) <=', $nextSaturday);
}
if($addeddate=='month')
{
$this->db->where('date(addeddate) >=', $first_day_this_month);
$this->db->where('date(addeddate) <=', $last_day_this_month);
}
if($addeddate=='year')
{
$this->db->where('date(addeddate) >=', $first_day_this_year);
$this->db->where('date(addeddate) <=', $last_day_this_year);
}
$query = $this -> db -> get();
if ($query->num_rows() > 0)
{
return $query->num_rows();
}
return 0;
//return $query->num_rows();
}
function get_total_merchant($status='',$addeddate='')
{
$today = date('Y-m-d');
$date = strtotime($today);
$startingSunday = strtotime('-' . date('w', $date) . ' days', $date);
$previousSaturday = strtotime('-1 day', $startingSunday);
$nextWeekSaturday = strtotime('+6 days', $startingSunday);
$startingSunday = date('Y-m-d',$startingSunday);
$nextSaturday = date('Y-m-d',$nextWeekSaturday);
$first_day_this_month = date('Y-m-01');
$last_day_this_month = date('Y-m-t');
$first_day_this_year = date('Y-01-01');
$last_day_this_year = date('Y-12-31');
$deactive = '0';
$this -> db -> select('*');
$this -> db -> from('rt_restaurant');
if($status!=''){ $this -> db -> where('restaurant_status',$status); }
if($addeddate=='week')
{
$this->db->where('date(addeddate) >=', $startingSunday);
$this->db->where('date(addeddate) <=', $nextSaturday);
}
if($addeddate=='month')
{
$this->db->where('date(addeddate) >=', $first_day_this_month);
$this->db->where('date(addeddate) <=', $last_day_this_month);
}
if($addeddate=='year')
{
$this->db->where('date(addeddate) >=', $first_day_this_year);
$this->db->where('date(addeddate) <=', $last_day_this_year);
}
$this -> db -> where('restaurant_validate','1');
$query = $this -> db -> get();
return $query->num_rows();
}
#Dashboard List
function DashboardLastOrders()
{
$status = 'Delivered';
$data_table='';
$this->db->select('ord.ordergenerateid, ord.restaurant_id, ord.deliverystreet, ord.customername, ord.ordertotalprice, ord.orderdate, ord.status,res.restaurant_name,res.restaurant_streetaddress');
$this->db->from('rt_order ord');
$this->db->join('rt_restaurant res','res.restaurant_id = ord.restaurant_id');
//$this->db->where('ord.status = ' . "'" . $status . "'".' ORDER BY ord.orderid DESC LIMIT 10');
$this->db->order_by('ord.orderid', 'DESC');
$this->db->limit('10');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$queryData = $query->result();
foreach($queryData as $key=>$row)
{
$addeddate = $row->orderdate;
$addeddate = strtotime($addeddate);
$addeddate = date("D j, Y h:i A",$addeddate);
$data_table .='<tr>
<td class="paddingtop13 text-center">'.$row->restaurant_id.'</td>
<td class="paddingtop13 text-center">'.$row->restaurant_name.'</td>
<td class="paddingtop13 text-center">'.$row->deliverystreet.'</td>
<td class="paddingtop13 text-center">'.$row->ordergenerateid.'</td>
<td class="paddingtop13 text-center">$'.$row->ordertotalprice.'</td>
<td class="paddingtop13 text-center">'.$addeddate.'</td>
</tr>';
}
return $data_table;
}else{
$data_table .='<tr >
<td colspan="6" class="paddingtop13 text-center">No Order found!</td>
</tr>';
return $data_table;
}
}
function DashboardtopDiscountRestaurants()
{
$today = date("Y-m-d");
$data_table='';
$status = 1;
$this->db->select('res.restaurant_name,off.offer_id, off.restaurant_id, off.offer_percentage, off.offer_price, off.offer_valid_from, off.offer_valid_to, off.addeddate, off.status');
$this->db->from('rt_restaurant_offer off');
$this->db->join('rt_restaurant res','res.restaurant_id = off.restaurant_id');
//$this->db->where('off.offer_valid_from <=', $today);
//$this->db->where('off.offer_valid_from >=', $today);
$this->db->where('off.status',$status);
$this->db->group_by('off.restaurant_id');
$this->db->order_by('off.offer_percentage', 'desc LIMIT 10');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$queryData = $query->result();
foreach($queryData as $key=>$row)
{
$addeddate = $row->addeddate;
$addeddate = strtotime($addeddate);
$addeddate = date("D j, Y h:i A",$addeddate);
$data_table .='<tr>
<td class="paddingtop13 text-center">'.$row->restaurant_id.'</td>
<td class="paddingtop13 text-center">'.$row->restaurant_name.'</td>
<td class="paddingtop13 text-center">'.$row->offer_percentage.'</td>
<td class="paddingtop13 text-center">'.$row->offer_price.'</td>
<td class="paddingtop13 text-center">'.$row->offer_valid_from.'</td>
<td class="paddingtop13 text-center">'.$row->offer_valid_to.'</td>
<td class="paddingtop13 text-center">'.$addeddate.'</td>
</tr>';
}
return $data_table;
}else{
$data_table .='<tr >
<td colspan="7" class="paddingtop13 text-center">No Record found!</td>
</tr>';
return $data_table;
}
}
function DashboardOrderStatistics($status = '', $addeddate = '', $restaurant_id = 0, $caller = '')
{
if($this->session->userdata('logged_in_restaurant')){
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
}else{
$restaurant_id = 0;
}
$today = date('Y-m-d');
$date = strtotime($today);
$startingSunday = strtotime('-' . date('w', $date) . ' days', $date);
$previousSaturday = strtotime('-1 day', $startingSunday);
$nextWeekSaturday = strtotime('+6 days', $startingSunday);
$startingSunday = date('Y-m-d',$startingSunday);
$nextSaturday = date('Y-m-d',$nextWeekSaturday);
$first_day_this_month = date('Y-m-01');
$last_day_this_month = date('Y-m-t');
$first_day_this_year = date('Y-01-01');
$last_day_this_year = date('Y-12-31');
$first_day_prev_year = date('Y-01-01', strtotime('-1 year'));
$last_day_prev_year = date('Y-12-31', strtotime('-1 year'));
$last_day_prev_month = date("Y-m-d", mktime(0, 0, 0, date("m"), 0));
$first_day_prev_month = date("Y-m-d", mktime(0, 0, 0, date("m")-1, 1));
$this->db->select('*');
$this->db->from('rt_order');
//if($status!='') { $this->db->where('status',$status); }
if($status!='') {
$this->db->where('status',$status);
}
else if ($status != '' && $caller != 'report') {
$this->db->where('status !=', 'In Preparation');
$this->db->where('status !=', 'Refund Requested');
$this->db->where('status !=', 'Refund Accepted');
}
if($restaurant_id>0) { $this->db->where('restaurant_id',$restaurant_id); }
if($addeddate=='today')
{
$this->db->where('DATE(orderdate)', $today);
}
if($addeddate=='week')
{
$this->db->where('date(orderdate) >=', $startingSunday);
$this->db->where('date(orderdate) <=', $nextSaturday);
}
if($addeddate=='month')
{
$this->db->where('date(orderdate) >=', $first_day_this_month);
$this->db->where('date(orderdate) <=', $last_day_this_month);
}
if($addeddate=='last_month')
{
$this->db->where('date(orderdate) >=', $first_day_prev_month);
$this->db->where('date(orderdate) <=', $last_day_prev_month);
}
if($addeddate=='year')
{
$this->db->where('date(orderdate) >=', $first_day_this_year);
$this->db->where('date(orderdate) <=', $last_day_this_year);
}
if($addeddate=='last_year')
{
$this->db->where('date(orderdate) >=', $first_day_prev_year);
$this->db->where('date(orderdate) <=', $last_day_prev_year);
}
$query = $this -> db -> get();
//echo $this->db->last_query();
return $query->num_rows();
}
function DashboardSalesStatistics($status='',$addeddate='',$restaurant_id=0, $field = '')
{
$today = date('Y-m-d');
$date = strtotime($today);
$startingSunday = strtotime('-' . date('w', $date) . ' days', $date);
$previousSaturday = strtotime('-1 day', $startingSunday);
$nextWeekSaturday = strtotime('+6 days', $startingSunday);
$startingSunday = date('Y-m-d',$startingSunday);
$nextSaturday = date('Y-m-d',$nextWeekSaturday);
$first_day_this_month = date('Y-m-01');
$last_day_this_month = date('Y-m-t');
$first_day_this_year = date('Y-01-01');
$last_day_this_year = date('Y-12-31');
if ($field != '') {
$this->db->select_sum($field);
}
else {
$this->db->select_sum('ordertotalprice');
}
$this->db->from('rt_order');
if($status!='') { $this->db->where('status',$status); }
if($restaurant_id>0) { $this->db->where('restaurant_id',$restaurant_id); }
if($addeddate=='today')
{
$this->db->where('date(orderdate)', $today);
}
if($addeddate=='week')
{
$this->db->where('date(orderdate) >=', $startingSunday);
$this->db->where('date(orderdate) <=', $nextSaturday);
}
if($addeddate=='month')
{
$this->db->where('date(orderdate) >=', $first_day_this_month);
$this->db->where('date(orderdate) <=', $last_day_this_month);
}
if($addeddate=='year')
{
$this->db->where('date(orderdate) >=', $first_day_this_year);
$this->db->where('date(orderdate) <=', $last_day_this_year);
}
$query = $this->db->get();
if ($query->row()->ordertotalprice > 0)
{
//return $query->row()->ordertotalprice;
return number_format($query->row()->ordertotalprice, 2, '.', '');
}
else if ($query->row()->commission > 0) {
return number_format($query->row()->commission, 2, '.', '');
}
return 0;
}
function get_website_settings()
{
$this->db->select('*');
$this->db->from('rt_sitesetting');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->row_array();
}
return false;
}
function StateList()
{
$is_active = 1;
$this->db->select('*');
$this->db->from('rt_state');
$this->db->where('state_status = ' . "'" . $is_active . "'".' order by statename ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return false;
}
function CityList()
{
$is_active = 1;
$this->db->select('*');
$this->db->from('rt_city');
$this->db->where('city_status = ' . "'" . $is_active . "'".' order by cityname ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return false;
}
function GetCityByState($state_id = '')
{
$is_active = 1;
$this->db->select('*');
$this->db->from('rt_city');
if ($state_id != '') {
$this->db->where('statecode',$state_id);
}
$this->db->where('city_status = ' . "'" . $is_active . "'".' order by cityname ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return false;
}
function CuisineList()
{
$is_active = 1;
$this->db->select('*');
$this->db->from('rt_cuisine');
$this->db->where('cuisine_status = ' . "'" . $is_active . "'".' order by cuisine_name ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return false;
}
function TimezonList()
{
$is_active = 1;
$this->db->select('*');
$this->db->from('sa_timezones');
$this->db->order_by('id','ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return false;
}
function DelliveryTimeList($restaurant_id=0)
{
$is_active = 1;
$this->db->select('*');
$this->db->from('rt_delivery_zone');
$this->db->where('restaurant_id',$restaurant_id);
$this->db->order_by('id','ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
return false;
}
function get_setting_payment()
{
$this->db->select('*');
$this->db->from('rt_setting_payment');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->row_array();
}
return false;
}
function ZipcodeList()
{
$is_active = 1;
$this->db->select('*');
$this->db->from('rt_zipcode');
$this->db->where('zipcode_status = ' . "'" . $is_active . "'".' order by zipcode_id ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return false;
}
function RestaurantList()
{
$is_active = 1;
$this->db->select('*');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_status = ' . "'" . $is_active . "'".' order by restaurant_name ASC');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return false;
}
function IsUserExist($password, $userid)
{
$this->db->select('admin_id');
$this->db->from('rt_admin');
$this->db->where('password',$password);
$this->db->where('admin_id',$userid);
$this->db->limit(1);
$query = $this -> db -> get();
if($query -> num_rows() == 1)
{
return true;
}
else
{
return false;
}
}
function IsRestaurantExist($password, $userid)
{
$this->db->select('restaurant_id');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_password',md5($password));
$this->db->where('restaurant_id',$userid);
$this->db->limit(1);
$query = $this -> db -> get();
if($query -> num_rows() == 1)
{
return true;
}
else
{
return false;
}
}
function GetAdminDetails() {
$this->db->select('*');
$this->db->from('rt_admin');
$this->db->limit(1);
$query = $this->db->get();
if ($query) {
return $query->row_array();
}
else {
return false;
}
}
function GetRestaurantDetails($restaurant_id) {
$this->db->select('*');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id',$restaurant_id);
$this->db->limit(1);
$query = $this->db->get();
if ($query) {
return $query->row_array();
}
else {
return false;
}
}
function DashboardPriceStatistics($restaurant_id,$Fld,$table,$status)
{
$this->db->select_sum($Fld);
$this->db->from($table);
$this->db->where('restaurant_id',$restaurant_id);
if($status!='') {
$this->db->where('status',$status);
}
else {
$this->db->where('status !=', 'In Preparation');
$this->db->where('status !=', 'Refund Requested');
$this->db->where('status !=', 'Refund Accepted');
}
$query = $this->db->get();
$tot = $query->row()->$Fld;
if($tot>0)
{
//return $query->row()->$Fld;
return number_format($query->row()->$Fld, 2, '.', '');
}else{
return 0;
}
}
#Dashboard List
function DashboardLastOrdersRestaurant($restaurant_id=0)
{
$status = 'Delivered';
$data_table='';
$this->db->select('ord.ordergenerateid, ord.restaurant_id, ord.customername, ord.ordertotalprice, ord.orderdate, ord.status,res.restaurant_name,res.restaurant_streetaddress');
$this->db->from('rt_order ord');
$this->db->join('rt_restaurant res','res.restaurant_id = ord.restaurant_id');
$this->db->where('ord.status = ' . "'" . $status . "'".' ORDER BY ord.orderid DESC LIMIT 10');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$queryData = $query->result();
foreach($queryData as $key=>$row)
{
$addeddate = $row->orderdate;
$addeddate = strtotime($addeddate);
$addeddate = date("D j, Y h:i A",$addeddate);
$data_table .='<tr>
<td class="paddingtop13 text-center">'.$row->restaurant_id.'</td>
<td class="paddingtop13 text-center">'.$row->restaurant_name.'</td>
<td class="paddingtop13 text-center">'.$row->restaurant_streetaddress.'</td>
<td class="paddingtop13 text-center">'.$row->ordergenerateid.'</td>
<td class="paddingtop13 text-center">$'.$row->ordertotalprice.'</td>
<td class="paddingtop13 text-center">'.$addeddate.'</td>
</tr>';
}
return $data_table;
}else{
$data_table .='<tr >
<td colspan="6" class="paddingtop13 text-center">No Order found!</td>
</tr>';
return $data_table;
}
}
function GetOffers($restaurant_id='')
{
$status = '1';
$today_date = date('Y-m-d');
$this -> db -> select('*');
$this -> db -> from('rt_restaurant_offer');
$this -> db -> where('status',$status);
$this -> db -> where('restaurant_id',$restaurant_id);
$this->db->where('offer_valid_to >= ' . "'" . $today_date . "'".' order by offer_valid_to ASC');
$query = $this -> db -> get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
return false;
}
function DashboardLastOrders_restaurant($status,$restaurant_id)
{
//$status = 'Delivered';
$data_table='';
// if ($status == 'In Preparation') {
// $statusClass = 'pending-blink';
// }
// else {
// $statusClass = '';
// }
$this->db->select('ord.driverid,ord.isdriver_assign,ord.orderid,ord.ordergenerateid, ord.restaurant_id, ord.customername,ord.customerlastname, ord.ordertotalprice, ord.orderdate, ord.status,res.restaurant_name,res.restaurant_streetaddress, ord.deliverytype');
$this->db->from('rt_order ord');
$this->db->join('rt_restaurant res','res.restaurant_id = ord.restaurant_id');
// Orders are accepted by drivers
//$this->db->where('ord.driverid !=', 0);
$this->db->where('ord.restaurant_id',$restaurant_id);
$this->db->where('ord.status = ' . "'" . $status . "'".' ORDER BY ord.orderid DESC LIMIT 5');
$query = $this->db->get();
//echo $this->db->last_query().'||||';
if ($query->num_rows() > 0)
{
$queryData = $query->result();
//print_r($queryData);
foreach($queryData as $key=>$row)
{
if ($row->driverid == 0) {
$statusClass = 'pending-blink';
}
else {
$statusClass = '';
}
if($row->driverid==0 && $row->deliverytype == "Delivery")
{
$driverassign = '<td class="text-center"><button onclick="view_order_details('.$row->orderid.',event);" type="button" class="btn btn-default padding3 assign-driver"><i class="fa fa-car" aria-hidden="true"></i> Assign Driver</button></td>';
}else{
$driverassign = '<td class="text-center"><button onclick="view_order_details('.$row->orderid.',event);" type="button" class="btn btn-default padding3 view" data-toggle="modal" data-target="#myModal"><i class="fa fa-search" aria-hidden="true"></i> '.$this->lang->line('View').'</button></td>';
}
$driverassign = '<td class="text-center"><button onclick="view_order_details('.$row->orderid.',event);" type="button" class="btn btn-default padding3 view" data-toggle="modal" data-target="#myModal"><i class="fa fa-search" aria-hidden="true"></i> '.$this->lang->line('View').'</button></td>';
$addeddate = $row->orderdate;
$addeddate = strtotime($addeddate);
$addeddate = date("F j, Y h:i A",$addeddate);
$data_table .='<tr class="'.$statusClass.'" id="orderRow_'.$row->orderid.'">
<td class="paddingtop13">'.$row->ordergenerateid.'</td>
<td class="paddingtop13">'.$addeddate.'</td>
<td class="text-center paddingtop13">'.$row->customername.' '.$row->customerlastname.'</td>
<td class="paddingtop13">'.SITENAME_CURRENCY.$row->ordertotalprice.'</td>
'.$driverassign.'
</tr>';
}
return $data_table;
}else{
$data_table .='<tr >
<td colspan="6" class="paddingtop13 text-center">No Order found!</td>
</tr>';
return $data_table;
}
}
function DashboardLastOrders_restaurant2($status,$restaurant_id)
{
//$status = 'Delivered';
$data_table='';
$this->db->select('ord.orderid,ord.drivername,ord.delivery_completed_date,ord.ordergenerateid, ord.restaurant_id, ord.customername, ord.ordertotalprice, ord.orderdate, ord.status,res.restaurant_name,res.restaurant_streetaddress');
$this->db->from('rt_order ord');
$this->db->join('rt_restaurant res','res.restaurant_id = ord.restaurant_id');
$this->db->where('ord.restaurant_id',$restaurant_id);
$this->db->where('ord.status = ' . "'" . $status . "'".' ORDER BY ord.orderid DESC LIMIT 5');
$query = $this->db->get();
if ($query->num_rows() > 0)
{
$queryData = $query->result();
foreach($queryData as $key=>$row)
{
$addeddate = $row->orderdate;
$addeddate = strtotime($addeddate);
$addeddate = date("F j, Y h:i A",$addeddate);
$completed_date = $row->delivery_completed_date;
$completed_date = strtotime($completed_date);
$completed_date = date("F j, Y h:i A",$completed_date);
$data_table .='<tr>
<td class="paddingtop13">'.$row->ordergenerateid.'</td>
<td class="paddingtop13">'.$addeddate.'</td>
<td class="paddingtop13">'.$completed_date.'</td>
<td class="text-center paddingtop13">'.$row->drivername.'</td>
<td class="paddingtop13">'.SITENAME_CURRENCY.$row->ordertotalprice.'</td>
<td class="text-center"><button onclick="view_order_details('.$row->orderid.',event);" type="button" class="btn btn-default padding3 view" data-toggle="modal" data-target="#myModal"><i class="fa fa-search" aria-hidden="true"></i> '.$this->lang->line('View').'</button></td>
</tr>';
}
return $data_table;
}else{
$data_table .='<tr >
<td colspan="6" class="paddingtop13 text-center">No Order found!</td>
</tr>';
return $data_table;
}
}
function get_driver_earning($invoice_id)
{
$this->db->select('*');
$this->db->from('driver_invoice');
$this->db->where('id_code',$invoice_id);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->row_array();
}
return false;
}
function get_restaurant_invoice($invoice_id)
{
$this->db->select('*');
$this->db->from('restaurant_invoice');
$this->db->where('id_code',$invoice_id);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->row_array();
}
return false;
}
function e_Wallet()
{
// $status = 'success';
// $this->db->select_sum('ordertotalprice');
// $this -> db -> from('rt_order');
// $this -> db -> where('paypal_status', $status);
// $query = $this->db->get();
// $ordertotalprice = $query->row()->ordertotalprice;
$status = 'success';
$this->db->select_sum('ordertotalprice');
$this->db->from('rt_order');
$this->db->where('paypal_status', $status);
$query = $this->db->get();
$ordertotalprice = $query->row()->ordertotalprice;
$grandTotal = $ordertotalprice;
$status = 'success';
$this->db->select_sum('menuprice_total');
$this->db->from('rt_order');
$this->db->where('paypal_status', $status);
$query = $this->db->get();
$itemTotal = $query->row()->menuprice_total;
$status = 'success';
$this->db->select_sum('taxvalue');
$this->db->from('rt_order');
$this->db->where('paypal_status', $status);
$query = $this->db->get();
$taxAmount = $query->row()->taxvalue;
$status = 'success';
$this->db->select_sum('offervalue');
$this->db->from('rt_order');
$this->db->where('paypal_status', $status);
$query = $this->db->get();
$offervalue = $query->row()->offervalue;
$status = 'success';
$this->db->select_sum('commission');
$this->db->from('rt_order');
$this->db->where('paypal_status', $status);
$query = $this->db->get();
$commission = $query->row()->commission;
// $status = 1;
// $this->db->select_sum('order_amount');
// $this -> db -> from('restaurant_invoice');
// $this -> db -> where('status', $status);
// $query = $this->db->get();
// $order_amount = $query->row()->order_amount;
$status = 1;
$this->db->select_sum('amount');
$this -> db -> from('driver_invoice');
$this -> db -> where('status', $status);
$query = $this->db->get();
$driver_amount = $query->row()->amount;
$status = 1;
$this->db->select_sum('driver_tip');
$this -> db -> from('driver_invoice');
$this -> db -> where('status', $status);
$query = $this->db->get();
$driver_tip = $query->row()->driver_tip;
// $this->db->select('*');
// $this->db->from('rt_setting_payment');
// $this->db->limit('1');
// $paypalQuery = $this->db->get();
// if ($paypalQuery->num_rows() > 0) {
// $paypalData = $paypalQuery->row();
// $paypalAmt = $ordertotalprice * ($paypalData->paypal_fee / 100);
// $ordertotalprice = $ordertotalprice - $paypalAmt - $paypalData->paypal_fee_fix;
// }
// $eWallet = $ordertotalprice - ($order_amount + $driver_amount + $driver_tip);
$RestaurantShare = number_format($itemTotal + $taxAmount - $offervalue - $commission, 2, '.', '');
$WebsiteShare = number_format($grandTotal - $RestaurantShare, 2, '.', '');
$eWallet = $WebsiteShare - $driver_amount - $driver_tip;
return number_format($eWallet, 2, '.', '');
}
function get_total_commission()
{
$status = 'success';
$this->db->select_sum('commission');
$this -> db -> from('rt_order');
$this -> db -> where('paypal_status', $status);
$query = $this->db->get();
$commission = $query->row()->commission;
$status = 'success';
$this->db->select_sum('delivery_charged');
$this -> db -> from('rt_order');
$this -> db -> where('paypal_status', $status);
$query = $this->db->get();
$delivery_charged = $query->row()->delivery_charged;
$status = 'success';
$this->db->select_sum('tip');
$this -> db -> from('rt_order');
$this -> db -> where('paypal_status', $status);
$query = $this->db->get();
$tip = $query->row()->tip;
$status = 'success';
$this->db->select_sum('taxvalue');
$this -> db -> from('rt_order');
$this -> db -> where('paypal_status', $status);
$query = $this->db->get();
$taxvalue = $query->row()->taxvalue;
// $TotalComm = $commission + $delivery_charged + $tip + $taxvalue;
$TotalComm = $commission + $delivery_charged + $tip;
if($TotalComm>0)
{
return number_format($TotalComm,2);
}else{
return '0.00';
}
}
function get_driver_list()
{
$schedule_date = date('Y-m-d');
$driver_availability_status = '1';
$current_time = date("h:i:s");
$this->db->select('*');
//$this->db->from('rt_driver_available_schedule');
$this->db->from('rt_driver');
//$this->db->join('rt_driver','rt_driver.driver_id = rt_driver_available_schedule.driver_id');
$this->db->where('driver_availability_status', $driver_availability_status);
//$this->db->where('schedule_date', $schedule_date);
//$this->db->where('schedule_time_from <= ' . "'" . $current_time . "'");
//$this->db->where('schedule_time_to >= ' . "'" . $current_time . "'");
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result_array();
}
return false;
}
function check_driver($driver_id, $order_id = '') {
$this->db->select('restaurant_id');
$this->db->from('rt_order');
$this->db->where('orderid', $order_id);
$this->db->limit(1);
$q = $this->db->get();
$data = $q->result_array();
$this->db->select('restaurant_delivery_by');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $data[0]["restaurant_id"]);
$this->db->limit(1);
$q = $this->db->get();
$data_res = $q->result_array();
$delivery_status = 3;
$this->db->select('*');
$this->db->from('rt_order');
$this->db->where('driverid',$driver_id);
if($data_res[0]["restaurant_delivery_by"] == "1") {
$this->db->where('restaurant_id', $data[0]["restaurant_id"]);
}
$this->db->where('delivery_status != ' . "'" . $delivery_status . "'");
//$this -> db ->where('counter_no = ' . "'" . $counter_no . "'");
$this->db->limit(1);
$query1 = $this->db->get();
$this->db->select('*');
$this->db->from('rt_notification_decline');
$this->db->where('driver_id', $driver_id);
$this->db->where('order_id', $order_id);
$this->db->limit(1);
$query2 = $this->db->get();
if($query1->num_rows() == 1 || $query2->num_rows() == 1) {
return true;
}
else {
return false;
}
}
function driver_location($driver_id)
{
$this -> db -> select('*');
$this -> db -> from('rt_driver');
$this -> db -> where('driver_id',$driver_id);
//$this -> db -> where('counter_no = ' . "'" . $counter_no . "'");
$this -> db -> limit(1);
$query = $this -> db -> get();
if($query -> num_rows() == 1)
{
return $query->row_array();
}
else
{
return false;
}
}
}