/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if ($this->customer->birthday) { $birthday = explode('-', $this->customer->birthday); } else { $birthday = array('-', '-', '-'); } /* Generate years, months and days */ $this->context->smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders())); if (Module::isInstalled('blocknewsletter')) { $this->context->smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active); } // start of implementation of the module code - taxamo // Get selected country if (Tools::isSubmit('taxamoisocountryresidence') && !is_null(Tools::getValue('taxamoisocountryresidence'))) { $selected_country = Tools::getValue('taxamoisocountryresidence'); } else { $selected_country = Taxamoeuvat::getCountryByCustomer($this->customer->id); } // Generate countries list if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } /* todo use helper */ $list = '<option value="">-</option>'; foreach ($countries as $country) { $selected = $country['iso_code'] == $selected_country ? 'selected="selected"' : ''; $list .= '<option value="' . $country['iso_code'] . '" ' . $selected . '>' . htmlentities($country['name'], ENT_COMPAT, 'UTF-8') . '</option>'; } // Get selected cc prefix if (Tools::isSubmit('taxamoccprefix') && !is_null(Tools::getValue('taxamoccprefix'))) { $taxamo_cc_prefix = Tools::getValue('taxamoccprefix'); } else { $taxamo_cc_prefix = Taxamoeuvat::getPrefixByCustomer($this->customer->id); } if ($this->customer->id) { $this->context->smarty->assign(array('countries_list' => $list, 'taxamoisocountryresidence' => $selected_country, 'taxamoccprefix' => $taxamo_cc_prefix)); } // end of code implementation module - taxamo $this->setTemplate(_PS_THEME_DIR_ . 'identity.tpl'); }
protected function renderCustomersList($group) { $genders = array(0 => '?'); $genders_icon = array('default' => 'unknown.gif'); foreach (Gender::getGenders() as $gender) { $genders_icon[$gender->id] = '../genders/' . (int) $gender->id . '.jpg'; $genders[$gender->id] = $gender->name; } $customer_fields_display = array('id_customer' => array('title' => $this->l('ID'), 'width' => 15, 'align' => 'center'), 'id_gender' => array('title' => $this->l('Titles'), 'align' => 'center', 'width' => 50, 'icon' => $genders_icon, 'list' => $genders), 'firstname' => array('title' => $this->l('Name'), 'align' => 'center'), 'lastname' => array('title' => $this->l('Name'), 'align' => 'center'), 'email' => array('title' => $this->l('E-mail address'), 'width' => 150, 'align' => 'center'), 'birthday' => array('title' => $this->l('Birth date'), 'width' => 150, 'align' => 'right', 'type' => 'date'), 'date_add' => array('title' => $this->l('Register date'), 'width' => 150, 'align' => 'right', 'type' => 'date'), 'orders' => array('title' => $this->l('Orders'), 'align' => 'center'), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'width' => 20, 'active' => 'status', 'type' => 'bool')); $customer_list = $group->getCustomers(false); $helper = new HelperList(); $helper->currentIndex = Context::getContext()->link->getAdminLink('AdminCustomers', false); $helper->token = Tools::getAdminTokenLite('AdminCustomers'); $helper->shopLinkType = ''; $helper->table = 'customer'; $helper->identifier = 'id_customer'; $helper->actions = array('edit', 'view'); $helper->show_toolbar = false; return $helper->generateList($customer_list, $customer_fields_display); }
public function getFormat() { $format = []; $format['id_customer'] = (new FormField())->setName('id_customer')->setType('hidden'); $genderField = (new FormField())->setName('id_gender')->setType('radio-buttons')->setLabel($this->translator->trans('Social title', [], 'Shop.Forms.Labels')); foreach (Gender::getGenders($this->language->id) as $gender) { $genderField->addAvailableValue($gender->id, $gender->name); } $format[$genderField->getName()] = $genderField; $format['firstname'] = (new FormField())->setName('firstname')->setLabel($this->translator->trans('First name', [], 'Shop.Forms.Labels'))->setRequired(true); $format['lastname'] = (new FormField())->setName('lastname')->setLabel($this->translator->trans('Last name', [], 'Shop.Forms.Labels'))->setRequired(true); if (Configuration::get('PS_B2B_ENABLE')) { $format['company'] = (new FormField())->setName('company')->setType('text')->setLabel($this->translator->trans('Company', [], 'Shop.Forms.Labels')); $format['siret'] = (new FormField())->setName('siret')->setType('text')->setLabel($this->translator->trans('Identification number', [], 'Shop.Forms.Labels')); } $format['email'] = (new FormField())->setName('email')->setType('email')->setLabel($this->translator->trans('Email', [], 'Shop.Forms.Labels'))->setRequired(true); if ($this->ask_for_password) { $format['password'] = (new FormField())->setName('password')->setType('password')->setLabel($this->translator->trans('Password', [], 'Shop.Forms.Labels'))->setRequired($this->password_is_required); } if ($this->ask_for_new_password) { $format['new_password'] = (new FormField())->setName('new_password')->setType('password')->setLabel($this->translator->trans('New password', [], 'Shop.Forms.Labels')); } if ($this->ask_for_birthdate) { $format['birthday'] = (new FormField())->setName('birthday')->setType('text')->setLabel($this->translator->trans('Birthdate', [], 'Shop.Forms.Labels'))->addAvailableValue('placeholder', Tools::getDateFormat())->addAvailableValue('comment', $this->translator->trans('(E.g.: %date_format%)', array('%date_format%' => Tools::formatDateStr('31 May 1970')), 'Shop.Forms.Help')); } if ($this->ask_for_partner_optin) { $format['optin'] = (new FormField())->setName('optin')->setType('checkbox')->setLabel($this->translator->trans('Receive offers from our partners', [], 'Shop.Theme.CustomerAccount')); } $additionalCustomerFormFields = Hook::exec('additionalCustomerFormFields', array(), null, true); if (!is_array($additionalCustomerFormFields)) { $additionalCustomerFormFields = array(); } $format = array_merge($format, $additionalCustomerFormFields); // TODO: TVA etc.? return $this->addConstraints($format); }
public function displayContent() { parent::displayContent(); $customer = new Customer((int) self::$cart->id_customer); $address_invoice = new Address((int) self::$cart->id_address_invoice); $country = new Country((int) $address_invoice->id_country); $currency = new Currency((int) self::$cart->id_currency); $countries = $this->klarna->getCountries(); $type = Tools::getValue('type'); if ($this->klarna->verifCountryAndCurrency($country, $currency) && ($type == 'invoice' || $type == 'account' || $type == 'special')) { $pno = array('SE' => 'yymmdd-nnnn', 'FI' => 'ddmmyy-nnnn', 'DK' => 'ddmmyynnnn', 'NO' => 'ddmmyynnnn', 'DE' => 'ddmmyy', 'NE' => 'ddmmyynnnn'); self::$smarty->assign('country', $country); self::$smarty->assign('pnoValue', $pno[$country->iso_code]); self::$smarty->assign('iso_code', strtolower($country->iso_code)); $i = 1; while ($i <= 31) { if ($i < 10) { $days[] = '0' . $i; } else { $days[] = $i; } $i++; } $i = 1; while ($i <= 12) { if ($i < 10) { $months[] = '0' . $i; } else { $months[] = $i; } $i++; } $i = 2000; while ($i >= 1910) { $years[] = $i--; } $houseInfo = $this->getHouseInfo($address_invoice->address1); self::$smarty->assign(array('days' => $days, 'customer_day' => (int) substr($customer->birthday, 8, 2), 'months' => $months, 'customer_month' => (int) substr($customer->birthday, 5, 2), 'years' => $years, 'customer_year' => (int) substr($customer->birthday, 0, 4), 'street_number' => $houseInfo[1], 'house_ext' => $houseInfo[2])); if ($type == 'invoice') { $total = self::$cart->getOrderTotal() + (double) Product::getPriceStatic((int) Configuration::get('KLARNA_INV_FEE_ID_' . $countries[$country->iso_code]['name'])); } else { $total = self::$cart->getOrderTotal(); } self::$smarty->assign(array('total_fee' => $total, 'fee' => $type == 'invoice' ? (double) Product::getPriceStatic((int) Configuration::get('KLARNA_INV_FEE_ID_' . $countries[$country->iso_code]['name'])) : 0)); if ($type == 'account') { self::$smarty->assign('accountPrice', $this->getMonthlyCoast(self::$cart, $countries, $country)); } if ($customer->id_gender != 1 && $customer->id_gender != 2 && $customer->id_gender != 3 && ($country->iso_code == 'DE' || $country->iso_code == 'NL')) { self::$smarty->assign('gender', Gender::getGenders()->getResults()); } self::$smarty->assign('linkTermsCond', $type == 'invoice' ? 'https://online.klarna.com/villkor' . ($country->iso_code != 'SE' ? '_' . strtolower($country->iso_code) : '') . '.yaws?eid=' . (int) Configuration::get('KLARNA_STORE_ID_' . $countries[$country->iso_code]['name']) . '&charge=' . round((double) Product::getPriceStatic((int) Configuration::get('KLARNA_INV_FEE_ID_' . $countries[$country->iso_code]['name'])), 2) : 'https://online.klarna.com/account_' . strtolower($country->iso_code) . '.yaws?eid=' . (int) Configuration::get('KLARNA_STORE_ID_' . $countries[$country->iso_code]['name'])); self::$smarty->assign('payment_type', Tools::safeOutput($type)); self::$smarty->display(_PS_MODULE_DIR_ . 'klarnaprestashop/tpl/form.tpl'); } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); /* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */ if (empty($this->context->cart->id_carrier)) { $checked = $this->context->cart->simulateCarrierSelectedOutput(); $checked = (int) Cart::desintifier($checked); $this->context->cart->id_carrier = $checked; $this->context->cart->update(); CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); } // SHOPPING CART $this->_assignSummaryInformations(); // WRAPPING AND TOS $this->_assignWrappingAndTOS(); $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } // If a rule offer free-shipping, force hidding shipping prices $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping'] && !$rule['carrier_restriction']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => (bool) (isset($_GET['isPaymentStep']) && $_GET['isPaymentStep']), 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); /* Load guest informations */ if ($this->isLogged && $this->context->cookie->is_guest) { $this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); } // ADDRESS if ($this->isLogged) { $this->_assignAddress(); } // CARRIER $this->_assignCarrier(); // PAYMENT $this->_assignPayment(); Tools::safePostVars(); $blocknewsletter = Module::getInstanceByName('blocknewsletter'); $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active)); $this->_processAddressFormat(); $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl'); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->context->smarty->assign('genders', Gender::getGenders()); $this->assignDate(); $this->assignCountries(); $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active; $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN')); $back = Tools::getValue('back'); $key = Tools::safeOutput(Tools::getValue('key')); if (!empty($key)) { $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key; } if ($back == Tools::secureReferrer(Tools::getValue('back'))) { $this->context->smarty->assign('back', html_entity_decode($back)); } else { $this->context->smarty->assign('back', Tools::safeOutput($back)); } if (Tools::getValue('display_guest_checkout')) { if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } $this->context->smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'sl_country' => (int) $this->id_country, 'countries' => $countries)); } if (Tools::getValue('create_account')) { $this->context->smarty->assign('email_create', 1); } if (Tools::getValue('multi-shipping') == 1) { $this->context->smarty->assign('multi_shipping', true); } else { $this->context->smarty->assign('multi_shipping', false); } $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase()); $this->assignAddressFormat(); // Call a hook to display more information on form $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); // Just set $this->template value here in case it's used by Ajax $this->setTemplate(_PS_THEME_DIR_ . 'authentication.tpl'); if ($this->ajax) { // Call a hook to display more information on form $this->context->smarty->assign(array('PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'genders' => Gender::getGenders())); $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'page' => $this->context->smarty->fetch($this->template), 'token' => Tools::getToken(false)); $this->ajaxDie(Tools::jsonEncode($return)); } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if ($this->customer->birthday) { $birthday = explode('-', $this->customer->birthday); } else { $birthday = array('-', '-', '-'); } /* Generate years, months and days */ $this->context->smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders())); $this->context->smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active); $this->setTemplate(_PS_THEME_DIR_ . 'identity.tpl'); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); /* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */ if (empty($this->context->cart->id_carrier)) { $checked = $this->context->cart->simulateCarrierSelectedOutput(); $checked = (int) Cart::desintifier($checked); $this->context->cart->id_carrier = $checked; $this->context->cart->update(); CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); } // SHOPPING CART $this->_assignSummaryInformations(); // WRAPPING AND TOS $this->_assignWrappingAndTOS(); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } // If a rule offer free-shipping, force hidding shipping prices $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping'] && !$rule['carrier_restriction']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => (int) Tools::getCountry(), 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => isset($_GET['isPaymentStep']) && $_GET['isPaymentStep'], 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); /* Load guest informations */ if ($this->isLogged && $this->context->cookie->is_guest) { $this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); } // ADDRESS if ($this->isLogged) { $this->_assignAddress(); } // CARRIER $this->_assignCarrier(); // PAYMENT $this->_assignPayment(); Tools::safePostVars(); $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active; $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN')); $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase()); $this->_processAddressFormat(); $link = new Link(); if (Tools::getValue('deleteFromOrderLine')) { $id_product = Tools::getValue('id_product'); $date_from = Tools::getValue('date_from'); $date_to = Tools::getValue('date_to'); $obj_cart_bk_data = new HotelCartBookingData(); $cart_data_dlt = $obj_cart_bk_data->deleteRoomDataFromOrderLine($this->context->cart->id, $this->context->cart->id_guest, $id_product, $date_from, $date_to); if ($cart_data_dlt) { Tools::redirect($link->getPageLink('order', null, $this->context->language->id)); } } if ((bool) Configuration::get('PS_ADVANCED_PAYMENT_API')) { $this->addJS(_THEME_JS_DIR_ . 'advanced-payment-api.js'); $this->setTemplate(_PS_THEME_DIR_ . 'order-opc-advanced.tpl'); } else { if (Module::isInstalled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php'; $obj_cart_bk_data = new HotelCartBookingData(); $obj_htl_bk_dtl = new HotelBookingDetail(); $obj_rm_type = new HotelRoomType(); $htl_rm_types = $this->context->cart->getProducts(); if (!empty($htl_rm_types)) { foreach ($htl_rm_types as $type_key => $type_value) { $product = new Product($type_value['id_product'], false, $this->context->language->id); $cover_image_arr = $product->getCover($type_value['id_product']); if (!empty($cover_image_arr)) { $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default'); } else { $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default'); } $unit_price = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1); if (isset($this->context->customer->id)) { $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']); } else { $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $type_value['id_product']); } $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['id_product']); $cart_htl_data[$type_key]['id_product'] = $type_value['id_product']; $cart_htl_data[$type_key]['cover_img'] = $cover_img; $cart_htl_data[$type_key]['name'] = $product->name; $cart_htl_data[$type_key]['unit_price'] = $unit_price; $cart_htl_data[$type_key]['adult'] = $rm_dtl['adult']; $cart_htl_data[$type_key]['children'] = $rm_dtl['children']; foreach ($cart_bk_data as $data_k => $data_v) { $date_join = strtotime($data_v['date_from']) . strtotime($data_v['date_to']); if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1; $num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days']; $vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] * $num_days; $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1); $amount *= $vart_quant; $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount; } else { $num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']); $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1; $cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; $cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; $amount = Product::getPriceStatic($type_value['id_product'], true, null, 6, null, false, true, 1); $amount *= $num_days; $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount; $cart_htl_data[$type_key]['date_diff'][$date_join]['link'] = $link->getPageLink('order', null, $this->context->language->id, "id_product=" . $type_value['id_product'] . "&deleteFromOrderLine=1&date_from=" . $data_v['date_from'] . "&date_to=" . $data_v['date_to']); } } } $this->context->smarty->assign('cart_htl_data', $cart_htl_data); } } $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl'); } }
public function initContent() { $this->context->controller->addJS(self::$amz_payments->getPathUri() . 'views/js/amzpayments_checkout.js'); $this->context->cart->id_address_delivery = null; $this->context->cart->id_address_invoice = null; parent::initContent(); if (empty($this->context->cart->id_carrier)) { $checked = $this->context->cart->simulateCarrierSelectedOutput(); $checked = (int) Cart::desintifier($checked); $this->context->cart->id_carrier = $checked; $this->context->cart->update(); CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context); } $this->_assignSummaryInformations(); $this->_assignWrappingAndTOS(); $selected_country = (int) Configuration::get('PS_COUNTRY_DEFAULT'); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping'] && !$rule['carrier_restriction']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('advanced_payment_api' => false, 'free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selected_country) ? $selected_country : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier.', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service.', false), 'isPaymentStep' => (bool) Tools::getIsset(Tools::getValue('isPaymentStep')) && Tools::getValue('isPaymentStep'), 'genders' => Gender::getGenders(), 'one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); $this->_assignCarrier(); Tools::safePostVars(); $blocknewsletter = Module::getInstanceByName('blocknewsletter'); $this->context->smarty->assign('newsletter', (bool) $blocknewsletter && $blocknewsletter->active); $this->context->smarty->assign(array('amz_module_path' => self::$amz_payments->getPathUri(), 'amz_session' => Tools::getValue('session') ? Tools::getValue('session') : $this->context->cookie->amazon_id, 'sellerID' => Configuration::get('AMZ_MERCHANT_ID'), 'sandboxMode' => false)); if (isset($this->context->cookie->amz_access_token) && $this->context->cookie->amz_access_token != '' && !AmazonPaymentsCustomerHelper::customerHasAmazonCustomerId($this->context->cookie->id_customer)) { $this->context->smarty->assign('show_amazon_account_creation_allowed', true); } else { $this->context->smarty->assign('show_amazon_account_creation_allowed', false); } $this->context->smarty->assign('preselect_create_account', Configuration::get('PRESELECT_CREATE_ACCOUNT') == 1); $this->context->smarty->assign('force_account_creation', Configuration::get('FORCE_ACCOUNT_CREATION') == 1); if (Configuration::get('TEMPLATE_VARIANT_BS') == 1) { $this->setTemplate('amzpayments_bs.tpl'); } else { $this->setTemplate('amzpayments.tpl'); } }
protected function renderCustomersList($group) { $genders = array(0 => '?'); $genders_icon = array('default' => 'unknown.gif'); foreach (Gender::getGenders() as $gender) { $genders_icon[$gender->id] = '../genders/' . (int) $gender->id . '.jpg'; $genders[$gender->id] = $gender->name; } $this->table = 'customer_group'; $this->lang = false; $this->list_id = 'customer_group'; $this->actions = array(); $this->addRowAction('edit'); $this->identifier = 'id_customer'; $this->bulk_actions = false; $this->list_no_link = true; $this->explicitSelect = true; $this->fields_list = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'filter_key' => 'c!id_customer', 'class' => 'fixed-width-xs'), 'id_gender' => array('title' => $this->l('Social title'), 'icon' => $genders_icon, 'list' => $genders), 'firstname' => array('title' => $this->l('First name')), 'lastname' => array('title' => $this->l('Last name')), 'email' => array('title' => $this->l('Email address'), 'filter_key' => 'c!email', 'orderby' => true), 'birthday' => array('title' => $this->l('Birth date'), 'type' => 'date', 'class' => 'fixed-width-md', 'align' => 'center'), 'date_add' => array('title' => $this->l('Registration date'), 'type' => 'date', 'class' => 'fixed-width-md', 'align' => 'center'), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'class' => 'fixed-width-sm', 'active' => 'status', 'type' => 'bool', 'search' => false, 'orderby' => false, 'filter_key' => 'c!active')); $this->_select = 'c.*, a.id_group'; $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON (a.`id_customer` = c.`id_customer`)'; $this->_where = 'AND a.`id_group` = ' . (int) $group->id . ' AND c.`deleted` != 1'; self::$currentIndex = self::$currentIndex . '&viewgroup'; $this->processFilter(); return parent::renderList(); }
public function initContent() { $internal_referrer = isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], Dispatcher::getInstance()->createUrl('order-opc', $this->context->cookie->id_lang)); $upsell = @Module::getInstanceByName('upsell'); if ($upsell && $upsell->active && !(Tools::getValue('skip_offers') == 1 || $internal_referrer)) { ParentOrderController::initContent(); // We need this to display the page properly (parent of overriden controller) $upsell->getUpsells(); $this->template = $upsell->setTemplate('upsell-products.tpl'); } else { if (!$this->isOpcModuleActive()) { return parent::initContent(); } $this->origInitContent(); $this->_assignSummaryInformations(); $this->_assignWrappingAndTOS(); $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping'] && !$rule['carrier_restriction']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isLogged' => $this->isLogged, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier before', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service before', false), 'isPaymentStep' => (bool) (Tools::getIsset('isPaymentStep') && Tools::getValue('isPaymentStep')), 'genders' => Gender::getGenders())); $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); if ($this->isLogged) { $this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); } if ($this->context->cart->id_address_delivery > 0) { $def_address = new Address($this->context->cart->id_address_delivery); $def_country = $def_address->id_country; $def_state = $def_address->id_state; } else { $def_country = 0; $def_state = 0; } if ($this->context->cart->id_address_invoice > 0) { $def_address_invoice = new Address($this->context->cart->id_address_invoice); $def_country_invoice = $def_address_invoice->id_country; $def_state_invoice = $def_address_invoice->id_state; } else { $def_country_invoice = 0; $def_state_invoice = 0; } if ($this->context->cart->id_address_delivery > 0 && $this->context->cart->id_address_invoice > 0 && $this->context->cart->id_address_delivery != $this->context->cart->id_address_invoice) { $def_different_billing = 1; } else { $def_different_billing = 0; } $this->context->smarty->assign('def_different_billing', $def_different_billing); $this->context->smarty->assign('def_country', $def_country); $this->context->smarty->assign('def_state', $def_state); $this->context->smarty->assign('def_country_invoice', $def_country_invoice); $this->context->smarty->assign('def_state_invoice', $def_state_invoice); if ($this->isLogged) { $this->_assignAddress(); } // ADDRESS $this->_assignCarrier(); $this->_assignPayment(); Tools::safePostVars(); if (!$this->context->cart->isMultiAddressDelivery()) { $this->context->cart->setNoMultishipping(); } // As the cart is no multishipping, set each delivery address lines with the main delivery address $summary = $this->context->cart->getSummaryDetails(null, true); // to force refresh on product.id_address_delivery $this->_assignSummaryInformations(); $blocknewsletter = Module::getInstanceByName('blocknewsletter'); $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active)); $this->context->smarty->assign('opc_templates_path', $this->opc_templates_path); $this->context->smarty->assign('twoStepCheckout', false); // TODO: hardcoded value! $online_country = new Country($this->opc_config['online_country_id']); if ($online_country->active) { $this->context->smarty->assign('onlineCountryActive', true); } if (Tools::isSubmit('cart-only')) { $this->context->smarty->assign('onlyCartSummary', '1'); $this->context->smarty->assign('order_process_type', Configuration::get('PS_ORDER_PROCESS_TYPE')); $this->setTemplate('shopping-cart.tpl'); } else { $this->setTemplate('order-opc.tpl'); } } }
public function renderForm() { if (!($obj = $this->loadObject(true))) { return; } $genders = Gender::getGenders(); $list_genders = array(); foreach ($genders as $key => $gender) { $list_genders[$key]['id'] = 'gender_' . $gender->id; $list_genders[$key]['value'] = $gender->id; $list_genders[$key]['label'] = $gender->name; } $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $groups = Group::getGroups($this->default_form_language, true); $this->fields_form = array('legend' => array('title' => $this->l('Customer'), 'image' => '../img/admin/tab-customers.gif'), 'input' => array(array('type' => 'radio', 'label' => $this->l('Titles:'), 'name' => 'id_gender', 'required' => false, 'class' => 't', 'values' => $list_genders), array('type' => 'text', 'label' => $this->l('First name:'), 'name' => 'firstname', 'size' => 33, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:'), array('type' => 'text', 'label' => $this->l('Last name:'), 'name' => 'lastname', 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:'), array('type' => 'text', 'label' => $this->l('E-mail address:'), 'name' => 'email', 'size' => 33, 'required' => true), array('type' => 'password', 'label' => $this->l('Password:'******'name' => 'passwd', 'size' => 33, 'required' => $obj->id ? false : true, 'desc' => $obj->id ? $this->l('Leave blank if no change') : $this->l('5 characters min., only letters, numbers, or') . ' -_'), array('type' => 'birthday', 'label' => $this->l('Birthday:'), 'name' => 'birthday', 'options' => array('days' => $days, 'months' => $months, 'years' => $years)), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Allow or disallow this customer to log in')), array('type' => 'radio', 'label' => $this->l('Newsletter:'), 'name' => 'newsletter', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'newsletter_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'newsletter_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Customer will receive your newsletter via e-mail')), array('type' => 'radio', 'label' => $this->l('Opt-in:'), 'name' => 'optin', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'optin_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'optin_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Customer will receive your ads via e-mail')))); // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) { $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP'); $guest_group = Configuration::get('PS_GUEST_GROUP'); foreach ($groups as $key => $g) { if (in_array($g['id_group'], array($visitor_group, $guest_group))) { unset($groups[$key]); } } } $this->fields_form['input'] = array_merge($this->fields_form['input'], array(array('type' => 'group', 'label' => $this->l('Group access:'), 'name' => 'groupBox', 'values' => $groups, 'required' => true, 'desc' => $this->l('Select all customer groups you would like to apply to this customer')), array('type' => 'select', 'label' => $this->l('Default customer group:'), 'name' => 'id_default_group', 'options' => array('query' => $groups, 'id' => 'id_group', 'name' => 'name'), 'hint' => $this->l('The group will be as applied by default.'), 'desc' => $this->l('Apply the discount\'s price of this group.')))); // if customer is a guest customer, password hasn't to be there if ($obj->id && ($obj->is_guest && $obj->id_default_group == Configuration::get('PS_GUEST_GROUP'))) { foreach ($this->fields_form['input'] as $k => $field) { if ($field['type'] == 'password') { array_splice($this->fields_form['input'], $k, 1); } } } if (Configuration::get('PS_B2B_ENABLE')) { $risks = Risk::getRisks(); $list_risks = array(); foreach ($risks as $key => $risk) { $list_risks[$key]['id_risk'] = (int) $risk->id; $list_risks[$key]['name'] = $risk->name; } $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Company:'), 'name' => 'company', 'size' => 33); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('SIRET:'), 'name' => 'siret', 'size' => 14); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('APE:'), 'name' => 'ape', 'size' => 5); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Website:'), 'name' => 'website', 'size' => 33); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Outstanding allowed:'), 'name' => 'outstanding_allow_amount', 'size' => 10, 'hint' => $this->l('Valid characters:') . ' 0-9', 'suffix' => '¤'); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Max payment days:'), 'name' => 'max_payment_days', 'size' => 10, 'hint' => $this->l('Valid characters:') . ' 0-9'); $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Risk:'), 'name' => 'id_risk', 'required' => false, 'class' => 't', 'options' => array('query' => $list_risks, 'id' => 'id_risk', 'name' => 'name')); } $this->fields_form['submit'] = array('title' => $this->l(' Save '), 'class' => 'button'); $birthday = explode('-', $this->getFieldValue($obj, 'birthday')); $this->fields_value = array('years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0, 'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0, 'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0); // Added values of object Group $customer_groups = $obj->getGroups(); $customer_groups_ids = array(); if (is_array($customer_groups)) { foreach ($customer_groups as $customer_group) { $customer_groups_ids[] = $customer_group; } } // if empty $carrier_groups_ids : object creation : we set the default groups if (empty($customer_groups_ids)) { $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP')); $customer_groups_ids = array_merge($customer_groups_ids, $preselected); } foreach ($groups as $group) { $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $customer_groups_ids)); } return parent::renderForm(); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if ($this->customer->birthday) { $birthday = explode('-', $this->customer->birthday); } else { $birthday = array('-', '-', '-'); } /* Generate years, months and days */ $this->context->smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors, 'genders' => Gender::getGenders())); // Call a hook to display more information $this->context->smarty->assign(array('HOOK_CUSTOMER_IDENTITY_FORM' => Hook::exec('displayCustomerIdentityForm'))); $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active; $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool) Configuration::get('PS_CUSTOMER_OPTIN')); $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase()); $this->setTemplate(_PS_THEME_DIR_ . 'identity.tpl'); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); // SHOPPING CART $this->_assignSummaryInformations(); // WRAPPING AND TOS $this->_assignWrappingAndTOS(); $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } // If a rule offer free-shipping, force hidding shipping prices $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier before', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service before', false), 'isPaymentStep' => (bool) (isset($_GET['isPaymentStep']) && $_GET['isPaymentStep']), 'genders' => Gender::getGenders())); /* Call a hook to display more information on form */ self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); /* Load guest informations */ if ($this->isLogged && $this->context->cookie->is_guest) { $this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); } if ($this->isLogged) { $this->_assignAddress(); } // ADDRESS // CARRIER $this->_assignCarrier(); // PAYMENT $this->_assignPayment(); Tools::safePostVars(); $this->context->smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active); $this->_processAddressFormat(); $this->setTemplate(_PS_THEME_DIR_ . 'order-opc.tpl'); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->context->smarty->assign('genders', Gender::getGenders()); $this->assignDate(); $this->assignCountries(); $active_module_newsletter = false; if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) { $active_module_newsletter = $module_newsletter->active; } $this->context->smarty->assign('newsletter', (int) $active_module_newsletter); $back = Tools::getValue('back'); $key = Tools::safeOutput(Tools::getValue('key')); if (!empty($key)) { $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key; } if (!empty($back)) { $this->context->smarty->assign('back', Tools::safeOutput($back)); } if (Tools::getValue('display_guest_checkout')) { if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } $this->context->smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'sl_country' => (int) Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')), 'countries' => $countries)); } if (Tools::getValue('create_account')) { $this->context->smarty->assign('email_create', 1); } if (Tools::getValue('multi-shipping') == 1) { $this->context->smarty->assign('multi_shipping', true); } else { $this->context->smarty->assign('multi_shipping', false); } $this->assignAddressFormat(); // Call a hook to display more information on form $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); if ($this->ajax) { // Call a hook to display more information on form $this->context->smarty->assign(array('PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'genders' => Gender::getGenders())); $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'page' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'authentication.tpl'), 'token' => Tools::getToken(false)); die(Tools::jsonEncode($return)); } $this->setTemplate(_PS_THEME_DIR_ . 'authentication.tpl'); }
public function renderForm() { /** @var Customer $obj */ if (!($obj = $this->loadObject(true))) { return; } $genders = Gender::getGenders(); $list_genders = array(); foreach ($genders as $key => $gender) { /** @var Gender $gender */ $list_genders[$key]['id'] = 'gender_' . $gender->id; $list_genders[$key]['value'] = $gender->id; $list_genders[$key]['label'] = $gender->name; } $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $groups = Group::getGroups($this->default_form_language, true); $this->fields_form = array('legend' => array('title' => $this->l('Customer'), 'icon' => 'icon-user'), 'input' => array(array('type' => 'radio', 'label' => $this->l('Social title'), 'name' => 'id_gender', 'required' => false, 'class' => 't', 'values' => $list_genders), array('type' => 'text', 'label' => $this->l('First name'), 'name' => 'firstname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"°{}_$%:'), array('type' => 'text', 'label' => $this->l('Last name'), 'name' => 'lastname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"°{}_$%:'), array('type' => 'text', 'prefix' => '<i class="icon-envelope-o"></i>', 'label' => $this->l('Email address'), 'name' => 'email', 'col' => '4', 'required' => true, 'autocomplete' => false), array('type' => 'password', 'label' => $this->l('Password'), 'name' => 'passwd', 'required' => $obj->id ? false : true, 'col' => '4', 'hint' => $obj->id ? $this->l('Leave this field blank if there\'s no change.') : sprintf($this->l('Password should be at least %s characters long.'), Validate::PASSWORD_LENGTH)), array('type' => 'birthday', 'label' => $this->l('Birthday'), 'name' => 'birthday', 'options' => array('days' => $days, 'months' => $months, 'years' => $years)), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Enable or disable customer login.')), array('type' => 'switch', 'label' => $this->l('Newsletter'), 'name' => 'newsletter', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'newsletter_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'newsletter_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_NWSL')), 'hint' => $this->l('This customer will receive your newsletter via email.')), array('type' => 'switch', 'label' => $this->l('Opt-in'), 'name' => 'optin', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'optin_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'optin_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_OPTIN')), 'hint' => $this->l('This customer will receive your ads via email.')))); // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) { $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP'); $guest_group = Configuration::get('PS_GUEST_GROUP'); foreach ($groups as $key => $g) { if (in_array($g['id_group'], array($visitor_group, $guest_group))) { unset($groups[$key]); } } } $this->fields_form['input'] = array_merge($this->fields_form['input'], array(array('type' => 'group', 'label' => $this->l('Group access'), 'name' => 'groupBox', 'values' => $groups, 'required' => true, 'col' => '6', 'hint' => $this->l('Select all the groups that you would like to apply to this customer.')), array('type' => 'select', 'label' => $this->l('Default customer group'), 'name' => 'id_default_group', 'options' => array('query' => $groups, 'id' => 'id_group', 'name' => 'name'), 'col' => '4', 'hint' => array($this->l('This group will be the user\'s default group.'), $this->l('Only the discount for the selected group will be applied to this customer.'))))); // if customer is a guest customer, password hasn't to be there if ($obj->id && ($obj->is_guest && $obj->id_default_group == Configuration::get('PS_GUEST_GROUP'))) { foreach ($this->fields_form['input'] as $k => $field) { if ($field['type'] == 'password') { array_splice($this->fields_form['input'], $k, 1); } } } if (Configuration::get('PS_B2B_ENABLE')) { $risks = Risk::getRisks(); $list_risks = array(); foreach ($risks as $key => $risk) { /** @var Risk $risk */ $list_risks[$key]['id_risk'] = (int) $risk->id; $list_risks[$key]['name'] = $risk->name; } $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company'); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('SIRET'), 'name' => 'siret'); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('APE'), 'name' => 'ape'); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Website'), 'name' => 'website'); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Allowed outstanding amount'), 'name' => 'outstanding_allow_amount', 'hint' => $this->l('Valid characters:') . ' 0-9', 'suffix' => $this->context->currency->sign); $this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Maximum number of payment days'), 'name' => 'max_payment_days', 'hint' => $this->l('Valid characters:') . ' 0-9'); $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Risk rating'), 'name' => 'id_risk', 'required' => false, 'class' => 't', 'options' => array('query' => $list_risks, 'id' => 'id_risk', 'name' => 'name')); } $this->fields_form['submit'] = array('title' => $this->l('Save')); $birthday = explode('-', $this->getFieldValue($obj, 'birthday')); $this->fields_value = array('years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0, 'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0, 'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0); // Added values of object Group if (!Validate::isUnsignedId($obj->id)) { $customer_groups = array(); } else { $customer_groups = $obj->getGroups(); } $customer_groups_ids = array(); if (is_array($customer_groups)) { foreach ($customer_groups as $customer_group) { $customer_groups_ids[] = $customer_group; } } // if empty $carrier_groups_ids : object creation : we set the default groups if (empty($customer_groups_ids)) { $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP')); $customer_groups_ids = array_merge($customer_groups_ids, $preselected); } foreach ($groups as $group) { $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $customer_groups_ids)); } return parent::renderForm(); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->context->smarty->assign('genders', Gender::getGenders()); $this->assignDate(); $this->assignCountries(); $this->context->smarty->assign('newsletter', 1); $back = Tools::getValue('back'); $key = Tools::safeOutput(Tools::getValue('key')); if (!empty($key)) { $back .= (strpos($back, '?') !== false ? '&' : '?') . 'key=' . $key; } if ($back == Tools::secureReferrer(Tools::getValue('back'))) { $this->context->smarty->assign('back', html_entity_decode($back)); } else { $this->context->smarty->assign('back', Tools::safeOutput($back)); } if (Tools::getValue('display_guest_checkout')) { if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { // get all countries as language (xy) or language-country (wz-XY) $array = array(); preg_match("#(?<=-)\\w\\w|\\w\\w(?!-)#", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array); if (!Validate::isLanguageIsoCode($array[0]) || !($sl_country = Country::getByIso($array[0]))) { $sl_country = (int) Configuration::get('PS_COUNTRY_DEFAULT'); } } else { $sl_country = (int) Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')); } $this->context->smarty->assign(array('inOrderProcess' => true, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'sl_country' => (int) $sl_country, 'countries' => $countries)); } if (Tools::getValue('create_account')) { $this->context->smarty->assign('email_create', 1); } if (Tools::getValue('multi-shipping') == 1) { $this->context->smarty->assign('multi_shipping', true); } else { $this->context->smarty->assign('multi_shipping', false); } $this->assignAddressFormat(); // Call a hook to display more information on form $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); // Just set $this->template value here in case it's used by Ajax $this->setTemplate(_PS_THEME_DIR_ . 'authentication.tpl'); if ($this->ajax) { // Call a hook to display more information on form $this->context->smarty->assign(array('PS_REGISTRATION_PROCESS_TYPE' => Configuration::get('PS_REGISTRATION_PROCESS_TYPE'), 'genders' => Gender::getGenders())); $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'page' => $this->context->smarty->fetch($this->template), 'token' => Tools::getToken(false)); die(Tools::jsonEncode($return)); } }
protected function initCustomerList() { $genders_icon = array('default' => 'unknown.gif'); $genders = array(0 => $this->l('?')); foreach (Gender::getGenders() as $gender) { $genders_icon[$gender->id] = '../genders/' . (int) $gender->id . '.jpg'; $genders[$gender->id] = $gender->name; } $this->fields_list['customers'] = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'id_gender' => array('title' => $this->l('Social title'), 'align' => 'center', 'icon' => $genders_icon, 'list' => $genders, 'width' => 25), 'firstname' => array('title' => $this->l('First Name'), 'align' => 'left', 'width' => 150), 'lastname' => array('title' => $this->l('Name'), 'align' => 'left', 'width' => 'auto'), 'email' => array('title' => $this->l('Email address'), 'align' => 'left', 'width' => 250), 'birthday' => array('title' => $this->l('Birth date'), 'align' => 'center', 'type' => 'date', 'width' => 75), 'date_add' => array('title' => $this->l('Registration date'), 'align' => 'center', 'type' => 'date', 'width' => 75), 'orders' => array('title' => $this->l('Orders'), 'align' => 'center', 'width' => 50), 'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'width' => 25)); }
public function initContent() { // Upsell integration $internal_referrer = isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], Dispatcher::getInstance()->createUrl('order-opc', $this->context->cookie->id_lang)); $upsell = @Module::getInstanceByName('upsell'); if ($upsell && $upsell->active && !(Tools::getValue('skip_offers') == 1 || $internal_referrer)) { ParentOrderController::initContent(); // We need this to display the page properly (parent of overriden controller) $upsell->getUpsells(); $this->template = $upsell->setTemplate('upsell-products.tpl'); } else { if (!$this->isOpcModuleActive()) { return parent::initContent(); } // parent::initContent(); - toto by volalo celu metodu aj s volanim sablony z default themy $this->origInitContent(); // SHOPPING CART $this->_assignSummaryInformations(); // WRAPPING AND TOS $this->_assignWrappingAndTOS(); $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT'); if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) { $countries = Carrier::getDeliveredCountries($this->context->language->id, true, true); } else { $countries = Country::getCountries($this->context->language->id, true); } // If a rule offer free-shipping, force hidding shipping prices $free_shipping = false; foreach ($this->context->cart->getCartRules() as $rule) { if ($rule['free_shipping'] && !$rule['carrier_restriction']) { $free_shipping = true; break; } } $this->context->smarty->assign(array('free_shipping' => $free_shipping, 'isLogged' => $this->isLogged, 'isGuest' => isset($this->context->cookie->is_guest) ? $this->context->cookie->is_guest : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'errorCarrier' => Tools::displayError('You must choose a carrier before', false), 'errorTOS' => Tools::displayError('You must accept the Terms of Service before', false), 'isPaymentStep' => (bool) (Tools::getIsset('isPaymentStep') && Tools::getValue('isPaymentStep')), 'genders' => Gender::getGenders())); /* Call a hook to display more information on form */ $this->context->smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('displayCustomerAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('displayCustomerAccountFormTop'))); $years = Tools::dateYears(); $months = Tools::dateMonths(); $days = Tools::dateDays(); $this->context->smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days)); /* Load guest informations */ //if ($this->isLogged && $this->context->cookie->is_guest) // opckt changed. if ($this->isLogged) { $this->context->smarty->assign('guestInformations', $this->_getGuestInformations()); } // OPCKT default address update - in case customer is not yet logged-in and address is not // yet entered and refresh happens if ($this->context->cart->id_address_delivery > 0) { $def_address = new Address($this->context->cart->id_address_delivery); $def_country = $def_address->id_country; $def_state = $def_address->id_state; } else { $def_country = 0; $def_state = 0; } if ($this->context->cart->id_address_invoice > 0) { $def_address_invoice = new Address($this->context->cart->id_address_invoice); $def_country_invoice = $def_address_invoice->id_country; $def_state_invoice = $def_address_invoice->id_state; } else { $def_country_invoice = 0; $def_state_invoice = 0; } if ($this->context->cart->id_address_delivery > 0 && $this->context->cart->id_address_invoice > 0 && $this->context->cart->id_address_delivery != $this->context->cart->id_address_invoice) { $def_different_billing = 1; } else { $def_different_billing = 0; } $this->context->smarty->assign('def_different_billing', $def_different_billing); $this->context->smarty->assign('def_country', $def_country); $this->context->smarty->assign('def_state', $def_state); $this->context->smarty->assign('def_country_invoice', $def_country_invoice); $this->context->smarty->assign('def_state_invoice', $def_state_invoice); if ($this->isLogged) { $this->_assignAddress(); } // ADDRESS // CARRIER $this->_assignCarrier(); // PAYMENT $this->_assignPayment(); Tools::safePostVars(); if (!$this->context->cart->isMultiAddressDelivery()) { $this->context->cart->setNoMultishipping(); } // As the cart is no multishipping, set each delivery address lines with the main delivery address // cart-summary $summary = $this->context->cart->getSummaryDetails(null, true); // to force refresh on product.id_address_delivery $this->_assignSummaryInformations(); $blocknewsletter = Module::getInstanceByName('blocknewsletter'); $this->context->smarty->assign('newsletter', (bool) ($blocknewsletter && $blocknewsletter->active)); //$this->_processAddressFormat(); - v OPC module to nepotrebujeme, to je len format // "offline" needitovatelnej adresy //$this->setTemplate(_PS_THEME_DIR_.'order-opc.tpl'); $this->context->smarty->assign('opc_templates_path', $this->opc_templates_path); $this->context->smarty->assign('twoStepCheckout', false); // TODO: hardcoded value! //$this->context->smarty->assign('paypal_express_checkout_on', isset($this->context->cookie->express_checkout)); $online_country = new Country($this->opc_config['online_country_id']); if ($online_country->active) { $this->context->smarty->assign('onlineCountryActive', true); } if (Tools::isSubmit('cart-only')) { $this->context->smarty->assign('onlyCartSummary', '1'); $this->context->smarty->assign('order_process_type', Configuration::get('PS_ORDER_PROCESS_TYPE')); $this->setTemplate('shopping-cart.tpl'); } else { $this->setTemplate('order-opc.tpl'); } } }