- Accounting: Add new tab for product to define the number liable to an existing zone, update upgrader and installer

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9986 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vSchoener
2011-11-09 14:16:28 +00:00
parent 14c94558a6
commit 5016b3ca0d
8 changed files with 234 additions and 21 deletions
+51 -10
View File
@@ -28,11 +28,11 @@
class AccountingCore
{
/**
* Set an account number to a zone
* Set an account number to a zone (will be refactoring for a dynamic use depending of the Controller)
* @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)
public static function setAccountNumberByZoneShop($assoZoneShopList, $table)
{
$query = '
REPLACE INTO`'._DB_PREFIX_.'accounting_zone_shop`
@@ -53,16 +53,57 @@ class AccountingCore
}
/**
* Get an account number by zone
* @var int $id_zone
* @return string
* Add or update product accounting information for a product (will be refactoring for a dynamic use depending of the Controller)
* @param int $id_product
* @param array $accountingInfos
*/
public static function getAccountNumberByZone($id_zone, $id_shop)
public static function saveProductAccountingInformations($assoProductZoneShop)
{
return Db::getInstance()->getValue('
SELECT `accounting_account_number`
$query = '
REPLACE INTO`'._DB_PREFIX_.'accounting_product_zone_shop`
(id_zone, id_shop, id_product, account_number)
VALUES %s';
$values = '';
foreach($assoProductZoneShop as $asso)
if (array_key_exists('id_zone', $asso) &&
array_key_exists('id_shop', $asso) &&
array_key_exists('id_product', $asso) &&
array_key_exists('num', $asso))
$values .= '('.(int)$asso['id_zone'].','.(int)$asso['id_shop'].','.(int)$asso['id_product'].', \''.pSQL($asso['num']).'\'), ';
$query = sprintf($query, rtrim($values, ', '));
if (!empty($values))
return Db::getInstance()->execute($query);
return false;
}
/**
* Get product account number list by zone (will be refactoring for a dynamic use depending of the Controller)
* @var int $id_zone
* @var int $id_shop
* @return array
*/
public static function getProductAccountNumberZoneShop($id_product, $id_shop)
{
return Db::getInstance()->executeS('
SELECT `account_number`, `id_zone`
FROM `'._DB_PREFIX_.'accounting_product_zone_shop`
WHERE `id_product` = '.(int)$id_product.'
AND `id_shop` = '.(int)$id_shop);
}
/**
* Get shop account number list by zone (will be refactoring for a dynamic use depending of the Controller)
* @var int $id_zone
* @var int $id_shop
* @return array
*/
public static function getAccountNumberZoneShop($id_shop)
{
return Db::getInstance()->executeS('
SELECT `id_shop`, `id_zone`, `account_number`
FROM `'._DB_PREFIX_.'accounting_zone_shop`
WHERE `id_zone` = '.(int)$id_zone).'
AND id_shop` = '.(int)$id_shop;
WHERE `id_shop` = '.(int)$id_shop);
}
}