/**
  * 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');
 }
Example #2
0
 /**
  * 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');
 }
Example #3
0
 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');
         }
     }
 }
Example #4
0
            $errors = $customer->validateControler();
        }
        if (!sizeof($errors)) {
            $customer->id_default_group = intval($prev_id_default_group);
            $customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
            if (Tools::getValue('passwd')) {
                $cookie->passwd = $customer->passwd;
            }
            if ($customer->update()) {
                $cookie->customer_lastname = $customer->lastname;
                $cookie->customer_firstname = $customer->firstname;
                $smarty->assign('confirmation', 1);
            } else {
                $errors[] = Tools::displayError('impossible to update information');
            }
        }
    }
} else {
    $_POST = array_map('stripslashes', $customer->getFields());
}
if ($customer->birthday) {
    $birthday = explode('-', $customer->birthday);
} else {
    $birthday = array('-', '-', '-');
}
/* Generate years, months and days */
$smarty->assign(array('need_identification_number' => $need_identification_number, 'years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $errors));
Tools::safePostVars();
include dirname(__FILE__) . '/header.php';
$smarty->display(_PS_THEME_DIR_ . 'identity.tpl');
include dirname(__FILE__) . '/footer.php';
    public function displayForm($isMainTab = true)
    {
        global $currentIndex;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
        $customer_groups = Tools::getValue('groupBox', $obj->getGroups());
        $groups = Group::getGroups($this->_defaultFormLanguage, true);
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" autocomplete="off">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/tab-customers.gif" />' . $this->l('Customer') . '</legend>
				<label>' . $this->l('Gender:') . ' </label>
				<div class="margin-form">
					<input type="radio" size="33" name="id_gender" id="gender_1" value="1" ' . ($this->getFieldValue($obj, 'id_gender') == 1 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_1"> ' . $this->l('Male') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_2" value="2" ' . ($this->getFieldValue($obj, 'id_gender') == 2 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_2"> ' . $this->l('Female') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_3" value="9" ' . (($this->getFieldValue($obj, 'id_gender') == 9 or !$this->getFieldValue($obj, 'id_gender')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_3"> ' . $this->l('Unknown') . '</label>
				</div>
				<label>' . $this->l('Last name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
				</div>
				<label>' . $this->l('First name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
				</div>
				<label>' . $this->l('Password:'******' </label>
				<div class="margin-form">
					<input type="password" size="33" name="passwd" value="" /> ' . (!$obj->id ? '<sup>*</sup>' : '') . '
					<p>' . ($obj->id ? $this->l('Leave blank if no change') : $this->l('5 characters min., only letters, numbers, or') . ' -_') . '</p>
				</div>
				<label>' . $this->l('E-mail address:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="email" value="' . htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('Birthday:') . ' </label>';
        $sl_year = $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0;
        $years = Tools::dateYears();
        $sl_month = $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0;
        $months = Tools::dateMonths();
        $sl_day = $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0;
        $days = Tools::dateDays();
        $tab_months = array($this->l('January'), $this->l('February'), $this->l('March'), $this->l('April'), $this->l('May'), $this->l('June'), $this->l('July'), $this->l('August'), $this->l('September'), $this->l('October'), $this->l('November'), $this->l('December'));
        echo '
					<div class="margin-form">
					<select name="days">
						<option value="">-</option>';
        foreach ($days as $v) {
            echo '<option value="' . $v . '" ' . ($sl_day == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '
					</select>
					<select name="months">
						<option value="">-</option>';
        foreach ($months as $k => $v) {
            echo '<option value="' . $k . '" ' . ($sl_month == $k ? 'selected="selected"' : '') . '>' . $this->l($v) . '</option>';
        }
        echo '</select>
					<select name="years">
						<option value="">-</option>';
        foreach ($years as $v) {
            echo '<option value="' . $v . '" ' . ($sl_year == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '</select>
				</div>';
        echo '<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this customer to log in') . '</p>
				</div>
				<label>' . $this->l('Newsletter:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="newsletter" id="newsletter_on" value="1" ' . ($this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="newsletter" id="newsletter_off" value="0" ' . (!$this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your newsletter via e-mail') . '</p>
				</div>
				<label>' . $this->l('Opt-in:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="optin" id="optin_on" value="1" ' . ($this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="optin" id="optin_off" value="0" ' . (!$this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your ads via e-mail') . '</p>
				</div>
				<label>' . $this->l('Default group:') . ' </label>
				<div class="margin-form">
					<select name="id_default_group" onchange="checkDefaultGroup(this.value);">';
        foreach ($groups as $group) {
            echo '<option value="' . (int) $group['id_group'] . '"' . ($group['id_group'] == $obj->id_default_group ? ' selected="selected"' : '') . '>' . htmlentities($group['name'], ENT_NOQUOTES, 'utf-8') . '</option>';
        }
        echo '
					</select>
					<p>' . $this->l('Apply non-cumulative rules (e.g., price, display method, reduction)') . '</p>
				</div>
				<label>' . $this->l('Groups:') . ' </label>
				<div class="margin-form">';
        if (sizeof($groups)) {
            echo '
					<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)" /></th>
							<th>' . $this->l('ID') . '</th>
							<th>' . $this->l('Group name') . '</th>
						</tr>';
            $irow = 0;
            foreach ($groups as $group) {
                echo '
							<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
								<td>' . '<input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $group['id_group'] . '" value="' . $group['id_group'] . '" ' . (in_array($group['id_group'], $customer_groups) ? 'checked="checked" ' : '') . '/></td>
								<td>' . $group['id_group'] . '</td>
								<td><label for="groupBox_' . $group['id_group'] . '" class="t">' . $group['name'] . '</label></td>
							</tr>';
            }
            echo '
					</table>
					<p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Check all the box(es) of groups of which the customer is to be a member') . '<sup> *</sup></p>
					';
        } else {
            echo '<p>' . $this->l('No group created') . '</p>';
        }
        echo '
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
            $errors = $customer->validateControler();
        }
        if (!sizeof($errors)) {
            $customer->lastname = Tools::strtoupper($customer->lastname);
            $customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
            if (Tools::getValue('passwd')) {
                $cookie->passwd = $customer->passwd;
            }
            if ($customer->update()) {
                $cookie->customer_lastname = $customer->lastname;
                $cookie->customer_firstname = $customer->firstname;
                $smarty->assign('confirmation', 1);
            } else {
                $errors[] = Tools::displayError('impossible to update information');
            }
        }
    }
} else {
    $_POST = array_map('stripslashes', $customer->getFields());
}
if ($customer->birthday) {
    $birthday = explode('-', $customer->birthday);
} else {
    $birthday = array('-', '-', '-');
}
/* Generate years, months and days */
$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' => $errors));
Tools::safePostVars();
include dirname(__FILE__) . '/header.php';
$smarty->display(_PS_THEME_DIR_ . 'identity.tpl');
include dirname(__FILE__) . '/footer.php';
 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!&lt;&gt;,;?=+()@#"°{}_$%:'), array('type' => 'text', 'label' => $this->l('Last name'), 'name' => 'lastname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&lt;&gt;,;?=+()@#"°{}_$%:'), 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();
 }
 public function process()
 {
     // 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((int) self::$cookie->id_lang, true, true);
     } else {
         $countries = Country::getCountries((int) self::$cookie->id_lang, true);
     }
     self::$smarty->assign(array('isLogged' => $this->isLogged, 'isGuest' => isset(self::$cookie->is_guest) ? self::$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 terms of service before', false), 'isPaymentStep' => (bool) (isset($_GET['isPaymentStep']) and $_GET['isPaymentStep'])));
     /* Call a hook to display more information on form */
     self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')));
     $years = Tools::dateYears();
     $months = Tools::dateMonths();
     $days = Tools::dateDays();
     self::$smarty->assign(array('years' => $years, 'months' => $months, 'days' => $days));
     /* Load guest informations */
     if ($this->isLogged and self::$cookie->is_guest) {
         self::$smarty->assign('guestInformations', $this->_getGuestInformations());
     }
     if ($this->isLogged) {
         $this->_assignAddress();
     }
     // ADDRESS
     // CARRIER
     $this->_assignCarrier();
     // PAYMENT
     $this->_assignPayment();
     Tools::safePostVars();
     if ($blocknewsletter = Module::getInstanceByName('blocknewsletter')) {
         self::$smarty->assign('newsletter', (int) $blocknewsletter->active);
     } else {
         self::$smarty->assign('newsletter', 0);
     }
 }
Example #9
0
 /**
  * Assign user profile data
  * @param null
  * @return null
  */
 public function setContentProfile()
 {
     $sup = new SocialUserProfileModel();
     $this->context->smarty->assign('customer', $sup->loadCustomerData($this->context->cookie->id_customer));
     $this->context->smarty->assign('days', Tools::dateDays());
     $this->context->smarty->assign('months', Tools::dateMonths());
     $this->context->smarty->assign('years', Tools::dateYears());
     $no_address = (int) Customer::getAddressesTotalById($this->context->cookie->id_customer);
     if ($no_address != 0) {
         $this->_address = $sup->loadAdressesData($this->context->cookie->id_customer, $sup->getAddressesByCustomerId($this->context->cookie->id_customer), $this->id_lang);
         $this->assignCountries();
     }
     $this->context->smarty->assign('address', $this->_address[0]);
     $this->context->smarty->assign('address_validation', Address::$definition['fields']);
 }
Example #10
0
 /**
  * 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');
 }
 public function preProcess()
 {
     parent::preProcess();
     if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) {
         Tools::redirect('history.php');
     }
     if (Tools::getValue('create_account')) {
         $create_account = 1;
         self::$smarty->assign('email_create', 1);
     }
     if (Tools::isSubmit('SubmitCreate')) {
         if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (Customer::customerExists($email)) {
             $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             $_POST['email'] = $_POST['email_create'];
             unset($_POST['email_create']);
         } else {
             $create_account = 1;
             self::$smarty->assign('email_create', Tools::safeOutput($email));
             $_POST['email'] = $email;
         }
     }
     if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) {
         $create_account = 1;
         if (Tools::isSubmit('submitAccount')) {
             self::$smarty->assign('email_create', 1);
         }
         /* New Guest customer */
         if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
             $this->errors[] = Tools::displayError('You cannot create a guest account.');
         }
         if (!Tools::getValue('is_new_customer', 1)) {
             $_POST['passwd'] = md5(time() . _COOKIE_KEY_);
         }
         if (isset($_POST['guest_email']) and $_POST['guest_email']) {
             $_POST['email'] = $_POST['guest_email'];
         }
         /* Preparing customer */
         $customer = new Customer();
         $lastnameAddress = $_POST['lastname'];
         $firstnameAddress = $_POST['firstname'];
         $_POST['lastname'] = $_POST['customer_lastname'];
         $_POST['firstname'] = $_POST['customer_firstname'];
         //if (!Tools::getValue('phone') AND !Tools::getValue('phone_mobile'))
         //$this->errors[] = Tools::displayError('You must register at least one phone number');
         if ($_POST['passwd'] != $_POST['retype_passwd']) {
             $this->errors[] = Tools::displayError('password and confirmation do not match');
         }
         $this->errors = array_unique(array_merge($this->errors, $customer->validateControler()));
         /*
         // Preparing address 
         $address = new Address();
         $_POST['lastname'] = $lastnameAddress;
         $_POST['firstname'] = $firstnameAddress;
         $address->id_customer = 1;
         $this->errors = array_unique(array_merge($this->errors, $address->validateControler()));
         
         // US customer: normalize the address 
         if($address->id_country == Country::getByIso('US'))
         {
         	include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
         	$normalize = new AddressStandardizationSolution;
         	$address->address1 = $normalize->AddressLineStandardization($address->address1);
         	$address->address2 = $normalize->AddressLineStandardization($address->address2);
         }
         
         $zip_code_format = Country::getZipCodeFormat((int)(Tools::getValue('id_country')));
         if (Country::getNeedZipCode((int)(Tools::getValue('id_country'))))
         {
         	if (($postcode = Tools::getValue('postcode')) AND $zip_code_format)
         	{
         		$zip_regexp = '/^'.$zip_code_format.'$/ui';
         		$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
         		$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
         		$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
         		$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
         		$zip_regexp = str_replace('C', Country::getIsoById((int)(Tools::getValue('id_country'))), $zip_regexp);
         		if (!preg_match($zip_regexp, $postcode))
         			$this->errors[] = '<strong>'.Tools::displayError('Zip/ Postal code').'</strong> '.Tools::displayError('is invalid.').'<br />'.Tools::displayError('Must be typed as follows:').' '.str_replace('C', Country::getIsoById((int)(Tools::getValue('id_country'))), str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
         	}
         	elseif ($zip_code_format)
         		$this->errors[] = '<strong>'.Tools::displayError('Zip/ Postal code').'</strong> '.Tools::displayError('is required.');
         	elseif ($postcode AND !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
         		$this->errors[] = '<strong>'.Tools::displayError('Zip/ Postal code').'</strong> '.Tools::displayError('is invalid.');
         }
         if (Country::isNeedDniByCountryId($address->id_country) AND (!Tools::getValue('dni') OR !Validate::isDniLite(Tools::getValue('dni'))))
         	$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
         elseif (!Country::isNeedDniByCountryId($address->id_country))
         	$address->dni = NULL;
         */
         //create customer and login
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         }
         if (!sizeof($this->errors)) {
             if (Customer::customerExists(Tools::getValue('email'))) {
                 $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             }
             if (Tools::isSubmit('newsletter')) {
                 $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
                 $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
             }
             $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
             if (!sizeof($this->errors)) {
                 //if (!$country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT')) OR !Validate::isLoadedObject($country))
                 //die(Tools::displayError());
                 //if ((int)($country->contains_states) AND !(int)($address->id_state))
                 //$this->errors[] = Tools::displayError('This country requires a state selection.');
                 //else
                 //{
                 $customer->active = 1;
                 /* New Guest customer */
                 if (Tools::isSubmit('is_new_customer')) {
                     $customer->is_guest = !Tools::getValue('is_new_customer', 1);
                 } else {
                     $customer->is_guest = 0;
                 }
                 if (!$customer->add()) {
                     $this->errors[] = Tools::displayError('An error occurred while creating your account.');
                 } else {
                     //award registration points
                     VBRewards::addRegistrationPoints($customer->id);
                     self::$cookie->new_reg = true;
                     self::$cookie->write();
                     //Add coupons to account
                     Tools::addCoupons($customer->id);
                     //$address->id_customer = (int)($customer->id);
                     //if (!$address->add())
                     //$this->errors[] = Tools::displayError('An error occurred while creating your address.');
                     //else
                     //{
                     if (!$customer->is_guest) {
                         //TODO: remove these extra emails
                         /*Mail::Send((int)(self::$cookie->id_lang), 'alert_account', Mail::l('New Customer Registered'),
                         						array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, 
                         						'{passwd}' => Tools::getValue('passwd')), '*****@*****.**', 'Vineet Saxena');
                         		
                         		Mail::Send((int)(self::$cookie->id_lang), 'alert_account', Mail::l('New Customer Registered'),
                         							array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email,
                         							'{passwd}' => Tools::getValue('passwd')), '*****@*****.**', 'Ramakant Sharma');
                         		
                         		*/
                         if ((int) self::$cookie->id_country === 110) {
                             $subject = Mail::l("Welcome to IndusDiva, INR 2500 has been credited to your account");
                             $amount = "INR 2500";
                         } else {
                             $subject = Mail::l("Welcome to IndusDiva, USD 100 has been credited to your account");
                             $amount = "USD 100";
                         }
                         if (!Mail::Send((int) self::$cookie->id_lang, 'account', $subject, array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd'), '{amount}' => $amount), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                             $this->errors[] = Tools::displayError('Cannot send email');
                         }
                     }
                     self::$smarty->assign('confirmation', 1);
                     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;
                     self::$cookie->is_guest = !Tools::getValue('is_new_customer', 1);
                     /* Update cart address */
                     self::$cart->secure_key = $customer->secure_key;
                     //self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
                     //self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
                     self::$cart->update();
                     Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer));
                     if (Tools::isSubmit('ajax')) {
                         $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => true, 'id_customer' => (int) self::$cookie->id_customer, 'token' => Tools::getToken(false));
                         die(Tools::jsonEncode($return));
                     }
                     if ($back = Tools::getValue('back')) {
                         Tools::redirect($back);
                     }
                     Tools::redirect('index.php');
                     //}
                 }
                 //}
             }
         }
         if (sizeof($this->errors)) {
             if (!Tools::getValue('is_new_customer')) {
                 unset($_POST['passwd']);
             }
             if (Tools::isSubmit('ajax')) {
                 $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => false, 'id_customer' => 0);
                 die(Tools::jsonEncode($return));
             }
         }
     }
     if (isset($create_account)) {
         /* Select the most appropriate country */
         if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) {
             $selectedCountry = (int) $_POST['id_country'];
         }
         /* FIXME : language iso and country iso are not similar,
         			 * maybe an associative table with country an language can resolve it,
         			 * But for now it's a bug !
         			 * @see : bug #6968
         			 * @link:http://www.prestashop.com/bug_tracker/view/6968/
         			elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
         			{
         				$array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         				if (Validate::isLanguageIsoCode($array[0]))
         				{
         					$selectedCountry = Country::getByIso($array[0]);
         					if (!$selectedCountry)
         						$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
         				}
         			}*/
         if (!isset($selectedCountry)) {
             $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         }
         $countries = Country::getCountries((int) self::$cookie->id_lang, true);
         self::$smarty->assign(array('countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT')));
         /* Call a hook to display more information on form */
         self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')));
     }
     /* Generate years, months and days */
     if (isset($_POST['years']) and is_numeric($_POST['years'])) {
         $selectedYears = (int) $_POST['years'];
     }
     $years = Tools::dateYears();
     if (isset($_POST['months']) and is_numeric($_POST['months'])) {
         $selectedMonths = (int) $_POST['months'];
     }
     $months = Tools::dateMonths();
     if (isset($_POST['days']) and is_numeric($_POST['days'])) {
         $selectedDays = (int) $_POST['days'];
     }
     $days = Tools::dateDays();
     self::$smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0));
     self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
 }
