From 758d9297f1f62f260db9bba3c10e4e7d02bb4f6a Mon Sep 17 00:00:00 2001 From: lLefevre Date: Tue, 20 Dec 2011 13:06:28 +0000 Subject: [PATCH] [-] MO : #PSTEST-41 : update ProcessAttachment method --- .../themes/template/products/attachments.tpl | 34 +++++++++++++++++++ admin-dev/themes/template/products/form.tpl | 14 -------- controllers/admin/AdminProductsController.php | 9 +++++ 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/admin-dev/themes/template/products/attachments.tpl b/admin-dev/themes/template/products/attachments.tpl index 0dcd3034c..6eabf56b6 100644 --- a/admin-dev/themes/template/products/attachments.tpl +++ b/admin-dev/themes/template/products/attachments.tpl @@ -99,11 +99,45 @@
 
+ {/if} diff --git a/admin-dev/themes/template/products/form.tpl b/admin-dev/themes/template/products/form.tpl index edcb44727..795d625da 100644 --- a/admin-dev/themes/template/products/form.tpl +++ b/admin-dev/themes/template/products/form.tpl @@ -165,20 +165,6 @@ $('#desc-product-newCombination').show(); populate_attrs(); } - else if (btn_name == 'Attachments') - { - $("#addAttachment").live('click', function() { - return !$("#selectAttachment2 option:selected").remove().appendTo("#selectAttachment1"); - }); - $("#removeAttachment").live('click', function() { - return !$("#selectAttachment1 option:selected").remove().appendTo("#selectAttachment2"); - }); - $("#product").submit(function() { - $("#selectAttachment1 option").each(function(i) { - $(this).attr("selected", "selected"); - }); - }); - } else { $('#desc-product-newCombination').hide(); diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 75009081e..e75af17db 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1024,6 +1024,15 @@ class AdminProductsControllerCore extends AdminController */ public function postProcess($token = null) { + if ($this->action == 'attachments') + if ($id = (int)Tools::getValue($this->identifier)) + { + $attachments = trim(Tools::getValue('arrayAttachments'), ','); + $attachments_tab = explode(',', $attachments); + if (Attachment::attachToProduct($id, $attachments_tab)) + $this->redirect_after = self::$currentIndex.'&id_product='.(int)$id.(isset($_POST['id_category']) ? '&id_category='.(int)$_POST['id_category'] : '').'&conf=4&add'.$this->table.'&action=Attachments&token='.($token ? $token : $this->token); + } + if (!$this->redirect_after) parent::postProcess(true); }