-
|
';
- $this->displayPack($obj);
- $content .= '
|
';
+ $smarty->assign('languages', $languages);
+ $smarty->assign('feature_shop_active', Shop::isFeatureActive());
+ $smarty->assign('displayAssoShop', $this->displayAssoShop());
+
+ $product_props = array();
+ // global informations
+ array_push($product_props, 'reference', 'supplier_reference', 'ean13', 'upc', 'location',
+ 'available_for_order', 'show_price', 'online_only',
+ 'id_manufacturer', 'id_supplier'
+ );
+
+ // specific / detailled information
+ array_push($product_props,
+ // physical product
+ 'width', 'height', 'weight', 'active',
+ // virtual product
+ 'is_virtual', 'cache_default_attribute',
+ // customization
+ 'uploadable_files', 'text_fields'
+ );
+ foreach($product_props as $prop)
+ $product->$prop = $this->getFieldValue($product, $prop);
+$product->manufacturer_name = Manufacturer::getNameById($product->id_manufacturer);
+$product->supplier_name = Supplier::getNameById($product->id_supplier);
+
+ $smarty->assign('ps_dimension_unit', Configuration::get('PS_DIMENSION_UNIT'));
+ $smarty->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT'));
+ //$product->{'pack_info'} =
+ $this->initPack($product);
/*
* Form for add a virtual product like software, mp3, etc...
*/
$productDownload = new ProductDownload();
- if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id')))
- $productDownload = new ProductDownload($id_product_download);
+ if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($product, 'id')))
+ $product->{'product_download'} = new ProductDownload($id_product_download);
+
$this->displayInitInformationAndAttachment();
- $content .= '
-
-
-
- |
+ // price.js is used in information
+ $this->addJs(_PS_JS_DIR_.'price.js');
-
-
-
-
- '.$this->l('Does this product has an associated file ?').' ';
-
- // todo handle is_virtual with the value of the product
- $exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownload->filename;
-
- if ($productDownload->id && !empty($cache_default_attribute) && !empty($productDownload->display_filename))
+ // todo handle is_virtual with the value of the product
+ $exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$product->productDownload->filename;
+ $smarty->assign('product_downloaded',
+ $product->productDownload->id
+ // it seems the following is not used
+ // && !empty($product->cache_default_attribute)
+ && !empty($product->productDownload->display_filename));
+ if (!file_exists($exists_file)
+ && !empty($product->productDownload->display_filename)
+ && !empty($product->cache_default_attribute))
{
- $check_yes = 'checked="checked"';
- $check_no = '';
+
+ $msg = sprintf(Tools::displayError('This file "%s" is missing'), $product->productDownload->display_filename);
}
else
+ $msg = '';
+
+ $smarty->assign('download_product_file_missing', $msg);
+ $smarty->assign('download_dir_writable', ProductDownload::checkWritableDir());
+
+ if (empty($product->cache_default_attribute))
{
- $check_yes = '';
- $check_no = 'checked="checked"';
- }
-
- $content .= ' '. $this->l('Yes').'
- '.$this->l('No').' ';
-
- if (!file_exists($exists_file) && !empty($productDownload->display_filename) && empty($cache_default_attribute))
- {
- $msg = sprintf(Tools::displayError('This file "%s" is missing'), $productDownload->display_filename);
- $content .= '
- '.$msg.' :
- '.realpath(_PS_DOWNLOAD_DIR_) .'/'. $productDownload->filename.'
- ';
- }
-
- if (!ProductDownload::checkWritableDir())
- {
- $content .= '
- '.$this->l('Your download repository is not writable.').'
- '.realpath(_PS_DOWNLOAD_DIR_).'
- ';
- }
-
- $content .= ' ';
- if (empty($cache_default_attribute))
- {
- if($productDownload->id)
- $content .= ' ';
-
- $content .= ' ';
-
- if (!$productDownload->checkFile())
- {
- $content .= '
- '.$this->l('Your server\'s maximum upload file size is') . ': ' . ini_get('upload_max_filesize').' ';
- if (!strval(Tools::getValue('virtual_product_filename')) OR $productDownload->id > 0)
- {
- $content .= '
- ';
- }
-
- $content .= ' ';
+ $smarty->assign('show_file_input', !strval(Tools::getValue('virtual_product_filename')) OR $product->productDownload->id > 0);
// found in informations and combination : to merge
$smarty->assign('up_filename', strval(Tools::getValue('virtual_product_filename')));
- if ($up_filename = strval(Tools::getValue('virtual_product_filename')))
- $content .= '';
+ $display_filename = ($product->productDownload->id > 0) ? $product->productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
- $content .= '
- '.$this->l('Delete this file').'';
- }
- else
- {
- $content .= '
- '.$this->l('This is the link').': '.$productDownload->getHtmlLink(false, true).'
- '.$this->l('Delete this file').'';
- }
-
- $display_filename = ($productDownload->id > 0) ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
- $content .= '
-
-
- '.$this->l('The full filename with its extension (e.g., Book.pdf)').'
-
-
- ';
-
- if (!$productDownload->id || !$productDownload->active)
+ if (!$product->productDownload->id || !$product->productDownload->active)
$hidden = 'display:none;';
+ else $hidden ='';
- $nb_downloadable = ($productDownload->id > 0) ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8');
- $date_expiration = ($productDownload->id > 0) ? ((!empty($productDownload->date_expiration) && $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' ) : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8');
- $nb_days_accessible = ($productDownload->id > 0) ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8');
- $is_shareable = ($productDownload->id > 0 && $productDownload->is_shareable) ? 'checked="checked"' : '';
-
- $content .= '
- ';
+ $product->productDownload->nb_downloadable = ($product->productDownload->id > 0) ? $product->productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8');
+ $product->productDownload->date_expiration = ($product->productDownload->id > 0) ? ((!empty($product->productDownload->date_expiration) && $product->productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($product->productDownload->date_expiration)) : '' ) : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8');
+ $product->productDownload->nb_days_accessible = ($product->productDownload->id > 0) ? $product->productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8');
+ $product->productDownload->is_shareable = $product->productDownload->id > 0 && $product->productDownload->is_shareable;
}
else
{
$error ='';
- $content .= ' '.$this->l('You used combinations, for this reason you can\'t edit your file here, but in the Combinations tab').'
- ';
- $product_attribute = ProductDownload::getAttributeFromIdProduct($this->getFieldValue($obj, 'id'));
- foreach ($product_attribute as $product)
+ $product_attribute = ProductDownload::getAttributeFromIdProduct($this->getFieldValue($product, 'id'));
+ foreach ($product_attribute as $p)
{
- $productDownloadAttribute = new ProductDownload($product['id_product_download']);
+ $productDownloadAttribute = new ProductDownload($p['id_product_download']);
$exists_file2 = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownloadAttribute->filename;
if (!file_exists($exists_file2) && !empty($productDownloadAttribute->id_product_attribute))
{
@@ -2572,66 +2398,15 @@ switch ($this->action)
';
}
}
- $content .= $error;
+ $smarty->assign('error_product_download', $error);
}
- $content .= '
-
- |
-
';
$currency = $this->context->currency;
- $content .= '
-
|
-
- ';
$content .= '
| '.$this->l('Pre-tax wholesale price:').' |
- '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
+ '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
'.$this->l('The wholesale price at which you bought this product').'
|
';
@@ -2639,7 +2414,7 @@ switch ($this->action)
| '.$this->l('Pre-tax retail price:').' |
- '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' *
+ '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' *
'.$this->l('The pre-tax retail price to sell this product').'
|
';
@@ -2668,16 +2443,16 @@ switch ($this->action)
';
foreach ($tax_rules_groups as $tax_rules_group)
- $content .= '';
+ $content .= '';
$content .= '
-
'.$this->l('Create').'
+
'.$this->l('Create').'
';
if (Tax::excludeTaxeOption())
{
$content .= ''.$this->l('Taxes are currently disabled').' ('.$this->l('Tax options').')';
- $content .= '';
+ $content .= '';
}
$content .= '
@@ -2688,7 +2463,7 @@ switch ($this->action)
| '.$this->l('Eco-tax (tax incl.):').' |
- '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
+ '.($currency->format % 2 != 0 ? $currency->sign.' ' : '').''.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
('.$this->l('already included in price').')
|
';
@@ -2710,15 +2485,15 @@ switch ($this->action)
| '.$this->l('Unit price without tax:').' |
- '.($currency->format % 2 != 0 ? ' '.$currency->sign : '').' '.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' '.$this->l('per').' '.
- (Configuration::get('PS_TAX') && $this->context->country->display_tax_label ? ''.$this->l('or').' '.($currency->format % 2 != 0 ? ' '.$currency->sign : '').'0.00'.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' '.$this->l('per').' '.$this->getFieldValue($obj, 'unity').' '.$this->l('with tax') : '').'
+ '.($currency->format % 2 != 0 ? ' '.$currency->sign : '').' '.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' '.$this->l('per').' '.
+ (Configuration::get('PS_TAX') && $this->context->country->display_tax_label ? ''.$this->l('or').' '.($currency->format % 2 != 0 ? ' '.$currency->sign : '').'0.00'.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' '.$this->l('per').' '.$this->getFieldValue($product, 'unity').' '.$this->l('with tax') : '').'
'.$this->l('Eg. $15 per Lb').'
|
| |
- getFieldValue($obj, 'on_sale') ? 'checked="checked"' : '').'value="1" />
+ getFieldValue($product, 'on_sale') ? 'checked="checked"' : '').'value="1" />
|
@@ -2752,7 +2527,7 @@ switch ($this->action)
| '.$this->l('Minimum quantity:').' |
-
+
'.$this->l('The minimum quantity to buy this product (set to 1 to disable this feature)').'
|
';
@@ -2784,7 +2559,7 @@ switch ($this->action)
| '.$this->l('Additional shipping cost:').' |
- '.($currency->format % 2 == 0 ? ' '.$currency->sign : '');
+ '.($currency->format % 2 == 0 ? ' '.$currency->sign : '');
if ($this->context->country->display_tax_label)
$content .= ' ('.$this->l('tax excl.').')';
@@ -2797,7 +2572,7 @@ switch ($this->action)
foreach ($this->_languages as $language)
$content .= '
+ value="'.stripslashes(htmlentities($this->getFieldValue($product, 'available_now', $language['id_lang']), ENT_COMPAT, 'UTF-8')).'" />
'.$this->l('Forbidden characters:').' <>;=#{}
';
$content .= ' |
@@ -2808,7 +2583,7 @@ switch ($this->action)
foreach ($this->_languages as $language)
$content .= '
+ value="'.stripslashes(htmlentities($this->getFieldValue($product, 'available_later', $language['id_lang']), ENT_COMPAT, 'UTF-8')).'" />
'.$this->l('Forbidden characters:').' <>;=#{}
';
$content .= '
@@ -2816,7 +2591,7 @@ switch ($this->action)
// Check if product has combination, to display the available date only for the product or for each combination
if (Combination::isFeatureActive())
- $countAttributes = (int)Db::getInstance()->getValue('SELECT COUNT(id_product) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$obj->id);
+ $countAttributes = (int)Db::getInstance()->getValue('SELECT COUNT(id_product) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$product->id);
if (isset($countAttributes) && $countAttributes == 0)
{
@@ -2824,7 +2599,7 @@ switch ($this->action)
| '.$this->l('Available date:').' |
-
+
'.$this->l('The available date when this product is out of stock').'
|
';
@@ -2839,9 +2614,9 @@ switch ($this->action)
| '.$this->l('When out of stock:').' |
- getFieldValue($obj, 'out_of_stock')) == 0 ? 'checked="checked"' : '').'/>
- getFieldValue($obj, 'out_of_stock') == 1 ? 'checked="checked"' : '').'/>
- getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '').'/>
+ getFieldValue($product, 'out_of_stock')) == 0 ? 'checked="checked"' : '').'/>
+ getFieldValue($product, 'out_of_stock') == 1 ? 'checked="checked"' : '').'/>
+ getFieldValue($product, 'out_of_stock') == 2 ? 'checked="checked"' : '').'/>
|
@@ -2857,7 +2632,7 @@ switch ($this->action)
var post_selected_cat;
';
$default_category = Tools::getValue('id_category', 1);
- if (!$obj->id)
+ if (!$product->id)
{
$selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->_defaultFormLanguage);
$content .= '
@@ -2870,12 +2645,12 @@ switch ($this->action)
if (Tools::isSubmit('categoryBox'))
$selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->_defaultFormLanguage);
else
- $selectedCat = Product::getProductCategoriesFull($obj->id, $this->_defaultFormLanguage);
+ $selectedCat = Product::getProductCategoriesFull($product->id, $this->_defaultFormLanguage);
}
$content .= '
@@ -2906,7 +2681,7 @@ switch ($this->action)
foreach ($this->_languages as $language)
$content .= '
+ value="'.htmlentities($this->getFieldValue($product, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8').'" />
'.$this->l('Forbidden characters:').' <>;=#{}
';
$content .= ' '.$this->l('Product page title; leave blank to use product name').'
@@ -2918,7 +2693,7 @@ switch ($this->action)
foreach ($this->_languages as $language)
$content .= '
+ value="'.htmlentities($this->getFieldValue($product, 'meta_description', $language['id_lang']), ENT_COMPAT, 'UTF-8').'" />
'.$this->l('Forbidden characters:').' <>;=#{}
';
$content .= ' '.$this->l('A single sentence for HTML header').'
@@ -2930,7 +2705,7 @@ switch ($this->action)
foreach ($this->_languages as $language)
$content .= '
+ value="'.htmlentities($this->getFieldValue($product, 'meta_keywords', $language['id_lang']), ENT_COMPAT, 'UTF-8').'" />
'.$this->l('Forbidden characters:').' <>;=#{}
';
$content .= ' '.$this->l('Keywords for HTML header, separated by a comma').'
@@ -2943,7 +2718,7 @@ switch ($this->action)
{
$content .= '
*
+ value="'.htmlentities($this->getFieldValue($product, 'link_rewrite', $language['id_lang']), ENT_COMPAT, 'UTF-8').'" onkeyup="if (isArrowKey(event)) return ;updateFriendlyURL();" onchange="updateFriendlyURL();" /> *
'.$this->l('Only letters and the "less" character are allowed').'
';
}
@@ -2960,7 +2735,7 @@ switch ($this->action)
';
foreach ($this->_languages as $language)
$content .= '
-
+
';
$content .= '
|
@@ -2970,12 +2745,12 @@ switch ($this->action)
';
foreach ($this->_languages as $language)
$content .= '
-
+
';
$content .= '
|
';
- $images = Image::getImages($this->context->language->id, $obj->id);
+ $images = Image::getImages($this->context->language->id, $product->id);
if ($images)
{
$content .= '
@@ -2999,7 +2774,7 @@ switch ($this->action)
$content .= '
';
- $urlImage = $this->context->link->getImageLink($obj->link_rewrite[$this->context->language->id], $obj->id.'-'.$image['id_image'], 'small');
+ $urlImage = $this->context->link->getImageLink($product->link_rewrite[$this->context->language->id], $product->id.'-'.$image['id_image'], 'small');
$content .= '
';
@@ -3083,20 +2858,20 @@ switch ($this->action)
| '.$this->l('Tags:').' |
';
- if ($obj->id)
- $obj->tags = Tag::getProductTags((int)$obj->id);
+ if ($product->id)
+ $product->tags = Tag::getProductTags((int)$product->id);
foreach ($this->_languages as $language)
{
$content .= '
+ value="'.htmlentities(Tools::getValue('tags_'.$language['id_lang'], $product->getTags($language['id_lang'], true)), ENT_COMPAT, 'UTF-8').'" />
'.$this->l('Forbidden characters:').' !<>;?=+#"°{}_$%
';
}
$content .= ' '.$this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)').'
|
';
- $accessories = Product::getAccessoriesLight($this->context->language->id, $obj->id);
+ $accessories = Product::getAccessoriesLight($this->context->language->id, $product->id);
if ($postAccessories = Tools::getValue('inputAccessories'))
{
@@ -3160,7 +2935,7 @@ switch ($this->action)
function getAccessorieIds()
{
- var ids = '. $obj->id.'+\',\';
+ var ids = '. $product->id.'+\',\';
ids += $(\'#inputAccessories\').val().replace(/\\-/g,\',\').replace(/\\,$/,\'\');
ids = ids.replace(/\,$/,\'\');
@@ -3195,6 +2970,8 @@ switch ($this->action)
unitPriceWithTax(\'unit\');
';
$categoryBox = Tools::getValue('categoryBox', array());
+
+ $smarty->assign('product', $product);
$smarty->assign('content', $content);
$this->content = $this->context->smarty->fetch('products/informations.tpl');
}
@@ -3662,18 +3439,17 @@ switch ($this->action)
$smarty->assign('attributes_groups', AttributeGroup::getAttributesGroups($this->context->language->id));
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
- $productDownload = new ProductDownload();
- $id_product_download = (int) $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'));
+ $product->productDownload = new ProductDownload();
+ $id_product_download = (int) $product->productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'));
if (!empty($id_product_download))
- $productDownload = new ProductDownload($id_product_download);
+ $product->productDownload = new ProductDownload($id_product_download);
- $smarty->assign('productDownload', $productDownload);
+ // $smarty->assign('productDownload', $productDownload);
$smarty->assign('currency', $currency);
$images = Image::getImages($this->context->language->id, $obj->id);
if ($obj->id)
{
- $smarty->assign('upload_max_filesize', ini_get('upload_max_filesize'));
$smarty->assign('tax_exclude_option', Tax::excludeTaxeOption());
$smarty->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT'));
@@ -3982,190 +3758,52 @@ switch ($this->action)
return false;
}
- private function displayPack(Product $obj)
+ private function initPack(Product $product)
{
- $boolPack = (($obj->id && Pack::isPack($obj->id)) || Tools::getValue('ppack')) ? true : false;
- $packItems = $boolPack ? Pack::getItems($obj->id, $this->context->language->id) : array();
-
- $this->content .= '
-
- |
-
-
- |
-
-
- ';
- foreach ($packItems as $packItem)
- $this->content .= $packItem->pack_quantity.' x '.$packItem->name.'  ';
- $this->content .= '
-
-
-
-
- '.$this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:').'
- '.$this->l('You cannot add downloadable products to a pack.').'
-
-
-
- 
- |
-
-
';
- // param multipleSeparator:'||' ajouté à cause de bug dans lib autocomplete
- $this->content .= '';
+ $smarty = $this->context->smarty;
+ $smarty->assign('is_pack', ($product->id && Pack::isPack($product->id)) || Tools::getValue('ppack'));
+ $product->packItems = Pack::getItems($product->id, $this->context->language->id);
+
+ $input_pack_items = '';
+ if(Tools::getValue('inputPackItems'))
+ $input_pack_items = Tools::getValue('inputPackItems');
+ else
+ foreach ($product->packItems as $packItem)
+ $input_pack_items .= $packItem->pack_quantity.'x'.$packItem->id.'-';
+ $smarty->assign('input_pack_items',$input_pack_items);
+ $input_namepack_items = '';
+ if (Tools::getValue('namePackItems'))
+ $input_namepack_items = Tools::getValue('namePackItems');
+ else
+ foreach ($product->packItems as $packItem)
+ $input_namepack_items.= $packItem->pack_quantity.' x '.$packItem->name.'¤';
+ $smarty->assign('input_namepack_items',$input_namepack_items);
}
- private function addPackItem()
- {
- return '
- function addPackItem()
- {
- if ($(\'#curPackItemId\').val() == \'\' || $(\'#curPackItemName\').val() == \'\')
- {
- alert(\''.$this->l('Thanks to select at least one product.').'\');
- return false;
- }
- else if ($(\'#curPackItemId\').val() == \'\' || $(\'#curPackItemQty\').val() == \'\')
- {
- alert(\''.$this->l('Thanks to set a quantity to add a product.').'\');
- return false;
- }
- var lineDisplay = $(\'#curPackItemQty\').val()+ \'x \' +$(\'#curPackItemName\').val();
-
- var divContent = $(\'#divPackItems\').html();
- divContent += lineDisplay;
- divContent += \'
\';
-
- // QTYxID-QTYxID
- var line = $(\'#curPackItemQty\').val()+ \'x\' +$(\'#curPackItemId\').val();
-
-
- $(\'#inputPackItems\').val($(\'#inputPackItems\').val() + line + \'-\');
- $(\'#divPackItems\').html(divContent);
- $(\'#namePackItems\').val($(\'#namePackItems\').val() + lineDisplay + \'¤\');
-
- $(\'#curPackItemId\').val(\'\');
- $(\'#curPackItemName\').val(\'\');
-
- $(\'#curPackItemName\').setOptions({
- extraParams: {excludeIds : getSelectedIds()}
- });
- }
- ';
- }
-
- private function delPackItem()
- {
- return '
- function delPackItem(id)
- {
- var reg = new RegExp(\'-\', \'g\');
- var regx = new RegExp(\'x\', \'g\');
-
- var div = getE(\'divPackItems\');
- var input = getE(\'inputPackItems\');
- var name = getE(\'namePackItems\');
- var select = getE(\'curPackItemId\');
- var select_quantity = getE(\'curPackItemQty\');
-
- var inputCut = input.value.split(reg);
- var nameCut = name.value.split(new RegExp(\'¤\', \'g\'));
-
- input.value = \'\';
- name.value = \'\';
- div.innerHTML = \'\';
-
- for (var i = 0; i < inputCut.length; ++i)
- if (inputCut[i])
- {
- var inputQty = inputCut[i].split(regx);
- if (inputQty[1] != id)
- {
- input.value += inputCut[i] + \'-\';
- name.value += nameCut[i] + \'¤\';
- div.innerHTML += nameCut[i] + \' 
\';
- }
- }
-
- $(\'#curPackItemName\').setOptions({
- extraParams: {excludeIds : getSelectedIds()}
- });
- }';
- }
public function updatePackItems($product)
{
Pack::deleteItems($product->id);
// lines format: QTY x ID-QTY x ID
- if (Tools::getValue('ppack') && $items = Tools::getValue('inputPackItems') && sizeof($lines = array_unique(explode('-', $items))))
+ if (Tools::getValue('ppack'))
{
- foreach ($lines as $line)
- {
- // line format QTY x ID
- list($qty, $item_id) = explode('x', $line);
- if ($qty > 0 && isset($item_id))
- {
- if (!Pack::addItem((int)($product->id), (int)($item_id), (int)($qty)))
- return false;
- }
- }
+ $items = Tools::getValue('inputPackItems');
+ $lines = array_unique(explode('-', $items));
+ // lines is an array of string with format : QTYxID
+ if(count($lines))
+ foreach ($lines as $line)
+ if (!empty($line))
+ {
+ list($qty, $item_id) = explode('x', $line);
+ if ($qty > 0 && isset($item_id))
+ {
+ if (!Pack::addItem((int)($product->id), (int)($item_id), (int)($qty)))
+ return false;
+ }
+ }
}
return true;
}
@@ -4210,6 +3848,7 @@ switch ($this->action)
$this->displayErrors();
}
+
public function displayInitInformationAndAttachment()
{
$this->addJqueryPlugin('thickbox');
diff --git a/js/admin.js b/js/admin.js
index 8e6585232..485b6b9ba 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -101,6 +101,7 @@ function strToAltImgAttr(str,encoding,ucfirst)
function copy2friendlyURL()
{
$('#link_rewrite_' + id_language).val(str2url($('#name_' + id_language).val().replace(/^[0-9]+\./, ''), 'UTF-8'));
+ return;
}
function copyMeta2friendlyURL()
@@ -927,3 +928,24 @@ function showErrorMessage(msg)
$("#ajax_confirmation").show()
.html("
"+msg+"
");
}
+
+$(document).ready(function(){
+ $(".copy2friendlyURL").live('keyup',function(e){
+ if(!isArrowKey(e))
+ return copy2friendlyURL()
+ });
+
+ // on live will make this binded for dynamic content
+ $(".updateCurrentText").live('keyup change',function(e){
+ if(typeof e == KeyboardEvent)
+ if(isArrowKey(e))
+ return;
+
+ updateCurrentText()
+ });
+
+ $(".copyMeta2friendlyURL").live('keyup',function(e){
+ if(!isArrowKey(e))
+ return copyMeta2friendlyURL()
+ });
+});