Example #12
0
 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');
     }
 }
 public function preProcess()
 {
     parent::preProcess();
     $customer = new Customer((int) self::$cookie->id_customer);
     if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) {
         $customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
     }
     if (Tools::isSubmit('submitIdentity')) {
         if (Module::getInstanceByName('blocknewsletter')->active) {
             if (!isset($_POST['optin'])) {
                 $customer->optin = 0;
             }
             if (!isset($_POST['newsletter'])) {
                 $customer->newsletter = 0;
             }
         }
         if (!isset($_POST['id_gender'])) {
             $_POST['id_gender'] = 9;
         }
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         } else {
             $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
             $id_customer_exists = (int) Customer::customerExists(Tools::getValue('email'), true, false);
             if ($id_customer_exists && $id_customer_exists != (int) self::$cookie->id_customer) {
                 $this->errors[] = Tools::displayError('An account is already registered with this e-mail.');
             }
             $_POST['old_passwd'] = trim($_POST['old_passwd']);
             if (empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
                 $this->errors[] = Tools::displayError('Your password is incorrect.');
             } elseif ($_POST['passwd'] != $_POST['confirmation']) {
                 $this->errors[] = Tools::displayError('Password and confirmation do not match');
             } else {
                 $prev_id_default_group = $customer->id_default_group;
                 $this->errors = array_unique(array_merge($this->errors, $customer->validateController(true, true)));
             }
             if (!count($this->errors)) {
                 $customer->id_default_group = (int) $prev_id_default_group;
                 $customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
                 if (Tools::getValue('passwd')) {
                     self::$cookie->passwd = $customer->passwd;
                 }
                 if ($customer->update()) {
                     self::$cookie->customer_lastname = $customer->lastname;
                     self::$cookie->customer_firstname = $customer->firstname;
                     self::$smarty->assign('confirmation', 1);
                 } else {
                     $this->errors[] = Tools::displayError('Cannot update information');
                 }
             }
         }
     } else {
         $_POST = array_map('stripslashes', $customer->getFields());
     }
     $birthday = $customer->birthday ? explode('-', $customer->birthday) : array('-', '-', '-');
     /* Generate years, months and days */
     self::$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));
     self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
 }
