예제 #1
0
 public function indexAction()
 {
     /**
      * Display tempalte
      */
     $this->view->headTitle('Contact Us');
     $this->view->menuId = 'contactus';
     /**
      * Get post data
      */
     $data = $this->_getParam('data', false);
     if (false != $data) {
         /**
          * Get admin
          */
         $objUser = new Models_User();
         $admin = $objUser->getByUserName('admin');
         /**
          * Send message
          */
         $objMail = new Models_Mail();
         $objMail->sendHtmlMail('contact', $data, $admin['email']);
     }
     $this->view->data = $data;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 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;
     }
 }
예제 #4
0
 public function editAction()
 {
     /**
      * 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();
     $data = $this->_getParam('data', false);
     $id = $this->_getParam('id', false);
     $error = '';
     if (false != $data) {
         /**
          * Insert new 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']);
         if (null != $newRes['image']) {
             $newRes['image'] = $this->_getImagePath($newRes['image']);
         }
         //            echo '<pre>';print_r($newRes);die;
         $objRes->update($newRes, array('restaurant_id=?' => $id));
         //            /**
         //             * Update user if activating user
         //             */
         //            if ('1' == $newRes['enabled'] && false != $this->_getParam('user_id', false)) {
         //                /**
         //                 * Active user
         //                 */
         //                $objUser->update(array('enabled' => 1), array('user_id=?' => $this->_getParam('user_id', false)));
         //            }
         $this->session->restaurantMessage = array('success' => true, 'message' => Vi_Language::translate('Edit restaurant successfully'));
         $this->_redirect('restaurant/admin/manager#listofrestaurant');
     } else {
         /**
          * Loading data
          */
         $data = $objRes->find($id)->toArray();
         $data = current($data);
         if (false == $data) {
             $this->_redirect('restaurant/admin/manager');
         }
         /**
          * Load user
          */
         $user = $objUser->find($data['user_id'])->toArray();
         $user = current($user);
     }
     $this->view->isNumberCuisine = is_numeric($data['cuisine']);
     $cuisines = $objCat->getAllValues('cuisine');
     $this->view->cuisines = $cuisines;
     $this->view->data = $data;
     $this->view->error = $error;
     $this->view->user = $user;
     $this->view->headTitle('Edit Restaurant');
     $this->view->menu = array('restaurant');
 }
예제 #5
0
 /**
  * Activate user data using user id.
  *
  * @access public
  * @param int $userId [User id]
  * @return bool
  */
 public function activate($userId)
 {
     $this->_errorStack = Noobh_ErrorStackSingleton::getInstance();
     try {
         if (!empty($userId)) {
             $userModel = new Models_User();
             $result = $userModel->getUserBy($email = null, $userId);
             if (!empty($result)) {
                 $status = $userModel->activate($userId);
                 return $status;
             } else {
                 throw new Exception($this->_errorList[602], 602);
             }
         } else {
             throw new Exception($this->_errorList[604], 604);
         }
     } catch (Exception $ex) {
         $code = $ex->getCode();
         $message = $ex->getMessage();
         $this->_errorStack->push(self::VALIDATION_TYPE, $code, $message);
         Noobh_Log::error($message);
         throw new Exception($message);
     }
 }
 public function activateAction()
 {
     $response = array();
     try {
         $request = $this->getRequest();
         $params = $request->getParams();
         if ($request->isPOST()) {
             if (!isset($params['email'])) {
                 $response['error_code'] = 803;
                 $response['error_message'] = $this->_errorList[803];
             } else {
                 $email = htmlspecialchars($params['email']);
                 $user = new Models_User($email);
                 if ($user->activate($user->getHash())) {
                     $response['status'] = 'OK';
                     $response['error_code'] = 0;
                 } else {
                     $response['error_code'] = 820;
                     $response['error_message'] = $this->_errorList[820];
                 }
             }
         } else {
             $response['error_code'] = 400;
             $response['error_message'] = 'Bad Request';
         }
     } catch (Exception $ex) {
         $response['error_code'] = 820;
         $response['error_message'] = $this->_errorList[820];
     }
     echo json_encode($response);
     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;
 }
예제 #8
0
 public function deleteUserAction()
 {
     /**
      * Check permission
      */
     if (false == $this->checkPermission('delete_user')) {
         $this->_forwardToNoPermissionPage();
         return;
     }
     $id = $this->_getParam('id', false);
     if (false == $id) {
         $this->_redirect('user/admin/user-manager');
     }
     $ids = explode('_', trim($id, '_'));
     $objUser = new Models_User();
     try {
         foreach ($ids as $id) {
             $objUser->delete(array('user_id=?' => $id, 'username !=?' => 'admin'));
         }
         $this->session->userMessage = array('success' => true, 'message' => Vi_Language::translate('Delete user successfully'));
     } catch (Exception $e) {
         $this->session->userMessage = array('success' => false, 'message' => Vi_Language::translate('Can NOT delete this user. Please try again'));
     }
     $this->_redirect('user/admin/user-manager#listofuser');
 }
 public function deleteAction($userId)
 {
     $response = array();
     try {
         $user = new Models_User($userId, null);
         /**
          * Inactivate User Info
          */
         $status = '-1';
         $userId = $user->id;
         if ($user->id != '') {
             if ($user->inActivate($userId)) {
                 $response['status'] = 'OK';
                 $response['error_code'] = 0;
                 $response['user_status'] = 'Inactivated';
             }
         } else {
             $response['error_code'] = '401';
             $response['error_message'] = 'User Id not available';
         }
     } catch (Exception $ex) {
         $response['error_code'] = '401';
         $response['error_message'] = 'Bad Request';
     }
     return json_encode($response);
 }
예제 #10
0
 /**
  * Get logged in user
  * 
  * @return Zend_Db_Table_Row| false
  */
 public static function getLoggedInUser()
 {
     if (NULL == self::getAuth()->getUsername()) {
         return false;
     }
     require_once 'Shared/Models/User.php';
     $objUser = new Models_User();
     return $objUser->getByUserName(self::getAuth()->getUsername());
 }
예제 #11
0
 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');
 }