/**
  * The default action - show the home page
  */
 public function loginAction()
 {
     $this->view->headTitle(Vi_Language::translate("Login to Visual Idea Control Panel"));
     $this->setLayout('default', 'default');
     $loginError = false;
     $submitHandler = Vi_Registry::getAppBaseUrl() . "access/admin/login";
     $params = $this->_request->getParams();
     if ($this->_request->isPost() && isset($params['username']) && $params['username'] != "") {
         $authAdapter = new Vi_Auth_Adapter();
         $authAdapter->setUserInfo($params['username'], $params['password']);
         $result = $this->auth->authenticate($authAdapter);
         if ($result->isValid()) {
             //TODO: update last login time
             $objUser = new Models_User();
             $objUser->updateLastLogin($params['username']);
             /**
              * Remember this user
              */
             $this->session->backendUser = $objUser->getByUserName($params['username'])->toArray();
             if ($this->_getCallBackUrl()) {
                 $this->_redirect($this->_getCallBackUrl());
             } else {
                 $this->_redirect("");
             }
         } else {
             $loginError = true;
         }
     }
     $this->view->submitHandler = $submitHandler;
     $this->view->loginError = $loginError;
     //		echo $this->session->accessMessage;die;
     $this->view->accessMessage = $this->session->accessMessage;
     $this->session->accessMessage = null;
 }
Example #2
0
 /**
  * Override Smarty::_read_file
  * Read template email from database
  *
  * @param string $filename
  * @return string|bool Return false if not found
  */
 function _read_file($filename)
 {
     //        if ( file_exists($filename) && is_readable($filename) && ($fd = @fopen($filename, 'rb')) ) {
     //            $contents = '';
     //            while (!feof($fd)) {
     //                $contents .= fread($fd, 8192);
     //            }
     //            fclose($fd);
     //            return $contents;
     //        } else {
     //            return false;
     //        }
     //        echo $filename . "<hr/>HERE";die;
     $objMail = new Objects_Mail();
     if (Vi_Registry::isRegistered('emailLangCode')) {
         $langCode = Vi_Registry::get('emailLangCode');
     } else {
         $langCode = Vi_Registry::getLangCode();
     }
     $template = $objMail->getMailTemplate($filename, $langCode);
     if (null == $template) {
         return false;
     } else {
         return $template['content'];
     }
 }
Example #3
0
 /**
  * initialize all config for vi system
  * @return unknown_type
  */
 public function __construct()
 {
     //MD5(?) AND active = "TRUE"
     $config = Vi_Registry::getConfig();
     $db = Vi_Registry::getDB();
     parent::__construct($db, $config['database']['params']['prefix'] . "user", 'username', 'password', 'MD5(?) AND enabled = 1');
 }
 /**
  * postDispatch - auto render a view
  *
  * Override Zend_Controller_Action_Helper_ViewRenderer::postDispatch()
  * @return void
  */
 public function postDispatch()
 {
     /**
      * Get module name, controller name, action name
      */
     $request = $this->getRequest();
     $module = $request->getModuleName();
     if (null === $module) {
         $module = $this->getFrontController()->getDispatcher()->getDefaultModule();
     }
     $controller = $request->getControllerName();
     if (null === $controller) {
         $controller = $this->getFrontController()->getDispatcher()->getDefaultControllerName();
     }
     $action = $request->getActionName();
     if (null == $action) {
         $action = $this->getFrontController()->getDispatcher()->getDefaultAction();
     }
     /**
      * Set cacheId for Smarty's caching
      */
     $langCode = Vi_Registry::get('langCode');
     $this->view->cacheId = Vi_Registry::getAppName() . '|' . $langCode . '|module|' . $module . '_' . $controller . '_' . $action . ($this->view->cacheId ? '_' . $this->view->cacheId : '');
     /**
      * Call parent's postDispatch() function
      */
     $result = parent::postDispatch();
     /**
      * Revive Vi_Language::$currentType and Vi_Language::$currentName
      */
     Vi_Language::$currentType = Vi_Registry::get('controllerCurrentType');
     Vi_Language::$currentName = Vi_Registry::get('controllerCurrentName');
     return $result;
 }