Example #14
0
 /**
  * Assign date var to smarty
  */
 protected function assignDate()
 {
     $selectedYears = (int) Tools::getValue('years', 0);
     $years = Tools::dateYears();
     $selectedMonths = (int) Tools::getValue('months', 0);
     $months = Tools::dateMonths();
     $selectedDays = (int) Tools::getValue('days', 0);
     $days = Tools::dateDays();
     $this->context->smarty->assign(array('one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'onr_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'years' => $years, 'sl_year' => $selectedYears, 'months' => $months, 'sl_month' => $selectedMonths, 'days' => $days, 'sl_day' => $selectedDays));
 }
Example #15
0
 /**
  * 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');
 }
Example #16
0
 /**
  * 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');
 }
 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();
 }
 public function preProcess()
 {
     parent::preProcess();
     $customer = new Customer((int) self::$cookie->id_customer);
     if (sizeof($_POST)) {
         $exclusion = array('secure_key', 'old_passwd', 'passwd', 'active', 'date_add', 'date_upd', 'last_passwd_gen', 'newsletter_date_add', 'id_default_group');
         $fields = $customer->getFields();
         foreach ($fields as $key => $value) {
             if (!in_array($key, $exclusion)) {
                 $customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0;
             }
         }
     }
     if (isset($_POST['years']) and isset($_POST['months']) and isset($_POST['days'])) {
         $customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
     }
     if (Tools::isSubmit('submitIdentity')) {
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         } else {
             $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
             $_POST['old_passwd'] = trim($_POST['old_passwd']);
             if (empty($_POST['old_passwd']) or Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
                 $this->errors[] = Tools::displayError('Your password is incorrect.');
             } elseif ($_POST['passwd'] != $_POST['confirmation']) {
                 $this->errors[] = Tools::displayError('Password and confirmation do not match');
             } else {
                 $prev_id_default_group = $customer->id_default_group;
                 $this->errors = $customer->validateControler();
             }
             if (!sizeof($this->errors)) {
                 $customer->id_default_group = (int) $prev_id_default_group;
                 $customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
                 if (Tools::getValue('passwd')) {
                     self::$cookie->passwd = $customer->passwd;
                 }
                 if ($customer->update()) {
                     self::$cookie->customer_lastname = $customer->lastname;
                     self::$cookie->customer_firstname = $customer->firstname;
                     self::$smarty->assign('confirmation', 1);
                 } else {
                     $this->errors[] = Tools::displayError('Cannot update information');
                 }
             }
         }
     } else {
         $_POST = array_map('stripslashes', $customer->getFields());
     }
     if ($customer->birthday) {
         $birthday = explode('-', $customer->birthday);
     } else {
         $birthday = array('-', '-', '-');
     }
     /* Generate years, months and days */
     self::$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));
     self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
 }
 public function renderForm()
 {
     $this->fields_value = array('type_text' => 'with value', 'type_text_readonly' => 'with value that you can\'t edit', 'type_switch' => 1, 'days' => 17, 'months' => 3, 'years' => 2014, 'groupBox_1' => false, 'groupBox_2' => true, 'groupBox_3' => false, 'groupBox_4' => true, 'groupBox_5' => true, 'groupBox_6' => false, 'type_color' => '#8BC954', 'tab_note' => 'The tabs are always pushed to the top of the form, wherever they are in the fields_form array.', 'type_free' => '<p class="form-control-static">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc lacinia in enim iaculis malesuada. Quisque congue fermentum leo et porta. Pellentesque a quam dui. Pellentesque sed augue id sem aliquet faucibus eu vel odio. Nullam non libero volutpat, pulvinar turpis non, gravida mauris. Nullam tincidunt id est at euismod. Quisque euismod quam in pellentesque mollis. Nulla suscipit porttitor massa, nec eleifend risus egestas in. Aenean luctus porttitor tempus. Morbi dolor leo, dictum id interdum vel, semper ac est. Maecenas justo augue, accumsan in velit nec, consectetur fringilla orci. Nunc ut ante erat. Curabitur dolor augue, eleifend a luctus non, aliquet a mi. Curabitur ultricies lectus in rhoncus sodales. Maecenas quis dictum erat. Suspendisse blandit lacus sed felis facilisis, in interdum quam congue.<p>');
     $this->fields_form = array('legend' => array('title' => 'patterns of helper form.tpl', 'icon' => 'icon-edit'), 'tabs' => array('small' => 'Small Inputs', 'large' => 'Large Inputs'), 'description' => 'You can use image instead of icon for the title.', 'input' => array(array('type' => 'text', 'label' => 'simple input text', 'name' => 'type_text'), array('type' => 'text', 'label' => 'input text with desc', 'name' => 'type_text_desc', 'desc' => 'desc input text'), array('type' => 'text', 'label' => 'required input text', 'name' => 'type_text_required', 'required' => true), array('type' => 'text', 'label' => 'input text with hint', 'name' => 'type_text_hint', 'hint' => 'hint input text'), array('type' => 'text', 'label' => 'input text with prefix', 'name' => 'type_text_prefix', 'prefix' => 'prefix'), array('type' => 'text', 'label' => 'input text with suffix', 'name' => 'type_text_suffix', 'suffix' => 'suffix'), array('type' => 'text', 'label' => 'input text with placeholder', 'name' => 'type_text_placeholder', 'placeholder' => 'placeholder'), array('type' => 'text', 'label' => 'input text with character counter', 'name' => 'type_text_maxchar', 'maxchar' => 30), array('type' => 'text', 'lang' => true, 'label' => 'input text multilang', 'name' => 'type_text_multilang'), array('type' => 'text', 'label' => 'input readonly', 'readonly' => true, 'name' => 'type_text_readonly'), array('type' => 'text', 'label' => 'input fixed-width-xs', 'name' => 'type_text_xs', 'class' => 'input fixed-width-xs'), array('type' => 'text', 'label' => 'input fixed-width-sm', 'name' => 'type_text_sm', 'class' => 'input fixed-width-sm'), array('type' => 'text', 'label' => 'input fixed-width-md', 'name' => 'type_text_md', 'class' => 'input fixed-width-md'), array('type' => 'text', 'label' => 'input fixed-width-lg', 'name' => 'type_text_lg', 'class' => 'input fixed-width-lg'), array('type' => 'text', 'label' => 'input fixed-width-xl', 'name' => 'type_text_xl', 'class' => 'input fixed-width-xl'), array('type' => 'text', 'label' => 'input fixed-width-xxl', 'name' => 'type_text_xxl', 'class' => 'fixed-width-xxl'), array('type' => 'text', 'label' => 'input fixed-width-sm', 'name' => 'type_text_sm', 'class' => 'input fixed-width-sm', 'tab' => 'small'), array('type' => 'text', 'label' => 'input fixed-width-md', 'name' => 'type_text_md', 'class' => 'input fixed-width-md', 'tab' => 'small'), array('type' => 'text', 'label' => 'input fixed-width-lg', 'name' => 'type_text_lg', 'class' => 'input fixed-width-lg', 'tab' => 'large'), array('type' => 'text', 'label' => 'input fixed-width-xl', 'name' => 'type_text_xl', 'class' => 'input fixed-width-xl', 'tab' => 'large'), array('type' => 'text', 'label' => 'input fixed-width-xxl', 'name' => 'type_text_xxl', 'class' => 'fixed-width-xxl', 'tab' => 'large'), array('type' => 'free', 'label' => 'About tabs', 'name' => 'tab_note', 'tab' => 'small'), array('type' => 'text', 'label' => 'input fixed-width-md with prefix', 'name' => 'type_text_md', 'class' => 'input fixed-width-md', 'prefix' => 'prefix'), array('type' => 'text', 'label' => 'input fixed-width-md with sufix', 'name' => 'type_text_md', 'class' => 'input fixed-width-md', 'suffix' => 'suffix'), array('type' => 'tags', 'label' => 'input tags', 'name' => 'type_text_tags'), array('type' => 'textbutton', 'label' => 'input with button', 'name' => 'type_textbutton', 'button' => array('label' => 'do something', 'attributes' => array('onclick' => 'alert(\'something done\');'))), array('type' => 'select', 'label' => 'select', 'name' => 'type_select', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name')), array('type' => 'select', 'label' => 'select with chosen', 'name' => 'type_select_chosen', 'class' => 'chosen', 'options' => array('query' => Country::getCountries((int) Context::getContext()->cookie->id_lang), 'id' => 'id_zone', 'name' => 'name')), array('type' => 'select', 'label' => 'select multiple with chosen', 'name' => 'type_select_multiple_chosen', 'class' => 'chosen', 'multiple' => true, 'options' => array('query' => Country::getCountries((int) Context::getContext()->cookie->id_lang), 'id' => 'id_zone', 'name' => 'name')), array('type' => 'radio', 'label' => 'radios', 'name' => 'type_radio', 'values' => array(array('id' => 'type_male', 'value' => 0, 'label' => 'first'), array('id' => 'type_female', 'value' => 1, 'label' => 'second'), array('id' => 'type_neutral', 'value' => 2, 'label' => 'third'))), array('type' => 'checkbox', 'label' => 'checkbox', 'name' => 'type_checkbox', 'values' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name')), array('type' => 'switch', 'label' => 'switch', 'name' => 'type_switch', 'values' => array(array('id' => 'type_switch_on', 'value' => 1), array('id' => 'type_switch_off', 'value' => 0))), array('type' => 'switch', 'label' => 'switch disabled', 'name' => 'type_switch_disabled', 'disabled' => 'true', 'values' => array(array('id' => 'type_switch_disabled_on', 'value' => 1), array('id' => 'type_switch_disabled_off', 'value' => 0))), array('type' => 'textarea', 'label' => 'text area (with autoresize)', 'name' => 'type_textarea'), array('type' => 'textarea', 'label' => 'text area with rich text editor', 'name' => 'type_textarea_rte', 'autoload_rte' => true), array('type' => 'password', 'label' => 'input password', 'name' => 'type_password'), array('type' => 'birthday', 'label' => 'input birthday', 'name' => 'type_birthday', 'options' => array('days' => Tools::dateDays(), 'months' => Tools::dateMonths(), 'years' => Tools::dateYears())), array('type' => 'group', 'label' => 'group', 'name' => 'type_group', 'values' => Group::getGroups(Context::getContext()->language->id)), array('type' => 'categories', 'label' => 'tree categories', 'name' => 'type_categories', 'tree' => array('id' => 'id_category', 'name' => 'name_category', 'selected_categories' => array(3))), array('type' => 'file', 'label' => 'input file', 'name' => 'type_file'), array('type' => 'color', 'label' => 'input color', 'name' => 'type_color'), array('type' => 'date', 'label' => 'input date', 'name' => 'type_date'), array('type' => 'datetime', 'label' => 'input date and time', 'name' => 'type_datetime'), array('type' => 'html', 'name' => 'html_data', 'html_content' => '<hr><strong>html:</strong> for writing free html like this <span class="label label-danger">i\'m a label</span> <span class="badge badge-info">i\'m a badge</span> <button type="button" class="btn btn-default">i\'m a button</button><hr>'), array('type' => 'free', 'label' => 'input free', 'name' => 'type_free')), 'submit' => array('title' => 'Save'), 'buttons' => array());
     return parent::renderForm();
 }
