Beispiel #1
0
function unjsonizeMaybe($original)
{
    if (isJSON($original)) {
        return json_decode($original);
    }
    return $original;
}
 public function actionCommentCreate()
 {
     if (isset($_POST['commentJSON']) && isJSON($_POST['commentJSON'])) {
         $productCommentModel = new ProductComment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['commentJSON'], true);
         $productCommentModel->text = isset($commentCreatePost['text']) ? $commentCreatePost['text'] : '';
         $productCommentModel->create_time = date("Y-m-d H:i:s");
         $productCommentModel->product_id = isset($commentCreatePost['product_id']) ? $commentCreatePost['product_id'] : '';
         $productCommentModel->contact_method = isset($commentCreatePost['contact_method']) ? $commentCreatePost['contact_method'] : '';
         $productCommentModel->amazing_level = isset($commentCreatePost['amazing_level']) ? $commentCreatePost['amazing_level'] : 5;
         if (!$productCommentModel->validateProductId($productCommentModel->product_id)) {
             $errorMessage = Yii::t('productComment', 'The product is not exist, please try again!');
         }
         if (!$productCommentModel->validateContactMethod()) {
             $errorMessage = Yii::t('productComment', 'Contact method is too long, please shorten it!');
         }
         if (!$productCommentModel->validateSiteMark()) {
             $errorMessage = Yii::t('productComment', 'The mark is out of range, please try again!');
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $productModel = Product::model()->findByAttributes(array('product_id' => $productCommentModel->product_id));
             $productModel->product_mark_sum = $productModel->product_mark * $productModel->product_marked_times + $productCommentModel->amazing_level;
             ++$productModel->product_marked_times;
             $productModel->product_mark = $productModel->product_mark_sum / $productModel->product_marked_times;
             if ($productCommentModel->save() && $productModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $productCommentModel->create_time));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }
 public function actionCommentCreate()
 {
     if (isset($_POST['productCommentJSON']) && isJSON($_POST['productCommentJSON'])) {
         $productCommentModel = new ProductComment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['productCommentJSON']);
         $productCommentModel->text = $commentCreatePost['text'];
         $productCommentModel->create_time = date("Y-m-d H:i:s");
         $productCommentModel->product_id = $commentCreatePost['product_id'];
         $productCommentModel->contact_method = $commentCreatePost['contact_method'];
         $productCommentModel->amazing_level = $commentCreatePost['amazing_level'];
         if (!$productCommentModel->validateProductId()) {
             $errorMessage = '该产品不存在,请确认后重新提交';
         }
         if (!$productCommentModel->validateContactMethod()) {
             $errorMessage = '联系方式超出长度,请简略填写联系信息(小于50个字)';
         }
         if (!$productCommentModel->validateSiteMark()) {
             $errorMessage = '评分不在范围之内,请重新输入或与管理员联系';
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $productModel = Product::model()->findByPk($productCommentModel->product_id);
             $productModel->product_mark_sum = $productModel->product_mark * $productModel->product_mark_times + $productCommentModel->amazing_level;
             ++$productModel->product_mark_times;
             $productModel->product_mark = $productModel->product_mark_sum / $productModel->product_mark_times;
             if ($productCommentModel->save() && $productModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $productCommentModel->create_time));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }
Beispiel #4
0
function client_notification_list()
{
    global $HAMMU_BOL_Service;
    global $language;
    global $Userservice;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    //Lang Call Start
    $hammu_lang_id = $app->request()->params("lang_id");
    if (!empty($hammu_lang_id)) {
        getCurrentLanguages($hammu_lang_id);
    }
    //Lang Call end
    $inviterId = $app->request()->params("inviterId");
    $rarray = $HAMMU_BOL_Service->findClientListByIds($inviterId);
    $datas = json_decode(json_encode($rarray, true), true);
    $data_content = "";
    $meet_location = "";
    $longitude = "";
    $latitude = "";
    $instruction = "";
    $final_date = "";
    if (!empty($datas)) {
        $return_array = array();
        $inviteeId_loop = null;
        $data_content = "";
        //        print_r($datas);
        //        exit;
        foreach ($datas as $key => $data) {
            $searchArr = checkFavorite($data['inviterId'], $data['inviteeId']);
            if (count($searchArr)) {
                $is_favorite = "1";
            } else {
                $is_favorite = "0";
            }
            $inviteeUsername = $Userservice->getUserName($data["inviteeId"]);
            $date = date("Y/m/d H:i", $data["timestamp"]);
            $time = date("H:i", $data["timestamp"]);
            $data_timestamp = $data["data"];
            $json_string = isJSON($data_timestamp);
            if (!empty($json_string)) {
                $meet_location_result = json_decode($data_timestamp);
                $meeting_data_arr = (array) $meet_location_result;
                if (in_array($meeting_data_arr['meet_location'], $meeting_data_arr)) {
                    $meet_location = $meeting_data_arr['meet_location'];
                }
                if (in_array($meeting_data_arr['latitude'], $meeting_data_arr)) {
                    $latitude = $meeting_data_arr['latitude'];
                }
                if (in_array($meeting_data_arr['longitude'], $meeting_data_arr)) {
                    $longitude = $meeting_data_arr['longitude'];
                }
                if (in_array($meeting_data_arr['instruction'], $meeting_data_arr)) {
                    $instruction = $meeting_data_arr['instruction'];
                }
                if (in_array($meeting_data_arr['date'], $meeting_data_arr)) {
                    $data_content = $final_date = date("Y-m-d H:i", $meeting_data_arr['date']);
                }
            } else {
                if ($data_timestamp) {
                    // $data_content = date("Y-m-d H:i", $data_timestamp);
                    $data_content = "";
                }
            }
            $message = $language->text('hammu', $data["action"] . "_noti", array('user' => $inviteeUsername, "date" => $date, "time" => $time, "data" => $data_content));
            $flag = "none";
            if ($data["action"] == "invitation_accept") {
                $flag = "agree";
            } else {
                if ($data["action"] == "buy_rose") {
                    $flag = "location";
                } else {
                    if ($data["action"] == "propose_date_accept" || $data["action"] == "client_re_arrange") {
                        $flag = "confirm";
                    } else {
                        if ($data["action"] == "meet_location") {
                            $flag = "meetting";
                        } else {
                            if ($data["action"] == "buy_rose_client") {
                                $flag = "location";
                            }
                        }
                    }
                }
            }
            //echo $data["inviteeId"];
            if ($inviteeId_loop != $data["inviteeId"]) {
                $inviteeId_loop = $data["inviteeId"];
                $user_infos = getUserInfo($inviteeId_loop);
            }
            $user_infos["meet_location"] = $meet_location;
            $user_infos["latitude"] = $latitude;
            $user_infos["longitude"] = $longitude;
            $user_infos["instruction"] = $instruction;
            $user_infos["propose_date"] = $final_date;
            $return_array[] = array("message" => $message, "id" => $data["id"], "data" => $data["data"], "flag" => $flag, "action" => $data["action"], "seen_unseen" => $data["flag"], "inviteeId" => $data["inviteeId"], "user_info" => $user_infos, "date" => date("Y/m/d H:i", $data["timestamp"]), "is_favorite" => $is_favorite);
        }
        // exit;
        $return_data = array("response_status" => "1", "data" => $return_array);
        $app->response->setBody(json_encode($return_data));
    } else {
        $message = $language->text("hammu", "client_notification_list_fail");
        //"You have No Notification"
        $return_data = array("response_status" => "0", "response_message" => $message);
        $app->response->setBody(json_encode($return_data));
    }
}
Beispiel #5
0
             if (!empty($value)) {
                 $stringVAL .= '<td>' . $value . '</td>';
             }
         }
         return $stringVAL .= '</tr></table>';
     } else {
         return $string;
     }
 }
 $description_product = $field['description_product'][0];
 $ingredients_product = $field['ingredients_product'][0];
 $ingredients_product_all = $field['ingredients_product_all'][0];
 $warning_product = $field['warning_product'][0];
 $type_product = $field['type_product'][0];
 $odor_product = $field['odor_product'][0];
 $extent_product = isJSON($field['extent_product'][0]);
 $type_packaging_product = $field['type_packaging_product'][0];
 $cardboard_product = $field['cardboard_product'][0];
 $pallets_product = $field['pallets_product'][0];
 ?>
         <div class="col-xs-12 col-sm-3 col-md-3">
             <?php 
 $content = get_post(get_the_ID());
 echo $content->post_content;
 ?>
             <div class="col-xs-12 product-extend-block">
                 <?php 
 echo $extent_product;
 ?>
             </div>
         </div>