Example #5
0
 protected function _initAcl()
 {
     $isRedirect = false;
     if (!parent::_initAcl()) {
         $isRedirect = true;
     } else {
         $username = $this->auth->getUsername();
         $this->aclAdmin = new Vi_Acl($username);
         Vi_Registry::set('aclAdmin', $this->aclAdmin);
         //		    echo '<pre>';print_r($this->aclAdmin);die;
         $isRedirect = !$this->aclAdmin->checkPermission('access', 'application::' . Vi_Registry::getAppName());
     }
     if ($isRedirect && Vi_Registry::getModuleName() != 'access') {
         $url = "";
         $module = Vi_Registry::getModuleName();
         $controller = Vi_Registry::getControllerName();
         $action = Vi_Registry::getActionName();
         $params = $this->_request->getParams();
         $url .= $module . '/' . $controller . '/' . $action . '/';
         unset($params[Vi_Registry::getModuleKey()]);
         unset($params[Vi_Registry::getControllerKey()]);
         unset($params[Vi_Registry::getActionKey()]);
         //			echo "<pre>";print_r($params);die;
         foreach ($params as $key => $param) {
             $url .= @urlencode($key) . '/' . @urlencode($param);
         }
         $this->_setCallBackUrl($url);
         if (null != $this->auth->getUsername()) {
             $this->session->accessMessage = Vi_Language::translate("You don't have permission to access this application");
         }
         $this->_redirect("access/admin/login");
     }
     return true;
 }
 public function getUrlWithoutAppBaseUrl($id)
 {
     $result = $this->getByColumnName(array('scontent_id=?' => $id))->toArray();
     $result = current($result);
     if (null == @$result['url']) {
         return Vi_Registry::getAppBaseUrl();
     }
     return 'page/' . $result['url'] . '.html';
 }
 public function run()
 {
     $langCode = Vi_Registry::get('langCode');
     $loggedUser = Vi_Registry::getLoggedInUser();
     $isLoggedIn = true;
     if (false == $loggedUser) {
         $isLoggedIn = false;
     }
     $this->view->loggedUser = $loggedUser;
     $this->view->isLoggedIn = $isLoggedIn;
     $this->view->fqaUrl = Vi_Registry::getContentUrl(15);
 }
 public function run()
 {
     $langCode = Vi_Registry::get('langCode');
     //	    if ($langCode) {
     //		    $this->view->baseContentUrl = Vi_Registry::get('APP_BASE_URL') . "content/$langCode/";
     //		    $this->view->baseProductUrl = Vi_Registry::get('APP_BASE_URL') . "mit/product/index/lang/$langCode/";
     //	    } else {
     //	        $this->view->baseContentUrl = Vi_Registry::get('APP_BASE_URL') . 'content/';
     //	        $this->view->baseProductUrl = Vi_Registry::get('APP_BASE_URL') . 'mit/product/index/';
     //	    }
     $menus = array(0 => array('url' => Vi_Registry::getBaseUrl(), 'name' => 'Find a restaurant', 'id' => 'home'), 1 => array('url' => Vi_Registry::getContentUrl(1), 'name' => 'How it works', 'id' => 1), 2 => array('url' => Vi_Registry::getContentUrl(2), 'name' => 'Coropporate Accounts', 'id' => 2), 4 => array('url' => Vi_Registry::getContentUrl(4), 'name' => 'Refer a Restaurant', 'id' => 4), 5 => array('url' => Vi_Registry::getContentUrl(5), 'name' => 'Refer a friend', 'id' => 5), 6 => array('url' => Vi_Registry::getContentUrl(6), 'name' => 'About us', 'id' => 6), 7 => array('url' => Vi_Registry::getBaseUrl() . 'contact-us.html', 'name' => 'Contact us', 'id' => 'contactus'));
     $this->view->menus = $menus;
 }
 public function run()
 {
     $langCode = Vi_Registry::get('langCode');
     $menus1 = array(0 => array('url' => Vi_Registry::getContentUrl(6), 'name' => 'About Us', 'id' => 6), 1 => array('url' => Vi_Registry::getContentUrl(1), 'name' => 'How it Works', 'id' => 1), 2 => array('url' => Vi_Registry::getBaseUrl() . 'restaurant?mark=pickup', 'name' => 'Browse Restaurants', 'id' => 'home'), 3 => array('url' => Vi_Registry::getContentUrl(9), 'name' => 'Newsroom', 'id' => 9));
     $menus2 = array(0 => array('url' => Vi_Registry::getContentUrl(3), 'name' => 'Share the Bounty', 'id' => 3), 1 => array('url' => Vi_Registry::getContentUrl(13), 'name' => 'Fundraising', 'id' => 13), 2 => array('url' => Vi_Registry::getContentUrl(5), 'name' => 'Refer a Friend', 'id' => 5), 3 => array('url' => Vi_Registry::getContentUrl(4), 'name' => 'Refer a Restaurant', 'id' => 4));
     $menus3 = array(0 => array('url' => Vi_Registry::getContentUrl(2), 'name' => 'Corporate Accounts', 'id' => 2), 1 => array('url' => Vi_Registry::getBaseUrl() . 'restaurant-owner-register.html', 'name' => 'Restaurant Owners', 'id' => 'restaurant_owners'), 2 => array('url' => Vi_Registry::getContentUrl(18), 'name' => 'Business Partners', 'id' => 18));
     $menus4 = array(0 => array('url' => Vi_Registry::getContentUrl(10), 'name' => 'Term of Use', 'id' => 10), 1 => array('url' => Vi_Registry::getContentUrl(14), 'name' => 'Privacy Policy', 'id' => 14), 2 => array('url' => Vi_Registry::getContentUrl(16), 'name' => 'Copyright', 'id' => 16));
     $menus5 = array(0 => array('url' => Vi_Registry::getContentUrl(15), 'name' => 'FAQs', 'id' => 15), 1 => array('url' => Vi_Registry::getBaseUrl() . 'contact-us.html', 'name' => 'Contact Us', 'id' => 'contactus'));
     $this->view->menus1 = $menus1;
     $this->view->menus2 = $menus2;
     $this->view->menus3 = $menus3;
     $this->view->menus4 = $menus4;
     $this->view->menus5 = $menus5;
 }
Example #10
0
 /**
  * Check permisison
  * 
  * @param string $permission
  * @param string $module
  * @param string|integer $expandId  Note: $expandId == '*": Check to have all expandable permisisnon
  *                                        $expandId == '?': Check to have one or more permisison
  *                                        $expandId is interger: Check for special expand value
  */
 public function checkPermission($permission, $module, $expandId = '*')
 {
     $config = Vi_Registry::getConfig();
     if ($this->_auth->getIdentity() == 'admin' && @$config['useAdminFullControlSystem']) {
         return true;
     }
     if ('*' == $expandId) {
         if (true === @$this->_permissions[$module][$permission]) {
             return true;
         } elseif (is_array($pers = @$this->_permissions[$module][$permission])) {
             /**
              * Check all expandable permissions
              */
             foreach ($pers as $per) {
                 if (false == $per) {
                     return false;
                 }
             }
             return true;
         }
     } else {
         if ('?' == $expandId) {
             /**
              * Match one of all permission
              */
             if (true === @$this->_permissions[$module][$permission]) {
                 return true;
             } elseif (is_array($pers = @$this->_permissions[$module][$permission])) {
                 /**
                  * Check all expandable permissions
                  */
                 foreach ($pers as $per) {
                     if (true == $per) {
                         return true;
                     }
                 }
                 return false;
             }
         } else {
             /**
              * Check expandable permission
              */
             if (true == @$this->_permissions[$module][$permission][$expandId]) {
                 return true;
             }
         }
     }
     return false;
 }
 /**
  * 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'];
     }
 }
Example #12
0
 /**
  * Init Model
  */
 public function init()
 {
     parent::init();
     /**
      * Init string primary key
      */
     if (is_array($this->_primary)) {
         $this->_sPrimary = current($this->_primary);
     } else {
         $this->_sPrimary = $this->_primary;
     }
     /**
      * Init database prefix
      */
     $config = Vi_Registry::get('config');
     if (isset($config['database']['params']['prefix']) && null != $config['database']['params']['prefix']) {
         $this->_prefix = $config['database']['params']['prefix'];
     }
 }
 public function managerAction()
 {
     /**
      * Check permission
      */
     if (false == $this->checkPermission('see_permission')) {
         $this->_forwardToNoPermissionPage();
         return;
     }
     $this->view->headTitle(Vi_Language::translate('Permission manager'));
     $this->view->menu = array('usergroup', 'permissionmanager');
     $config = Vi_Registry::getConfig();
     /**
      * Load all groups
      */
     $objGroup = new Models_Group();
     /**
      * Set values for tempalte
      */
     $this->view->allGroups = $objGroup->getAll(array('sorting ASC', 'group_id ASC'))->toArray();
     /**
      * Get all applications
      */
     $allApps = Vi_Folder::getFolders('applications');
     foreach ($allApps as $index => $app) {
         if (!is_dir("applications/{$app}")) {
             unset($allApps[$index]);
         }
     }
     $this->view->allApps = $allApps;
     /**
      * Get all modules
      */
     $allModules = Vi_Folder::getFolders('modules');
     foreach ($allModules as $index => $module) {
         if (!is_dir("modules/{$module}")) {
             unset($allModules[$index]);
         }
     }
     $this->view->allModules = $allModules;
     $this->view->permissionMessage = $this->session->permissionMessage;
     $this->session->permissionMessage = null;
 }
