Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap

This commit is contained in:
Kevin Granger
2013-10-14 16:35:01 +02:00
8 changed files with 433 additions and 182 deletions
@@ -112,11 +112,11 @@
<li>
{l s='Newsletter:'} {if $customer->newsletter}
<span class="label label-success">
<i class="icon-check-sign"></i> {l s='Yes'}
<i class="icon-check-sign"></i> {l s='Registered'}
</span>
{else}
<span class="label label-warning">
<i class="icon-ban-circle"></i> {l s='No'}
<i class="icon-ban-circle"></i> {l s='Unregistered'}
</span>
{/if}
</li>
@@ -125,19 +125,23 @@
{if $customer->optin}
<span class="label label-success">
<i class="icon-check-sign"></i>
{l s='Yes'}
{l s='Registered'}
</span>
{else}
<span class="label label-warning">
<i class="icon-ban-circle"></i>
{l s='No'}
{l s='Unregistered'}
</span>
{/if}
</li>
<li>
{l s='Age:'}
{$customer_stats['age']}
{if isset($customer->birthday['age'])}({$customer_birthday}){else}{l s='Unknown'}{/if}</li>
{if isset($customer->birthday)}
{$customer_stats['age']} {l s='years old'} ({l s='Birth date:'} {$customer_birthday})
{else}
{l s='Unknown'}
{/if}
</li>
<li>
{l s='Last update:'}
<span>{$last_update}</span>
@@ -147,12 +151,12 @@
{if $customer->active}
<span class="label label-success">
<i class="icon-check-sign"></i>
{l s='Yes'}
{l s='Active'}
</span>
{else}
<span class="label label-warning">
<i class="icon-ban-circle"></i>
{l s='No'}
{l s='Inactive'}
</span>
{/if}
</li>
@@ -193,11 +197,11 @@
<div class="row">
<div class="col-lg-6">
<i class="icon-ok-circle icon-big"></i>
{l s='Valid orders:'} <span class="badge badge-success">{$count_ok}</span> {l s='for'} {$total_ok}
{l s='Valid orders:'} <span class="label label-success">{$count_ok}</span> {l s='for'} {$total_ok}
</div>
<div class="col-lg-6">
<i class="icon-exclamation-sign icon-big"></i>
{l s='Invalid orders:'} <span class="badge badge-warning">{$count_ko}</span>
{l s='Invalid orders:'} <span class="label label-danger">{$count_ko}</span>
</div>
</div>
</div>
+1 -1
View File
@@ -3062,7 +3062,7 @@ class ProductCore extends ObjectModel
$check_stock = !Configuration::get('PS_DISP_UNAVAILABLE_ATTR');
if (!$res = Db::getInstance()->executeS('
SELECT pa.id_product, a.color, pac.id_product_attribute,'.($check_stock ? 'SUM(IF(stock.quantity > 0, 1, 0)' : '').') qty
SELECT pa.id_product, a.color, pac.id_product_attribute, '.($check_stock ? 'SUM(IF(stock.quantity > 0, 1, 0))' : '0').' qty
FROM '._DB_PREFIX_.'product_attribute pa
'.Shop::addSqlAssociation('product_attribute', 'pa').
($check_stock ? Product::sqlStock('pa', 'pa') : '').'
+1 -1
View File
@@ -1157,7 +1157,7 @@ class FrontControllerCore extends Controller
protected function addColorsToProductList(&$products)
{
if (!count($products))
if (!is_array($products) || !count($products))
return;
$products_need_cache = array();
+281 -170
View File
@@ -88,13 +88,17 @@ class DateOfDelivery extends Module
public function getContent()
{
$this->_html .= '<h2>'.$this->l('Date of delivery configuration').'</h2>';
$this->_html .= '';
$this->_postProcess();
if (Tools::isSubmit('addCarrierRule') OR (Tools::isSubmit('editCarrierRule') AND Tools::isSubmit('id_carrier_rule')))
$this->_setCarrierRuleForm();
if (Tools::isSubmit('addCarrierRule') OR (Tools::isSubmit('updatedateofdelivery') AND Tools::isSubmit('id_carrier_rule')))
$this->_html .= $this->renderAddForm();
else
$this->_setConfigurationForm();
{
$this->_html .= $this->renderList();
$this->_html .= $this->renderForm();
}
return $this->_html;
}
@@ -212,10 +216,10 @@ class DateOfDelivery extends Module
if (!sizeof($errors))
{
Configuration::updateValue('DOD_EXTRA_TIME_PRODUCT_OOS', (int)(Tools::getValue('extra_time_product_oos')));
Configuration::updateValue('DOD_EXTRA_TIME_PREPARATION', (int)(Tools::getValue('extra_time_preparation')));
Configuration::updateValue('DOD_PREPARATION_SATURDAY', (int)(Tools::isSubmit('preparation_saturday')));
Configuration::updateValue('DOD_PREPARATION_SUNDAY', (int)(Tools::isSubmit('preparation_sunday')));
Configuration::updateValue('DOD_EXTRA_TIME_PRODUCT_OOS', (int)Tools::getValue('extra_time_product_oos'));
Configuration::updateValue('DOD_EXTRA_TIME_PREPARATION', (int)Tools::getValue('extra_time_preparation'));
Configuration::updateValue('DOD_PREPARATION_SATURDAY', (int)Tools::getValue('preparation_day_preparation_saturday'));
Configuration::updateValue('DOD_PREPARATION_SUNDAY', (int)Tools::getValue('preparation_day_preparation_sunday'));
Configuration::updateValue('DOD_DATE_FORMAT', Tools::getValue('date_format'));
$this->_html .= $this->displayConfirmation($this->l('Settings are updated'));
}
@@ -229,7 +233,7 @@ class DateOfDelivery extends Module
$errors[] = $this->l('Minimum time is invalid');
if (!Validate::isUnsignedInt(Tools::getValue('maximal_time')))
$errors[] = $this->l('Maximum time is invalid');
if (($carrier = new Carrier((int)(Tools::getValue('id_carrier')))) AND !Validate::isLoadedObject($carrier))
if (($carrier = new Carrier((int)Tools::getValue('id_carrier'))) AND !Validate::isLoadedObject($carrier))
$errors[] = $this->l('Carrier is invalid');
if ($this->_isAlreadyDefinedForCarrier((int)($carrier->id), (int)(Tools::getValue('id_carrier_rule', 0))))
$errors[] = $this->l('You cannot use this carrier, a rule has already been saved.');
@@ -240,7 +244,7 @@ class DateOfDelivery extends Module
{
if (Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'dateofdelivery_carrier_rule`(`id_carrier`, `minimal_time`, `maximal_time`, `delivery_saturday`, `delivery_sunday`)
VALUES ('.(int)($carrier->id).', '.(int)(Tools::getValue('minimal_time')).', '.(int)(Tools::getValue('maximal_time')).', '.(int)(Tools::isSubmit('delivery_saturday')).', '.(int)(Tools::isSubmit('delivery_sunday')).')
VALUES ('.(int)($carrier->id).', '.(int)Tools::getValue('minimal_time').', '.(int)Tools::getValue('maximal_time').', '.(int)Tools::isSubmit('preparation_day_delivery_saturday').', '.(int)Tools::isSubmit('preparation_day_delivery_sunday').')
'))
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&confirmAddCarrierRule');
else
@@ -250,10 +254,10 @@ class DateOfDelivery extends Module
{
if (Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'dateofdelivery_carrier_rule`
SET `id_carrier` = '.(int)($carrier->id).', `minimal_time` = '.(int)(Tools::getValue('minimal_time')).', `maximal_time` = '.(int)(Tools::getValue('maximal_time')).', `delivery_saturday` = '.(int)(Tools::isSubmit('delivery_saturday')).', `delivery_sunday` = '.(int)(Tools::isSubmit('delivery_sunday')).'
WHERE `id_carrier_rule` = '.(int)(Tools::getValue('id_carrier_rule'))
SET `id_carrier` = '.(int)($carrier->id).', `minimal_time` = '.(int)Tools::getValue('minimal_time').', `maximal_time` = '.(int)Tools::getValue('maximal_time').', `delivery_saturday` = '.(int)Tools::isSubmit('preparation_day_delivery_saturday').', `delivery_sunday` = '.(int)Tools::isSubmit('preparation_day_delivery_sunday').'
WHERE `id_carrier_rule` = '.(int)Tools::getValue('id_carrier_rule')
))
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&confirmEditCarrierRule');
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&confirmupdatedateofdelivery');
else
$this->_html .= $this->displayError($this->l('An error occurred on updating of carrier rule.'));
}
@@ -263,173 +267,19 @@ class DateOfDelivery extends Module
$this->_html .= $this->displayError(implode('<br />', $errors));
}
if (Tools::isSubmit('deleteCarrierRule') AND Tools::isSubmit('id_carrier_rule') AND (int)(Tools::getValue('id_carrier_rule')) AND $this->_isCarrierRuleExists((int)(Tools::getValue('id_carrier_rule'))))
if (Tools::isSubmit('deletedateofdelivery') AND Tools::isSubmit('id_carrier_rule') AND (int)Tools::getValue('id_carrier_rule') AND $this->_isCarrierRuleExists((int)Tools::getValue('id_carrier_rule')))
{
$this->_deleteByIdCarrierRule((int)(Tools::getValue('id_carrier_rule')));
$this->_deleteByIdCarrierRule((int)Tools::getValue('id_carrier_rule'));
$this->_html .= $this->displayConfirmation($this->l('Carrier rule deleted successfully'));
}
if (Tools::isSubmit('confirmAddCarrierRule'))
$this->_html = $this->displayConfirmation($this->l('Carrier rule added successfully'));
if (Tools::isSubmit('confirmEditCarrierRule'))
if (Tools::isSubmit('confirmupdatedateofdelivery'))
$this->_html = $this->displayConfirmation($this->l('Carrier rule updated successfully'));
}
private function _setConfigurationForm()
{
$this->_html .= '
<fieldset>
<legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/time.png" alt="" /> '.$this->l('Carrier configuration').'</legend>
<p><a href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addCarrierRule"><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/time_add.png" alt="" /> '.$this->l('Add a new carrier rule').'</a></p>
<h3>'.$this->l('List of carrier rules').'</h3>';
$carrier_rules = $this->_getCarrierRulesWithCarrierName();
if (sizeof($carrier_rules))
{
$this->_html .= '<table width="100%" class="table" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th width="30%"><b>'.$this->l('Name of carrier').'</b></th>
<th width="40%" class="center"><b>'.$this->l('Delivery between').'</b></th>
<th width="10%" class="center"><b>'.$this->l('Saturday delivery').'</b></th>
<th width="10%" class="center"><b>'.$this->l('Sunday delivery').'</b></th>
<th width="10%" class="center"><b>'.$this->l('Actions').'</b></th>
</tr>
</thead>
<tbody>
';
foreach ($carrier_rules as $rule)
{
$this->_html .= '
<tr>
<td width="30%">'.(!preg_match('/^0$/Ui', $rule['name']) ? htmlentities($rule['name'], ENT_QUOTES, 'UTF-8') : Configuration::get('PS_SHOP_NAME')).'</td>
<td width="40%" class="center"><b>'.'</b> '.sprintf($this->l('%1$d day(s) and %2$d day(s)'), $rule['minimal_time'], $rule['maximal_time']).'</td>
<td width="10%" class="center">';
if ($rule['delivery_saturday'])
$this->_html .= '<img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/tick.png" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" />';
else
$this->_html .= '<img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/cross.png" alt="'.$this->l('No').'" title="'.$this->l('No').'" />';
$this->_html .='
</td>
<td width="10%" class="center">';
if ($rule['delivery_sunday'])
$this->_html .= '<img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/tick.png" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" />';
else
$this->_html .= '<img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/cross.png" alt="'.$this->l('No').'" title="'.$this->l('No').'" />';
$this->_html .= '
</td>
<td width="10%" class="center">
<a href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editCarrierRule&id_carrier_rule='.(int)($rule['id_carrier_rule']).'" title="'.$this->l('Edit').'"><img src="'._PS_ADMIN_IMG_.'edit.gif" alt="" /></a>
<a href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&deleteCarrierRule&id_carrier_rule='.(int)($rule['id_carrier_rule']).'" title="'.$this->l('Delete').'"><img src="'._PS_ADMIN_IMG_.'delete.gif" alt="" /></a>
</td>
</tr>';
}
$this->_html .= '
</tbody>
</table>';
}
else
$this->_html .= '<p class="center">'.$this->l('No carrier rule').'</p>';
$this->_html .= '
</fieldset>
<br />
<form method="post" action="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'">
<fieldset style="width:500px;">
<legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/time.png" alt="" /> '.$this->l('More options').'</legend>
<label for="extra_time_product_oos">'.$this->l('Extra time when a product is out of stock').'</label>
<div class="margin-form">
<input type="text" name="extra_time_product_oos" id="extra_time_product_oos" value="'.(int)(Tools::getValue('extra_time_product_oos', Configuration::get('DOD_EXTRA_TIME_PRODUCT_OOS'))).'" size="2" /> '.$this->l('day(s)').'
</div>
<div class="clear"></div>
<label for="extra_time_preparation">'.$this->l('Extra time for preparation of the order').'</label>
<div class="margin-form">
<input type="text" name="extra_time_preparation" id="extra_time_preparation" value="'.(int)(Tools::getValue('extra_time_preparation', Configuration::get('DOD_EXTRA_TIME_PREPARATION'))).'" size="2" /> '.$this->l('day(s)').'
</div>
<div class="clear"></div>
<label>'.$this->l('Preparation option').'</label>
<div class="margin-form">
<ul style="list-style-type:none;margin:0;padding:0;">
<li><input type="checkbox" name="preparation_saturday" id="preparation_saturday" '.(Configuration::get('DOD_PREPARATION_SATURDAY') ? 'checked="checked"' : '').' /> <label class="t" for="preparation_saturday">'.$this->l('Saturday preparation').'</label></li>
<li><input type="checkbox" name="preparation_sunday" id="preparation_sunday" '.(Configuration::get('DOD_PREPARATION_SUNDAY') ? 'checked="checked"' : '').' /> <label class="t" for="preparation_sunday">'.$this->l('Sunday preparation').'</label></li>
</ul>
</div>
<label for="date_format">'.$this->l('Date format:').'</label>
<div class="margin-form">
<input type="text" name="date_format" id="date_format" value="'.htmlentities(Tools::getValue('date_format', Configuration::get('DOD_DATE_FORMAT')), ENT_QUOTES, 'UTF-8').'" size="10" />
<p>'.$this->l('You can see all parameters available at:').' <a href="http://www.php.net/manual/en/function.date.php" target="_blank">http://www.php.net/manual/en/function.date.php</a></p>
</div>
<p class="center"><input type="submit" class="button" name="submitMoreOptions" value="'.$this->l('Save').'" /></p>
</fieldset>
</form>
';
}
private function _setCarrierRuleForm()
{
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::ALL_CARRIERS);
if (Tools::isSubmit('editCarrierRule') AND $this->_isCarrierRuleExists(Tools::getValue('id_carrier_rule')))
$carrier_rule = $this->_getCarrierRule(Tools::getValue('id_carrier_rule'));
$this->_html .= '
<form method="post" action="'.$_SERVER['REQUEST_URI'].'">
';
if (isset($carrier_rule) AND $carrier_rule['id_carrier_rule'])
$this->_html .= '<input type="hidden" name="id_carrier_rule" value="'.(int)($carrier_rule['id_carrier_rule']).'" />';
$this->_html .= '
<fieldset>
';
if (Tools::isSubmit('addCarrierRule'))
$this->_html .= '<legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/time_add.png" alt="" /> '.$this->l('New carrier rule').'</legend>';
elseif (Tools::isSubmit('editCarrierRule'))
$this->_html .= '<legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/img/time_add.png" alt="" /> '.$this->l('Edit carrier rule').'</legend>';
$this->_html .= '
<label for="id_carrier">'.$this->l('Carrier:').'</label>
<div class="margin-form">
<select name="id_carrier" id="id_carrier">
<option>'.$this->l('Choose').'</option>';
foreach ($carriers as $carrier)
$this->_html .= '<option value="'.$carrier['id_carrier'].'" '.((Tools::isSubmit('id_carrier') AND Tools::getValue('id_carrier') == $carrier['id_carrier']) ? 'selected="selected"' : ((isset($carrier_rule) AND $carrier_rule['id_carrier'] == $carrier['id_carrier']) ? 'selected="selected"' : '')).'>'.htmlentities($carrier['name'].' | '.$carrier['delay'], ENT_QUOTES, 'UTF-8').'</option>';
$this->_html .= '
</select>
</div>
<label>'.$this->l('Delivery between').'</label>
<div class="margin-form">
<input type="text" name="minimal_time" value="'.htmlentities(Tools::getValue('minimal_time', ((isset($carrier_rule) AND $carrier_rule['minimal_time']) ? $carrier_rule['minimal_time'] : 0)), ENT_QUOTES, 'UTF-8').'" size="2" /> '.$this->l('day(s) and').'
<input type="text" name="maximal_time" value="'.htmlentities(Tools::getValue('maximal_time', ((isset($carrier_rule) AND $carrier_rule['maximal_time']) ? $carrier_rule['maximal_time'] : 0)), ENT_QUOTES, 'UTF-8').'" size="2" /> '.$this->l('day(s)').'
</div>
<label>'.$this->l('Delivery options:').'</label>
<div class="margin-form">
<ul style="list-style-type:none;margin:0;padding:0;">
<li><input type="checkbox" name="delivery_saturday" id="delivery_saturday" '.(Tools::isSubmit('delivery_saturday') ? 'checked="checked"' : ((isset($carrier_rule) AND $carrier_rule['delivery_saturday']) ? 'checked="checked"' : '')).' /> <label class="t" for="delivery_saturday">'.$this->l('Saturday delivery').'</label></li>
<li><input type="checkbox" name="delivery_sunday" id="delivery_sunday" '.(Tools::isSubmit('delivery_sunday') ? 'checked="checked"' : ((isset($carrier_rule) AND $carrier_rule['delivery_sunday']) ? 'checked="checked"' : '')).' /> <label class="t" for="delivery_sunday">'.$this->l('Sunday delivery').'</label></li>
</ul>
</div>
<p class="center"><input type="submit" class="button" name="submitCarrierRule" value="'.$this->l('Save').'" /></p>
<p class="center"><a href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'">'.$this->l('Cancel').'</a></p>
';
$this->_html .= '
</fieldset>
</form>
';
}
private function _getCarrierRulesWithCarrierName()
{
return Db::getInstance()->executeS('
@@ -596,4 +446,265 @@ class DateOfDelivery extends Module
)
);
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Extra time when a product is out of stock'),
'name' => 'extra_time_product_oos',
'suffix' => $this->l('day(s)'),
),
array(
'type' => 'text',
'label' => $this->l('Extra time for preparation of the order'),
'name' => 'extra_time_preparation',
'suffix' => $this->l('day(s)'),
),
array(
'type' => 'checkbox',
'label' => $this->l('Preparation option'),
'name' => 'preparation_day',
'values' => array(
'id' => 'id',
'name' => 'name',
'query' => array(
array(
'id' => 'preparation_saturday',
'name' => $this->l('Saturday preparation'),
'val' => 1
),
array(
'id' => 'preparation_sunday',
'name' => $this->l('Sunday preparation'),
'val' => 1
),
),
)
),
array(
'type' => 'text',
'label' => $this->l('Date format:'),
'name' => 'date_format',
'desc' => $this->l('You can see all parameters available at:').' <a href="http://www.php.net/manual/en/function.date.php">http://www.php.net/manual/en/function.date.php</a>',
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-primary')
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$this->fields_form = array();
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitMoreOptions';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function renderAddForm()
{
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::ALL_CARRIERS);
foreach ($carriers as $key => $val)
$carriers[$key]['name'] = (!$val['name'] ? Configuration::get('PS_SHOP_NAME') : $val['name']);
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Carrier :'),
'name' => 'id_carrier',
'options' => array(
'query' => $carriers,
'id' => 'id_carrier',
'name' => 'name'
)
),
array(
'type' => 'text',
'label' => $this->l('Delivery between'),
'name' => 'minimal_time',
'suffix' => $this->l('day(s)'),
),
array(
'type' => 'text',
'label' => $this->l(''),
'name' => 'maximal_time',
'suffix' => $this->l('day(s)'),
),
array(
'type' => 'checkbox',
'label' => $this->l('Preparation option'),
'name' => 'preparation_day',
'values' => array(
'id' => 'id',
'name' => 'name',
'query' => array(
array(
'id' => 'delivery_saturday',
'name' => $this->l('Saturday preparation'),
'val' => 1
),
array(
'id' => 'delivery_sunday',
'name' => $this->l('Sunday preparation'),
'val' => 1
),
),
)
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-primary',
'name' => 'submitCarrierRule',
)
),
);
if (Tools::getValue('id_carrier_rule') && $this->_isCarrierRuleExists(Tools::getValue('id_carrier_rule')))
$fields_form['form']['input'][] = array('type' => 'hidden', 'name' => 'id_carrier_rule');
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$this->fields_form = array();
$helper->identifier = $this->identifier;
if (Tools::getValue('id_carrier_rule'))
$helper->submit_action = 'updatedateofdelivery';
else
$helper->submit_action = 'addCarrierRule';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getCarrierRuleFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function getConfigFieldsValues()
{
return array(
'extra_time_product_oos' => Tools::getValue('extra_time_product_oos', Configuration::get('DOD_EXTRA_TIME_PRODUCT_OOS')),
'extra_time_preparation' => Tools::getValue('extra_time_preparation', Configuration::get('DOD_EXTRA_TIME_PREPARATION')),
'preparation_day_preparation_saturday' => Tools::getValue('preparation_day_preparation_saturday', Configuration::get('DOD_PREPARATION_SATURDAY')),
'preparation_day_preparation_sunday' => Tools::getValue('preparation_day_preparation_sunday', Configuration::get('DOD_PREPARATION_SUNDAY')),
'date_format' => Tools::getValue('date_format', Configuration::get('DOD_DATE_FORMAT')),
'id_carrier' => Tools::getValue('id_carrier'),
);
}
public function getCarrierRuleFieldsValues()
{
$fields = array(
'id_carrier_rule' => Tools::getValue('id_carrier_rule'),
'id_carrier' => Tools::getValue('id_carrier'),
'minimal_time' => Tools::getValue('minimal_time'),
'maximal_time' => Tools::getValue('maximal_time'),
'delivery_saturday' => Tools::getValue('delivery_saturday'),
'delivery_sunday' => Tools::getValue('delivery_sunday'),
);
if (Tools::isSubmit('updatedateofdelivery') AND $this->_isCarrierRuleExists(Tools::getValue('id_carrier_rule')))
{
$carrier_rule = $this->_getCarrierRule(Tools::getValue('id_carrier_rule'));
$fields['id_carrier_rule'] = Tools::getValue('id_carrier_rule', $carrier_rule['id_carrier_rule']);
$fields['id_carrier'] = Tools::getValue('id_carrier', $carrier_rule['id_carrier']);
$fields['minimal_time'] = Tools::getValue('minimal_time', $carrier_rule['minimal_time']);
$fields['maximal_time'] = Tools::getValue('maximal_time', $carrier_rule['maximal_time']);
$fields['preparation_day_delivery_saturday'] = Tools::getValue('preparation_day_delivery_saturday', $carrier_rule['delivery_saturday']);
$fields['preparation_day_delivery_sunday'] = Tools::getValue('preparation_day_delivery_sunday', $carrier_rule['delivery_sunday']);
}
return $fields;
}
public function renderList()
{
$add_url = $this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&addCarrierRule=1';
$fields_list = array(
'name' => array(
'title' => $this->l('Name of carrier'),
'type' => 'text',
),
'delivery_between' => array(
'title' => $this->l('Delivery between'),
'type' => 'text',
),
'delivery_saturday' => array(
'title' => $this->l('Saturday delivery'),
'type' => 'bool',
'align' => 'center',
'active' => 'status',
),
'delivery_sunday' => array(
'title' => $this->l('Sunday delivery'),
'type' => 'bool',
'align' => 'center',
'active' => 'status',
),
);
$list = $this->_getCarrierRulesWithCarrierName();
foreach ($list as $key => $val)
{
if (!$val['name'])
$list[$key]['name'] = Configuration::get('PS_SHOP_NAME');
$list[$key]['delivery_between'] = sprintf($this->l('%1$d day(s) and %2$d day(s)'), $val['minimal_time'], $val['maximal_time']);
}
$helper = new HelperList();
$helper->shopLinkType = '';
$helper->simple_header = true;
$helper->identifier = 'id_carrier_rule';
$helper->actions = array('edit', 'delete');
$helper->show_toolbar = false;
$helper->title = $this->l('Link list');
$helper->table = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
$this->context->smarty->assign(array('add_url' => $add_url));
return $this->display(__FILE__, 'button.tpl').$helper->generateList($list, $fields_list).$this->display(__FILE__, 'button.tpl');
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
@@ -0,0 +1,31 @@
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="row">
<div class="col-lg-9">
<a href="{$add_url}" class="btn btn-primary">{l s="Add a new carrier rule"}</a>
</div>
</div>
<br/>
@@ -0,0 +1,35 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../../');
@@ -0,0 +1,35 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../../');