Example #20
0
    public function displayForm()
    {
        global $currentIndex;
        $obj = $this->loadObject(true);
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
        $customer_groups = $obj->getGroups();
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" class="width3" autocomplete="off">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/tab-customers.gif" />' . $this->l('Customer') . '</legend>
				<label>' . $this->l('Gender:') . ' </label>
				<div class="margin-form">
					<input type="radio" size="33" name="id_gender" id="gender_1" value="1" ' . ($this->getFieldValue($obj, 'id_gender') == 1 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_1"> ' . $this->l('Male') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_2" value="2" ' . ($this->getFieldValue($obj, 'id_gender') == 2 ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_2"> ' . $this->l('Female') . '</label>
					<input type="radio" size="33" name="id_gender" id="gender_3" value="9" ' . (($this->getFieldValue($obj, 'id_gender') == 9 or !$this->getFieldValue($obj, 'id_gender')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="gender_3"> ' . $this->l('Unknown') . '</label>
				</div>
				<label>' . $this->l('Last name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
				</div>
				<label>' . $this->l('First name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '"/> <sup>*</sup>
					<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' 0-9!<>,;?=+()@#"�{}_$%:<span class="hint-pointer">&nbsp;</span></span>
				</div>
				<label>' . $this->l('Password:'******' </label>
				<div class="margin-form">
					<input type="password" size="33" name="passwd" value="" /> ' . (!$obj->id ? '<sup>*</sup>' : '') . '
					<p>' . ($obj->id ? $this->l('Leave blank if no change') : $this->l('5 characters min., only letters, numbers, or') . ' -_') . '</p>
				</div>
				<label>' . $this->l('E-mail address:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="email" value="' . htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				';
        if ($obj->isVendor()) {
            $classifications = $this->getFieldValue($obj, 'classifications');
            $classifications = array_flip(explode(",", $classifications));
            echo '
					<label>Faks</label>
					<div class="margin-form">
						<input type="text" size="10" name="fax" value="' . htmlentities($this->getFieldValue($obj, 'fax'), ENT_COMPAT, 'UTF-8') . '" />
					</div>
					
					<label>Åpningstider</label>
					<div class="margin-form">
						<textarea name="hours" cols="31" rows="3">' . htmlentities($this->getFieldValue($obj, 'hours'), ENT_COMPAT, 'UTF-8') . '</textarea>
					</div>
					
					<label>Klassifikasjoner</label>
					<div class="margin-form">
						<input type="checkbox" name="classifications[broderi]" value="1"' . (isset($classifications['broderi']) ? ' checked' : '') . '/> Ekspert på broderisymaskiner og programvare<br/>
						<input type="checkbox" name="classifications[service]" value="1"' . (isset($classifications['service']) ? ' checked' : '') . '/> Eget serviceverksted<br/>
						<input type="checkbox" name="classifications[kurs]"    value="1"' . (isset($classifications['kurs']) ? ' checked' : '') . '/> Driver kursvirksomhet
					</div>
					
					<label>Blogg</label>
					<div class="margin-form">
						<input type="text" size="33" name="blog_url" value="' . htmlentities($this->getFieldValue($obj, 'blog_url'), ENT_COMPAT, 'UTF-8') . '" />
					</div>
					';
        }
        echo '
				<label>' . $this->l('Birthday:') . ' </label>';
        $sl_year = $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0;
        $years = Tools::dateYears();
        $sl_month = $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0;
        $months = Tools::dateMonths();
        $sl_day = $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0;
        $days = Tools::dateDays();
        $tab_months = array($this->l('January'), $this->l('February'), $this->l('March'), $this->l('April'), $this->l('May'), $this->l('June'), $this->l('July'), $this->l('August'), $this->l('September'), $this->l('October'), $this->l('November'), $this->l('December'));
        echo '
					<div class="margin-form">
					<select name="days">
						<option value="">-</option>';
        foreach ($days as $v) {
            echo '<option value="' . $v . '" ' . ($sl_day == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '
					</select>
					<select name="months">
						<option value="">-</option>';
        foreach ($months as $k => $v) {
            echo '<option value="' . $k . '" ' . ($sl_month == $k ? 'selected="selected"' : '') . '>' . $this->l($v) . '</option>';
        }
        echo '</select>
					<select name="years">
						<option value="">-</option>';
        foreach ($years as $v) {
            echo '<option value="' . $v . '" ' . ($sl_year == $v ? 'selected="selected"' : '') . '>' . $v . '</option>';
        }
        echo '</select>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this customer to log in') . '</p>
				</div>
				<label>' . $this->l('Newsletter:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="newsletter" id="newsletter_on" value="1" ' . ($this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="newsletter" id="newsletter_off" value="0" ' . (!$this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="newsletter_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your newsletter via e-mail') . '</p>
				</div>
				<label>' . $this->l('Opt-in:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="optin" id="optin_on" value="1" ' . ($this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="optin" id="optin_off" value="0" ' . (!$this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="optin_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Customer will receive your ads via e-mail') . '</p>
				</div>
				<label>' . $this->l('Groups:') . ' </label>
				<div class="margin-form">';
        $groups = Group::getGroups($defaultLanguage, true);
        if (sizeof($groups)) {
            echo '
					<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)" /></th>
							<th>' . $this->l('ID') . '</th>
							<th>' . $this->l('Group name') . '</th>
						</tr>';
            $irow = 0;
            foreach ($groups as $group) {
                echo '
							<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
								<td>' . ($group['id_group'] != 1 ? '<input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $group['id_group'] . '" value="' . $group['id_group'] . '" ' . (in_array($group['id_group'], $customer_groups) ? 'checked="checked" ' : '') . '/>' : '') . '</td>
								<td>' . $group['id_group'] . '</td>
								<td><label for="groupBox_' . $group['id_group'] . '" class="t">' . $group['name'] . '</label></td>
							</tr>';
            }
            echo '
					</table>
					<p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of groups to which the customer is to be member') . '<sup> *</sup></p>
					';
        } else {
            echo '<p>' . $this->l('No group created') . '</p>';
        }
        echo '
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
Example #21
0
 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');
         }
     }
 }
