From adae213cec0abaddcb046de3dbe720f6aafca057 Mon Sep 17 00:00:00 2001 From: vSchoener Date: Tue, 15 Nov 2011 17:11:53 +0000 Subject: [PATCH] // Update Accounting for the return display html git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10145 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Accounting.php | 2 +- .../admin/AdminAccountingExportController.php | 7 ++++--- .../admin/AdminAccountingManagementController.php | 12 ++++++------ controllers/admin/AdminProductsController.php | 11 ++++++++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/classes/Accounting.php b/classes/Accounting.php index 61df8ff1c..89f8f465c 100644 --- a/classes/Accounting.php +++ b/classes/Accounting.php @@ -32,7 +32,7 @@ class AccountingCore * @var array $assoZoneShopList correspond to an associated list of id_zone - id_shop - num * @return bool To know if any modification in the database succeed */ - public static function setAccountNumberByZoneShop($assoZoneShopList, $table) + public static function setAccountNumberByZoneShop($assoZoneShopList) { $query = ' REPLACE INTO`'._DB_PREFIX_.'accounting_zone_shop` diff --git a/controllers/admin/AdminAccountingExportController.php b/controllers/admin/AdminAccountingExportController.php index 61b3cff5b..f66340ee5 100644 --- a/controllers/admin/AdminAccountingExportController.php +++ b/controllers/admin/AdminAccountingExportController.php @@ -138,9 +138,9 @@ class AdminAccountingExportControllerCore extends AdminController private function checkRights() { if (!is_writeable($this->downloadDir)) - $this->prevent['errors'][] = $this->l('The download folder doesn\'t have the sufficient right…'); + $this->_errors[] = $this->l('The download folder doesn\'t have the sufficient right…'); if (!($this->fd = fopen($this->downloadFile, 'w+'))) - $this->prevent['errors'][] = $this->l('The file can\'t be opened or created, please check the right'); + $this->_errors[] = $this->l('The file can\'t be opened or created, please check the right'); @chmod($this->downloadFile, 0777); } @@ -222,7 +222,7 @@ class AdminAccountingExportControllerCore extends AdminController { $this->checkRights(); - if (!count($this->prevent['errors']) && $this->fd !== NULL) + if (!count($this->_errors) && $this->fd !== NULL) { $buffer = ''; foreach($this->exportTypeList[$this->exportSelected]['fields'] as $key => $translation) @@ -238,6 +238,7 @@ class AdminAccountingExportControllerCore extends AdminController $buffer .= $val.';'; fwrite($this->fd, rtrim($buffer, ';')."\r\n"); } + $this->confirmations[] = $this->l('Export has been successfully done'); } } diff --git a/controllers/admin/AdminAccountingManagementController.php b/controllers/admin/AdminAccountingManagementController.php index 3219f1fa1..d694a7240 100644 --- a/controllers/admin/AdminAccountingManagementController.php +++ b/controllers/admin/AdminAccountingManagementController.php @@ -133,12 +133,12 @@ class AdminAccountingManagementControllerCore extends AdminController 'num' => $num); // Save to the database the account - if (count($tab)) - { - Accounting::setAccountNumberByZoneShop($tab); - $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; - Tools::redirectAdmin(self::$currentIndex.'&token='.$token); - } + if (count($tab) && Accounting::setAccountNumberByZoneShop($tab)) + $this->confirmations[] = $this->l('Account numbers have been updated'); + else + $this->_errors[] = $this->l('Account Numbers could not be updated or added in the database'); + //$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; + //Tools::redirectAdmin(self::$currentIndex.'&token='.$token); } } diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index e76548cd5..09678ddb2 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -810,7 +810,7 @@ class AdminProductsController extends AdminController { $specificPrice = new SpecificPrice(); $specificPrice->id_product = $id_product; - $specificPrice->id_product_attribute = (int)Tools::getValue('sp_id_product_attribute'); + $specificPrice->id_product_attribute = (int)Tools::getValue('id_product_attribute'); $specificPrice->id_shop = (int)$id_shop; $specificPrice->id_currency = (int)($id_currency); $specificPrice->id_country = (int)($id_country); @@ -1848,11 +1848,13 @@ if (false) } return $preview_url; } + /** * Post traitment for accounting */ public function postProcessFormAccounting() { + if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product'))))) { $id_shop = $this->context->shop->getID(); @@ -1870,8 +1872,11 @@ if (false) 'id_shop' => $id_shop, 'num' => $num); - if (count($tab)) - Accounting::saveProductAccountingInformations($tab); + // Save to the database the account + if (count($tab) && Accounting::saveProductAccountingInformations($tab)) + $this->confirmations[] = $this->l('Account numbers have been updated'); + else + $this->_errors[] = $this->l('Account Numbers could not be updated or added in the database'); } } }