public function process()
 {
     parent::process();
     $multipleAddressesFormated = array();
     $ordered_fields = array();
     $customer = new Customer((int) self::$cookie->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         die(Tools::displayError('Customer not found'));
     }
     // Retro Compatibility Theme < 1.4.1
     self::$smarty->assign('addresses', $customer->getAddresses((int) self::$cookie->id_lang));
     $customerAddressesDetailed = $customer->getAddresses((int) self::$cookie->id_lang);
     $total = 0;
     foreach ($customerAddressesDetailed as $addressDetailed) {
         $address = new Address($addressDetailed['id_address']);
         $multipleAddressesFormated[$total] = AddressFormat::getFormattedLayoutData($address);
         unset($address);
         ++$total;
         // Retro theme < 1.4.2
         $ordered_fields = AddressFormat::getOrderedAddressFields($addressDetailed['id_country'], false, true);
     }
     // Retro theme 1.4.2
     if ($key = array_search('Country:name', $ordered_fields)) {
         $ordered_fields[$key] = 'country';
     }
     self::$smarty->assign('addresses_style', array('company' => 'address_company', 'vat_number' => 'address_company', 'firstname' => 'address_name', 'lastname' => 'address_name', 'address1' => 'address_address1', 'address2' => 'address_address2', 'city' => 'address_city', 'country' => 'address_country', 'phone' => 'address_phone', 'phone_mobile' => 'address_phone_mobile', 'alias' => 'address_title'));
     self::$smarty->assign(array('multipleAddresses' => $multipleAddressesFormated, 'ordered_fields' => $ordered_fields));
     unset($customer);
 }
 public function process()
 {
     parent::process();
     $this->productSort();
     $nbProducts = Product::getPricesDrop((int) self::$cookie->id_lang, NULL, NULL, true);
     $this->pagination($nbProducts);
     self::$smarty->assign(array('products' => Product::getPricesDrop((int) self::$cookie->id_lang, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home')));
 }
 public function process()
 {
     parent::process();
     //echo "vao day";die;
     if (self::$cookie->RoleID == 1) {
         Tools::redirect('hotelpage.php?mid=' . self::$cookie->HotelID);
     }
     $continentCode = Tools::getUserContinentCode(self::$cookie->CompanyID);
     $search_form = array();
     $search_form['CityId'] = 0;
     $search_form['AreaId'] = 0;
     if ((self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) && self::$cookie->OldLoginUserName == NULL) {
         $search_form['CheckIn'] = date('Y-m-d', strtotime(date('Y-m-d') . " + 5 days"));
         $search_form['Nights'] = 1;
         $search_form['CheckOut'] = date('Y-m-d', strtotime($search_form['CheckIn'] . " + {$search_form['Nights']} days"));
     }
     $search_form['HotelClassId'] = 0;
     $search_form['HotelName'] = '';
     $search_form['ContinentCode'] = $continentCode;
     $roomtype_list = RoomPlan::getRoomTypeList();
     $roomtype_form_list = array();
     foreach ($roomtype_list as $roomtype) {
         $roomTypeId = $roomtype['RoomTypeId'];
         $roomtype_form_list[$roomTypeId] = 0;
     }
     $search_form['RoomTypeVals'] = $roomtype_form_list;
     self::$smarty->assign("roomTypeList", $roomtype_list);
     self::$smarty->assign("search_form", $search_form);
     self::$smarty->assign("classList", Tools::getAllHotelClasses());
     self::$smarty->assign("areaList", Tools::getJapanAreas());
     //get Hotel List and Promotion List
     $promotionList = Promotion::getHomePromotionList(Promotion::$TYPE_PROMOTION);
     self::$smarty->assign('homePromotionList', $promotionList);
     $eventList = Promotion::getHomePromotionList(Promotion::$TYPE_EVENT);
     self::$smarty->assign('homeEventList', $eventList);
     // Get Popular Hotel List
     $poList = HotelDetail::getPopularHotelList(3);
     // 東京・横浜 - 関東 areaid = 3
     $popularList = array();
     global $cookie;
     $iso = Language::getIsoById((int) $cookie->LanguageID);
     foreach ($poList as $popular) {
         $image = HotelDetail::getFirstFileOfHotel($popular['HotelId'], 150, 150);
         if (is_file(_TAS_ROOT_DIR_ . "/asset/" . $image['w5_path'])) {
             $popular['HotelFilePath'] = $image['w5_path'];
             $popular['w5'] = $image['w5'];
             $popular['h5'] = $image['h5'];
         }
         $popular['LowestPrice'] = HotelDetail::getLowestPriceOfHotel($popular['HotelId']);
         $popular['AreaName'] = HotelDetail::getAreaName($popular['HotelArea']);
         $HotelNameKey = 'HotelName_' . $iso;
         $popular['HotelName'] = $popular[$HotelNameKey];
         $popularList[] = $popular;
     }
     //self::$smarty->assign('homeAreaList', Db::getInstance()->ExecuteS("select *, AreaName_".$this->iso." as AreaName from HT_Area where AreaId in (3, 5, 8, 12)"));
     self::$smarty->assign('homeAreaList', Db::getInstance()->ExecuteS('select  *, AreaName_' . $this->iso . ' as AreaName from `HT_Area` where isPopular = 1'));
     self::$smarty->assign("popularList", $popularList);
 }
 public function process()
 {
     parent::process();
     if (Tools::isSubmit('SubmitForgotpassword')) {
         $email = Tools::getValue("email");
         if (!$email) {
             $this->errors[] = Tools::displayError('email is required');
         } else {
             $result = Member::checkReset($email);
             if ($result) {
                 $to = $email;
                 $headers = 'From: web@tas-agent.com' . "\r\n";
                 $headers .= 'MIME-Version: 1.0' . "\r\n";
                 $headers .= 'Content-Type: text/html; charset=utf-8' . "\r\n";
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . '/resetpassword.php?code=' . base64_encode($result['Password'] . '#_#' . $email);
                 if ($result['LanguageID'] == 1) {
                     $subject = 'TAS-Agent - Password reset';
                     $message = 'Dear ' . $result['Name'] . ":<br/><br/>";
                     $message .= 'Please click below to reset your password of TAS Agent as requested.' . "<br/>";
                     $message .= '<a href="' . $url . '">' . $url . "</a><br/>";
                     $message .= 'Thank you for using TAS-Agent' . "<br/><br/>";
                     $message .= 'TAS Agent Team';
                 } else {
                     if ($result['LanguageID'] == 2) {
                         $subject = 'TAS-Agent - 重置密码';
                         $message = '您好:' . $result['Name'] . "<br/><br/>";
                         $message .= '请点击如下链接重置您的TAS Agent账户信息。' . "<br/>";
                         $message .= '<a href="' . $url . '">' . $url . "</a><br/>";
                         $message .= '感谢您使用TAS-Agent' . "<br/><br/>";
                         $message .= 'TAS Agent 团队';
                     } else {
                         if ($result['LanguageID'] == 3) {
                             $subject = 'TAS-Agent - 重置密碼';
                             $message = '您好 ' . $result['Name'] . "<br/><br/>";
                             $message .= '請點擊如下鏈接重置您的TAS Agent帳戶信息。' . "<br/>";
                             $message .= '感謝您使用TAS-Agent' . "<br/><br/>";
                             $message .= 'TAS Agent 團隊';
                         } else {
                             $subject = 'TAS-Agent - パスワードリセット';
                             $message = $result['Name'] . " 様<br/><br/>";
                             $message .= '下記リンクをクリックしTAS Agentのパスワードを再設定してください。' . "<br/>";
                             $message .= '<a href="' . $url . '">' . $url . "</a><br/><br/>";
                             $message .= 'TAS-Agentのご利用ありがとうございます。' . "<br/><br/>";
                             $message .= 'TAS Agent Team';
                         }
                     }
                 }
                 Tools::sendEmail($to, $subject, $message);
                 //@mail($to, $subject, $message, $headers);
                 self::$smarty->assign("LanguageID", $result['LanguageID']);
                 $this->success = true;
             } else {
                 $this->errors[] = Tools::displayError('Your email address is not registered.');
             }
         }
     }
 }
 public function process()
 {
     parent::process();
     self::$smarty->assign(array('is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int) $this->id_order), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int) $this->id_order, (int) $this->id_module)));
     if (self::$cookie->is_guest) {
         self::$smarty->assign(array('id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order)));
         /* If guest we clear the cookie for security reason */
         self::$cookie->mylogout();
     }
 }
 public function process()
 {
     parent::process();
     if ($id_order = Tools::getValue('id_order') and $email = Tools::getValue('email')) {
         $order = new Order((int) $id_order);
         if (!Validate::isLoadedObject($order)) {
             $this->errors[] = Tools::displayError('Invalid order');
         } elseif (!$order->isAssociatedAtGuest($email)) {
             $this->errors[] = Tools::displayError('Invalid order');
         } else {
             $customer = new Customer((int) $order->id_customer);
             $id_order_state = (int) $order->getCurrentState();
             $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
             $addressInvoice = new Address((int) $order->id_address_invoice);
             $addressDelivery = new Address((int) $order->id_address_delivery);
             $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
             $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
             $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
             $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
             if ($order->total_discounts > 0) {
                 self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts));
             }
             $products = $order->getProducts();
             $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
             Product::addCustomizationPrice($products, $customizedDatas);
             $this->processAddressFormat($addressDelivery, $addressInvoice);
             self::$smarty->assign(array('shop_name' => Configuration::get('PS_SHOP_NAME'), 'order' => $order, 'return_allowed' => false, 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => true, 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'use_tax' => Configuration::get('PS_TAX'), 'customizedDatas' => $customizedDatas, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues));
             if ($carrier->url and $order->shipping_number) {
                 self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
             Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
             if (Tools::isSubmit('submitTransformGuestToCustomer')) {
                 $customer = new Customer((int) $order->id_customer);
                 if (!Validate::isLoadedObject($customer)) {
                     $this->errors[] = Tools::displayError('Invalid customer');
                 }
                 if (!$customer->transformToCustomer(self::$cookie->id_lang, Tools::getValue('password'))) {
                     $this->errors[] = Tools::displayError('An error occurred while transforming guest to customer.');
                 }
                 if (!Tools::getValue('password')) {
                     $this->errors[] = Tools::displayError('Invalid password');
                 } else {
                     self::$smarty->assign('transformSuccess', true);
                 }
             }
         }
         if (sizeof($this->errors)) {
             /* Handle brute force attacks */
             sleep(1);
         }
     }
     self::$smarty->assign(array('action' => 'guest-tracking.php', 'errors' => $this->errors));
 }
 public function process()
 {
     global $cookie;
     parent::process();
     $swhere = parent::getSearchWhere();
     $featureCount = HotelFeature::getFeatureCount($swhere);
     $this->pagination($featureCount);
     $hotelList = HotelFeature::getFeatureList($swhere, $this->p, $this->n);
     self::$smarty->assign("listData", $hotelList);
     self::$smarty->assign("featureList", $this->FeatureType);
 }
 public function process()
 {
     parent::process();
     //Clean compare product table
     CompareProduct::cleanCompareProducts('week');
     $hasProduct = false;
     if (!Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
         return Tools::redirect('404.php');
     }
     if ($product_list = Tools::getValue('compare_product_list') and $postProducts = isset($product_list) ? rtrim($product_list, '|') : '') {
         $ids = array_unique(explode('|', $postProducts));
     } elseif (isset(self::$cookie->id_customer)) {
         $ids = CompareProduct::getCustomerCompareProducts(self::$cookie->id_customer);
     } elseif (isset(self::$cookie->id_guest)) {
         $ids = CompareProduct::getGuestCompareProducts(self::$cookie->id_guest);
     } else {
         $ids = null;
     }
     if ($ids) {
         if (sizeof($ids) > 0) {
             if (sizeof($ids) > Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
                 $ids = array_slice($ids, 0, Configuration::get('PS_COMPARATOR_MAX_ITEM'));
             }
             $listProducts = array();
             $listFeatures = array();
             foreach ($ids as $id) {
                 $curProduct = new Product((int) $id, true, (int) self::$cookie->id_lang);
                 if (!Validate::isLoadedObject($curProduct)) {
                     continue;
                 }
                 if (!$curProduct->active) {
                     unset($ids[$k]);
                     continue;
                 }
                 foreach ($curProduct->getFrontFeatures(self::$cookie->id_lang) as $feature) {
                     $listFeatures[$curProduct->id][$feature['id_feature']] = $feature['value'];
                 }
                 $cover = Product::getCover((int) $id);
                 $curProduct->id_image = Tools::htmlentitiesUTF8(Product::defineProductImage(array('id_image' => $cover['id_image'], 'id_product' => $id), self::$cookie->id_lang));
                 $curProduct->allow_oosp = Product::isAvailableWhenOutOfStock($curProduct->out_of_stock);
                 $listProducts[] = $curProduct;
             }
             if (sizeof($listProducts) > 0) {
                 $width = 80 / sizeof($listProducts);
                 $hasProduct = true;
                 $ordered_features = Feature::getFeaturesForComparison($ids, self::$cookie->id_lang);
                 self::$smarty->assign(array('ordered_features' => $ordered_features, 'product_features' => $listFeatures, 'products' => $listProducts, 'link' => new Link(), 'width' => $width, 'homeSize' => Image::getSize('home')));
                 self::$smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids)));
             }
         }
     }
     self::$smarty->assign('hasProduct', $hasProduct);
 }
 public function process()
 {
     parent::process();
     $discounts = Discount::getCustomerDiscounts((int) self::$cookie->id_lang, (int) self::$cookie->id_customer, true, false);
     $nbDiscounts = 0;
     foreach ($discounts as $discount) {
         if ($discount['quantity_for_user']) {
             $nbDiscounts++;
         }
     }
     self::$smarty->assign(array('nbDiscounts' => (int) $nbDiscounts, 'discount' => $discounts));
 }
 public function process()
 {
     global $cookie;
     parent::process();
     $member = new Member();
     $member->getByLoginUserName($cookie->LoginUserName);
     $swhere = parent::getSearchWhere();
     $agentCount = $member->getAdminCount($swhere);
     $this->pagination($agentCount);
     $hotelList = $member->getAdminList($swhere, $this->p, $this->n);
     self::$smarty->assign("listData", $hotelList);
 }
 public function process()
 {
     parent::process();
     self::$smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0));
     self::$smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(_USER_ID_LANG_, 1, 1, 1));
     self::$smarty->assign('voucherAllowed', (int) Configuration::get('PS_VOUCHERS'));
     $blockmanufacturer = Module::getInstanceByName('blockmanufacturer');
     $blocksupplier = Module::getInstanceByName('blocksupplier');
     self::$smarty->assign('display_manufacturer_link', (int) $blockmanufacturer->id ? true : false);
     self::$smarty->assign('display_supplier_link', (int) $blocksupplier->id ? true : false);
     self::$smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS'));
     self::$smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP'));
 }
 public function process()
 {
     parent::process();
     if ($orders = Order::getCustomerOrders((int) self::$cookie->id_customer)) {
         foreach ($orders as &$order) {
             $myOrder = new Order((int) $order['id_order']);
             if (Validate::isLoadedObject($myOrder)) {
                 $order['virtual'] = $myOrder->isVirtual(false);
             }
         }
     }
     self::$smarty->assign(array('orders' => $orders, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'slowValidation' => Tools::isSubmit('slowvalidation')));
 }
 public function process()
 {
     parent::process();
     if (Tools::isSubmit('email')) {
         if (!($email = Tools::getValue('email')) or !Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } else {
             $customer = new Customer();
             $customer->getByemail($email);
             if (!Validate::isLoadedObject($customer)) {
                 $this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
             } else {
                 if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
                     $this->errors[] = Tools::displayError('You can regenerate your password only every') . ' ' . (int) $min_time . ' ' . Tools::displayError('minute(s)');
                 } else {
                     if (Mail::Send((int) self::$cookie->id_lang, 'password_query', Mail::l('Password query confirmation'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => self::$link->getPageLink('password.php', true) . '?token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                         self::$smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
                     } else {
                         $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
                     }
                 }
             }
         }
     } elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) {
         $email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer);
         if ($email) {
             $customer = new Customer();
             $customer->getByemail($email);
             if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
                 Tools::redirect('authentication.php?error_regen_pwd');
             } else {
                 $customer->passwd = Tools::encrypt($password = Tools::passwdGen((int) MIN_PASSWD_LENGTH));
                 $customer->last_passwd_gen = date('Y-m-d H:i:s', time());
                 if ($customer->update()) {
                     if (Mail::Send((int) self::$cookie->id_lang, 'password', Mail::l('Your password'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                         self::$smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
                     } else {
                         $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
                     }
                 } else {
                     $this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
                 }
             }
         } else {
             $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
         }
     } elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer'))) {
         $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
     }
 }
 public function process()
 {
     parent::process();
     self::$smarty->assign("code", Tools::getValue("code"));
     $code = Tools::getValue("code");
     $code = explode('#_#', base64_decode($code));
     if (time() > $code[0]) {
         $this->expired = true;
     }
     if (Tools::isSubmit('SubmitResetpassword')) {
         $password = Tools::getValue("password");
         $confirm = Tools::getValue("confirm");
         $code = Tools::getValue("code");
         if (!$password) {
             $this->errors[] = Tools::displayError('password is required');
         } else {
             if (!$confirm) {
                 $this->errors[] = Tools::displayError('confirm password is required');
             } else {
                 if (!$code) {
                     $this->errors[] = Tools::displayError('Invalid Access!!');
                 } else {
                     if ($password != $confirm) {
                         $this->errors[] = Tools::displayError('Password confirmation is not mismatch');
                     } else {
                         $code = explode('#_#', base64_decode($code));
                         if (time() > $code[0]) {
                             $this->errors[] = Tools::displayError('Check code has expired!');
                             $this->expired = true;
                         } else {
                             $result = Member::checkReset($code[1]);
                             if ($result) {
                                 if (Member::resetPassword($code[1], $password)) {
                                     self::$smarty->assign("LanguageID", $result['LanguageID']);
                                     $this->success = true;
                                 } else {
                                     $this->errors[] = Tools::displayError('Invalid Access!!');
                                 }
                             } else {
                                 $this->errors[] = Tools::displayError('Invalid check code!!');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function process()
 {
     parent::process();
     $customer = new Customer((int) self::$cookie->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         die(Tools::displayError('Customer not found'));
     }
     self::$smarty->assign('addresses', $customer->getAddresses((int) self::$cookie->id_lang));
     $values = array();
     $customer_address = $customer->getAddresses((int) self::$cookie->id_lang);
     foreach ($customer_address as $addr_item) {
         $ordered_fields = AddressFormat::getOrderedAddressFields($addr_item['id_country']);
     }
     self::$smarty->assign('addresses_style', array('company' => 'address_company', 'vat_number' => 'address_company', 'firstname' => 'address_name', 'lastname' => 'address_name', 'address1' => 'address_address1', 'address2' => 'address_address2', 'city' => 'address_city', 'country' => 'address_country', 'phone' => 'address_phone', 'phone_mobile' => 'address_phone_mobile', 'alias' => 'address_title'));
     self::$smarty->assign('ordered_fields', $ordered_fields);
 }
 public function process()
 {
     parent::process();
     if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) {
         $this->errors[] = Tools::displayError('Missing category ID');
     } else {
         if (!Validate::isLoadedObject($this->category)) {
             $this->errors[] = Tools::displayError('Category does not exist');
         } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) {
             $this->errors[] = Tools::displayError('You do not have access to this category.');
         } elseif (!$this->category->active) {
             self::$smarty->assign('category', $this->category);
         } else {
             $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite);
             /* Scenes  (could be externalised to another controler if you need them */
             self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false));
             /* Scenes images formats */
             if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) {
                 foreach ($sceneImageTypes as $sceneImageType) {
                     if ($sceneImageType['name'] == 'thumb_scene') {
                         $thumbSceneImageType = $sceneImageType;
                     } elseif ($sceneImageType['name'] == 'large_scene') {
                         $largeSceneImageType = $sceneImageType;
                     }
                 }
                 self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
                 self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
             }
             $this->category->description = nl2br2($this->category->description);
             $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang);
             self::$smarty->assign('category', $this->category);
             if (Db::getInstance()->numRows()) {
                 self::$smarty->assign('subcategories', $subCategories);
                 self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
             }
             if ($this->category->id != 1) {
                 $nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
                 $this->pagination((int) $nbProducts);
                 self::$smarty->assign('nb_products', (int) $nbProducts);
                 $cat_products = $this->category->getProducts((int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay);
             }
             self::$smarty->assign(array('products' => (isset($cat_products) and $cat_products) ? $cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home')));
         }
     }
     self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers()));
 }
 public function process()
 {
     global $cookie;
     parent::process();
     $roomtype_list = RoomPlan::getRoomTypeList();
     $roomtype_form_list = array();
     $search_form = array();
     // get contient code
     self::$cookie->UserID;
     $continentCode = Tools::getUserContinentCode(self::$cookie->CompanyID);
     if (Tools::isSubmit("search")) {
         $search_form = Tools::element_copy($_REQUEST, 'CityId', 'AreaId', 'CheckIn', 'CheckOut', 'Nights', 'HotelClassId', 'HotelName', 'SortBy', 'SortOrder');
         if (self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3) {
             $search_form['ContinentCode'] = $continentCode;
             $search_form['HideRQ'] = @$_REQUEST['HideRQ'];
             $search_form['Role'] = 'Agent';
         }
         foreach ($roomtype_list as $roomtype) {
             $roomTypeId = $roomtype['RoomTypeId'];
             $roomtype_form_list[$roomTypeId] = $_REQUEST['RoomType_' . $roomTypeId];
         }
         $search_form['RoomTypeVals'] = $roomtype_form_list;
         if (self::$cookie->RoleID == 2 || self::$cookie->RoleID == 3 || $search_form['CheckIn'] && $search_form['CheckOut']) {
             $search_form['Role'] = 'Agent';
             $hotel_roomplan_count = RoomPlan::searchHotelRoomPlanCount($search_form);
             parent::pagination($hotel_roomplan_count);
             $hotel_roomplan_list = RoomPlan::searchHotelRoomPlan($search_form, $this->p, $this->n);
         } else {
             $hotel_roomplan_count = HotelDetail::getHotelByAreaCityCount($search_form);
             parent::pagination($hotel_roomplan_count);
             $hotel_roomplan_list = HotelDetail::getHotelByAreaCity($search_form, $this->p, $this->n);
         }
     } else {
         // redirect
         Tools::redirect('index.php');
     }
     self::$smarty->assign("hotel_roomplan_list", $hotel_roomplan_list);
     self::$smarty->assign("hotel_roomplan_count", $hotel_roomplan_count);
     self::$smarty->assign("search_form", $search_form);
     self::$smarty->assign("search_city_name", Tools::getCityName($search_form['CityId']));
     self::$smarty->assign("search_area_name", Tools::getAreaName($search_form['AreaId']));
     self::$smarty->assign("roomTypeList", $roomtype_list);
     self::$smarty->assign("classList", Tools::getAllHotelClasses());
     self::$smarty->assign("areaList", Tools::getJapanAreas());
 }
 public function process()
 {
     global $cookie;
     parent::process();
     $member = new Member();
     $member->getByLoginUserName($cookie->LoginUserName);
     $swhere = parent::getSearchWhere();
     if ($member->RoleID < 4) {
         if ($swhere != "") {
             $swhere .= " AND ";
         }
         $swhere = "A.CompanyID = " . $member->CompanyID;
     }
     $agentCount = $member->getAgentCount($swhere);
     $this->pagination($agentCount);
     $hotelList = $member->getAgentList($swhere, $this->p, $this->n);
     self::$smarty->assign("listData", $hotelList);
 }
 public function process()
 {
     global $cookie;
     parent::process();
     $iso = Language::getIsoById((int) $cookie->LanguageID);
     $member = new Member();
     $member->getByLoginUserName($cookie->LoginUserName);
     $swhere = parent::getSearchWhere();
     if ($swhere == "") {
         $swhere .= " 1 = 1 ";
     }
     if (Tools::getValue("HotelName") != "") {
         $swhere .= " AND HotelName_" . $iso . " like '%" . Tools::getValue("HotelName") . "%'";
     }
     $hotelCount = $member->getHotelCount($swhere);
     $this->pagination($hotelCount);
     $hotelList = $member->getHotelList($swhere, $this->p, $this->n);
     self::$smarty->assign("listData", $hotelList);
 }
 public function process()
 {
     parent::process();
     global $cookie;
     self::$smarty->assign("email", $cookie->Email);
     if (Tools::isSubmit('SubmitUpdatepassword')) {
         $password = Tools::getValue("password");
         $confirm = Tools::getValue("confirm");
         $npassword = Tools::getValue("npassword");
         $email = Tools::getValue("email");
         if (!$password) {
             $this->errors[] = Tools::displayError('password is required');
         } else {
             if (!$email) {
                 $this->errors[] = Tools::displayError('email is required!!');
             } else {
                 if (!$confirm) {
                     $this->errors[] = Tools::displayError('confirm password is required');
                 } else {
                     if (!$npassword) {
                         $this->errors[] = Tools::displayError('new password is required!!');
                     } else {
                         if ($npassword != $confirm) {
                             $this->errors[] = Tools::displayError('Password confirmation is not mismatch');
                         } else {
                             $result = Member::checkReset($email, $password);
                             if ($result) {
                                 if (Member::resetPassword($email, $npassword)) {
                                     self::$smarty->assign("LanguageID", $result['LanguageID']);
                                     self::$smarty->assign("message", "Updated!");
                                 } else {
                                     $this->errors[] = Tools::displayError('Invalid Operation!');
                                 }
                             } else {
                                 $this->errors[] = Tools::displayError('Invalid Operation!');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #21
0
 public function process()
 {
     if (!$this->klarna->active) {
         return;
     }
     parent::process();
     if (Tools::isSubmit('klarna_pno') || Tools::isSubmit('klarna_pno_day') && Tools::isSubmit('klarna_pno_month') && Tools::isSubmit('klarna_pno_year')) {
         $address_invoice = new Address((int) self::$cart->id_address_invoice);
         $country = new Country((int) $address_invoice->id_country);
         if ($country->iso_code == 'DE' && !isset($_POST['klarna_de_accept'])) {
             $result['error'] = true;
             $result['message'] = 'Please agree your consent';
         } else {
             $result = $this->klarna->setPayment(Tools::safeOutput(Tools::getValue('type')));
         }
         if (isset($result['error'])) {
             self::$smarty->assign('error', $result['message']);
         }
     }
     self::$smarty->assign(array('nbProducts' => self::$cart->nbProducts(), 'total' => self::$cart->getOrderTotal(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/klarnaprestashop/'));
 }
Example #22
0
 public function process()
 {
     parent::process();
     $params = $this->initParams();
     $call = new Call();
     try {
         $result = $call->createTransaction($params);
     } catch (Exception $e) {
         //d($e);
     }
     if (isset($result->CreateTransactionResult) && isset($result->CreateTransactionResult->TransportKey) && $result->CreateTransactionResult->TransportKey != '') {
         self::$smarty->assign('formLink', $this->_paymentLink[Configuration::get('MERCHANT_WARE_MODE')]);
         self::$smarty->assign('transportKey', Tools::safeOutput($result->CreateTransactionResult->TransportKey));
     } elseif (isset($result->CreateTransactionResult)) {
         Logger::addLog('Module merchantware: ' . $result->CreateTransactionResult->Messages->Message[0]->Information, 2);
         self::$smarty->assign('error', true);
     } else {
         self::$smarty->assign('error', true);
         Logger::addLog('Module merchantware: no message returned', 2);
     }
 }
 public function process()
 {
     //... edit window
     if (trim(Tools::getValue('ajaxType')) == "edit") {
         $msgId = trim(Tools::getValue('msgId'));
         // get Writer User ID from MSG
         $sql = "SELECT UserId from " . _DB_PREFIX_ . "Message where MsgId = {$msgId}";
         $writerId = Db::getInstance()->getValue($sql);
         if (self::$cookie->UserID != $writerId) {
             $sql = "update " . _DB_PREFIX_ . "Message set  isRead = 1 where MsgId = {$msgId}";
             Db::getInstance()->Execute($sql);
         }
         $sql = "SELECT m.*, u.LoginUserName, u.RoleID, r.RoleName FROM " . _DB_PREFIX_ . "MessageCont AS m, " . _DB_PREFIX_ . "User AS u, " . _DB_PREFIX_ . "Role r \n\t\t\t\t\t\tWHERE m.MsgId={$msgId} AND  m.UserId=u.UserID AND u.RoleId=r.RoleId  ORDER BY m.regDate DESC ";
         self::$smarty->assign("list", Db::getInstance()->ExecuteS($sql));
         $sql = "SELECT m.Title FROM HT_Message AS m WHERE m.MsgId={$msgId} ";
         self::$smarty->assign("info", Db::getInstance()->getRow($sql));
         return;
     }
     //... main window
     parent::process();
     $schKey = trim(Tools::getValue('schKey'));
     $where = " m.UserId=u.UserID AND u.RoleId=r.RoleId ";
     if ($schKey != "") {
         $where .= " AND CONCAT(m.Title,'-|-',u.LoginUserName,'-|-',u.Name) LIKE '%{$schKey}%' ";
     }
     if (self::$cookie->RoleID == 3) {
         //... agent admin
         $where .= " AND m.CompanyId=" . self::$cookie->CompanyID;
     } else {
         if (self::$cookie->RoleID < 3) {
             //.... agent user or hotel
             $where .= " AND m.UserId=" . self::$cookie->UserID;
         }
     }
     $subsql = " FROM " . _DB_PREFIX_ . "Message AS m, " . _DB_PREFIX_ . "User AS u, " . _DB_PREFIX_ . "Role r WHERE {$where}  ";
     $sql = "SELECT COUNT(*) " . $subsql;
     $this->pagination((int) Db::getInstance()->getValue($sql));
     $sql = "SELECT m.*, u.LoginUserName, u.Name, r.RoleName {$subsql} ORDER BY lastDate DESC " . ($this->p ? ' LIMIT ' . ((int) $this->p - 1) * (int) $this->n . ',' . (int) $this->n : '');
     self::$smarty->assign("list", Db::getInstance()->ExecuteS($sql));
 }
 public function process()
 {
     parent::process();
     if (Tools::isSubmit('SubmitContact')) {
         $name = Tools::getValue("name");
         $email = Tools::getValue("email");
         $tel = Tools::getValue("tel");
         $content = Tools::getValue("content");
         if (!$name) {
             $this->errors[] = Tools::displayError('name is required');
         } else {
             if (!$email) {
                 $this->errors[] = Tools::displayError('email is required');
             } else {
                 if (!$tel) {
                     $this->errors[] = Tools::displayError('telephone is required');
                 } else {
                     if (!$content) {
                         $this->errors[] = Tools::displayError('content is required');
                     } else {
                         $to = '*****@*****.**';
                         $subject = 'Message from ' . $name . ' via TAS AGENT Contact';
                         $message = 'Name: ' . $name . "\n";
                         $message .= 'E-mail: ' . $email . "\n";
                         $message .= 'TEL: ' . $tel . "\n";
                         $message .= 'Message: ' . $content . "\n";
                         //$headers = 'From: contact@tas-agent.com' . "\r\n";
                         Tools::sendEmail($to, $subject, $message);
                         //@mail($to, $subject, $message, $headers);
                         $this->success = true;
                     }
                 }
             }
         }
     }
 }
 public function process()
 {
     global $link;
     parent::process();
     self::$smarty->assign(array('defaultLat' => (double) Configuration::get('PS_STORES_CENTER_LAT'), 'defaultLong' => (double) Configuration::get('PS_STORES_CENTER_LONG'), 'searchUrl' => $link->getPageLink('stores.php')));
 }
 public function process()
 {
     parent::process();
     $back = Tools::getValue('back');
     $key = Tools::safeOutput(Tools::getValue('key'));
     if (!empty($key)) {
         $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key;
     }
     if (!empty($back)) {
         self::$smarty->assign('back', Tools::safeOutput($back));
         if (strpos($back, 'order.php') !== false) {
             if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
                 $countries = Carrier::getDeliveredCountries((int) self::$cookie->id_lang, true, true);
             } else {
                 $countries = Country::getCountries((int) self::$cookie->id_lang, true);
             }
             self::$smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'sl_country' => (int) Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')), 'countries' => $countries));
         }
     }
 }
 public function process()
 {
     parent::process();
     if (Tools::isSubmit('SubmitPassword')) {
         $new_pass = Tools::getValue('new_password');
         $retype_pass = Tools::getValue('retype_password');
         if (strcmp($new_pass, $retype_pass)) {
             $errors[] = Tools::displayError("Password fields don't match. Please retype.");
         } else {
             $email = Tools::getValue('email');
             $customer = new Customer();
             $customer->getByemail($email);
             if (!Validate::isLoadedObject($customer)) {
                 $errors[] = Tools::displayError('Could not retrieve the account information.');
             } else {
                 $customer->passwd = Tools::encrypt($new_pass);
                 $customer->reset_token = NULL;
                 $customer->reset_time = NULL;
                 if ($customer->update()) {
                     self::$cart->secure_key = $customer->secure_key;
                     self::$cookie->id_customer = (int) $customer->id;
                     self::$cookie->customer_lastname = $customer->lastname;
                     self::$cookie->customer_firstname = $customer->firstname;
                     self::$cookie->passwd = $customer->passwd;
                     self::$cookie->logged = 1;
                     self::$cookie->email = $customer->email;
                     if (Configuration::get('PS_CART_FOLLOWING') and (empty(self::$cookie->id_cart) or Cart::getNbProducts(self::$cookie->id_cart) == 0)) {
                         self::$cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id);
                     }
                     self::$cart->update();
                     Tools::redirect('index.php');
                 } else {
                     $errors[] = Tools::displayError('error resetting the password');
                 }
             }
         }
     } else {
         if (Tools::isSubmit('email')) {
             if (!($email = Tools::getValue('email')) or !Validate::isEmail($email)) {
                 $this->errors[] = Tools::displayError('Invalid e-mail address');
             } else {
                 $customer = new Customer();
                 $customer->getByemail($email);
                 if (!Validate::isLoadedObject($customer)) {
                     $this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
                 } else {
                     if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
                         $this->errors[] = Tools::displayError('You can regenerate your password only every') . ' ' . (int) $min_time . ' ' . Tools::displayError('minute(s)');
                     } else {
                         if (Mail::Send((int) self::$cookie->id_lang, 'password_query', Mail::l('Your password reset request at IndusDiva.com'), array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => self::$link->getPageLink('password.php', true) . '?token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                             self::$smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
                         } else {
                             $this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
                         }
                     }
                 }
             }
         } elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) {
             $email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = "' . pSQL($token) . '" AND c.id_customer=' . (int) $id_customer);
             if ($email) {
                 $customer = new Customer();
                 $customer->getByemail($email);
                 if (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
                     Tools::redirect('authentication.php?error_regen_pwd');
                 } else {
                     self::$smarty->assign(array('password_reset' => 1, 'email' => $customer->email));
                     /*
                     $customer->passwd = Tools::encrypt($password = Tools::passwdGen((int)(MIN_PASSWD_LENGTH)));
                     $customer->last_passwd_gen = date('Y-m-d H:i:s', time());
                     if ($customer->update())
                     {
                     	if (Mail::Send((int)(self::$cookie->id_lang), 'password', Mail::l('Your password'), 
                     	array('{email}' => $customer->email, 
                     		  '{lastname}' => $customer->lastname, 
                     		  '{firstname}' => $customer->firstname, 
                     		  '{passwd}' => $password), 
                     	$customer->email, 
                     	$customer->firstname.' '.$customer->lastname)) 
                     		self::$smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
                     	else
                     		$this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
                     }
                     else
                     	$this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
                     */
                 }
             } else {
                 $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
             }
         } elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer'))) {
             $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
         }
     }
 }
 public function process()
 {
     global $cart, $currency;
     parent::process();
     if (!($id_product = (int) Tools::getValue('id_product')) or !Validate::isUnsignedId($id_product)) {
         $this->errors[] = Tools::displayError('Product not found');
     } else {
         if (!Validate::isLoadedObject($this->product) or !$this->product->active and Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct' . $this->product->id) || !file_exists(dirname(__FILE__) . '/../' . Tools::getValue('ad') . '/ajax.php')) {
             header('HTTP/1.1 404 page not found');
             $this->errors[] = Tools::displayError('Product is no longer available.');
         } elseif (!$this->product->checkAccess((int) self::$cookie->id_customer)) {
             $this->errors[] = Tools::displayError('You do not have access to this product.');
         } else {
             self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
             if (!$this->product->active) {
                 self::$smarty->assign('adminActionDisplay', true);
             }
             /* rewrited url set */
             $rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite);
             /* Product pictures management */
             require_once 'images.inc.php';
             self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
             if (Tools::isSubmit('submitCustomizedDatas')) {
                 $this->pictureUpload($this->product, $cart);
                 $this->textRecord($this->product, $cart);
                 $this->formTargetFormat();
             } elseif (isset($_GET['deletePicture']) and !$cart->deletePictureToProduct((int) $this->product->id, (int) Tools::getValue('deletePicture'))) {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
             }
             $files = self::$cookie->getFamily('pictures_' . (int) $this->product->id);
             $textFields = self::$cookie->getFamily('textFields_' . (int) $this->product->id);
             foreach ($textFields as $key => $textField) {
                 $textFields[$key] = str_replace('<br />', "\n", $textField);
             }
             self::$smarty->assign(array('pictures' => $files, 'textFields' => $textFields));
             if ((int) Tools::getValue('pp') == 1) {
                 echo 'here1';
             }
             $productPriceWithTax = Product::getPriceStatic($id_product, true, NULL, 6);
             if (Product::$_taxCalculationMethod == PS_TAX_INC) {
                 $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time2 = time();
                 echo 'time2: ' . $time2;
             }
             $productPriceWithoutEcoTax = (double) ($productPriceWithTax - $this->product->ecotax);
             $configs = Configuration::getMultiple(array('PS_ORDER_OUT_OF_STOCK', 'PS_LAST_QTIES'));
             /* Features / Values */
             $features = $this->product->getFrontFeatures((int) self::$cookie->id_lang);
             $attachments = $this->product->getAttachments((int) self::$cookie->id_lang);
             /* Category */
             $category = false;
             if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) {
                 if (isset($regs[2]) and is_numeric($regs[2])) {
                     if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[2])))) {
                         $category = new Category((int) $regs[2], (int) self::$cookie->id_lang);
                     }
                 } elseif (isset($regs[5]) and is_numeric($regs[5])) {
                     if (Product::idIsOnCategoryId((int) $this->product->id, array('0' => array('id_category' => (int) $regs[5])))) {
                         $category = new Category((int) $regs[5], (int) self::$cookie->id_lang);
                     }
                 }
             }
             if (!$category) {
                 $category = new Category($this->product->id_category_default, (int) self::$cookie->id_lang);
             }
             if (isset($category) and Validate::isLoadedObject($category)) {
                 self::$smarty->assign(array('path' => Tools::getPath((int) $category->id, $this->product->name, true), 'category' => $category, 'subCategories' => $category->getSubCategories((int) self::$cookie->id_lang, true), 'id_category_current' => (int) $category->id, 'id_category_parent' => (int) $category->id_parent, 'return_category_name' => Tools::safeOutput($category->name)));
             } else {
                 self::$smarty->assign('path', Tools::getPath((int) $this->product->id_category_default, $this->product->name));
             }
             self::$smarty->assign('return_link', (isset($category->id) and $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();');
             $lang = Configuration::get('PS_LANG_DEFAULT');
             if (Pack::isPack((int) $this->product->id, (int) $lang) and !Pack::isInStock((int) $this->product->id, (int) $lang)) {
                 $this->product->quantity = 0;
             }
             $group_reduction = (100 - Group::getReduction((int) self::$cookie->id_customer)) / 100;
             $id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0;
             $id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
             $id_country = (int) ($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
             if ((int) Tools::getValue('pp') == 1) {
                 $time3 = time();
                 echo 'time3: ' . $time3;
             }
             // Tax
             $tax = (double) Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             self::$smarty->assign('tax_rate', $tax);
             $ecotax_rate = (double) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
             $ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
             if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
                 $ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
             }
             $manufacturer = new Manufacturer((int) $this->product->id_manufacturer, 1);
             $sizechart = new Sizechart((int) $this->product->id_sizechart, 1);
             //see if the product is already in the wishlist
             if ($id_customer) {
                 $sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $this->product->id;
                 $res = Db::getInstance()->ExecuteS($sql);
                 if ($res) {
                     self::$smarty->assign("in_wishlist", true);
                 } else {
                     self::$smarty->assign("in_wishlist", false);
                 }
             } else {
                 self::$smarty->assign("in_wishlist", false);
             }
             self::$smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int) $this->product->id, (int) Shop::getCurrentShop(), (int) self::$cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (double) $tax), 'product' => $this->product, 'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'homeSize' => Image::getSize('home'), 'product_manufacturer' => $manufacturer, 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => (double) $productPriceWithoutEcoTax, 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) $configs['PS_LAST_QTIES'], 'group_reduction' => $group_reduction, 'col_img_dir' => _PS_COL_IMG_DIR_, 'sizechart' => $sizechart->sizechart, 'sizechart_data' => $sizechart->sizechart_data));
             self::$smarty->assign(array('HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
             if ((int) Tools::getValue('pp') == 1) {
                 $time4 = time();
                 echo 'time4: ' . $time4;
             }
             $images = $this->product->getImages((int) self::$cookie->id_lang);
             $productImages = array();
             foreach ($images as $k => $image) {
                 if ($image['cover']) {
                     self::$smarty->assign('mainImage', $images[0]);
                     $cover = $image;
                     $cover['id_image'] = Configuration::get('PS_LEGACY_IMAGES') ? $this->product->id . '-' . $image['id_image'] : $image['id_image'];
                     $cover['id_image_only'] = (int) $image['id_image'];
                 }
                 $productImages[(int) $image['id_image']] = $image;
             }
             if (!isset($cover)) {
                 $cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture');
             }
             $size = Image::getSize('large');
             self::$smarty->assign(array('cover' => $cover, 'imgWidth' => (int) $size['width'], 'mediumSize' => Image::getSize('medium'), 'largeSize' => Image::getSize('large'), 'accessories' => $this->product->getAccessories((int) self::$cookie->id_lang)));
             if (sizeof($productImages)) {
                 self::$smarty->assign('images', $productImages);
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time5 = time();
                 echo 'time5: ' . $time5;
             }
             /* Attributes / Groups & colors */
             $colors = array();
             //see if the product has shades
             if ($this->product->id_group && $this->product->id_group > 0) {
                 global $link;
                 $related_productIds = $this->product->getRelatedProducts();
                 $related_products = array();
                 foreach ($related_productIds as &$productId) {
                     $relProduct = new Product((int) $productId['id_product'], true, self::$cookie->id_lang);
                     $idImage = $relProduct->getCoverWs();
                     if ($idImage) {
                         $idImage = $relProduct->id . '-' . $idImage;
                     } else {
                         $idImage = Language::getIsoById(1) . '-default';
                     }
                     $relProduct->image_link = $link->getImageLink($relProduct->link_rewrite, $idImage, 'small');
                     $relProduct->link = $relProduct->getLink();
                     $related_products[] = $relProduct;
                 }
                 self::$smarty->assign('relatedProducts', $related_products);
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time6 = time();
                 echo 'time6: ' . $time6;
             }
             $attributesGroups = $this->product->getAttributesGroups((int) self::$cookie->id_lang);
             // @todo (RM) should only get groups and not all declination ?
             if (is_array($attributesGroups) and $attributesGroups) {
                 $groups = array();
                 $combinationImages = $this->product->getCombinationImages((int) self::$cookie->id_lang);
                 foreach ($attributesGroups as $k => $row) {
                     /* Color management */
                     if ((isset($row['attribute_color']) and $row['attribute_color'] or file_exists(_PS_COL_IMG_DIR_ . $row['id_attribute'] . '.jpg')) and $row['id_attribute_group'] == $this->product->id_color_default) {
                         $colors[$row['id_attribute']]['value'] = $row['attribute_color'];
                         $colors[$row['id_attribute']]['name'] = $row['attribute_name'];
                         if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) {
                             $colors[$row['id_attribute']]['attributes_quantity'] = 0;
                         }
                         $colors[$row['id_attribute']]['attributes_quantity'] += (int) $row['quantity'];
                     }
                     if (!isset($groups[$row['id_attribute_group']])) {
                         $groups[$row['id_attribute_group']] = array('name' => $row['public_group_name'], 'is_color_group' => $row['is_color_group'], 'default' => -1);
                     }
                     $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
                     if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) {
                         $groups[$row['id_attribute_group']]['default'] = (int) $row['id_attribute'];
                     }
                     if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) {
                         $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
                     }
                     $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int) $row['quantity'];
                     $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
                     $combinations[$row['id_product_attribute']]['attributes'][] = (int) $row['id_attribute'];
                     $combinations[$row['id_product_attribute']]['price'] = (double) $row['price'];
                     $combinations[$row['id_product_attribute']]['ecotax'] = (double) $row['ecotax'];
                     $combinations[$row['id_product_attribute']]['weight'] = (double) $row['weight'];
                     $combinations[$row['id_product_attribute']]['quantity'] = (int) $row['quantity'];
                     $combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
                     $combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
                     $combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
                     $combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1;
                 }
                 if ((int) Tools::getValue('pp') == 1) {
                     $time7 = time();
                     echo 'time7: ' . $time7;
                 }
                 //wash attributes list (if some attributes are unavailables and if allowed to wash it)
                 if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) {
                     foreach ($groups as &$group) {
                         foreach ($group['attributes_quantity'] as $key => &$quantity) {
                             if (!$quantity) {
                                 unset($group['attributes'][$key]);
                             }
                         }
                     }
                     foreach ($colors as $key => $color) {
                         if (!$color['attributes_quantity']) {
                             unset($colors[$key]);
                         }
                     }
                 }
                 if ((int) Tools::getValue('pp') == 1) {
                     $time71 = time();
                     echo 'time71: ' . $time71;
                 }
                 foreach ($groups as &$group) {
                     natcasesort($group['attributes']);
                 }
                 foreach ($combinations as $id_product_attribute => $comb) {
                     $attributeList = '';
                     foreach ($comb['attributes'] as $id_attribute) {
                         $attributeList .= '\'' . (int) $id_attribute . '\',';
                     }
                     $attributeList = rtrim($attributeList, ',');
                     $combinations[$id_product_attribute]['list'] = $attributeList;
                 }
                 self::$smarty->assign(array('groups' => $groups, 'combinaisons' => $combinations, 'combinations' => $combinations, 'colors' => (sizeof($colors) and $this->product->id_color_default) ? $colors : false, 'combinationImages' => $combinationImages));
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time72 = time();
                 echo 'time72: ' . $time72;
             }
             //$newProducts = Product::getNewProducts((int)(self::$cookie->id_lang), 0, 10, false, 'date_add', 'desc');
             /*$categoryProducts = $this->getRandomCatProducts();
               self::$smarty->assign('cat_products', $categoryProducts);*/
             //$brandProducts = $this->getRandomBrandProducts();
             //self::$smarty->assign('brand_products', $brandProducts);
             if ((int) Tools::getValue('pp') == 1) {
                 $time73 = time();
                 echo ' time73: ' . $time73;
             }
             self::$smarty->assign(array('no_tax' => Tax::excludeTaxeOption() or !Tax::getProductTaxRate((int) $this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int) self::$cookie->id_lang)));
             if ((int) Tools::getValue('pp') == 1) {
                 $time74 = time();
                 echo 'time74: ' . $time74;
             }
             // Pack management
             self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int) self::$cookie->id_lang, true) : array());
             self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int) self::$cookie->id_lang, true, 1));
             if ((int) Tools::getValue('pp') == 1) {
                 print_r('pack done');
             }
         }
     }
     if ((int) Tools::getValue('pp') == 1) {
         $time8 = time();
         echo 'time8: ' . $time8;
     }
     if ($this->is_saree || $this->is_lehenga) {
         if ($this->is_lehenga) {
             self::$smarty->assign('is_lehenga', $this->is_lehenga);
         }
         self::$smarty->assign('as_shown', (bool) $this->product->as_shown);
         /*if($blouse_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 1))
               self::$smarty->assign('measurement_info', $blouse_measurements);
           if($skirt_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 2))
               self::$smarty->assign('skirt_measurement_info', $skirt_measurements);*/
         if ((int) Tools::getValue('pp') == 1) {
             $time81 = time();
             echo 'time81: ' . $time81;
         }
         if ($this->is_saree) {
             //count of all styles mapped to this product
             $res = Db::getInstance()->getRow("select count(s.id_style) as style_count from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1");
             $style_count = (int) $res['style_count'];
             if ($style_count === 0) {
                 // show the default style for sarees
                 $style = array('id_style' => 1, 'style_image_small' => '1-small.png', 'style_name' => 'Round');
             } else {
                 $res = Db::getInstance()->getRow("select s.id_style, s.style_name, s.style_image_small  from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and s.style_type = 1 and ps.is_default = 1");
                 if (!empty($res)) {
                     //show the default style for this product
                     $style = array('id_style' => $res['id_style'], 'style_image_small' => $res['style_image_small'], 'style_name' => $res['style_name']);
                 }
             }
             if ((int) Tools::getValue('pp') == 1) {
                 $time82 = time();
                 echo 'time82: ' . $time82;
             }
             self::$smarty->assign('blouse_style_count', $style_count);
             self::$smarty->assign('blouse_style', $style);
         }
     } else {
         if ($this->is_skd || $this->is_skd_rts) {
             self::$smarty->assign('is_anarkali', $this->is_anarkali);
             if ($this->is_anarkali) {
                 if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 5)) {
                     self::$smarty->assign('kurta_measurement_info', $kurta_measurements);
                 }
             } else {
                 if ($kurta_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 3)) {
                     self::$smarty->assign('kurta_measurement_info', $kurta_measurements);
                 }
             }
             if ($salwar_measurements = $this->getCustomerMeasurements(self::$cookie->id_customer, 4)) {
                 self::$smarty->assign('salwar_measurement_info', $salwar_measurements);
             }
             //get default styles for this product (RTS)
             if ($this->is_skd_rts) {
                 $res = Db::getInstance()->ExecuteS("select count(s.id_style) as style_count, s.style_type, ps.id_product from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} group by ps.id_product,s.style_type");
                 foreach ($res as $s) {
                     $style_count = (int) $s['style_count'];
                     if ((int) $s['style_type'] === 4) {
                         self::$smarty->assign('kurta_style_count', $style_count);
                     } else {
                         if ((int) $s['style_type'] === 5) {
                             self::$smarty->assign('salwar_style_count', $style_count);
                         }
                     }
                 }
                 $res = Db::getInstance()->ExecuteS("select s.id_style, s.style_type, s.style_image_small, s.style_name from ps_styles s inner join ps_product_style ps on ps.id_style = s.id_style and ps.id_product = {$id_product} and ps.is_default = 1");
                 foreach ($res as $s) {
                     $style = array('id_style' => $s['id_style'], 'style_image_small' => $s['style_image_small'], 'style_name' => $s['style_name']);
                     if ((int) $s['style_type'] === 4) {
                         self::$smarty->assign('kurta_style', $style);
                     } else {
                         if ((int) $s['style_type'] === 5) {
                             self::$smarty->assign('salwar_style', $style);
                         }
                     }
                 }
             }
         }
     }
     self::$smarty->assign('is_bottoms', $this->is_bottoms);
     self::$smarty->assign('is_abaya', $this->is_abaya);
     self::$smarty->assign('is_wristwear', $this->is_wristwear);
     self::$smarty->assign('is_pakistani_rts', $this->is_pakistani_rts);
     if ((int) Tools::getValue('pp') == 1) {
         $time85 = time();
         echo 'time85: ' . $time85;
     }
     self::$smarty->assign(array('ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'categories' => Category::getHomeCategories((int) self::$cookie->id_lang), 'have_image' => Product::getCover((int) Tools::getValue('id_product')), 'tax_enabled' => Configuration::get('PS_TAX'), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'ecotax' => !sizeof($this->errors) and $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'currencySign' => $currency->sign, 'currencyRate' => $currency->conversion_rate, 'currencyFormat' => $currency->format, 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')));
     if ((int) Tools::getValue('pp') == 1) {
         $time9 = time();
         echo 'time9: ' . $time9;
     }
     //add this to product stats
     //Tools::captureActivity(PSTAT_VIEWS,$id_product);
     if ((int) Tools::getValue('pp') == 1) {
         $time1 = time();
         echo 'process end: ' . $time1;
     }
 }
 public function process()
 {
     parent::process();
     self::$smarty->assign(array('voucherAllowed' => (int) Configuration::get('PS_VOUCHERS'), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN')));
     self::$smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount'));
 }
 public function displayContent()
 {
     parent::displayContent();
     parent::process();
     self::$smarty->assign(array('HOOK_CATEGORY_LEFT' => Module::hookExec('categoryleft'), 'HOOK_HOME_CATEGORY' => Module::hookExec('homecategory')));
     self::$smarty->display(_PS_THEME_DIR_ . 'category.tpl');
 }