Beispiel #6
0
function client_notification_list()
{
    global $HAMMU_BOL_Service;
    global $language;
    global $Userservice;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    $inviterId = $app->request()->params("inviterId");
    $rarray = $HAMMU_BOL_Service->findClientListByIds($inviterId);
    $datas = json_decode(json_encode($rarray, true), true);
    if (!empty($datas)) {
        $return_array = array();
        $inviteeId_loop = null;
        //$user_infos;
        $data_content = "";
        foreach ($datas as $key => $data) {
            $inviteeUsername = $Userservice->getUserName($data["inviteeId"]);
            $date = date("Y/m/d H:i", $data["timestamp"]);
            $time = date("H:i", $data["timestamp"]);
            $data_timestamp = $data["data"];
            $data_content = "";
            $json_string = isJSON($data_timestamp);
            if (!empty($json_string)) {
                $meet_location_result = json_decode($data_timestamp);
                //                print_r($meet_location_result->meet_location);
                //                exit;
            } else {
                if ($data_timestamp) {
                    $data_content = date("Y-m-d H:i", $data_timestamp);
                }
            }
            $message = $language->text('hammu', $data["action"] . "_noti", array('user' => $inviteeUsername, "date" => $date, "time" => $time, "data" => $data_content));
            $flag = "none";
            if ($data["action"] == "invitation_accept") {
                $flag = "agree";
            } else {
                if ($data["action"] == "buy_rose") {
                    $flag = "location";
                } else {
                    if ($data["action"] == "propose_date_accept" || $data["action"] == "client_re_arrange") {
                        $flag = "confirm";
                    }
                }
            }
            if ($inviteeId_loop != $data["inviteeId"]) {
                $inviteeId_loop = $data["inviteeId"];
                $user_infos = getUserInfo($inviteeId_loop);
            }
            $return_array[] = array("message" => $message, "id" => $data["id"], "data" => $data["data"], "flag" => $flag, "action" => $data["action"], "seen_unseen" => $data["flag"], "inviteeId" => $data["inviteeId"], "user_info" => $user_infos, "date" => date("Y/m/d H:i", $data["timestamp"]));
        }
        $return_data = array("response_status" => "1", "data" => $return_array);
        $app->response->setBody(json_encode($return_data));
    } else {
        $return_data = array("response_status" => "0", "response_message" => "You have No Notification");
        $app->response->setBody(json_encode($return_data));
    }
}
Beispiel #7
0
 public function createorder()
 {
     $json = array();
     if (!$this->cart->hasProducts() && (!isset($this->session->data['vouchers']) || !$this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
         $json['redirect'] = $this->url->link('checkout/cart');
     }
     $this->load->model('onecheckout/checkout');
     $version_int = $this->model_onecheckout_checkout->versiontoint();
     if ($this->customer->isLogged()) {
         $payment_address = $this->model_onecheckout_checkout->getAddress($this->session->data['payment_address_id']);
     } elseif (isset($this->session->data['guest']['payment'])) {
         $payment_address = $this->session->data['guest']['payment'];
     }
     if (!isset($payment_address)) {
         $json['redirect'] = $this->url->link('onecheckout/checkout', '', 'SSL');
     }
     if (!isset($this->session->data['payment_method'])) {
         $json['redirect'] = $this->url->link('onecheckout/checkout', '', 'SSL');
     }
     if ($this->cart->hasShipping()) {
         if ($this->customer->isLogged()) {
             $shipping_address = $this->model_onecheckout_checkout->getAddress($this->session->data['shipping_address_id']);
         } elseif (isset($this->session->data['guest']['shipping'])) {
             $shipping_address = $this->session->data['guest']['shipping'];
         }
         if (!isset($shipping_address)) {
             $json['redirect'] = $this->url->link('onecheckout/checkout', '', 'SSL');
         }
         if (!isset($this->session->data['shipping_method'])) {
             $json['redirect'] = $this->url->link('onecheckout/checkout', '', 'SSL');
         }
     } else {
         unset($this->session->data['guest']['shipping']);
         unset($this->session->data['shipping_address_id']);
         unset($this->session->data['shipping_method']);
         unset($this->session->data['shipping_methods']);
     }
     if (!$json) {
         $total_data = array();
         $total = 0;
         $taxes = $this->cart->getTaxes();
         $sort_order = array();
         $results = $this->model_onecheckout_checkout->getExtensions('total');
         foreach ($results as $key => $value) {
             $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
         }
         array_multisort($sort_order, SORT_ASC, $results);
         foreach ($results as $result) {
             if ($this->config->get($result['code'] . '_status')) {
                 $this->load->model('total/' . $result['code']);
                 $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
             }
         }
         $sort_order = array();
         foreach ($total_data as $key => $value) {
             $sort_order[$key] = $value['sort_order'];
         }
         array_multisort($sort_order, SORT_ASC, $total_data);
         $data = array();
         $data['invoice_prefix'] = $this->config->get('config_invoice_prefix');
         $data['store_id'] = $this->config->get('config_store_id');
         $data['store_name'] = $this->config->get('config_name');
         if ($data['store_id']) {
             $data['store_url'] = $this->config->get('config_url');
         } else {
             $data['store_url'] = HTTP_SERVER;
         }
         if ($this->customer->isLogged()) {
             $data['customer_id'] = $this->customer->getId();
             $data['customer_group_id'] = $this->customer->getCustomerGroupId();
             $data['firstname'] = $this->customer->getFirstName();
             $data['lastname'] = $this->customer->getLastName();
             $data['email'] = $this->customer->getEmail();
             $data['telephone'] = $this->customer->getTelephone();
             $data['fax'] = $this->customer->getFax();
             $payment_address = $this->model_onecheckout_checkout->getAddress($this->session->data['payment_address_id']);
             if ($version_int >= 1530) {
                 $payment_address = array();
                 $this->load->model('account/address');
                 $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);
             }
         } elseif (isset($this->session->data['guest'])) {
             $data['customer_id'] = 0;
             $data['customer_group_id'] = isset($this->session->data['guest']['customer_group_id']) ? $this->session->data['guest']['customer_group_id'] : $this->config->get('config_customer_group_id');
             $data['firstname'] = $this->session->data['guest']['firstname'];
             $data['lastname'] = $this->session->data['guest']['lastname'];
             $data['email'] = $this->session->data['guest']['email'];
             $data['telephone'] = $this->session->data['guest']['telephone'];
             $data['fax'] = $this->session->data['guest']['fax'];
             $payment_address = $this->session->data['guest']['payment'];
         }
         $data['payment_firstname'] = $payment_address['firstname'];
         $data['payment_lastname'] = $payment_address['lastname'];
         $data['payment_company'] = $payment_address['company'];
         $data['payment_company_id'] = isset($payment_address['company_id']) ? $payment_address['company_id'] : '';
         $data['payment_tax_id'] = isset($payment_address['tax_id']) ? $payment_address['tax_id'] : '';
         $data['payment_address_1'] = $payment_address['address_1'];
         $data['payment_address_2'] = $payment_address['address_2'];
         $data['payment_city'] = $payment_address['city'];
         $data['payment_postcode'] = $payment_address['postcode'];
         $data['payment_zone'] = $payment_address['zone'];
         $data['payment_zone_id'] = $payment_address['zone_id'];
         $data['payment_country'] = $payment_address['country'];
         $data['payment_country_id'] = $payment_address['country_id'];
         $data['payment_address_format'] = $payment_address['address_format'];
         if (isset($this->session->data['payment_method']['title'])) {
             $data['payment_method'] = $this->session->data['payment_method']['title'];
         } else {
             $data['payment_method'] = '';
         }
         if (isset($this->session->data['payment_method']['code'])) {
             $data['payment_code'] = $this->session->data['payment_method']['code'];
         } else {
             $data['payment_code'] = '';
         }
         if ($this->cart->hasShipping()) {
             if ($this->customer->isLogged()) {
                 $shipping_address = $this->model_onecheckout_checkout->getAddress($this->session->data['shipping_address_id']);
             } elseif (isset($this->session->data['guest']['shipping'])) {
                 $shipping_address = $this->session->data['guest']['shipping'];
             }
             $data['shipping_firstname'] = $shipping_address['firstname'];
             $data['shipping_lastname'] = $shipping_address['lastname'];
             $data['shipping_company'] = $shipping_address['company'];
             $data['shipping_address_1'] = $shipping_address['address_1'];
             $data['shipping_address_2'] = $shipping_address['address_2'];
             $data['shipping_city'] = $shipping_address['city'];
             $data['shipping_postcode'] = $shipping_address['postcode'];
             $data['shipping_zone'] = $shipping_address['zone'];
             $data['shipping_zone_id'] = $shipping_address['zone_id'];
             $data['shipping_country'] = $shipping_address['country'];
             $data['shipping_country_id'] = $shipping_address['country_id'];
             $data['shipping_address_format'] = $shipping_address['address_format'];
             if (isset($this->session->data['shipping_method']['title'])) {
                 $data['shipping_method'] = $this->session->data['shipping_method']['title'];
             } else {
                 $data['shipping_method'] = '';
             }
             if (isset($this->session->data['shipping_method']['code'])) {
                 $data['shipping_code'] = $this->session->data['shipping_method']['code'];
             } else {
                 $data['shipping_code'] = '';
             }
         } else {
             $data['shipping_firstname'] = '';
             $data['shipping_lastname'] = '';
             $data['shipping_company'] = '';
             $data['shipping_address_1'] = '';
             $data['shipping_address_2'] = '';
             $data['shipping_city'] = '';
             $data['shipping_postcode'] = '';
             $data['shipping_zone'] = '';
             $data['shipping_zone_id'] = '';
             $data['shipping_country'] = '';
             $data['shipping_country_id'] = '';
             $data['shipping_address_format'] = '';
             $data['shipping_method'] = '';
             $data['shipping_code'] = '';
         }
         $this->language->load('onecheckout/checkout');
         $this->load->library('encryption');
         //version
         if ($version_int < 1513 && $version_int >= 1500) {
             if ($this->cart->hasShipping()) {
                 $this->tax->setZone($shipping_address['country_id'], $shipping_address['zone_id']);
             } else {
                 $this->tax->setZone($payment_address['country_id'], $payment_address['zone_id']);
             }
         }
         $product_data = array();
         $total_saleoff = 0;
         $sale2 = 0;
         foreach ($this->cart->getProducts() as $product) {
             $option_data = array();
             foreach ($product['option'] as $option) {
                 if ($option['type'] != 'file') {
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $option['option_value'], 'type' => $option['type']);
                 } else {
                     $encryption = new Encryption($this->config->get('config_encryption'));
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $encryption->decrypt($option['option_value']), 'type' => $option['type']);
                 }
                 if ($option['type'] != 'date') {
                     $option_include = $option['include'];
                 }
             }
             $version_int = $this->model_onecheckout_checkout->versiontoint();
             //version
             if ($version_int < 1513 && $version_int >= 1500) {
                 $version_tax = $this->tax->getRate($product['tax_class_id']);
             } elseif ($version_int >= 1513) {
                 $version_tax = $this->tax->getTax($product['price'], $product['tax_class_id']);
             }
             if (preg_match('/người lớn/', $product['option'][0]['name'])) {
                 $sale = 0;
                 $date = explode('/', end($option_data)['value']);
                 $date_ch = strtotime($date[1] . '/' . $date[0] . '/' . $date[2]);
                 if (isJSON($this->event->check((int) $product['product_id']))) {
                     $EVENT_START = EVENT_START;
                     $EVENT_START2 = EVENT_START;
                     $EVENT_END = EVENT_END;
                 } else {
                     $EVENT_START = '0000-00-00';
                     $EVENT_START2 = '0000-00-00';
                     $EVENT_END = '0000-00-00';
                 }
                 if ($date_ch >= strtotime($EVENT_START2) && $date_ch <= strtotime($EVENT_END)) {
                     /*---- code by minh event am lich -----*/
                     $json = json_decode($this->event->check((int) $product['product_id']), true);
                     if (isset($json)) {
                         if (EVENT_CODE == 'GT_') {
                             preg_match('/[0-9]/', $json['name'], $match);
                             if ($product['day_pay'] == 1) {
                                 if ($product['quantity'] < 3) {
                                     $sale = 75000;
                                 } elseif ($product['quantity'] >= 3 && $product['quantity'] < 5) {
                                     $sale = 105000;
                                 } elseif ($product['quantity'] > 5) {
                                     $sale = 145000;
                                 }
                             }
                             if ($product['day_pay'] == 2) {
                                 if ($product['quantity'] < 3) {
                                     $sale = 145000;
                                 } elseif ($product['quantity'] >= 3 && $product['quantity'] < 5) {
                                     $sale = 175000;
                                 } elseif ($product['quantity'] > 5) {
                                     $sale = 295000;
                                 }
                             }
                         }
                     }
                     /*---- code by minh  event am lich -----*/
                 }
                 $sale2 = $sale2 + $sale * $product['quantity'];
                 $total_saleoff = $total_saleoff + $product['total'] - $sale * $product['quantity'];
             } else {
                 $total_saleoff = $total_saleoff + $product['total'];
             }
             $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'day_pay' => $product['day_pay'], 'model' => $product['model'], 'included' => $option_include ? $option_include : $product['included'], 'notincluded' => $product['notincluded'], 'terms' => $product['terms'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $version_tax, 'reward' => isset($product['reward']) ? $product['reward'] : 0);
         }
         // Gift Voucher
         if ($version_int < 1520 && $version_int >= 1500) {
             if (isset($this->session->data['vouchers']) && $this->session->data['vouchers']) {
                 foreach ($this->session->data['vouchers'] as $voucher) {
                     $product_data[] = array('product_id' => 0, 'name' => $voucher['description'], 'model' => '', 'option' => array(), 'download' => array(), 'quantity' => 1, 'subtract' => false, 'price' => $voucher['amount'], 'total' => $voucher['amount'], 'tax' => 0);
                 }
             }
             $data['reward'] = $this->cart->getTotalRewardPoints();
         } elseif ($version_int >= 1520) {
             $voucher_data = array();
             if (!empty($this->session->data['vouchers'])) {
                 foreach ($this->session->data['vouchers'] as $voucher) {
                     $voucher_data[] = array('description' => $voucher['description'], 'code' => substr(md5(mt_rand()), 0, 10), 'to_name' => $voucher['to_name'], 'to_email' => $voucher['to_email'], 'from_name' => $voucher['from_name'], 'from_email' => $voucher['from_email'], 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount']);
                 }
             }
             $data['vouchers'] = $voucher_data;
         }
         $data_total['saleoff'] = $sale2;
         $data_total['total_saleoff'] = $total_saleoff;
         $data['products'] = $product_data;
         $data['totals'] = $total_data;
         $data['comment'] = $this->session->data['comment'];
         $data['total'] = $total;
         if (isset($this->request->cookie['tracking'])) {
             $affiliate_info = $this->model_onecheckout_checkout->getAffiliateByCode($this->request->cookie['tracking']);
             $subtotal = $this->cart->getSubTotal();
             if ($affiliate_info) {
                 $data['affiliate_id'] = $affiliate_info['affiliate_id'];
                 $data['commission'] = $subtotal / 100 * $affiliate_info['commission'];
             } else {
                 $data['affiliate_id'] = 0;
                 $data['commission'] = 0;
             }
         } else {
             $data['affiliate_id'] = 0;
             $data['commission'] = 0;
         }
         $data['language_id'] = $this->config->get('config_language_id');
         $data['currency_id'] = $this->currency->getId();
         $data['currency_code'] = $this->currency->getCode();
         $data['currency_value'] = $this->currency->getValue($this->currency->getCode());
         $data['ip'] = $this->request->server['REMOTE_ADDR'];
         if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
             $data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
         } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) {
             $data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP'];
         } else {
             $data['forwarded_ip'] = '';
         }
         if (isset($this->request->server['HTTP_USER_AGENT'])) {
             $data['user_agent'] = $this->request->server['HTTP_USER_AGENT'];
         } else {
             $data['user_agent'] = '';
         }
         if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) {
             $data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE'];
         } else {
             $data['accept_language'] = '';
         }
         if ($version_int < 1520 && $version_int >= 1500) {
             $this->session->data['order_id'] = $this->model_onecheckout_checkout->create($data);
             // Gift Voucher
             if (isset($this->session->data['vouchers']) && is_array($this->session->data['vouchers'])) {
                 foreach ($this->session->data['vouchers'] as $voucher) {
                     $this->model_onecheckout_checkout->addVoucher($this->session->data['order_id'], $voucher);
                 }
             }
         } elseif ($version_int >= 1520) {
             $this->load->model('checkout/order');
             $this->session->data['order_id'] = $this->model_checkout_order->addOrder($data);
             $data_total['order_id'] = $this->session->data['order_id'];
             $data_total['event_id'] = EVENT_ID;
             $this->model_checkout_order->addOrdertotalSaleOff($data_total);
         }
         $this->data['payment'] = $this->getChild('payment/' . $this->session->data['payment_method']['code']);
         $this->data['button_back'] = $this->language->get('button_back');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/onecheckout/confirmorder.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/onecheckout/confirmorder.tpl';
         } else {
             $this->template = 'default/template/onecheckout/confirmorder.tpl';
         }
         $json['output'] = $this->render();
     }
     $this->response->setOutput($this->model_onecheckout_checkout->jsonencode($json));
 }
