| 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
class UpdateRestaurant extends MY_Restaurant {
function __construct()
{
parent::__construct();
$this->load->helper("url");
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('javascript');
$this->load->model('dashboard_model');
$this->load->model('user');
$this->load->library('Ajax_pagination');
$this->perPage = ROW_PER_PAGE;
$this->load->model('restaurantmanagement_model');
$this->load->model('menumanagement_model');
$this->load->library('googlemaps');
$this->load->library('braintree_lib');
$session_data = $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('restaurantAdmin', $language);
//if(empty($session_data)) { redirect('superadmin', 'refresh'); }
}
function index( $restaurant_id = 0 )
{
if ($this->input->server('REQUEST_METHOD') == 'POST')
{
if($this->input->post('ActionTab')=='ContactInfo')
{
$this->restaurat_contact();
}
if($this->input->post('ActionTab')=='RestaurantInfo')
{
$this->restaurat_info();
}
if($this->input->post('ActionTab')=='DeliveryAreaSettings')
{
$this->restaurat_deliveryarea();
}
if($this->input->post('ActionTab')=='RestaurantPhoto')
{
$this->RestaurantPhoto();
}
if($this->input->post('ActionTab')=='CommissionInfo')
{
$this->CommissionInfo();
}
if($this->input->post('ActionTab')=='BankInfo')
{
$this->RestauratBankInfo();
}
if($this->input->post('ActionTab')=='BankInfoPinPayment')
{
$this->restaurantPinPaymentAccount();
}
if($this->input->post('ActionTab')=='SiteDocusign')
{
$this->websettings_DocuSign();
}
}else
{
$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']['agreement_status']) && $query['data']['agreement_status'] == 1) {
$query['RestaurantAgreement'] = $query['data']['agreement_view'];
}
else {
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);
}
$query['RestaurantAgreement'] = $myContent;
}
$query['StateList'] = $this->dashboard_model->StateList();
$query['CityList'] = $this->dashboard_model->CityList();
$query['CuisineList'] = $this->dashboard_model->CuisineList();
$query['ZipcodeList'] = $this->dashboard_model->ZipcodeList();
$query['DelliveryTimeList'] = $this->dashboard_model->DelliveryTimeList($restaurant_id);
$latitude = $query['data']['latitude'];
$longitude = $query['data']['longitude'];
$address = $query['data']['restaurant_streetaddress'];
$this->googlemaps->initialize();
$marker = array();
//$marker['position'] ="'".$latitude.','.$longitude."'";
$marker['position'] =$address;
//$marker['draggable'] = true;
//$marker['ondragend'] = 'alert(\'You just dropped me at: \' + event.latLng.lat() + \', \' + event.latLng.lng());';
$this->googlemaps->add_marker($marker);
//$config['center'] = "'".$latitude.','.$longitude."'";
$config['center'] = $address;
$config['zoom'] = '15';
//$config['drawing'] = true;
//$config['drawingDefaultMode'] = 'circle';
//$config['drawingModes'] = array('circle','rectangle','polygon');
$this->googlemaps->initialize($config);
$this->googlemaps->add_marker($marker);
$data['map'] = $this->googlemaps->create_map();
$data['title']="Update Restaurant";
$query['SiteTab'] ='updaterestaurant';
$query['SiteTab'] ='ContactInfo';
$data['page']="updaterestaurant";
$this->load->view('restaurantadmin/header',$data);
$this->load->view('restaurantadmin/main-sidebar');
$this->load->view('restaurantadmin/addnewrestaurant',$query);
$this->load->view('restaurantadmin/footer');
}
}
function restaurat_deliveryarea()
{
//$test = $this->input->post(['map']['markers']);
//print_r($this->input->post());
//exit();
// $restaurant_delivery = $this->input->post('restaurant_delivery');
// if($restaurant_delivery =='on')
// {
// $restaurant_delivery = 'YES';
// }else{
// $restaurant_delivery = 'NO';
// }
$restaurant_id = $this->input->post('restaurant_id');
$data_restaurant= array(
// 'restaurant_estimated_time' => $this->input->post('restaurant_estimated_time'),
// 'restaurant_delivery' => $restaurant_delivery,
// 'deliveryarea' => $this->input->post('delivery_radio'),
'delivery_zone_1' => $this->input->post('delivery_area1'),
'delivery_zone_2' => $this->input->post('delivery_area2'),
'delivery_zone_3' => $this->input->post('delivery_area3'),
'restaurant_delivery_charge' => $this->input->post('restaurant_delivery_charge'),
'restaurant_minorder_price' => $this->input->post('restaurant_minorder_price'),
'restaurant_delivery_charge_2' => $this->input->post('restaurant_delivery_charge_2'),
'restaurant_minorder_price_2' => $this->input->post('restaurant_minorder_price_2'),
'restaurant_delivery_charge_3' => $this->input->post('restaurant_delivery_charge_3'),
'restaurant_minorder_price_3' => $this->input->post('restaurant_minorder_price_3')
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->session->set_flashdata('SiteTab', 'DeliveryInfo');
$this->session->set_flashdata('success_msg', $this->lang->line('RestaurantDeliveryAreainfoupdatedsuccessfully'));
redirect('restaurantadmin/updaterestaurant/');
}
function restaurat_contact()
{
$delivery_zone_1="[[41.49324271131432,-90.47262668609619],[41.49700357252215,-90.46794891357422],[41.49240693472465,-90.46438694000244],[41.48780997072924,-90.46940803527832]]";
$delivery_zone_2="[[41.49324271131432,-90.47262668609619],[41.49700357252215,-90.46794891357422],[41.49240693472465,-90.46438694000244],[41.48780997072924,-90.46940803527832]]";
$delivery_zone_3="[[41.49324271131432,-90.47262668609619],[41.49700357252215,-90.46794891357422],[41.49240693472465,-90.46438694000244],[41.48780997072924,-90.46940803527832]]";
// We define our address
$address = $this->input->post('restaurant_zip').' '.$this->input->post('restaurant_streetaddress').' '.$this->input->post('restaurant_state').' '.$this->input->post('restaurant_city');
// We get the JSON results from this request
if($address!='')
{
$geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false');
// We convert the JSON to an array
$geo = json_decode($geo, true);
// If everything is cool
if ($geo['status'] = 'OK') {
// We set our values
$latitude = isset($geo['results'][0]['geometry']['location']['lat'])? $geo['results'][0]['geometry']['location']['lat']: DEFAULT_LAT ;
$longitude = isset($geo['results'][0]['geometry']['location']['lng'])? $geo['results'][0]['geometry']['location']['lng'] : DEFAULT_LONG;
}else{
$latitude = DEFAULT_LAT;
$longitude = DEFAULT_LONG;
}
}else
{
$latitude = DEFAULT_LAT;
$longitude = DEFAULT_LONG;
}
$this->form_validation->set_rules('restaurant_name', 'restaurant_name', 'trim|required|xss_clean|callback_isRestNameExist');
$this->form_validation->set_rules('restaurant_phone');
$this->form_validation->set_rules('restaurant_website');
//$this->form_validation->set_rules('restaurant_fax');
$this->form_validation->set_rules('restaurant_abn');
$this->form_validation->set_rules('restaurant_zip');
$this->form_validation->set_rules('restaurant_streetaddress');
$this->form_validation->set_rules('restaurant_contact_name');
$this->form_validation->set_rules('restaurant_contact_phone');
$this->form_validation->set_rules('restaurant_contact_email', 'restaurant_contact_email', 'trim|required|xss_clean|callback_isUserExist');
//$this->form_validation->set_rules('restaurant_contact_email');
$this->form_validation->set_rules('order_receive_type');
$this->form_validation->set_rules('restaurant_state', 'State', 'trim|required');
$this->form_validation->set_rules('restaurant_city', 'City', 'trim|required');
if($this->form_validation->run() == FALSE)
{
$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();
$query['StateList'] = $this->dashboard_model->StateList();
$query['CityList'] = $this->dashboard_model->CityList();
$query['CuisineList'] = $this->dashboard_model->CuisineList();
$query['ZipcodeList'] = $this->dashboard_model->ZipcodeList();
$query['DelliveryTimeList'] = $this->dashboard_model->DelliveryTimeList($restaurant_id);
$latitude = $query['data']['latitude'];
$longitude = $query['data']['longitude'];
$address = $query['data']['restaurant_streetaddress'];
$this->googlemaps->initialize();
$marker = array();
//$marker['position'] ="'".$latitude.','.$longitude."'";
$marker['position'] =$address;
//$marker['draggable'] = true;
//$marker['ondragend'] = 'alert(\'You just dropped me at: \' + event.latLng.lat() + \', \' + event.latLng.lng());';
$this->googlemaps->add_marker($marker);
//$config['center'] = "'".$latitude.','.$longitude."'";
$config['center'] = $address;
$config['zoom'] = '15';
//$config['drawing'] = true;
//$config['drawingDefaultMode'] = 'circle';
//$config['drawingModes'] = array('circle','rectangle','polygon');
$this->googlemaps->initialize($config);
$this->googlemaps->add_marker($marker);
$data['map'] = $this->googlemaps->create_map();
$data['title']="Update Restaurant";
$query['SiteTab'] ='updaterestaurant';
$query['SiteTab'] ='ContactInfo';
$data['page']="updaterestaurant";
$this->load->view('restaurantadmin/header',$data);
$this->load->view('restaurantadmin/main-sidebar');
$this->load->view('restaurantadmin/addnewrestaurant',$query);
$this->load->view('restaurantadmin/footer');
}else
{
$addeddate = date('Y-m-d H:i:s');
if ($this->input->post('order_receive_type')) {
$order_receive_type_array = $this->input->post('order_receive_type');
if (is_array($order_receive_type_array)) {
$order_receive_type = implode(',', $order_receive_type_array);
}
else {
$order_receive_type = '';
}
}
else {
$order_receive_type = '';
}
$this->db->trans_start();
$restaurant_id = $this->input->post('restaurant_id');
$this->db->select('delivery_zone_1, delivery_zone_2, delivery_zone_3');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id',$restaurant_id);
$myQuery = $this->db->get();
$myData = $myQuery->row();
if ($myData->delivery_zone_1 !== '') {
$delivery_zone_1 = $myData->delivery_zone_1;
}
if ($myData->delivery_zone_2 !== '') {
$delivery_zone_2 = $myData->delivery_zone_2;
}
if ($myData->delivery_zone_3 !== '') {
$delivery_zone_3 = $myData->delivery_zone_3;
}
$data_up= array(
'restaurant_name' => $this->input->post('restaurant_name'),
'restaurant_phone' => $this->input->post('restaurant_phone'),
'restaurant_website' => $this->input->post('restaurant_website'),
'restaurant_fax' => $this->input->post('restaurant_fax'),
'restaurant_abn' => $this->input->post('restaurant_abn'),
'restaurant_state' => $this->input->post('restaurant_state'),
'restaurant_city' => $this->input->post('restaurant_city'),
'restaurant_zip' => $this->input->post('restaurant_zip'),
'restaurant_streetaddress' => $this->input->post('restaurant_streetaddress'),
'restaurant_contact_name' => $this->input->post('restaurant_contact_name'),
'restaurant_contact_phone' => $this->input->post('restaurant_contact_phone'),
'restaurant_contact_email' => $this->input->post('restaurant_contact_email'),
'addeddate' => $addeddate,
'latitude' => $latitude,
'longitude' => $longitude,
'delivery_zone_1' => $delivery_zone_1,
'delivery_zone_2' => $delivery_zone_2,
'delivery_zone_3' => $delivery_zone_3,
'order_receive_type' => $order_receive_type,
'business_type' => $this->input->post('business_type')
);
if($restaurant_id>0)
{
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_up);
}else{
$this->db->insert('rt_restaurant',$data_up);
$restaurant_id=$this->db->insert_id();
}
$restaurant_seourl = makeSEOurl($this->input->post('restaurant_name')).'-'.$restaurant_id;
$seo_data_up = array('restaurant_seourl' => $restaurant_seourl);
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $seo_data_up);
$this->db->trans_complete();
$this->session->set_flashdata('SiteTab', 'ContactInfo');
$this->session->set_flashdata('success_msg', $this->lang->line('Contactinfosavesuccessflly'));
$old_array = $this->session->userdata('logged_in_restaurant');
$old_array['username'] = $this->input->post('restaurant_name');
$this->session->set_userdata('logged_in_restaurant', $old_array);
//print_r($old_array);
//echo $restaurant_id;
//$query['StateList'] =$this->dashboard_model->StateList();
//$query['data'] =$this->restaurantmanagement_model->GetRestauratDetails($restaurant_id);
redirect('restaurantadmin/updaterestaurant/');
}
}
function restaurat_info()
{
$restaurant_id = $this->input->post('restaurant_id');
$cuisine = '';
if(isset($_POST['restaurant_serving_cuisines'])){
$cuisine = implode(',',$_POST['restaurant_serving_cuisines']);
}
if ($this->input->post('restaurant_pickup') != 'yes' && $this->input->post('restaurant_delivery') != 'yes' && $this->input->post('restaurant_dinein') != 'yes') {
$restaurant_delivery = 'yes';
}
else {
$restaurant_delivery = $this->input->post('restaurant_delivery');
}
$data_restaurant= array(
'restaurant_description' => $this->input->post('restaurant_description'),
'restaurant_pickup' => $this->input->post('restaurant_pickup'),
'restaurant_delivery' => $restaurant_delivery,
'restaurant_delivery_by' => $this->input->post('restaurant_delivery_by'),
'restaurant_dinein' => $this->input->post('restaurant_dinein'),
'restaurant_booktable' => $this->input->post('restaurant_booktable'),
'restaurant_estimated_time' => ltrim($this->input->post('restaurant_estimated_time'), '0'),
'restaurant_delivery_sun_opentime' => $this->input->post('restaurant_delivery_sun_opentime'),
'restaurant_delivery_sun_closetime' => $this->input->post('restaurant_delivery_sun_closetime'),
'restaurant_delivery_mon_opentime' => $this->input->post('restaurant_delivery_mon_opentime'),
'restaurant_delivery_mon_closetime' => $this->input->post('restaurant_delivery_mon_closetime'),
'restaurant_delivery_tue_opentime' => $this->input->post('restaurant_delivery_tue_opentime'),
'restaurant_delivery_tue_closetime' => $this->input->post('restaurant_delivery_tue_closetime'),
'restaurant_delivery_wed_opentime' => $this->input->post('restaurant_delivery_wed_opentime'),
'restaurant_delivery_wed_closetime' => $this->input->post('restaurant_delivery_wed_closetime'),
'restaurant_delivery_thu_opentime' => $this->input->post('restaurant_delivery_thu_opentime'),
'restaurant_delivery_thu_closetime' => $this->input->post('restaurant_delivery_thu_closetime'),
'restaurant_delivery_fri_opentime' => $this->input->post('restaurant_delivery_fri_opentime'),
'restaurant_delivery_fri_closetime' => $this->input->post('restaurant_delivery_fri_closetime'),
'restaurant_delivery_sat_opentime' => $this->input->post('restaurant_delivery_sat_opentime'),
'restaurant_delivery_sat_closetime' => $this->input->post('restaurant_delivery_sat_closetime'),
'restaurant_delivery_sun_opentime1' => $this->input->post('restaurant_delivery_sun_opentime1'),
'restaurant_delivery_sun_closetime1' => $this->input->post('restaurant_delivery_sun_closetime1'),
'restaurant_delivery_mon_opentime1' => $this->input->post('restaurant_delivery_mon_opentime1'),
'restaurant_delivery_mon_closetime1' => $this->input->post('restaurant_delivery_mon_closetime1'),
'restaurant_delivery_tue_opentime1' => $this->input->post('restaurant_delivery_tue_opentime1'),
'restaurant_delivery_tue_closetime1' => $this->input->post('restaurant_delivery_tue_closetime1'),
'restaurant_delivery_wed_opentime1' => $this->input->post('restaurant_delivery_wed_opentime1'),
'restaurant_delivery_wed_closetime1' => $this->input->post('restaurant_delivery_wed_closetime1'),
'restaurant_delivery_thu_opentime1' => $this->input->post('restaurant_delivery_thu_opentime1'),
'restaurant_delivery_thu_closetime1' => $this->input->post('restaurant_delivery_thu_closetime1'),
'restaurant_delivery_fri_opentime1' => $this->input->post('restaurant_delivery_fri_opentime1'),
'restaurant_delivery_fri_closetime1' => $this->input->post('restaurant_delivery_fri_closetime1'),
'restaurant_delivery_sat_opentime1' => $this->input->post('restaurant_delivery_sat_opentime1'),
'restaurant_delivery_sat_closetime1' => $this->input->post('restaurant_delivery_sat_closetime1'),
'restaurant_delivery_sun_opentime2' => $this->input->post('restaurant_delivery_sun_opentime2'),
'restaurant_delivery_sun_closetime2' => $this->input->post('restaurant_delivery_sun_closetime2'),
'restaurant_delivery_mon_opentime2' => $this->input->post('restaurant_delivery_mon_opentime2'),
'restaurant_delivery_mon_closetime2' => $this->input->post('restaurant_delivery_mon_closetime2'),
'restaurant_delivery_tue_opentime2' => $this->input->post('restaurant_delivery_tue_opentime2'),
'restaurant_delivery_tue_closetime2' => $this->input->post('restaurant_delivery_tue_closetime2'),
'restaurant_delivery_wed_opentime2' => $this->input->post('restaurant_delivery_wed_opentime2'),
'restaurant_delivery_wed_closetime2' => $this->input->post('restaurant_delivery_wed_closetime2'),
'restaurant_delivery_thu_opentime2' => $this->input->post('restaurant_delivery_thu_opentime2'),
'restaurant_delivery_thu_closetime2' => $this->input->post('restaurant_delivery_thu_closetime2'),
'restaurant_delivery_fri_opentime2' => $this->input->post('restaurant_delivery_fri_opentime2'),
'restaurant_delivery_fri_closetime2' => $this->input->post('restaurant_delivery_fri_closetime2'),
'restaurant_delivery_sat_opentime2' => $this->input->post('restaurant_delivery_sat_opentime2'),
'restaurant_delivery_sat_closetime2' => $this->input->post('restaurant_delivery_sat_closetime2'),
'restaurant_salestax' => $this->input->post('restaurant_salestax'),
'restaurant_minorder_price' => ltrim($this->input->post('restaurant_minorder_price'), '0'),
'restaurant_serving_cuisines' => $cuisine
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->db->trans_complete();
if (!empty($_FILES['restaurant_logo']['name']))
{
$this->do_upload_logo('restaurant_logo',$restaurant_id);
}
$this->session->set_flashdata('success_msg', $this->lang->line('RestaurantInfoupdatedsuccessfully'));
$this->session->set_flashdata('SiteTab', 'RestaurantInfo');
redirect('restaurantadmin/updaterestaurant/');
}
function do_upload_logo($form_field_name2,$restaurant_id)
{
$rendid = date('Ymdhis');
$new_name = $restaurant_id.'_'.$rendid.'_logo.jpg';
$config1 = array(
'upload_path' => RESTAURAT_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_name2))
{
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config2['new_image'] = RESTAURAT_LOGO_PATH.'thumbs';
$config2['maintain_ratio'] = TRUE;
//$config2['create_thumb'] = TRUE;
//$config2['thumb_marker'] = '_thumb';
$config2['width'] = RESTAURAT_LOGO_WIDTH;
$config2['height'] = RESTAURAT_LOGO_HEIGHT;
$this->load->library('image_lib',$config2);
$this->image_lib->initialize($config2);
if ( !$this->image_lib->resize()){
$this->session->set_flashdata('errors', $this->image_lib->display_errors('', ''));
}
$result =$this->restaurantmanagement_model->GetRestauratDetails($restaurant_id);
if(file_exists(RESTAURAT_LOGO_PATH.'thumbs/'.$result['restaurant_logo']) && $result['restaurant_logo']!='' && $result['restaurant_logo']!=RESTAURAT_DEFAULT_IMAGE)
{
if($result['restaurant_logo']!=SITE_DEFAULT_LOGO)
{
unlink(RESTAURAT_LOGO_PATH.'thumbs/'.$result['restaurant_logo']);
}
}
unlink(RESTAURAT_LOGO_PATH.$new_name);
$data = array('upload_data' => $this->upload->data());
$data_restaurant= array(
'restaurant_logo' => $new_name
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->db->trans_complete();
}else{
$error = $this->upload->display_errors();
$this->session->set_flashdata('success_msg', $error);
redirect('restaurantadmin/updaterestaurant/');
}
}
function RestaurantPhoto()
{
$restaurant_id = $this->input->post('restaurant_id');
if (!empty($_FILES['res_marketbanner_img_code']['name']))
{
$this->do_upload_banner('res_marketbanner_img_code',$restaurant_id);
}
/*echo "<pre>";
print_r ($this->input->post());
echo "</pre>";
exit();*/
$restaurant_id = $this->input->post('restaurant_id');
$data_restaurant= array(
'restaurant_display_photo' => $this->input->post('restaurant_display_photo'),
'restaurant_display_banner' => $this->input->post('restaurant_display_banner'),
'banner_color' => $this->input->post('banner_color')
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->db->trans_complete();
$this->session->set_flashdata('SiteTab', 'RestaurantPhoto');
$this->session->set_flashdata('success_msg', $this->lang->line('RestaurantInfoupdatedsuccessfully'));
redirect('restaurantadmin/updaterestaurant/');
}
function do_upload_banner($form_field_name2,$restaurant_id)
{
$rendid = date('Ymdhis');
$new_name = $restaurant_id.'_'.$rendid.'_banner.jpg';
$config1 = array(
'upload_path' => RESTAURAT_BANNER_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_name2))
{
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config2['new_image'] = RESTAURAT_BANNER_PATH.'thumbs';
$config2['maintain_ratio'] = TRUE;
//$config2['create_thumb'] = TRUE;
//$config2['thumb_marker'] = '_thumb';
$config2['width'] = RESTAURAT_BANNER_WIDTH;
$config2['height'] = RESTAURAT_BANNER_HEIGHT;
$this->load->library('image_lib',$config2);
$this->image_lib->initialize($config2);
if ( !$this->image_lib->resize()){
$this->session->set_flashdata('errors', $this->image_lib->display_errors('', ''));
}
$result =$this->restaurantmanagement_model->GetRestauratDetails($restaurant_id);
if(file_exists(RESTAURAT_BANNER_PATH.'thumbs/'.$result['res_marketbanner_img_code']) && $result['res_marketbanner_img_code']!='' && $result['res_marketbanner_img_code']!=RESTAURAT_DEFAULT_IMAGE)
{
if($result['restaurant_logo']!=RESTAURAT_DEFAULT_BANNER)
{
unlink(RESTAURAT_BANNER_PATH.'thumbs/'.$result['res_marketbanner_img_code']);
}
}
unlink(RESTAURAT_BANNER_PATH.$new_name);
$data = array('upload_data' => $this->upload->data());
$data_restaurant= array(
'res_marketbanner_img_code' => $new_name
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->db->trans_complete();
}else{
$error = $this->upload->display_errors();
$this->session->set_flashdata('success_msg', $error);
redirect('restaurantadmin/updaterestaurant/');
}
}
function CommissionInfo()
{
$restaurant_id = $this->input->post('restaurant_id');
$data_restaurant= array(
'restaurant_commissiontype' => $this->input->post('restaurant_commissiontype'),
'restaurant_commission_percnt' => $this->input->post('restaurant_commission_percnt'),
'restaurant_commission_fixed' => $this->input->post('restaurant_commission_fixed')
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->db->trans_complete();
$this->session->set_flashdata('SiteTab', 'CommissionInfo');
$this->session->set_flashdata('success_msg', $this->lang->line('RestaurantCommissioninfoupdatedsuccessfully'));
redirect('restaurantadmin/updaterestaurant/');
}
/*
* Method is created for adding the restaurant's bank account to Pin Payment
*/
function restaurantPinPaymentAccount()
{
$restaurant_id = $this->input->post('restaurant_id');
$data_restaurant = array(
'bt_first_name' => $this->input->post('bt_first_name'),
'bt_last_name' => $this->input->post('bt_last_name'),
'bt_email' => $this->input->post('bt_email'),
'res_ac_no' => $this->input->post('res_ac_no'),
'res_routine_no' => $this->input->post('res_routine_no')
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->db->trans_complete();
$name = $this->input->post('bt_first_name')." ".$this->input->post('bt_last_name');
$email = $this->input->post('bt_email');
$account_no = $this->input->post('res_ac_no');
$bsb = $this->input->post('res_routine_no');
if ($this->input->post('braintree_sub_merchant_id') == '') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://".$this->config->item("pin_payment_url")."/1/recipients");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=".$email."&name=".$name."&bank_account[name]=".$name."&bank_account[bsb]=".$bsb."&bank_account[number]=".$account_no);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, $this->config->item("pin_payment_key") . ":" . "");
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
if($this->config->item("pin_payment_is_live")) {
echo 'Error:' . curl_error($ch);
}
}
curl_close($ch);
$response = json_decode($result, true);
if (!array_key_exists("error", $response)) {
$id = $response["response"]["token"];;
$status = "active";
$bt_status_array = array(
'braintree_sub_merchant_id' => $id,
'braintree_sub_merchant_status' => $status
);
$this->db->trans_start();
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $bt_status_array);
$this->db->trans_complete();
// $this->session->set_flashdata('success_msg', 'Restaurant Braintree Registration completed successfully.');
$this->session->set_flashdata('success_msg', $this->lang->line('Ifapprovedyourstatuswillbe'));
} else {
$bt_status_array = array(
'braintree_sub_merchant_status' => 'failed'
);
$this->db->trans_start();
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $bt_status_array);
$this->db->trans_complete();
$reason = '';
if ($result->message) {
$reason = '<br>' . $result->message;
}
$this->session->set_flashdata('error_msg', $this->lang->line('RestaurantPinPaymentRegistration').'' . $reason);
}
}else{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://".$this->config->item("pin_payment_url")."/1/recipients/".$this->input->post('braintree_sub_merchant_id'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=".$email."&name=".$name."&bank_account[name]=".$name."&bank_account[bsb]=".$bsb."&bank_account[number]=".$account_no);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_USERPWD, $this->config->item("pin_payment_key") . ":" . "");
$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
if($this->config->item("pin_payment_is_live")) {
echo 'Error:' . curl_error($ch);
}
}
curl_close ($ch);
$response = json_decode($result, true);
if (!array_key_exists("error", $response)) {
$status = "active";
$bt_status_array = array(
'braintree_sub_merchant_status' => $status
);
$this->db->trans_start();
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $bt_status_array);
$this->db->trans_complete();
$this->session->set_flashdata('success_msg', $this->lang->line('RestaurantPinPaymentRegistrationupdatedsuccessfully'));
}
else {
$reason = '';
if ($result->message) {
$reason = '<br>'.$result->message;
}
$this->session->set_flashdata('error_msg', $this->lang->line('RestaurantPinPaymentRegistrationupdatefailedPleaserecheckallinformation').''.$reason);
// echo "<pre>";
// print_r($result);
// echo "</pre>";
// exit();
}
}
$this->session->set_flashdata('SiteTab', 'BankInfoPinPayment');
// $this->session->set_flashdata('success_msg', 'Restaurant Braintree Registration updated successfully');
redirect('restaurantadmin/updaterestaurant/');
}
function RestauratBankInfo()
{
$restaurant_id = $this->input->post('restaurant_id');
// $data_restaurant= array(
// 'res_bank_name' => $this->input->post('res_bank_name'),
// 'payee_name' => $this->input->post('payee_name'),
// 'is_savings_account' => $this->input->post('is_savings_account'),
// 'is_personal_account' => $this->input->post('is_personal_account'),
// 'res_ac_no' => $this->input->post('res_ac_no'),
// 'res_routine_no' => $this->input->post('res_routine_no'),
// 'res_swift_code' => $this->input->post('res_swift_code')
// );
if ($this->input->post('bt_registered_business') == 1) {
$bt_registered_business = 1;
}
else {
$bt_registered_business = 0;
}
$data_restaurant = array(
'bt_first_name' => $this->input->post('bt_first_name'),
'bt_last_name' => $this->input->post('bt_last_name'),
'bt_email' => $this->input->post('bt_email'),
'bt_phone' => $this->input->post('bt_phone'),
'bt_dob' => $this->input->post('bt_dob'),
'bt_ssn' => $this->input->post('bt_ssn'),
'bt_street_address' => $this->input->post('bt_street_address'),
'bt_locality' => $this->input->post('bt_locality'),
'bt_region' => $this->input->post('bt_region'),
'bt_zipcode' => $this->input->post('bt_zipcode'),
'bt_registered_business' => $bt_registered_business,
'bt_business_legal_name' => $this->input->post('bt_business_legal_name'),
'bt_business_dba_name' => $this->input->post('bt_business_dba_name'),
'bt_business_tax_id' => $this->input->post('bt_business_tax_id'),
'bt_business_street_address' => $this->input->post('bt_business_street_address'),
'bt_business_locality' => $this->input->post('bt_business_locality'),
'bt_business_region' => $this->input->post('bt_business_region'),
'bt_business_zipcode' => $this->input->post('bt_business_zipcode'),
'res_ac_no' => $this->input->post('res_ac_no'),
'res_routine_no' => $this->input->post('res_routine_no')
);
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->update('rt_restaurant',$data_restaurant);
$this->db->trans_complete();
/*Braintree Registration or Update Start*/
if ($bt_registered_business == 1) {
$merchantAccountParams = [
'individual' => [
'firstName' => $this->input->post('bt_first_name'),
'lastName' => $this->input->post('bt_last_name'),
'email' => $this->input->post('bt_email'),
'phone' => $this->input->post('bt_phone'),
'dateOfBirth' => $this->input->post('bt_dob'),
'ssn' => ''.$this->input->post('bt_ssn').'',
'address' => [
'streetAddress' => $this->input->post('bt_street_address'),
'locality' => $this->input->post('bt_locality'),
'region' => $this->input->post('bt_region'),
'postalCode' => $this->input->post('bt_zipcode')
]
],
'business' => [
'legalName' => $this->input->post('bt_business_legal_name'),
'dbaName' => $this->input->post('bt_business_dba_name'),
'taxId' => $this->input->post('bt_business_tax_id'),
'address' => [
'streetAddress' => $this->input->post('bt_business_street_address'),
'locality' => $this->input->post('bt_business_locality'),
'region' => $this->input->post('bt_business_region'),
'postalCode' => $this->input->post('bt_business_zipcode')
]
],
'funding' => [
'descriptor' => SITENAME,
'destination' => 'bank',
'email' => '',
'mobilePhone' => '',
'accountNumber' => $this->input->post('res_ac_no'),
'routingNumber' => $this->input->post('res_routine_no')
],
'tosAccepted' => true,
'masterMerchantAccountId' => BT_MASTER_MERCHANT_ID
];
}
else {
$merchantAccountParams = [
'individual' => [
'firstName' => $this->input->post('bt_first_name'),
'lastName' => $this->input->post('bt_last_name'),
'email' => $this->input->post('bt_email'),
'phone' => $this->input->post('bt_phone'),
'dateOfBirth' => $this->input->post('bt_dob'),
'ssn' => ''.$this->input->post('bt_ssn').'',
'address' => [
'streetAddress' => $this->input->post('bt_street_address'),
'locality' => $this->input->post('bt_locality'),
'region' => $this->input->post('bt_region'),
'postalCode' => $this->input->post('bt_zipcode')
]
],
'funding' => [
'descriptor' => SITENAME,
'destination' => 'bank',
'email' => '',
'mobilePhone' => '',
'accountNumber' => $this->input->post('res_ac_no'),
'routingNumber' => $this->input->post('res_routine_no')
],
'tosAccepted' => true,
'masterMerchantAccountId' => BT_MASTER_MERCHANT_ID
];
}
if ($this->input->post('braintree_sub_merchant_id') == '') {
// echo "empty"; exit();
$result = Braintree_MerchantAccount::create($merchantAccountParams);
if ($result->success) {
// echo "success"; exit();
$id = $result->merchantAccount->id;
$status = $result->merchantAccount->status;
$bt_status_array = array(
'braintree_sub_merchant_id' => $id,
'braintree_sub_merchant_status' => $status
);
$this->db->trans_start();
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $bt_status_array);
$this->db->trans_complete();
$this->session->set_flashdata('success_msg', $this->lang->line('Ifapprovedyourstatuswillbe'));
}
else {
// echo "fail"; exit();
$bt_status_array = array(
'braintree_sub_merchant_status' => 'failed'
);
$this->db->trans_start();
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $bt_status_array);
$this->db->trans_complete();
$reason = '';
if ($result->message) {
$reason = '<br>'.$result->message;
}
// echo $reason; exit();
$this->session->set_flashdata('bt_error_msg', $this->lang->line('RestaurantBraintreeRegistrationfailedPleaserecheckallinformation').''.$reason);
// echo $this->session->flashdata('bt_error_msg');
/*echo "<pre>";
print_r($result);
echo "</pre>";
exit();*/
}
}
else {
$result = Braintree_MerchantAccount::update($this->input->post('braintree_sub_merchant_id'), $merchantAccountParams);
if ($result->success) {
$status = $result->merchantAccount->status;
$bt_status_array = array(
'braintree_sub_merchant_status' => $status
);
$this->db->trans_start();
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $bt_status_array);
$this->db->trans_complete();
$this->session->set_flashdata('success_msg', $this->lang->line('RestaurantBraintreeRegistrationupdatedsuccessfully'));
}
else {
$reason = '';
if ($result->message) {
$reason = '<br>'.$result->message;
}
$this->session->set_flashdata('bt_error_msg', $this->lang->line('RestaurantBraintreeRegistrationupdatefailedPleaserecheckallinformation').''.$reason);
// echo "<pre>";
// print_r($result);
// echo "</pre>";
// exit();
}
}
/*Braintree Registration or Update End*/
$this->session->set_flashdata('SiteTab', 'BankInfo');
// echo $this->session->flashdata('SiteTab'); exit();
// $this->session->set_flashdata('success_msg', 'Restaurant Braintree Registration updated successfully');
redirect('restaurantadmin/updaterestaurant/');
}
function managerestaurant()
{
if ($this->input->server('REQUEST_METHOD') == 'POST')
{
$restaurant_id = $this->input->post('restaurant_id');
$this->db->trans_start();
$data_up= array(
'delivery_by_admin' => $this->input->post('delivery_by_admin'),
'delivery_by_restaurant' => $this->input->post('delivery_by_restaurant'),
'delivery_by_admin_fee' => $this->input->post('delivery_by_admin_fee')
);
$session_data = $this->session->userdata('logged_in');
$id = $session_data['id'];
$this->db->where('id',$id);
$this->db->update('rt_sitesetting',$data_up);
$this->db->trans_complete();
$this->db->trans_start();
$this->db->where('restaurant_id',$restaurant_id);
$this->db->delete('rt_delivery_zone');
$state_code = $this->input->post('state_code');
$timezone_code = $this->input->post('timezone_code');
$estimated_time = $this->input->post('estimated_time');
$time_from = $this->input->post('time_from');
$time_to = $this->input->post('time_to');
$data_insert = array();
foreach($state_code as $key=>$val)
{
$data_option = array(
'state_code' =>$state_code[$key],
'timezone_code' =>$timezone_code[$key],
'estimated_time'=>$estimated_time[$key],
'time_from' =>$time_from[$key],
'time_to' =>$time_to[$key]
);
$this->db->insert('rt_delivery_zone',$data_option);
}
$this->db->trans_complete();
$this->session->set_flashdata('success_msg', $this->lang->line('Deliverysettingsupdatedsuccessfully'));
redirect('restaurantadmin/deliverysettings');
}else
{
$SearchBy = '';
$PerPage = $this->input->post('Per_Page');
if(!$PerPage){
$PerPage = $this->perPage;
}else{
$PerPage = $PerPage;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_restaurat_list());
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataRestaurat/'.$SearchBy;
$config['total_rows'] = $totalRec;
$config['per_page'] = $PerPage;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['RestauratList'] = $this->restaurantmanagement_model->get_restaurat_list(array('limit'=>$PerPage), $SearchBy);
$query['TotalRestaurant'] =$this->restaurantmanagement_model->RestauratStatistics($status='');
$query['ActiveRestaurant'] =$this->restaurantmanagement_model->RestauratStatistics($status='1');
$query['InactiveRestaurant'] =$this->restaurantmanagement_model->RestauratStatistics($status='0');
$query['RestaurantList'] = $this ->restaurantmanagement_model-> RestaurantList();
$data['title']="Manage Restaurant";
$data['page']="managerestaurant";
$query['SiteTab'] ='managerestaurant';
$this->load->view('superadmin/header',$data);
$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/restaurant_list',$query);
$this->load->view('superadmin/footer');
}
}
function ajaxPaginationDataRestaurat(){
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$action = $this->input->post('action');
/*if(!$action){
$action = '';
}else{
$action = $action;
}*/
$perpage = $this->input->post('per_page');
if(!$perpage){
$perpage = $this->perPage;
}else{
$perpage = $perpage;
}
$action2 = $this->input->post('action2');
if(!$action2){
$action2 = '0';
}else{
$action2 = $action2;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_restaurat_list($params = array(), $action,$action2));
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataRestaurat';
$config['total_rows'] = $totalRec;
$config['per_page'] = $perpage;
$config['action'] = $action;
$config['action2'] = $action2;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['RestauratList'] = $this->restaurantmanagement_model->get_restaurat_list(array('start'=>$offset,'limit'=>$perpage),$action,$action2);
$data['title']="Manage Restaurant";
$data['page']="managerestaurant";
/*** Remember what was the last page start ***/
if ($this->input->post('pagination') != '') {
$myPage = $this->input->post('page');
$myAction = $this->input->post('action');
$myPerPage = $this->input->post('per_page');
$myAction2 = $this->input->post('action2');
$paginationArray = array('page' => $myPage, 'action' => $myAction, 'per_page' => $myPerPage, 'action2' => $myAction2, 'page_name' => $data['page'], 'pagination' => $this->input->post('pagination'));
if ($this->session->userdata('paginationArray')) {
$this->session->unset_userdata('paginationArray');
}
$this->session->set_userdata('paginationArray', $paginationArray);
}
/*** Remember what was the last page end ***/
$this->load->view('superadmin/restaurant_list_ajax', $data, false);
}
function restaurantreviews()
{
$SearchBy = '';
$PerPage = $this->input->post('Per_Page');
if(!$PerPage){
$PerPage = $this->perPage;
}else{
$PerPage = $PerPage;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_restaurat_reviews_list());
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataRestauratRewiews/'.$SearchBy;
$config['total_rows'] = $totalRec;
$config['per_page'] = $PerPage;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['ReviewsList'] = $this->restaurantmanagement_model->get_restaurat_reviews_list(array('limit'=>$PerPage), $SearchBy);
$query['TotalRecords'] =$this->restaurantmanagement_model->ReviewsStatistics($status='');
$query['ActiveRecords'] =$this->restaurantmanagement_model->ReviewsStatistics($status='1');
$query['InactiveRecords'] =$this->restaurantmanagement_model->ReviewsStatistics($status='0');
$query['RestaurantList'] = $this ->restaurantmanagement_model-> RestaurantList();
$data['title']="Manage Reviews";
$data['page']="reviews_list";
$query['SiteTab'] ='reviews_list';
$this->load->view('superadmin/header',$data);
$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/restaurant_reviews_list',$query);
$this->load->view('superadmin/footer');
}
function ajaxPaginationDataRestauratRewiews(){
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$action = $this->input->post('action');
/*if(!$action){
$action = '';
}else{
$action = $action;
}*/
$perpage = $this->input->post('per_page');
if(!$perpage){
$perpage = $this->perPage;
}else{
$perpage = $perpage;
}
$action2 = $this->input->post('action2');
if(!$action2){
$action2 = '0';
}else{
$action2 = $action2;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_restaurat_reviews_list($params = array(), $action,$action2));
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataRestauratRewiews';
$config['total_rows'] = $totalRec;
$config['per_page'] = $perpage;
$config['action'] = $action;
$config['action2'] = $action2;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['ReviewsList'] = $this->restaurantmanagement_model->get_restaurat_reviews_list(array('start'=>$offset,'limit'=>$perpage),$action,$action2);
$data['title']="Manage Reviews";
$data['page']="reviews_list";
$query['SiteTab'] ='reviews_list';
/*** Remember what was the last page start ***/
if ($this->input->post('pagination') != '') {
$myPage = $this->input->post('page');
$myAction = $this->input->post('action');
$myPerPage = $this->input->post('per_page');
$myAction2 = $this->input->post('action2');
$paginationArray = array('page' => $myPage, 'action' => $myAction, 'per_page' => $myPerPage, 'action2' => $myAction2, 'page_name' => $data['page'], 'pagination' => $this->input->post('pagination'));
if ($this->session->userdata('paginationArray')) {
$this->session->unset_userdata('paginationArray');
}
$this->session->set_userdata('paginationArray', $paginationArray);
}
/*** Remember what was the last page end ***/
$this->load->view('superadmin/restaurant_reviews_list_ajax', $data, false);
}
function restaurantreport()
{
//$SearchBy = 4;
$SearchBy = '';
$PerPage = $this->input->post('Per_Page');
if(!$PerPage){
$PerPage = $this->perPage;
}else{
$PerPage = $PerPage;
}
//total rows count
$totalRec = count($this->menumanagement_model->get_order_list_restaurant($params = array(),$SearchBy));
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'updaterestaurant/ajaxPaginationDataOrder/'.$SearchBy;
$config['total_rows'] = $totalRec;
$config['per_page'] = $PerPage;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['OrderList'] = $this->menumanagement_model->get_order_list_restaurant(array('limit'=>$PerPage), $SearchBy);
$query['TotalOrder'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='');
$query['OrdersToday'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='today');
$query['OrdersWeek'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='week');
$query['OrdersMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='month');
$query['LastMonth'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='last_month');
$query['OrdersYear'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='year');
$query['LastYear'] =$this->dashboard_model->DashboardOrderStatistics($status='Delivered',$addeddate='last_year');
$query['RestaurantList'] = $this ->restaurantmanagement_model-> RestaurantList();
$data['title']="Manage Report";
$data['page']="report_list";
$query['SiteTab'] ='report_list';
$this->load->view('restaurantadmin/header',$data);
$this->load->view('restaurantadmin/main-sidebar');
$this->load->view('restaurantadmin/restaurant_report_list',$query);
$this->load->view('restaurantadmin/footer');
}
function ajaxPaginationDataOrder(){
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$action = $this->input->post('action');
/*if(!$action){
$action = '';
}else{
$action = $action;
}*/
$perpage = $this->input->post('per_page');
if(!$perpage){
$perpage = $this->perPage;
}else{
$perpage = $perpage;
}
$action2 = $this->input->post('action2');
if(!$action2){
$action2 = '0';
}else{
$action2 = $action2;
}
//total rows count
$totalRec = count($this->menumanagement_model->get_order_list_restaurant($params = array(), $action,$action2));
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'updaterestaurant/ajaxPaginationDataOrder';
$config['total_rows'] = $totalRec;
$config['per_page'] = $perpage;
$config['action'] = $action;
$config['action2'] = $action2;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['OrderList'] = $this->menumanagement_model->get_order_list_restaurant(array('start'=>$offset,'limit'=>$perpage),$action,$action2);
$data['title']="Manage Report";
$data['page']="report_list";
$query['SiteTab'] ='report_list';
$data['perPageCount'] = $page;
/*** Remember what was the last page start ***/
if ($this->input->post('pagination') != '') {
$myPage = $this->input->post('page');
$myAction = $this->input->post('action');
$myPerPage = $this->input->post('per_page');
$myAction2 = $this->input->post('action2');
$paginationArray = array('page' => $myPage, 'action' => $myAction, 'per_page' => $myPerPage, 'action2' => $myAction2, 'page_name' => $data['page'], 'pagination' => $this->input->post('pagination'));
if ($this->session->userdata('paginationArray')) {
$this->session->unset_userdata('paginationArray');
}
$this->session->set_userdata('paginationArray', $paginationArray);
}
/*** Remember what was the last page end ***/
$this->load->view('restaurantadmin/restaurant_report_list_ajax', $data, false);
}
function restaurantsubscriptions()
{
$SearchBy = '';
$PerPage = $this->input->post('Per_Page');
if(!$PerPage){
$PerPage = $this->perPage;
}else{
$PerPage = $PerPage;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_restaurat_subscriptions_list());
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataSubscriptions/'.$SearchBy;
$config['total_rows'] = $totalRec;
$config['per_page'] = $PerPage;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['SubscriptionsList'] = $this->restaurantmanagement_model->get_restaurat_subscriptions_list(array('limit'=>$PerPage), $SearchBy);
$query['RestaurantList'] = $this ->restaurantmanagement_model-> RestaurantList();
$data['title']="Subscription List";
$data['page']="subscription_list";
$query['SiteTab'] ='subscription_list';
$this->load->view('superadmin/header',$data);
$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/restaurant_subscription_list',$query);
$this->load->view('superadmin/footer');
}
function ajaxPaginationDataSubscriptions(){
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$action = $this->input->post('action');
/*if(!$action){
$action = '';
}else{
$action = $action;
}*/
$perpage = $this->input->post('per_page');
if(!$perpage){
$perpage = $this->perPage;
}else{
$perpage = $perpage;
}
$action2 = $this->input->post('action2');
if(!$action2){
$action2 = '0';
}else{
$action2 = $action2;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_restaurat_subscriptions_list());
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataSubscriptions';
$config['total_rows'] = $totalRec;
$config['per_page'] = $perpage;
$config['action'] = $action;
$config['action2'] = $action2;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['OrderList'] = $this->restaurantmanagement_model->get_restaurat_subscriptions_list(array('start'=>$offset,'limit'=>$perpage),$action,$action2);
$data['title']="Subscription List";
$data['page']="subscription_list";
$query['SiteTab'] ='subscription_list';
$this->load->view('superadmin/restaurant_subscription_list_ajax', $data, false);
}
function restaurant_commission($restaurant_id)
{
$SearchBy = '';
$PerPage = $this->input->post('Per_Page');
$PerPage = 1000;
if(!$PerPage){
$PerPage = $this->perPage;
}else{
$PerPage = $PerPage;
}
//total rows count
$totalRec = count($this->menumanagement_model->get_order_list($params = array(), $action = '', $action2 =0, $action3 ='',$restaurant_id));
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataCommission/'.$SearchBy;
$config['total_rows'] = $totalRec;
$config['per_page'] = $PerPage;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['OrderList'] = $this->menumanagement_model->get_order_list(array('limit'=>$PerPage), $action = '', $action2 =0, $action3 ='',$restaurant_id);
$query['RestaurantList'] = $this ->menumanagement_model -> RestaurantList();
$data['title']="Order List";
$query['SiteTab'] ='order_list';
$data['page']="order_list";
$data['restaurant_id']=$restaurant_id;
$this->load->view('superadmin/header',$data);
///$this->load->view('superadmin/main-sidebar');
$this->load->view('superadmin/order_list_restaurant',$query);
$this->load->view('superadmin/footer');
}
function ajaxPaginationDataCommission(){
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$action = $this->input->post('action');
/*if(!$action){
$action = '';
}else{
$action = $action;
}*/
$perpage = $this->input->post('per_page');
if(!$perpage){
$perpage = $this->perPage;
}else{
$perpage = $perpage;
}
$action2 = $this->input->post('action2');
if(!$action2){
$action2 = '0';
}else{
$action2 = $action2;
}
//total rows count
$totalRec = count($this->menumanagement_model->get_order_list());
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'addnewrestaurant/ajaxPaginationDataSubscriptions';
$config['total_rows'] = $totalRec;
$config['per_page'] = $perpage;
$config['action'] = $action;
$config['action2'] = $action2;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['OrderList'] = $this->menumanagement_model->get_order_list(array('start'=>$offset,'limit'=>$perpage),$action,$action2);
$data['title']="Subscription List";
$data['page']="order_list";
$query['SiteTab'] ='subscription_list';
/*** Remember what was the last page start ***/
if ($this->input->post('pagination') != '') {
$myPage = $this->input->post('page');
$myAction = $this->input->post('action');
$myPerPage = $this->input->post('per_page');
$myAction2 = $this->input->post('action2');
$paginationArray = array('page' => $myPage, 'action' => $myAction, 'per_page' => $myPerPage, 'action2' => $myAction2, 'page_name' => $data['page'], 'pagination' => $this->input->post('pagination'));
if ($this->session->userdata('paginationArray')) {
$this->session->unset_userdata('paginationArray');
}
$this->session->set_userdata('paginationArray', $paginationArray);
}
/*** Remember what was the last page end ***/
$this->load->view('superadmin/restaurant_subscription_list_ajax', $data, false);
}
function restaurant_invoice()
{
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
$SearchBy = $restaurant_id;
$PerPage = $this->input->post('Per_Page');
if(!$PerPage){
$PerPage = $this->perPage;
}else{
$PerPage = $PerPage;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_invoice_list());
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'updaterestaurant/ajaxPaginationDataInvoice/'.$SearchBy;
$config['total_rows'] = $totalRec;
$config['per_page'] = $PerPage;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['InvoiceList'] = $this->restaurantmanagement_model->get_invoice_list(array('limit'=>$PerPage), $SearchBy);
//$query['Driverlist'] = $this ->restaurantmanagement_model -> DriverList();
//$query['CategoryList'] = $this ->driver_model -> CategoryList();
$query['data'] =$this->restaurantmanagement_model->GetRestauratDetails($restaurant_id);
$data['title']="Invoice";
$query['SiteTab'] ='restaurant_invoice';
$data['page']="restaurant_invoice";
$this->load->view('restaurantadmin/header',$data);
$this->load->view('restaurantadmin/main-sidebar');
$this->load->view('restaurantadmin/restaurant_invoice_list',$query);
$this->load->view('restaurantadmin/footer');
}
function ajaxPaginationDataInvoice(){
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$action = $this->input->post('action');
$perpage = $this->input->post('per_page');
if(!$perpage){
$perpage = $this->perPage;
}else{
$perpage = $perpage;
}
$action2 = $this->input->post('action2');
if(!$action2){
$action2 = '0';
}else{
$action2 = $action2;
}
//total rows count
$totalRec = count($this->restaurantmanagement_model->get_invoice_list($params = array(), $action,$action2));
//pagination configuration
$config['target'] = '#postList';
$config['base_url'] = base_url().'updaterestaurant/ajaxPaginationDataInvoice';
$config['total_rows'] = $totalRec;
$config['per_page'] = $perpage;
$config['action'] = $action;
$config['action2'] = $action2;
$this->ajax_pagination->initialize($config);
//get the posts data
$data['InvoiceList'] = $this->restaurantmanagement_model->get_invoice_list(array('start'=>$offset,'limit'=>$perpage),$action,$action2);
$data['title']="Restaurant invoice";
$data['page']="restaurant_invoice";
/*** Remember what was the last page start ***/
if ($this->input->post('pagination') != '') {
$myPage = $this->input->post('page');
$myAction = $this->input->post('action');
$myPerPage = $this->input->post('per_page');
$myAction2 = $this->input->post('action2');
$paginationArray = array('page' => $myPage, 'action' => $myAction, 'per_page' => $myPerPage, 'action2' => $myAction2, 'page_name' => $data['page'], 'pagination' => $this->input->post('pagination'));
if ($this->session->userdata('paginationArray')) {
$this->session->unset_userdata('paginationArray');
}
$this->session->set_userdata('paginationArray', $paginationArray);
}
/*** Remember what was the last page end ***/
$this->load->view('restaurantadmin/restaurant_invoice_list_ajax', $data, false);
}
function isUserExist($restaurant_contact_email)
{
$session_data = $this->session->userdata('logged_in_restaurant');
$restaurant_id = $session_data['id'];
$is_exist = $this->user->IsUserExist($restaurant_contact_email,$restaurant_id);
if ($is_exist) {
$this->form_validation->set_message('isUserExist', 'Email is already exist.');
return false;
}else{
return true;
}
}
function isRestNameExist($restaurant_name,$id)
{
$restaurant_id = $this->input->post('restaurant_id');
$is_exist = $this->user->isRestNameExist($restaurant_name,$restaurant_id);
if ($is_exist) {
$this->form_validation->set_message('isRestNameExist', 'Name is already exist.');
return false;
}else{
return true;
}
}
function agreement() {
$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);
}
$query['RestaurantAgreement'] = $myContent;
$now = date('Y-m-d H:i:s');
$data_up = array(
'agreement_view' => htmlspecialchars_decode($query['RestaurantAgreement']),
'agreement_status' => '1',
'agreement_date' => $now
);
$this->db->where('restaurant_id', $restaurant_id);
$this->db->update('rt_restaurant', $data_up);
$this->session->set_flashdata('success_msg', $this->lang->line('Youhavesuccessfullyacceptedtheagreement'));
redirect('restaurantadmin/updaterestaurant/');
}
}