| Server IP : 162.214.74.102 / Your IP : 216.73.217.103 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_projetos/sopizzas/application/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 Dashboard extends MY_Controller {
function __construct()
{
parent::__construct();
$this->load->helper("url");
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('javascript');
$this->load->model('dashboard_model');
$this->load->model('menumanagement_model');
$this->load->model('restaurantmanagement_model');
$this->load->model('customersmanagement_model');
$this->load->model('driver_model');
$this->load->model('createorder_model');
$this->load->model('frontend_model');
$this->load->library('myemail');
$this->perPage = ROW_PER_PAGE;
$this->load->library('m_pdf');
$this->load->library('excel');
$session_data = $this->session->userdata('logged_in');
//print_r($this->session->userdata('logged_in'));
//if(empty($session_data)) { redirect('superadmin', 'refresh'); }
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);
}
function index( $offset = 0 )
{
//$data99 =$this->dashboard_model->DashboardOrderStatistics($status='Pending',$addeddate='year');
//echo "t: ".$data99 ;
//exit();
// print_r($this->session->userdata('logged_in'));
$data['title']="Dashboard";
$data['page']="dashboard";
$data['TotalOrder']=$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='');
$data['TotalUsers']=$this->dashboard_model->get_total_customer($status='',$addeddate='');
$data['TotalMerchant']=$this->dashboard_model->get_total_merchant();
$data['TotalCommission']=$this->dashboard_model->get_total_commission();
$this->load->view('superadmin/header',$data);
$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/dashboard');
$this->load->view('superadmin/footer');
}
function live_feed()
{
$data99['TotalUsers'] =$this->dashboard_model->get_total_customer($status='');
$data99['ActiveUsers'] =$this->dashboard_model->get_total_customer($status='1');
$data99['InactiveUsers'] =$this->dashboard_model->get_total_customer($status='0');
$data99['UserJoinedThisWeek'] =$this->dashboard_model->get_total_customer($status='',$addeddate='week');
$data99['UserJoinedThisMonth'] =$this->dashboard_model->get_total_customer($status='',$addeddate='month');
$data99['UserJoinedThisYear'] =$this->dashboard_model->get_total_customer($status='',$addeddate='year');
$data99['TotalMerchant'] =$this->dashboard_model->get_total_merchant($status='');
$data99['ActiveRestaurants'] =$this->dashboard_model->get_total_merchant($status='1');
$data99['InactiveRestaurants'] =$this->dashboard_model->get_total_merchant($status='0');
$data99['PendingRestaurants'] =$this->dashboard_model->get_total_merchant($status='2');
$data99['RestaurantsJoinedWeek'] =$this->dashboard_model->get_total_merchant($status='',$addeddate='week');
$data99['RestaurantsJoinedMonth']=$this->dashboard_model->get_total_merchant($status='',$addeddate='month');
$data99['RestaurantsJoinedYear'] =$this->dashboard_model->get_total_merchant($status='',$addeddate='year');
$data99['DashboardtopDiscountRestaurants'] =$this->dashboard_model->DashboardtopDiscountRestaurants();
//Order Statistics
$data99['TotalOrder']=$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='');
$data99['DashboardLastOrders'] =$this->dashboard_model->DashboardLastOrders();
// Order Statistics -- Today
$data99['OrdersToday'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='today');
$data99['SalesToday'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='today');
$data99['DeliveredOrderToday'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='today');
$data99['PendingOrderToday'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='today');
// Order Statistics -- Week
$data99['OrdersWeek'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='week');
$data99['SalesWeek'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='week');
$data99['DeliveredOrderWeek'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='week');
$data99['PendingOrderWeek'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='week');
// Order Statistics -- Month
$data99['OrdersMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='month');
$data99['SalesMonth'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='month');
$data99['DeliveredOrderMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='month');
$data99['PendingOrderMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='month');
// Order Statistics -- Year
$data99['OrdersYear'] =$this->dashboard_model->DashboardOrderStatistics($status='',$addeddate='year');
$data99['SalesYear'] =$this->dashboard_model->DashboardSalesStatistics($status='Delivered',$addeddate='year');
$data99['DeliveredOrderYear'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='year');
$data99['PendingOrderYear'] =$this->dashboard_model->DashboardOrderStatistics($status='In Preparation',$addeddate='year');
$data99['e_Wallet'] =$this->dashboard_model->e_Wallet();
// echo $TotalOrder;
header('Content-Type: application/json');
echo json_encode($data99);
}
function eWallet()
{
$data99['e_Wallet'] =$this->dashboard_model->e_Wallet();
// echo $TotalOrder;
header('Content-Type: application/json');
echo json_encode($data99);
}
function rnd()
{
$first_day_this_month = date('Y-m-01'); // hard-coded '01' for first day
$last_day_this_month = date('Y-m-t');
echo $last_day_this_month;
}
function ChangeActiveInactive()
{
$table = $this->input->post('table');
$status = $this->input->post('status');
$id = $this->input->post('id');
switch ($table) {
case "rt_cuisine":
$StatusField = 'cuisine_status';
$IdField = 'cuisine_id';
break;
case "rt_category_main":
$StatusField = 'status';
$IdField = 'maincateid';
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';
break;
case "rt_restaurant_addons":
$StatusField = 'status';
$IdField = 'id';
break;
case "rt_restaurant_offer":
$StatusField = 'status';
$IdField = 'offer_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;
default:
}
$this->db->trans_start();
$data_up= array( $StatusField => $status );
$this->db->where($IdField,$id);
$this->db->update($table,$data_up);
$this->db->trans_complete();
return TRUE;
}
function ChangePopuler()
{
$table = $this->input->post('table');
$status = $this->input->post('status');
$id = $this->input->post('id');
switch ($table) {
case "rt_cuisine":
$StatusField = 'cuisine_popular_dish';
$IdField = 'cuisine_id';
break;
case "rt_restaurant_menu":
$StatusField = 'menu_popular_dish';
$IdField = 'id';
break;
default:
}
$this->db->trans_start();
$data_up= array( $StatusField => $status );
$this->db->where($IdField,$id);
$this->db->update($table,$data_up);
$this->db->trans_complete();
return TRUE;
}
function DeleteNow()
{
$table = $this->input->post('table');
$id = $this->input->post('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';
break;
case "rt_restaurant_menu":
$IdField = 'id';
break;
case "rt_restaurant_addons":
$IdField = 'id';
break;
case "rt_restaurant_offer":
$IdField = 'offer_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';
break;
default:
}
$this->db->where($IdField, $id);
$this->db->delete($table);
return $this->db->affected_rows() > 0;
}
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 delevery_select_option()
{
$StateList =$this->dashboard_model->StateList();
$State_List='<option value='.'0'.'>Select State</option>';
if(is_array($StateList) && sizeof($StateList)>0)
{
foreach($StateList as $row)
{
$State_List .='<option value='.$row->statecode.'>'.$row->statename.'</option>';
}
}
$TimezonList =$this->dashboard_model->TimezonList();
$Timezone_List='<option value='.'0'.'>Select Timezone</option>';
if(is_array($TimezonList) && sizeof($TimezonList)>0)
{
foreach($TimezonList as $row)
{
$Timezone_List .='<option value='.$row->code.'>'.$row->name.'</option>';
}
}
$data99['StateList'] =$State_List;
$data99['TimezoneList'] =$Timezone_List;
//$data99['TimezonList'] =$this->dashboard_model->TimezonList();
header('Content-Type: application/json');
echo json_encode($data99);
}
function delevery_select_restaurant()
{
$ZipcodeList =$this->dashboard_model->ZipcodeList();
$Zipcode_List='<option value='.'0'.'>Select Area/Zipcode</option>';
if(is_array($ZipcodeList) && sizeof($ZipcodeList)>0)
{
foreach($ZipcodeList as $row)
{
$Zipcode_List .='<option value='.$row->zipcode_id.'>'.$row->areaname.'/'.$row->zipcode.'</option>';
}
}
$data99['TimezoneList'] =$Zipcode_List;
//$data99['TimezonList'] =$this->dashboard_model->TimezonList();
header('Content-Type: application/json');
echo json_encode($data99);
}
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();
return TRUE;
}
function order_export($restaurant_id=0, $action ='')
{
$action = explode('-', $action);
$order_list = $this->menumanagement_model->get_order_list($params = array(), $action, $action2 =0, $action3 ='',$restaurant_id);
//$action = explode('-', $action);
$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('superadmin/restaurantreport', '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 Date');
/* $this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Date');*/
$this->excel->getActiveSheet()->setCellValue('D3', 'Delivery Type');
$this->excel->getActiveSheet()->setCellValue('E3', 'Amount');
$this->excel->getActiveSheet()->setCellValue('F3', 'Payment Type');
$this->excel->getActiveSheet()->setCellValue('G3', 'Commission');
$this->excel->getActiveSheet()->setCellValue('H3', 'Customer Email');
$this->excel->getActiveSheet()->setCellValue('I3', 'Order Status');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($order_list as $key => $value)
{
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value['ordergenerateid']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, $value['restaurant_name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, date("m/d/Y g:i A", strtotime($value['orderdate'])));
/* $this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, date('m/d/Y', strtotime($value['deliverydate'])));*/
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, $value['deliverytype']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(4, $data_row, $value['ordertotalprice']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(5, $data_row, $value['payment_type']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(6, $data_row, $value['commission']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(7, $data_row, $value['customeremail']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(8, $data_row, $value['status']);
$data_row++;
}
$filename='order_export.xls'; //save our workbook as this file name
header('Content-Type: application/vnd.ms-excel'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
$objWriter->save('php://output');
}
}
function order_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('mpdf.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 restaurant_export($action = '', $action2 = '')
{
$restaurant_list = $this->restaurantmanagement_model->get_restaurat_list(array(), $action, $action2);
$restaurant_name = "All restaurant";
if (empty($restaurant_list)) {
$this->session->set_flashdata('error_msg', $this->lang->line('Norecordfoundof').' '.$restaurant_name);
redirect('superadmin/customersmanagement', 'refresh');
}
else
{
$this->excel->getActiveSheet()->setCellValue('A1', 'Date:');
$this->excel->getActiveSheet()->setCellValue('B1', date('d-m-Y'));
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('restaurant_export');
$this->excel->getActiveSheet()->setCellValue('A3', 'ID');
$this->excel->getActiveSheet()->setCellValue('B3', 'Name ');
$this->excel->getActiveSheet()->setCellValue('C3', 'Phone No');
$this->excel->getActiveSheet()->setCellValue('D3', 'State');
$this->excel->getActiveSheet()->setCellValue('E3', 'City');
$this->excel->getActiveSheet()->setCellValue('F3', 'Added Date');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($restaurant_list as $key => $value)
{
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value['restaurant_id']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, $value['restaurant_name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, $value['restaurant_phone']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, $value['restaurant_state']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(4, $data_row, $value['restaurant_city']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(5, $data_row, date('d.m.Y', strtotime($value['addeddate'])));
$data_row++;
}
$filename='restaurant_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 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']="Dashboard";
$data['page']="dashboard";
$this->load->view('superadmin/header',$data);
$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/change_password');
$this->load->view('superadmin/footer');
}
else
{
$this->db->trans_start();
$data_up= array('password' => $this->input->post('newpassword'));
$session_data = $this->session->userdata('logged_in');
$id = $session_data['id'];
$this->db->where('admin_id',$id);
$this->db->update('rt_admin',$data_up);
$this->db->trans_complete();
$this->session->set_flashdata('success_msg', $this->lang->line('Passwordupdatedsuccessfully'));
redirect('superadmin/changepassword');
}
//redirect(base_url('changePassword'));
}else
{
$data['title']="Dashboard";
$data['page']="dashboard";
$this->load->view('superadmin/header',$data);
$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/change_password');
$this->load->view('superadmin/footer');
}
}
public function checkPass($str)
{
$userPassword = $this->input->post('userPassword');
$session_data = $this->session->userdata('logged_in');
$userid = $session_data['id'];
$is_exist = $this->dashboard_model->isUserExist($userPassword,$userid);
if ($is_exist) {
return true;
}else{
$this->form_validation->set_message('checkPass', 'Please enter correct password.');
return false;
}
}
function changeRestFeature() {
$restaurant_id = $this->input->post('restaurant_id');
$restaurant_feature_status = $this->input->post('restaurant_feature_status');
$this->db->trans_start();
$data_up= array('restaurant_feature_status' => $restaurant_feature_status);
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_up);
$this->db->trans_complete();
return TRUE;
}
function changeRestFooter() {
$restaurant_id = $this->input->post('restaurant_id');
$restaurant_footer_status = $this->input->post('restaurant_footer_status');
$this->db->trans_start();
$data_up= array('restaurant_footer_status' => $restaurant_footer_status);
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_up);
$this->db->trans_complete();
return TRUE;
}
function customer_export($action = '')
{
$customer_list = $this->customersmanagement_model->get_customer_list(array(), $action);
$restaurant_name = "All restaurant";
if (empty($customer_list)) {
$this->session->set_flashdata('error_msg', $this->lang->line('Norecordfoundof').' '.$restaurant_name);
redirect('superadmin/customersmanagement', 'refresh');
}
else
{
$this->excel->getActiveSheet()->setCellValue('A1', 'Date:');
$this->excel->getActiveSheet()->setCellValue('B1', date('d-m-Y'));
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('customer_export');
$this->excel->getActiveSheet()->setCellValue('A3', 'Customer Name');
$this->excel->getActiveSheet()->setCellValue('B3', 'Email Id');
$this->excel->getActiveSheet()->setCellValue('C3', 'Phone');
$this->excel->getActiveSheet()->setCellValue('D3', 'Added Date');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($customer_list as $key => $value)
{
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value['customer_name'].' '.$value['customer_lastname']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, $value['customer_email']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, $value['customer_phone']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, date('d.m.Y', strtotime($value['addeddate'])));
$data_row++;
}
$filename='customer_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');
}
}
/**
* @param string $action
*/
function newsletter_subscriber_export($action = '')
{
$newsletter_subscriber_list = $this->frontend_model->getNewsletterSubscriberList(array(), $action);
$restaurant_name = "All subscriber";
if (empty($newsletter_subscriber_list)) {
$this->session->set_flashdata('error_msg', $this->lang->line('Norecordfoundof').' '.$restaurant_name);
redirect('superadmin/newslettersubscriber', 'refresh');
}
else
{
$this->excel->getActiveSheet()->setCellValue('A1', 'Date:');
$this->excel->getActiveSheet()->setCellValue('B1', date('d-m-Y'));
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('newsletter_subscriber_export');
$this->excel->getActiveSheet()->setCellValue('A3', 'Subscriber Email');
$this->excel->getActiveSheet()->setCellValue('B3', 'Subscriber Type');
// $this->excel->getActiveSheet()->setCellValue('C3', 'Phone');
// $this->excel->getActiveSheet()->setCellValue('D3', 'Added Date');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($newsletter_subscriber_list as $key => $value)
{
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value['subscriber_email']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, ($value['subscriber_type'] == "0" ? "Customer" : ($value['subscriber_type'] == "1" ? "Restaurant" : "Driver")));
// $this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, $value['customer_phone']);
// $this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, date('d.m.Y', strtotime($value['addeddate'])));
$data_row++;
}
$filename='newsletter_subscriber_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 upload_admin_image()
{
/*print_r($_FILES);
print_r($this->input->post());
exit();*/
$form_field_name = 'admin_image';
/*echo $form_field_name;
exit();*/
$rendid = date('Ymdhis');
$new_name = 'admin_'.$rendid.'_logo.jpg';
$config1 = array(
'upload_path' => ADMIN_LOGO_PATH,
'allowed_types' => "gif|jpg|png|jpeg",
'overwrite' => TRUE,
'file_name' => $new_name
);
$this->load->library('upload', $config1);
$this->upload->initialize($config1);
if($this->upload->do_upload($form_field_name)) {
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config2['new_image'] = ADMIN_LOGO_PATH.'thumbs';
$config2['maintain_ratio'] = TRUE;
$config2['width'] = ADMIN_LOGO_WIDTH;
$config2['height'] = ADMIN_LOGO_HEIGHT;
$this->load->library('image_lib',$config2);
$this->image_lib->initialize($config2);
if ( !$this->image_lib->resize()) {
return false;
}
$result =$this->dashboard_model->GetAdminDetails();
if(file_exists(ADMIN_LOGO_PATH.'thumbs/'.$result['admin_image']) && $result['admin_image'] != '' && $result['admin_image'] != ADMIN_DEFAULT_IMAGE)
{
if($result['admin_image'] != ADMIN_DEFAULT_IMAGE) {
unlink(ADMIN_LOGO_PATH.'thumbs/'.$result['admin_image']);
}
}
unlink(ADMIN_LOGO_PATH.$new_name);
$data = array('upload_data' => $this->upload->data());
$data_up= array(
'admin_image' => $new_name
);
$this->db->trans_start();
$this->db->where('admin_id', $this->session->userdata('logged_in')['id']);
$this->db->update('rt_admin',$data_up);
$this->db->trans_complete();
$logged_in = $this->session->userdata('logged_in');
$logged_in['admin_image'] = $new_name;
$this->session->set_userdata('logged_in', $logged_in);
echo $new_name;
}
else {
$error = $this->upload->display_errors();
echo $error;
}
}
function manage_wallet()
{
$data['RestaurantList'] = $this->restaurantmanagement_model->get_restaurat_list();
$data['Driverlist'] = $this ->driver_model -> DriverList();
$data['title']="Manage Wallet";
$data['page']="manage_wallet";
$this->load->view('superadmin/header',$data);
$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/manage_wallet');
$this->load->view('superadmin/footer');
}
function GetDriverInvoice()
{
$tableData ='';
$diver_id = $this->input->post('driver_id');
$InvoiceList = $this->driver_model->get_driver_invoice_list(array('limit'=>100), $diver_id,$action2 = 99999);
if (is_array($InvoiceList) && count($InvoiceList) > 0) {
$tableHeader='<thead>
<tr class="label-info labelinfo1">
<th class="text-center">'.$this->lang->line('InvoiceNo').'</th>
<th class="text-center">'.$this->lang->line('InvoiceDate').'</th>
<th class="text-center">'.$this->lang->line('DriverName').'</th>
<th class="text-center">'.$this->lang->line('BillingPeriod').'</th>
<th class="text-center">'.$this->lang->line('Amount').'</th>
<th class="text-center">'.$this->lang->line('Status').'</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>';
foreach ($InvoiceList as $key => $value) {
$amount = $value['amount'];
$tip = $value['driver_tip'];
$TotalAmt = $amount + $tip;
$TotalAmt = number_format($TotalAmt,2);
$invoice_id = $value['invoice_id'];
$sel1='';
$sel2='';
if($value['status']=='0'){ $sel1="selected";}
if($value['status']=='1'){ $sel2="selected";}
$tableData .='
<tr>
<td class="text-center ">#INV'.$invoice_id.'</td>
<td class="text-center ">'.date("F j, Y", strtotime($value['addeddate'])).'</td>
<td class="text-center ">'.date("F j, Y", strtotime($value['from_date'])).' to '.date("F j, Y", strtotime($value['to_date'])).'</td>
<td class="text-center ">'.$TotalAmt.'</td>
<td class="text-center " style="width: 165px;">
<select onchange="update_invoice_status('.$value['invoice_id'].',this.value,2)" class="select2">
<option value="0" '.$sel1.' >'.$this->lang->line('InvoiceSent').'</option>
<option value="1" '.$sel2.'>'.$this->lang->line('PaymentSent').'</option>
</select>
</td>
<td class="text-center "><i style="font-size: 20px; cursor: pointer;" onclick="do_pdf(\''.$value['id_code'].'\');" class="fa fa-file-pdf-o" aria-hidden="true"></i></td>
</tr>';
// <td class="text-center ">'.$value['driver_first_name'].' '.$value['driver_middle_name'].' '.$value['driver_last_name'].'</td>
}
$tableData99 = $tableHeader.$tableData.'</tbody>';
}else{
$tableData99 ='<thead>
<tr class="label-info labelinfo1">
<th class="text-center">'.$this->lang->line('InvoiceNo').'</th>
<th class="text-center">'.$this->lang->line('InvoiceDate').'</th>
<th class="text-center">'.$this->lang->line('BillingPeriod').'</th>
<th class="text-center">'.$this->lang->line('Amount').'</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5" class="text-center ">'.$this->lang->line('Norecordfound!').'</td>
</tr></table>';
// <th class="text-center">Driver Name</th>
}
echo $tableData99;
}
function GetRestaurantInvoice()
{
$tableData ='';
$restaurant_id = $this->input->post('restaurant_id');
$InvoiceList = $this->restaurantmanagement_model->get_invoice_list(array('limit'=>100), $restaurant_id,$action2 = 99999);
if (is_array($InvoiceList) && count($InvoiceList) > 0) {
/*$tableHeader='<thead>
<tr class="label-info labelinfo1">
<th class="text-center">Invoice No.</th>
<th class="text-center">Invoice Date</th>
<th class="text-center">Restaurant Name</th>
<th class="text-center">Billing Period</th>
<th class="text-center">Amount</th>
<th class="text-center">Status</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>';*/
$tableHeader='<thead>
<tr class="label-info labelinfo1">
<th class="text-center">'.$this->lang->line('InvoiceNo').'</th>
<th class="text-center">'.$this->lang->line('InvoiceDate').'</th>
<th class="text-center">'.$this->lang->line('RestaurantName').'</th>
<th class="text-center">'.$this->lang->line('BillingPeriod').'</th>
<th class="text-center">'.$this->lang->line('Amount').'</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>';
foreach ($InvoiceList as $key => $value) {
$amount = $value['order_amount'];
$TotalAmt = number_format($amount,2);
$invoice_id = $value['invoice_id'];
$sel1='';
$sel2='';
if($value['status']=='0'){ $sel1="selected";}
if($value['status']=='1'){ $sel2="selected";}
/*$tableData .='
<tr>
<td class="text-center ">#INV'.$invoice_id.'</td>
<td class="text-center ">'.date("F j, Y", strtotime($value['addeddate'])).'</td>
<td class="text-center ">'.$value['restaurant_name'].'</td>
<td class="text-center ">'.date("F j, Y", strtotime($value['from_date'])).' to '.date("F j, Y", strtotime($value['to_date'])).'</td>
<td class="text-center ">'.$TotalAmt.'</td>
<td class="text-center " style="width: 165px;">
<select onchange="update_invoice_status('.$value['invoice_id'].',this.value,1)" class="select2">
<option value="0" '.$sel1.' >Invoice Sent</option>
<option value="1" '.$sel2.'>Payment Sent</option>
</select>
</td>
<td class="text-center "><i style="font-size: 20px; cursor: pointer;" onclick="do_pdf_res(\''.$value['id_code'].'\');" class="fa fa-file-pdf-o" aria-hidden="true"></i></td>
</tr>';*/
$tableData .='
<tr>
<td class="text-center ">#INV'.$invoice_id.'</td>
<td class="text-center ">'.date("F j, Y", strtotime($value['addeddate'])).'</td>
<td class="text-center ">'.$value['restaurant_name'].'</td>
<td class="text-center ">'.date("F j, Y", strtotime($value['from_date'])).' to '.date("F j, Y", strtotime($value['to_date'])).'</td>
<td class="text-center ">'.$TotalAmt.'</td>
<td class="text-center "><i style="font-size: 20px; cursor: pointer;" onclick="do_pdf_res(\''.$value['id_code'].'\');" class="fa fa-file-pdf-o" aria-hidden="true"></i></td>
</tr>';
}
$tableData99 = $tableHeader.$tableData.'</tbody>';
}else{
$tableData99 ='<thead>
<tr class="label-info labelinfo1">
<th class="text-center">'.$this->lang->line('InvoiceNo').'</th>
<th class="text-center">'.$this->lang->line('InvoiceDate').'</th>
<th class="text-center">'.$this->lang->line('RestaurantName').'</th>
<th class="text-center">'.$this->lang->line('BillingPeriod').'</th>
<th class="text-center">'.$this->lang->line('Amount').'</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="5" class="text-center ">No record found!</td>
</tr></table>';
}
echo $tableData99;
}
function refundComplete() {
$orderid = $this->input->post('orderid');
$this->session->set_flashdata('success_msg', $this->lang->line('Refundacceptedfororder').' ORD'.$orderid.'.');
$update_order_status = array('status' => 'Refund Accepted');
$this->db->trans_start();
$this->db->where('orderid', $orderid);
$this->db->update('rt_order', $update_order_status);
$this->db->trans_complete();
$orderShort = $this->createorder_model->orderShortDetails($orderid);
$orderLong = $this->createorder_model->orderLongDetails($orderid);
$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'] = 'Coupon Discount';
$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, Your refund request is accepted. 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 is accepted 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 cancelOrder() {
$orderid = $this->input->post('orderid');
$status = $this->input->post('status');
$this->session->set_flashdata('success_msg', $this->lang->line('Refundacceptedfororder').' ORD'.$orderid.'.');
$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();
}*/
$update_order_status = array('status' => 'Refund Requested');
$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 order_export_payment($restaurant_id=0, $action ='') {
$action2 = $restaurant_id;
$order_list = $this->customersmanagement_model->get_customer_payment_list(array(),$action,$action2);
// echo "<pre>";
// print_r($order_list);
// echo "</pre>";
// exit();
$restaurant_name = "All restaurant";
if (empty($order_list)) {
$this->session->set_flashdata('error_msg', $this->lang->line('Norecordfound!'));
redirect('superadmin/customerpayment', 'refresh');
}
else {
$this->excel->getActiveSheet()->setCellValue('A1', 'Date:');
$this->excel->getActiveSheet()->setCellValue('B1', date('m/d/Y'));
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->setTitle('track_payment');
$this->excel->getActiveSheet()->setCellValue('A3', 'Customer Name');
$this->excel->getActiveSheet()->setCellValue('B3', 'Restaurant');
$this->excel->getActiveSheet()->setCellValue('C3', 'Price');
$this->excel->getActiveSheet()->setCellValue('D3', 'Payment Type');
$this->excel->getActiveSheet()->setCellValue('E3', 'Order Date');
$this->excel->getActiveSheet()->setCellValue('F3', 'Transaction ID');
$data_row = 4; // 1-based index
$data_col = 0;
foreach ($order_list as $key => $value) {
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(0, $data_row, $value['customer_name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(1, $data_row, $value['restaurant_name']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(2, $data_row, $value['ordertotalprice']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(3, $data_row, $value['payment_type']);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(4, $data_row, date("M j, Y", strtotime($value['orderdate'])));
$this->excel->getActiveSheet()->setCellValueByColumnAndRow(5, $data_row, $value['transaction_id']);
$data_row++;
}
$filename='track_payment.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 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';
}
}
}