Beispiel #8
0
function wsOnMessage($clientID, $message, $messageLength, $binary)
{
    global $Server;
    $client = $Server->wsClients[$clientID];
    $ip = long2ip($client[6]);
    // check if message length is 0
    if ($messageLength == 0) {
        $Server->wsClose($clientID);
        return;
    }
    if ($data = isJSON($message)) {
        if ($data->type == 'auth') {
            $data->id;
            $user = getUserInfo($data->id);
            if (!$user) {
                $Server->wsRemoveClient($clientID);
                $Server->log("!{$clientID}[{$ip}] not in system.");
            } else {
                $Server->wsClients[$clientID][15] = $data->room;
                $Server->wsClients[$clientID][12] = $data->id;
                $Server->wsClients[$clientID][13] = $user['last_name'] . ' ' . $user['first_name'];
                $client = $Server->wsClients[$clientID];
                foreach (array_keys($Server->wsClients) as $id) {
                    if ($id != $clientID) {
                        contactUpdate($id, $clientID, 'online');
                        sendMess($id, array('System', "{$client[13]} подключен к чату", '000'), $data->room);
                    } else {
                        sendMess($id, array('System', "Здравствуйте, {$client[13]}", '000'));
                        $color = getHystory($id, $data->room);
                        getUsers($id, $data->room);
                        getRooms($id);
                    }
                }
                if ($color) {
                    $Server->wsClients[$clientID][14] = $color;
                } else {
                    if (++$Server->c_id >= 6) {
                        $Server->c_id = 0;
                    }
                    $Server->wsClients[$clientID][14] = $Server->colors[$Server->c_id];
                }
                $Server->log("{$clientID}[{$ip}] login as {$client[13]} ({$client[12]}).");
                // $Server->log($Server->wsClients[$clientID]);
            }
        } else {
            if ($data->type == 'createRoom') {
                createRoom($clientID, $data->id, $data->room);
            } else {
                if ($data->type == 'add2Room') {
                    add2Room($clientID, $data->id, $data->room);
                } else {
                    if ($data->type == 'delRoom') {
                        updateRoom($data->room, false, $data->id, true);
                        getRooms($clientID);
                        foreach (array_keys($Server->wsClients) as $id) {
                            if ($id != $clientID) {
                                getUsers($id, $Server->wsClients[$id][15]);
                            }
                        }
                    } else {
                        if ($data->type == 'renRoom') {
                            updateRoom($data->room, $data->name, $data->id);
                            getRooms($clientID);
                        }
                    }
                }
            }
        }
    } else {
        $Server->log("{$clientID}[{$ip}] say:{$message}");
        if (!isset($client[12]) || $client[12] == '') {
            sendMess($clientID, array('System', "НЕАВТОРИЗОВАННАЯ ПОПЫТКА ДОСТУПА!", 'f00'));
            $Server->log("{$clientID}[{$ip}] unauthorized access.");
            $Server->wsClose($clientID);
        } else {
            //The speaker is the only person in the room. Don't let them feel lonely.
            /*if ( sizeof($Server->wsClients) == 1 )
            			sendMess($clientID, array('System', "Чат пуст, дождитесь хотябы одного собеседника", '000'));
            		else{*/
            $color = $client[14];
            $message = str_replace('<', '&lt;', $message);
            $message = str_replace('>', '&gt;', $message);
            $message = str_replace('\'', '&#039;', $message);
            $send_mes = set_smiles($message);
            //Send the message to everyone but the person who said it
            foreach (array_keys($Server->wsClients) as $id) {
                $time = date('H:i:s');
                if ($id != $clientID) {
                    $mes = array($client[13] . '|' . $time, $send_mes, $color);
                } else {
                    $mes = array('You|' . $time, $send_mes, $color);
                    addHistory($client[12], $message, $color, $client[15]);
                }
                sendMess($id, $mes, $client[15]);
            }
            //}
        }
    }
}
 public function EventAL()
 {
     $tourgroup = 3;
     $price1 = $price2 = $price3 = '';
     $this->language->load('product/product');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->load->model('catalog/category');
     $this->load->model('catalog/manufacturer');
     if (isset($this->request->get['manufacturer_id'])) {
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator'));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
         if ($manufacturer_info) {
             $this->data['breadcrumbs'][] = array('text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url), 'separator' => $this->language->get('text_separator'));
         }
     }
     if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
         $url = '';
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url), 'separator' => $this->language->get('text_separator'));
     }
     if (isset($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         $product_id = 0;
     }
     $this->data['grouptour'] = 0;
     if (isset($product_id)) {
         /* bat dieu kien kiem tra thu vien event, neu la chuoi JSON, san pham thuoc dieu kien cua thu vien, neu khong se return 0*/
         if (isJSON($this->event->check($product_id))) {
             $this->data['promotion_date_start'] = EVENT_START;
             $this->data['promotion_date_start2'] = EVENT_START;
             $this->data['promotion_date_end'] = EVENT_END;
         } else {
             $this->data['promotion_date_start'] = '0000-00-00';
             $this->data['promotion_date_start2'] = '0000-00-00';
             $this->data['promotion_date_end'] = '0000-00-00';
         }
         /* Khoa end*/
         if ($this->event->check($product_id)) {
             $this->data['event'] = 'event';
             $json = json_decode($this->event->check($product_id));
             $match = explode('#', $json->name);
             // print_r($match);
             // exit();
             if (isset($match[3]) && $match[3] != 0 && !empty($match[3])) {
                 if ($match[3] <= 3) {
                     $this->data['linkbannergroup'] = HTTP_SERVER . '/image/data/banner-promotion/nguyendan/1-3n.jpg';
                     $this->data['grouptour'] = 1;
                 } elseif ($match[3] >= 4 && $match[3] <= 6) {
                     $this->data['linkbannergroup'] = HTTP_SERVER . '/image/data/banner-promotion/nguyendan/4-6n.jpg';
                     $this->data['grouptour'] = 2;
                 } else {
                     $this->data['linkbannergroup'] = HTTP_SERVER . '/image/data/banner-promotion/nguyendan/7n.jpg';
                     $this->data['grouptour'] = 3;
                 }
             } else {
                 $this->data['grouptour'] = 4;
             }
         }
     }
     $this->load->model('catalog/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     if ($product_info) {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         if ($product_info['custom_breadcrumb']) {
             /* Set parent category breadcrumb	*/
             $category_parent = $this->model_catalog_category->getParentByCategoriesId($product_info['custom_breadcrumb']);
             foreach ($category_parent as $path_id) {
                 $category_info = $this->model_catalog_category->getCategory($path_id);
                 if ($category_info) {
                     $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path_id), 'separator' => $this->language->get('text_separator'));
                 }
             }
             /* Set the last category breadcrumb		*/
             $category_info = $this->model_catalog_category->getCategory($product_info['custom_breadcrumb']);
             if ($category_info) {
                 $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $product_info['custom_breadcrumb']), 'separator' => $this->language->get('text_separator'));
             }
         }
         $this->data['breadcrumbs'][] = array('text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($product_info['custom_title'] ? $product_info['custom_title'] : $product_info['name']);
         $this->document->setDescription($product_info['meta_description']);
         $this->document->setKeywords($product_info['meta_keyword']);
         $this->document->addLink($this->url->link('product/product', 'path=' . $product_info['custom_link'] . '&product_id=' . $this->request->get['product_id']), 'canonical');
         $this->document->addScript('catalog/view/javascript/jquery/minitip/jquery.miniTip.min.js');
         $this->document->addScript('catalog/view/javascript/jquery/tabs.js');
         $this->document->addScript('catalog/view/javascript/jquery/colorbox/jquery.colorbox-min.js');
         $this->document->addStyle('catalog/view/javascript/jquery/colorbox/colorbox.css');
         $this->document->addScript('catalog/view/javascript/jquery/jquery-scrolltofixed-min.js');
         $this->document->addScript('catalog/view/javascript/jquery/jquery.jcarousel.min.js');
         $this->document->addStyle('catalog/view/javascript/jquery/minitip/miniTip.min.css');
         if (file_exists('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/carousel.css')) {
             $this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/carousel.css');
         } else {
             $this->document->addStyle('catalog/view/theme/default/stylesheet/carousel.css');
         }
         if ($product_info['robot_index']) {
             $this->document->addMeta('noindex, nofollow', '', 'robots');
         }
         $this->data['heading_title'] = $product_info['name_tour'] ? $product_info['name_tour'] : $product_info['name'];
         $this->data['text_select'] = $this->language->get('text_select');
         $this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
         $this->data['text_model'] = $this->language->get('text_model');
         $this->data['text_reward'] = $this->language->get('text_reward');
         $this->data['text_points'] = $this->language->get('text_points');
         $this->data['text_discount'] = $this->language->get('text_discount');
         $this->data['text_stock'] = $this->language->get('text_stock');
         $this->data['text_price'] = $this->language->get('text_price');
         $this->data['text_tax'] = $this->language->get('text_tax');
         $this->data['text_option'] = $this->language->get('text_option');
         $this->data['text_qty'] = $this->language->get('text_qty');
         $this->data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
         $this->data['text_or'] = $this->language->get('text_or');
         $this->data['text_write'] = $this->language->get('text_write');
         $this->data['text_review'] = sprintf($this->language->get('text_review'), $this->data['heading_title']);
         $this->data['text_note'] = $this->language->get('text_note');
         $this->data['text_share'] = $this->language->get('text_share');
         $this->data['text_wait'] = $this->language->get('text_wait');
         $this->data['text_tags'] = $this->language->get('text_tags');
         /*V2*/
         $this->data['text_percent'] = $this->language->get('text_percent');
         $this->data['text_price_special'] = $this->language->get('text_price_special');
         $this->data['text_price_special1'] = $this->language->get('text_price_special1');
         $this->data['text_time_special'] = $this->language->get('text_time_special');
         $this->data['text_time_special1'] = $this->language->get('text_time_special1');
         $this->data['text_price_save'] = $this->language->get('text_price_save');
         $this->data['text_info'] = $this->language->get('text_info');
         $this->data['text_info_details'] = $this->language->get('text_info_details');
         $this->data['text_desc'] = sprintf($this->language->get('text_desc'), $this->data['heading_title']);
         $this->data['text_highlights'] = $this->language->get('text_highlights');
         $this->data['text_schedule'] = $this->language->get('text_schedule');
         $this->data['text_price_details'] = sprintf($this->language->get('text_price_details'), $this->data['heading_title']);
         $this->data['text_type'] = $this->language->get('text_type');
         $this->data['text_price_list'] = $this->language->get('text_price_list');
         $this->data['text_hotel_details'] = sprintf($this->language->get('text_hotel_details'), $this->data['heading_title']);
         $this->data['text_location'] = $this->language->get('text_location');
         $this->data['text_hotel'] = $this->language->get('text_hotel');
         $this->data['text_slideshow'] = $this->language->get('text_slideshow');
         $this->data['text_terms'] = $this->language->get('text_terms');
         $this->data['text_not_menu'] = $this->language->get('text_not_menu');
         /*END V2*/
         $this->data['entry_name'] = $this->language->get('entry_name');
         $this->data['entry_review'] = $this->language->get('entry_review');
         $this->data['entry_rating'] = $this->language->get('entry_rating');
         $this->data['entry_good'] = $this->language->get('entry_good');
         $this->data['entry_bad'] = $this->language->get('entry_bad');
         $this->data['entry_captcha'] = $this->language->get('entry_captcha');
         /*V2*/
         $this->data['entry_duration'] = $this->language->get('entry_duration');
         $this->data['entry_departure'] = $this->language->get('entry_departure');
         $this->data['entry_start_time'] = $this->language->get('entry_start_time');
         $this->data['entry_start_time_holiday'] = $this->language->get('entry_start_time_holiday');
         $this->data['entry_start_time_tet'] = $this->language->get('entry_start_time_tet');
         $this->data['entry_not_start_time'] = $this->language->get('entry_not_start_time');
         $this->data['entry_location_to'] = $this->language->get('entry_location_to');
         $this->data['entry_location_from'] = $this->language->get('entry_location_from');
         $this->data['entry_transport'] = $this->language->get('entry_transport');
         $this->data['entry_schedule'] = $this->language->get('entry_schedule');
         $this->data['entry_included'] = $this->language->get('entry_included');
         $this->data['entry_notincluded'] = $this->language->get('entry_notincluded');
         $this->data['entry_info_extra'] = $this->language->get('entry_info_extra');
         $this->data['entry_meeting'] = $this->language->get('entry_meeting');
         $this->data['entry_tag'] = $this->language->get('entry_tag');
         $this->data['entry_model'] = $this->language->get('entry_model');
         /*END V2*/
         $this->data['button_cart'] = $this->language->get('button_cart');
         $this->data['button_car_rent'] = $this->language->get('button_car_rent');
         $this->data['button_wishlist'] = $this->language->get('button_wishlist');
         $this->data['button_compare'] = $this->language->get('button_compare');
         $this->data['button_upload'] = $this->language->get('button_upload');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->load->model('catalog/review');
         $this->data['tab_description'] = $this->language->get('tab_description');
         $this->data['tab_attribute'] = $this->language->get('tab_attribute');
         $this->data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
         $this->data['tab_related'] = $this->language->get('tab_related');
         /*V2*/
         $this->data['tab_schedule'] = $this->language->get('tab_schedule');
         $this->data['tab_price'] = $this->language->get('tab_price');
         $this->data['tab_hotel'] = $this->language->get('tab_hotel');
         $this->data['tab_payment'] = $this->language->get('tab_payment');
         $this->data['tab_terms'] = $this->language->get('tab_terms');
         $this->data['tab_info'] = $this->language->get('tab_info');
         $this->data['tab_menu'] = $this->language->get('tab_menu');
         /*END V2*/
         $this->data['product_id'] = $this->request->get['product_id'];
         $this->data['manufacturer'] = $product_info['manufacturer'];
         $this->data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
         $this->data['model'] = $product_info['model'];
         $this->data['reward'] = $product_info['reward'];
         $this->data['points'] = $product_info['points'];
         $this->data['promotion_title'] = $this->config->get('promotion_title');
         $this->data['promotion_title2'] = $this->config->get('promotion_title2');
         $this->data['start_time'] = $product_info['start_time'];
         //
         $this->data['start_time_holiday'] = $product_info['start_time_holiday'];
         $this->data['start_time_tet'] = $product_info['start_time_tet'];
         $this->data['not_start_time'] = $product_info['not_start_time'];
         $this->data['departure'] = $product_info['departure'];
         $this->data['location_to'] = $product_info['location_to'];
         $this->data['location_from'] = $product_info['location_from'];
         $this->data['transport'] = $product_info['transport'];
         $this->data['duration'] = $product_info['duration'];
         $this->data['sub_duration'] = $product_info['sub_duration'];
         $this->data['schedule'] = $product_info['schedule'];
         $this->data['product_class'] = $product_info['product_class'];
         $this->data['print_product'] = 'print/' . str_replace(HTTP_SERVER, '', $this->url->link('product/product', 'path=' . $product_info['custom_link'] . '&product_id=' . $this->request->get['product_id']));
         /*UPDATE DATE PROMOTION*/
         $this->data['promotion_date'] = $price_date1 = $price_date2 = $price_date3 = '';
         $duration = explode(' ', $product_info['duration']);
         $duration = $duration[0];
         if ($duration > 5) {
             $this->data['promotion_date'] = 3;
             $price_date1 = '220000';
             $price_date2 = '230000';
             $price_date3 = '240000';
         } elseif ($duration >= 2 && $duration <= 5) {
             $this->data['promotion_date'] = 2;
             $price_date1 = '150000';
             $price_date2 = '160000';
             $price_date3 = '170000';
         } else {
             $this->data['promotion_date'] = 1;
             $price_date1 = '80000';
             $price_date2 = '90000';
             $price_date3 = '100000';
         }
         /*END UPDATE DATE PROMOTION						
         		//UPDATE DATE PROMOTION 2	*/
         $this->data['promotion_date2'] = $price_date12 = $price_date22 = $price_date32 = '';
         $price_date12 = '100000';
         $price_date22 = '150000';
         $price_date32 = '200000';
         /*END UPDATE DATE PROMOTION 2*/
         if ($product_info['quantity'] <= 0) {
             $this->data['stock'] = $product_info['stock_status'];
         } elseif ($this->config->get('config_stock_display')) {
             $this->data['stock'] = $product_info['quantity'];
         } else {
             $this->data['stock'] = $this->language->get('text_instock');
         }
         $this->load->model('tool/image');
         if ($product_info['image'] && file_exists(DIR_IMAGE . $product_info['image'])) {
             $this->data['popup'] = $this->model_tool_image->onesize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         } else {
             $this->data['popup'] = $this->model_tool_image->onesize('no_image.jpg', $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         }
         if ($product_info['image'] && file_exists(DIR_IMAGE . $product_info['image'])) {
             $this->data['thumb'] = $this->model_tool_image->cropsize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         } else {
             $this->data['thumb'] = $this->model_tool_image->cropsize('no_image.jpg', $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         }
         $this->data['images'] = array();
         $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
         foreach ($results as $result) {
             $this->data['images'][] = array('popup' => $this->model_tool_image->onesize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->cropsize($result['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')));
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price') && $product_info['price'] != 0) {
             $this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $this->data['price'] = false;
         }
         if ((double) $product_info['special']) {
             $this->data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $this->data['special'] = false;
         }
         if ((double) $product_info['special1']) {
             $this->data['special1'] = $this->currency->format($this->tax->calculate($product_info['special1'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $this->data['special1'] = false;
         }
         $price_save = $product_info['price'] - $product_info['special'];
         if ($price_save > 0) {
             $this->data['price_save'] = $this->currency->format($this->tax->calculate($price_save, $product_info['tax_class_id'], $this->config->get('config_tax')));
             /*$this->data['percent'] = ceil(($price_save / $product_info['price']) * 100);*/
             $this->data['percent'] = $this->currency->format($price_save);
         } else {
             $this->data['price_save'] = false;
             $this->data['percent'] = false;
         }
         if ($this->config->get('config_tax')) {
             $this->data['tax'] = $this->currency->format((double) $product_info['special'] ? $product_info['special'] : $product_info['price']);
         } else {
             $this->data['tax'] = false;
         }
         $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
         $this->data['discounts'] = array();
         foreach ($discounts as $discount) {
             $this->data['discounts'][] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))));
         }
         $this->data['policy'] = array();
         if ($product_info['policy']) {
             $this->load->model('catalog/policy');
             $policy = $this->model_catalog_policy->getPolicy($product_info['policy']);
             $this->data['policy'] = array('name' => $policy['name'], 'description' => html_entity_decode($policy['description'], ENT_QUOTES, 'UTF-8'));
         }
         $this->data['phuthu'] = array(22, 28, 96, 97, 99, 117);
         $this->data['check_maybay'] = $this->data['check_vetau'] = false;
         $this->data['options'] = array();
         foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) {
             if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox' || $option['type'] == 'image') {
                 $option_value_data = array();
                 foreach ($option['option_value'] as $option_value) {
                     if (!$option_value['subtract'] || $option_value['quantity'] > 0) {
                         if ($tourgroup == 0) {
                             if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                                 $price1 = $this->currency->format($this->tax->calculate((int) $option_value['price'] - 99000, $product_info['tax_class_id'], $this->config->get('config_tax')));
                             } else {
                                 $price1 = false;
                             }
                             if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                                 $price2 = $this->currency->format($this->tax->calculate((int) $option_value['price'] - 119000, $product_info['tax_class_id'], $this->config->get('config_tax')));
                             } else {
                                 $price2 = false;
                             }
                         }
                         if ($tourgroup == 1) {
                             if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                                 $price1 = $this->currency->format($this->tax->calculate((int) $option_value['price'] - 129000, $product_info['tax_class_id'], $this->config->get('config_tax')));
                             } else {
                                 $price1 = false;
                             }
                             if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                                 $price2 = $this->currency->format($this->tax->calculate((int) $option_value['price'] - 219000, $product_info['tax_class_id'], $this->config->get('config_tax')));
                             } else {
                                 $price2 = false;
                             }
                         }
                         if (($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) && (double) $option_value['price']) {
                             $price = $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
                         } else {
                             $price = false;
                         }
                         $option_value_data[] = array('product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'name' => $option_value['name'], 'image' => $this->model_tool_image->onesize($option_value['image'], 50, 50), 'price' => $price, 'price_1' => $price1, 'price_2' => $price2, 'price_text' => $option_value['price'], 'price1' => $option_value['price'] - $price_date1, 'price2' => $option_value['price'] - $price_date2, 'price3' => $option_value['price'] - $price_date3, 'price12' => $option_value['price'] - $price_date12, 'price22' => $option_value['price'] - $price_date22, 'price32' => $option_value['price'] - $price_date32, 'price_prefix' => '');
                     }
                 }
                 /*Check Ve May Bay		*/
                 if ($option['class'] == 1) {
                     $this->data['check_maybay'] = true;
                 }
                 /*Check Vé tàu*/
                 if ($option['class'] == 3) {
                     $this->data['check_vetau'] = true;
                 }
                 $this->data['options'][] = array('product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'category' => $option['category'], 'class' => $option['class'], 'option_value' => $option_value_data, 'required' => $option['required']);
             } elseif ($option['type'] == 'text' || $option['type'] == 'textarea' || $option['type'] == 'file' || $option['type'] == 'date' || $option['type'] == 'datetime' || $option['type'] == 'time') {
                 $this->data['options'][] = array('product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'category' => $option['category'], 'class' => $option['class'], 'option_value' => $option['option_value'], 'required' => $option['required']);
             }
         }
         if ($product_info['minimum']) {
             $this->data['minimum'] = $product_info['minimum'];
         } else {
             $this->data['minimum'] = 1;
         }
         if ($product_info['delay_book']) {
             $this->data['day'] = date($this->language->get('date_format_short'), time() + $product_info['delay_book'] * 86400);
         } else {
             $this->data['day'] = date($this->language->get('date_format_short'), time());
         }
         $this->data['delay_book'] = (int) $product_info['delay_book'];
         $this->data['product_type'] = (int) $product_info['product_type'];
         $this->data['product_class'] = (int) $product_info['product_class'];
         $this->data['promotion1_date_start'] = $this->language->get('promotion1_date_start');
         $this->data['promotion1_date_end'] = $this->language->get('promotion1_date_end');
         $this->data['review_status'] = $this->config->get('config_review_status');
         $this->data['reviews'] = sprintf($this->language->get('text_reviews'), (int) $product_info['reviews']);
         $this->data['rating'] = (int) $product_info['rating'];
         $this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
         $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']);
         $this->data['url'] = $this->url->link('product/product', 'path=' . $product_info['custom_link'] . '&product_id=' . $this->request->get['product_id']);
         $this->data['review_no'] = $product_info['reviews'];
         $this->data['quantity'] = $product_info['quantity'];
         $this->data['shortdescription'] = html_entity_decode($product_info['shortdescription'], ENT_QUOTES, 'UTF-8');
         $this->data['highlights'] = html_entity_decode($product_info['highlights'], ENT_QUOTES, 'UTF-8');
         $this->data['included'] = html_entity_decode($product_info['included'], ENT_QUOTES, 'UTF-8');
         $this->data['notincluded'] = html_entity_decode($product_info['notincluded'], ENT_QUOTES, 'UTF-8');
         $this->data['info'] = html_entity_decode($product_info['info'], ENT_QUOTES, 'UTF-8');
         $this->data['meeting'] = html_entity_decode($product_info['meeting'], ENT_QUOTES, 'UTF-8');
         $this->data['terms'] = html_entity_decode($product_info['terms'], ENT_QUOTES, 'UTF-8');
         $this->data['suggest'] = html_entity_decode($product_info['suggest'], ENT_QUOTES, 'UTF-8');
         $this->data['payment_content'] = html_entity_decode($this->config->get('payment_content'), ENT_QUOTES, 'UTF-8');
         $this->data['payment_menu'] = html_entity_decode($this->config->get('payment_menu'), ENT_QUOTES, 'UTF-8');
         $this->data['product_details'] = array();
         $product_details = $this->model_catalog_product->getProductDetails($this->request->get['product_id']);
         $this->load->model('catalog/attribute_meal');
         $this->data['check_menu'] = false;
         foreach ($product_details as $product_detail) {
             if ($product_detail['image'] && file_exists(DIR_IMAGE . $product_detail['image'])) {
                 $image = $product_detail['image'];
             } else {
                 $image = 'no_image.jpg';
             }
             $product_detail_meals = array();
             $attribute_meal_info = $this->model_catalog_attribute_meal->getAttributeMeals();
             foreach ($attribute_meal_info as $result) {
                 $s = $this->model_catalog_product->getProductDetailMeal($product_detail['product_detail_id'], $result['attribute_meal_id']);
                 if ($s) {
                     $product_detail_meals[] = array('attribute_meal_id' => $result['attribute_meal_id'], 'image' => HTTP_SERVER . 'image/' . $result['image'], 'name' => $result['name']);
                 }
             }
             if ($product_detail['menu']) {
                 $this->data['check_menu'] = true;
             }
             $this->data['product_details'][] = array('product_detail_id' => $product_detail['product_detail_id'], 'meals' => $product_detail_meals, 'label' => $product_detail['label'], 'title' => $product_detail['title'], 'text' => html_entity_decode($product_detail['text'], ENT_QUOTES, 'UTF-8'), 'menu' => html_entity_decode($product_detail['menu'], ENT_QUOTES, 'UTF-8'), 'image' => $image, 'thumb' => $this->model_tool_image->cropsize($image, $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')), 'status' => $product_detail['status'], 'sort_order' => $product_detail['sort_order']);
         }
         /*Attribute Meal*/
         $this->data['attribute_meals'] = array();
         $attribute_meal_info = $this->model_catalog_attribute_meal->getAttributeMeals();
         foreach ($attribute_meal_info as $result) {
             $this->data['attribute_meals'][] = array('attribute_meal_id' => $result['attribute_meal_id'], 'image' => HTTP_SERVER . 'image/' . $result['image'], 'name' => $result['name']);
         }
         $this->load->model('account/customer');
         if ($this->customer->isLogged()) {
             $customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
             $this->data['customer_name'] = $customer_info['lastname'] . ' ' . $customer_info['firstname'];
         } else {
             $this->data['customer_name'] = false;
         }
         $this->data['products'] = array();
         $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
         foreach ($results as $result) {
             if ($result['image']) {
                 $image = $this->model_tool_image->onesize($result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
                 $tooltip = $this->model_tool_image->onesize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
             } else {
                 $image = false;
                 $tooltip = false;
             }
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $price = false;
             }
             if ((double) $result['special']) {
                 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             $this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'tooltip' => $tooltip, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']));
         }
         $data = array('product_id' => $product_id, 'filter_duration' => $product_info['duration'], 'filter_category' => $product_info['custom_breadcrumb']);
         $this->data['products_orther'] = array();
         $results = $this->model_catalog_product->getOrtherProducts($data);
         /*var_dump($results)*/
         shuffle($results);
         $results = array_slice($results, 0, 6);
         foreach ($results as $result) {
             if ($result['image']) {
                 $image = $this->model_tool_image->onesize($result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
                 $tooltip = $this->model_tool_image->onesize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
             } else {
                 $image = false;
                 $tooltip = false;
             }
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price') && $result['price'] != 0) {
                 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $price = false;
             }
             if ((double) $result['special']) {
                 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             if (isset($result['custom_link'])) {
                 $custom_link = '&path=' . $result['custom_link'];
             }
             $this->data['products_orther'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'tooltip' => $tooltip, 'name' => cutString($result['name'], 20), 'full_name' => $result['name'], 'model' => $result['model'], 'start_time' => $result['start_time'], 'start_time_holiday' => $result['start_time_holiday'], 'start_time_tet' => $result['start_time_tet'], 'departure' => $result['departure'], 'location_to' => $result['location_to'], 'location_from' => $result['location_from'], 'transport' => $result['transport'], 'duration' => $result['duration'], 'schedule' => $result['schedule'], 'product_type' => $result['product_type'], 'price' => $price ? $price : $this->language->get('text_contact'), 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', $custom_link . '&product_id=' . $result['product_id']));
         }
         /*Tags*/
         $this->load->model('catalog/tag');
         $this->data['tags'] = array();
         $tags = $this->model_catalog_product->getTags($product_info['product_id']);
         foreach ($tags as $item) {
             $result = $this->model_catalog_tag->getTag($item['tag_id']);
             if ($result) {
                 $this->data['tags'][] = array('name' => $result['name_menu'] ? $result['name_menu'] : $result['name'], 'href' => $this->url->link('product/tag', 'tag_id=' . $result['tag_id']));
             }
         }
         $this->data['text_payment_profile'] = $this->language->get('text_payment_profile');
         $this->data['profiles'] = $this->model_catalog_product->getProfiles($product_info['product_id']);
         $this->model_catalog_product->updateViewed($this->request->get['product_id']);
         if ($product_info['product_type'] == 0) {
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
                 $this->template = $this->config->get('config_template') . '/template/product/product.tpl';
             } else {
                 $this->template = 'default/template/product/product.tpl';
             }
         }
         if ($product_info['product_type'] == 1) {
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/openbus.tpl')) {
                 $this->template = $this->config->get('config_template') . '/template/product/openbus.tpl';
             } else {
                 $this->template = 'default/template/product/openbus.tpl';
             }
         } elseif ($product_info['product_type'] == 2) {
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/car_rent.tpl')) {
                 $this->template = $this->config->get('config_template') . '/template/product/car_rent.tpl';
             } else {
                 $this->template = 'default/template/product/car_rent.tpl';
             }
         } elseif ($product_info['product_type'] == 3) {
             $this->template = $this->config->get('config_template') . '/template/product/tour_special_tet.tpl';
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header', 'module/comment');
         $this->response->setOutput($this->render());
     } else {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($this->language->get('text_error'));
         $this->data['heading_title'] = $this->language->get('text_error');
         $this->data['text_error'] = $this->language->get('text_error');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['continue'] = $this->url->link('common/home');
         $this->data['error_tmp'] = 1;
         $this->data['heading_title_page'] = $this->language->get('heading_title_error_site');
         $this->data['heading_title_error'] = $this->language->get('heading_title_error');
         $this->data['text_special_error'] = $this->language->get('text_special_error');
         $this->data['text_account_error'] = $this->language->get('text_account_error');
         $this->data['text_edit_error'] = $this->language->get('text_edit_error');
         $this->data['text_password_error'] = $this->language->get('text_password_error');
         $this->data['text_address_error'] = $this->language->get('text_address_error');
         $this->data['text_history_error'] = $this->language->get('text_history_error');
         $this->data['text_download_error'] = $this->language->get('text_download_error');
         $this->data['text_cart_error'] = $this->language->get('text_cart_error');
         $this->data['text_checkout_error'] = $this->language->get('text_checkout_error');
         $this->data['text_search_error'] = $this->language->get('text_search_error');
         $this->data['text_information_error'] = $this->language->get('text_information_error');
         $this->data['text_contact_error'] = $this->language->get('text_contact_error');
         $this->load->model('catalog/category');
         $this->load->model('catalog/product');
         $this->data['categories'] = array();
         $categories_1 = $this->model_catalog_category->getCategories(0);
         foreach ($categories_1 as $category_1) {
             $level_2_data = array();
             $categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);
             foreach ($categories_2 as $category_2) {
                 $level_3_data = array();
                 $categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
                 foreach ($categories_3 as $category_3) {
                     $level_3_data[] = array('name' => $category_3['name_menu'] ? $category_3['name_menu'] : $category_3['name'], 'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id']));
                 }
                 $level_2_data[] = array('name' => $category_2['name_menu'] ? $category_2['name_menu'] : $category_2['name'], 'children' => $level_3_data, 'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id']));
             }
             $this->data['categories'][] = array('name' => $category_1['name_menu'] ? $category_1['name_menu'] : $category_1['name'], 'children' => $level_2_data, 'href' => $this->url->link('product/category', 'path=' . $category_1['category_id']));
         }
         $this->data['special'] = $this->url->link('product/special');
         $this->data['account'] = $this->url->link('account/account', '', 'SSL');
         $this->data['edit'] = $this->url->link('account/edit', '', 'SSL');
         $this->data['password'] = $this->url->link('account/password', '', 'SSL');
         $this->data['address'] = $this->url->link('account/address', '', 'SSL');
         $this->data['history'] = $this->url->link('account/order', '', 'SSL');
         $this->data['download'] = $this->url->link('account/download', '', 'SSL');
         $this->data['cart'] = $this->url->link('checkout/cart');
         $this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
         $this->data['search'] = $this->url->link('product/search');
         $this->data['contact'] = $this->url->link('information/contact');
         $this->load->model('catalog/information');
         $this->data['informations'] = array();
         foreach ($this->model_catalog_information->getInformations() as $result) {
             $this->data['informations'][] = array('title' => $result['title'], 'href' => $this->url->link('information/information', 'information_id=' . $result['information_id']));
         }
         $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this->template = 'default/template/error/not_found.tpl';
         }
         $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
         $this->response->setOutput($this->render());
     }
 }
 public function actionCommentCreate()
 {
     if (isset($_POST['commentJSON']) && isJSON($_POST['commentJSON'])) {
         $commentModel = new Comment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['commentJSON'], true);
         $commentModel->text = isset($commentCreatePost['text']) ? $commentCreatePost['text'] : Yii::t('comment', 'no comment text');
         $commentModel->create_time = date("Y-m-d H:i:s");
         $commentModel->contact_method = isset($commentCreatePost['contact_method']) ? $commentCreatePost['contact_method'] : null;
         $commentModel->service_attitude = isset($commentCreatePost['service_attitude']) ? $commentCreatePost['service_attitude'] : 5;
         $commentModel->delivery_speed = isset($commentCreatePost['delivery_speed']) ? $commentCreatePost['delivery_speed'] : 5;
         if (!Comment::model()->validateContactMethod($commentCreatePost['contact_method'])) {
             $errorMessage = Yii::t('comment', 'Contact method is too long!');
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['service_attitude'])) {
             $errorMessage = Yii::t('comment', 'Service mark is out of range!');
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['delivery_speed'])) {
             $errorMessage = Yii::t('comment', 'Delivery mark is out of range!');
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $siteMarkModel = SiteMark::model()->findByAttributes(array('id' => '1'));
             $siteMarkModel->service_attitude_sum = $siteMarkModel->service_attitude * $siteMarkModel->service_attitude_times + $commentModel->service_attitude;
             $siteMarkModel->delivery_speed_sum = $siteMarkModel->delivery_speed * $siteMarkModel->delivery_speed_times + $commentModel->delivery_speed;
             ++$siteMarkModel->service_attitude_times;
             ++$siteMarkModel->delivery_speed_times;
             $siteMarkModel->service_attitude = $siteMarkModel->service_attitude_sum / $siteMarkModel->service_attitude_times;
             $siteMarkModel->delivery_speed = $siteMarkModel->delivery_speed_sum / $siteMarkModel->delivery_speed_times;
             if ($siteMarkModel->save() && $commentModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $commentModel->create_time));
             } else {
                 $errorMessage = Yii::t('comment', 'Server error!');
                 $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }
