| 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 Dashboardcustomer extends MY_Customer {
function __construct()
{
parent::__construct();
$this->load->helper("url");
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('javascript');
$this->perPage = ROW_PER_PAGE;
$this->load->model('dashboard_model');
$this->load->model('customersmanagement_model');
$this->load->model('menumanagement_model');
$this->load->model('restaurantmanagement_model');
$this->load->model('frontend_model');
$this->load->model('createorder_model');
$this->load->library('m_pdf');
$this->load->library('javascript');
$this->load->library('Ajax_pagination');
$this->load->library('cart');
$this->load->library('myemail');
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('frontpage', $language);
}
function index( $offset = 0 )
{
$session_data = $this->session->userdata('logged_in_customer');
$customer_id = $session_data['id'];
$data['title']="Customer Dashboard";
$data['page']="dashboardcustomer";
$SearchBy = '';
$PerPage = $this->input->post('Per_Page');
if(!$PerPage){
$PerPage = $this->perPage;
}else{
$PerPage = $PerPage;
}
//total rows count
$totalRec = count($this->customersmanagement_model->get_order_list());
$config['target'] = '#postList';
$config['base_url'] = base_url().'dashboardcustomer/ajaxPaginationDataOrder/'.$SearchBy;
$config['total_rows'] = $totalRec;
$config['per_page'] = $PerPage;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['OrderList'] = $this->customersmanagement_model->get_order_list(array('limit'=>$PerPage), $SearchBy);
// echo "<pre>";
// print_r($data['OrderList']);
// echo "</pre>";
// exit();
//echo "ok".$customer_id;
//exit();
$data['CustomerDetails'] = $this->customersmanagement_model->GetCustomerDetails($customer_id);
$data['pointDetails'] = $this->frontend_model->getRewardPoints($customer_id);
$data['rewardAvailability'] = $this->frontend_model->checkRewardPointStatus();
$this->load->view('customer/header',$data);
$this->load->view('customer/main-sidebar');
$this->load->view('customer/dashboard');
$this->load->view('customer/footer');
}
function ajaxPaginationDataOrder(){
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$action = 0; //Delivered
$order_id= $this->input->post('order_id');
$order_date_from= $this->input->post('order_date_from');
$order_date_to= $this->input->post('order_date_to');
$order_status= $this->input->post('order_status');
$sess_array = array(
'order_id' => $order_id,
'order_date_from' => $order_date_from,
'order_date_to' => $order_date_to,
'order_status' => $order_status
);
$this->session->set_userdata('order_search_data', $sess_array);
/*if(!$action){
$action = '';
}else{
$action = $action;
}*/
$perpage = $this->input->post('per_page');
if(!$perpage){
$perpage = $this->perPage;
}else{
$perpage = $perpage;
}
$action2 = $this->input->post('action2');
if(!$action2){
$action2 = '0';
}else{
$action2 = $action2;
}
//total rows count
$totalRec = count($this->customersmanagement_model->get_order_list($params = array(), $action,$action2));
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'dashboardcustomer/ajaxPaginationDataOrder';
$config['total_rows'] = $totalRec;
$config['per_page'] = $perpage;
$config['action'] = $action;
$config['action2'] = $action2;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['OrderList'] = $this->customersmanagement_model->get_order_list(array('start'=>$offset,'limit'=>$perpage),$action,$action2);
$data['title']="Order";
$data['page']="dashboardcustomer";
$data['perPageCount'] = $page;
/*** Remember what was the last page start ***/
if ($this->input->post('pagination') != '') {
$myPage = $this->input->post('page');
$myAction = $this->input->post('action');
$myPerPage = $this->input->post('per_page');
$myAction2 = $this->input->post('action2');
$paginationArray = array('page' => $myPage, 'action' => $myAction, 'per_page' => $myPerPage, 'action2' => $myAction2, 'page_name' => $data['page'], 'pagination' => $this->input->post('pagination'));
if ($this->session->userdata('paginationArray')) {
$this->session->unset_userdata('paginationArray');
}
$this->session->set_userdata('paginationArray', $paginationArray);
}
/*** Remember what was the last page end ***/
$this->load->view('customer/order_list_ajax', $data, false);
}
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('customer/header',$data);
$this->load->view('customer/main-sidebar');
$this->load->view('customer/change_password');
$this->load->view('customer/footer');
}
else
{
$this->db->trans_start();
$password = $this->input->post('newpassword');
$data_up= array('customer_password' => md5($password));
$session_data = $this->session->userdata('logged_in_customer');
$id = $session_data['id'];
$this->db->where('customer_id',$id);
$this->db->update('rt_customer',$data_up);
$this->db->trans_complete();
$this->db->trans_start();
$this->db->select('customer_email');
$this->db->from('rt_customer');
$this->db->where('customer_id', $id);
$query = $this->db->get();
$customer_data = $query->row();
//$data['customer_email'] = $customer_data->customer_email;
$this->db->trans_complete();
$logo=base_url().'assets/logo-main.png';
$image_path=base_url().'assets/';
$variables = array();
$to = $customer_data->customer_email;
$variables['logo'] = $logo;
$variables['image_path'] = $image_path;
$variables['to_email'] = $to;
$variables['email'] = $customer_data->customer_email;
$variables['password'] = $password;
$variables['site_address'] = SITE_ADDRESS;
$variables['sender_name'] = SITENAME;
$variables['site_name'] = SITENAME;
$template_name = 'change_password';
$mail_data = $this->frontend_model->getEmailTemplate($template_name);
$mailcontent=htmlspecialchars_decode($mail_data->template);
$subject = $mail_data->subject;
foreach($variables as $key => $value) {
$mailcontent = str_replace('{{'.$key.'}}', $value, $mailcontent);
}
$this->send_my_mail($to,$subject,$mailcontent, $mail_CC = '');
$this->session->set_flashdata('success_msg', 'Password successfully updated');
redirect('dashboardcustomer/changepassword');
}
//redirect(base_url('changePassword'));
}else
{
$data['title']="Change Password";
$data['page']="password";
$this->load->view('customer/header',$data);
$this->load->view('customer/main-sidebar');
$this->load->view('customer/change_password');
$this->load->view('customer/footer');
}
}
public function checkPass($str)
{
$userPassword = $this->input->post('userPassword');
$session_data = $this->session->userdata('logged_in_customer');
$userid = $session_data['id'];
$is_exist = $this->customersmanagement_model->IsCustomerExist($userPassword,$userid);
if ($is_exist) {
return true;
}else{
$this->form_validation->set_message('checkPass', 'Please enter correct password.');
return false;
}
}
function profile()
{
if ($this->input->server('REQUEST_METHOD') == 'POST')
{
if($this->input->post('ActionTab')=='PersonalInfo')
{
$this->PersonalInfo();
}
if($this->input->post('ActionTab')=='PaymentInfo')
{
$this->PaymentInfo();
}
if($this->input->post('ActionTab')=='SiteVAT')
{
$this->websettings_VAT();
}
}else
{
$session_data = $this->session->userdata('logged_in_customer');
$customer_id = $session_data['id'];
$data['StateList'] = $this->frontend_model->StateList();
$data['CityList'] = $this->frontend_model->CityList();
$data['title']="Settings";
$data['page']="customersettings";
$query['data'] = $this->customersmanagement_model->GetCustomerDetails($customer_id);
$data['pointDetails'] = $this->frontend_model->getRewardPoints($customer_id);
$data['rewardAvailability'] = $this->frontend_model->checkRewardPointStatus();
//$query['cardData'] = $this->customersmanagement_model->GetCustomerCardDetails($customer_id);
$this->db->select('*');
$this->db->from('rt_credit_cards');
$this->db->where('customer_id', $customer_id);
$ccQuery = $this->db->get();
$ccData = $ccQuery->row_array();
if (isset($ccData['cc_number']) && $ccData['cc_number'] != '') {
$CCNumber = ccDecrypt($ccData['cc_number'], $ccData['cc_time']);
$CCNumberLength = strlen($CCNumber);
$myCCNumber = substr_replace($CCNumber, 'XXXXXXXXXXXX', 0, $CCNumberLength - 4);
}
else {
$myCCNumber = '';
}
if (isset($ccData['cc_cvv'])) {
$CCCvv = ccDecrypt($ccData['cc_cvv'], $ccData['cc_time']);
}
$data['cc_number'] = isset($myCCNumber)?$myCCNumber:'';
$data['cc_type'] = isset($ccData['cc_type'])?$ccData['cc_type']:'';
$data['cc_exp_month'] = isset($ccData['cc_exp_month'])?$ccData['cc_exp_month']:'';
$data['cc_exp_year'] = isset($ccData['cc_exp_year'])?$ccData['cc_exp_year']:'';
$data['cc_cvv'] = isset($CCCvv)?$CCCvv:'';
$data['cc_time'] = isset($ccData['cc_time'])?$ccData['cc_time']:'';
$this->load->view('customer/header',$data);
$this->load->view('customer/main-sidebar',$query);
$this->load->view('customer/profile');
$this->load->view('customer/footer');
}
}
function PaymentInfo( $offset = 0 )
{
/*echo "<pre>";
print_r ($this->input->post());
echo "</pre>";
exit();*/
$time = time();
$cc_number_clean = str_replace(' ', '', $this->input->post('cc_number'));
$cc_number = ccEncrypt($cc_number_clean, $time);
$cc_cvv = ccEncrypt($this->input->post('cc_cvv'), $time);
$this->db->trans_start();
$session_data = $this->session->userdata('logged_in_customer');
$id = $session_data['id'];
$cardData = $this->customersmanagement_model->GetCustomerCardDetails($id);
if ($cardData) {
if (is_numeric($cc_number_clean)) {
$data_up= array(
'cc_number' => $cc_number,
'cc_type' => $this->input->post('cc_type'),
'cc_exp_month' => $this->input->post('cc_exp_month'),
'cc_exp_year' => $this->input->post('cc_exp_year'),
'cc_cvv' => $cc_cvv,
'cc_time' => $time
);
}
else {
$data_up= array(
'cc_type' => $this->input->post('cc_type'),
'cc_exp_month' => $this->input->post('cc_exp_month'),
'cc_exp_year' => $this->input->post('cc_exp_year'),
);
}
$this->db->where('customer_id',$id);
$this->db->update('rt_credit_cards',$data_up);
}
else {
$data_in= array(
'customer_id' => $id,
'cc_number' => $cc_number,
'cc_type' => $this->input->post('cc_type'),
'cc_exp_month' => $this->input->post('cc_exp_month'),
'cc_exp_year' => $this->input->post('cc_exp_year'),
'cc_cvv' => $cc_cvv,
'cc_time' => $time
);
$this->db->insert('rt_credit_cards',$data_in);
}
$this->db->trans_complete();
$this->session->set_flashdata('SiteTab', 'SiteInfo');
$this->session->set_flashdata('success_msg', 'Payment Information successfully updated');
redirect('customer/dashboard/profile');
}
function PersonalInfo( $offset = 0 )
{
/*$customer_full_name = $this->input->post('customer_name'); //none
$space = strrpos($customer_full_name, ' '); //none
$length = strlen($customer_full_name); //none
if ($space != 0) {
$customer_name = substr($customer_full_name, 0, $space);
$customer_lastname = substr($customer_full_name, $space, $length);
}
else {
$customer_name = $customer_full_name;
$customer_lastname = '';
}*/
$this->form_validation->set_rules('customer_email', 'Email', 'trim|required|callback_isEmailExist');
if ($this->form_validation->run() == FALSE) {
$session_data = $this->session->userdata('logged_in_customer');
$customer_id = $session_data['id'];
$data['StateList'] = $this->frontend_model->StateList();
$data['CityList'] = $this->frontend_model->CityList();
$data['title']="Settings";
$data['page']="customersettings";
$query['data'] = $this->customersmanagement_model->GetCustomerDetails($customer_id);
$this->load->view('customer/header',$data);
$this->load->view('customer/main-sidebar',$query);
$this->load->view('customer/profile');
$this->load->view('customer/footer');
}
else {
$customer_name = $this->input->post('customer_name');
$customer_lastname = $this->input->post('customer_lastname');
$this->db->trans_start();
$data_up= array(
'customer_name' => $customer_name,
'customer_lastname' => $customer_lastname,
'customer_street' => $this->input->post('customer_street'),
'customer_phone' => $this->input->post('customer_phone'),
'customer_zip' => $this->input->post('customer_zip'),
'customer_state' => $this->input->post('customer_state'),
'customer_city' => $this->input->post('customer_city'),
'customer_email' => $this->input->post('customer_email')
);
$session_data = $this->session->userdata('logged_in_customer');
$id = $session_data['id'];
$this->db->where('customer_id',$id);
$this->db->update('rt_customer',$data_up);
$this->db->trans_complete();
$logged_in_customer = $this->session->userdata('logged_in_customer');
$logged_in_customer['username'] = $customer_name;
$this->session->set_userdata('logged_in_customer', $logged_in_customer);
$this->session->set_flashdata('SiteTab', 'SiteInfo');
$this->session->set_flashdata('success_msg', 'Personal Information updated successfully');
redirect('dashboardcustomer/profile');
}
//redirect('customer/dashboard/profile');
}
function isEmailExist() {
$CustData = $this->session->userdata('logged_in_customer');
$customer_id = $CustData['id'];
$customer_email = $this->input->post('customer_email');
$isEmailExist = $this->customersmanagement_model->isEmailExist($customer_id, $customer_email);
if ($isEmailExist) {
$this->form_validation->set_message('isEmailExist', 'Email already exist');
return false;
}
else {
return true;
}
}
function logout()
{
$this->session->unset_userdata('logged_in_customer');
//redirect('frontend', 'refresh');
$this->cart->destroy();
redirect(base_url(),refresh);
}
function OrderDetails($order_id=0)
{
$topping ='';
$orderid = $this->input->post('order_id');
$order_details = $this->menumanagement_model->get_order_details($orderid);
$order_kart = $this->menumanagement_model->get_order_kart($orderid);
if(is_array($order_details) && sizeof($order_details)>0)
{
if($order_details['tip']!='')
{
$tips = $order_details['tip'];
}else{
$tips = 0;
}
if ($order_details['discountvalue'] > 0) {
$discountvalue = '<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>'.$this->lang->line('Discount').': </td>
<td><b>'.SITENAME_CURRENCY.number_format($order_details['discountvalue'], 2, '.', '').'</b></td>
</tr>';
}
else if ($order_details['offervalue'] > 0 && $order_details['offervalue'] != '') {
$discountvalue = '<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>'.$this->lang->line('Discount').': </td>
<td><b>'.SITENAME_CURRENCY.number_format($order_details['offervalue'], 2, '.', '').'</b></td>
</tr>';
}
else {
$discountvalue = '';
}
$delivery_charged = $order_details['delivery_charged'];
$deliverystreet = '';
if($order_details['deliverystreet']!='' || $order_details['deliverystreet']!='undefined')
{
$deliverystreet =$order_details['deliverystreet'];
}
$totalval = $order_details['ordersubtotal'];
$Total = $totalval + $delivery_charged;
if($order_details['isdriver_assign']==0)
{
$driverassign = '';
}else{
$driverassign = '';
}
if($order_details['driverid']>0)
{
$drivername = $order_details['drivername'];
}else{
$drivername = $this->lang->line('Not_yet_assigned');
}
/*if ($order_details['customer_signature'] != '' && file_exists(base_url().CUSTOMER_SIGNATURE_IMAGE_THUMBS.$order_details['customer_signature'])) {
$customer_signature = '<div class="detail-instruction"><b>Customer Signature : </b> <img style="width: 50px;" src="'.base_url().CUSTOMER_SIGNATURE_IMAGE_THUMBS.$order_details['customer_signature'].'"></img> </div>';
}*/
if ($order_details['customer_signature'] != '') {
$customer_signature = '<div class="detail-instruction"><b>Customer Signature : </b> <img style="width: 50px;" src="'.base_url().CUSTOMER_SIGNATURE_IMAGE_THUMBS.$order_details['customer_signature'].'"></img> <a download href="'.base_url().CUSTOMER_SIGNATURE_IMAGE_THUMBS.$order_details['customer_signature'].'" target="_blank"><button class="btn btn-outline green btn-sm opo opened btn-circle mcfr active pad2_10">'.$this->lang->line('Download').'</button></a></div>';
}
else {
//$customer_signature = '<div class="detail-instruction"><b>Customer Signature : </b> Not signed. </div>';
$customer_signature = '';
}
$data_view='
<div class="testPopupBottom-backLayer"></div>
<div class="col-md-8 col-sm-12 col-xs-12 pull-center positionAbsolute">
<h3>Order Details<button onclick="closeme()" class="btn btn-danger btn-circle pull-right hideMe">'.$this->lang->line('Close').'</button></h3>
<div class="modal-body">
<div class="row driver-listTop" style="margin-left: -15px;margin-right: -15px;">
<div class="col-md-4 col-sm-3 oredrId"><b> '.$order_details['ordergenerateid'].'</b></div>
<div class="col-md-8 col-sm-9">
<div class="row">
<p class="col-md-4 col-sm-4"><i class="fa fa-calendar"></i> '.date('m/d/Y', strtotime($order_details['orderdate'])).'</p>
<p class="col-md-4 col-sm-4"> </p>
<p class="col-md-4 col-sm-4"><b>'.$this->lang->line('Total_Price').': '.SITENAME_CURRENCY.$order_details['ordertotalprice'].'</b></p>
</div>
</div>
</div>
<div class="row driver-listBottom">
<div class="col-md-12 address-section">
<p class="driver-address col-md-4 no-padding"><img src="'.base_url().'assets/img/homeleft.png" title="leftimg" alt="leftimg"> '.$deliverystreet.'</p>
<p class="user-status col-md-8">
<span class="statusbutton" id="order_view_status_1183">Order Status: '.$order_details['status'].'</span>
</p>
</div>
</div>
<ul class="orderaddress row">
<li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-user"></i> </span> '.$order_details['customername'].'</li>
<li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-envelope"></i> </span> '.$order_details['customeremail'].'</li>
<li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-phone"></i></span> '.$order_details['customercellphone'].'</li>
<li class="col-md-4 col-sm-6">Payment Type : '.$order_details['payment_type'].'</li>
<li class="col-md-4 col-sm-6">Payment Status : '.$order_details['paypal_status'].'</li>
</ul>
<div class="detail-instruction"><b>'.$this->lang->line('Restaurant').' : </b> '.$order_details['restaurant_name'].' </div>
<div class="detail-instruction"><b>'.$this->lang->line('Instruction').' : </b> '.$order_details['instructions'].' </div>
<div class="table-responsive">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>'.$this->lang->line('Sl_No').'</th>
<th>'.$this->lang->line('Item_Name').'</th>
<th>'.$this->lang->line('Item_Instruction').'</th>
<th>'.$this->lang->line('Quantity').'</th>
<th>'.$this->lang->line('Price').'</th>
<th>'.$this->lang->line('Total').'</th>
</tr>
</thead>
<tbody>';
// <li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-car"></i></span> Driver Name : '.$drivername.'</li>
if(is_array($order_kart) && sizeof($order_kart)>0){
$slno=0;
foreach($order_kart as $row) {
if($row->addonsname != ''){
$topping = '<br> <b>'.$this->lang->line('Addon').': </b>'.$row->addonsname;
}
$slno = $slno+1;
$data_view .=' <tr class="even">
<td>'.$slno.'</td>
<td>'.$row->menuname.' '.$topping.'</td>
<td>'.$row->specialinstruction.'</td>
<td>'.$row->quantity.'<br></td>
<td>'.SITENAME_CURRENCY.$row->menuprice.'</td>
<td>'.SITENAME_CURRENCY.$row->tot_menuprice.'</td>
</tr>';
} }
$data_view .='</tbody>
<tfoot>
<tr class="even">
<td></td>
<td></td>
<td></td>
<td></td>
<td><b>'.$this->lang->line('Item_Price').' : </b></td>
<td><b>'.SITENAME_CURRENCY.$order_details['menuprice_total'].'</b></td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>'.$this->lang->line('Delivery_Charge').' : </td>
<td>'.SITENAME_CURRENCY.number_format($delivery_charged, 2, '.', '').'</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>'.$this->lang->line('Tax').' : </td>
<td>'.SITENAME_CURRENCY.$order_details['taxvalue'].'</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td><b>'.$this->lang->line('Sub_Total').' : </b></td>
<td><b>'.SITENAME_CURRENCY.number_format($order_details['ordersubtotal'], 2, '.', '').'</b></td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>'.$this->lang->line('Tips').' : </td>
<td>'.SITENAME_CURRENCY.number_format($tips, 2, '.', '').'</td>
</tr>
'.$discountvalue.'
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>'.$this->lang->line('RewardsPointAmount').' : </td>
<td>'.SITENAME_CURRENCY.number_format($order_details['point_amount'], 2, '.', '').'</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td><b>'.$this->lang->line('Total').' : </b></td>
<td><b>'.SITENAME_CURRENCY.number_format($order_details['ordertotalprice'], 2, '.', '').'</b></td>
</tr>
</tfoot>
</table>
</div>
<div class="driver-list-detail-button clearfix">
'.$customer_signature.'
<a href="javascript:void(0);" onclick="do_pdf('.$orderid.');" style="margin-right:20px;"><i class="fa fa-print"></i> '.$this->lang->line('Print').'</a>
<a href="javascript:void(0);" onclick="do_pdf('.$orderid.');"><i class="fa fa-file-pdf-o"></i> '.$this->lang->line('Download_PDF').'</a>
'.$driverassign.'
</div>
</div>
</div>';
}
echo $data_view;
}
function trackOrder($order_id=0)
{
$topping ='';
$orderid = $this->input->post('order_id');
$order_details = $this->menumanagement_model->get_order_details($orderid);
$order_kart = $this->menumanagement_model->get_order_kart($orderid);
if(is_array($order_details) && sizeof($order_details)>0)
{
$deliverylatitude = $order_details['deliverylatitude'];
$deliverylongitude = $order_details['deliverylongitude'];
$driver_id = $order_details['driverid'];
$restaurant = $this->restaurantmanagement_model->GetRestauratDetails($order_details['restaurant_id']);
$restaurantlatitude = $restaurant['latitude'];
$restaurantlongitude = $restaurant['longitude'];
$this->db->select('current_latitude, current_longitude');
$this->db->from('rt_driver');
$this->db->where('driver_id', $driver_id);
$driverDetails = $this->db->get();
$driverDetails = $driverDetails->row_array();
$currentlatitude = $driverDetails['current_latitude'];
$currentlongitude = $driverDetails['current_longitude'];
if($order_details['tip']!='')
{
$tips = $order_details['tip'];
}else{
$tips = 0;
}
if ($order_details['discountvalue'] > 0) {
$discountvalue = '<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Discount: </td>
<td><b>- '.SITENAME_CURRENCY.number_format($order_details['discountvalue'], 2, '.', '').'</b></td>
</tr>';
}
else if ($order_details['offervalue'] > 0 && $order_details['offervalue'] != '') {
$discountvalue = '<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Coupon Discount: </td>
<td><b>- '.SITENAME_CURRENCY.number_format($order_details['offervalue'], 2, '.', '').'</b></td>
</tr>';
}
else {
$discountvalue = '';
}
$delivery_charged = $order_details['delivery_charged'];
$deliverystreet = '';
if($order_details['deliverystreet']!='' || $order_details['deliverystreet']!='undefined')
{
$deliverystreet =$order_details['deliverystreet'];
}
$totalval = $order_details['ordersubtotal'];
$Total = $totalval + $delivery_charged;
if($order_details['isdriver_assign']==0)
{
$driverassign = '';
}else{
$driverassign = '';
}
if($order_details['driverid']>0)
{
$drivername = $order_details['drivername'];
}else{
$drivername = "Not yet assigned";
}
$data_view='
<div class="testPopupBottom-backLayer"></div>
<div class="col-md-11 col-sm-12 col-xs-12 pull-center positionAbsolute">
<div class="col-md-12 col-sm-12 col-xs-12 custom-padding-0">
<h3>Order Details<button onclick="closeme()" class="btn btn-danger btn-circle pull-right hideMe">Close</button></h3>
</div>
<div class="modal-body" style="float:left;width:100%;">
<div class="col-md-8">
<div class="row driver-listTop" style="margin-left: -15px;margin-right: -15px;">
<div class="col-md-4 col-sm-3 oredrId"><b> '.$order_details['ordergenerateid'].'</b></div>
<div class="col-md-8 col-sm-9">
<div class="row">
<p class="col-md-4 col-sm-4"><i class="fa fa-calendar"></i> '.date('m/d/Y', strtotime($order_details['orderdate'])).'</p>
<p class="col-md-4 col-sm-4"> </p>
<p class="col-md-4 col-sm-4"><b>Total Price: '.SITENAME_CURRENCY.$order_details['ordertotalprice'].'</b></p>
</div>
</div>
</div>
<div class="row driver-listBottom">
<div class="col-md-12 address-section">
<p class="driver-address col-md-4 no-padding"><img src="../assets/img/homeleft.png" title="leftimg" alt="leftimg"> '.$deliverystreet.'</p>
<p class="user-status col-md-4">
<span class="statusbutton" id="order_view_status_1183">Order Status: '.$order_details['status'].'</span>
</p>
<p class="user-status col-md-4">
<span class="statusbutton">Order Type: '.ucfirst($order_details['deliverytype']).'</span>
</p>
</div>
</div>
<ul class="orderaddress row">
<li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-user"></i> </span> '.$order_details['customername'].'</li>
<li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-envelope"></i> </span> '.$order_details['customeremail'].'</li>
<li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-phone"></i></span> '.$order_details['customercellphone'].'</li>
<li class="col-md-4 col-sm-6">Payment Type : '.$order_details['payment_type'].'</li>
<li class="col-md-4 col-sm-6">Payment Status : '.$order_details['paypal_status'].'</li>
</ul>
<div class="detail-instruction"><b>Instruction : </b> </div>
<div class="table-responsive">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>S.No</th>
<th>Item Name</th>
<th>Item Instruction</th>
<th>Qty</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>';
// <li class="col-md-4 col-sm-6"><span class="addressimg"><i class="fa fa-car"></i></span> Driver Name : '.$drivername.'</li>
if(is_array($order_kart) && sizeof($order_kart)>0){
$slno=0;
foreach($order_kart as $row) {
if($row->addonsname != ''){
$topping = '<br> <b>Topping: </b>'.$row->addonsname;
}
$slno = $slno+1;
$data_view .=' <tr class="even">
<td>'.$slno.'</td>
<td>'.$row->menuname.' '.$topping.'</td>
<td>'.$row->specialinstruction.'</td>
<td>'.$row->quantity.'<br></td>
<td>'.SITENAME_CURRENCY.$row->menuprice.'</td>
<td>'.SITENAME_CURRENCY.$row->tot_menuprice.'</td>
</tr>';
} }
$data_view .='</tbody>
<tfoot>
<tr class="even">
<td></td>
<td></td>
<td></td>
<td></td>
<td><b>Total item : </b></td>
<td><b>'.SITENAME_CURRENCY.$order_details['menuprice_total'].'</b></td>
</tr>
'.$discountvalue.'
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Tax : </td>
<td>'.SITENAME_CURRENCY.$order_details['taxvalue'].'</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Tips : </td>
<td>'.SITENAME_CURRENCY.number_format($tips, 2, '.', '').'</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Sub Total : </td>
<td><b>'.SITENAME_CURRENCY.number_format($totalval, 2, '.', '').'</b></td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>Delivery Charge : </td>
<td>'.SITENAME_CURRENCY.number_format($delivery_charged, 2, '.', '').'</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td>'.$this->lang->line('RewardsPointAmount').' : </td>
<td>'.SITENAME_CURRENCY.number_format($order_details['point_amount'], 2, '.', '').'</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
<td><b>Total : </b></td>
<td><b>'.SITENAME_CURRENCY.number_format($order_details['ordertotalprice'], 2, '.', '').'</b></td>
</tr>
</tfoot>
</table>
</div>
<div class="driver-list-detail-button clearfix">
<a href="javascript:void(0);" onclick="do_pdf('.$orderid.');" style="margin-right:20px;"><i class="fa fa-print"></i> Print</a>
<a href="javascript:void(0);" onclick="do_pdf('.$orderid.');"><i class="fa fa-file-pdf-o"></i> Download in PDF format</a>
'.$driverassign.'
</div>
</div>
<div class="col-md-4 col-sm-12 col-xs-12 padding-left-only">
<h4>Live Tracking</h4>
<div id="map"></div>
<div class="clearfix"></div>
</div>
</div>
</div>
<INPUT type="hidden" NAME="order_latitude" id="order_latitude" value="'.$deliverylatitude.'"><INPUT type="hidden" NAME="order_longitude" id="order_longitude" value="'.$deliverylongitude.'">
<INPUT type="hidden" NAME="restaurant_latitude" id="restaurant_latitude" value="'.$restaurantlatitude.'"><INPUT type="hidden" NAME="restaurant_longitude" id="restaurant_longitude" value="'.$restaurantlongitude.'">
<INPUT type="hidden" NAME="current_latitude" id="current_latitude" value="'.$currentlatitude.'"><INPUT type="hidden" NAME="current_longitude" id="current_longitude" value="'.$currentlongitude.'">
<INPUT type="hidden" NAME="driver_id" id="driver_id" value="'.$driver_id.'">';
}
echo $data_view;
}
function order_PDF($orderid)
{
$pdfContent = $this->OrderDetails4PDF($orderid);
$this->m_pdf->pdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$this->m_pdf->pdf->useOnlyCoreFonts = true; // false is default
//$this->m_pdf->pdf->SetProtection(array('print'));
//$this->m_pdf->pdf->SetTitle(SITENAME." - Report");
//$this->m_pdf->pdf->SetAuthor(SITENAME);
//$this->m_pdf->pdf->SetWatermarkText(SITENAME);
//$this->m_pdf->pdf->showWatermarkText = true;
//$this->m_pdf->pdf->watermark_font = 'DejaVuSansCondensed';
//$this->m_pdf->pdf->watermarkTextAlpha = 0.03;
//$this->m_pdf->pdf->SetDisplayMode('fullwidth');
//base_url(); assets/css/
$stylesheet = file_get_contents(base_url().'assets/css/mpdfstyletables.css');
//$stylesheet = file_get_contents(dirname(dirname(__FILE__)).'/includes/mpdf/mpdfstyletables.css');
//$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
$this->m_pdf->pdf->WriteHTML($stylesheet,1);
$this->m_pdf->pdf->WriteHTML($pdfContent,2);
$this->m_pdf->pdf->Output('invoice_'.$orderid.'.pdf','D');
exit;
}
function OrderDetails4PDF($orderid)
{
$menudetails='';
$totaltax=0;
$deliverychargeamt='';
$taxamount=0;
$orderType='';
$orderSend='';
$pdf_content='';
$landline='';
$deliveryTime='';
$deliveryoption='';
//$orderid = $this->input->post('order_id');
//echo $orderid;
//exit();
$website_settings =$this->dashboard_model->get_website_settings();
$order_details = $this->menumanagement_model->get_order_details($orderid);
$order_kart = $this->menumanagement_model->get_order_kart($orderid);
$restaurant_details = $this->restaurantmanagement_model->GetRestauratDetails($order_details['restaurant_id']);
$customerName = $order_details['customername'];
$customerLastname = $order_details['customerlastname'];
$deliveryStreet = $order_details['deliverystreet'];
$deliverydoornumber = $order_details['deliverydoornumber'];
$deliverylandmark = $order_details['deliverylandmark'];
$deliveryarea = $order_details['deliveryarea'];
$instructions = $order_details['instructions'];
$deliverycity = $order_details['deliverycity'];
$deliveryState = $order_details['deliverystate'];
$cust_Phone = $order_details['customercellphone'];
$logo = base_url().SITE_LOGO_PATH_THUMBS.$website_settings['sitelogo'];
if($order_details['tip']!='')
{
$tips = $order_details['tip'];
}else{
$tips = 0;
}
if($order_details['deliverytype'] == 'delivery'){
$deliverychargeamt = $order_details['delivery_charged'];
$deliverycharge .= '<tr>
<td style="height:35px;"> </td>
<td style="height:35px;"> </td>
<td style="height:35px;">Delivery Charge </td>
<td style="height:35px;">'.SITENAME_CURRENCY.''.$order_details['delivery_charged'].'</td>
</tr>';
}
if(is_array($order_kart) && sizeof($order_kart)>0)
{
foreach($order_kart as $row) {
$rowTotal[] = $row->tot_menuprice;
$menuname = $row->menuname;
$menuprice = $row->menuprice;
$tot_menuprice = $row->tot_menuprice;
$quantity = $row->quantity;
$addonsname = '';
$addonsprice = '';
$crustname = '';
$topping = '';
$instruction = '';
$menu_size = '';
if($row->menu_size != ''){
$menu_size = '(' .$row->menu_size.')';
}
if($row->addonsname!= ''){
$addonsname = '<br> <b>Addons:</b>' .$row->addonsname;
$addonsprice = '('.$row->addonsprice.' '.'Extra'.')';
}
if($row->menu_crustname != ''){
$crustname = '<br> <b>Crust:</b>'.$row->menu_crustname;
}
if($row->menu_addonsname != ''){
$topping = '<br> <b>Topping:</b>'.$row->menu_addonsname;
}
if($row->specialinstruction != ''){
$instruction = '<br> <b>Instruction:</b>'.$row->specialinstruction;
}
$menudetails .= '<tr>
<td align="center" style="height:35px;border-bottom:1px solid #CCC;">'.$quantity.'</td>
<td align="left" style="height:35px;border-bottom:1px solid #CCC; max-width:40%;">'.$menuname.' '.$menu_size.' '.$addonsname.' '.$crustname.' '.$topping.' '.$instruction.' </td>
<td align="left" style="height:35px;border-bottom:1px solid #CCC;">'.SITENAME_CURRENCY.''.$menuprice.'</td>
<td align="left" style="height:35px;border-bottom:1px solid #CCC;">'.SITENAME_CURRENCY.''.$tot_menuprice.'</td>
</tr>';
}
if(!empty($rowTotal) && is_array($rowTotal))
{
$orderSubTotal = array_sum($rowTotal);
}
}
$tax = $restaurant_details['restaurant_salestax'];
/*if($tax != ''){
$taxamount1 = $orderSubTotal*($tax/100);
$taxamount = number_format($taxamount1,2);
}*/
$taxamount = $order_details['taxvalue'];
if($tax != '0.00'){
$taxperchantage = $tax;
}
/*$offer_percentage = $order_details['offervalue'];
if( isset($offer_percentage) && !empty($offer_percentage) ){
$orderDiscountPrice = $orderSubTotal*($offer_percentage/100);
$orderDiscountPriceTotal = $orderSubTotal-$orderDiscountPrice;
$orderGrandTotal = $orderDiscountPriceTotal+$totaltax+$deliverychargeamt+$taxamount+$tips;
$offerdetails .= '<tr>
<td style="height:35px;"> </td>
<td style="height:35px;"> </td>
<td style="height:35px;">Coupon Discount('.$offer_percentage.' % Off) </td>
<td style="height:35px;">'.SITENAME_CURRENCY.''.number_format($orderDiscountPrice,2).'</td>
</tr>';
}else{
$orderGrandTotal =$orderSubTotal+$totaltax+$deliverychargeamt+$taxamount+$tips;
}*/
$offervalue = $order_details['offervalue'];
$discountvalue = $order_details['discountvalue'];
if( isset($offervalue) && $offervalue > 0 ){
$orderDiscountPriceTotal = $orderSubTotal-$offervalue;
$orderGrandTotal = $orderDiscountPriceTotal+$totaltax+$deliverychargeamt+$taxamount+$tips;
$offerdetails .= '<tr>
<td style="height:35px;"> </td>
<td style="height:35px;"> </td>
<td style="height:35px;">Coupon Discount </td>
<td style="height:35px;">-'.SITENAME_CURRENCY.''.number_format($offervalue,2).'</td>
</tr>';
}
if( isset($discountvalue) && $discountvalue > 0 ){
$orderDiscountPriceTotal = $orderSubTotal-$discountvalue;
$orderGrandTotal = $orderDiscountPriceTotal+$totaltax+$deliverychargeamt+$taxamount+$tips;
$offerdetails .= '<tr>
<td style="height:35px;"> </td>
<td style="height:35px;"> </td>
<td style="height:35px;">Discount </td>
<td style="height:35px;">-'.SITENAME_CURRENCY.''.number_format($discountvalue,2).'</td>
</tr>';
}else{
$orderGrandTotal =$orderSubTotal+$totaltax+$deliverychargeamt+$taxamount+$tips;
}
$point_amount = $order_details['point_amount'];
if( isset($point_amount) && $point_amount > 0 ){
$offerdetails .= '<tr>
<td style="height:35px;"> </td>
<td style="height:35px;"> </td>
<td style="height:35px;">Reward Point Used </td>
<td style="height:35px;">-'.SITENAME_CURRENCY.''.number_format($point_amount,2).'</td>
</tr>';
}
//Deliver Time
if($order_details['deliverytype'] == 'delivery'){
if($order_details['foodassoonas'] == '1'){
$deliveryoption = 'As Soon AS Possiable';
}else{
$deliveryoption = date('M j, Y', strtotime($order_details['deliverydate'])).' '.date('g:i A', strtotime($order_details['deliverydate'])).' '.$order_details['deliverytime'];
}
$deliveryTime = 'Delivery Time';
$orderType = 'Delivery Order';
//$orderSend = 'This order will be delivered to the customer';
$orderSend = '';
}
elseif($order_details['deliverytype'] == 'pickup'){
if($order_details['foodassoonas'] == '1'){
$deliveryoption = 'As Soon AS Possiable';
}else{
$deliveryoption = date('M j, Y', strtotime($order_details['deliverydate'])).' '.date('g:i A', strtotime($order_details['deliverydate'])).' '.$order_details['deliverytime'];
}
$deliveryTime = 'Pickup Time';
$orderType = 'Pickup Order';
//$orderSend = 'This order will be pickup by the customer';
$orderSend = '';
}
if($order_details['deliverylandmark'] != ''){
$landmark = 'Landmark:'.$order_details['deliverylandmark'];
}
if($order_details['customerlandline'] != ''){
$landline = $order_details['customerlandline'];
}
if($order_details['payment_type'] == 'cod'){
$payment_type = 'Cash on Delivery';
}elseif($order_details['payment_type'] == 'CC'){
$payment_type = 'Credit Card';
}else{
$payment_type = $order_details['payment_type'];
}
$restaurant_name = $order_details['restaurant_name'];
//Address Details
$cust_address = '';
if( $order_details['deliverydoornumber']!='' ) $cust_address .= $order_details['deliverydoornumber'].', ';
if( $order_details['deliverystreet']!='') $cust_address .= $order_details['deliverystreet'].', ';
if( $deliveryarea!='') $cust_address .= $deliveryarea.', ';
if( $deliverycity!='') $cust_address .= $deliverycity.', ';
if( $deliveryStreet!='') $cust_address .= $deliveryStreet.', ';
if( $deliveryState!='') $cust_address .= $deliveryState;
//Lanline Details
if( !empty($deliverylandmark) ){
$landmark_details = '<td>Landmark</td><td>:</td><td>'.$deliverylandmark.'</td>';
}
//Lanline Details
if( !empty($landline) ){
$landline_details = '<td>Landline</td><td>:</td><td>'.$landline.'</td>';
}
//Payment Detils
if( !empty($transactionId) ){
$trasnsId_details = '<td width="18%">Transaction Id</td><td width="2%">:</td><td width="30%">'.$transactionId.'</td>';
}else{
$trasnsId_details = '<td> </td><td> </td><td> </td>';
}
if ($order_details['customer_signature'] != '') {
$customer_signature = '<div style="font-weight:bold; width:100%;">Customer Signature: <img style="width: 50px;" src="'.base_url().CUSTOMER_SIGNATURE_IMAGE_THUMBS.$order_details['customer_signature'].'"></img></div></div>';
}
else {
//$customer_signature = '<div style="font-weight:bold; width:100%;">Customer Signature:________________________________</div></div>';
$customer_signature = '';
}
$order_payment_details = '<tr>
<td align="left" colspan="3">
<table width="100%" cellpadding="5" cellspacing="0" border="0" style="border:1px solid #CCC;">
<tr><td width="18%">Payment Method</td><td width="2%">:</td><td width="30%">'.$payment_type.'</td>'.$trasnsId_details.'</tr>
</table>
</td>
</tr>';
//___________JOSE___________ Aca se modifico lo que se imprimia en el pdf para que mostrara el deliverydoornumber y el deliverylandmark
//.......................................................................................................................................................
if ($tips) {
$tips_content = '<tr>
<td > </td>
<td > </td>
<td align="left" >Tips </td>
<td align="left" >'.SITENAME_CURRENCY.''.number_format($tips,2).'</td>
</tr>';
}
$pdf_content .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<div style="display:block; width:760px; padding:0 10px;">
<div style="display:block; width:100%; vertical-align:top;">
<div style="display:block; width:100%; vertical-align:top;">
<table width="100%" align="center">
<tr>
<td valign="top" width="70%">
<table style="display:inline-block; width:100%; vertical-align:top; float:right;font-family:Arial; font-size:13px; ">
<tr style="display:block; width:100%; font-family:Arial; font-size:13px;">
<td style="display:inline-block; width:100%; vertical-align:top; font-size:20px; font-weight:bold;">'.$orderType.' #'.$order_details['ordergenerateid'].'</td>
</tr>
<tr style="display:block; width:100%;">
<td style="display:inline-block; width:100%; vertical-align:top;font-weight:bold;">'.$orderSend.'</td>
</tr>
<tr style="display:block; width:100%;">
<td style="display:inline-block; width:100%; vertical-align:top;">Question? Call us at '.SITE_PHONE_NO.'</td>
</tr>
</table>
</td>
<td valign="top" width="30%">
<div style="display:inline-block; width:100%; vertical-align:top;">
<img width="100" src="'.$logo.'" title="'.SITENAME.'" alt="'.SITENAME.'" />
</div>
</td>
</tr>
</table>
</div>
<div style="clear:both;"></div>
<div style="display:block; width:100%; vertical-align:top; margin-top:20px;margin-bottom:10px;">
<div style="display:block; width:100%;font-weight:bold; font-family:Arial; font-size:13px;line-height:26px; margin-bottom:8px;">'.$restaurant_name.'</div>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td align="center" style="height:25px; font-weight:bold;border-bottom:1px dotted #CCC;">Qty</td>
<td align="left" style="height:25px; font-weight:bold;border-bottom:1px dotted #CCC;">Menu </td>
<td align="left" style="height:25px; font-weight:bold;border-bottom:1px dotted #CCC;">Price</td>
<td align="left" style="height:25px; font-weight:bold;border-bottom:1px dotted #CCC;">Total Price</td>
</tr>
'.$menudetails;
if($order_details['deliverytype'] == 'delivery'){
$pdf_content .= '<tr>
<td> </td><td> </td><td style="font-weight:bold;">Item Price</td><td style="font-weight:bold;">'.SITENAME_CURRENCY.''.number_format($order_details['menuprice_total'],2).'</td>
</tr>
'.$deliverycharge.'
<tr>
<td style="height:25px; font-weight:bold;border-bottom:1px dotted #CCC;"> </td>
<td style="height:25px; font-weight:bold;border-bottom:1px dotted #CCC;"> </td>
<td style="height:25px; border-bottom:1px dotted #CCC;">Tax('.$taxperchantage.' %)</td>
<td style="height:25px; border-bottom:1px dotted #CCC;">'.SITENAME_CURRENCY.''.$order_details['taxvalue'].'</td>
</tr>
<tr>
<td> </td><td> </td><td style="font-weight:bold;">Subtotal</td><td style="font-weight:bold;">'.SITENAME_CURRENCY.''.number_format($order_details['ordersubtotal'],2).'</td>
</tr>
'.$tips_content.'
'.$offerdetails;
}elseif ($order_details['deliverytype'] == 'pickup') {
$pdf_content .= '<tr>
<td> </td><td> </td><td style="font-weight:bold;">Subtotal</td><td style="font-weight:bold;">'.SITENAME_CURRENCY.''.number_format($orderSubTotal,2).'</td>
</tr>
<tr>
<td> </td><td> </td><td>Tax</td><td>'.SITENAME_CURRENCY.''.$taxamount.'</td>
</tr>
'.$tips_content.'
'.$offerdetails;
}
$pdf_content .= '
<tr>
<td style="border-top:1px solid #CCC;"> </td>
<td style="border-top:1px solid #CCC;"> </td>
<td align="left" style="height:35px;font-weight:bold;border-top:1px solid #CCC;">Reward Point </td>
<td align="left" style="height:35px;font-weight:bold;border-top:1px solid #CCC;">'.SITENAME_CURRENCY.''.number_format($order_details['point_amount'],2).'</td>
</tr>
<tr>
<td style="border-top:1px solid #CCC;"> </td>
<td style="border-top:1px solid #CCC;"> </td>
<td align="left" style="height:35px;font-weight:bold;border-top:1px solid #CCC;">Total </td>
<td align="left" style="height:35px;font-weight:bold;border-top:1px solid #CCC;">'.SITENAME_CURRENCY.''.number_format($order_details['ordertotalprice'],2).'</td>
</tr>
</table>
</div>
<div style="width:100%; font-family:Arial; font-size:13px;"></div>
</div>
<div style="width:100%; vertical-align:top; border-top:1px solid #000000;font-size:13px; font-family:Arial; margin-top:10px; margin-bottom:10px;padding-top:10px;">
<div style="float:left; width:40%;">
<div style="font-weight:bold; width:100%;">Order will be delivered to :</div>
<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'Name'.': </span>'.$customerName.' '.$customerLastname.'</div>
<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'Address'.': </span>'.$deliveryStreet.'</div>
<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'Cellphone'.': </span>'.$cust_Phone.'</div>
';
/*if(isset($instructions) && !empty($instructions)){
$pdf_content .= '<div style="width:100%;">
<span style="font-weight:bold; width:100%;">
Instructions:
</span>'.$instructions.'</div>';
}*/
$pdf_content .= '</div>
<div style="float:left; width:30%;">
<div style="font-weight:bold; width:100%;">'.$deliveryTime.':</div>
<div style="font-weight:bold; color:#cc0000; width:100%;">'.$deliveryoption.'</div>
</div>
<div style="float:right; width:25%;">
<div style="font-weight:bold; width:100%;">Payment Type:</div>
<div style="font-weight:normal; width:100%;">'.$payment_type.'</div>
</div>
</div>';
if(isset($instructions) && !empty($instructions)){
$pdf_content .= '<div style="width:100%;">
<span style="font-weight:bold; width:100%;">
Instructions:
</span>'.$instructions.'</div>';
}
$pdf_content .= '<div style="width:100%; font-family:Arial; font-size:13px;">
<span style="font-weight:bold; width:100%;">Order Status :</span> '.$order_details['status'].'
</div><br>
'.$customer_signature.'
</body>
</html>';
/*<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'Doorno'.': </span>'.$deliverydoornumber.'</div>
<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'Landmark'.': </span>'.$deliverylandmark.'</div>
<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'Area'.': </span>'.$deliverycity.'</div>
<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'City'.': </span>'.$deliveryState.'</div>
<div style="width:100%;"><span style="font-weight:bold; width:50%;">'.'Landline'.': </span>'.$landline.'</div>*/
/*<td> </td><td> </td><td>Tax('.$taxperchantage.' %)</td><td>'.SITENAME_CURRENCY.''.$taxamount.'</td>*/
//.......................................................................................................................................................
// echo $pdf_content; exit();
return $pdf_content;
}
function upload_customer_image()
{
$session_data = $this->session->userdata('logged_in_customer');
$customer_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 = $rendid.'_profile_photo.jpg';
$config1 = array(
'upload_path' => CUSTOMER_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'] = CUSTOMER_LOGO_PATH.'thumbs';
$config2['maintain_ratio'] = TRUE;
$config2['width'] = CUSTOMER_LOGO_WIDTH;
$config2['height'] = CUSTOMER_LOGO_HEIGHT;
$this->load->library('image_lib',$config2);
$this->image_lib->initialize($config2);
if ( !$this->image_lib->resize()) {
return false;
}
$result =$this->customersmanagement_model->GetCustomerDetails($customer_id);
if(file_exists(ADMIN_LOGO_PATH.'thumbs/'.$result['image_name']) && $result['image_name'] != '' && $result['image_name'] != CUSTOMER_DEFAULT_IMAGE)
{
if($result['image_name'] != CUSTOMER_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(
'image_name' => $new_name,
'image' => base_url().CUSTOMER_LOGO_PATH.'thumbs/'.$new_name
);
$this->db->trans_start();
$this->db->where('customer_id',$customer_id);
$this->db->update('rt_customer',$data_up);
$this->db->trans_complete();
$logged_in = $this->session->userdata('logged_in_customer');
$logged_in['customer_image'] = $new_name;
$this->session->set_userdata('logged_in_customer', $logged_in);
echo $new_name;
}
else {
$error = $this->upload->display_errors();
echo $error;
}
}
function favorites()
{
$session_data = $this->session->userdata('logged_in_customer');
$customer_id = $session_data['id'];
$data['title']="favorites";
$data['page']="favorites";
$query['fav_list'] = $this->customersmanagement_model->get_customer_fav($customer_id);
$data['pointDetails'] = $this->frontend_model->getRewardPoints($customer_id);
$data['rewardAvailability'] = $this->frontend_model->checkRewardPointStatus();
$this->load->view('customer/header',$data);
$this->load->view('customer/main-sidebar',$query);
$this->load->view('customer/favorites_page');
$this->load->view('customer/footer');
}
/*function DriverData()
{
$driver_id = $this->input->post('driver_id');
$DriverData = $this->customersmanagement_model->GetDriverDetails($driver_id);
$datatable='<option selected value="'.$DriverData['current_latitude'].', '.$DriverData['current_longitude'].'">Montreal, QBC</option>';
echo $datatable;
}*/
function restaurant_map_view()
{
$data['title']="Restaurant map view";
$data['page']="map_view";
$query['RestaurantList'] = $this->menumanagement_model->RestaurantList();
$this->load->view('customer/header',$data);
$this->load->view('customer/main-sidebar',$query);
$this->load->view('customer/map_view');
$this->load->view('customer/footer');
}
function DriverData()
{
$driverid = $this->input->post('driver_id');
$result = $this->dashboard_model->driver_location($driverid);
$data99['current_latitude'] = $result['current_latitude'];
$data99['current_longitude'] = $result['current_longitude'];
header('Content-Type: application/json');
echo json_encode($data99);
}
function cancelOrder() {
$orderid = $this->input->post('orderid');
$status = $this->input->post('status');
$orderShort = $this->createorder_model->orderShortDetails($orderid);
$orderLong = $this->createorder_model->orderLongDetails($orderid);
if ($status == 'Out for delivery') {
$this->db->select('restaurant_phone');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $orderShort->restaurant_id);
$restaurant_phone = $this->db->get()->row()->restaurant_phone;
echo 'Hi, this order is already left for delivery and will reach you soon. Please contact restaurant to cancel the order and get refund. Restaurant contact number: '.$restaurant_phone;
exit();
}
$now = date('Y-m-d H:i:s');
$update_order_status = array('status' => 'Refund Requested', 'refund_apply_time' => $now);
$this->db->trans_start();
$this->db->where('orderid', $orderid);
$this->db->update('rt_order', $update_order_status);
$this->db->trans_complete();
$cart_items = '';
if ($orderLong) {
foreach ($orderLong as $key => $value) {
$cart_items .= '<tr class="even" style="">';
$cart_items .= '<td style="text-align: center;">'.($key+1).'</td>';
if($value->addonsname != "")
{
$cart_items .= '<td style="text-align: center;">'.trim(htmlentities($value->menuname)).'<br /><span style="font-size: 12px;">'.trim(htmlentities($value->addonsname)).'</span></td>';
}
else {
$cart_items .= '<td style="text-align: center;">'.trim(htmlentities($value->menuname)).'</td>';
}
$cart_items .= '<td style="text-align: center;">'.$value->quantity.'</td>';
$cart_items .= '<td style="text-align: center;">$'.$value->menuprice.'</td>';
$cart_items .= '<td style="text-align: center;">$'.$value->tot_menuprice.'</td>';
$cart_items .= '</tr>';
}
}
/*echo "<pre>";
print_r ($orderShort);
print_r ($orderLong);
echo "</pre>";
exit();*/
if (isset($orderShort) && isset($orderLong)) {
/*echo "<pre>";
print_r ($orderShort);
print_r ($orderLong);
echo "</pre>";
exit();*/
$image_path = base_url().'assets/';
$variables = array();
$to = $orderShort->customeremail;
$customer_email = $orderShort->customeremail;
$this->db->select('restaurant_contact_email');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $orderShort->restaurant_id);
$restaurant_email = $this->db->get()->row()->restaurant_contact_email;
$admin_email = SITE_CONTACT_EMAIL;
$variables['order_id'] = 'ORD'.$orderShort->orderid;
$variables['customer_email'] = $orderShort->customeremail;
$variables['customer_name'] = $orderShort->customername.' '.$orderShort->customerlastname;
$variables['total_item_price_label'] = 'Item Price';
$variables['total_item_price'] = number_format($orderShort->menuprice_total, 2, '.', '');
$variables['tax_label'] = 'Tax('.$orderShort->tax_per.'%)';
$variables['tax_amount'] = number_format($orderShort->taxvalue, 2, '.', '');
$variables['sub_total_label'] = 'Sub Total';
$variables['sub_total_amount'] = number_format($orderShort->ordersubtotal, 2, '.', '');
$variables['delivery_charge_label'] = 'Delivery Charge';
$variables['delivery_charge_amount'] = number_format($orderShort->delivery_charged, 2, '.', '');
$variables['tips_label'] = 'Tips';
$variables['tips_amount'] = $orderShort->tip == ''?0.00:number_format($orderShort->tip, 2, '.', '');
$variables['offer_label'] = 'Coupon Discount';
$variables['offer_amount'] = number_format($orderShort->offervalue, 2, '.', '')==''?0.00:number_format($orderShort->offervalue, 2, '.', '');
$variables['point_label'] = "Reward Point Used";
$variables['point_amount'] = number_format($orderShort->point_amount, 2, '.', '')==''?0.00:number_format($orderShort->point_amount, 2, '.', '');
$variables['grand_total_label'] = 'Grand Total';
$variables['grand_total'] = number_format($orderShort->ordertotalprice, 2, '.', '');
$variables['cart_items'] = $cart_items;
$variables['image_path'] = $image_path;
$variables['to_email'] = $to;
//$variables['sender_email'] = SITE_CONTACT_EMAIL;
$variables['site_address'] = SITE_ADDRESS;
$variables['sender_name'] = SITENAME;
$variables['site_name'] = SITENAME;
$template_name = 'order_cancel';
$mail_data = $this->frontend_model->getEmailTemplate($template_name);
$mailcontent=htmlspecialchars_decode($mail_data->template);
$subject = $mail_data->subject;
foreach($variables as $key => $value) {
$mailcontent = str_replace('{{'.$key.'}}', $value, $mailcontent);
}
//Customer
$mail_body_text = 'Hi, You have requested successfully for refund. We will refund the order amount soon for the following order.';
$mailcontent_customer = str_replace('{{mail_body_text}}', $mail_body_text, $mailcontent);
$to = $customer_email;
//$to = 'earthtechnology7@gmail.com';
$this->send_my_mail($to,$subject,$mailcontent_customer);
//echo $mailcontent_customer;
//Restaurant & Admin
$mail_body_text = 'Hi, Refund request received for ORD'.$orderid.'.';
$mailcontent_other = str_replace('{{mail_body_text}}', $mail_body_text, $mailcontent);
$to = $restaurant_email;
//$to = 'earthtechnology7@gmail.com';
$this->send_my_mail($to,$subject,$mailcontent_other);
$to = $admin_email;
//$to = 'earthtechnology7@gmail.com';
$this->send_my_mail($to,$subject,$mailcontent_other);
//echo $mailcontent_other;
}
}
function openReview() {
// print_r($this->input->post());
$order_id = $this->input->post('order_id');
$reviewDetails = $this->customersmanagement_model->getReviewDetails($order_id);
// print_r($reviewDetails);
$myArray = array();
if ($reviewDetails) {
$myArray['rating'] = $reviewDetails['rating'];
$myArray['message'] = $reviewDetails['message'];
$myArray['status'] = $reviewDetails['status'];
}
echo json_encode($myArray);
}
function addReview() {
// print_r($this->input->post());
$now = date('Y-m-d H:i:s');
$review_orderid = $this->input->post('review_orderid');
$review_rating = $this->input->post('review_rating');
$review_message = $this->input->post('review_message');
$review_restaurantid = $this->input->post('review_restaurantid');
if ($this->session->userdata('logged_in_customer')) {
$customer_id = $this->session->userdata('logged_in_customer')['id'];
}
$this->db->trans_start();
$this->db->where('order_id', $review_orderid);
$this->db->delete('rt_restaurant_reviews');
$data_in = array(
'order_id' => $review_orderid,
'rating' => $review_rating == '' ? 0 : $review_rating,
'message' => $review_message,
'restaurant_id' => $review_restaurantid,
'customer_id' => $customer_id,
'status' => '0',
'addeddate' => $now
);
$this->db->insert('rt_restaurant_reviews', $data_in);
$this->db->trans_complete();
}
function send_my_mail($mail_To,$mail_subject,$mail_Body,$mail_CC="")
{
$mail_From = SITENAME;
$mail = new PHPMailer();
//Your SMTP servers details
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = SMTP_HOST; // specify main and backup server or localhost
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = SMTP_USER; // SMTP username
$mail->Password = SMTP_PASSWORD; // SMTP password It should be same as that of the SMTP user
//$mail->PluginDir = "/home/phpaucti/public_html/website_development/coding/includes/";
$mail->From = $mail->Username; //Default From email same as smtp user
$mail->FromName = $mail_From;
$emailArr = explode(',', $mail_To);
foreach ($emailArr AS $emailVal) {
$mail->AddAddress($emailVal, ""); //Email address where you wish to receive/collect those emails.
}
/*$emailCCArr = explode(',',$mail_CC);
foreach($emailCCArr AS $emailCCVal) {
$mail->AddCC($emailCCVal, ""); //Email address where you wish to receive/collect those emails.
}*/
$mail->WordWrap = 100; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $mail_subject;
$message = $mail_Body;
$mail->Body = $message;
if (!$mail->Send()) {
/*echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;*/
} else {
//echo 'ok';
}
}
function redeemvoucher()
{
//print_r($this->session->userdata["logged_in_customer"]["id"]);
if ($this->input->server('REQUEST_METHOD') == 'POST') {
$customer_name = $this->session->userdata["logged_in_customer"]["username"];
$customer_id = $this->session->userdata["logged_in_customer"]["id"];
$voucherAmount = $this->input->post('voucher_amount');
$partnerName = $this->input->post('partner_name');
$voucherPoint = $this->input->post('voucher_point');
$this->db->select('customer_email');
$this->db->from('rt_customer');
$this->db->where('customer_id', $customer_id);
$customer_email = $this->db->get()->row()->customer_email;
$this->frontend_model->deductPoint($customer_id, 0, $voucherPoint);
/*EMAIL TEMPLATES*/
$variables = array();
$image_path = base_url() . 'assets/';
$variables['site_address'] = SITE_ADDRESS;
$variables['sender_name'] = SITENAME;
$variables['site_name'] = SITENAME;
$variables['image_path'] = $image_path;
$variables['to_email'] = $customer_email;
$template_name = 'redemption_email';
$mail_data = $this->frontend_model->getEmailTemplate($template_name);
$mailcontent = htmlspecialchars_decode($mail_data->template);
$subject = $mail_data->subject;
foreach ($variables as $key => $value) {
$mailcontent = str_replace('{{' . $key . '}}', $value, $mailcontent);
}
//Customer
$mail_body_text = 'Hi '.$customer_name.',<br/>Thanks for your redemption. The '.$partnerName." ".SITENAME_CURRENCY.$voucherAmount.' voucher will be email to you within the next 3 working days.<br/><br/>If you do not receive after 3 days, or have any further inquiries, please email us at '.SITE_FEEDBACK_EMAIL;
$mailcontent_customer = str_replace('{{mail_body_text}}', $mail_body_text, $mailcontent);
//$to = 'earthtechnology7@gmail.com';
$this->send_my_mail($customer_email, $subject, $mailcontent_customer);
$this->send_my_mail(SITE_FEEDBACK_EMAIL, $subject, $mailcontent_customer);
//$this->send_my_mail("earthtechnology10@gmail.com", $subject, $mailcontent_customer);
}
$data['title']="Redeem Voucher";
$data['page']="redeem_voucher";
$query['RedeemVouchers'] = $this->getAllRedeemVouchers();
$data['pointDetails'] = $this->frontend_model->getRewardPoints($this->session->userdata["logged_in_customer"]["id"]);
$data['rewardAvailability'] = $this->frontend_model->checkRewardPointStatus();
$this->load->view('customer/header',$data);
$this->load->view('customer/main-sidebar',$query);
$this->load->view('customer/redeem');
$this->load->view('customer/footer');
}
function getAllRedeemVouchers()
{
$pointDetails = $this->frontend_model->getRewardPoints($this->session->userdata["logged_in_customer"]["id"]);
$point = $pointDetails["points"];
$this->db->select('rt_reward_partner.partner_name, rt_rewards.*');
$this->db->from('rt_rewards');
$this->db->join('rt_reward_partner','rt_reward_partner.id = rt_rewards.partner_id', "LEFT");
$this->db->where('rt_rewards.status', "1");
$this->db->where('rt_rewards.redemption_point <=', $point);
$this->db->order_by('rt_rewards.redemption_amount', 'DESC');
$query = $this->db->get();
//echo $this->db->last_query();
return ($query->num_rows() > 0)?$query->result_array():array();
}
}