| Server IP : 162.214.74.102 / Your IP : 216.73.217.80 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/public_html/lrsys_projetos/sopizzas/application/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Dashboardrestaurant extends MY_Restaurant {
function __construct()
{
parent::__construct();
$this->load->helper("url");
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('javascript');
$this->load->model('dashboard_model');
$this->load->model('restaurantmanagement_model');
$this->load->model('menumanagement_model');
$this->load->library('m_pdf');
$this->load->library('excel');
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_latitude = $session_data['latitude'];
$restaurant_longitude = $session_data['longitude'];
$this->data = array(
'RestaurantName' => $restaurant_name,
'restaurant_latitude' => $restaurant_latitude,
'restaurant_longitude' => $restaurant_longitude,
);
if($this->session->userdata('user_language'))
{
$language = $this->session->userdata('user_language');
}
else
{
$language = $this->config->item("language");
}
$data['user_language'] = $language;
$this->lang->load('restaurantAdmin', $language);
}
function index( $offset = 0 )
{
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
$data['title']="Restaurant Dashboard";
$data['page']="dashboardrestaurant";
//$data = $this->data;
$data['TotalOrderPrice']=$this->dashboard_model->DashboardPriceStatistics($restaurant_id,$fld='ordertotalprice',$table='rt_order',$status='');
$data['PendingOrderPrice']=$this->dashboard_model->DashboardPriceStatistics($restaurant_id,$fld='ordertotalprice',$table='rt_order',$status='In Preparation');
//$data['PendingOrderPrice']=$this->dashboard_model->DashboardPriceStatistics($restaurant_id,$fld='ordertotalprice',$table='rt_order',$status='Out for delivery');
$data['TotalEarning']=$this->dashboard_model->DashboardPriceStatistics($restaurant_id,$fld='ordertotalprice',$table='rt_order',$status='Delivered');
//echo $this->db->last_query(); exit();
$data['CommissionPrice'] =$this->dashboard_model->DashboardPriceStatistics($restaurant_id,$fld='commission',$table='rt_order',$status='Delivered');
$data['TotalEarning'] = number_format($data['TotalEarning'] - $data['CommissionPrice'], 2, '.', '');
$data['RestaurantDetails'] = $this->restaurantmanagement_model->GetRestauratDetails($restaurant_id);
$data['TotalOrder']=$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='');
//$data['TotalUsers']=$this->dashboard_model->get_total_customer($status='',$addeddate='');
//$data['TotalMerchant']=$this->dashboard_model->get_total_merchant();
$data['InPreparation'] =$this->dashboard_model->DashboardLastOrders_restaurant($status='In Preparation',$restaurant_id);
$data['OutforDelivery'] =$this->dashboard_model->DashboardLastOrders_restaurant($status='Out for delivery',$restaurant_id);
$data['Delivered'] =$this->dashboard_model->DashboardLastOrders_restaurant2($status='Delivered',$restaurant_id);
$this->load->view('restaurantadmin/header',$data);
$this->load->view('restaurantadmin/main-sidebar');
$this->load->view('restaurantadmin/dashboard');
$this->load->view('restaurantadmin/footer');
}
function live_feed()
{
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
//Order Statistics
$data99['TotalOrder']=$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='');
$data99['DashboardLastOrders'] =$this->dashboard_model->DashboardLastOrders();
// Order Statistics -- Today
$data99['OrdersToday'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='today',$restaurant_id);
$data99['SalesToday'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='today',$restaurant_id);
$data99['DeliveredOrderToday'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='today',$restaurant_id);
$data99['PendingOrderToday'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='today',$restaurant_id);
// Order Statistics -- Week
$data99['OrdersWeek'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='week',$restaurant_id);
$data99['SalesWeek'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='week',$restaurant_id);
$data99['SalesCommissionWeek'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='week',$restaurant_id,'commission');
$data99['SalesWeek'] = number_format($data99['SalesWeek'] - $data99['SalesCommissionWeek'], 2, '.', '');
$data99['DeliveredOrderWeek'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='week',$restaurant_id);
$data99['PendingOrderWeek'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='week',$restaurant_id);
// Order Statistics -- Month
$data99['OrdersMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='month',$restaurant_id);
$data99['SalesMonth'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='month',$restaurant_id);
$data99['SalesCommissionMonth'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='month',$restaurant_id,'commission');
$data99['SalesMonth'] = number_format($data99['SalesMonth'] - $data99['SalesCommissionMonth'], 2, '.', '');
$data99['DeliveredOrderMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='month',$restaurant_id);
$data99['PendingOrderMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='month',$restaurant_id);
// Order Statistics -- Year
$data99['OrdersYear'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='year',$restaurant_id);
$data99['SalesYear'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='year',$restaurant_id);
$data99['SalesCommissionYear'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='year',$restaurant_id,'commission');
$data99['SalesYear'] = number_format($data99['SalesYear'] - $data99['SalesCommissionYear'], 2, '.', '');
$data99['DeliveredOrderYear'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='year',$restaurant_id);
$data99['PendingOrderYear'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='year',$restaurant_id);
// echo $TotalOrder;
header('Content-Type: application/json');
echo json_encode($data99);
}
function upload_admin_image()
{
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
/*print_r($_FILES);
print_r($this->input->post());
exit();*/
$form_field_name = 'admin_image';
/*echo $form_field_name;
exit();*/
$rendid = date('Ymdhis');
$new_name = 'rest_admin_'.$rendid.'_logo.jpg';
$config1 = array(
'upload_path' => ADMIN_LOGO_PATH,
'allowed_types' => "gif|jpg|png|jpeg",
'overwrite' => TRUE,
'file_name' => $new_name
);
$this->load->library('upload', $config1);
$this->upload->initialize($config1);
if($this->upload->do_upload($form_field_name)) {
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config2['new_image'] = ADMIN_LOGO_PATH.'thumbs';
$config2['maintain_ratio'] = TRUE;
$config2['width'] = ADMIN_LOGO_WIDTH;
$config2['height'] = ADMIN_LOGO_HEIGHT;
$this->load->library('image_lib',$config2);
$this->image_lib->initialize($config2);
if ( !$this->image_lib->resize()) {
return false;
}
$result =$this->dashboard_model->GetRestaurantDetails($restaurant_id);
if(file_exists(ADMIN_LOGO_PATH.'thumbs/'.$result['admin_image']) && $result['admin_image'] != '' && $result['admin_image'] != ADMIN_DEFAULT_IMAGE)
{
if($result['admin_image'] != ADMIN_DEFAULT_IMAGE) {
//unlink(ADMIN_LOGO_PATH.'thumbs/'.$result['admin_image']);
}
}
//unlink(ADMIN_LOGO_PATH.$new_name);
$data = array('upload_data' => $this->upload->data());
$data_up= array(
'admin_image' => $new_name
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_up);
$this->db->trans_complete();
$logged_in = $this->session->userdata('logged_in_restaurant');
$logged_in['restaurant_admin_image'] = $new_name;
$this->session->set_userdata('logged_in_restaurant', $logged_in);
echo $new_name;
}
else {
$error = $this->upload->display_errors();
echo $error;
}
}
function changepassword()
{
if ($this->input->server('REQUEST_METHOD') == 'POST')
{
$this->load->library('form_validation');
$this->form_validation->set_rules('userPassword', 'Current Password', 'required|callback_checkPass');
$this->form_validation->set_rules('newpassword', 'New Password', 'required');
$this->form_validation->set_rules('newpassword', 'New password', 'trim|required|matches[confirmpassword]');
$this->form_validation->set_rules('confirmpassword', 'Confirm Password', 'required');
$this->session->unset_userdata($input_data);
if($this->form_validation->run() == FALSE)
{
$data['title']="Change Password";
$data['page']="password";
$this->load->view('restaurantadmin/header',$data);
$this->load->view('restaurantadmin/main-sidebar');
$this->load->view('restaurantadmin/change_password');
$this->load->view('restaurantadmin/footer');
}
else
{
$this->db->trans_start();
$password = $this->input->post('newpassword');
$data_up= array('restaurant_password' => md5($password));
$session_data = $this->session->userdata('logged_in_restaurant');
$id = $session_data['id'];
$this->db->where('restaurant_id',$id);
$this->db->update('rt_restaurant',$data_up);
$this->db->trans_complete();
$this->session->set_flashdata('success_msg', $this->lang->line('Passwordupdatedsuccessfully'));
redirect('restaurantadmin/changepassword');
}
//redirect(base_url('changePassword'));
}else
{
$data['title']="Change Password";
$data['page']="password";
$this->load->view('restaurantadmin/header',$data);
$this->load->view('restaurantadmin/main-sidebar');
$this->load->view('restaurantadmin/change_password');
$this->load->view('restaurantadmin/footer');
}
}
public function checkPass($str)
{
$userPassword = $this->input->post('userPassword');
$session_data = $this->session->userdata('logged_in_restaurant');
$userid = $session_data['id'];
$is_exist = $this->dashboard_model->IsRestaurantExist($userPassword,$userid);
if ($is_exist) {
return true;
}else{
$this->form_validation->set_message('checkPass', 'Please enter correct password.');
return false;
}
}
function order_export($restaurant_id=0, $action = '')
{
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
$order_list = $this->menumanagement_model->get_order_list($params = array(), $action, $action2 =0, $action3 ='',$restaurant_id);
$restaurant_name = "All orders";
if (empty($order_list)) {
//$restaurant_dtl = $this->coupon_model->get_restaurant_name($restaurant_id);
//$restaurant_name = $restaurant_dtl['restaurant_name'];
$this->session->set_flashdata('error_msg', $this->lang->line('Norecordfound!'));
redirect('restaurantadmin/restaurantreport');
}
else
{
//$this->excel->getActiveSheet()->setCellValue('A1', 'Restaurant: ');
//$this->excel->getActiveSheet()->setCellValue('B1', $restaurant_name);
$this->excel->getActiveSheet()->setCellValue('A1', 'Date:');
$this->excel->getActiveSheet()->setCellValue('B1', date('m/d/Y'));
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('order_export');
$this->excel->getActiveSheet()->setCellValue('A3', 'Order ID');
$this->excel->getActiveSheet()->setCellValue('B3', 'Restaurant');
$this->excel->getActiveSheet()->setCellValue('C3', 'Order Date');
/*$this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Date');*/
$this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Type');
$this->excel->getActiveSheet()->setCellValue('E3', 'Amount');
$this->excel->getActiveSheet()->setCellValue('F3', 'Payment Type');
$this->excel->getActiveSheet()->setCellValue('G3', 'Commission');
$this->excel->getActiveSheet()->setCellValue('H3', 'Customer Email');
$this->excel->getActiveSheet()->setCellValue('I3', 'Order Status');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($order_list as $key => $value)
{
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value['ordergenerateid']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, $value['restaurant_name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, date("m/d/Y g:i A", strtotime($value['orderdate'])));
/*$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, date('m/d/Y', strtotime($value['deliverydate'])));*/
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, $value['deliverytype']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(4, $data_row, $value['ordertotalprice']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(5, $data_row, $value['payment_type']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(6, $data_row, $value['commission']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(7, $data_row, $value['customeremail']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(8, $data_row, $value['status']);
$data_row++;
}
$filename='order_export.xls'; //save our workbook as this file name
header('Content-Type: application/vnd.ms-excel'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
}
function order_report_export($restaurant_id=0, $action = '')
{
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
$order_list = $this->menumanagement_model->get_order_list($params = array(), $action, $action2 =0, $action3 ='',$restaurant_id);
$restaurant_name = "All orders";
if (empty($order_list)) {
//$restaurant_dtl = $this->coupon_model->get_restaurant_name($restaurant_id);
//$restaurant_name = $restaurant_dtl['restaurant_name'];
$this->session->set_flashdata('error_msg', $this->lang->line('Norecordfound!'));
redirect('restaurantadmin/restaurantreport');
}
else
{
//$this->excel->getActiveSheet()->setCellValue('A1', 'Restaurant: ');
//$this->excel->getActiveSheet()->setCellValue('B1', $restaurant_name);
$this->excel->getActiveSheet()->setCellValue('A1', 'Date:');
$this->excel->getActiveSheet()->setCellValue('B1', date('m/d/Y'));
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('order_export');
$this->excel->getActiveSheet()->setCellValue('A3', 'Order ID');
$this->excel->getActiveSheet()->setCellValue('B3', 'Customer Name');
$this->excel->getActiveSheet()->setCellValue('C3', 'Customer Email');
$this->excel->getActiveSheet()->setCellValue('D3', 'Customer Phone');
$this->excel->getActiveSheet()->setCellValue('E3', 'Order Price');
$this->excel->getActiveSheet()->setCellValue('F3', 'Order Date');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($order_list as $key => $value)
{
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value['ordergenerateid']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, $value['customername'].' '.$value['customerlastname']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, $value['customeremail']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, $value['customercellphone']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(4, $data_row, $value['ordertotalprice']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(5, $data_row, date("m/d/Y g:i A", strtotime($value['orderdate'])));
$data_row++;
}
$filename='order_report_export.xls'; //save our workbook as this file name
header('Content-Type: application/vnd.ms-excel'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
}
}