Example #14
0
 public function __construct()
 {
     parent::__construct(Vi_Constant::SESSION_NAMESPACE . "_" . Vi_Registry::getAppName(), 'user');
 }
 /**
  * List all meal follow restaurant
  */
 public function indexAction()
 {
     $this->view->headTitle('Cart information');
     $order_id = session_id();
     if (!isset($_SESSION['cart'][$order_id])) {
         $this->_redirect('');
     }
     /**
      * Get restaurant
      */
     $objRes = new Models_Restaurant();
     $res = $objRes->find($_SESSION['cart'][$order_id]['restaurant_id'])->toArray();
     $res = current($res);
     //        echo '<pre>';print_r($_SESSION);//die;
     //        echo '<pre>';print_r($res);die;
     if (false == $res) {
         $this->_redirect('');
     }
     $this->view->session_cart = $_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'];
     $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'];
     $data_info = $this->_getParam('data', false);
     $confirm = $this->_getParam('confirm', false);
     /**
      * Remember customer's infomation
      */
     if (false !== $data_info) {
         $_SESSION['cart_customer'] = $data_info;
     }
     $data_info = $_SESSION['cart_customer'];
     $this->view->full_name = $data_info['full_name'];
     $this->view->address = $data_info['address'];
     $this->view->zip_code = $data_info['zip_code'];
     $this->view->phone = $data_info['phone1'] . "." . $data_info['phone2'] . "." . $data_info['phone3'];
     $this->view->cardType = $_SESSION['cart_customer']['card_type'];
     $cardNumber = $_SESSION['cart_customer']['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';
     $this->view->cardNumber = $cardNumber;
     $error = '';
     /**
      * Store to DB and redirect
      */
     if (false != $confirm) {
         /**************************************************************************
          * Make payment
          */
         require_once 'libs/paypal/CallerService.php';
         /**
          * Fist name, last name
          */
         $firstName = trim(substr($data_info['full_name'], 0, strpos($data_info['full_name'] . ' ', ' ') + 1));
         $lastName = trim(substr($data_info['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_info['card_type']);
         $creditCardNumber = urlencode($data_info['card_number']);
         $expDateMonth = urlencode($data_info['card_month']);
         // Month must be padded with leading zero
         $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
         $expDateYear = urlencode($data_info['card_year']);
         $cvv2Number = urlencode($data_info['card_cvv']);
         $address1 = urlencode($data_info['address']);
         $address2 = urlencode('');
         $city = urlencode($data_info['city']);
         $state = urlencode($data_info['state']);
         $zip = urlencode($data_info['zip_code']);
         $amount = urlencode(number_format($_SESSION['cart'][$order_id]['ordertotal'], 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"]);
         if ($ack != "SUCCESS") {
             $_SESSION['card_error_msg'] = @$resArray['L_LONGMESSAGE0'];
             $this->_redirect('restaurant/ship');
         }
         /**
          * End payment
          **************************************************************************/
         //-- begin save into db: vi_order and vi_order_detail
         $arr_order = array('sub_total' => $_SESSION['cart'][$order_id]['subtotal'], 'sales_tax' => $_SESSION['cart'][$order_id]['tax'], 'shipping_fee' => $_SESSION['cart'][$order_id]['shipping'], 'order_total' => $_SESSION['cart'][$order_id]['ordertotal'], 'date' => $_SESSION['cart'][$order_id]['date'], 'time' => $_SESSION['cart'][$order_id]['time'], 'order_service' => $_SESSION['cart'][$order_id]['order_service'], 'full_name' => $data_info['full_name'], 'address' => $data_info['address'], 'suite' => $data_info['note'], 'city' => $data_info['city'], 'state' => $data_info['state'], 'zip_code' => $data_info['zip_code'], 'phone' => $data_info['phone1'] . "." . $data_info['phone2'] . "." . $data_info['phone3'], 'email' => $data_info['email'], 'created_date' => time(), 'restaurant_id' => $_SESSION['cart'][$order_id]['restaurant_id']);
         $objOrder = new Models_Order();
         $bResultOrder = $objOrder->insert($arr_order);
         foreach ($_SESSION['cart'][$order_id] as $key => $value) {
             $arr_order_detail = array('order_id' => $bResultOrder, 'meal_id' => $value['meal_id'], 'name' => $value['name'], 'description' => $value['description'], 'price' => $value['price'], 'quantity' => $value['quantity'], 'total' => $value['total_money']);
             if (!empty($value['name'])) {
                 $objOrderDetail = new Models_OrderDetail();
                 $objOrderDetail->insert($arr_order_detail);
             }
         }
         //-- end save into db: vi_order and vi_order_detail
         /**
          * Send email to admin and user
          */
         $objUser = new Models_User();
         $objMail = new Models_Mail();
         $data = $arr_order;
         $config = Vi_Registry::getConfig();
         $data['created_date'] = date($config['dateFormat'], $data['created_date']);
         $data['card_type'] = $this->view->cardType;
         $data['card_number'] = $this->view->cardNumber;
         //            echo '<pre>';print_r($data);die;
         $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;'>PAYMENT METHOD</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['phone']}</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>\n                           \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                           \n                       </table>\n                       <br/>\n                   </td>\n\n                </tr>\n                \n                </table>\n                <table>\n                \n                <tr style='background-color: #DDDDDD;'>\n                    <td style='color: #AD5B21; font-weight: bold;'> Meal</td>\n                    <td style='color: #AD5B21; font-weight: bold;'> </td>\n                    <td style='color: #AD5B21; font-weight: bold;'> Quanlity</td>\n                    <td style='color: #AD5B21; font-weight: bold;'> Price</td>\n                    <td style='color: #AD5B21; font-weight: bold;'> Total</td>\n                </tr> ";
         foreach ($_SESSION['cart'][$order_id] as $key => $meal) {
             if (null == $meal['meal_id']) {
                 continue;
             }
             $mealImage = Vi_Registry::getConfig('liveSite') . '/' . $meal['image'];
             if (null != $meal['image']) {
                 $mealImage = '<img src="' . $mealImage . '" style="max-width: 100px;">';
             } else {
                 $mealImage = '';
             }
             if (is_numeric($key)) {
                 $cartDetail .= "\n\t                 <tr>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\n\t                        {$mealImage}\n\t                    </td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\n\t                        <b>{$meal['name']}</b>\n\t\n\t                        <br/>\n\t                        <p>{$meal['description']}</p>\n\t                    </td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>{$meal['quantity']}</td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\$" . number_format($meal['price'] * 1.0, 2) . "</td>\n\t                    <td style='border-bottom: 1px solid #DDDDDD;'>\$" . number_format($meal['total_money'] * 1.0, 2) . "</td>\n\t                </tr>";
             }
         }
         $cartDetail .= "   \n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Subtotal </td>\n                    <td>\$" . number_format($data['sub_total'], 2) . "</td>\n\n                </tr>\n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Tax </td>\n                    <td>\$" . number_format($data['sales_tax'], 2) . "</td>\n                </tr>\n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Shipping fee </td>\n\n                    <td>\$" . number_format($data['shipping_fee'], 2) . "</td>\n                </tr>\n                <tr>\n                    <td colspan='2'> </td>\n                    <td> Order total </td>\n                    <td  style='color: #AD5B21; font-weight: bold;'>\$" . number_format($data['order_total'], 2) . "</td>\n                </tr>\n            </table>\n            ";
         $data['card_detail'] = $cartDetail;
         //            echo '<pre>';print_r($data);die;
         $admin = $objUser->getByUserName('admin');
         $objMail->sendHtmlMail('meal_order', $data, array($admin['email'], $data['email'], $res['owner_email']));
         /**
          * Clear session
          */
         unset($_SESSION['cart']);
         unset($_SESSION['cart_customer']);
         /**
          * Redirec to success page
          */
         $objContent = new Models_ScontentLang();
         $this->_redirect($objContent->getUrlWithoutAppBaseUrl(21));
         return;
     }
 }
 private function _getImagePath($path)
 {
     return substr($path, strlen(Vi_Registry::getBaseUrl()));
 }
 public function run()
 {
     $langCode = Vi_Registry::get('langCode');
     $menus = array(0 => array('url' => Vi_Registry::getContentUrl(6), 'name' => 'About us', 'id' => 6), 1 => array('url' => Vi_Registry::getContentUrl(1), 'name' => 'How it works', 'id' => 1), 2 => array('url' => Vi_Registry::getContentUrl(7), 'name' => 'Meet the team', 'id' => 7), 3 => array('url' => Vi_Registry::getContentUrl(8), 'name' => 'Careers', 'id' => 8), 4 => array('url' => Vi_Registry::getContentUrl(9), 'name' => 'News room', 'id' => 9));
     $this->view->menus = $menus;
 }
Example #18
0
 /**
  * Processes a template and returns the output.
  *
  * @param string $name The template to process.
  * @return string.
  */
 public function render($name = '')
 {
     if ($name == '') {
         $name = $this->_templateDir . $this->_name . '/' . $this->_name . '.tpl';
         if ($this->_sampleMode) {
             $name = $this->_templateDir . $this->_name . '/' . $this->_name . '-sample.tpl';
         }
     }
     $this->_data .= $this->view->render($name, Vi_Registry::getAppName() . '|' . $this->_langCode . '|sticker|' . $this->_name);
 }
Example #19
0
 /**
  * Send mail to all user
  * 
  * @param string $subject              The subject of mail
  * @param string $bodyText             The text body of mail
  * @param string $bodyHtml             The HTML body of mail
  * @param string $bodyDbTemplateName   The name of mail
  * @param array  $templateData         Array data of template mail
  * @param bool   $isHtmlTempalte       Default is true, that means using HTML email to send
  * @return bool
  */
 public function sendEmailToAllUser($subject, $bodyText = null, $bodyHtml = null, $bodyDbTemplateName = null, $templateData = array(), $isHtmlTempalte = true)
 {
     if (null == $bodyText && null == $bodyHtml && null == $bodyDbTemplateName) {
         return false;
     }
     $allUsers = $this->getAll();
     /**
      * Send email
      */
     require_once 'Vi/Mail.php';
     require_once 'Zend/Mail/Transport/Smtp.php';
     $config = Vi_Registry::getConfig();
     $transport = new Zend_Mail_Transport_Smtp($config['adminMail']['mailServer'], $config['adminMail']);
     try {
         foreach ($allUsers as $user) {
             $mail = new Vi_Mail('utf-8');
             $mail->setSubject($subject);
             $mail->setFrom($config['adminMail']['username']);
             $mail->addTo($user['email']);
             if (null != $bodyText) {
                 $mail->setBodyText($bodyText);
             } else {
                 if (null != $bodyHtml) {
                     $mail->setBodyHtml($bodyHtml);
                 } else {
                     if (null != $bodyDbTemplateName) {
                         $mail->setBodyDbTemplateName($bodyDbTemplateName, $isHtmlTempalte);
                         $mail->view->templateData = $templateData;
                     }
                 }
             }
             $mail->send($transport);
         }
         return true;
     } catch (Exception $e) {
         /**
          * Error
          */
         return false;
     }
 }
Example #20
0
 public function headTitle($string)
 {
     $websiteName = Vi_Registry::getConfig('websiteName');
     if (null != $websiteName) {
         $websiteName .= " - ";
     }
     $this->headTitle->headTitle($websiteName . "{$string}");
 }
Example #21
0
 /**
  * Send HTML mail from DB mail template
  * 
  * @param string $mailTemplateName
  * @param array $data
  * @param string|array $to 
  * @param string $subject If null, subject from DB will be chosen
  */
 public function sendHtmlMail($mailTemplateName, $data = array(), $to = array(), $subject = null, $langId = null)
 {
     if (!is_array($to)) {
         $to = array($to);
     }
     if (null == $langId) {
         $langId = 1;
     }
     /**
      * Get mail template
      */
     $select = $this->select()->setIntegrityCheck(false)->from(array('m' => $this->_name))->joinLeft(array('ml' => $this->_prefix . 'mail_lang'), 'm.mail_id = ml.mail_id', array('lang_id', 'subject', 'content'))->where('m.name=?', $mailTemplateName)->where('ml.lang_id=?', $langId);
     $mail = @$this->fetchRow($select)->toArray();
     if (null == $mail) {
         return true;
     }
     /**
      * Change key
      */
     $newKey = array();
     foreach ($data as $index => $item) {
         $newKey['[' . strtoupper($index) . ']'] = $item;
     }
     $data = $newKey;
     /**
      * Insert data file for the first time call
      */
     if (null == $mail['data'] && !empty($data)) {
         $this->update(array('data' => implode('<br/>', array_keys($data))), array('name=?' => $mailTemplateName));
     }
     /**
      * Replace subject
      */
     if (null == $subject) {
         /**
          * Replace subject with DATA
          */
         $mail['subject'] = str_replace(array_keys($data), $data, $mail['subject']);
     } else {
         $mail['subject'] = $subject;
     }
     /**
      * Replace content
      */
     $mail['content'] = str_replace(array_keys($data), $data, $mail['content']);
     //        echo '<pre>';print_r($mail);die;
     $fromMail = Vi_Registry::getConfig('fromMail');
     // To send HTML mail, the Content-type header must be set
     $headers = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     if (null != $fromMail) {
         $headers .= "From: {$fromMail}" . "\r\n" . "Reply-To: {$fromMail}" . "\r\n" . 'X-Mailer: PHP/' . phpversion();
     }
     /**
      * Send mail
      */
     foreach ($to as $email) {
         @mail($email, $mail['subject'], $mail['content'], $headers);
     }
 }
 /**
  * List all meal follow restaurant
  */
 public function indexAction()
 {
     $this->view->headTitle('Cart information');
     //-- begin add information into cart
     $meal_id = $this->_getParam('meal_id', false);
     $quantity = $this->_getParam('quantity', false);
     $mark = $_SESSION['mark'];
     //$this->_getParam('mark', false);
     $state = $this->_getParam('state', 0);
     //-- state=0: delete meal in session cart
     $date = $_SESSION['date'];
     //$this->_getParam('date', false);
     $time = $_SESSION['time'];
     //$this->_getParam('time', false);
     $res_id = $this->_getParam('res_id', false);
     if (false === $res_id) {
         $this->_redirect('');
     }
     $order_id = session_id();
     //-- begin delete meal in session cart
     if (0 != $state) {
         foreach ($_SESSION['cart'][$order_id] as $key => $value) {
             if ($key != $meal_id) {
                 $_SESSION['cart_delete'][$order_id][$key] = $value;
             }
         }
         //-- begin calculate sum
         $_SESSION['cart_delete'][$order_id]['subtotal'] = 0;
         foreach ($_SESSION['cart_delete'][$order_id] as $key => $value) {
             if ($value['total_money'] > 0) {
                 $_SESSION['cart_delete'][$order_id]['subtotal'] += $value['total_money'];
             }
         }
         //-- end calculate sum
         $_SESSION['cart_delete'][$order_id]['ordertotal'] = $_SESSION['cart_delete'][$order_id]['subtotal'] + $_SESSION['cart'][$order_id]['tax'] + $_SESSION['cart'][$order_id]['shipping'];
         unset($_SESSION['cart'][$order_id]);
         $_SESSION['cart'][$order_id] = $_SESSION['cart_delete'][$order_id];
         unset($_SESSION['cart_delete'][$order_id]);
         $this->view->session_cart = $_SESSION['cart'][$order_id];
     } else {
         //-- end delete meal in session cart
         if (false != $meal_id) {
             if (false != $quantity) {
                 $_SESSION['cart'][$order_id][$meal_id]['quantity'] = $quantity;
             } else {
                 if (isset($_SESSION['cart'][$order_id][$meal_id]['meal_id']) && $_SESSION['cart'][$order_id][$meal_id]['meal_id'] == $meal_id) {
                     $_SESSION['cart'][$order_id][$meal_id]['quantity'] = $_SESSION['cart'][$order_id][$meal_id]['quantity'] + 1;
                 } else {
                     $objMeal = new Models_Meal();
                     $arr_meal = $objMeal->getDataById($meal_id);
                     $_SESSION['cart'][$order_id][$meal_id]['meal_id'] = $arr_meal['meal_id'];
                     $_SESSION['cart'][$order_id][$meal_id]['image'] = $arr_meal['image_thumb'] ? $arr_meal['image_thumb'] : $arr_meal['image'];
                     $_SESSION['cart'][$order_id][$meal_id]['name'] = $arr_meal['name'];
                     $_SESSION['cart'][$order_id][$meal_id]['description'] = $arr_meal['description'];
                     $_SESSION['cart'][$order_id][$meal_id]['price'] = $arr_meal['price'];
                     $_SESSION['cart'][$order_id][$meal_id]['quantity'] = 1;
                 }
             }
             $_SESSION['cart'][$order_id][$meal_id]['total_money'] = $_SESSION['cart'][$order_id][$meal_id]['price'] * $_SESSION['cart'][$order_id][$meal_id]['quantity'];
             $_SESSION['cart'][$order_id]['subtotal'] = 0;
             $_SESSION['cart'][$order_id]['restaurant_id'] = $res_id;
             //-- begin calculate sum
             foreach ($_SESSION['cart'][$order_id] as $key => $value) {
                 if ($value['total_money'] > 0 && is_numeric($key)) {
                     $_SESSION['cart'][$order_id]['subtotal'] += $value['total_money'];
                 }
             }
             //-- end calculate sum
             $_SESSION['cart'][$order_id]['tax'] = $_SESSION['cart'][$order_id]['subtotal'] * Vi_Registry::getConfig('taxFee');
             //-- begin get shipping fee for catering delivery and catering
             if (strcmp($mark, 'catering_delivery') == 0 || strcmp($mark, 'delivery') == 0) {
                 $objRestaurant = new Models_Restaurant();
                 $arrRestaurant = $objRestaurant->getShipFeeFromMealId($meal_id);
                 if (strcmp($mark, 'delivery_charge') == 0) {
                     $shippingFee = $arrRestaurant['delivery_charge'];
                 } else {
                     $shippingFee = $arrRestaurant['catering_delivery_charge'];
                 }
                 $_SESSION['cart'][$order_id]['shipping'] = $shippingFee;
             } else {
                 $_SESSION['cart'][$order_id]['shipping'] = 0;
             }
             //-- end get shipping fee for catering delivery and catering
             $_SESSION['cart'][$order_id]['ordertotal'] = $_SESSION['cart'][$order_id]['subtotal'] + $_SESSION['cart'][$order_id]['tax'] + $_SESSION['cart'][$order_id]['shipping'];
             $this->view->session_cart = $_SESSION['cart'][$order_id];
         } else {
             $this->view->session_cart = '';
         }
     }
     $_SESSION['cart'][$order_id]['date'] = $date;
     $_SESSION['cart'][$order_id]['time'] = $time;
     $_SESSION['cart'][$order_id]['order_service'] = $mark;
     //		 echo "<pre>";print_r($_SESSION['cart'][$order_id]);echo "</pre>";
     $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'];
     //-- end add information into cart
     $this->view->order_id = $order_id;
     $this->view->meal_id = $meal_id;
     $this->view->mark = strtoupper($mark);
     $this->view->date = $date;
     $this->view->time = strtoupper($time);
 }
 public function detailAction()
 {
     $this->view->headTitle(Vi_Language::translate('Detail Order'));
     $this->view->menu = array('order');
     $config = Vi_Registry::getConfig();
     $numRowPerPage = Vi_Registry::getConfig("defaultNumberRowPerPage");
     $currentPage = $this->_getParam("page", 1);
     $displayNum = $this->_getParam('displayNum', false);
     $id = $this->_getParam('id', false);
     if (false == $id) {
         $this->_redirect('order/admin/manager');
     }
     /**
      * Load all details
      */
     $objDetail = new Models_OrderDetail();
     $allDetails = $objDetail->getByColumnName(array('order_id=?' => $id))->toArray();
     /**
      * Get order
      */
     $objOrder = new Models_Order();
     $order = $objOrder->find($id)->toArray();
     $order = current($order);
     $this->view->order = $order;
     /**
      * Get restaurant
      */
     $objRes = new Models_Restaurant();
     $res = $objRes->find($order['restaurant_id'])->toArray();
     $res = current($res);
     $this->view->res = $res;
     /**
      * Set values for tempalte
      */
     $this->view->allMeals = $allDetails;
 }
Example #24
0
 /**
  * Change alias name to module name in URI
  * 
  * @return void
  * @throws Exception if module's alias point to empty module's name
  */
 public function changeAliasToModuleName()
 {
     $appBaseUrl = Vi_Registry::get('APP_BASE_URL');
     $params = substr($_SERVER['REQUEST_URI'], strlen($appBaseUrl));
     $params = explode('/', trim($params, '/'));
     $alias = $params[0];
     if (null == $alias) {
         return null;
     } else {
         if (Vi_Registry::isRegistered('moduleAliases')) {
             $moduleAliases = @Vi_Registry::get('moduleAliases');
             if (!array_key_exists($alias, $moduleAliases)) {
                 return null;
             }
             $module = $moduleAliases[$alias];
             if (null == $module) {
                 throw new Exception("Module's alias ({$alias}) point to empty module's name");
             }
             $params[0] = $module;
             $params = implode('/', $params);
             $_SERVER['REDIRECT_URL'] = $appBaseUrl . $params;
             $_SERVER['REQUEST_URI'] = $appBaseUrl . $params;
         }
     }
     //        /**
     //         * Reset server params
     //         */
     //        echo '<pre>';print_r($_SERVER);
     //        $params = implode('/', $params);
     //        $_SERVER['REDIRECT_URL'] = $appBaseUrl . $params;
     //        $_SERVER['REQUEST_URI']  = $appBaseUrl . $params;
     //        echo '<pre>';print_r($_SERVER);die;
 }
Example #25
0
 public static function getCurrentLangCode()
 {
     return Vi_Registry::get('langCode');
 }
 /**
  * List all restaurant after search
  */
 public function indexAction()
 {
     $this->view->headTitle('Restaurant');
     $config = Vi_Registry::getConfig();
     $numRowPerPage = Vi_Registry::getConfig("defaultNumberRowPerPage");
     //        $numRowPerPage = 1;
     $currentPage = $this->_getParam("page", 1);
     $condition = $this->_getParam('data', array());
     $find = $this->_getParam('find', false);
     if (strpos($_SERVER["REDIRECT_URL"], 'mark_restaurant')) {
         $mark = $_SESSION['mark'] = $this->_getParam('mark', 'pickup');
         //isset($_SESSION['mark'])? $_SESSION['mark']: $this->_getParam('mark', false);
     } else {
         $mark = $_SESSION['mark'] = isset($_SESSION['mark']) && !empty($_SESSION['mark']) ? $_SESSION['mark'] : $this->_getParam('mark', 'pickup');
     }
     $searchword = $this->_getParam('searchword', false);
     $conditions = $this->_getParam('condition', array());
     /**
      * Set variables for template
      */
     $str_lead_time_title = "";
     if (strcmp($mark, 'pickup') == 0) {
         $this->view->mark_pickup = 'checked';
         $str_lead_time_title = 'Pick up';
     } elseif (strcmp($mark, 'curbside') == 0) {
         $this->view->mark_curbside = 'checked';
         $str_lead_time_title = 'Curbside';
     } elseif (strcmp($mark, 'catering_pickup') == 0) {
         $this->view->mark_catering_pickup = 'checked';
         $str_lead_time_title = 'Catering Pickup';
     } elseif (strcmp($mark, 'delivery') == 0) {
         $this->view->mark_delivery = 'checked';
         $str_lead_time_title = 'Delivery';
     } elseif (strcmp($mark, 'catering_delivery') == 0) {
         $this->view->mark_catering_delivery = 'checked';
         $str_lead_time_title = 'Catering Delivery';
     }
     /**
      * Get condition for search
      */
     $arr_condition = array();
     if (false != $mark) {
         //	    	$arr_condition["{$mark} != ?"] = Zend_DB::NULL_EMPTY_STRING;
         $arr_con["mark"] = $mark;
     }
     if (false != $find) {
         //	    	$arr_condition["name LIKE ? "] = $find."%";
         $arr_con["name"] = $find;
     }
     if (null != @$condition['zip']) {
         /**
          * Condition here
          */
         $objCountry = new Models_Country();
         $city_from_code = $objCountry->getCityByCode($condition['zip']);
         //	    	$arr_condition["address LIKE ? "] = "%".$city_from_code[0]['city']."%";
         $arr_con['city'] = $city_from_code[0]['city'];
         $arr_con['zip'] = $condition['zip'];
         //	    	$arr_con['address'] = $city_from_code[0]['city'];
     } else {
         if (false != $searchword) {
             //-- searchword: city
             //	    	$arr_condition["address LIKE ? "] = "%".$searchword."%";
             //	    	$arr_con["address"] = $searchword;
             $arr_con["city"] = $searchword;
         }
     }
     if (null != @$conditions['cuisine'] && $conditions['cuisine'] > 0) {
         /**
          * Condition here
          */
         $arr_con['cuisine_id'] = $conditions['cuisine'];
         if (null != @$conditions['time']) {
             $arr_con['time'] = $conditions['time'];
         }
         if (null != @$conditions['date']) {
             $arr_con['date'] = strtolower(substr($conditions['date'], -3));
         }
     }
     $arr_con = isset($arr_con) ? $arr_con : array();
     $objRestaurant = new Models_Restaurant();
     $restaurants = $objRestaurant->getRestaurantByData($arr_con, $numRowPerPage, ($currentPage - 1) * $numRowPerPage);
     $count = count($objRestaurant->getRestaurantByData($arr_con));
     //	    else{
     //
     //	    $arr_condition["enabled = ? "] = 1;
     //	    $objRestaurant = new Models_Restaurant();
     //	    $restaurants = $objRestaurant->getByColumnName($arr_condition,
     //			    											array('name ASC'),
     //			    											$numRowPerPage,
     //		                                                   ($currentPage - 1) * $numRowPerPage)->toArray();
     //	    $count = count($objRestaurant->getByColumnName($arr_condition));
     //	    }
     $this->view->lead_time = $str_lead_time_title;
     $this->view->mark = $mark;
     $this->view->alphabet = GetAlphabet();
     $strServices = "";
     foreach ($restaurants as $key => $value) {
         //	    	if ( !empty($value['services']) ){
         //		    	$arr_services = explode(',',$value['services']);
         //		    	$restaurants[$key]['arr_service'] = $arr_services;
         //	    	}
         $strServices = "";
         if (!empty($value['pickup'])) {
             if (!empty($strServices)) {
                 $strServices .= ',Pickup';
             } else {
                 $strServices .= 'Pickup';
             }
         }
         if (!empty($value['curbside'])) {
             if (!empty($strServices)) {
                 $strServices .= ',Curbside';
             } else {
                 $strServices .= 'Curbside';
             }
         }
         if (!empty($value['delivery'])) {
             if (!empty($strServices)) {
                 $strServices .= ',Delivery';
             } else {
                 $strServices .= 'Delivery';
             }
         }
         if (!empty($value['catering_pickup'])) {
             if (!empty($strServices)) {
                 $strServices .= ',Catering Pickup';
             } else {
                 $strServices .= 'Catering Pickup';
             }
         }
         if (!empty($value['catering_delivery'])) {
             if (!empty($strServices)) {
                 $strServices .= ',Catering Delivery';
             } else {
                 $strServices .= 'Catering Delivery';
             }
         }
         $arr_services = explode(',', $strServices);
         $restaurants[$key]['arr_service'] = $arr_services;
         $restaurants[$key]['address'] = $value['street'] . " " . $value['city'] . " " . $value['state'];
         $restaurants[$key]['alias'] = Vi_Controller_Action::makeURLSafeString($value['name']) . '.html';
     }
     $this->view->restaurants = $restaurants;
     /**
      * Begin get date and month
      */
     $date_month[] = date("M jS - D");
     for ($i = 1; $i < 14; $i++) {
         $date_month[] = date("M jS - D", time() + $i * 24 * 60 * 60);
     }
     $this->view->date_month = $date_month;
     /**
      * Begin get time
      */
     //		$arr_time[]= '12:15 AM';
     //		$arr_time[]= '12:30 AM';
     //		$arr_time[]= '12:45 AM';
     //		for( $i = 1; $i<12; $i++ ){
     for ($i = 5; $i < 24; $i++) {
         for ($j = 1; $j < 5; $j++) {
             if ($j == 1) {
                 $format = '00';
             } else {
                 if ($j == 2) {
                     $format = '15';
                 } else {
                     if ($j == 3) {
                         $format = '30';
                     } else {
                         if ($j == 4) {
                             $format = '45';
                         }
                     }
                 }
             }
             //				$arr_time[] = $i.":".$format." AM";
             $arr_time[] = $i . ":" . $format;
         }
     }
     //		$arr_time[] = '12:00 PM';
     //		$arr_time[] = '12:15 PM';
     //		$arr_time[] = '12:30 PM';
     //		$arr_time[] = '12:45 PM';
     //		for( $i = 1; $i<13; $i++ ){
     //			for( $j=1;$j<5;$j++ ){
     //				if ( $j==1 )
     //					$format = '00';
     //				else if ( $j==2 )
     //					$format = '15';
     //				else if ( $j==3 )
     //					$format = '30';
     //				else if ( $j==4 )
     //					$format = '45';
     //				$arr_time[] = $i.":".$format." PM";
     //			}
     //		}
     $this->view->arr_time = $arr_time;
     $this->view->zip = null != @$condition['zip'] ? $condition['zip'] : '';
     $this->view->city = $searchword;
     $date = isset($_SESSION['date']) ? $_SESSION['date'] : $this->_getParam('date', false);
     $time = isset($_SESSION['time']) ? $_SESSION['time'] : $this->_getParam('time', false);
     $_SESSION['date'] = null != @$conditions['date'] ? $conditions['date'] : (false != $date ? $date : '');
     $_SESSION['time'] = null != @$conditions['time'] ? $conditions['time'] : (false != $time ? $time : '');
     $this->view->time = $_SESSION['time'];
     $this->view->date = $_SESSION['date'];
     /**
      * Pagination
      */
     $this->setPagination($numRowPerPage, $currentPage, $count);
     $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'];
         $this->view->res_id_ses = $_SESSION['cart'][$order_id]['restaurant_id'];
     }
 }
Example #27
0
 public function run()
 {
     $langCode = Vi_Registry::get('langCode');
     $this->view->loginError = $this->session->loginError;
     $this->session->loginError = false;
 }
 public function deleteReservationAction()
 {
     $resId = Vi_Registry::getRestaurantIdFromLoggedUser();
     if (false == $resId) {
         $this->_redirect('access/index/login');
     }
     $objRes = new Models_Restaurant();
     $res = $objRes->find($resId)->toArray();
     $res = current($res);
     if (false == $res) {
         $this->_redirect('');
     }
     $id = $this->_getParam('id', false);
     if (false == $id) {
         $this->_redirect('restaurant/admin/reservation');
     }
     $ids = explode('_', trim($id, '_'));
     $objReser = new Models_Reservation();
     try {
         foreach ($ids as $id) {
             $objReser->delete(array('reservation_id=?' => $id, 'restaurant_id=?' => $resId));
         }
         $this->session->reserMessage = array('success' => true, 'message' => 'Reservation is deleted successfully');
     } catch (Exception $e) {
         $this->session->reserMessage = array('success' => false, 'message' => 'Can NOT delete this reservation. Please try again');
     }
     $this->_redirect('restaurant/reservation/manager');
 }
 public function categoryValueManagerAction()
 {
     /**
      * Check permission
      */
     if (false == $this->checkPermission('see_value')) {
         $this->_forwardToNoPermissionPage();
         return;
     }
     $this->view->headTitle(Vi_Language::translate('Value manager'));
     $this->view->menu = array('others', 'categorymanager');
     $config = Vi_Registry::getConfig();
     $numRowPerPage = Vi_Registry::getConfig("defaultNumberRowPerPage");
     $currentPage = $this->_getParam("page", 1);
     $displayNum = $this->_getParam('displayNum', false);
     $id = $this->_getParam('id', false);
     if (false == $id) {
         $this->_redirect('category/admin/category-manager');
     }
     /**
      * Update sort
      */
     $data = $this->_getParam('data', false);
     if (false != $data) {
         $objCatVal = new Models_CategoryValue();
         foreach ($data as $index => $value) {
             $objCatVal->update(array('sorting' => $value), array('category_value_id=?' => $index));
         }
         $this->session->categoryValueMessage = array('success' => true, 'message' => Vi_Language::translate('Sorting values are updated successfully'));
     }
     /**
      * Get number of category values per page
      */
     if (false === $displayNum) {
         $displayNum = $this->session->categoryValueDisplayNum;
     } else {
         $this->session->categoryValueDisplayNum = $displayNum;
     }
     if (null != $displayNum) {
         $numRowPerPage = $displayNum;
     }
     /**
      * Get condition
      */
     $condition = $this->_getParam('condition', false);
     if (false === $condition) {
         $condition = $this->session->categoryValueCondition;
     } else {
         $this->session->categoryValueCondition = $condition;
         $currentPage = 1;
     }
     if (false == $condition) {
         $condition = array();
     }
     $condition['category_id'] = $id;
     /**
      * Load all categoryValues
      */
     $objCategoryValue = new Models_CategoryValue();
     $allCategoryValues = $objCategoryValue->getAllCategoryValues($condition, array('sorting ASC', 'name ASC'), $numRowPerPage, ($currentPage - 1) * $numRowPerPage);
     /**
      * Count all categoryValues
      */
     $count = count($objCategoryValue->getAllCategoryValues($condition));
     /**
      * Load category
      */
     $objCategory = new Models_Category();
     $category = $objCategory->find($id)->toArray();
     $category = current($category);
     /**
      * Set values for tempalte
      */
     $this->setPagination($numRowPerPage, $currentPage, $count);
     $this->view->allCategoryValues = $allCategoryValues;
     $this->view->categoryValueMessage = $this->session->categoryValueMessage;
     $this->session->categoryValueMessage = null;
     $this->view->condition = $condition;
     $this->view->displayNum = $numRowPerPage;
     $this->view->category = $category;
 }
 public function managerAction()
 {
     /**
      * Check permission
      */
     if (false == $this->checkPermission('see_scontent', null, '?')) {
         $this->_forwardToNoPermissionPage();
         return;
     }
     $this->view->headTitle(Vi_Language::translate('Content Manager'));
     $this->view->menu = array('scontent', 'manager');
     $config = Vi_Registry::getConfig();
     $numRowPerPage = Vi_Registry::getConfig("defaultNumberRowPerPage");
     $currentPage = $this->_getParam("page", 1);
     $displayNum = $this->_getParam('displayNum', false);
     $objScontent = new Models_Scontent();
     $objScontentLang = new Models_ScontentLang();
     $objLang = new Models_Lang();
     $objCat = new Models_ScontentCategory();
     /**
      * Update sorting
      */
     $data = $this->_getParam('data', array());
     foreach ($data as $id => $value) {
         $value = intval($value);
         if (1 > $value) {
             continue;
         }
         $objScontent->update(array('sorting' => $value), array('scontent_id=?' => $id));
         $this->session->scontentMessage = array('success' => true, 'message' => Vi_Language::translate("Edit sort numbers successfully"));
     }
     /**
      * Get number of items per page
      */
     if (false === $displayNum) {
         $displayNum = $this->session->contentDisplayNum;
     } else {
         $this->session->contentDisplayNum = $displayNum;
     }
     if (null != $displayNum) {
         $numRowPerPage = $displayNum;
     }
     /**
      * Get condition
      */
     $condition = $this->_getParam('condition', false);
     if (false === $condition) {
         $condition = $this->session->contentCondition;
     } else {
         $this->session->contentCondition = $condition;
         $currentPage = 1;
     }
     if (false == $condition) {
         $condition = array();
     }
     /**
      * Get all categories
      */
     $this->view->allCats = $objCat->getAll(array('sorting ASC'))->toArray();
     /**
      * Get all display languages
      */
     $allLangs = $objLang->getAll(array('sorting ASC'))->toArray();
     $this->view->allLangs = $allLangs;
     /**
      * Check permisison for each language
      */
     foreach ($allLangs as $index => $lang) {
         if (false == $this->checkPermission('see_scontent', null, $lang['lang_id'])) {
             /**
              * Disappaer this language
              */
             unset($allLangs[$index]);
         }
     }
     /**
      * Get all contents
      */
     $allScontents = $objScontent->getAllContents($condition, array('sorting ASC', 's.scontent_id DESC'), $numRowPerPage, ($currentPage - 1) * $numRowPerPage);
     //        echo '<pre>';print_r($allScontents);die;
     /**
      * Count all contents
      */
     $count = count($objScontent->getAllContents($condition));
     /**
      * Get content detail
      */
     foreach ($allScontents as $index => $scontent) {
         $allDetails = $objScontentLang->getByColumnName(array('scontent_id=?' => $scontent['scontent_id']))->toArray();
         foreach ($allLangs as $lang) {
             $tmp = array('lang_id' => $lang['lang_id']);
             foreach ($allDetails as $scontentLang) {
                 if ($lang['lang_id'] == $scontentLang['lang_id']) {
                     $tmp = $scontentLang;
                     break;
                 }
             }
             $tmp['lang_image'] = $lang['lang_image'];
             $allScontents[$index]['details'][] = $tmp;
         }
         /**
          * Change date
          */
         if (0 != $scontent['created_date']) {
             $allScontents[$index]['created_date'] = date($config['dateFormat'], $scontent['created_date']);
         } else {
             $allScontents[$index]['created_date'] = '';
         }
         if (0 != $scontent['publish_up_date']) {
             $allScontents[$index]['publish_up_date'] = date($config['dateFormat'], $scontent['publish_up_date']);
         } else {
             $allScontents[$index]['publish_up_date'] = '';
         }
         if (0 != $scontent['publish_down_date']) {
             $allScontents[$index]['publish_down_date'] = date($config['dateFormat'], $scontent['publish_down_date']);
         } else {
             $allScontents[$index]['publish_down_date'] = '';
         }
     }
     //        echo '<pre>';print_r($allScontents);die;
     /**
      * Set values for tempalte
      */
     $this->setPagination($numRowPerPage, $currentPage, $count);
     $this->view->allScontents = $allScontents;
     $this->view->scontentMessage = $this->session->scontentMessage;
     $this->session->scontentMessage = null;
     $this->view->condition = $condition;
     $this->view->displayNum = $numRowPerPage;
     $this->view->fullPermisison = $this->checkPermission('see_scontent');
 }