本文整理汇总了PHP中Tools::dateYears方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::dateYears方法的具体用法?PHP Tools::dateYears怎么用?PHP Tools::dateYears使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::dateYears方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
/**
* 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');
}
示例2: initContent
/**
* 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');
}
示例3: initContent
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));
//.........这里部分代码省略.........
示例4: intval
$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';
示例5: displayForm
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"> </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"> </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) {
//.........这里部分代码省略.........
示例6: array_map
$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';
示例7: renderForm
public function renderForm()
{
/** @var Customer $obj */
if (!($obj = $this->loadObject(true))) {
return;
}
$genders = Gender::getGenders();
$list_genders = array();
foreach ($genders as $key => $gender) {
/** @var Gender $gender */
$list_genders[$key]['id'] = 'gender_' . $gender->id;
$list_genders[$key]['value'] = $gender->id;
$list_genders[$key]['label'] = $gender->name;
}
$years = Tools::dateYears();
$months = Tools::dateMonths();
$days = Tools::dateDays();
$groups = Group::getGroups($this->default_form_language, true);
$this->fields_form = array('legend' => array('title' => $this->l('Customer'), 'icon' => 'icon-user'), 'input' => array(array('type' => 'radio', 'label' => $this->l('Social title'), 'name' => 'id_gender', 'required' => false, 'class' => 't', 'values' => $list_genders), array('type' => 'text', 'label' => $this->l('First name'), 'name' => 'firstname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"°{}_$%:'), array('type' => 'text', 'label' => $this->l('Last name'), 'name' => 'lastname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!<>,;?=+()@#"°{}_$%:'), array('type' => 'text', 'prefix' => '<i class="icon-envelope-o"></i>', 'label' => $this->l('Email address'), 'name' => 'email', 'col' => '4', 'required' => true, 'autocomplete' => false), array('type' => 'password', 'label' => $this->l('Password'), 'name' => 'passwd', 'required' => $obj->id ? false : true, 'col' => '4', 'hint' => $obj->id ? $this->l('Leave this field blank if there\'s no change.') : sprintf($this->l('Password should be at least %s characters long.'), Validate::PASSWORD_LENGTH)), array('type' => 'birthday', 'label' => $this->l('Birthday'), 'name' => 'birthday', 'options' => array('days' => $days, 'months' => $months, 'years' => $years)), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Enable or disable customer login.')), array('type' => 'switch', 'label' => $this->l('Newsletter'), 'name' => 'newsletter', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'newsletter_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'newsletter_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_NWSL')), 'hint' => $this->l('This customer will receive your newsletter via email.')), array('type' => 'switch', 'label' => $this->l('Opt-in'), 'name' => 'optin', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'optin_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'optin_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'disabled' => (bool) (!Configuration::get('PS_CUSTOMER_OPTIN')), 'hint' => $this->l('This customer will receive your ads via email.'))));
// if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups
if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) {
$visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP');
$guest_group = Configuration::get('PS_GUEST_GROUP');
foreach ($groups as $key => $g) {
if (in_array($g['id_group'], array($visitor_group, $guest_group))) {
unset($groups[$key]);
}
}
}
$this->fields_form['input'] = array_merge($this->fields_form['input'], array(array('type' => 'group', 'label' => $this->l('Group access'), 'name' => 'groupBox', 'values' => $groups, 'required' => true, 'col' => '6', 'hint' => $this->l('Select all the groups that you would like to apply to this customer.')), array('type' => 'select', 'label' => $this->l('Default customer group'), 'name' => 'id_default_group', 'options' => array('query' => $groups, 'id' => 'id_group', 'name' => 'name'), 'col' => '4', 'hint' => array($this->l('This group will be the user\'s default group.'), $this->l('Only the discount for the selected group will be applied to this customer.')))));
// if customer is a guest customer, password hasn't to be there
if ($obj->id && ($obj->is_guest && $obj->id_default_group == Configuration::get('PS_GUEST_GROUP'))) {
foreach ($this->fields_form['input'] as $k => $field) {
if ($field['type'] == 'password') {
array_splice($this->fields_form['input'], $k, 1);
}
}
}
if (Configuration::get('PS_B2B_ENABLE')) {
$risks = Risk::getRisks();
$list_risks = array();
foreach ($risks as $key => $risk) {
/** @var Risk $risk */
$list_risks[$key]['id_risk'] = (int) $risk->id;
$list_risks[$key]['name'] = $risk->name;
}
$this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company');
$this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('SIRET'), 'name' => 'siret');
$this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('APE'), 'name' => 'ape');
$this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Website'), 'name' => 'website');
$this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Allowed outstanding amount'), 'name' => 'outstanding_allow_amount', 'hint' => $this->l('Valid characters:') . ' 0-9', 'suffix' => $this->context->currency->sign);
$this->fields_form['input'][] = array('type' => 'text', 'label' => $this->l('Maximum number of payment days'), 'name' => 'max_payment_days', 'hint' => $this->l('Valid characters:') . ' 0-9');
$this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Risk rating'), 'name' => 'id_risk', 'required' => false, 'class' => 't', 'options' => array('query' => $list_risks, 'id' => 'id_risk', 'name' => 'name'));
}
$this->fields_form['submit'] = array('title' => $this->l('Save'));
$birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
$this->fields_value = array('years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0, 'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0, 'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0);
// Added values of object Group
if (!Validate::isUnsignedId($obj->id)) {
$customer_groups = array();
} else {
$customer_groups = $obj->getGroups();
}
$customer_groups_ids = array();
if (is_array($customer_groups)) {
foreach ($customer_groups as $customer_group) {
$customer_groups_ids[] = $customer_group;
}
}
// if empty $carrier_groups_ids : object creation : we set the default groups
if (empty($customer_groups_ids)) {
$preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP'));
$customer_groups_ids = array_merge($customer_groups_ids, $preselected);
}
foreach ($groups as $group) {
$this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $customer_groups_ids));
}
return parent::renderForm();
}
示例8: process
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);
}
}
示例9: setContentProfile
/**
* 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']);
}
示例10: initContent
/**
* 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');
}
示例11: preProcess
//.........这里部分代码省略.........
array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email,
'{passwd}' => Tools::getValue('passwd')), 'vineet.saxena@I.com', '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@violetbag.com', '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);
}
示例12: initContent
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');
}
}
示例13: preProcess
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);
}
示例14: assignDate
/**
* 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));
}
示例15: initContent
/**
* 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');
}