/** * List all meal follow restaurant */ public function indexAction() { $this->view->headTitle('Ship information'); $order_id = session_id(); //$this->_getParam('order_id', false); $this->view->order_id = $order_id; $obj_country = new Models_Country(); $arr_province = $obj_country->getAllProvincesWithCode(); // echo '<pre>';print_r($arr_province);die; $this->view->arr_province = $arr_province; /** * Get customer's information */ $data = @$_SESSION['cart_customer']; if (null == $data || false == $data) { /** * Get logged user */ $user = Vi_Registry::getLoggedInUser(); // echo '<pre>';print_r($user);die; if (false != $user) { $data = array('full_name' => trim($user['full_name']), 'address' => $user['address'], 'address' => $user['address'], 'note' => $user['suite_apt_note'], 'city' => $user['city'], 'state' => $user['state'], 'zip_code' => $user['zipcode'], 'phone1' => $user['phone1'], 'phone2' => $user['phone2'], 'phone3' => $user['phone3'], 'email' => $user['email']); } } $this->view->data = $data; /** * Expired year */ $years = array(); for ($i = date('Y'); $i <= date('Y') + 7; $i++) { $years[] = $i; } $this->view->years = $years; $this->view->cartErrorMsg = @$_SESSION['card_error_msg']; $_SESSION['card_error_msg'] = null; $this->view->mark = strtoupper($_SESSION['cart'][$order_id]['order_service']); $this->view->date = $_SESSION['cart'][$order_id]['date']; $this->view->time = $_SESSION['cart'][$order_id]['time']; $order_id = session_id(); if (isset($_SESSION['cart'][$order_id])) { $this->view->subtotal = $_SESSION['cart'][$order_id]['subtotal']; $this->view->tax = $_SESSION['cart'][$order_id]['tax']; $this->view->shipping = $_SESSION['cart'][$order_id]['shipping']; $this->view->ordertotal = $_SESSION['cart'][$order_id]['ordertotal']; } }
public function editMealAction() { $rid = $this->_getParam('rid', false); if (false == $rid) { $this->_redirect('restaurant/admin/manager'); } /** * Get all provice CODE */ $objCountry = new Models_Country(); $this->view->allProvinces = $objCountry->getAllProvinces(); /** * Get some list */ $objCat = new Models_Category(); $this->view->leadTimeNormal = $objCat->getAllValues('lead_time_normal'); $this->view->leadTimeCatering = $objCat->getAllValues('lead_time_catering'); // echo '<pre>';print_r($this->view->allProvinces);die; /** * Get data */ $objMeal = new Models_Meal(); $data = $this->_getParam('data', false); $id = $this->_getParam('id', false); $error = ''; if (false != $data) { /** * Insert new meal */ $newMeal = $data; $newMeal['price'] = number_format($newMeal['price'], 2, '.', ''); if (null != $newMeal['image']) { $newMeal['image'] = $this->getImagePath($newMeal['image']); $newMeal['image_thumb'] = $this->getThumbnailImagePath($newMeal['image']); } // echo '<pre>';print_r($newMeal);die; $objMeal->update($newMeal, array('meal_id=?' => $id)); $this->session->mealMessage = array('success' => true, 'message' => Vi_Language::translate('Edit meal successfully')); $this->_redirect('restaurant/admin/meal-manager/rid/' . $rid . '#listofmeal'); } else { /** * Loading data */ $data = $objMeal->find($id)->toArray(); $data = current($data); if (false == $data) { $this->_redirect('restaurant/admin/meal-manager/rid/' . $rid); } } $cuisines = $objCat->getAllValues('cuisine'); $this->view->cuisines = $cuisines; $this->view->data = $data; $this->view->error = $error; $this->view->headTitle('Edit Meal'); $this->view->menu = array('restaurant'); }
function autocompleteCityAction() { $query = $this->_getParam('query', false); $objCountry = new Models_Country(); $cities = $objCountry->getAllCountry($query); $counter = 0; $str_jason = ""; $str_jason .= "{"; $str_jason .= "query:'{$query}',"; $str_jason .= "suggestions:["; $tmpArr = array(); foreach ($cities as $key => $value) { $name = $value['city']; $name = addslashes(trim($name, "\r\n ")); $tmpArr[] = "'{$name}'"; } if (!empty($tmpArr)) { $str_jason .= implode(',', $tmpArr); } $str_jason .= "]}"; echo $str_jason; exit; }
public function finishAction() { $order_id = session_id(); $this->view->headTitle('Reservation'); $objReser = new Models_Reservation(); $resId = $this->_getParam('rid', false); if (false === $resId) { $this->_redirect(''); } /** * Get restaurant */ $objRes = new Models_Restaurant(); $res = $objRes->find($resId)->toArray(); $res = current($res); if (false == $res || '0' == $res['reser_onoff']) { $this->_redirect(''); } /** * Check active restaurant */ $this->_checkReservationOfRestaurant($res); /** * Get search condition */ $t = $this->_getParam('t', false); $search = $this->session->reserSearch; if (null == $search || false == $t || 0 >= $search['quantity']) { $this->_redirect('restaurant/reservation/index/rid/' . $resId); } $t = base64_decode($t); /** * Update search */ $search['date'] = date('m/d/Y', $t); $search['time'] = date('G', $t) * 3600 + ceil(date('i', $t) / 30) * 1800; $search['unixTime'] = $t; $this->session->reserSearch = $search; // echo '<pre>';print_r($search);die; /** * Check availabe at current time */ $exitResers = $objReser->searchExistRerservation($t, $t, $res['reser_quantity'] - $search['quantity']); if (0 < count($exitResers)) { /** * Some users are faster :) */ $this->_redirect('restaurant/reservation/index/rid/' . $resId); } /** * Submit? */ $error = ''; $data = $this->_getParam('data', false); // echo '<pre>';print_r($data);die; if (false != $data) { // echo '<pre>';print_r($data);die; /** * Insert reservation */ $newData = array('restaurant_id' => $resId, 'time' => $search['unixTime'], 'quantity' => $search['quantity'], 'created_date' => time(), 'deposit' => '1' == $res['reser_deposit_onoff'] ? $res['reser_deposit'] : 0, 'full_name' => $data['full_name'], 'address' => $data['address'], 'note' => $data['note'], 'city' => $data['city'], 'state' => $data['state'], 'zip_code' => $data['zip_code'], 'phone' => $data['phone1'] . "." . $data['phone2'] . "." . $data['phone3'], 'email' => $data['email'], 'special_request' => $data['special_request']); $newReserId = $objReser->insert($newData); if ('1' == $res['reser_deposit_onoff']) { /************************************************************************** * Make payment */ require_once 'libs/paypal/CallerService.php'; /** * Fist name, last name */ $firstName = trim(substr($data['full_name'], 0, strpos($data['full_name'] . ' ', ' ') + 1)); $lastName = trim(substr($data['full_name'], strlen($firstName))); /** * Get required parameters from the web form for the request */ $paymentType = urlencode('Sale'); $firstName = urlencode($firstName); $lastName = urlencode($lastName); $creditCardType = urlencode($data['card_type']); $creditCardNumber = urlencode($data['card_number']); $expDateMonth = urlencode($data['card_month']); // Month must be padded with leading zero $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT); $expDateYear = urlencode($data['card_year']); $cvv2Number = urlencode($data['card_cvv']); $address1 = urlencode($data['address']); $address2 = urlencode(''); $city = urlencode($data['city']); $state = urlencode($data['state']); $zip = urlencode($data['zip_code']); $amount = urlencode(number_format($res['reser_deposit'], 2, '.', '')); $currencyCode = "CAD"; // $state = 'NL'; $country = 'CA'; /* Construct the request string that will be sent to PayPal. The variable $nvpstr contains all the variables and is a name value pair string with & as a delimiter */ $nvpstr = "&PAYMENTACTION={$paymentType}&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&LASTNAME={$lastName}&STREET={$address1}&CITY={$city}&STATE={$state}" . "&ZIP={$zip}&COUNTRYCODE={$country}&CURRENCYCODE={$currencyCode}"; // echo $nvpstr;die; /* Make the API call to PayPal, using API signature. The API response is stored in an associative array called $resArray */ $resArray = hash_call("doDirectPayment", $nvpstr); // echo '<pre>';print_r($resArray);die; /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' If the response was an error, display the errors received using APIError.php. */ $ack = strtoupper($resArray["ACK"]); /** * End payment **************************************************************************/ } if ('1' == $res['reser_deposit_onoff'] && $ack != "SUCCESS") { $error = @$resArray['L_LONGMESSAGE0']; /** * Delete reservation */ $objReser->delete(array('reservation_id=?' => $newReserId)); } else { /** * Success */ /** * Send email to admin and user */ $objUser = new Models_User(); $objMail = new Models_Mail(); $config = Vi_Registry::getConfig(); $cardNumber = @$data['card_number']; $cardNumber[4] = 'X'; $cardNumber[5] = 'X'; $cardNumber[6] = 'X'; $cardNumber[7] = 'X'; $cardNumber[8] = 'X'; $cardNumber[9] = 'X'; $cardNumber[10] = 'X'; $cardNumber[11] = 'X'; $data['card_number'] = $cardNumber; $cartDetail = "\n <table width='90%'>\n <tr>\n <td width='55%'></td>\n <td width='15%'></td>\n <td width='15%'></td>\n <td width='15%'></td>\n </tr>\n <tr>\n <td style='color: #442006; font-weight: bold;'>SHIPPING ADDRESS</td>\n <td colspan='3' style='color: #442006; font-weight: bold;'>RESTAURANT</td>\n </tr> \n <tr>\n <td valign='top'>\n <br/>\n <table width='400px;'>\n \n <tr>\n <td width='30%' align='right' style='background-color: #EEEEEE;'>Full Name:</td>\n <td width='70%' style='color: #442006;'>{$data['full_name']}</td>\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n <td style='color: #442006;'>{$data['address']}</td>\n \n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Postal Code:</td>\n <td style='color: #442006;'>{$data['zip_code']}</td>\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Phone:</td>\n \n <td style='color: #442006;'>{$data['phone1']}.{$data['phone2']}.{$data['phone3']}</td>\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Special Requests:</td>\n \n <td style='color: #442006;'>{$data['special_request']}</td>\n </tr>\n </table>\n <br/>\n \n </td>\n <td valign='top'>\n <br/>\n <table width='400px;'>\n \n <tr>\n <td width='30%' align='right' style='background-color: #EEEEEE;'>Name:</td>\n <td width='70%' style='color: #442006;'>{$res['name']}</td>\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n <td style='color: #442006;'>{$res['street']}, {$res['city']}, {$res['state']}</td>\n </tr>\n <tr>\n <td width='30%' align='right' style='background-color: #EEEEEE;'>Phone:</td>\n <td width='70%' style='color: #442006;'>{$res['phone']}</td>\n </tr>" . ('1' == $res['reser_deposit_onoff'] ? "\n <tr>\n <td colspan='2' style='color: #442006; font-weight: bold;'><br/>PAYMENT METHOD</td>\n </tr>\n <tr>\n <td align='right' colspan='2'>{$data['card_type']}: {$data['card_number']}</td>\n </tr>" : "") . "\n </table>\n <br/>\n </td>\n \n </tr>\n </table> \n \n <table width='90%'> \n <tr style='background-color: #DDDDDD;'>\n <td width='25%' style='color: #AD5B21; font-weight: bold;'> Date</td>\n <td width='25%' style='color: #AD5B21; font-weight: bold;'> Time</td>\n <td width='25%' style='color: #AD5B21; font-weight: bold;'> Party Size</td>\n <td width='25%' style='color: #AD5B21; font-weight: bold;'> Deposit</td>\n </tr>\n <tr>\n <td style='border-bottom: 1px solid #DDDDDD;'> " . date('m/d/Y', $t) . " </td>\n <td style='border-bottom: 1px solid #DDDDDD;'> " . date('g:i A', $t) . "</td>\n <td style='border-bottom: 1px solid #DDDDDD;'> {$search['quantity']} " . (1 == $search['quantity'] ? 'person' : 'people') . " </td>\n <td style='border-bottom: 1px solid #DDDDDD;'>\$ " . ('1' == $res['reser_deposit_onoff'] ? number_format($res['reser_deposit'] * 1.0, 2) : 0) . "</td>\n </tr>\n \n </table>\n "; $data['card_detail'] = $cartDetail; // echo '<pre>';print_r($data);die; $admin = $objUser->getByUserName('admin'); $objMail->sendHtmlMail('reservation_order', $data, array($admin['email'], $data['email'], $res['owner_email'])); /** * Redirec to success page */ $objContent = new Models_ScontentLang(); $this->_redirect($objContent->getUrlWithoutAppBaseUrl(22)); return; } } /** * Data for view */ $this->view->res = $res; $this->view->arr_restaurant = $res; $this->view->resId = $resId; $this->view->search = $search; $this->view->data = $data; $this->view->error = $error; $this->view->address_restaurant = $res['street'] . " " . $res['city'] . " " . $res['state']; /** * Expired year */ $years = array(); for ($i = date('Y'); $i <= date('Y') + 7; $i++) { $years[] = $i; } $this->view->years = $years; /** * All province */ $obj_country = new Models_Country(); $arr_province = $obj_country->getAllProvincesWithCode(); $this->view->arr_province = $arr_province; }
public function editRestaurantAction() { /** * Get all provice CODE */ $objCountry = new Models_Country(); $this->view->allProvinces = $objCountry->getAllProvinces(); /** * Get some list */ $objCat = new Models_Category(); $this->view->leadTimeNormal = $objCat->getAllValues('lead_time_normal'); $this->view->leadTimeCatering = $objCat->getAllValues('lead_time_catering'); // echo '<pre>';print_r($this->view->allProvinces);die; /** * Get data */ $objRes = new Models_Restaurant(); $objUser = new Models_User(); $objUserExp = new Models_UserExpand(); $data = $this->_getParam('data', false); $user = $this->_getParam('user', false); $condition = $this->_getParam('condition', false); if (false != $data && false != $user) { /** * Update restaurant */ $newRes = $data; /** * Modify date */ $dateArr = array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'); foreach ($dateArr as $item) { if ('1' != @$newRes["date_{$item}"]) { unset($newRes["date_{$item}_start"]); unset($newRes["date_{$item}_end"]); } else { /** * Change correct time */ if (null == @$newRes["date_{$item}_start"]) { $newRes["date_{$item}_start"] = '00:00'; //0 hours } else { $tmp = explode(':', $newRes["date_{$item}_start"]); /** * Hour */ if (null == @$tmp[0]) { $tmp[0] = 0; } $tmp[0] = '00' . abs(intval($tmp[0])); $tmp[0] = substr($tmp[0], -2, 2); if (23 < intval($tmp[0])) { $tmp[0] = '00'; } /** * Minute */ if (null == @$tmp[1]) { $tmp[1] = 0; } $tmp[1] = '00' . abs(intval($tmp[1])); $tmp[1] = substr($tmp[1], -2, 2); if (59 < intval($tmp[1])) { $tmp[1] = '00'; } $newRes["date_{$item}_start"] = $tmp[0] . ':' . $tmp[1]; } if (null == @$newRes["date_{$item}_end"]) { $newRes["date_{$item}_end"] = 24 * 3600 - 60; //23:59:59 hours } else { $tmp = explode(':', $newRes["date_{$item}_end"]); /** * Hour */ if (null == @$tmp[0]) { $tmp[0] = 23; } $tmp[0] = '00' . abs(intval($tmp[0])); $tmp[0] = substr($tmp[0], -2, 2); if (23 < intval($tmp[0])) { $tmp[0] = '23'; } /** * Minute */ if (null == @$tmp[1]) { $tmp[1] = 59; } $tmp[1] = '00' . abs(intval($tmp[1])); $tmp[1] = substr($tmp[1], -2, 2); if (59 < intval($tmp[1])) { $tmp[1] = '59'; } $newRes["date_{$item}_end"] = $tmp[0] . ':' . $tmp[1]; } } } /** * Modify data */ if ('1' != @$newRes['check']['pickup']) { unset($newRes['pickup']); } if ('1' != @$newRes['check']['curbside']) { unset($newRes['curbside']); } if ('1' != @$newRes['check']['delivery']) { unset($newRes['delivery']); unset($newRes['delivery_limit_hour']); unset($newRes['delivery_charge']); unset($newRes['delivery_minimum']); } if ('1' != @$newRes['check']['catering_pickup']) { unset($newRes['catering_pickup']); } if ('1' != @$newRes['check']['catering_delivery']) { unset($newRes['catering_delivery']); unset($newRes['catering_delivery_limit_hour']); unset($newRes['catering_delivery_charge']); unset($newRes['catering_delivery_minimum']); } /** * Remove tempory data */ unset($newRes['check']); unset($newRes['owner_email']); // echo '<pre>';print_r($newRes);die; $objRes->update($newRes, array('restaurant_id=?' => Vi_Registry::getRestaurantIdFromLoggedUser())); /** * Update new password */ $newUser = $user; // echo '<pre>';print_r($newUser);die; if (null != $newUser['password'] && $newUser['password'] == $newUser['retype_password']) { $newUser['password'] = md5($newUser['password']); /** * TODO Read date format from language table */ unset($newUser['retype_password']); } else { /** * Don't change password */ unset($newUser['password']); unset($newUser['retype_password']); } unset($newUser['email']); unset($newUser['username']); $newUser['company'] = $data['name']; $newUser['full_name'] = $data['owner']; $objUser->update($newUser, array('user_id=?' => Vi_Registry::getLoggedInUserId())); $this->view->updateSuccess = true; } /** * Reload user and restaurant */ $user = Vi_Registry::getLoggedInUser()->toArray(); $data = $objRes->getByColumnName(array('user_id=?' => $user['user_id']))->toArray(); $data = current($data); $this->view->user = $user; $this->view->data = $data; $cuisines = $objCat->getAllValues('cuisine'); $this->view->cuisines = $cuisines; $this->view->headTitle('Restaurant Owner Register'); // $this->setLayout('front2'); }