Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into bootstrap
Conflicts: admin-dev/themes/default/template/controllers/customer_threads/message.tpl admin-dev/themes/default/template/controllers/customers/helpers/view/view.tpl admin-dev/themes/default/template/controllers/import/helpers/form/form.tpl admin-dev/themes/default/template/controllers/modules/favorites.tpl admin-dev/themes/default/template/controllers/modules/list.tpl admin-dev/themes/default/template/controllers/modules/tab_module_line.tpl admin-dev/themes/default/template/controllers/modules_positions/list_modules.tpl admin-dev/themes/default/template/controllers/orders/_print_pdf_icon.tpl admin-dev/themes/default/template/controllers/orders/form.tpl admin-dev/themes/default/template/controllers/orders/helpers/view/view.tpl admin-dev/themes/default/template/controllers/products/associations.tpl admin-dev/themes/default/template/controllers/products/combinations.tpl admin-dev/themes/default/template/controllers/products/images.tpl admin-dev/themes/default/template/controllers/products/informations.tpl admin-dev/themes/default/template/controllers/products/prices.tpl admin-dev/themes/default/template/controllers/referrers/helpers/view/view.tpl admin-dev/themes/default/template/header.tpl admin-dev/themes/default/template/helpers/form/form.tpl admin-dev/themes/default/template/helpers/list/list_header.tpl classes/ProductSale.php classes/helper/HelperList.php controllers/admin/AdminCmsController.php controllers/admin/AdminCustomersController.php controllers/admin/AdminMetaController.php controllers/admin/AdminModulesController.php controllers/admin/AdminPerformanceController.php controllers/admin/AdminProductsController.php controllers/front/ParentOrderController.php install-dev/theme/views/welcome.phtml modules/blocknewproducts/blocknewproducts.php modules/blocktopmenu/blocktopmenu.php modules/importerosc/importerosc.php modules/mailalerts/mailalerts.php modules/shopimporter/shopimporter.php modules/statsstock/statsstock.php themes/default/css/product_list.css
This commit is contained in:
@@ -196,6 +196,8 @@ class AdminAttachmentsControllerCore extends AdminController
|
||||
$this->errors[] = $this->l('Failed to copy the file.');
|
||||
$_POST['file_name'] = $_FILES['file']['name'];
|
||||
@unlink($_FILES['file']['tmp_name']);
|
||||
if (!sizeof($this->errors) && isset($a) && file_exists(_PS_DOWNLOAD_DIR_.$a->file))
|
||||
unlink(_PS_DOWNLOAD_DIR_.$a->file);
|
||||
$_POST['file'] = $uniqid;
|
||||
$_POST['mime'] = $_FILES['file']['type'];
|
||||
}
|
||||
@@ -211,11 +213,14 @@ class AdminAttachmentsControllerCore extends AdminController
|
||||
'<b>'.$upload_mb.'</b>'
|
||||
);
|
||||
}
|
||||
else if (!empty($_FILES['file']['tmp_name']))
|
||||
else
|
||||
$this->errors[] = $this->l('Upload error. Please check your server configurations for the maximum upload size allowed.');
|
||||
}
|
||||
$this->validateRules();
|
||||
}
|
||||
return parent::postProcess();
|
||||
$return = parent::postProcess();
|
||||
if (!$return && isset($uniqid) && file_exists(_PS_DOWNLOAD_DIR_.$uniqid))
|
||||
unlink(_PS_DOWNLOAD_DIR_.$uniqid);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,7 +877,7 @@ class AdminCarrierWizardControllerCore extends AdminController
|
||||
$step_number = Tools::getValue('step_number');
|
||||
|
||||
if ($step_number == 4 && !Shop::isFeatureActive() || $step_number == 5 && Shop::isFeatureActive())
|
||||
return array();
|
||||
return array('fields' => array());
|
||||
|
||||
$step_fields = array(
|
||||
1 => array('name', 'delay', 'grade', 'url'),
|
||||
@@ -896,7 +896,7 @@ class AdminCarrierWizardControllerCore extends AdminController
|
||||
foreach ($definition['fields'] as $field => $def)
|
||||
if (!in_array($field, $step_fields[$step_number]))
|
||||
unset($definition['fields'][$field]);
|
||||
|
||||
|
||||
return $definition;
|
||||
}
|
||||
|
||||
|
||||
@@ -566,6 +566,8 @@ class AdminCartsControllerCore extends AdminController
|
||||
if (count($summary['products']))
|
||||
foreach ($summary['products'] as &$product)
|
||||
{
|
||||
$product['numeric_price'] = $product['price'];
|
||||
$product['numeric_total'] = $product['total'];
|
||||
$product['price'] = str_replace($currency->sign, '', Tools::displayPrice($product['price'], $currency));
|
||||
$product['total'] = str_replace($currency->sign, '', Tools::displayPrice($product['total'], $currency));
|
||||
$product['image_link'] = $this->context->link->getImageLink($product['link_rewrite'], $product['id_image'], 'small_default');
|
||||
|
||||
@@ -162,6 +162,26 @@ class AdminCmsControllerCore extends AdminController
|
||||
'cols' => 40,
|
||||
'hint' => $this->l('Invalid characters:').' <>;=#{}'
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Indexation (by search engines):'),
|
||||
'name' => 'indexation',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'indexation_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'indexation_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Displayed:'),
|
||||
|
||||
@@ -339,6 +339,8 @@ class AdminCurrenciesControllerCore extends AdminController
|
||||
}
|
||||
if (Tools::isSubmit('submitAddcurrency') && !Tools::getValue('id_currency') && Currency::exists(Tools::getValue('iso_code'), Tools::getValue('iso_code_num')))
|
||||
$this->errors[] = Tools::displayError('This currency already exists.');
|
||||
if (Tools::isSubmit('submitAddcurrency') && (float)Tools::getValue('conversion_rate') <= 0)
|
||||
$this->errors[] = Tools::displayError('This currency conversion rate can not be equal to 0.');
|
||||
parent::initProcess();
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
$contact = new Contact((int)$ct->id_contact, (int)$ct->id_lang);
|
||||
if (Validate::isLoadedObject($contact))
|
||||
{
|
||||
$from_name = $contact->name[(int)$ct->id_lang];
|
||||
$from_name = $contact->name;
|
||||
$from_email = $contact->email;
|
||||
}
|
||||
else
|
||||
@@ -401,6 +401,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
$from_name = null;
|
||||
$from_email = null;
|
||||
}
|
||||
|
||||
if (Mail::Send(
|
||||
(int)$ct->id_lang,
|
||||
'reply_msg',
|
||||
@@ -641,6 +642,12 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
ENT_QUOTES, 'UTF-8')
|
||||
);
|
||||
|
||||
$is_valid_order_id = true;
|
||||
$order = new Order((int)$message['id_order']);
|
||||
|
||||
if (!Validate::isLoadedObject($order))
|
||||
$is_valid_order_id = false;
|
||||
|
||||
$tpl->assign(array(
|
||||
'current' => self::$currentIndex,
|
||||
'token' => $this->token,
|
||||
@@ -651,7 +658,8 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
'PS_SHOP_NAME' => Configuration::get('PS_SHOP_NAME'),
|
||||
'file_name' => file_exists(_PS_UPLOAD_DIR_.$message['file_name']),
|
||||
'contacts' => $contacts,
|
||||
'PS_CUSTOMER_SERVICE_SIGNATURE' => str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', $message['id_lang']))
|
||||
'PS_CUSTOMER_SERVICE_SIGNATURE' => str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', $message['id_lang'])),
|
||||
'is_valid_order_id' => $is_valid_order_id
|
||||
));
|
||||
|
||||
return $tpl->fetch();
|
||||
|
||||
@@ -308,7 +308,7 @@ class AdminCustomersControllerCore extends AdminController
|
||||
'name' => 'passwd',
|
||||
'required' => ($obj->id ? false : true),
|
||||
'col' => '4',
|
||||
'hint' => ($obj->id ? $this->l('Leave this field blank if there\'s no change') : $this->l('Minimum of five characters (only letters and numbers).').' -_')
|
||||
'hint' => ($obj->id ? $this->l('Leave this field blank if there\'s no change') : $this->l('Minimum of five characters'))
|
||||
),
|
||||
array(
|
||||
'type' => 'birthday',
|
||||
@@ -678,9 +678,10 @@ class AdminCustomersControllerCore extends AdminController
|
||||
$carts[$i]['name'] = $carrier->name;
|
||||
}
|
||||
|
||||
$sql = 'SELECT DISTINCT id_product, c.id_cart, c.id_shop, cp.id_shop AS cp_id_shop
|
||||
$sql = 'SELECT DISTINCT cp.id_product, c.id_cart, c.id_shop, cp.id_shop AS cp_id_shop
|
||||
FROM '._DB_PREFIX_.'cart_product cp
|
||||
JOIN '._DB_PREFIX_.'cart c ON (c.id_cart = cp.id_cart)
|
||||
JOIN '._DB_PREFIX_.'product p ON (cp.id_product = p.id_product)
|
||||
WHERE c.id_customer = '.(int)$customer->id.'
|
||||
AND cp.id_product NOT IN (
|
||||
SELECT product_id
|
||||
@@ -693,6 +694,8 @@ class AdminCustomersControllerCore extends AdminController
|
||||
for ($i = 0; $i < $total_interested; $i++)
|
||||
{
|
||||
$product = new Product($interested[$i]['id_product'], false, $this->default_form_language, $interested[$i]['id_shop']);
|
||||
if (!Validate::isLoadedObject($product))
|
||||
continue;
|
||||
$interested[$i]['url'] = $this->context->link->getProductLink(
|
||||
$product->id,
|
||||
$product->link_rewrite,
|
||||
@@ -706,15 +709,15 @@ class AdminCustomersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$connections = $customer->getLastConnections();
|
||||
if (!is_array($connections))
|
||||
$connections = array();
|
||||
$total_connections = count($connections);
|
||||
for ($i = 0; $i < $total_connections; $i++)
|
||||
{
|
||||
$connections[$i]['date_add'] = Tools::displayDate($connections[$i]['date_add'],null , true);
|
||||
$connections[$i]['http_referer'] = $connections[$i]['http_referer'] ?
|
||||
preg_replace('/^www./', '', parse_url($connections[$i]['http_referer'], PHP_URL_HOST)) :
|
||||
$this->l('Direct link');
|
||||
$connections[$i]['http_referer'] = $connections[$i]['http_referer'] ? preg_replace('/^www./', '', parse_url($connections[$i]['http_referer'], PHP_URL_HOST)) : $this->l('Direct link');
|
||||
}
|
||||
|
||||
|
||||
$referrers = Referrer::getReferrers($customer->id);
|
||||
$total_referrers = count($referrers);
|
||||
for ($i = 0; $i < $total_referrers; $i++)
|
||||
|
||||
@@ -63,7 +63,8 @@ class AdminEmailsControllerCore extends AdminController
|
||||
),
|
||||
'js' => array(
|
||||
1 => 'onclick="$(\'#smtp\').slideUp();"',
|
||||
2 => 'onclick="$(\'#smtp\').slideDown();"'
|
||||
2 => 'onclick="$(\'#smtp\').slideDown();"',
|
||||
3 => 'onclick="$(\'#smtp\').slideUp();"'
|
||||
),
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
|
||||
@@ -216,7 +216,7 @@ class AdminEmployeesControllerCore extends AdminController
|
||||
'required' => true,
|
||||
'hint' => ($obj->id ?
|
||||
$this->l('Leave this field blank if you do not want to change your password.') :
|
||||
$this->l('Minimum of eight characters (use only letters and numbers)').' -_')
|
||||
$this->l('Minimum of eight characters'))
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
|
||||
@@ -303,7 +303,7 @@ class AdminHomeControllerCore extends AdminController
|
||||
|
||||
public function getMonthlyStatistics()
|
||||
{
|
||||
$currency = Tools::setCurrency($this->context->cookie);
|
||||
$currency = Tools::setCurrency((object)array('id_currency' => null));
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT IFNULL(SUM(`total_paid_real` / conversion_rate), "0") as total_sales, COUNT(*) as total_orders
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
@@ -400,7 +400,7 @@ class AdminHomeControllerCore extends AdminController
|
||||
$chart->getCurve(1)->setPoint(strtotime($row['invoice_date'].' 02:00:00'), $row['total_converted']);
|
||||
$chart->setSize(580, 170);
|
||||
$chart->setTimeMode(strtotime('-7 DAYS', time()), time(), 'd');
|
||||
$currency = Tools::setCurrency($this->context->cookie);
|
||||
$currency = Tools::setCurrency((object)array('id_currency' => null));
|
||||
$chart->getCurve(1)->setLabel($this->l('Sales + Tax').' ('.strtoupper($currency->iso_code).')');
|
||||
|
||||
$content .= $chart->fetch();
|
||||
|
||||
@@ -427,10 +427,11 @@ class AdminImagesControllerCore extends AdminController
|
||||
if (!is_dir($dir))
|
||||
return false;
|
||||
$toDel = scandir($dir);
|
||||
|
||||
foreach ($toDel as $d)
|
||||
foreach ($type as $imageType)
|
||||
if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d) || preg_match('/^([[:lower:]]{2})\-default\-(.*)\.jpg$/', $d))
|
||||
if (file_exists($dir.$d))
|
||||
if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d) || preg_match('/^([[:lower:]]{2})\-default\-'.$imageType['name'].'\.jpg$/', $d))
|
||||
if (file_exists($dir.$d))
|
||||
unlink($dir.$d);
|
||||
|
||||
// delete product images using new filesystem.
|
||||
|
||||
@@ -89,6 +89,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->l('Addresses'),
|
||||
$this->l('Manufacturers'),
|
||||
$this->l('Suppliers'),
|
||||
$this->l('Alias'),
|
||||
);
|
||||
|
||||
// @since 1.5.0
|
||||
@@ -247,13 +248,13 @@ class AdminImportControllerCore extends AdminController
|
||||
'delete_existing_images' => array(
|
||||
'label' => $this->l('Delete existing images (0 = No, 1 = Yes)')
|
||||
),
|
||||
'features' => array('label' => $this->l('Feature(Name:Value:Position)')),
|
||||
'features' => array('label' => $this->l('Feature(Name:Value:Position:Customized)')),
|
||||
'online_only' => array('label' => $this->l('Available online only (0 = No, 1 = Yes)')),
|
||||
'condition' => array('label' => $this->l('Condition')),
|
||||
'customizable' => array('label' => $this->l('Customizable (0 = No, 1 = Yes)')),
|
||||
'uploadable_files' => array('label' => $this->l('Uploadable files (0 = No, 1 = Yes)')),
|
||||
'text_fields' => array('label' => $this->l('Text fields (0 = No, 1 = Yes)')),
|
||||
'out_of_stock' => array('label' => $this->l('Out_of_stock')),
|
||||
'out_of_stock' => array('label' => $this->l('Action when out of stock')),
|
||||
'advanced_stock_management' => array('label' => $this->l('Advanced stock management')),
|
||||
'shop' => array(
|
||||
'label' => $this->l('ID / Name of shop'),
|
||||
@@ -306,7 +307,8 @@ class AdminImportControllerCore extends AdminController
|
||||
'firstname' => array('label' => $this->l('First Name *')),
|
||||
'newsletter' => array('label' => $this->l('Newsletter (0/1)')),
|
||||
'optin' => array('label' => $this->l('Opt-in (0/1)')),
|
||||
'group' => array('label' => $this->l('Groupe Name')),
|
||||
'group' => array('label' => $this->l('Groups (x,y,z...)')),
|
||||
'id_default_group' => array('label' => $this->l('Default group ID')),
|
||||
'id_shop' => array(
|
||||
'label' => $this->l('ID / Name of shop'),
|
||||
'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.'),
|
||||
@@ -361,7 +363,6 @@ class AdminImportControllerCore extends AdminController
|
||||
'postcode' => 'X'
|
||||
);
|
||||
break;
|
||||
|
||||
case $this->entities[$this->l('Manufacturers')]:
|
||||
case $this->entities[$this->l('Suppliers')]:
|
||||
//Overwrite validators AS name is not MultiLangField
|
||||
@@ -383,6 +384,7 @@ class AdminImportControllerCore extends AdminController
|
||||
'meta_title' => array('label' => $this->l('Meta title')),
|
||||
'meta_keywords' => array('label' => $this->l('Meta keywords')),
|
||||
'meta_description' => array('label' => $this->l('Meta description')),
|
||||
'image' => array('label' => $this->l('Image URL')),
|
||||
'shop' => array(
|
||||
'label' => $this->l('ID / Name of group shop'),
|
||||
'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.'),
|
||||
@@ -393,6 +395,23 @@ class AdminImportControllerCore extends AdminController
|
||||
'shop' => Shop::getGroupFromShop(Configuration::get('PS_SHOP_DEFAULT')),
|
||||
);
|
||||
break;
|
||||
case $this->entities[$this->l('Alias')]:
|
||||
//Overwrite required_fields
|
||||
$this->required_fields = array(
|
||||
'alias',
|
||||
'search',
|
||||
);
|
||||
$this->available_fields = array(
|
||||
'no' => array('label' => $this->l('Ignore this column')),
|
||||
'id' => array('label' => $this->l('ID')),
|
||||
'alias' => array('label' => $this->l('Alias *')),
|
||||
'search' => array('label' => $this->l('Search *')),
|
||||
'active' => array('label' => $this->l('Active')),
|
||||
);
|
||||
self::$default_values = array(
|
||||
'active' => '1',
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// @since 1.5.0
|
||||
@@ -456,9 +475,8 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
}
|
||||
|
||||
$this->separator = substr(strval(trim(Tools::getValue('separator', ';'))), 0, 1);
|
||||
$this->multiple_value_separator = substr(strval(trim(Tools::getValue('multiple_value_separator', ','))), 0, 1);
|
||||
|
||||
$this->separator = ($separator = Tools::substr(strval(trim(Tools::getValue('separator'))), 0, 1)) ? $separator : ';';
|
||||
$this->multiple_value_separator = ($separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1)) ? $separator : ',';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -508,11 +526,11 @@ class AdminImportControllerCore extends AdminController
|
||||
if (isset($this->context->cookie->iso_lang_selected) && $this->context->cookie->iso_lang_selected)
|
||||
$id_lang_selected = (int)Language::getIdByIso(base64_decode($this->context->cookie->iso_lang_selected));
|
||||
|
||||
$separator_selected = $this->multiple_value_separator;
|
||||
$separator_selected = $this->separator;
|
||||
if (isset($this->context->cookie->separator_selected) && $this->context->cookie->separator_selected)
|
||||
$separator_selected = base64_decode($this->context->cookie->separator_selected);
|
||||
|
||||
$multiple_value_separator_selected = $this->separator;
|
||||
$multiple_value_separator_selected = $this->multiple_value_separator;
|
||||
if (isset($this->context->cookie->multiple_value_separator_selected) && $this->context->cookie->multiple_value_separator_selected)
|
||||
$multiple_value_separator_selected = base64_decode($this->context->cookie->multiple_value_separator_selected);
|
||||
|
||||
@@ -553,8 +571,8 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
$this->context->cookie->entity_selected = (int)Tools::getValue('entity');
|
||||
$this->context->cookie->iso_lang_selected = base64_encode(Tools::getValue('iso_lang'));
|
||||
$this->context->cookie->separator_selected = base64_encode(Tools::getValue('separator'));
|
||||
$this->context->cookie->multiple_value_separator_selected = base64_encode(Tools::getValue('multiple_value_separator'));
|
||||
$this->context->cookie->separator_selected = base64_encode($this->separator);
|
||||
$this->context->cookie->multiple_value_separator_selected = base64_encode($this->multiple_value_separator);
|
||||
$this->context->cookie->csv_selected = base64_encode(Tools::getValue('csv'));
|
||||
|
||||
$this->tpl_view_vars = array(
|
||||
@@ -633,7 +651,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$html .= '<tr id="table_'.$current_table.'_line_'.$current_line.'" style="padding: 4px">';
|
||||
foreach ($line as $nb_c => $column)
|
||||
if ((MAX_COLUMNS * (int)$current_table <= $nb_c) && ((int)$nb_c < MAX_COLUMNS * ((int)$current_table + 1)))
|
||||
$html .= '<td>'.htmlentities(substr($column, 0, 200), ENT_QUOTES, 'UTF-8').'</td>';
|
||||
$html .= '<td>'.htmlentities(Tools::substr($column, 0, 200), ENT_QUOTES, 'UTF-8').'</td>';
|
||||
$html .= '</tr>';
|
||||
}
|
||||
$html .= '</table>';
|
||||
@@ -676,6 +694,8 @@ class AdminImportControllerCore extends AdminController
|
||||
protected static function rewindBomAware($handle)
|
||||
{
|
||||
// A rewind wrapper that skip BOM signature wrongly
|
||||
if (!is_resource($handle))
|
||||
return false;
|
||||
rewind($handle);
|
||||
if (($bom = fread($handle, 3)) != "\xEF\xBB\xBF")
|
||||
rewind($handle);
|
||||
@@ -871,6 +891,12 @@ class AdminImportControllerCore extends AdminController
|
||||
case 'categories':
|
||||
$path = _PS_CAT_IMG_DIR_.(int)$id_entity;
|
||||
break;
|
||||
case 'manufacturers':
|
||||
$path = _PS_MANU_IMG_DIR_.(int)$id_entity;
|
||||
break;
|
||||
case 'suppliers':
|
||||
$path = _PS_SUPP_IMG_DIR_.(int)$id_entity;
|
||||
break;
|
||||
}
|
||||
$url = str_replace(' ', '%20', trim($url));
|
||||
|
||||
@@ -947,7 +973,7 @@ class AdminImportControllerCore extends AdminController
|
||||
}
|
||||
elseif (isset($category->parent) && is_string($category->parent))
|
||||
{
|
||||
$category_parent = Category::searchByName($default_language_id, $category->parent, true);
|
||||
$category_parent = Category::searchByName($id_lang, $category->parent, true);
|
||||
if ($category_parent['id_category'])
|
||||
{
|
||||
$category->id_parent = (int)$category_parent['id_category'];
|
||||
@@ -968,7 +994,7 @@ class AdminImportControllerCore extends AdminController
|
||||
{
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$category_to_create->name[$default_language_id],
|
||||
$category_to_create->name[$id_lang],
|
||||
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null'
|
||||
);
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||
@@ -1010,8 +1036,8 @@ class AdminImportControllerCore extends AdminController
|
||||
($lang_field_error = $category->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && empty($this->errors))
|
||||
{
|
||||
$category_already_created = Category::searchByNameAndParentCategoryId(
|
||||
$default_language_id,
|
||||
$category->name[$default_language_id],
|
||||
$id_lang,
|
||||
$category->name[$id_lang],
|
||||
$category->id_parent
|
||||
);
|
||||
|
||||
@@ -1074,11 +1100,11 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
// Get shops for each attributes
|
||||
$info['shop'] = explode($this->multiple_value_separator, $info['shop']);
|
||||
|
||||
|
||||
foreach ($info['shop'] as $shop)
|
||||
if (!is_numeric($shop))
|
||||
if (!empty($shop) && !is_numeric($shop))
|
||||
$category->addShop(Shop::getIdByName($shop));
|
||||
else
|
||||
elseif (!empty($shop))
|
||||
$category->addShop($shop);
|
||||
}
|
||||
}
|
||||
@@ -1126,7 +1152,7 @@ class AdminImportControllerCore extends AdminController
|
||||
else
|
||||
$product = new Product();
|
||||
|
||||
if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product'))
|
||||
if (isset($product->id) && $product->id && Product::existsInDatabase((int)$product->id, 'product'))
|
||||
{
|
||||
$product->loadStockData();
|
||||
$category_data = Product::getProductCategories((int)$product->id);
|
||||
@@ -1150,9 +1176,9 @@ class AdminImportControllerCore extends AdminController
|
||||
// link product to shops
|
||||
$product->id_shop_list = array();
|
||||
foreach (explode($this->multiple_value_separator, $product->shop) as $shop)
|
||||
if (!is_numeric($shop))
|
||||
if (!empty($shop) && !is_numeric($shop))
|
||||
$product->id_shop_list[] = Shop::getIdByName($shop);
|
||||
else
|
||||
elseif (!empty($shop))
|
||||
$product->id_shop_list[] = $shop;
|
||||
|
||||
if ((int)$product->id_tax_rules_group != 0)
|
||||
@@ -1275,7 +1301,7 @@ class AdminImportControllerCore extends AdminController
|
||||
}
|
||||
else if (is_string($value) && !empty($value))
|
||||
{
|
||||
$category = Category::searchByName($default_language_id, trim($value), true);
|
||||
$category = Category::searchByName($id_lang, trim($value), true);
|
||||
if ($category['id_category'])
|
||||
$product->id_category[] = (int)$category['id_category'];
|
||||
else
|
||||
@@ -1393,8 +1419,10 @@ class AdminImportControllerCore extends AdminController
|
||||
$product_shop = explode($this->multiple_value_separator, $product->shop);
|
||||
foreach ($product_shop as $shop)
|
||||
{
|
||||
if (empty($shop))
|
||||
continue;
|
||||
$shop = trim($shop);
|
||||
if (!is_numeric($shop))
|
||||
if (!empty($shop) && !is_numeric($shop))
|
||||
$shop = Shop::getIdByName($shop);
|
||||
|
||||
if (in_array($shop, $shop_ids))
|
||||
@@ -1446,36 +1474,36 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
$id_shop_list = array();
|
||||
foreach ($info['shop'] as $shop)
|
||||
if (!is_numeric($shop))
|
||||
if (!empty($shop) && !is_numeric($shop))
|
||||
$id_shop_list[] = (int)Shop::getIdByName($shop);
|
||||
else
|
||||
elseif (!empty($shop))
|
||||
$id_shop_list[] = $shop;
|
||||
|
||||
if ((isset($info['reduction_price']) && $info['reduction_price'] > 0) || (isset($info['reduction_percent']) && $info['reduction_percent'] > 0))
|
||||
foreach($id_shop_list as $id_shop)
|
||||
{
|
||||
$specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
|
||||
if ((isset($info['reduction_price']) && $info['reduction_price'] > 0) || (isset($info['reduction_percent']) && $info['reduction_percent'] > 0))
|
||||
foreach($id_shop_list as $id_shop)
|
||||
{
|
||||
$specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
|
||||
|
||||
if (is_array($specific_price) && isset($specific_price['id_specific_price']))
|
||||
$specific_price = new SpecificPrice((int)$specific_price['id_specific_price']);
|
||||
else
|
||||
$specific_price = new SpecificPrice();
|
||||
$specific_price->id_product = (int)$product->id;
|
||||
$specific_price->id_specific_price_rule = 0;
|
||||
$specific_price->id_shop = $id_shop;
|
||||
$specific_price->id_currency = 0;
|
||||
$specific_price->id_country = 0;
|
||||
$specific_price->id_group = 0;
|
||||
$specific_price->price = -1;
|
||||
$specific_price->id_customer = 0;
|
||||
$specific_price->from_quantity = 1;
|
||||
$specific_price->reduction = (isset($info['reduction_price']) && $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
|
||||
$specific_price->reduction_type = (isset($info['reduction_price']) && $info['reduction_price']) ? 'amount' : 'percentage';
|
||||
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
||||
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
||||
if (!$specific_price->save())
|
||||
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
|
||||
}
|
||||
if (is_array($specific_price) && isset($specific_price['id_specific_price']))
|
||||
$specific_price = new SpecificPrice((int)$specific_price['id_specific_price']);
|
||||
else
|
||||
$specific_price = new SpecificPrice();
|
||||
$specific_price->id_product = (int)$product->id;
|
||||
$specific_price->id_specific_price_rule = 0;
|
||||
$specific_price->id_shop = $id_shop;
|
||||
$specific_price->id_currency = 0;
|
||||
$specific_price->id_country = 0;
|
||||
$specific_price->id_group = 0;
|
||||
$specific_price->price = -1;
|
||||
$specific_price->id_customer = 0;
|
||||
$specific_price->from_quantity = 1;
|
||||
$specific_price->reduction = (isset($info['reduction_price']) && $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
|
||||
$specific_price->reduction_type = (isset($info['reduction_price']) && $info['reduction_price']) ? 'amount' : 'percentage';
|
||||
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
||||
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
||||
if (!$specific_price->save())
|
||||
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
|
||||
}
|
||||
|
||||
if (isset($product->tags) && !empty($product->tags))
|
||||
{
|
||||
@@ -1489,7 +1517,8 @@ class AdminImportControllerCore extends AdminController
|
||||
if (is_array($product->tags) && count($product->tags))
|
||||
{
|
||||
foreach ($product->tags as $key => $tag)
|
||||
$product->tags[$key] = trim($tag);
|
||||
if (!empty($tag))
|
||||
$product->tags[$key] = trim($tag);
|
||||
$tags[$id_lang] = $product->tags;
|
||||
$product->tags = $tags;
|
||||
}
|
||||
@@ -1497,7 +1526,7 @@ class AdminImportControllerCore extends AdminController
|
||||
}
|
||||
// Delete tags for this id product, for no duplicating error
|
||||
Tag::deleteTagsForProduct($product->id);
|
||||
if (!is_array($product->tags))
|
||||
if (!is_array($product->tags) && !empty($product->tags))
|
||||
{
|
||||
$product->tags = AdminImportController::createMultiLangField($product->tags);
|
||||
foreach ($product->tags as $key => $tags)
|
||||
@@ -1581,14 +1610,20 @@ class AdminImportControllerCore extends AdminController
|
||||
if (isset($features['features']) && !empty($features['features']))
|
||||
foreach (explode($this->multiple_value_separator, $features['features']) as $single_feature)
|
||||
{
|
||||
if (empty($single_feature))
|
||||
continue;
|
||||
$tab_feature = explode(':', $single_feature);
|
||||
$feature_name = trim($tab_feature[0]);
|
||||
$feature_value = trim($tab_feature[1]);
|
||||
$position = isset($tab_feature[2]) ? $tab_feature[2]: false;
|
||||
$feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : '';
|
||||
$feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : '';
|
||||
$position = isset($tab_feature[2]) ? (int)$tab_feature[2] : false;
|
||||
$custom = isset($tab_feature[3]) ? (int)$tab_feature[3] : false;
|
||||
if(!empty($feature_name) && !empty($feature_value))
|
||||
{
|
||||
$id_feature = Feature::addFeatureImport($feature_name, $position);
|
||||
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value, $product->id, $id_lang);
|
||||
$id_feature = (int)Feature::addFeatureImport($feature_name, $position);
|
||||
$id_product = null;
|
||||
if (Tools::getValue('forceIDs') || Tools::getValue('match_ref'))
|
||||
$id_product = (int)$product->id;
|
||||
$id_feature_value = (int)FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom);
|
||||
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
|
||||
}
|
||||
}
|
||||
@@ -1606,7 +1641,6 @@ class AdminImportControllerCore extends AdminController
|
||||
StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id);
|
||||
|
||||
}
|
||||
|
||||
$this->closeCsvFile($handle);
|
||||
}
|
||||
|
||||
@@ -1646,11 +1680,12 @@ class AdminImportControllerCore extends AdminController
|
||||
$info['shop'] = explode($this->multiple_value_separator, $info['shop']);
|
||||
|
||||
$id_shop_list = array();
|
||||
foreach ($info['shop'] as $shop)
|
||||
if (!is_numeric($shop))
|
||||
$id_shop_list[] = Shop::getIdByName($shop);
|
||||
else
|
||||
$id_shop_list[] = $shop;
|
||||
if (is_array($info['shop']) && count($info['shop']))
|
||||
foreach ($info['shop'] as $shop)
|
||||
if (!empty($shop) && !is_numeric($shop))
|
||||
$id_shop_list[] = Shop::getIdByName($shop);
|
||||
elseif (!empty($shop))
|
||||
$id_shop_list[] = $shop;
|
||||
|
||||
if(isset($info['id_product']))
|
||||
$product = new Product((int)$info['id_product'], false, $default_language);
|
||||
@@ -1724,12 +1759,14 @@ class AdminImportControllerCore extends AdminController
|
||||
if(isset($info['group']))
|
||||
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group)
|
||||
{
|
||||
if (empty($group))
|
||||
continue;
|
||||
$tab_group = explode(':', $group);
|
||||
$group = trim($tab_group[0]);
|
||||
if (!isset($tab_group[1]))
|
||||
$type = 'select';
|
||||
else
|
||||
$type = trim($tab_group[1]);
|
||||
$type = trim($tab_group[1]);
|
||||
|
||||
// sets group
|
||||
$groups_attributes[$key]['group'] = $group;
|
||||
@@ -1779,6 +1816,8 @@ class AdminImportControllerCore extends AdminController
|
||||
if(isset($info['attribute']))
|
||||
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute)
|
||||
{
|
||||
if (empty($attribute))
|
||||
continue;
|
||||
$tab_attribute = explode(':', $attribute);
|
||||
$attribute = trim($tab_attribute[0]);
|
||||
// if position is filled
|
||||
@@ -1925,6 +1964,9 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->receiveTab();
|
||||
$handle = $this->openCsvFile();
|
||||
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
$id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
|
||||
if (!Validate::isUnsignedId($id_lang))
|
||||
$id_lang = $default_language_id;
|
||||
AdminImportController::setLocale();
|
||||
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
|
||||
{
|
||||
@@ -1952,31 +1994,45 @@ class AdminImportControllerCore extends AdminController
|
||||
$customer_exist = true;
|
||||
$customer_groups = $customer->getGroups();
|
||||
$addresses = $customer->getAddresses((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
foreach ($customer_groups as $key => $group)
|
||||
if ($group == $customer->id_default_group)
|
||||
unset($customer_groups[$key]);
|
||||
}
|
||||
|
||||
// Group Importation
|
||||
if (isset($info['group']) && !empty($info['group']))
|
||||
{
|
||||
if (!isset($customer_groups))
|
||||
$customer_groups = array();
|
||||
|
||||
$myGroup = Group::searchByName($default_language_id, $info['group']);
|
||||
|
||||
if (!$myGroup)
|
||||
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group)
|
||||
{
|
||||
$myGroup = new Group();
|
||||
$myGroup->name = Array($default_language_id => $info['group']);
|
||||
$myGroup->price_display_method = 1;
|
||||
$myGroup->add();
|
||||
$myGroup = Group::searchByName($default_language_id, $info['group']);
|
||||
$group = trim($group);
|
||||
if(empty($group))
|
||||
continue;
|
||||
$id_group = false;
|
||||
if (is_numeric($group) && $group)
|
||||
{
|
||||
$myGroup = new Group((int)$group);
|
||||
if (Validate::isLoadedObject($myGroup))
|
||||
$customer_groups[] = (int)$group;
|
||||
continue;
|
||||
}
|
||||
$myGroup = Group::searchByName($group);
|
||||
if (isset($myGroup['id_group']) && $myGroup['id_group'])
|
||||
$id_group = (int)$myGroup['id_group'];
|
||||
if (!$id_group)
|
||||
{
|
||||
$myGroup = new Group();
|
||||
$myGroup->name = Array($id_lang => $group);
|
||||
if ($id_lang != $default_language_id)
|
||||
$myGroup->name = array_merge($myGroup->name, array($default_language_id => $group));
|
||||
$myGroup->price_display_method = 1;
|
||||
$myGroup->add();
|
||||
if (Validate::isLoadedObject($myGroup))
|
||||
$id_group = (int)$myGroup->id;
|
||||
}
|
||||
if ($id_group)
|
||||
$customer_groups[] = (int)$id_group;
|
||||
}
|
||||
if (isset($myGroup['0']['id_group']))
|
||||
$customer_groups[] = $myGroup['0']['id_group'];
|
||||
}
|
||||
|
||||
elseif(empty($info['group']) && isset($customer->id) && $customer->id)
|
||||
$customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
|
||||
|
||||
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
|
||||
|
||||
if ($customer->passwd)
|
||||
@@ -1990,6 +2046,8 @@ class AdminImportControllerCore extends AdminController
|
||||
{
|
||||
foreach ($id_shop_list as $id_shop)
|
||||
{
|
||||
if (empty($id_shop))
|
||||
continue;
|
||||
$shop = new Shop((int)$id_shop);
|
||||
$group_shop = $shop->getGroup();
|
||||
if ($group_shop->share_customer)
|
||||
@@ -2011,7 +2069,18 @@ class AdminImportControllerCore extends AdminController
|
||||
//set temporally for validate field
|
||||
$customer->id_shop = $default_shop->id;
|
||||
$customer->id_shop_group = $default_shop->getGroup()->id;
|
||||
|
||||
if (isset($info['id_default_group']) && !empty($info['id_default_group']) && !is_numeric($info['id_default_group']))
|
||||
{
|
||||
$info['id_default_group'] = trim($info['id_default_group']);
|
||||
$myGroup = Group::searchByName($info['id_default_group']);
|
||||
if (isset($myGroup['id_group']) && $myGroup['id_group'])
|
||||
$info['id_default_group'] = (int)$myGroup['id_group'];
|
||||
}
|
||||
$myGroup = new Group($customer->id_default_group);
|
||||
if (!Validate::isLoadedObject($myGroup))
|
||||
$customer->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
|
||||
$customer_groups[] = (int)$customer->id_default_group;
|
||||
$customer_groups = array_flip(array_flip($customer_groups));
|
||||
$res = true;
|
||||
if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
||||
($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
|
||||
@@ -2029,12 +2098,9 @@ class AdminImportControllerCore extends AdminController
|
||||
$customer->id = $current_id_customer;
|
||||
$res &= $customer->update();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$res &= $customer->add();
|
||||
if (isset($customer_groups))
|
||||
$customer->addGroups($customer_groups);
|
||||
if (isset($addresses))
|
||||
foreach ($addresses as $address)
|
||||
{
|
||||
@@ -2043,6 +2109,8 @@ class AdminImportControllerCore extends AdminController
|
||||
Db::getInstance()->insert('address', $address);
|
||||
}
|
||||
}
|
||||
if ($res && isset($customer_groups))
|
||||
$customer->updateGroup($customer_groups);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2057,8 +2125,6 @@ class AdminImportControllerCore extends AdminController
|
||||
else
|
||||
{
|
||||
$res &= $customer->add();
|
||||
if (isset($customer_groups))
|
||||
$customer->addGroups($customer_groups);
|
||||
if (isset($addresses))
|
||||
foreach ($addresses as $address)
|
||||
{
|
||||
@@ -2067,9 +2133,12 @@ class AdminImportControllerCore extends AdminController
|
||||
Db::getInstance()->insert('address', $address);
|
||||
}
|
||||
}
|
||||
if ($res && isset($customer_groups))
|
||||
$customer->updateGroup($customer_groups);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($customer_groups);
|
||||
$customer_exist = false;
|
||||
if (!$res)
|
||||
{
|
||||
@@ -2116,7 +2185,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$country->active = 1;
|
||||
$country->name = AdminImportController::createMultiLangField($address->country);
|
||||
$country->id_zone = 0; // Default zone for country to create
|
||||
$country->iso_code = strtoupper(substr($address->country, 0, 2)); // Default iso for country to create
|
||||
$country->iso_code = Tools::strtoupper(Tools::substr($address->country, 0, 2)); // Default iso for country to create
|
||||
$country->contains_states = 0; // Default value for country to create
|
||||
$lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true);
|
||||
if (($field_error = $country->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
||||
@@ -2147,7 +2216,7 @@ class AdminImportControllerCore extends AdminController
|
||||
$state->name = $address->state;
|
||||
$state->id_country = isset($country->id) ? (int)$country->id : 0;
|
||||
$state->id_zone = 0; // Default zone for state to create
|
||||
$state->iso_code = strtoupper(substr($address->state, 0, 2)); // Default iso for state to create
|
||||
$state->iso_code = Tools::strtoupper(Tools::substr($address->state, 0, 2)); // Default iso for state to create
|
||||
$state->tax_behavior = 0;
|
||||
if (($field_error = $state->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
||||
($lang_field_error = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $state->add())
|
||||
@@ -2332,6 +2401,11 @@ class AdminImportControllerCore extends AdminController
|
||||
if (!$res)
|
||||
$res = $manufacturer->add();
|
||||
|
||||
//copying images of manufacturer
|
||||
if (isset($manufacturer->image) && !empty($manufacturer->image))
|
||||
if (!AdminImportController::copyImg($manufacturer->id, null, $manufacturer->image, 'manufacturers', !Tools::getValue('regenerate')))
|
||||
$this->warnings[] = $manufacturer->image.' '.Tools::displayError('cannot be copied.');
|
||||
|
||||
if ($res)
|
||||
{
|
||||
// Associate supplier to group shop
|
||||
@@ -2345,6 +2419,8 @@ class AdminImportControllerCore extends AdminController
|
||||
$shops = array();
|
||||
foreach ($manufacturer->shop as $shop)
|
||||
{
|
||||
if (empty($shop))
|
||||
continue;
|
||||
$shop = trim($shop);
|
||||
if (!is_numeric($shop))
|
||||
$shop = ShopGroup::getIdByName($shop);
|
||||
@@ -2403,6 +2479,11 @@ class AdminImportControllerCore extends AdminController
|
||||
if (!$res)
|
||||
$res = $supplier->add();
|
||||
|
||||
//copying images of suppliers
|
||||
if (isset($supplier->image) && !empty($supplier->image))
|
||||
if (!AdminImportController::copyImg($supplier->id, null, $supplier->image, 'suppliers', !Tools::getValue('regenerate')))
|
||||
$this->warnings[] = $supplier->image.' '.Tools::displayError('cannot be copied.');
|
||||
|
||||
if (!$res)
|
||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
@@ -2422,6 +2503,8 @@ class AdminImportControllerCore extends AdminController
|
||||
$shops = array();
|
||||
foreach ($supplier->shop as $shop)
|
||||
{
|
||||
if (empty($shop))
|
||||
continue;
|
||||
$shop = trim($shop);
|
||||
if (!is_numeric($shop))
|
||||
$shop = ShopGroup::getIdByName($shop);
|
||||
@@ -2440,6 +2523,56 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->closeCsvFile($handle);
|
||||
}
|
||||
|
||||
public function aliasImport()
|
||||
{
|
||||
$this->receiveTab();
|
||||
$handle = $this->openCsvFile();
|
||||
AdminImportController::setLocale();
|
||||
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
|
||||
{
|
||||
if (Tools::getValue('convert'))
|
||||
$line = $this->utf8EncodeArray($line);
|
||||
$info = AdminImportController::getMaskedRow($line);
|
||||
|
||||
AdminImportController::setDefaultValues($info);
|
||||
|
||||
if (Tools::getValue('forceIDs') && isset($info['id']) && (int)$info['id'])
|
||||
$alias = new Alias((int)$info['id']);
|
||||
else
|
||||
{
|
||||
if (array_key_exists('id', $info) && (int)$info['id'] && Alias::existsInDatabase((int)$info['id'], 'alias'))
|
||||
$alias = new Alias((int)$info['id']);
|
||||
else
|
||||
$alias = new Alias();
|
||||
}
|
||||
|
||||
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $alias);
|
||||
|
||||
$res = false;
|
||||
if (($field_error = $alias->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
||||
($lang_field_error = $alias->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
|
||||
{
|
||||
if ($alias->id && $alias->aliasExists($alias->id))
|
||||
$res = $alias->update();
|
||||
if (!$res)
|
||||
$res = $alias->add();
|
||||
|
||||
if (!$res)
|
||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||
$info['name'],
|
||||
(isset($info['id']) ? $info['id'] : 'null')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errors[] = $this->l('Alias is invalid').' ('.$alias->name.')';
|
||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
|
||||
}
|
||||
}
|
||||
$this->closeCsvFile($handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@@ -2479,34 +2612,32 @@ class AdminImportControllerCore extends AdminController
|
||||
$date_delivery_expected = pSQL($info['date_delivery_expected']);
|
||||
$discount_rate = (float)$info['discount_rate'];
|
||||
$is_template = (bool)$info['is_template'];
|
||||
|
||||
|
||||
$error = '';
|
||||
// checks parameters
|
||||
if (!Supplier::supplierExists($id_supplier))
|
||||
$this->errors[] = sprintf($this->l('Supplier ID (%d) is not valid (at line %d).'), $id_supplier, $current_line + 1);
|
||||
$error = sprintf($this->l('Supplier ID (%d) is not valid (at line %d).'), $id_supplier, $current_line + 1);
|
||||
if (!Language::getLanguage($id_lang))
|
||||
$this->errors[] = sprintf($this->l('Lang ID (%d) is not valid (at line %d).'), $id_lang, $current_line + 1);
|
||||
$error = sprintf($this->l('Lang ID (%d) is not valid (at line %d).'), $id_lang, $current_line + 1);
|
||||
if (!Warehouse::exists($id_warehouse))
|
||||
$this->errors[] = sprintf($this->l('Warehouse ID (%d) is not valid (at line %d).'), $id_warehouse, $current_line + 1);
|
||||
$error = sprintf($this->l('Warehouse ID (%d) is not valid (at line %d).'), $id_warehouse, $current_line + 1);
|
||||
if (!Currency::getCurrency($id_currency))
|
||||
$this->errors[] = sprintf($this->l('Currency ID (%d) is not valid (at line %d).'), $id_currency, $current_line + 1);
|
||||
$error = sprintf($this->l('Currency ID (%d) is not valid (at line %d).'), $id_currency, $current_line + 1);
|
||||
if (empty($supply_order->reference) && SupplyOrder::exists($reference))
|
||||
$this->errors[] = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1);
|
||||
$error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1);
|
||||
if (!empty($supply_order->reference) && ($supply_order->reference != $reference && SupplyOrder::exists($reference)))
|
||||
$this->errors[] = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1);
|
||||
$error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1);
|
||||
if (!Validate::isDateFormat($date_delivery_expected))
|
||||
$this->errors[] = sprintf($this->l('Date (%s) is not valid (at line %d). Format: %s.'), $date_delivery_expected,
|
||||
$current_line + 1, $this->l('YYYY-MM-DD'));
|
||||
$error = sprintf($this->l('Date (%s) is not valid (at line %d). Format: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD'));
|
||||
else if (new DateTime($date_delivery_expected) <= new DateTime('yesterday'))
|
||||
$this->errors[] = sprintf($this->l('Date (%s) cannot be in the past (at line %d). Format: %s.'), $date_delivery_expected,
|
||||
$current_line + 1, $this->l('YYYY-MM-DD'));
|
||||
$error = sprintf($this->l('Date (%s) cannot be in the past (at line %d). Format: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD'));
|
||||
if ($discount_rate < 0 || $discount_rate > 100)
|
||||
$this->errors[] = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate,
|
||||
$current_line + 1, $this->l('Format: Between 0 and 100'));
|
||||
$error = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate, $current_line + 1, $this->l('Format: Between 0 and 100'));
|
||||
if ($supply_order->id > 0 && !$supply_order->isEditable())
|
||||
$this->errors[] = sprintf($this->l('Supply Order (%d) is not editable (at line %d).'), $supply_order->id, $current_line + 1);
|
||||
$error = sprintf($this->l('Supply Order (%d) is not editable (at line %d).'), $supply_order->id, $current_line + 1);
|
||||
|
||||
// if no errors, sets supply order
|
||||
if (empty($this->errors))
|
||||
if (empty($error))
|
||||
{
|
||||
// adds parameters
|
||||
$info['id_ref_currency'] = (int)Currency::getDefaultCurrency()->id;
|
||||
@@ -2523,8 +2654,10 @@ class AdminImportControllerCore extends AdminController
|
||||
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supply_order);
|
||||
|
||||
// updatesd($supply_order);
|
||||
|
||||
$res = true;
|
||||
if ($supply_order->id > 0)
|
||||
|
||||
if ((int)$supply_order->id && ($supply_order->exists((int)$supply_order->id) || $supply_order->exists($supply_order->reference)))
|
||||
$res &= $supply_order->update();
|
||||
else
|
||||
$res &= $supply_order->add();
|
||||
@@ -2533,6 +2666,8 @@ class AdminImportControllerCore extends AdminController
|
||||
if (!$res)
|
||||
$this->errors[] = sprintf($this->l('Supply Order could not be saved (at line %d).'), $current_line + 1);
|
||||
}
|
||||
else
|
||||
$this->errors[] = $error;
|
||||
}
|
||||
|
||||
// closes
|
||||
@@ -2658,6 +2793,8 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
protected function getNbrColumn($handle, $glue)
|
||||
{
|
||||
if (!is_resource($handle))
|
||||
return false;
|
||||
$tmp = fgetcsv($handle, MAX_LINE_SIZE, $glue);
|
||||
AdminImportController::rewindBomAware($handle);
|
||||
return count($tmp);
|
||||
@@ -2672,7 +2809,10 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
protected function openCsvFile()
|
||||
{
|
||||
$handle = fopen(_PS_ADMIN_DIR_.'/import/'.strval(preg_replace('/\.{2,}/', '.', Tools::getValue('csv'))), 'r');
|
||||
$file = _PS_ADMIN_DIR_.'/import/'.strval(preg_replace('/\.{2,}/', '.', Tools::getValue('csv')));
|
||||
$handle = false;
|
||||
if (is_file($file) && is_readable($file))
|
||||
$handle = fopen($file, 'r');
|
||||
|
||||
if (!$handle)
|
||||
$this->errors[] = Tools::displayError('Cannot read the .CSV file');
|
||||
@@ -2787,6 +2927,9 @@ class AdminImportControllerCore extends AdminController
|
||||
if (preg_match('/^[0-9]+(\-(.*))?\.jpg$/', $d))
|
||||
unlink(_PS_SUPP_IMG_DIR_.$d);
|
||||
break;
|
||||
case $this->entities[$this->l('Alias')]:
|
||||
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'alias`');
|
||||
break;
|
||||
}
|
||||
Image::clearTmpDir();
|
||||
return true;
|
||||
@@ -2811,7 +2954,7 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
if (Tools::isSubmit('submitFileUpload'))
|
||||
{
|
||||
$path = _PS_ADMIN_DIR_.'/import/'.date('Ymdhis').'-';
|
||||
$path = _PS_ADMIN_DIR_.'/import/'.date('YmdHis').'-';
|
||||
if (isset($_FILES['file']) && !empty($_FILES['file']['error']))
|
||||
{
|
||||
switch ($_FILES['file']['error'])
|
||||
@@ -2885,6 +3028,9 @@ class AdminImportControllerCore extends AdminController
|
||||
$this->supplierImport();
|
||||
$this->clearSmartyCache();
|
||||
break;
|
||||
case $this->entities[$import_type = $this->l('Alias')]:
|
||||
$this->aliasImport();
|
||||
break;
|
||||
}
|
||||
|
||||
// @since 1.5.0
|
||||
@@ -3002,3 +3148,4 @@ class AdminImportControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -225,6 +225,12 @@ class AdminMetaControllerCore extends AdminController
|
||||
public function renderForm()
|
||||
{
|
||||
$files = Meta::getPages(true, ($this->object->page ? $this->object->page : false));
|
||||
|
||||
$is_index = false;
|
||||
foreach ($this->object->url_rewrite as $rewrite)
|
||||
if($is_index != true)
|
||||
$is_index = ($this->object->page == 'index' && empty($rewrite)) ? true : false;
|
||||
|
||||
$pages = array(
|
||||
'common' => array(
|
||||
'name' => $this->l('Default pages'),
|
||||
@@ -312,6 +318,7 @@ class AdminMetaControllerCore extends AdminController
|
||||
'name' => 'url_rewrite',
|
||||
'lang' => true,
|
||||
'required' => true,
|
||||
'disabled' => (bool)$is_index,
|
||||
'hint' => array(
|
||||
$this->l('Only letters and hyphens are allowed'),
|
||||
$this->l('e.g. "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php'),
|
||||
@@ -404,7 +411,7 @@ class AdminMetaControllerCore extends AdminController
|
||||
{
|
||||
fwrite($write_fd, "# Directories\n");
|
||||
foreach ($this->rb_data['Directories'] as $dir)
|
||||
fwrite($write_fd, 'Disallow: /*'.$dir."\n");
|
||||
fwrite($write_fd, 'Disallow: */'.$dir."\n");
|
||||
}
|
||||
|
||||
// Files
|
||||
|
||||
@@ -829,7 +829,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
|
||||
if (count($module_errors))
|
||||
{
|
||||
$html_error = '<ul style="line-height:20px">';
|
||||
$html_error = '<ul>';
|
||||
foreach ($module_errors as $module_error)
|
||||
{
|
||||
$html_error_description = '';
|
||||
|
||||
@@ -317,7 +317,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'{shipping_number}' => $order->shipping_number,
|
||||
'{order_name}' => $order->getUniqReference()
|
||||
);
|
||||
if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit'), $templateVars,
|
||||
if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
|
||||
$customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
|
||||
_PS_MAIL_DIR_, true, (int)$order->id_shop))
|
||||
{
|
||||
@@ -715,7 +715,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
@Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'credit_slip',
|
||||
Mail::l('New credit slip regarding your order', $order->id_lang),
|
||||
Mail::l('New credit slip regarding your order', (int)$order->id_lang),
|
||||
$params,
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname,
|
||||
@@ -1884,7 +1884,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'order_changed',
|
||||
Mail::l('Your order has been changed', $order->id_lang),
|
||||
Mail::l('Your order has been changed', (int)$order->id_lang),
|
||||
$data,
|
||||
$order->getCustomer()->email,
|
||||
$order->getCustomer()->firstname.' '.$order->getCustomer()->lastname,
|
||||
|
||||
@@ -129,9 +129,68 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
$this->fields_value['smarty_console_key'] = Configuration::get('PS_SMARTY_CONSOLE_KEY');
|
||||
}
|
||||
|
||||
public function initFieldsetFeaturesDetachables()
|
||||
public function initFieldsetDebugMode()
|
||||
{
|
||||
$this->fields_form[1]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Debug mode'),
|
||||
'image' => '../img/admin/prefs.gif'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Disable non PrestaShop modules'),
|
||||
'name' => 'native_module',
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'native_module_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'native_module_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'desc' => $this->l('Enable or disable non PrestaShop Modules.')
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Disable all overrides'),
|
||||
'name' => 'overrides',
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'overrides_module_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'overrides_module_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'desc' => $this->l('Enable or disable all classes and controllers overrides')
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
),
|
||||
);
|
||||
|
||||
$this->fields_value['native_module'] = Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
|
||||
$this->fields_value['overrides'] = Configuration::get('PS_DISABLE_OVERRIDES');
|
||||
}
|
||||
|
||||
public function initFieldsetFeaturesDetachables()
|
||||
{
|
||||
$this->fields_form[2]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Optional features'),
|
||||
'icon' => 'icon-puzzle-piece'
|
||||
@@ -190,7 +249,7 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
|
||||
public function initFieldsetCCC()
|
||||
{
|
||||
$this->fields_form[2]['form'] = array(
|
||||
$this->fields_form[3]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('CCC (Combine, Compress and Cache)'),
|
||||
'icon' => 'icon-fullscreen'
|
||||
@@ -300,7 +359,7 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
|
||||
public function initFieldsetMediaServer()
|
||||
{
|
||||
$this->fields_form[3]['form'] = array(
|
||||
$this->fields_form[4]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Media servers (use only with CCC)'),
|
||||
'icon' => 'icon-link'
|
||||
@@ -346,7 +405,8 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
$warning_mcrypt = str_replace('[a]', '<a href="http://www.php.net/manual/'.substr($php_lang, 0, 2).'/book.mcrypt.php" target="_blank">', $warning_mcrypt);
|
||||
$warning_mcrypt = str_replace('[/a]', '</a>', $warning_mcrypt);
|
||||
|
||||
$this->fields_form[4]['form'] = array(
|
||||
$this->fields_form[5]['form'] = array(
|
||||
|
||||
'legend' => array(
|
||||
'title' => $this->l('Ciphering'),
|
||||
'icon' => 'icon-desktop'
|
||||
@@ -399,7 +459,7 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
|
||||
$warning_fs = ' '.sprintf($this->l('(the directory %s must be writable)'), realpath(_PS_CACHEFS_DIRECTORY_));
|
||||
|
||||
$this->fields_form[5]['form'] = array(
|
||||
$this->fields_form[6]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Caching'),
|
||||
'icon' => 'icon-desktop'
|
||||
@@ -481,12 +541,19 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
{
|
||||
// Initialize fieldset for a form
|
||||
$this->initFieldsetSmarty();
|
||||
|
||||
if (_PS_MODE_DEV_)
|
||||
$this->initFieldsetDebugMode();
|
||||
|
||||
$this->initFieldsetFeaturesDetachables();
|
||||
$this->initFieldsetCCC();
|
||||
$this->initFieldsetMediaServer();
|
||||
$this->initFieldsetCiphering();
|
||||
$this->initFieldsetCaching();
|
||||
|
||||
// Reindex fields
|
||||
$this->fields_form = array_values($this->fields_form);
|
||||
|
||||
// Activate multiple fieldset
|
||||
$this->multiple_fieldsets = true;
|
||||
|
||||
@@ -781,6 +848,17 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
Autoload::getInstance()->generateIndex();
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAddconfiguration') && _PS_MODE_DEV_)
|
||||
{
|
||||
Configuration::updateGlobalValue('PS_DISABLE_NON_NATIVE_MODULE', (int)Tools::getValue('native_module'));
|
||||
Configuration::updateGlobalValue('PS_DISABLE_OVERRIDES', (int)Tools::getValue('overrides'));
|
||||
|
||||
if (Tools::getValue('overrides'))
|
||||
Autoload::getInstance()->_include_override_path = false;
|
||||
|
||||
Autoload::getInstance()->generateIndex();
|
||||
}
|
||||
|
||||
if ($redirectAdmin && (!isset($this->errors) || !count($this->errors)))
|
||||
{
|
||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => ''));
|
||||
|
||||
@@ -180,7 +180,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
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 .= 'shop.name as shopname, a.id_shop_default, ';
|
||||
$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)
|
||||
@@ -331,12 +331,17 @@ class AdminProductsControllerCore extends AdminController
|
||||
$nb = count($this->_list);
|
||||
if ($this->_list)
|
||||
{
|
||||
$context = $this->context->cloneContext();
|
||||
$context->shop = clone($context->shop);
|
||||
/* update product final price */
|
||||
for ($i = 0; $i < $nb; $i++)
|
||||
{
|
||||
if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP)
|
||||
$context->shop = new Shop((int)$this->_list[$i]['id_shop_default']);
|
||||
|
||||
// convert price with the currency from context
|
||||
$this->_list[$i]['price'] = Tools::convertPrice($this->_list[$i]['price'], $this->context->currency, true, $this->context);
|
||||
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 2, null, false, true, 1, true);
|
||||
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 2, null, false, true, 1, true, null, null, null, $nothing, true, true, $context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,9 +372,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
if (is_array($default_product->$field_name))
|
||||
foreach ($default_product->$field_name as $key => $value)
|
||||
$this->object->{$field_name}[$key] = ObjectModel::formatValue($value, $def['fields'][$field_name]['type']);
|
||||
$this->object->{$field_name}[$key] = $value;
|
||||
else
|
||||
$this->object->$field_name = ObjectModel::formatValue($default_product->$field_name, $def['fields'][$field_name]['type']);
|
||||
$this->object->$field_name = $default_product->$field_name;
|
||||
}
|
||||
}
|
||||
$this->object->loadStockData();
|
||||
@@ -1337,7 +1342,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (isset($result['success']))
|
||||
{
|
||||
$obj = new Image((int)$result['success']['id_image']);
|
||||
|
||||
// Associate image to shop from context
|
||||
$shops = Shop::getContextListShopID();
|
||||
$obj->associateTo($shops);
|
||||
@@ -1351,6 +1355,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
'id'=>$obj->id,
|
||||
'path' => $obj->getExistingImgPath(),
|
||||
'position' => $obj->position,
|
||||
'legend' => $obj->legend,
|
||||
'cover' => $obj->cover,
|
||||
'shops' => $json_shops,
|
||||
);
|
||||
@@ -3676,6 +3681,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
foreach ($images as $k => $image)
|
||||
$images[$k] = new Image($image['id_image']);
|
||||
|
||||
|
||||
if ($this->context->shop->getContext() == Shop::CONTEXT_SHOP)
|
||||
$current_shop_id = (int)$this->context->shop->id;
|
||||
else
|
||||
@@ -3694,8 +3700,16 @@ class AdminProductsControllerCore extends AdminController
|
||||
'max_image_size' => $this->max_image_size / 1024 / 1024,
|
||||
'up_filename' => (string)Tools::getValue('virtual_product_filename_attribute'),
|
||||
'currency' => $this->context->currency,
|
||||
'current_shop_id' => $current_shop_id
|
||||
'current_shop_id' => $current_shop_id,
|
||||
'languages' => $this->_languages,
|
||||
'default_language' => (int)Configuration::get('PS_LANG_DEFAULT')
|
||||
));
|
||||
|
||||
$type = ImageType::getByNameNType('%', 'products', 'height');
|
||||
if (isset($type['name']))
|
||||
$data->assign('imageType', $type['name']);
|
||||
else
|
||||
$data->assign('imageType', 'small_default');
|
||||
}
|
||||
else
|
||||
$this->displayWarning($this->l('You must save the product in this shop before adding images.'));
|
||||
@@ -3752,7 +3766,11 @@ class AdminProductsControllerCore extends AdminController
|
||||
$data->assign('available_date', ($this->getFieldValue($product, 'available_date') != 0) ? stripslashes(htmlentities($this->getFieldValue($product, 'available_date'), $this->context->language->id)) : '0000-00-00');
|
||||
|
||||
$i = 0;
|
||||
$data->assign('imageType', ImageType::getByNameNType('small_default', 'products'));
|
||||
$type = ImageType::getByNameNType('%', 'products', 'height');
|
||||
if (isset($type['name']))
|
||||
$data->assign('imageType', $type['name']);
|
||||
else
|
||||
$data->assign('imageType', 'small_default');
|
||||
$data->assign('imageWidth', (isset($image_type['width']) ? (int)($image_type['width']) : 64) + 25);
|
||||
foreach ($images as $k => $image)
|
||||
{
|
||||
|
||||
@@ -1410,7 +1410,9 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
||||
true,
|
||||
$supply_order->id);
|
||||
|
||||
if (!$res)
|
||||
if ($res)
|
||||
StockAvailable::synchronize($supply_order_detail->id_product);
|
||||
else
|
||||
$this->errors[] = Tools::displayError($this->l('Something went wrong when adding products to the warehouse.'));
|
||||
|
||||
$location = Warehouse::getProductLocation($supply_order_detail->id_product,
|
||||
|
||||
@@ -1259,6 +1259,8 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
// Set the path of selected theme
|
||||
if ($this->theme_selected)
|
||||
define('_PS_THEME_SELECTED_DIR_', _PS_ROOT_DIR_.'/themes/'.$this->theme_selected.'/');
|
||||
else
|
||||
define('_PS_THEME_SELECTED_DIR_', '');
|
||||
|
||||
// Get type of translation
|
||||
if (($type = Tools::getValue('type')) && !is_array($type))
|
||||
|
||||
@@ -227,19 +227,19 @@ class AddressControllerCore extends FrontController
|
||||
else // Update cart address
|
||||
$this->context->cart->autosetProductAddress();
|
||||
|
||||
if ((bool)(Tools::getValue('select_address', false)) == true OR Tools::getValue('type') == 'invoice' && Configuration::get('PS_ORDER_PROCESS_TYPE'))
|
||||
{
|
||||
$this->context->cart->id_address_invoice = (int)$address->id;
|
||||
$this->context->cart->update();
|
||||
}
|
||||
|
||||
if ((bool)(Tools::getValue('select_address', false)) == true OR (Tools::getValue('type') == 'invoice' && Configuration::get('PS_ORDER_PROCESS_TYPE')))
|
||||
$this->context->cart->id_address_invoice = (int)$address->id;
|
||||
elseif (Configuration::get('PS_ORDER_PROCESS_TYPE'))
|
||||
$this->context->cart->id_address_invoice = (int)$this->context->cart->id_address_delivery;
|
||||
$this->context->cart->update();
|
||||
|
||||
if ($this->ajax)
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => (bool)$this->errors,
|
||||
'errors' => $this->errors,
|
||||
'id_address_delivery' => $this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => $this->context->cart->id_address_invoice
|
||||
'id_address_delivery' => (int)$this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => (int)$this->context->cart->id_address_invoice
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
@@ -247,6 +247,8 @@ class AddressControllerCore extends FrontController
|
||||
// Redirect to old page or current page
|
||||
if ($back = Tools::getValue('back'))
|
||||
{
|
||||
if ($back == Tools::secureReferrer(Tools::getValue('back')))
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
$mod = Tools::getValue('mod');
|
||||
Tools::redirect('index.php?controller='.$back.($mod ? '&back='.$mod : ''));
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class AuthControllerCore extends FrontController
|
||||
if (!empty($key))
|
||||
$back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key;
|
||||
if (!empty($back))
|
||||
$this->context->smarty->assign('back', Tools::safeOutput($back));
|
||||
$this->context->smarty->assign('back', Tools::safeOutput(Tools::secureReferrer($back)));
|
||||
|
||||
if (Tools::getValue('display_guest_checkout'))
|
||||
{
|
||||
@@ -329,7 +329,7 @@ class AuthControllerCore extends FrontController
|
||||
|
||||
if (!$this->ajax)
|
||||
{
|
||||
if ($back = Tools::getValue('back'))
|
||||
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back))
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
|
||||
}
|
||||
@@ -394,7 +394,10 @@ class AuthControllerCore extends FrontController
|
||||
$firstnameAddress = Tools::getValue('firstname');
|
||||
$_POST['lastname'] = Tools::getValue('customer_lastname');
|
||||
$_POST['firstname'] = Tools::getValue('customer_firstname');
|
||||
|
||||
$addresses_types = array('address');
|
||||
if (!Configuration::get('PS_ORDER_PROCESS_TYPE') && Configuration::get('PS_GUEST_CHECKOUT_ENABLED') && Tools::getValue('invoice_address'))
|
||||
$addresses_types[] = 'address_invoice';
|
||||
|
||||
$error_phone = false;
|
||||
if (Configuration::get('PS_ONE_PHONE_AT_LEAST'))
|
||||
{
|
||||
@@ -404,10 +407,8 @@ class AuthControllerCore extends FrontController
|
||||
$error_phone = true;
|
||||
}
|
||||
elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE'))
|
||||
|| (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create')))
|
||||
&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
|
||||
$error_phone = true;
|
||||
elseif (((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Configuration::get('PS_ORDER_PROCESS_TYPE') && Tools::getValue('email_create')))
|
||||
|| (Configuration::get('PS_ORDER_PROCESS_TYPE') && !Tools::getValue('email_create'))
|
||||
|| (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && Tools::getValue('email_create')))
|
||||
&& (!Tools::getValue('phone') && !Tools::getValue('phone_mobile')))
|
||||
$error_phone = true;
|
||||
}
|
||||
@@ -465,7 +466,7 @@ class AuthControllerCore extends FrontController
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
|
||||
if ($back = Tools::getValue('back'))
|
||||
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back))
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
// redirection: if cart is not empty : redirection to the cart
|
||||
if (count($this->context->cart->getProducts(true)) > 0)
|
||||
@@ -482,37 +483,57 @@ class AuthControllerCore extends FrontController
|
||||
}
|
||||
else // if registration type is in one step, we save the address
|
||||
{
|
||||
// Preparing address
|
||||
$address = new Address();
|
||||
$_POST['lastname'] = $lastnameAddress;
|
||||
$_POST['firstname'] = $firstnameAddress;
|
||||
$address->id_customer = 1;
|
||||
$this->errors = array_unique(array_merge($this->errors, $address->validateController()));
|
||||
|
||||
// US customer: normalize the address
|
||||
if ($address->id_country == Country::getByIso('US') && Configuration::get('PS_TAASC'))
|
||||
$post_back = $_POST;
|
||||
// Preparing addresses
|
||||
foreach($addresses_types as $addresses_type)
|
||||
{
|
||||
include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
|
||||
$normalize = new AddressStandardizationSolution;
|
||||
$address->address1 = $normalize->AddressLineStandardization($address->address1);
|
||||
$address->address2 = $normalize->AddressLineStandardization($address->address2);
|
||||
$$addresses_type = new Address();
|
||||
$$addresses_type->id_customer = 1;
|
||||
|
||||
if ($addresses_type == 'address_invoice')
|
||||
foreach($_POST as $key => &$post)
|
||||
if (isset($_POST[$key.'_invoice']))
|
||||
$post = $_POST[$key.'_invoice'];
|
||||
|
||||
$this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController()));
|
||||
if ($addresses_type == 'address_invoice')
|
||||
$_POST = $post_back;
|
||||
|
||||
// US customer: normalize the address
|
||||
if ($$addresses_type->id_country == Country::getByIso('US') && Configuration::get('PS_TAASC'))
|
||||
{
|
||||
include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php');
|
||||
$normalize = new AddressStandardizationSolution;
|
||||
$$addresses_type->address1 = $normalize->AddressLineStandardization($$addresses_type->address1);
|
||||
$$addresses_type->address2 = $normalize->AddressLineStandardization($$addresses_type->address2);
|
||||
}
|
||||
|
||||
if (!($country = new Country($$addresses_type->id_country)) || !Validate::isLoadedObject($country))
|
||||
$this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country');
|
||||
$postcode = Tools::getValue('postcode');
|
||||
/* Check zip code format */
|
||||
if ($country->zip_code_format && !$country->checkZipCode($postcode))
|
||||
$this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
|
||||
elseif(empty($postcode) && $country->need_zip_code)
|
||||
$this->errors[] = Tools::displayError('A Zip / Postal code is required.');
|
||||
elseif ($postcode && !Validate::isPostCode($postcode))
|
||||
$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
|
||||
|
||||
if ($country->need_identification_number && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
|
||||
$this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');
|
||||
elseif (!$country->need_identification_number)
|
||||
$$addresses_type->dni = null;
|
||||
|
||||
if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount'))
|
||||
if (!($country = new Country($$addresses_type->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country))
|
||||
$this->errors[] = Tools::displayError('Country is invalid');
|
||||
$contains_state = isset($country) && is_object($country) ? (int)$country->contains_states: 0;
|
||||
$id_state = isset($$addresses_type) && is_object($$addresses_type) ? (int)$$addresses_type->id_state: 0;
|
||||
if ((Tools::isSubmit('submitAccount')|| Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state)
|
||||
$this->errors[] = Tools::displayError('This country requires you to choose a State.');
|
||||
}
|
||||
|
||||
if (!($country = new Country($address->id_country)) || !Validate::isLoadedObject($country))
|
||||
$this->errors[] = Tools::displayError('Country cannot be loaded with address->id_country');
|
||||
$postcode = Tools::getValue('postcode');
|
||||
/* Check zip code format */
|
||||
if ($country->zip_code_format && !$country->checkZipCode($postcode))
|
||||
$this->errors[] = sprintf(Tools::displayError('The Zip/Postal code you\'ve entered is invalid. It must follow this format: %s'), str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format))));
|
||||
elseif(empty($postcode) && $country->need_zip_code)
|
||||
$this->errors[] = Tools::displayError('A Zip / Postal code is required.');
|
||||
elseif ($postcode && !Validate::isPostCode($postcode))
|
||||
$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');
|
||||
|
||||
if ($country->need_identification_number && (!Tools::getValue('dni') || !Validate::isDniLite(Tools::getValue('dni'))))
|
||||
$this->errors[] = Tools::displayError('The identification number is incorrect or has already been used.');
|
||||
elseif (!$country->need_identification_number)
|
||||
$address->dni = null;
|
||||
}
|
||||
|
||||
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == ''))
|
||||
@@ -531,88 +552,89 @@ class AuthControllerCore extends FrontController
|
||||
|
||||
if (!count($this->errors))
|
||||
{
|
||||
// if registration type is in one step, we save the address
|
||||
if (Tools::isSubmit('submitAccount') || Tools::isSubmit('submitGuestAccount'))
|
||||
if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) || !Validate::isLoadedObject($country))
|
||||
die(Tools::displayError());
|
||||
$contains_state = isset($country) && is_object($country) ? (int)$country->contains_states: 0;
|
||||
$id_state = isset($address) && is_object($address) ? (int)$address->id_state: 0;
|
||||
if ((Tools::isSubmit('submitAccount')|| Tools::isSubmit('submitGuestAccount')) && $contains_state && !$id_state)
|
||||
$this->errors[] = Tools::displayError('This country requires you to choose a State.');
|
||||
$customer->active = 1;
|
||||
// New Guest customer
|
||||
if (Tools::isSubmit('is_new_customer'))
|
||||
$customer->is_guest = !Tools::getValue('is_new_customer', 1);
|
||||
else
|
||||
$customer->is_guest = 0;
|
||||
if (!$customer->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
else
|
||||
{
|
||||
$customer->active = 1;
|
||||
// New Guest customer
|
||||
if (Tools::isSubmit('is_new_customer'))
|
||||
$customer->is_guest = !Tools::getValue('is_new_customer', 1);
|
||||
else
|
||||
$customer->is_guest = 0;
|
||||
if (!$customer->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
else
|
||||
foreach($addresses_types as $addresses_type)
|
||||
{
|
||||
$address->id_customer = (int)$customer->id;
|
||||
$this->errors = array_unique(array_merge($this->errors, $address->validateController()));
|
||||
if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$address->add())
|
||||
$$addresses_type->id_customer = (int)$customer->id;
|
||||
if ($addresses_type == 'address_invoice')
|
||||
foreach($_POST as $key => &$post)
|
||||
if (isset($_POST[$key.'_invoice']))
|
||||
$post = $_POST[$key.'_invoice'];
|
||||
|
||||
$this->errors = array_unique(array_merge($this->errors, $$addresses_type->validateController()));
|
||||
if ($addresses_type == 'address_invoice')
|
||||
$_POST = $post_back;
|
||||
if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->add())
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your address.');
|
||||
}
|
||||
if (!count($this->errors))
|
||||
{
|
||||
if (!$customer->is_guest)
|
||||
{
|
||||
$this->context->customer = $customer;
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the default customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));
|
||||
if (!$this->sendConfirmationMail($customer))
|
||||
$this->errors[] = Tools::displayError('The email cannot be sent.');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$customer->is_guest)
|
||||
{
|
||||
$this->context->customer = $customer;
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the default customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_CUSTOMER_GROUP')));
|
||||
if (!$this->sendConfirmationMail($customer))
|
||||
$this->errors[] = Tools::displayError('The email cannot be sent.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the guest customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_GUEST_GROUP')));
|
||||
}
|
||||
$this->updateContext($customer);
|
||||
$this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
$this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
|
||||
// If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
|
||||
$this->context->cart->update();
|
||||
|
||||
// Avoid articles without delivery address on the cart
|
||||
$this->context->cart->autosetProductAddress();
|
||||
|
||||
Hook::exec('actionCustomerAccountAdd', array(
|
||||
'_POST' => $_POST,
|
||||
'newCustomer' => $customer
|
||||
));
|
||||
if ($this->ajax)
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => true,
|
||||
'id_customer' => (int)$this->context->cookie->id_customer,
|
||||
'id_address_delivery' => $this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => $this->context->cart->id_address_invoice,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
// if registration type is in two steps, we redirect to register address
|
||||
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount'))
|
||||
Tools::redirect('index.php?controller=address');
|
||||
|
||||
if ($back = Tools::getValue('back'))
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
|
||||
// redirection: if cart is not empty : redirection to the cart
|
||||
if (count($this->context->cart->getProducts(true)) > 0)
|
||||
Tools::redirect('index.php?controller=order&multi-shipping='.(int)Tools::getValue('multi-shipping'));
|
||||
// else : redirection to the account
|
||||
else
|
||||
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
|
||||
$customer->cleanGroups();
|
||||
// we add the guest customer in the guest customer group
|
||||
$customer->addGroups(array((int)Configuration::get('PS_GUEST_GROUP')));
|
||||
}
|
||||
$this->updateContext($customer);
|
||||
$this->context->cart->id_address_delivery = (int)Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
$this->context->cart->id_address_invoice = (int)Address::getFirstCustomerAddressId((int)$customer->id);
|
||||
if (isset($address_invoice) && Validate::isLoadedObject($address_invoice))
|
||||
$this->context->cart->id_address_invoice = (int)$address_invoice->id;
|
||||
|
||||
// If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
|
||||
$this->context->cart->update();
|
||||
|
||||
// Avoid articles without delivery address on the cart
|
||||
$this->context->cart->autosetProductAddress();
|
||||
|
||||
Hook::exec('actionCustomerAccountAdd', array(
|
||||
'_POST' => $_POST,
|
||||
'newCustomer' => $customer
|
||||
));
|
||||
if ($this->ajax)
|
||||
{
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
'isSaved' => true,
|
||||
'id_customer' => (int)$this->context->cookie->id_customer,
|
||||
'id_address_delivery' => $this->context->cart->id_address_delivery,
|
||||
'id_address_invoice' => $this->context->cart->id_address_invoice,
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
// if registration type is in two steps, we redirect to register address
|
||||
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount'))
|
||||
Tools::redirect('index.php?controller=address');
|
||||
|
||||
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back))
|
||||
Tools::redirect(html_entity_decode($back));
|
||||
|
||||
// redirection: if cart is not empty : redirection to the cart
|
||||
if (count($this->context->cart->getProducts(true)) > 0)
|
||||
Tools::redirect('index.php?controller=order&multi-shipping='.(int)Tools::getValue('multi-shipping'));
|
||||
// else : redirection to the account
|
||||
else
|
||||
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,9 @@ class CmsControllerCore extends FrontController
|
||||
'content_only' => (int)(Tools::getValue('content_only')),
|
||||
'path' => $path
|
||||
));
|
||||
|
||||
if ($this->cms->indexation == 0)
|
||||
$this->context->smarty->assign('nobots', true);
|
||||
}
|
||||
else if ($this->assignCase == 2)
|
||||
{
|
||||
|
||||
@@ -58,8 +58,8 @@ class OrderControllerCore extends ParentOrderController
|
||||
{
|
||||
$this->step = 0;
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'),
|
||||
Tools::displayPrice($minimal_purchase, $currency)
|
||||
Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'),
|
||||
Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency)
|
||||
);
|
||||
}
|
||||
if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3)))
|
||||
|
||||
@@ -445,6 +445,21 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
'phone_mobile_invoice' => Tools::htmlentitiesUTF8($address_invoice->phone_mobile),
|
||||
'id_country_invoice' => (int)($address_invoice->id_country),
|
||||
'id_state_invoice' => (int)($address_invoice->id_state),
|
||||
'id_address_invoice' => $id_address_invoice,
|
||||
'invoice_company' => Tools::htmlentitiesUTF8($address_invoice->company),
|
||||
'invoice_lastname' => Tools::htmlentitiesUTF8($address_invoice->lastname),
|
||||
'invoice_firstname' => Tools::htmlentitiesUTF8($address_invoice->firstname),
|
||||
'invoice_vat_number' => Tools::htmlentitiesUTF8($address_invoice->vat_number),
|
||||
'invoice_dni' => Tools::htmlentitiesUTF8($address_invoice->dni),
|
||||
'invoice_address' => $this->context->cart->id_address_invoice !== $this->context->cart->id_address_delivery,
|
||||
'invoice_address1' => Tools::htmlentitiesUTF8($address_invoice->address1),
|
||||
'invoice_address2' => Tools::htmlentitiesUTF8($address_invoice->address2),
|
||||
'invoice_postcode' => Tools::htmlentitiesUTF8($address_invoice->postcode),
|
||||
'invoice_city' => Tools::htmlentitiesUTF8($address_invoice->city),
|
||||
'invoice_phone' => Tools::htmlentitiesUTF8($address_invoice->phone),
|
||||
'invoice_phone_mobile' => Tools::htmlentitiesUTF8($address_invoice->phone_mobile),
|
||||
'invoice_id_country' => (int)($address_invoice->id_country),
|
||||
'invoice_id_state' => (int)($address_invoice->id_state),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class ParentOrderControllerCore extends FrontController
|
||||
if ((Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 && Tools::getValue('step') == 1) || Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
$this->addJS(_THEME_JS_DIR_.'order-address.js');
|
||||
$this->addJqueryPlugin('fancybox');
|
||||
if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')) || Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
|
||||
if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')) || Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 || Tools::getValue('step') == 2)
|
||||
{
|
||||
$this->addJqueryPlugin('typewatch');
|
||||
$this->addJS(_THEME_JS_DIR_.'cart-summary.js');
|
||||
@@ -465,7 +465,7 @@ class ParentOrderControllerCore extends FrontController
|
||||
$address = new Address($this->context->cart->id_address_delivery);
|
||||
$id_zone = Address::getZoneById($address->id);
|
||||
$bad_delivery = false;
|
||||
if ($bad_delivery = !Address::isCountryActiveById((int)$this->context->cart->id_address_delivery) || !Address::isCountryActiveById((int)$this->context->cart->id_address_invoice))
|
||||
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) || (!Address::isCountryActiveById((int)$this->context->cart->id_address_invoice)))
|
||||
{
|
||||
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 && Dispatcher::getInstance()->getController() != 'order-opc')
|
||||
{
|
||||
|
||||
@@ -63,23 +63,8 @@ class PdfInvoiceControllerCore extends FrontController
|
||||
$order_invoice_list = $this->order->getInvoicesCollection();
|
||||
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
|
||||
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty, $this->context->language->id);
|
||||
$pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
|
||||
$pdf->render();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the invoice template associated to the country iso_code
|
||||
* @param string $iso_user
|
||||
*/
|
||||
public function getTemplate($iso_country)
|
||||
{
|
||||
$template = _PS_THEME_PDF_DIR_.'/invoice.tpl';
|
||||
|
||||
$iso_template = _PS_THEME_PDF_DIR_.'/invoice.'.$iso_country.'.tpl';
|
||||
if (file_exists($iso_template))
|
||||
$template = $iso_template;
|
||||
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user