function evolve_sanitize_typography($input)
{
    if (isJSON($input)) {
        $output = get_object_vars(json_decode($input));
    } else {
        $output = wp_parse_args($input, array('size' => '', 'face' => '', 'style' => '', 'color' => ''));
    }
    $output['size'] = apply_filters('evolve_font_size', $output['size']);
    $output['face'] = apply_filters('evolve_font_face', $output['face']);
    $output['style'] = apply_filters('evolve_font_style', $output['style']);
    $output['color'] = apply_filters('evolve_color', $output['color']);
    //var_dump($output);
    return $output;
}
if (!is_array($data["data"])) {
    echo out(array("success" => false, "message" => $data));
}
$obj = array();
$f_data = array();
function isJSON($string)
{
    return is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))) ? true : false;
}
foreach ($data["data"] as $row) {
    $row[0] = $row[0] - $_SESSION['time_offset'] * 60;
    $row[0] = date($date_format, $row[0]);
    // $date_format = "d.m.y H:i:s"; - data.php
    $row[4] = urldecode($row[4]);
    //добавлено, чтобы в 1с не декодировать
    if (isJSON($row[4])) {
        $row[4] = json_decode($row[4], true);
        $i = 0;
        foreach ($row[4] as $key => $value) {
            foreach ($value as $key => $val) {
                $t["item" . $i]["name"] = $key;
                $t["item" . $i]["value"] = $val;
                $i++;
            }
        }
        $row[4] = $t;
        $row[4] = translate($row[4], $_SESSION['lang'] ? $_SESSION['lang'] : 'ru');
    }
    $f_data[] = $row;
    $f_data = translate($f_data, $_SESSION['lang'] ? $_SESSION['lang'] : 'ru');
    //переводим на рус/англ
Beispiel #13
0
function piVarRaw($path)
{
    global $verbose;
    // Explode the dot-syntax into parts
    $varParts = explode(".", $path);
    // Reverse it so we can array_pop() to get
    //  and remove the variable part with one line.
    $varParts = array_reverse($varParts);
    if ($verbose) {
        var_dump($varParts);
    }
    // I'll come back to this...
    $firstPart = array_pop($varParts);
    $restored = restoreExternalized($firstPart);
    piLog($restored);
    $jsonString = isJSON($restored);
    if ($jsonString === false) {
        if ($restored === $firstPart) {
            return $path;
        }
        return $restored;
    }
    if ($verbose) {
        //var_dump($jsonString);
        //die();
    }
    // Decode the JSON string. The first one should be JSON...
    $varBase = $jsonString;
    //json_decode($jsonString, true);
    // Go through parts
    $currentVar = $varBase;
    while (count($varParts) > 0) {
        // Next variable name in dot-syntax
        $newVarName = array_pop($varParts);
        // Go ahead and get a restored version of the variable
        $externVarName = restoreExternalized($newVarName);
        if (isset($currentVar[$newVarName])) {
            // Current variable has the subobject
            $currentVar = $currentVar[$newVarName];
        } else {
            if (isset($currentVar[$externVarName])) {
                // Doesn't have the subobject.
                // Check if it has the restored name
                $currentVar = $currentVar[$externVarName];
            } else {
                if (isset($currentVar[intval($newVarName)])) {
                    // Current variable has the subobject
                    $currentVar = $currentVar[intval($newVarName)];
                } else {
                    if (isset($currentVar[intval($externVarName)])) {
                        // Doesn't have the subobject.
                        // Check if it has the restored name
                        $currentVar = $currentVar[intval($externVarName)];
                    } else {
                        // Welp that didn't exist... return what we got...
                        $jsonCheck = isJson($currentVar);
                        if ($jsonCheck !== false) {
                            $currentVar = json_encode($currentVar, JSON_PRETTY_PRINT);
                        }
                        array_push($varParts, $currentVar);
                        $varParts = array_reverse($varParts);
                        $currentVar = implode(".", $varParts);
                        break;
                    }
                }
            }
        }
        // Decode JSON sub-objects
        $jsonCheck = isJson($currentVar);
        if ($jsonCheck !== false) {
            $currentVar = $jsonCheck;
        }
    }
    // Array check
    if (is_array($currentVar)) {
        // Our last object was an array. Encode it
        $currentVar = trim(json_encode($currentVar, JSON_PRETTY_PRINT));
    }
    return $currentVar;
}
Beispiel #14
0
 public function actionCommentCreate()
 {
     if (isset($_POST['commentJSON']) && isJSON($_POST['commentJSON'])) {
         $commentModel = new Comment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['commentJSON'], true);
         $commentModel->text = $commentCreatePost['text'];
         $commentModel->create_time = date("Y-m-d H:i:s");
         $commentModel->contact_method = $commentCreatePost['contact_method'];
         $commentModel->service_attitude = $commentCreatePost['service_attitude'];
         $commentModel->delivery_speed = $commentCreatePost['delivery_speed'];
         if (!Comment::model()->validateContactMethod($commentCreatePost['contact_method'])) {
             $errorMessage = '联系方式太长';
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['service_attitude'])) {
             $errorMessage = '服务态度打分不在范围内';
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['delivery_speed'])) {
             $errorMessage = '发货速度打分不在范围内';
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $siteMarkModel = SiteMark::model()->findByAttributes(array('id' => '1'));
             $siteMarkModel->service_attitude_sum = $siteMarkModel->service_attitude * $siteMarkModel->service_attitude_times + $commentModel->service_attitude;
             $siteMarkModel->delivery_speed_sum = $siteMarkModel->delivery_speed * $siteMarkModel->delivery_speed_times + $commentModel->delivery_speed;
             ++$siteMarkModel->service_attitude_times;
             ++$siteMarkModel->delivery_speed_times;
             $siteMarkModel->service_attitude = $siteMarkModel->service_attitude_sum / $siteMarkModel->service_attitude_times;
             $siteMarkModel->delivery_speed = $siteMarkModel->delivery_speed_sum / $siteMarkModel->service_attitude_times;
             if ($siteMarkModel->save() && $commentModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $commentModel->create_time));
             } else {
                 $errorMessage = '服务器错误!';
                 $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }