| 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/public_html/lrsys_projetos/sopizzas/application/models/ |
Upload File : |
<?php
Class createorder_model extends CI_Model {
function CategoryByRestaurant($restaurant_id) {
$this->db->select('maincateid, maincatename');
$this->db->from('rt_category_main');
$this->db->where('restaurant_id', $restaurant_id);
$this->db->order_by('maincatename', 'ASC');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
}
else {
return false;
}
}
function MenuByCategory($menu_category) {
$this->db->select('*');
$this->db->from('rt_restaurant_menu');
$this->db->where('menu_category', $menu_category);
$this->db->order_by('menu_name', 'ASC');
$query = $this->db->get();
$result = $query->result();
if ($query->num_rows() > 0) {
foreach ($result as &$object) {
$is_menu_slice = $object->sizeoption;
if($is_menu_slice=='size'){
$restaurant_id = $object->restaurant_id;
$menu_slice_menuid= $object->id;
$menu_price = $this->menuSlicePrice($menu_slice_menuid);
$object->menu_price = $menu_price;
}
}
return $result;
}
else {
return false;
}
}
function menuSlicePrice($menu_slice_menuid) {
$this->db->select('*');
$this->db->from('rt_restaurant_menu_slice');
$this->db->where('menu_slice_menuid',$menu_slice_menuid);
$query = $this->db->get();
if ($query->num_rows() > 0) {
$price = $query->row();
return $price->menu_slice_price;
}
return 0;
}
function showEditMenu($menuid) {
$is_active = '1';
$this->db->select('*');
$this->db->from('rt_restaurant_menu');
$this->db->where('id', $menuid);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row_array();
}
else {
return false;
}
}
function showEditMenuSize($menuid) {
$is_active = '1';
$this->db->select('*');
$this->db->from('rt_restaurant_menu_slice');
$this->db->where('menu_slice_menuid', $menuid);
$this->db->order_by('menu_slice_id', 'ASC');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
}
else {
return false;
}
}
function showEditMenuParentAddon($menuid) {
$is_active = '1';
$this->db->select('*');
$this->db->from('rt_restaurant_menuaddons');
$this->db->where('menuaddons_menuid', $menuid);
$this->db->where('addonparentid', '0');
$this->db->order_by('menuaddons_id', 'ASC');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
}
else {
return false;
}
}
function showEditMenuChildAddon($parentid) {
$is_active = '1';
$this->db->select('*');
$this->db->from('rt_restaurant_menuaddons');
$this->db->where('addonparentid', $parentid);
$this->db->order_by('menuaddons_id', 'ASC');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
}
else {
return false;
}
}
function restOrderType($restaurant_id) {
$this->db->select('restaurant_delivery, restaurant_pickup, restaurant_dinein');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $restaurant_id);
$query = $this->db->get();
$data = $query->row();
return $data;
}
function restSalesTax($restaurant_id) {
$this->db->select('restaurant_salestax');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $restaurant_id);
$query = $this->db->get();
$data = $query->row();
if ($query->num_rows() > 0) {
$restaurant_salestax = $data->restaurant_salestax;
}
else {
$restaurant_salestax = 0;
}
return $restaurant_salestax;
}
function restName($restaurant_id) {
$this->db->select('restaurant_name');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $restaurant_id);
$query = $this->db->get();
$data = $query->row();
if ($query->num_rows() > 0) {
$restaurant_name = $data->restaurant_name;
}
else {
$restaurant_name = 0;
}
return $restaurant_name;
}
function deliveryCharge() {
// $this->db->select('delivery_by_admin_fee');
// $this->db->from('rt_sitesetting');
// $query = $this->db->get();
// $data = $query->row();
// $delivery_by_admin_fee = $data->delivery_by_admin_fee;
$deliveryCharge = 0;
if ($this->session->userdata('delivery_details')) {
$myData = $this->session->userdata('delivery_details');
if ($myData['isDeliveryAvailable']) {
$deliveryCharge = $myData['deliveryCharge'];
}
}
$delivery_by_admin_fee = $deliveryCharge;
return $delivery_by_admin_fee;
}
function restaurantCommission($restaurant_id, $itemTotal = 0, $deliveryCharge = 0, $taxAmount = 0, $offervalue = 0, $tips = 0) {
$this->db->select('restaurant_commissiontype, restaurant_commission_percnt, restaurant_commission_fixed');
$this->db->from('rt_restaurant');
$query = $this->db->get();
$data = $query->row();
if ($data->restaurant_commissiontype == 0) {
$commission_amount = $data->restaurant_commission_fixed;
}
// else if ($data->restaurant_commissiontype == 1) {
// $commission_amount = $itemTotal * ($data->restaurant_commission_percnt / 100);
// }
else if ($data->restaurant_commissiontype == 1) {
// $commission_amount = ($itemTotal + $deliveryCharge + $taxAmount) * ($data->restaurant_commission_percnt / 100);
$commission_amount = (floatval($itemTotal) + floatval($taxAmount) - floatval($offervalue)) * (floatval($data->restaurant_commission_percnt) / 100);
}
else {
$commission_amount = 0;
}
//$earnings = $commission_amount + $deliveryCharge + $taxAmount + $tips;
$earnings = $commission_amount;
return $earnings;
}
function ccEncrypt($password, $time){
//appending padding characters
$newPass = rand(0,9) . rand(0,9);
$c = 1;
while ($c < 15 && (int)substr($newPass,$c-1,1) + 1 != (int)substr($newPass,$c,1)){
$newPass .= rand(0,9);
$c++;
}
$newPass .= $password;
//applying XOR
$newSeed = md5(SEED . $time);
$passLength = strlen($newPass);
while (strlen($newSeed) < $passLength) $newSeed.= $newSeed;
$result = (substr($newPass,0,$passLength) ^ substr($newSeed,0,$passLength));
return base64_encode($result);
}
function ccDecrypt($password, $time){
$b64decoded = base64_decode($password);
//applying XOR
$newSeed = md5(SEED . $time);
$passLength = strlen($b64decoded);
while (strlen($newSeed) < $passLength) $newSeed.= $newSeed;
$original_password = (substr($b64decoded,0,$passLength) ^ substr($newSeed,0,$passLength));
//removing padding
$c = 1;
while($c < 15 && (int)substr($original_password,$c-1,1) + 1 != (int)substr($original_password,$c,1)){
$c++;
}
return substr($original_password,$c+1);
}
function getCCDetails($customer_id) {
$this->db->select('*');
$this->db->from('rt_credit_cards');
$this->db->where('customer_id', $customer_id);
$query = $this->db->get();
$details = $query->row();
if ($details) {
$details->cc_number = $this->ccDecrypt($details->cc_number, $details->cc_time);
$details->cc_cvv = $this->ccDecrypt($details->cc_cvv, $details->cc_time);
}
return $details;
}
function orderShortDetails($orderid) {
$this->db->select('*');
$this->db->from('rt_order');
$this->db->where('orderid', $orderid);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row();
}
else {
return false;
}
}
function orderLongDetails($orderid) {
$this->db->select('*');
$this->db->from('rt_restaurant_cart');
$this->db->where('orderid', $orderid);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
}
else {
return false;
}
}
function fetchCityName($city_id) {
$this->db->select('cityname');
$this->db->from('rt_city');
$this->db->where('city_id', $city_id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row()->cityname;
}
else {
return false;
}
}
function fetchStateName($statecode) {
$this->db->select('statename');
$this->db->from('rt_state');
$this->db->where('statecode', $statecode);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row()->statename;
}
else {
return false;
}
}
function billingStateList() {
$this->db->select('*');
$this->db->from('rt_billing_state');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
}
else {
return false;
}
}
function restaurantDeliveryDetails($restaurant_id) {
$this->db->select('delivery_zone_1, delivery_zone_2, delivery_zone_3, restaurant_delivery_charge, restaurant_minorder_price, restaurant_delivery_charge_2, restaurant_minorder_price_2, restaurant_delivery_charge_3, restaurant_minorder_price_3');
$this->db->from('rt_restaurant');
$this->db->where('restaurant_id', $restaurant_id);
$query = $this->db->get();
$row = $query->row();
// echo $this->db->last_query();
return $row;
}
}