| 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/www/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
require_once APPPATH."third_party/Services/Twilio.php";
class Superadmin extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('user','',TRUE);
$this->load->helper("url");
$this->load->helper('form');
$this->load->helper('cookie');
$this->load->library('session');
$this->load->model('dashboard_model');
$this->load->model('menumanagement_model');
$this->load->model('restaurantmanagement_model');
$this->load->model('customersmanagement_model');
$this->load->model('driver_model');
$this->load->model('frontend_model');
$this->load->model('notification_model');
$this->load->library('m_pdf');
$this->load->library('excel');
$session_data = $this->session->userdata('logged_in');
// $session_set_value = $this->session->all_userdata();
// Check for remember_me data in retrieved session data
//if (isset($session_set_value['remember_me']) && $session_set_value['remember_me'] == "1")
// {
// redirect('superadmin/dashboard', 'refresh');
// }
// print_r($this->session->userdata('logged_in'));
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('superAdmin', $language);
}
//if(empty($session_data)) { redirect('login', 'refresh'); }
function index( $offset = 0 )
{
// print_r($this->session->userdata('logged_in'));
//$cookieData = $this->input->cookie('remember_me_token_superadmin', TRUE);
$cookieData = $this->input->cookie('remember_me_token_superadmin');
$data['username'] = '';
$data['password'] = '';
$data['ischecked'] = '';
//print_r($cookieData);
//exit();
if ($cookieData != "") {
$result = $this->user->login_cookie($cookieData);
if($result)
{
$sess_array = array();
foreach($result as $row)
{
$admin_id = $row->admin_id;
$data['username'] = $row->username;
$data['password'] = $row->password;
$data['ischecked'] = 'checked';
}
}
}
$session_data = $this->session->userdata('logged_in');
if(empty($session_data)) {
$this->load->view('superadmin/login',$data);
}else{
redirect('superadmin/dashboard');
}
}
function forgot_password()
{
$this->load->view('superadmin/forgot_password');
}
function logout()
{
$this->session->unset_userdata('logged_in');
//session_destroy();
//$this->input->set_cookie('remember_me_token_superadmin', '');
redirect('superadmin', 'refresh');
}
function updateRefundCount() {
$this->db->select('orderid');
$this->db->from('rt_order');
$this->db->where('status', 'Refund Requested');
if ($this->session->userdata('logged_in_restaurant')) {
$this->db->where('restaurant_id', $this->session->userdata('logged_in_restaurant')['id']);
}
$query = $this->db->get();
echo $query->num_rows();
}
function refundNotification() {
$now = date('Y-m-d H:i:s');
$nowMinusOne = strtotime($now);
$nowMinusOne = $nowMinusOne - (1 * 10);
$nowMinusOne = date("Y-m-d H:i:s", $nowMinusOne);
$this->db->select('orderid');
$this->db->from('rt_order');
$this->db->where('status', 'Refund Requested');
$this->db->where('refund_apply_time >=', $nowMinusOne);
$this->db->where('refund_apply_time <=', $now);
if ($this->session->userdata('logged_in_restaurant')) {
$this->db->where('restaurant_id', $this->session->userdata('logged_in_restaurant')['id']);
}
$query = $this->db->get();
echo $query->num_rows();
}
function ChangeActiveInactive()
{
$table = $this->input->post('table');
$status = $this->input->post('status');
$id = $this->input->post('id');
$NeedVerification = false;
$IsRestaurant = false;
if ($this->session->userdata('logged_in_restaurant')) {
$IsRestaurant = true;
$restaurant_id = $this->session->userdata('logged_in_restaurant')['id'];
}
switch ($table) {
case "rt_cuisine":
$StatusField = 'cuisine_status';
$IdField = 'cuisine_id';
break;
case "rt_category_main":
$StatusField = 'status';
$IdField = 'maincateid';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_state":
$StatusField = 'state_status';
$IdField = 'state_id';
break;
case "rt_city":
$StatusField = 'city_status';
$IdField = 'city_id';
break;
case "rt_restaurant_menu":
$StatusField = 'status';
$IdField = 'id';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_restaurant_addons":
$StatusField = 'status';
$IdField = 'id';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_restaurant_offer":
$StatusField = 'status';
$IdField = 'offer_id';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_customer":
$StatusField = 'status';
$IdField = 'customer_id';
break;
case "rt_zipcode":
$StatusField = 'zipcode_status';
$IdField = 'zipcode_id';
break;
case "rt_driver":
$StatusField = 'driver_status';
$IdField = 'driver_id';
break;
case "rt_restaurant_reviews":
$StatusField = 'status';
$IdField = 'rating_id';
break;
case "rt_faq":
$StatusField = 'faq_status';
$IdField = 'faq_id';
break;
case "rt_restaurant":
$StatusField = 'restaurant_status';
$IdField = 'restaurant_id';
break;
case "rt_coupon":
$StatusField = 'coupon_status';
$IdField = 'coupon_id';
break;
case "rt_rewards":
$StatusField = 'status';
$IdField = 'id';
break;
case "rt_reward_partner":
$StatusField = 'status';
$IdField = 'id';
break;
default:
}
$this->db->trans_start();
$data_up= array( $StatusField => $status );
$this->db->where($IdField,$id);
if ($NeedVerification == true && $IsRestaurant == true) {
$this->db->where('restaurant_id', $restaurant_id);
}
$this->db->update($table,$data_up);
$this->db->trans_complete();
$affectedrows = $this->db->affected_rows();
echo $affectedrows;
//return TRUE;
}
function DeleteNow()
{
$table = $this->input->post('table');
$id = $this->input->post('id');
$NeedVerification = false;
$IsRestaurant = false;
if ($this->session->userdata('logged_in_restaurant')) {
$IsRestaurant = true;
$restaurant_id = $this->session->userdata('logged_in_restaurant')['id'];
}
switch ($table) {
case "rt_cuisine":
$IdField = 'cuisine_id';
break;
case "rt_state":
$IdField = 'state_id';
break;
case "rt_city":
$IdField = 'city_id';
break;
case "rt_category_main":
$IdField = 'maincateid';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_restaurant_menu":
$IdField = 'id';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_restaurant_addons":
$IdField = 'id';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_restaurant_offer":
$IdField = 'offer_id';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_customer":
$IdField = 'customer_id';
break;
case "rt_zipcode":
$IdField = 'zipcode_id';
break;
case "rt_driver":
$IdField = 'driver_id';
break;
case "rt_restaurant_reviews":
$IdField = 'rating_id';
break;
case "rt_payment":
$IdField = 'payment_id';
break;
case "rt_faq":
$StatusField = 'faq_status';
$IdField = 'faq_id';
break;
case "rt_restaurant":
$IdField = 'restaurant_id';
break;
case "rt_order":
$IdField = 'orderid';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_coupon":
$IdField = 'coupon_id';
break;
case "rt_rewards":
$IdField = 'id';
break;
case "rt_reward_partner":
$IdField = 'id';
break;
default:
}
$this->db->where($IdField, $id);
if ($NeedVerification == true && $IsRestaurant == true) {
$this->db->where($RestaurantIdField, $restaurant_id);
}
$this->db->delete($table);
return $this->db->affected_rows() > 0;
}
function DeleteNowCondition()
{
$table = $this->input->post('table');
$id = $this->input->post('id');
$why = $this->input->post('why');
$default_msg = "want to delete this data?";
$NeedVerification = false;
$IsRestaurant = false;
if ($this->session->userdata('logged_in_restaurant')) {
$IsRestaurant = true;
$restaurant_id = $this->session->userdata('logged_in_restaurant')['id'];
}
switch ($table) {
case 'rt_category_main':
$IdField = 'maincateid';
$SubTable = 'rt_restaurant_menu';
$SubTableMatchField = 'menu_category';
$SubTableUpdateField = 'status';
$SubTableUpdateFieldData = '0';
$special_msg = 'Menu items do exist in this category. If you delete this, menu items will unlink with this category. If you still want to delete this category, please press "Ok".';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
case "rt_city":
$IdField = 'city_id';
$SubTable = 'rt_zipcode';
$SubTableMatchField = 'cityid';
$SubTableUpdateField = 'zipcode_status';
$SubTableUpdateFieldData = '0';
$special_msg = 'Postcode do exist in this city. If you delete this, postcodes will unlink with this city. If you still want to delete this city, please press "Ok".';
break;
default:
# code...
break;
}
if ($why == 'check') {
$this->db->select('*');
$this->db->from($SubTable);
$this->db->where($SubTableMatchField, $id);
$query = $this->db->get();
if ($query->num_rows > 0) {
echo $special_msg;
}
else {
echo $default_msg;
}
}
else if ($why == 'delete') {
$this->db->where($IdField, $id);
if ($NeedVerification == true && $IsRestaurant == true) {
$this->db->where($RestaurantIdField, $restaurant_id);
}
$this->db->delete($table);
$data_up = array($SubTableUpdateField => $SubTableUpdateFieldData);
$this->db->where($SubTableMatchField, $id);
if ($NeedVerification == true && $IsRestaurant == true) {
$this->db->where($RestaurantIdField, $restaurant_id);
}
$this->db->update($SubTable, $data_up);
echo $this->db->affected_rows() > 0;
}
}
function ChangePopuler()
{
$table = $this->input->post('table');
$status = $this->input->post('status');
$id = $this->input->post('id');
$NeedVerification = false;
$IsRestaurant = false;
if ($this->session->userdata('logged_in_restaurant')) {
$IsRestaurant = true;
$restaurant_id = $this->session->userdata('logged_in_restaurant')['id'];
}
switch ($table) {
case "rt_cuisine":
$StatusField = 'cuisine_popular_dish';
$IdField = 'cuisine_id';
break;
case "rt_restaurant_menu":
$StatusField = 'menu_popular_dish';
$IdField = 'id';
$NeedVerification = true;
$RestaurantIdField = 'restaurant_id';
break;
default:
}
$this->db->trans_start();
$data_up= array( $StatusField => $status );
$this->db->where($IdField,$id);
if ($NeedVerification == true && $IsRestaurant == true) {
$this->db->where($RestaurantIdField, $restaurant_id);
}
$this->db->update($table,$data_up);
$this->db->trans_complete();
return TRUE;
}
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);
// date_default_timezone_set('America/Denver');
$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'];
// $deliveryoption = $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;">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>*/
//.......................................................................................................................................................
return $pdf_content;
}
function order_export($restaurant_id=0, $action = '', $action2 = 0, $action3 = '')
{
/*if($this->session->userdata('logged_in_restaurant')){
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
}else{
$restaurant_id = 0;
}*/
$order_list = $this->menumanagement_model->get_order_list($params = array(), $action, $action2, $action3 ='',$restaurant_id);
$restaurant_name = "All restaurant";
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('Norecordfoundof').' '.$restaurant_name);
//redirect('coupon/redeem_coupon', 'refresh');
}
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 Time');
/*$this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Date');*/
$this->excel->getActiveSheet()->setCellValue('D3', 'Order 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['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_export_refund($restaurant_id=0, $action = '', $action2 = 0, $action3 = '')
{
/*if($this->session->userdata('logged_in_restaurant')){
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
}else{
$restaurant_id = 0;
}*/
if ($action != '5' && $action != '6') {
$action3 = 'RR';
}
else {
$action3 = '';
}
$order_list = $this->menumanagement_model->get_order_list($params = array(), $action, $action2, $action3, $restaurant_id);
$restaurant_name = "All restaurant";
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('Norecordfoundof').' '.$restaurant_name);
//redirect('coupon/redeem_coupon', 'refresh');
}
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('d-m-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 Time');
/*$this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Date');*/
$this->excel->getActiveSheet()->setCellValue('D3', 'Order 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['name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, date("d.m.Y g:i A", strtotime($value['orderdate'])));
/*$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, date('d.m.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 ChangeOrderStatus()
{
$order_id = $this->input->post('order_id');
$order_status = $this->input->post('order_status');
$this->db->trans_start();
$data_up= array( 'status' => $order_status );
$this->db->where('orderid',$order_id);
$this->db->update('rt_order',$data_up);
$this->db->trans_complete();
$this->notifyRestaurant($order_id, $order_status);
return TRUE;
}
function payRewardBonus($user_id = 0, $point = 0)
{
$this->frontend_model->payRewardPoint($user_id, $point);
}
function notifyRestaurant($orderid, $order_status) {
$now = date('Y-m-d H:i:s');
$nowTime = date('H:i');
$this->db->select('restaurant_id, customer_id, point_amount, ordertotalprice, deliverytype, restaurant_name, customername, customerlastname, customercellphone, ordergenerateid');
$this->db->from('rt_order');
$this->db->where('orderid', $orderid);
$query = $this->db->get();
$ordDetails = $query->row_array();
$restaurant_id = $ordDetails['restaurant_id'];
$this->db->select('order_push_token_android');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $restaurant_id);
$query = $this->db->get();
$restDetails = $query->row_array();
$message = 'Order status has been updated by '.SITENAME.'. Please check.';
$generatedOrderID = "#".$ordDetails['ordergenerateid'];
$notification_param = array();
$param = array();
$param['browse_url'] = "";
$param['has_url'] = "false";
if ($order_status == 'In Preparation') {
$message = $generatedOrderID.' is In Preparation';
}
else if ($order_status == 'Out For Delivery') {
$message = $generatedOrderID.' is Out For Delivery';
$param['browse_url'] = BASE_URL."track.php?id=".$orderid;
$param['has_url'] = "true";
}
else if ($order_status == 'Delivered') {
$message = $generatedOrderID.' is Delivered';
$variables=array(
'{SERVICE_NAME}'=>($ordDetails['deliverytype'] == "Delivery" ? "delivered by ": ($ordDetails['deliverytype'] == "pickup" ? "picked up from" : "completed by ")),
'{ORDER_ID}'=>$generatedOrderID,
'{SITENAME}'=>SITENAME,
'{RESTAURANT_NAME}'=>$ordDetails['restaurant_name'],
'{CUSTOMER_NAME}'=>$ordDetails['customername']." ".$ordDetails['customerlastname']
);
$description = $this->config->item("MSG")["ORDER_PROCESS_NOTIFY_CUSTOMER"];
$sms_content_customer = $this->notification_model->EmailSendArray($description, $variables);//replace varibles
$notification_param = array("to"=>$ordDetails["customercellphone"],
"message"=>$sms_content_customer);
$this->frontend_model->payRewardPoint($ordDetails["customer_id"], $ordDetails["ordertotalprice"]);
}
else if ($order_status == 'Rejected') {
$message = $generatedOrderID.' is Rejected by '.SITENAME;
$this->frontend_model->payRewardPoint($ordDetails["customer_id"], 0, $ordDetails["point_amount"]);
}
else if ($order_status == 'Missed') {
$message = $generatedOrderID.' is Missed';
}
$notificationsubjectCustomer = "The order( ".$generatedOrderID." ) is ".$order_status.". ".SITENAME;
if($order_status == 'Rejected' || $order_status == 'Cancelled')
{
$notificationsubjectCustomer = "Sorry, the order( ".$generatedOrderID." ) is ".$order_status.". ".SITENAME;
}
$notificationsubjectSuperAdmin = "Dear ".SITENAME." Admin - status of order( ".$generatedOrderID." ) is ".$order_status;
$notificationsubjectRestaurantAdmin = "Dear Restaurant Admin - status of order( ".$generatedOrderID." ) is ".$order_status;
$param['push_notif_message'] = $notificationsubjectCustomer;
if ($order_status == 'Delivered') {
$param['push_notif_message'] = $sms_content_customer;
}
else if ($order_status == 'Out For Delivery') {
$param['push_notif_message'] = "Your order ".generatedOrderID." is out for delivery. Track your order: ".BASE_URL."track.php?id=".$orderid;
}
$param['orderid'] = $orderid;
$param['msg_to'] = "customer";
$this->notification_model->sendPushMessage($param);
$this->notification_model->sendSMSNotification($notification_param);
return true;
}
function ChangeInvoiceStatus()
{
$invoice_id = $this->input->post('invoice_id');
$status = $this->input->post('status');
$tbl = $this->input->post('tbl');
$this->db->trans_start();
$data_up= array( 'status' => $status );
$this->db->where('invoice_id',$invoice_id);
if($tbl==1)
{
$this->db->update('restaurant_invoice',$data_up);
}
if($tbl==2)
{
$this->db->update('driver_invoice',$data_up);
}
$this->db->trans_complete();
return TRUE;
}
function GetCityByState()
{
$state_id = $this->input->post('state_id');
$GetCityByState = $this->dashboard_model->GetCityByState($state_id);
$data_table ='';
if(is_array($GetCityByState) && sizeof($GetCityByState)>0)
{
foreach($GetCityByState as $row)
{
$data_table .='<option value='.$row->city_id.'>'.$row->cityname.'</option>';
}
$data99['option_redemp']=$data_table;
}else{
$data_table .='<option value='.''.'>No city found!!</option>';
}
echo $data_table;
}
function delete_res_logo()
{
$restaurant_id = $this->input->post('restaurant_id');
$this->db->trans_start();
$data_up= array( 'restaurant_logo' => '' );
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_up);
$this->db->trans_complete();
return TRUE;
}
function fetchCategoryByRest() {
$restaurant_id = $this->input->post('restaurant_id');
$this->db->trans_start();
$this->db->select('*');
$this->db->from('rt_category_main');
$this->db->where('restaurant_id', $restaurant_id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
$data = $query->result();
}
else {
$data = FALSE;
}
$this->db->trans_complete();
if ($data) {
$myHtml = '<option>Select Category</option>';
foreach ($data as $key => $value) {
$myHtml .= '<option value="'.$value->maincateid.'">'.$value->maincatename.'</option>';
}
}
else {
$myHtml = '<option>No Category found</option>';
}
echo $myHtml;
}
function order_export_restaurant($restaurant_id=0, $action)
{
/*if($this->session->userdata('logged_in_restaurant')){
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
}else{
$restaurant_id = 0;
}*/
$order_list = $this->menumanagement_model->get_order_list_restaurant($params = array(), $action, $action2 =0, $action3 ='',$restaurant_id);
$restaurant_name = "All restaurant";
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('Norecordfoundof').' '.$restaurant_name);
//redirect('coupon/redeem_coupon', 'refresh');
}
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('d-m-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 Time');
/*$this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Date');*/
$this->excel->getActiveSheet()->setCellValue('D3', 'Order 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['name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, date("d.m.Y g:i A", strtotime($value['orderdate'])));
/*$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, date('d.m.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_export_restaurant_refund($restaurant_id=0, $action = '')
{
/*if($this->session->userdata('logged_in_restaurant')){
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
}else{
$restaurant_id = 0;
}*/
if ($action != '5' && $action != '6') {
$action3 = 'RR';
}
else if ($action == '99999') {
$action3 = 'RR';
}
else {
$action3 = '';
}
$order_list = $this->menumanagement_model->get_order_list_restaurant($params = array(), $action, $action2 =0, $action3,$restaurant_id);
$restaurant_name = "All restaurant";
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('Norecordfoundof').' '.$restaurant_name);
//redirect('coupon/redeem_coupon', 'refresh');
}
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('d-m-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 Time');
/*$this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Date');*/
$this->excel->getActiveSheet()->setCellValue('D3', 'Order 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['name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, date("d.m.Y g:i A", strtotime($value['orderdate'])));
/*$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, date('d.m.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 driver_schedule_export($searchScheduleDate) {
// $searchScheduleDate = $this->input->post('searchScheduleDate');
$Driverlist = $this ->driver_model->DriverAvailableList($searchScheduleDate);
$this->excel->getActiveSheet()->setCellValue('A1', 'Date:');
$this->excel->getActiveSheet()->setCellValue('B1', date('d-m-Y'));
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('order_export');
$this->excel->getActiveSheet()->setCellValue('A3', 'Driver Name');
$this->excel->getActiveSheet()->setCellValue('B3', 'Schedule Time');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($Driverlist as $key => $value) {
$schedule_time_from = date("g:i A", strtotime($value->schedule_time_from));
$schedule_time_to = date("g:i A", strtotime($value->schedule_time_to));
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value->driver_first_name.' '.$value->driver_last_name);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, $schedule_time_from.'-'.$schedule_time_to);
$data_row++;
}
$filename='driver_schedule_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 previewAgreement($restaurant_id) {
/*$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];*/
if($restaurant_id!=0 )
{
$query['data'] =$this->restaurantmanagement_model->GetRestauratDetails($restaurant_id);
//$restaurant_state=isset($query['data']['restaurant_state']) ? $data['restaurant_state'] : '';
$restaurant_state= $query['data']['restaurant_state'];
//echo $restaurant_state;
//exit();
$query['CityList'] =$this->dashboard_model->GetCityByState($restaurant_state);
}
$data['admin_data'] =$this->dashboard_model->get_website_settings();
if (isset($query['data']['restaurant_city'])) {
$this->db->select('cityname');
$this->db->from('rt_city');
$this->db->where('city_id', $query['data']['restaurant_city']);
$myCityQuery = $this->db->get();
if ($myCityQuery->num_rows() > 0) {
$myCity = ', '.$myCityQuery->row()->cityname;
}
else {
$myCity = '';
}
}
else {
$myCity = '';
}
if (isset($query['data']['restaurant_state'])) {
$this->db->select('statename');
$this->db->from('rt_state');
$this->db->where('statecode', $query['data']['restaurant_state']);
$myStateQuery = $this->db->get();
if ($myStateQuery->num_rows() > 0) {
$myState = ', '.$myStateQuery->row()->statename;
}
else {
$myState = '';
}
}
else {
$myState = '';
}
$variables['effective_date'] = date("F j, Y");
$variables['restaurant_name'] = $query['data']['restaurant_name'];
$variables['restaurant_address'] = $query['data']['restaurant_streetaddress'].''.$myCity.''.$myState.', '.$query['data']['restaurant_zip'];
$variables['commission_amount'] = $data['admin_data']['agreement_pay_commission'];
$variables['commission_pay_date'] = $data['admin_data']['agreement_pay_date'];
$myContent = htmlspecialchars_decode($data['admin_data']['agreement']);
foreach($variables as $key => $value) {
$myContent = str_replace('{{'.$key.'}}', '<b>'.$value.'</b>', $myContent);
}
$pdfContent = $myContent;
$this->m_pdf->pdf->list_indent_first_level = 0;
$this->m_pdf->pdf->useOnlyCoreFonts = true;
$this->m_pdf->pdf->WriteHTML($pdfContent,2);
$this->m_pdf->pdf->Output(SITENAME.'agreement.pdf','D');
}
function searchRestaurant() {
$userSearchKey = $this->input->post('userSearchKey');
$this->db->select('restaurant_id, restaurant_name');
$this->db->from('rt_restaurant');
$this->db->like('restaurant_name', $userSearchKey, 'both');
$this->db->where('restaurant_validate', '1');
$this->db->limit('10');
$query = $this->db->get();
$data = $query->result();
if ($query->num_rows() > 0) {
foreach ($data as $key => $value) {
echo "<div style=\"\" class=\"suggestionlist\" onclick=\"setRestDetails('".$value->restaurant_id."', '".addslashes($value->restaurant_name)."')\">".$value->restaurant_name."</div>";
}
}
}
function searchDriver() {
$userSearchKey = $this->input->post('userSearchKey');
// $spacePosition = strrpos($userSearchKey, " ");
// if ($spacePosition) {
// $name = str_split($userSearchKey, $spacePosition);
// $driver_first_name = $name[0];
// $driver_last_name = $name[1];
// }
$this->db->select('driverid, driver_first_name, driver_middle_name, driver_last_name');
$this->db->from('driver_invoice');
$this->db->like('driver_first_name', $userSearchKey, 'both');
$this->db->group_by('driver_first_name');
// $this->db->like('driver_middle_name', $userSearchKey, 'both');
// $this->db->like('driver_last_name', $userSearchKey, 'both');
// if (isset($driver_first_name) && isset($driver_last_name)) {
// $this->db->like('driver_first_name', $driver_first_name, 'both');
// $this->db->like('driver_last_name', $driver_last_name, 'both');
// }
// else {
// $this->db->like('driver_first_name', $userSearchKey, 'both');
// }
$this->db->limit('10');
$query = $this->db->get();
$data = $query->result();
if ($query->num_rows() > 0) {
foreach ($data as $key => $value) {
$driverName = $value->driver_first_name;
if ($value->driver_middle_name != '') {
$driverName .= ' '.$value->driver_middle_name;
}
$driverName .= ' '.$value->driver_last_name;
echo "<div style=\"\" class=\"suggestionlist\" onclick=\"setDrivDetails('".$value->driverid."', '".addslashes($driverName)."')\">".$driverName."</div>";
}
}
}
function searchMenu() {
$userSearchKey = $this->input->post('userSearchKey');
$restaurant_id = $this->input->post('restaurant_id');
$this->db->select('id, restaurant_id, menu_name');
$this->db->from('rt_restaurant_menu');
$this->db->like('menu_name', $userSearchKey, 'both');
if ($this->session->userdata('logged_in_restaurant')) {
$this->db->where('restaurant_id', $this->session->userdata('logged_in_restaurant')['id']);
}
else if ($restaurant_id != 0 && $restaurant_id != '') {
$this->db->where('restaurant_id', $restaurant_id);
}
$this->db->limit('10');
$query = $this->db->get();
$data = $query->result();
if ($query->num_rows() > 0) {
foreach ($data as $key => $value) {
echo "<div style=\"\" class=\"suggestionlist\" onclick=\"setMenuDetails('".$value->id."', '".addslashes($value->menu_name)."')\">".$value->menu_name."</div>";
}
}
}
function searchOrder() {
$userSearchKey = $this->input->post('userSearchKey');
$this->db->select('orderid, ordergenerateid');
$this->db->from('rt_order');
$this->db->like('ordergenerateid', $userSearchKey, 'both');
if ($this->session->userdata('logged_in_restaurant')) {
$this->db->where('restaurant_id', $this->session->userdata('logged_in_restaurant')['id']);
}
$this->db->limit('10');
$query = $this->db->get();
$data = $query->result();
if ($query->num_rows() > 0) {
foreach ($data as $key => $value) {
echo "<div style=\"\" class=\"suggestionlist\" onclick=\"setOrderDetails('".$value->orderid."', '".addslashes($value->ordergenerateid)."')\">".$value->ordergenerateid."</div>";
}
}
}
function searchDriverSchedule() {
$userSearchKey = $this->input->post('userSearchKey');
$searchScheduleDate = $this->input->post('searchScheduleDate');
$this->db->select('rt_driver.driver_id, rt_driver.driver_first_name, rt_driver.driver_last_name, rt_driver.driver_availability_status');
$this->db->from('rt_driver_available_schedule');
$this->db->join('rt_driver', 'rt_driver.driver_id = rt_driver_available_schedule.driver_id');
$this->db->where('schedule_date', $searchScheduleDate);
$this->db->like('rt_driver.driver_first_name', $userSearchKey, 'both');
$this->db->limit('10');
$query = $this->db->get();
$data = $query->result();
if ($query->num_rows() > 0) {
foreach ($data as $key => $value) {
echo "<div style=\"\" class=\"suggestionlist\" onclick=\"setDriverDetails('".$value->driver_id."', '".addslashes($value->driver_first_name." ".$value->driver_last_name)."')\">".$value->driver_first_name." ".$value->driver_last_name."</div>";
}
}
}
}