Example #22
0
function displayAccount()
{
    global $cookie, $result, $email, $payerID, $errors, $ppExpress, $smarty;
    // Customer does not exists, signup form
    // If customer already logged, unlog him
    if ($cookie->isLogged(true)) {
        $cookie->makeNewLog();
    }
    // Generate years, months and days
    if (isset($_POST['years']) and is_numeric($_POST['years'])) {
        $selectedYears = (int) $_POST['years'];
    }
    $years = Tools::dateYears();
    if (isset($_POST['months']) and is_numeric($_POST['months'])) {
        $selectedMonths = (int) $_POST['months'];
    }
    $months = Tools::dateMonths();
    if (isset($_POST['days']) and is_numeric($_POST['days'])) {
        $selectedDays = (int) $_POST['days'];
    }
    $days = Tools::dateDays();
    // Select the most appropriate country
    if (Tools::getValue('id_country')) {
        $selectedCountry = (int) Tools::getValue('id_country');
    } else {
        if ((int) $result['COUNTRYCODE']) {
            $selectedCountry = Country::getByIso(strval($result['COUNTRYCODE']));
        }
    }
    $countries = Country::getCountries((int) $cookie->id_lang, true);
    // Smarty assigns
    $smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'email' => $email, 'firstname' => Tools::getValue('customer_firstname') ? Tools::htmlentitiesUTF8(strval(Tools::getValue('customer_firstname'))) : $result['FIRSTNAME'], 'lastname' => Tools::getValue('customer_lastname') ? Tools::htmlentitiesUTF8(strval(Tools::getValue('customer_lastname'))) : $result['LASTNAME'], 'street' => Tools::getValue('address1') ? Tools::htmlentitiesUTF8(strval(Tools::getValue('address1'))) : (isset($result['SHIPTOSTREET']) ? $result['SHIPTOSTREET'] : ''), 'city' => Tools::getValue('city') ? Tools::htmlentitiesUTF8(strval(Tools::getValue('city'))) : (isset($result['SHIPTOCITY']) ? $result['SHIPTOCITY'] : ''), 'zip' => Tools::getValue('postcode') ? Tools::htmlentitiesUTF8(strval(Tools::getValue('postcode'))) : (isset($result['SHIPTOZIP']) ? $result['SHIPTOZIP'] : ''), 'payerID' => $payerID, 'ppToken' => strval($cookie->paypal_token), 'errors' => $errors));
    // Display all and exit
    include _PS_ROOT_DIR_ . '/header.php';
    echo $ppExpress->display('paypal.php', 'express/authentication.tpl');
    include _PS_ROOT_DIR_ . '/footer.php';
    die;
}
 /**
  * Assign date var to smarty
  */
 protected function assignDate()
 {
     // Generate years, months and days
     if (isset($_POST['years']) && is_numeric($_POST['years'])) {
         $selectedYears = (int) $_POST['years'];
     }
     $years = Tools::dateYears();
     if (isset($_POST['months']) && is_numeric($_POST['months'])) {
         $selectedMonths = (int) $_POST['months'];
     }
     $months = Tools::dateMonths();
     if (isset($_POST['days']) && is_numeric($_POST['days'])) {
         $selectedDays = (int) $_POST['days'];
     }
     $days = Tools::dateDays();
     $this->context->smarty->assign(array('one_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'onr_phone_at_least' => (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0));
 }
 public function preProcess()
 {
     parent::preProcess();
     if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) {
         Tools::redirect('my-account.php');
     }
     if (Tools::getValue('create_account')) {
         $create_account = 1;
         self::$smarty->assign('email_create', 1);
     }
     if (Tools::isSubmit('SubmitCreate')) {
         if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (Customer::customerExists($email)) {
             $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             $_POST['email'] = $_POST['email_create'];
             unset($_POST['email_create']);
         } else {
             $create_account = 1;
             self::$smarty->assign('email_create', Tools::safeOutput($email));
             $_POST['email'] = $email;
         }
     }
     if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) {
         $create_account = 1;
         if (Tools::isSubmit('submitAccount')) {
             self::$smarty->assign('email_create', 1);
         }
         /* New Guest customer */
         if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
             $this->errors[] = Tools::displayError('You cannot create a guest account.');
         }
         if (!Tools::getValue('is_new_customer', 1)) {
             $_POST['passwd'] = md5(time() . _COOKIE_KEY_);
         }
         if (isset($_POST['guest_email']) and $_POST['guest_email']) {
             $_POST['email'] = $_POST['guest_email'];
         }
         /* Preparing customer */
         $customer = new Customer();
         $lastnameAddress = $_POST['lastname'];
         $firstnameAddress = $_POST['firstname'];
         $_POST['lastname'] = $_POST['customer_lastname'];
         $_POST['firstname'] = $_POST['customer_firstname'];
         if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) {
             $this->errors[] = Tools::displayError('You must register at least one phone number');
         }
         if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
             $this->errors[] = Tools::displayError('Invalid date of birth');
         }
         $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
         $this->errors = array_unique(array_merge($this->errors, $customer->validateControler()));
         /* Preparing address */
         $address = new Address();
         $_POST['lastname'] = $lastnameAddress;
         $_POST['firstname'] = $firstnameAddress;
         $address->id_customer = 1;
         $this->errors = array_unique(array_merge($this->errors, $address->validateControler()));
         /* US customer: normalize the address */
         if ($address->id_country == Country::getByIso('US')) {
             include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php';
             $normalize = new AddressStandardizationSolution();
             $address->address1 = $normalize->AddressLineStandardization($address->address1);
             $address->address2 = $normalize->AddressLineStandardization($address->address2);
         }
         $zip_code_format = Country::getZipCodeFormat((int) Tools::getValue('id_country'));
         if (Country::getNeedZipCode((int) Tools::getValue('id_country'))) {
             if ($postcode = Tools::getValue('postcode') and $zip_code_format) {
                 $zip_regexp = '/^' . $zip_code_format . '$/ui';
                 $zip_regexp = str_replace(' ', '( |)', $zip_regexp);
                 $zip_regexp = str_replace('-', '(-|)', $zip_regexp);
                 $zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
                 $zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
                 $zip_regexp = str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), $zip_regexp);
                 if (!preg_match($zip_regexp, $postcode)) {
                     $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
                 }
             } elseif ($zip_code_format) {
                 $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.');
             } elseif ($postcode and !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode)) {
                 $this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.');
             }
         }
         if (Country::isNeedDniByCountryId($address->id_country) and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) {
             $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
         } elseif (!Country::isNeedDniByCountryId($address->id_country)) {
             $address->dni = NULL;
         }
         if (!sizeof($this->errors)) {
             if (Customer::customerExists(Tools::getValue('email'))) {
                 $this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
             }
             if (Tools::isSubmit('newsletter')) {
                 $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
                 $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
             }
             if (!sizeof($this->errors)) {
                 if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) or !Validate::isLoadedObject($country)) {
                     die(Tools::displayError());
                 }
                 if ((int) $country->contains_states and !(int) $address->id_state) {
                     $this->errors[] = Tools::displayError('This country requires a state selection.');
                 } else {
                     $customer->active = 1;
                     /* New Guest customer */
                     if (Tools::isSubmit('is_new_customer')) {
                         $customer->is_guest = !Tools::getValue('is_new_customer', 1);
                     } else {
                         $customer->is_guest = 0;
                     }
                     if (!$customer->add()) {
                         $this->errors[] = Tools::displayError('An error occurred while creating your account.');
                     } else {
                         $address->id_customer = (int) $customer->id;
                         if (!$address->add()) {
                             $this->errors[] = Tools::displayError('An error occurred while creating your address.');
                         } else {
                             if (!$customer->is_guest) {
                                 if (!Mail::Send((int) self::$cookie->id_lang, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                                     $this->errors[] = Tools::displayError('Cannot send email');
                                 }
                             }
                             self::$smarty->assign('confirmation', 1);
                             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;
                             self::$cookie->is_guest = !Tools::getValue('is_new_customer', 1);
                             /* Update cart address */
                             self::$cart->secure_key = $customer->secure_key;
                             self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id);
                             self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id);
                             self::$cart->update();
                             Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer));
                             if (Tools::isSubmit('ajax')) {
                                 $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => true, 'id_customer' => (int) self::$cookie->id_customer, 'id_address_delivery' => self::$cart->id_address_delivery, 'id_address_invoice' => self::$cart->id_address_invoice, 'token' => Tools::getToken(false));
                                 die(Tools::jsonEncode($return));
                             }
                             if ($back = Tools::getValue('back')) {
                                 Tools::redirect($back);
                             }
                             Tools::redirect('my-account.php');
                         }
                     }
                 }
             }
         }
         if (sizeof($this->errors)) {
             if (!Tools::getValue('is_new_customer')) {
                 unset($_POST['passwd']);
             }
             if (Tools::isSubmit('ajax')) {
                 $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'isSaved' => false, 'id_customer' => 0);
                 die(Tools::jsonEncode($return));
             }
         }
     }
     if (Tools::isSubmit('SubmitLogin')) {
         Module::hookExec('beforeAuthentication');
         $passwd = trim(Tools::getValue('passwd'));
         $email = trim(Tools::getValue('email'));
         if (empty($email)) {
             $this->errors[] = Tools::displayError('E-mail address required');
         } elseif (!Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Invalid e-mail address');
         } elseif (empty($passwd)) {
             $this->errors[] = Tools::displayError('Password is required');
         } elseif (Tools::strlen($passwd) > 32) {
             $this->errors[] = Tools::displayError('Password is too long');
         } elseif (!Validate::isPasswd($passwd)) {
             $this->errors[] = Tools::displayError('Invalid password');
         } else {
             $customer = new Customer();
             $authentication = $customer->getByEmail(trim($email), trim($passwd));
             if (!$authentication or !$customer->id) {
                 /* Handle brute force attacks */
                 sleep(1);
                 $this->errors[] = Tools::displayError('Authentication failed');
             } else {
                 self::$cookie->id_compare = isset(self::$cookie->id_compare) ? self::$cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id);
                 self::$cookie->id_customer = (int) $customer->id;
                 self::$cookie->customer_lastname = $customer->lastname;
                 self::$cookie->customer_firstname = $customer->firstname;
                 self::$cookie->id_default_group = $customer->id_default_group;
                 self::$cookie->logged = 1;
                 self::$cookie->is_guest = $customer->isGuest();
                 self::$cookie->passwd = $customer->passwd;
                 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);
                 }
                 /* Update cart address */
                 self::$cart->id_carrier = 0;
                 self::$cart->id_address_delivery = Address::getFirstCustomerAddressId((int) $customer->id);
                 self::$cart->id_address_invoice = Address::getFirstCustomerAddressId((int) $customer->id);
                 // If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
                 self::$cart->secure_key = $customer->secure_key;
                 self::$cart->update();
                 Module::hookExec('authentication');
                 if (!Tools::isSubmit('ajax')) {
                     if ($back = Tools::getValue('back')) {
                         Tools::redirect($back);
                     }
                     Tools::redirect('my-account.php');
                 }
             }
         }
         if (Tools::isSubmit('ajax')) {
             $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'token' => Tools::getToken(false));
             die(Tools::jsonEncode($return));
         }
     }
     if (isset($create_account)) {
         /* Select the most appropriate country */
         if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) {
             $selectedCountry = (int) $_POST['id_country'];
         }
         /* FIXME : language iso and country iso are not similar,
         			 * maybe an associative table with country an language can resolve it,
         			 * But for now it's a bug !
         			 * @see : bug #6968
         			 * @link:http://www.prestashop.com/bug_tracker/view/6968/
         			elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
         			{
         				$array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         				if (Validate::isLanguageIsoCode($array[0]))
         				{
         					$selectedCountry = Country::getByIso($array[0]);
         					if (!$selectedCountry)
         						$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
         				}
         			}*/
         if (!isset($selectedCountry)) {
             $selectedCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
         }
         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('countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0, 'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT')));
         /* Call a hook to display more information on form */
         self::$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')));
     }
     /* Generate years, months and days */
     if (isset($_POST['years']) and is_numeric($_POST['years'])) {
         $selectedYears = (int) $_POST['years'];
     }
     $years = Tools::dateYears();
     if (isset($_POST['months']) and is_numeric($_POST['months'])) {
         $selectedMonths = (int) $_POST['months'];
     }
     $months = Tools::dateMonths();
     if (isset($_POST['days']) and is_numeric($_POST['days'])) {
         $selectedDays = (int) $_POST['days'];
     }
     $days = Tools::dateDays();
     self::$smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0));
     self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
 }
 /**
  * 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');
     }
 }
Example #26
0
            $cookie->id_address_delivery = $id_address;
            $cookie->id_address_invoice = $id_address;
            Module::hookExec('authentication');
            if ($back = Tools::getValue('back')) {
                Tools::redirect($back);
            }
            Tools::redirect('my-account.php');
        }
    }
}
if (isset($create_account)) {
    /* Generate years, months and days */
    if (isset($_POST['years']) and is_numeric($_POST['years'])) {
        $selectedYears = intval($_POST['years']);
    }
    $years = Tools::dateYears();
    if (isset($_POST['months']) and is_numeric($_POST['months'])) {
        $selectedMonths = intval($_POST['months']);
    }
    $months = Tools::dateMonths();
    if (isset($_POST['days']) and is_numeric($_POST['days'])) {
        $selectedDays = intval($_POST['days']);
    }
    $days = Tools::dateDays();
    /* Select the most appropriate country */
    if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) {
        $selectedCountry = intval($_POST['id_country']);
    } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
        if (Validate::isLanguageIsoCode($array[0])) {
            $selectedCountry = Country::getByIso($array[0]);
Example #27
0
 /**
  * Assign date var to smarty
  */
 protected function assignDate()
 {
     // Generate years, months and days
     if (isset($_POST['years']) && is_numeric($_POST['years'])) {
         $selectedYears = (int) $_POST['years'];
     }
     $years = Tools::dateYears();
     if (isset($_POST['months']) && is_numeric($_POST['months'])) {
         $selectedMonths = (int) $_POST['months'];
     }
     $months = Tools::dateMonths();
     if (isset($_POST['days']) && is_numeric($_POST['days'])) {
         $selectedDays = (int) $_POST['days'];
     }
     $days = Tools::dateDays();
     $this->context->smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0));
 }