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

Conflicts:
	.gitignore
	admin-dev/themes/default/css/admin.css
	admin-dev/themes/default/template/controllers/categories/helpers/list/list_header.tpl
	admin-dev/themes/default/template/controllers/customers/helpers/list/list_header.tpl
	admin-dev/themes/default/template/controllers/modules/list.tpl
	admin-dev/themes/default/template/controllers/modules/page.tpl
	admin-dev/themes/default/template/controllers/modules/tab_module_line.tpl
	admin-dev/themes/default/template/controllers/orders/_documents.tpl
	admin-dev/themes/default/template/controllers/orders/_shipping.tpl
	admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl
	admin-dev/themes/default/template/controllers/payment/helpers/view/view.tpl
	admin-dev/themes/default/template/controllers/payment/restrictions.tpl
	admin-dev/themes/default/template/controllers/products/images.tpl
	admin-dev/themes/default/template/controllers/products/informations.tpl
	admin-dev/themes/default/template/header.tpl
	admin-dev/themes/default/template/helpers/form/form.tpl
	admin-dev/themes/default/template/helpers/modules_list/list.tpl
	classes/Tools.php
	controllers/admin/AdminCartRulesController.php
	controllers/admin/AdminProductsController.php
	css/admin.css
This commit is contained in:
Kevin Granger
2013-07-24 17:01:23 +02:00
603 changed files with 14577 additions and 11364 deletions
@@ -152,18 +152,7 @@ class AdminAddressesControllerCore extends AdminController
$token_customer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id);
}
// @todo in 1.4, this include was done before the class declaration
// We should use a hook now
if (Configuration::get('VATNUMBER_MANAGEMENT') && file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php'))
include_once(_PS_MODULE_DIR_.'vatnumber/vatnumber.php');
if (Configuration::get('VATNUMBER_MANAGEMENT'))
if (file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php') && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT')))
$vat = 'is_applicable';
else
$vat = 'management';
$this->tpl_form_vars = array(
'vat' => isset($vat) ? $vat : null,
'customer' => isset($customer) ? $customer : null,
'tokenCustomer' => isset ($token_customer) ? $token_customer : null
);
@@ -32,10 +32,9 @@ class AdminCartRulesControllerCore extends AdminController
$this->table = 'cart_rule';
$this->className = 'CartRule';
$this->lang = true;
$this->addRowAction('edit');
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fields_list = array(
@@ -225,7 +225,7 @@ class AdminCategoriesControllerCore extends AdminController
{
if (empty($this->display))
{
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE'))
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops()) > 1)
$this->toolbar_btn['new-url'] = array(
'href' => self::$currentIndex.'&add'.$this->table.'root&token='.$this->token,
'desc' => $this->l('Add new root category')
+18 -1
View File
@@ -220,11 +220,28 @@ class AdminCmsControllerCore extends AdminController
$this->displayListFooter($token);
}
public function postProcess()
/**
* Modifying initial getList method to display position feature (drag and drop)
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if (Tools::isSubmit($this->table.'Orderby') || Tools::isSubmit($this->table.'Orderway'))
$this->filter = true;
if ($order_by && $this->context->cookie->__get($this->table.'Orderby'))
$order_by = $this->context->cookie->__get($this->table.'Orderby');
else
$order_by = 'position';
if (is_null($order_way))
$order_way = Tools::getValue($this->table.'Orderway', 'ASC');
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
}
public function postProcess()
{
if (Tools::isSubmit('viewcms') && ($id_cms = (int)Tools::getValue('id_cms')) && ($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms))
{
$redir = $this->context->link->getCMSLink($cms);
@@ -433,10 +433,10 @@ class AdminCountriesControllerCore extends AdminController
public function processStatus()
{
if (Validate::isLoadedObject($object = $this->loadObject()))
Country::addModuleRestrictions(array(), array(array('id_country' => $object->id)), array());
parent::processStatus();
if (Validate::isLoadedObject($object = $this->loadObject()) && $object->active == 1)
return Country::addModuleRestrictions(array(), array(array('id_country' => $object->id)), array());
return false;
}
public function processBulkStatusSelection($way)
@@ -38,7 +38,7 @@ class AdminCurrenciesControllerCore extends AdminController
'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 80),
'iso_code_num' => array('title' => $this->l('ISO code number'), 'align' => 'center', 'width' => 120),
'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false),
'conversion_rate' => array('title' => $this->l('Conversion rate'), 'type' => 'float', 'align' => 'center', 'width' => 130, 'search' => false),
'conversion_rate' => array('title' => $this->l('Exchange rate'), 'type' => 'float', 'align' => 'center', 'width' => 130, 'search' => false, 'filter_key' => 'currency_shop!conversion_rate'),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
);
@@ -130,12 +130,12 @@ class AdminCurrenciesControllerCore extends AdminController
),
array(
'type' => 'text',
'label' => $this->l('Conversion rate:'),
'label' => $this->l('Exchange rate:'),
'name' => 'conversion_rate',
'size' => 3,
'maxlength' => 11,
'required' => true,
'desc' => $this->l('Conversion rates are calculated from one unit of your shop\'s default currency. For example, if the default currency is euros and your chosen currency is dollars, type "1.20"').' 1€ = $1.20',
'desc' => $this->l('Exchange rates are calculated from one unit of your shop\'s default currency. For example, if the default currency is euros and your chosen currency is dollars, type "1.20"').' 1€ = $1.20',
),
array(
'type' => 'select',
@@ -401,10 +401,10 @@ class AdminCustomerThreadsControllerCore extends AdminController
),
);
//#ct == id_customer_thread #tc == token of thread <== used in the synchronization imap
$contact = new Contact((int)$ct->id_contact);
$contact = new Contact((int)$ct->id_contact, (int)$ct->id_lang);
if (Validate::isLoadedObject($contact))
{
$from_name = $contact->name;
$from_name = $contact->name[(int)$ct->id_lang];
$from_email = $contact->email;
}
else
@@ -805,4 +805,4 @@ class AdminCustomerThreadsControllerCore extends AdminController
die('{"hasError" : false, "errors" : ["'.$str_errors.$str_error_delete.'"]}');
}
}
}
}
+9 -9
View File
@@ -377,12 +377,13 @@ class AdminHomeControllerCore extends AdminController
$chart = new Chart();
$chart->getCurve(1)->setType('bars');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT total_paid / conversion_rate as total_converted, left(invoice_date, 10) as invoice_date
SELECT SUM(total_paid / conversion_rate) as total_converted, left(invoice_date, 10) as invoice_date
FROM '._DB_PREFIX_.'orders o
WHERE valid = 1
AND total_paid > 0
AND invoice_date BETWEEN \''.date('Y-m-d', strtotime('-7 DAYS', time())).' 00:00:00\' AND \''.date('Y-m-d H:i:s').'\'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
GROUP BY DATE(invoice_date)
');
foreach ($result as $row)
$chart->getCurve(1)->setPoint(strtotime($row['invoice_date'].' 02:00:00'), $row['total_converted']);
@@ -488,11 +489,10 @@ class AdminHomeControllerCore extends AdminController
// DISCOVER PRESTASHOP
$result['discover_prestashop'] = '<div id="block_tips">'.$this->getBlockDiscover().'</div>';
$result['discover_prestashop'] .= '<div class="row-news"><div id="block_discover"><iframe frameborder="no" style="margin: 0px; padding: 0px; width: 100%; height:300px; overflow:hidden;" src="'.$protocol.'://api.prestashop.com/rss2/news2.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe></div>';
// SHOW TIPS OF THE DAY
$content = @file_get_contents($protocol.'://api.prestashop.com/partner/tipsoftheday/?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser), false, $stream_context);
$content = Tools::file_get_contents($protocol.'://api.prestashop.com/partner/tipsoftheday/?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser), false, $stream_context);
$content = explode('|', $content);
if ($content[0] == 'OK' && Validate::isCleanHtml($content[1]))
$result['discover_prestashop'] .= '<div id="block_partner_tips">'.$content[1].'</div></div>';
@@ -540,7 +540,7 @@ class AdminHomeControllerCore extends AdminController
// Cache the logo
if (!file_exists('../img/tmp/preactivation_'.htmlentities((string)$partner->module).'.png'))
{
$logo = @Tools::file_get_contents(htmlentities((string)$partner->logo));
$logo = Tools::file_get_contents(htmlentities((string)$partner->logo));
if (sizeof($logo) > 0)
file_put_contents('../img/tmp/preactivation_'.htmlentities((string)$partner->module).'.png', $logo);
}
@@ -566,12 +566,12 @@ class AdminHomeControllerCore extends AdminController
if (empty($optional_final) && (string)$optional->attributes()->iso == $isoUser)
$optional_final = (string)$optional;
$link = 'index.php?controller=adminmodules&install='.htmlentities((string)$partner->module).'&token='.Tools::getAdminTokenLite('AdminModules').'&module_name='.htmlentities((string)$partner->module).'&redirect=config';
$link = 'index.php?controller=adminmodules&install='.Tools::htmlentitiesUTF8((string)$partner->module).'&token='.Tools::getAdminTokenLite('AdminModules').'&module_name='.Tools::htmlentitiesUTF8((string)$partner->module).'&redirect=config';
$return .= '<div style="width:46.5%;min-height:85px;border:1px solid #cccccc;background-color:white;padding-left:5px;padding-right:5px;'.(empty($return) ? 'float:left' : 'float:right').'">
<p align="center">
<a href="'.$link.'" class="preactivationLink" rel="'.htmlentities((string)$partner->module).'"><img src="../img/tmp/preactivation_'.htmlentities((string)$partner->module).'.png" alt="'.htmlentities((string)$partner->name).'" border="0" /></a><br />
<b><a href="'.$link.'" class="preactivationLink" rel="'.htmlentities((string)$partner->module).'">'.htmlentities(utf8_decode((string)$label_final)).'</a></b>
'.(($optional_final != '') ? '<a href="'.$link.'" class="preactivationLink" rel="'.htmlentities((string)$partner->module).'"><img src="'.htmlentities((string)$optional_final).'" /></a>' : '').'
<a href="'.$link.'" class="preactivationLink" rel="'.Tools::htmlentitiesUTF8((string)$partner->module).'"><img src="../img/tmp/preactivation_'.Tools::htmlentitiesUTF8((string)$partner->module).'.png" alt="'.htmlentities((string)$partner->name).'" border="0" /></a><br />
<b><a href="'.$link.'" class="preactivationLink" rel="'.Tools::htmlentitiesUTF8((string)$partner->module).'">'.Tools::htmlentitiesUTF8($label_final).'</a></b>
'.(($optional_final != '') ? '<a href="'.$link.'" class="preactivationLink" rel="'.Tools::htmlentitiesUTF8((string)$partner->module).'"><img src="'.Tools::htmlentitiesUTF8((string)$optional_final).'" /></a>' : '').'
</p>
</div>';
$count++;
@@ -375,6 +375,7 @@ class AdminImagesControllerCore extends AdminController
|| !Configuration::updateValue('PS_PNG_QUALITY', Tools::getValue('PS_PNG_QUALITY')))
$this->errors[] = Tools::displayError('Unknown error.');
else
$this->confirmations[] = $this->_conf[6];
return parent::postProcess();
}
else
+19 -11
View File
@@ -2710,43 +2710,51 @@ class AdminImportControllerCore extends AdminController
// If i am a superadmin, i can truncate table
if (((Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive()) && Tools::getValue('truncate'))
$this->truncateTables((int)Tools::getValue('entity'));
$import_type = false;
switch ((int)Tools::getValue('entity'))
{
case $this->entities[$this->l('Categories')]:
case $this->entities[$import_type = $this->l('Categories')]:
$this->categoryImport();
break;
case $this->entities[$this->l('Products')]:
case $this->entities[$import_type = $this->l('Products')]:
$import_type = $this->l('Categories');
$this->productImport();
break;
case $this->entities[$this->l('Customers')]:
case $this->entities[$import_type = $this->l('Customers')]:
$this->customerImport();
break;
case $this->entities[$this->l('Addresses')]:
case $this->entities[$import_type = $this->l('Addresses')]:
$this->addressImport();
break;
case $this->entities[$this->l('Combinations')]:
case $this->entities[$import_type = $this->l('Combinations')]:
$this->attributeImport();
break;
case $this->entities[$this->l('Manufacturers')]:
case $this->entities[$import_type = $this->l('Manufacturers')]:
$this->manufacturerImport();
break;
case $this->entities[$this->l('Suppliers')]:
case $this->entities[$import_type = $this->l('Suppliers')]:
$this->supplierImport();
break;
// @since 1.5.0
case $this->entities[$this->l('Supply Orders')]:
case $this->entities[$import_type = $this->l('Supply Orders')]:
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
$this->supplyOrdersImport();
break;
// @since 1.5.0
case $this->entities[$this->l('Supply Order Details')]:
case $this->entities[$import_type = $this->l('Supply Order Details')]:
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
$this->supplyOrdersDetailsImport();
break;
default:
$this->errors[] = $this->l('Please select what you would like to import');
}
if ($import_type !== false)
{
$log_message = sprintf($this->l('%s import'), $import_type);
if (Tools::getValue('truncate'))
$log_message .= ' '.$this->l('with truncate');
Logger::addLog($log_message, 1, null, $import_type, null, true, (int)$this->context->employee->id);
}
}
else
$this->errors[] = $this->l('You must upload a file in order to proceed to the next step');
@@ -2806,4 +2814,4 @@ class AdminImportControllerCore extends AdminController
die;
}
}
}
}
@@ -144,7 +144,7 @@ class AdminLanguagesControllerCore extends AdminController
'required' => true,
'size' => 2,
'maxlength' => 5,
'desc' => $this->l('Full language code (e.g. EN-US, PT-BR)')
'desc' => $this->l('IETF language tag (e.g. en-US, pt-BR).').' '.sprintf('<a href="http://en.wikipedia.org/wiki/IETF_language_tag" target="_blank">%s <img src="../img/admin/external_link.png" class="icon-top" /></a>', $this->l('IETF on Wikipedia'))
),
array(
'type' => 'text',
@@ -152,7 +152,7 @@ class AdminLanguagesControllerCore extends AdminController
'name' => 'date_format_lite',
'required' => true,
'size' => 15,
'desc' => $this->l('Short date format (e.g. YY-MM-DD)')
'desc' => sprintf($this->l('Short date format (e.g., %s)'), '<a href="http://php.net/date" target="_blank">Y-m-d</a>')
),
array(
'type' => 'text',
@@ -160,7 +160,7 @@ class AdminLanguagesControllerCore extends AdminController
'name' => 'date_format_full',
'required' => true,
'size' => 25,
'desc' => $this->l('Full date format (e.g., YYYY-MM-DD)')
'desc' => sprintf($this->l('Full date format (e.g., %s)'), '<a href="http://php.net/date" target="_blank">Y-m-d H:i:s</a>')
),
array(
'type' => 'file',
@@ -38,6 +38,7 @@ class AdminLogsControllerCore extends AdminController
$this->fields_list = array(
'id_log' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'employee' => array('title' => $this->l('Employee'), 'align' => 'center', 'width' => 100),
'severity' => array('title' => $this->l('Severity (1-4)'), 'align' => 'center', 'width' => 50),
'message' => array('title' => $this->l('Message')),
'object_type' => array('title' => $this->l('Object type'), 'width' => 75),
@@ -62,6 +63,8 @@ class AdminLogsControllerCore extends AdminController
)
);
$this->list_no_link = true;
$this->_select .= 'CONCAT(LEFT(e.firstname, 1), \'. \', e.lastname) employee';
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'employee e ON (a.id_employee = e.id_employee)';
parent::__construct();
}
@@ -185,7 +185,7 @@ class AdminManufacturersControllerCore extends AdminController
$this->_join .= '
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
ON (a.`id_manufacturer` = m.`id_manufacturer`)';
$this->_where = 'AND a.`id_customer` = 0 AND a.`id_supplier` = 0 AND a.`id_warehouse` = 0';
$this->_where = 'AND a.`id_customer` = 0 AND a.`id_supplier` = 0 AND a.`id_warehouse` = 0 AND a.`deleted`=0';
$this->context->smarty->assign('title_list', $this->l('Manufacturers addresses:'));
@@ -402,6 +402,12 @@ class AdminManufacturersControllerCore extends AdminController
'type' => 'hidden',
'name' => 'alias',
);
$form['input'][] = array(
'type' => 'hidden',
'name' => 'id_address',
);
$form['input'][] = array(
'type' => 'text',
'label' => $this->l('Last name:'),
@@ -501,7 +507,7 @@ class AdminManufacturersControllerCore extends AdminController
$this->fields_value = array(
'name' => Manufacturer::getNameById($address->id_manufacturer),
'alias' => 'manufacturer',
'id_country' => Configuration::get('PS_COUNTRY_DEFAULT')
'id_country' => $address->id_country
);
$this->initToolbar();
@@ -661,6 +667,8 @@ class AdminManufacturersControllerCore extends AdminController
if (Tools::isSubmit('editaddresses'))
$this->display = 'editaddresses';
else if (Tools::isSubmit('updateaddress'))
$this->display = 'editaddresses';
else if (Tools::isSubmit('addaddress'))
$this->display = 'addaddress';
else if (Tools::isSubmit('submitAddaddress'))
@@ -708,6 +716,9 @@ class AdminManufacturersControllerCore extends AdminController
return $res;
}
protected function beforeDelete($object)
{
return true;
}
}
+1 -1
View File
@@ -650,7 +650,7 @@ class AdminMetaControllerCore extends AdminController
}
$tab['GB'] = array(
'orderby=','orderway=','tag=','id_currency=','search_query=','back=','utm_source=','utm_medium=','utm_campaign=','n='
'orderby=','orderway=','tag=','id_currency=','search_query=','back=','n='
);
foreach ($disallow_controllers as $controller)
+6 -1
View File
@@ -572,7 +572,8 @@ class AdminModulesControllerCore extends AdminController
else
{
// Uninstall the module before deleting the files, but do not block the process if uninstall returns false
$module->uninstall();
if (Module::isInstalled($module->name))
$module->uninstall();
$moduleDir = _PS_MODULE_DIR_.str_replace(array('.', '/', '\\'), array('', '', ''), Tools::getValue('module_name'));
$this->recursiveDeleteOnDisk($moduleDir);
Tools::redirectAdmin(self::$currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name'));
@@ -674,6 +675,10 @@ class AdminModulesControllerCore extends AdminController
// Get the return value of current method
$echo = $module->{$method}();
// After a successful install of a single module that has a configuration method, to the configuration page
if ($key == 'install' && $echo === true && strpos(Tools::getValue('install'), '|') === false && method_exists($module, 'getContent'))
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&configure='.$module->name.'&conf=12');
}
// If the method called is "configure" (getContent method), we show the html code of configure page
+53 -9
View File
@@ -490,6 +490,14 @@ class AdminOrdersControllerCore extends AdminController
if ($shipping_cost_amount > 0)
$amount += $shipping_cost_amount;
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
if ($order_carrier->update())
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
if ($amount > 0)
{
if (!OrderSlip::createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list))
@@ -515,6 +523,7 @@ class AdminOrdersControllerCore extends AdminController
$now = time();
$cart_rule->date_from = date('Y-m-d H:i:s', $now);
$cart_rule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25)); /* 1 year */
$cart_rule->partial_use = 1;
$cart_rule->active = 1;
$cart_rule->reduction_amount = $amount;
@@ -654,8 +663,16 @@ class AdminOrdersControllerCore extends AdminController
// Delete product
$order_detail = new OrderDetail((int)$id_order_detail);
if (!$order->deleteProduct($order, $order_detail, $qtyCancelProduct))
if (!$order->deleteProduct($order, $order_detail, $qty_cancel_product))
$this->errors[] = Tools::displayError('An error occurred while attempting to delete the product.').' <span class="bold">'.$order_detail->product_name.'</span>';
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
if ($order_carrier->update())
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
Hook::exec('actionProductCancel', array('order' => $order, 'id_order_detail' => (int)$id_order_detail));
}
if (!count($this->errors) && $customizationList)
@@ -914,13 +931,10 @@ class AdminOrdersControllerCore extends AdminController
$order_detail->updateTaxAmount($order);
}
$id_order_carrier = Db::getInstance()->getValue('
SELECT `id_order_carrier`
FROM `'._DB_PREFIX_.'order_carrier`
WHERE `id_order` = '.(int)$order->id);
$id_order_carrier = (int)$order->getIdOrderCarrier();
if ($id_order_carrier)
{
$order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier = $order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
$order_carrier->shipping_cost_tax_excl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_excl, $old_currency, $currency);
$order_carrier->shipping_cost_tax_incl = (float)Tools::convertPriceFull($order_carrier->shipping_cost_tax_incl, $old_currency, $currency);
$order_carrier->update();
@@ -963,7 +977,7 @@ class AdminOrdersControllerCore extends AdminController
// Update currency in order
$order->id_currency = $currency->id;
// Update conversion rate
// Update exchange rate
$order->conversion_rate = (float)$currency->conversion_rate;
$order->update();
}
@@ -1301,7 +1315,7 @@ class AdminOrdersControllerCore extends AdminController
// display warning if there are products out of stock
$display_out_of_stock_warning = false;
$current_order_state = $order->getCurrentOrderState();
if (configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || ($current_order_state->delivery != 1 && $current_order_state->shipped != 1)))
if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || ($current_order_state->delivery != 1 && $current_order_state->shipped != 1)))
$display_out_of_stock_warning = true;
// products current stock (from stock_available)
@@ -1697,6 +1711,15 @@ class AdminOrdersControllerCore extends AdminController
// Save changes of order
$order->update();
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
if ($order_carrier->update())
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
// Update Tax lines
$order_detail->updateTaxAmount($order);
@@ -1904,6 +1927,17 @@ class AdminOrdersControllerCore extends AdminController
// Save order detail
$res &= $order_detail->update();
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
$res &= $order_carrier->update();
if ($res)
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
// Save order invoice
if (isset($order_invoice))
$res &= $order_invoice->update();
@@ -1996,12 +2030,22 @@ class AdminOrdersControllerCore extends AdminController
$order->total_products_wt -= $order_detail->total_price_tax_incl;
$res &= $order->update();
// Reinject quantity in stock
$this->reinjectQuantity($order_detail, $order_detail->product_quantity);
// Delete OrderDetail
$res &= $order_detail->delete();
// Update weight SUM
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier))
{
$order_carrier->weight = (float)$order->getTotalWeight();
$res &= $order_carrier->update();
if ($res)
$order->weight = sprintf("%.3f ".Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
if (!$res)
die(Tools::jsonEncode(array(
@@ -231,7 +231,7 @@ class AdminPPreferencesControllerCore extends AdminController
// if advanced stock management is disabled, updates concerned tables
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 &&
(int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
(int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0 && Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL)
{
ObjectModel::updateMultishopTable('Product', array('advanced_stock_management' => 0), 'product_shop.`advanced_stock_management` = 1');
@@ -95,6 +95,14 @@ class AdminPreferencesControllerCore extends AdminController
'default' => '0',
'visibility' => Shop::CONTEXT_ALL
),
'PS_ALLOW_HTML_IFRAME' => array(
'title' => $this->l('Allow iframes on html fields'),
'desc' => $this->l('Allow iframes on fields like product description. We recommend that you leave this option disabled'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'default' => '0'
),
'PS_PRICE_ROUND_MODE' => array(
'title' => $this->l('Round mode'),
'desc' => $this->l('You can choose how to round prices: Always round superior, always round inferior or classic rounding.'),
+96 -52
View File
@@ -77,7 +77,7 @@ class AdminProductsControllerCore extends AdminController
$this->allow_export = true;
// @since 1.5 : translations for tabs
$this->available_tabs_lang = array (
$this->available_tabs_lang = array(
'Informations' => $this->l('Information'),
'Pack' => $this->l('Pack'),
'VirtualProduct' => $this->l('Virtual Product'),
@@ -161,40 +161,28 @@ class AdminProductsControllerCore extends AdminController
if (Validate::isLoadedObject($this->_category) && empty($this->_filter))
$join_category = true;
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` '.(!Shop::isFeatureActive() ? ' AND i.cover=1' : '').')';
if (Shop::isFeatureActive())
{
$alias = 'sa';
$alias_image = 'image_shop';
if (Shop::getContext() == Shop::CONTEXT_SHOP)
{
$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop='.(int)$this->context->shop->id.')';
}
else
{
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop=a.id_shop_default)';
}
$this->_select .= 'shop.name as shopname, ';
}
else
{
$alias = 'a';
$alias_image = 'i';
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = 1)';
}
$this->_select .= 'MAX('.$alias_image.'.id_image) id_image,';
$this->_join .= ($join_category ? 'INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.')' : '').'
$this->_join .= '
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0
'.StockAvailable::addSqlShopRestriction(null, null, 'sav').') ';
$this->_select .= 'cl.name `name_category` '.($join_category ? ', cp.`position`' : '').', '.$alias.'.`price`, 0 AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
$alias = 'sa';
$alias_image = 'image_shop';
$id_shop = Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP? (int)$this->context->shop->id : 'a.id_shop_default';
$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')';
$this->_select .= 'shop.name as shopname, ';
$this->_select .= 'MAX('.$alias_image.'.id_image) id_image, cl.name `name_category`, '.$alias.'.`price`, 0 AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
if ($join_category)
{
$this->_join .= ' INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.') ';
$this->_select .= ' , cp.`position`, ';
}
$this->_group = 'GROUP BY '.$alias.'.id_product';
@@ -202,6 +190,8 @@ class AdminProductsControllerCore extends AdminController
$this->fields_list['id_product'] = array(
'title' => $this->l('ID'),
'align' => 'center',
'type' => 'int',
'width' => 40
);
$this->fields_list['image'] = array(
'title' => $this->l('Photo'),
@@ -244,13 +234,17 @@ class AdminProductsControllerCore extends AdminController
'havingFilter' => true,
'orderby' => false
);
$this->fields_list['sav_quantity'] = array(
'title' => $this->l('Quantity'),
'align' => 'right',
'filter_key' => 'sav!quantity',
'orderby' => true,
//'hint' => $this->l('This is the quantity available in the current shop/group.'),
);
if (Configuration::get('PS_STOCK_MANAGEMENT'))
$this->fields_list['sav_quantity'] = array(
'title' => $this->l('Quantity'),
'type' => 'int',
'align' => 'right',
'filter_key' => 'sav!quantity',
'orderby' => true,
//'hint' => $this->l('This is the quantity available in the current shop/group.'),
);
$this->fields_list['active'] = array(
'title' => $this->l('Status'),
'active' => 'status',
@@ -260,7 +254,7 @@ class AdminProductsControllerCore extends AdminController
'orderby' => false
);
if ((int)$this->id_current_category)
if ($join_category && (int)$this->id_current_category)
$this->fields_list['position'] = array(
'title' => $this->l('Position'),
'filter_key' => 'cp!position',
@@ -365,7 +359,14 @@ class AdminProductsControllerCore extends AdminController
$default_product = new Product((int)$this->object->id, false, null, (int)$this->object->id_shop_default);
$def = ObjectModel::getDefinition($this->object);
foreach ($def['fields'] as $field_name => $row)
$this->object->$field_name = ObjectModel::formatValue($default_product->$field_name, $def['fields'][$field_name]['type']);
{
$fields_array = array();
if(is_array($default_product->$field_name))
foreach ($fields_array as $key => $fields_name)
$this->object->$field_name[$key] = ObjectModel::formatValue($fields_name, $def['fields'][$field_name]['type']);
else
$this->object->$field_name = ObjectModel::formatValue($this->object->$field_name, $def['fields'][$field_name]['type']);
}
}
$this->object->loadStockData();
}
@@ -721,7 +722,12 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = sprintf(Tools::displayError('You cannot delete the product #%d because there is physical stock left.'), $product->id);
}
if (!count($this->errors))
$success &= $product->delete();
{
if ($product->delete())
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$product->id, true, (int)$this->context->employee->id);
else
$success = false;
}
else
$success = 0;
}
@@ -756,6 +762,26 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = Tools::displayError('The price attribute is required.');
if (!Tools::getIsset('attribute_combination_list') || Tools::isEmpty(Tools::getValue('attribute_combination_list')))
$this->errors[] = Tools::displayError('You must add at least one attribute.');
$array_checks = array(
'reference' => 'isReference',
'supplier_reference' => 'isReference',
'location' => 'isReference',
'ean13' => 'isEan13',
'upc' => 'isUpc',
'wholesale_price' => 'isPrice',
'price' => 'isPrice',
'ecotax' => 'isPrice',
'quantity' => 'isInt',
'weight' => 'isUnsignedFloat',
'unit_price_impact' => 'isPrice',
'default_on' => 'isBool',
'minimal_quantity' => 'isUnsignedInt',
'available_date' => 'isDateFormat'
);
foreach ($array_checks as $property => $check)
if (Tools::getValue('attribute_'.$property) !== false && !call_user_func(array('Validate', $check), Tools::getValue('attribute_'.$property)))
$this->errors[] = sprintf(Tools::displayError('Field %s is not valid'), $property);
if (!count($this->errors))
{
@@ -1678,6 +1704,7 @@ class AdminProductsControllerCore extends AdminController
if ($this->object->add())
{
Logger::addLog(sprintf($this->l('%s addition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
$this->addCarriers();
$this->updateAccessories($this->object);
$this->updatePackItems($this->object);
@@ -1819,6 +1846,7 @@ class AdminProductsControllerCore extends AdminController
if ($object->update())
{
Logger::addLog(sprintf($this->l('%s edition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
if (in_array($this->context->shop->getContext(), array(Shop::CONTEXT_SHOP, Shop::CONTEXT_ALL)))
{
if ($this->isTabSubmitted('Shipping'))
@@ -2008,17 +2036,28 @@ class AdminProductsControllerCore extends AdminController
// Check fields validity
foreach ($rules['validate'] as $field => $function)
if ($this->isProductFieldUpdated($field) && ($value = Tools::getValue($field)))
if (!Validate::$function($value))
{
$res = true;
if (Tools::strtolower($function) == 'iscleanhtml')
{
if (!Validate::$function($value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
$res = false;
}
else
if (!Validate::$function($value))
$res = false;
if (!$res)
$this->errors[] = sprintf(
Tools::displayError('The %s field is invalid.'),
call_user_func(array($className, 'displayFieldName'), $field, $className)
);
}
// Check multilingual fields validity
foreach ($rules['validateLang'] as $fieldLang => $function)
foreach ($languages as $language)
if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])))
if (!Validate::$function($value))
if (!Validate::$function($value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
$this->errors[] = sprintf(
Tools::displayError('The %1$s field (%2$s) is invalid.'),
call_user_func(array($className, 'displayFieldName'), $fieldLang, $className),
@@ -2493,7 +2532,7 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['currentIndex'] = self::$currentIndex;
$this->tpl_form_vars['display_multishop_checkboxes'] = (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->display == 'edit');
$this->fields_form = array('');
$this->display = 'edit';
$this->tpl_form_vars['token'] = $this->token;
$this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs();
$this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
@@ -2523,8 +2562,8 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize;
$this->tpl_form_vars['country_display_tax_label'] = $this->context->country->display_tax_label;
$this->tpl_form_vars['has_combinations'] = $this->object->hasAttributes();
$this->product_exists_in_shop = true;
if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id))
{
$this->product_exists_in_shop = false;
@@ -2552,12 +2591,14 @@ class AdminProductsControllerCore extends AdminController
$this->initPack($this->object);
$this->{'initForm'.$this->tab_display}($this->object);
$this->tpl_form_vars['product'] = $this->object;
if ($this->ajax)
if (!isset($this->tpl_form_vars['custom_form']))
throw new PrestaShopException('custom_form empty for action '.$this->tab_display);
else
return $this->tpl_form_vars['custom_form'];
}
$parent = parent::renderForm();
$this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch'));
return $parent;
@@ -2701,7 +2742,7 @@ class AdminProductsControllerCore extends AdminController
if (!$product_supplier_id)
{
$product->addSupplierReference($supplier->id_supplier, (int)$attribute['id_product_attribute'], $reference, (float)Tools::convertPrice($price, $id_currency), (int)$id_currency);
$product->addSupplierReference($supplier->id_supplier, (int)$attribute['id_product_attribute'], $reference, (float)$price, (int)$id_currency);
if ($product->id_supplier == $supplier->id_supplier)
{
if ((int)$attribute['id_product_attribute'] > 0)
@@ -2727,7 +2768,7 @@ class AdminProductsControllerCore extends AdminController
{
$product_supplier = new ProductSupplier($product_supplier_id);
$product_supplier->id_currency = (int)$id_currency;
$product_supplier->product_supplier_price_te = (float)Tools::convertPrice($price, $id_currency); //converted in the default currency
$product_supplier->product_supplier_price_te = (float)$price;
$product_supplier->product_supplier_reference = pSQL($reference);
$product_supplier->update();
@@ -2949,7 +2990,7 @@ class AdminProductsControllerCore extends AdminController
$data->assign(array(
'link' => $this->context->link,
'currency' => $currency = $this->context->currency,
'tax_rules_groups' => TaxRulesGroup::getTaxRulesGroups(true),
'tax_rules_groups' => TaxRulesGroup::getTaxRulesGroups(true, true),
'taxesRatesByGroup' => TaxRulesGroup::getAssociatedTaxRatesByIdCountry($this->context->country->id),
'ecotaxTaxRate' => Tax::getProductEcotaxRate(),
'tax_exclude_taxe_option' => Tax::excludeTaxeOption(),
@@ -3446,7 +3487,7 @@ class AdminProductsControllerCore extends AdminController
$data->assign('languages', $this->_languages);
$data->assign('currency', $currency);
$this->object = $product;
$this->display = 'edit';
//$this->display = 'edit';
$data->assign('product_name_redirected', Product::getProductName((int)$product->id_product_redirected, null, (int)$this->context->language->id));
/*
* Form for adding a virtual product like software, mp3, etc...
@@ -3602,12 +3643,15 @@ class AdminProductsControllerCore extends AdminController
$current_shop_id = (int)$this->context->shop->id;
else
$current_shop_id = 0;
$languages = Language::getLanguages(true);
$data->assign(array(
'countImages' => $count_images,
'id_product' => (int)Tools::getValue('id_product'),
'id_category_default' => (int)$this->_category->id,
'images' => $images,
'iso_lang' => $languages[0]['iso_code'],
'token' => $this->token,
'table' => $this->table,
'max_image_size' => $this->max_image_size / 1024 / 1024,
+18 -13
View File
@@ -75,16 +75,15 @@ class AdminScenesControllerCore extends AdminController
$images_types = ImageType::getImagesTypes('scenes');
foreach ($images_types as $k => $image_type)
{
if ($image_type['name'] == 'scene_default' && isset($_FILES['image']))
{
if ($image_type['name'] == 'scene_default' AND isset($_FILES['image']) AND isset($_FILES['image']['tmp_name']) AND !$_FILES['image']['error'])
ImageManager::resize(
$base_img_path,
_PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
(int)$image_type['width'],
(int)$image_type['height']
);
(int)$image_type['height']);
else if ($image_type['name'] == 'm_scene_default')
{
{
if (isset($_FILES['thumb']) && !$_FILES['thumb']['error'])
$base_thumb_path = _PS_SCENE_THUMB_IMG_DIR_.$obj->id.'.jpg';
else
@@ -93,8 +92,7 @@ class AdminScenesControllerCore extends AdminController
$base_thumb_path,
_PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($image_type['name']).'.jpg',
(int)$image_type['width'],
(int)$image_type['height']
);
(int)$image_type['height']);
}
}
}
@@ -207,20 +205,20 @@ class AdminScenesControllerCore extends AdminController
$this->addJqueryPlugin('imgareaselect');
$this->addJs(_PS_JS_DIR_.'admin-scene-cropping.js' );
$image_to_map_desc .= '<br /><img id="large_scene_image" alt="" src="'.
_THEME_SCENE_DIR_.$obj->id.'-scene_default.jpg" /><br />';
_THEME_SCENE_DIR_.$obj->id.'-scene_default.jpg?rand='.(int)rand().'" /><br />';
$image_to_map_desc .= '
<div id="ajax_choose_product" style="display:none; padding:6px; padding-top:2px; width:600px;">
'.$this->l('Begin typing the first few letters of the product name, then select the product you are looking for from the drop-down list:').'
<br /><input type="text" value="" id="product_autocomplete_input" />
<br /><input type="text" value="" id="product_autocomplete_input" style="width: 450px"/>
<input type="button" class="button" value="'.$this->l('OK').'" onclick="$(this).prev().search();" />
<input type="button" class="button" value="'.$this->l('Delete').'" onclick="undoEdit();" />
</div>
';
if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_.'thumbs/'.$obj->id.'-thumb_scene.jpg'))
if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_.'thumbs/'.$obj->id.'-m_scene_default.jpg'))
$image_to_map_desc .= '<br/>
<img id="large_scene_image" style="clear:both;border:1px solid black;" alt="" src="'._THEME_SCENE_DIR_.'thumbs/'.$obj->id.'-m_scene_default.jpg" />
<img id="large_scene_image" style="clear:both;border:1px solid black;" alt="" src="'._THEME_SCENE_DIR_.'thumbs/'.$obj->id.'-m_scene_default.jpg?rand='.(int)rand().'" />
<br />';
$img_alt_desc = '';
@@ -229,7 +227,7 @@ class AdminScenesControllerCore extends AdminController
.$this->l('File size:').' '.(Tools::getMaxUploadSize() / 1024).''.$this->l('Kb max.').' '
.sprintf($this->l('Automatically resized to %1$d x %2$dpx (width x height).'),
$thumb_scene_image_type['width'], $thumb_scene_image_type['height']).'.<br />'
.$this->l('Note: To change image dimensions, please change the \'thumb_scene\' image type settings to the desired size (in Back Office > Preferences > Images).');
.$this->l('Note: To change image dimensions, please change the \'m_scene_default\' image type settings to the desired size (in Back Office > Preferences > Images).');
$input_img_alt = array(
'type' => 'file',
@@ -312,7 +310,14 @@ class AdminScenesControllerCore extends AdminController
if (!Tools::isSubmit('zones') || !count(Tools::getValue('zones')))
$this->errors[] = Tools::displayError('You should create at least one zone.');
}
if (Tools::isSubmit('delete'.$this->table))
{
if (Validate::isLoadedObject($object = $this->loadObject()))
$object->deleteImage(false);
else
return false;
}
parent::postProcess();
}
}
+2 -7
View File
@@ -226,13 +226,8 @@ class AdminShopControllerCore extends AdminController
if (Tools::isSubmit('submitAddshopAndStay') || Tools::isSubmit('submitAddshop'))
{
$same_name = Db::getInstance()->getValue('
SELECT id_shop
FROM '._DB_PREFIX_.'shop
WHERE name = "'.pSQL(Tools::getValue('name')).'"
AND id_shop_group = '.(int)Tools::getValue('id_shop_group').'
'.(Tools::getValue('id_shop') ? 'AND id_shop != '.(int)Tools::getValue('id_shop') : ''));
if ($same_name)
$shop_group = new ShopGroup((int)Tools::getValue('id_shop_group'));
if ($shop_group->shopNameExists(Tools::getValue('name'), (int)Tools::getValue('id_shop')))
$this->errors[] = Tools::displayError('You cannot have two shops with the same name in the same group.');
}
@@ -394,6 +394,42 @@ class AdminShopUrlControllerCore extends AdminController
if ($this->redirect_shop_url)
$this->redirect_after = $object->getBaseURI().basename(_PS_ADMIN_DIR_).'/'.$this->context->link->getAdminLink('AdminShopUrl');
}
/**
* @param string $token
* @param integer $id
* @param string $name
* @return mixed
*/
public function displayDeleteLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('helpers/list/list_action_delete.tpl');
if (!array_key_exists('Delete', self::$cache_lang))
self::$cache_lang['Delete'] = $this->l('Delete', 'Helper');
if (!array_key_exists('DeleteItem', self::$cache_lang))
self::$cache_lang['DeleteItem'] = $this->l('Delete selected item?', 'Helper');
if (!array_key_exists('Name', self::$cache_lang))
self::$cache_lang['Name'] = $this->l('Name:', 'Helper');
if (!is_null($name))
$name = '\n\n'.self::$cache_lang['Name'].' '.$name;
$data = array(
$this->identifier => $id,
'href' => Tools::safeOutput(self::$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&id_shop='.$this->id_shop.'&token='.($token != null ? $token : $this->token)),
'action' => self::$cache_lang['Delete'],
);
if ($this->specificConfirmDelete !== false)
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : self::$cache_lang['DeleteItem'].$name;
$tpl->assign(array_merge($this->tpl_delete_link_vars, $data));
return $tpl->fetch();
}
}
@@ -181,11 +181,13 @@ class AdminStockInstantStateControllerCore extends AdminController
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if (Tools::isSubmit('csv') && (int)Tools::getValue('id_warehouse') != -1)
if ((Tools::isSubmit('csv_quantities') || Tools::isSubmit('csv_prices')) &&
(int)Tools::getValue('id_warehouse') != -1)
$limit = false;
$order_by_valuation = false;
$order_by_real_quantity = false;
if ($this->context->cookie->{$this->table.'Orderby'} == 'valuation')
{
unset($this->context->cookie->{$this->table.'Orderby'});
@@ -200,6 +202,7 @@ class AdminStockInstantStateControllerCore extends AdminController
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
$nb_items = count($this->_list);
for ($i = 0; $i < $nb_items; ++$i)
{
$item = &$this->_list[$i];
@@ -1060,8 +1060,8 @@ class AdminStockManagementControllerCore extends AdminController
{
$helper->fields_value['id_warehouse_from'] = Tools::getValue('id_warehouse_from', '');
$helper->fields_value['id_warehouse_to'] = Tools::getValue('id_warehouse_to', '');
$helper->fields_value['usable_from'] = Tools::getValue('usable_from', '');
$helper->fields_value['usable_to'] = Tools::getValue('usable_to', '');
$helper->fields_value['usable_from'] = Tools::getValue('usable_from', '1');
$helper->fields_value['usable_to'] = Tools::getValue('usable_to', '1');
}
$this->content .= $helper->generateForm($this->fields_form);
+6 -2
View File
@@ -296,8 +296,12 @@ class AdminStoresControllerCore extends AdminController
if (!($obj = $this->loadObject(true)))
return;
if (file_exists(_PS_TMP_IMG_DIR_.$this->table.'_'.(int)$obj->id.'.'.$this->imageType)) {
@unlink(_PS_TMP_IMG_DIR_.$this->table.'_'.(int)$obj->id.'.'.$this->imageType);
}
$image = ImageManager::thumbnail(_PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg', $this->table.'_'.(int)$obj->id.'.'.$this->imageType, 350, $this->imageType, true);
$image = ImageManager::thumbnail(_PS_STORE_IMG_DIR_.DIRECTORY_SEPARATOR.$obj->id.'.jpg', $this->table.'_'.(int)$obj->id.'.'.$this->imageType, 350, $this->imageType, true, true);
$days = array();
$days[1] = $this->l('Monday');
@@ -316,7 +320,7 @@ class AdminStoresControllerCore extends AdminController
'latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'),
'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'),
'image' => $image ? $image : false,
'size' => $image ? filesize(_PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg') / 1000 : false,
'size' => $image ? filesize(_PS_STORE_IMG_DIR_.DIRECTORY_SEPARATOR.$obj->id.'.jpg') / 1000 : false,
'days' => $days,
'hours' => isset($hours_unserialized) ? $hours_unserialized : false
);
+17 -11
View File
@@ -159,16 +159,6 @@ class AdminTabsControllerCore extends AdminController
),
'desc' => $this->l('Show or hide menu.')
),
array(
'type' => 'select',
'label' => $this->l('Parent:'),
'name' => 'id_parent',
'options' => array(
'query' => $tabs,
'id' => 'id_tab',
'name' => 'name'
)
)
),
'submit' => array(
'title' => $this->l(' Save '),
@@ -176,6 +166,22 @@ class AdminTabsControllerCore extends AdminController
)
);
$display_parent = true;
if (Validate::isLoadedObject($this->object) && !class_exists($this->object->class_name.'Controller'))
$display_parent = false;
if ($display_parent)
$this->fields_form['input'][] = array(
'type' => 'select',
'label' => $this->l('Parent:'),
'name' => 'id_parent',
'options' => array(
'query' => $tabs,
'id' => 'id_tab',
'name' => 'name'
)
);
return parent::renderForm();
}
@@ -324,4 +330,4 @@ class AdminTabsControllerCore extends AdminController
}
}
}
}
}
+15
View File
@@ -77,8 +77,23 @@ class AdminTagsControllerCore extends AdminController
public function postProcess()
{
if ($this->tabAccess['edit'] === '1' && Tools::getValue('submitAdd'.$this->table))
{
if (($id = (int)Tools::getValue($this->identifier)) && ($obj = new $this->className($id)) && Validate::isLoadedObject($obj))
{
$previousProducts = $obj->getProducts();
$removedProducts = array();
foreach ($previousProducts as $product)
if (!in_array($product['id_product'], $_POST['products']))
$removedProducts[] = $product['id_product'];
if (Configuration::get('PS_SEARCH_INDEXATION'))
Search::removeProductsSearchIndex($removedProducts);
$obj->setProducts($_POST['products']);
}
}
return parent::postProcess();
}
@@ -404,7 +404,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController
{
foreach ($this->selected_states as $id_state)
{
if ($tax_rules_group->hasUniqueTaxRuleForCountry($id_country, $id_state))
if ($tax_rules_group->hasUniqueTaxRuleForCountry($id_country, $id_state, $id_rule))
{
$this->errors[] = Tools::displayError('A tax rule already exists for this country/state with tax only behavior');
continue;
+2 -2
View File
@@ -122,7 +122,7 @@ class AdminThemesControllerCore extends AdminController
'fields' => array(
'PS_LOGO' => array(
'title' => $this->l('Header logo'),
'desc' => $this->l('Will appear on main page'),
'desc' => $this->l('Will appear on main page.').' '.$this->l('Recommended height: 52px. Maximum height on default theme: 65px.'),
'type' => 'file',
'thumb' => _PS_IMG_.Configuration::get('PS_LOGO').'?date='.time()
),
@@ -614,7 +614,7 @@ class AdminThemesControllerCore extends AdminController
$ext = ($field_name == 'PS_STORES_ICON') ? '.gif' : '.jpg';
$logo_name = $logo_prefix.'-'.(int)$id_shop.$ext;
if (Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL || $id_shop == 0 || Shop::isFeatureActive()==false)
if (Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL || $id_shop == 0 || Shop::isFeatureActive() == false)
$logo_name = $logo_prefix.$ext;
if ($field_name == 'PS_STORES_ICON')
@@ -353,13 +353,15 @@ class AdminTranslationsControllerCore extends AdminController
$items = Language::getFilesList($from_lang, $from_theme, $to_lang, $to_theme, false, false, true);
foreach ($items as $source => $dest)
{
$bool &= $this->checkDirAndCreate($dest);
$bool &= @copy($source, $dest);
if (strpos($dest, 'modules') && basename($source) === $from_lang.'.php' && $bool !== false)
$bool &= $this->changeModulesKeyTranslation($dest, $from_theme, $to_theme);
if (!$this->checkDirAndCreate($dest))
$this->errors[] = sprintf($this->l('Impossible to create the directory "%s".'), $dest);
elseif (!copy($source, $dest))
$this->errors[] = sprintf($this->l('Impossible to copy "%s" to "%s".'), $source, $dest);
elseif (strpos($dest, 'modules') && basename($source) === $from_lang.'.php' && $bool !== false)
if (!$this->changeModulesKeyTranslation($dest, $from_theme, $to_theme))
$this->errors[] = sprintf($this->l('Impossible to translate "$dest".'), $dest);
}
if ($bool)
if (!count($this->errors))
$this->redirect(false, 14);
$this->errors[] = $this->l('A part of the data has been copied but some of the language files could not be found.');
}
@@ -426,8 +428,8 @@ class AdminTranslationsControllerCore extends AdminController
{
$this->exportTabs();
$items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true));
$gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_.'/export/'.$this->lang_selected->iso_code.'.gzip', true);
$file_name = Tools::getCurrentUrlProtocolPrefix().Tools::getShopDomain().__PS_BASE_URI__.'translations/export/'.$this->lang_selected->iso_code.'.gzip';
$file_name = _PS_TRANSLATIONS_DIR_.'/export/'.$this->lang_selected->iso_code.'.gzip';
$gz = new Archive_Tar($file_name, true);
if ($gz->createModify($items, null, _PS_ROOT_DIR_));
{
ob_start();
@@ -440,7 +442,8 @@ class AdminTranslationsControllerCore extends AdminController
header('Content-Disposition: attachment; filename="'.$this->lang_selected->iso_code.'.gzip'.'"');
header('Content-Transfer-Encoding: binary');
ob_end_flush();
@readfile($file_name);
readfile($file_name);
@unlink($file_name);
exit;
}
$this->errors[] = Tools::displayError('An error occurred while creating archive.');
@@ -936,7 +939,6 @@ class AdminTranslationsControllerCore extends AdminController
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = html_entity_decode($GLOBALS[$name_var][$default_key], ENT_COMPAT, 'UTF-8');
else
{
//d(array($module_key, $default_key, $key, $GLOBALS[$name_var]));
$this->modules_translations[$theme_name][$module_name][$template_name][$key]['trad'] = '';
$this->missing_translations++;
}
@@ -983,8 +985,6 @@ class AdminTranslationsControllerCore extends AdminController
'header.inc.php',
'footer.inc.php',
'index.php',
'login.php',
'password.php',
'functions.php'
)
)
@@ -1066,7 +1066,7 @@ class AdminTranslationsControllerCore extends AdminController
{
case 'front':
// Parsing file in Front office
$regex = '/\{l\s*s=[\'\"]'._PS_TRANS_PATTERN_.'[\'\"](\s*sprintf=.*)?(\s*js=1)?\s*\}/U';
$regex = '/\{l\s*s=(?:\''._PS_TRANS_PATTERN_.'\'|\"'._PS_TRANS_PATTERN_.'\")(\s*sprintf=.*)?(\s*js=1)?\s*\}/U';
break;
case 'back':
@@ -1074,9 +1074,9 @@ class AdminTranslationsControllerCore extends AdminController
if ($type_file == 'php')
$regex = '/this->l\(\''._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
else if ($type_file == 'specific')
$regex = '/translate\(\''._PS_TRANS_PATTERN_.'\'\)/U';
$regex = '/Translate::getAdminTranslation\(\''._PS_TRANS_PATTERN_.'\'\)/U';
else
$regex = '/\{l\s*s\s*=[\'\"]'._PS_TRANS_PATTERN_.'[\'\"](\s*sprintf=.*)?(\s*js=1)?(\s*slashes=1)?\s*\}/U';
$regex = '/\{l\s*s\s*=(?:\''._PS_TRANS_PATTERN_.'\'|\"'._PS_TRANS_PATTERN_.'\")(\s*sprintf=.*)?(\s*js=1)?(\s*slashes=1)?\s*\}/U';
break;
case 'errors':
@@ -1090,7 +1090,7 @@ class AdminTranslationsControllerCore extends AdminController
$regex = '/->l\(\''._PS_TRANS_PATTERN_.'\'(, ?\'(.+)\')?(, ?(.+))?\)/U';
else
// In tpl file look for something that should contain mod='module_name' according to the documentation
$regex = '/\{l\s*s=[\'\"]'._PS_TRANS_PATTERN_.'[\'\"].*\s+mod=\''.$module_name.'\'.*\}/U';
$regex = '/\{l\s*s=(?:\''._PS_TRANS_PATTERN_.'\'|\"'._PS_TRANS_PATTERN_.'\").*\s+mod=\''.$module_name.'\'.*\}/U';
break;
case 'pdf':
@@ -1098,7 +1098,7 @@ class AdminTranslationsControllerCore extends AdminController
if ($type_file == 'php')
$regex = '/HTMLTemplate.*::l\(\''._PS_TRANS_PATTERN_.'\'[\)|\,]/U';
else
$regex = '/\{l\s*s=[\'\"]'._PS_TRANS_PATTERN_.'[\'\"](\s*sprintf=.*)?(\s*js=1)?(\s*pdf=\'true\')?\s*\}/U';
$regex = '/\{l\s*s=(?:\''._PS_TRANS_PATTERN_.'\'|\"'._PS_TRANS_PATTERN_.'\")(\s*sprintf=.*)?(\s*js=1)?(\s*pdf=\'true\')?\s*\}/U';
break;
}
@@ -1470,12 +1470,10 @@ class AdminTranslationsControllerCore extends AdminController
$array_subjects = array();
if (($subjects = Tools::getValue('subject')) && is_array($subjects))
{
$array_subjects['core_and_modules'] = array('translations'=>array(), 'path'=>$arr_mail_path['core_mail'].'lang.php');
$array_subjects['core_and_modules'] = array('translations' => array(), 'path' => $arr_mail_path['core_mail'].'lang.php');
foreach ($subjects as $subject_translation)
$array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation);
}
if (!empty($array_subjects))
foreach ($array_subjects as $infos)
$this->writeSubjectTranslationFile($infos['translations'], $infos['path']);
@@ -1775,12 +1773,14 @@ class AdminTranslationsControllerCore extends AdminController
if (preg_match('#controllers#', $tmp))
{
$parent_class = explode(DIRECTORY_SEPARATOR, $tmp);
$parent_class = explode(DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, $tmp));
$override = array_search('override', $parent_class);
if ($override !== false)
$prefix_key = 'Admin'.ucfirst($parent_class[count($parent_class) - 1]);
// case override/controllers/admin/templates/controller_name
$prefix_key = 'Admin'.ucfirst($parent_class[$override + 4]);
else
{
// case admin_name/themes/theme_name/template/controllers/controller_name
$key = array_search('controllers', $parent_class);
$prefix_key = 'Admin'.ucfirst($parent_class[$key + 1]);
}
@@ -2146,32 +2146,37 @@ class AdminTranslationsControllerCore extends AdminController
<div name="mails_div" id="'.$id_html.'">';
if (!empty($mails['files']))
{
$topic_already_displayed = array();
foreach ($mails['files'] as $mail_name => $mail_files)
{
if (array_key_exists('html', $mail_files) || array_key_exists('txt', $mail_files))
{
if (array_key_exists($mail_name, $all_subject_mail))
{
$subject_mail = $all_subject_mail[$mail_name];
$value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : '';
$str_return .= '
<div class="label-subject" style="text-align:center;">
<label style="text-align:right">'.sprintf($this->l('Subject for %s:'), '<em>'.$mail_name.'</em>').'</label>
<div class="mail-form" style="text-align:left">
<b>'.$subject_mail.'</b><br />';
if (isset($value_subject_mail['trad']) && $value_subject_mail['trad'])
$str_return .= '<input type="text" name="subject['.$group_name.']['.$subject_mail.']" value="'.$value_subject_mail['trad'].'" />';
else
$str_return .= '<input type="text" name="subject['.$group_name.']['.$subject_mail.']" value="" />';
foreach ($all_subject_mail[$mail_name] as $subject_mail)
{
$subject_key = 'subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']';
if (in_array($subject_key, $topic_already_displayed))
continue;
$topic_already_displayed[] = $subject_key;
$value_subject_mail = isset($mails['subject'][$subject_mail]) ? $mails['subject'][$subject_mail] : '';
$str_return .= '
<div class="label-subject" style="text-align:center;">
<label style="text-align:right">'.sprintf($this->l('Subject for %s:'), '<em>'.$mail_name.'</em>').'</label>
<div class="mail-form" style="text-align:left">
<b>'.$subject_mail.'</b><br />';
if (isset($value_subject_mail['trad']) && $value_subject_mail['trad'])
$str_return .= '<input type="text" name="subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']" value="'.$value_subject_mail['trad'].'" />';
else
$str_return .= '<input type="text" name="subject['.Tools::htmlentitiesUTF8($group_name).']['.Tools::htmlentitiesUTF8($subject_mail).']" value="" />';
if (isset($value_subject_mail['use_sprintf']) && $value_subject_mail['use_sprintf'])
{
$str_return .= '<a class="useSpecialSyntax" title="'.$this->l('This expression uses a special syntax:').' '.$value_subject_mail['use_sprintf'].'" style="cursor:pointer">
<img src="'._PS_IMG_.'admin/error.png" alt="'.$value_subject_mail['use_sprintf'].'" />
</a>';
}
if (isset($value_subject_mail['use_sprintf']) && $value_subject_mail['use_sprintf'])
$str_return .= '<a class="useSpecialSyntax" title="'.$this->l('This expression uses a special syntax:').' '.$value_subject_mail['use_sprintf'].'" style="cursor:pointer">
<img src="'._PS_IMG_.'admin/error.png" alt="'.$value_subject_mail['use_sprintf'].'" />
</a>';
$str_return .= '</div>
</div>';
</div>';
}
}
else
{
@@ -2193,12 +2198,11 @@ class AdminTranslationsControllerCore extends AdminController
}
}
else
{
$str_return .= '
<p class="error">'.$this->l('There was a problem getting the mail files.').'<br />'
.sprintf($this->l('English language files must exist in %s folder'), '<em>'.$mails['directory'].'en</em>')
.'</p>';
}
$str_return .= '<p class="error">
'.$this->l('There was a problem getting the mail files.').'<br />
'.sprintf($this->l('English language files must exist in %s folder'), '<em>'.preg_replace('@/[a-z]{2}(/?)$@', '/en$1', $mails['directory']).'</em>').'
</p>';
$str_return .= '
</div><!-- #'.$id_html.' -->
<div class="clear"></div>
@@ -2409,21 +2413,27 @@ class AdminTranslationsControllerCore extends AdminController
$content = file_get_contents($dir.'/'.$file);
$content = str_replace("\n", ' ', $content);
// Subject must match with a template, therefor we first grep the Mail::Send() function then the Mail::l() inside.
if (preg_match_all('/Mail::Send([^;]*);/si', $content, $tab))
for ($i = 0; isset($tab[1][$i]); $i++)
{
$tab2 = explode(',', $tab[1][$i]);
if (is_array($tab2))
if ($tab2 && isset($tab2[1]))
{
$tab2[1] = trim(str_replace('\'', '', $tab2[1]));
if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'/s', $tab2[2], $matches))
$subject_mail[$tab2[1]] = $matches[1];
}
if (is_array($tab2) && isset($tab2[1]))
{
$template = trim(str_replace('\'', '', $tab2[1]));
foreach ($tab2 as $tab3)
if (preg_match('/Mail::l\(\''._PS_TRANS_PATTERN_.'\'\)/Us', $tab3.')', $matches))
{
if (!isset($subject_mail[$template]))
$subject_mail[$template] = array();
if (!in_array($matches[1], $subject_mail[$template]))
$subject_mail[$template][] = $matches[1];
}
}
}
if (!in_array($file, self::$ignore_folder) && is_dir($dir.'/'.$file))
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
$subject_mail = $this->getSubjectMail($dir, $file, $subject_mail);
return $subject_mail;
}
@@ -2755,4 +2765,4 @@ class AdminTranslationsControllerCore extends AdminController
return true;
return false;
}
}
}