diff --git a/admin-dev/themes/default/template/controllers/accounting_export/menu.tpl b/admin-dev/themes/default/template/controllers/accounting_export/menu.tpl
index c670312ff..f29c9abeb 100644
--- a/admin-dev/themes/default/template/controllers/accounting_export/menu.tpl
+++ b/admin-dev/themes/default/template/controllers/accounting_export/menu.tpl
@@ -24,74 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA
*}
-
-
{foreach from=$preventList key=name item=preventType}
{if !empty($preventType)}
@@ -102,16 +34,4 @@
{/if}
{/foreach}
-
+
diff --git a/cache/class_index.php b/cache/class_index.php
index 85e0ba68a..2f02131f3 100644
--- a/cache/class_index.php
+++ b/cache/class_index.php
@@ -13,6 +13,8 @@
'AddressesControllerCore' => 'controllers/front/AddressesController.php',
'AdminAccessController' => 'override/controllers/admin/AdminAccessController.php',
'AdminAccessControllerCore' => 'controllers/admin/AdminAccessController.php',
+ 'AdminAccountingConfigurationController' => '',
+ 'AdminAccountingConfigurationControllerCore' => 'controllers/admin/AdminAccountingConfigurationController.php',
'AdminAccountingExportController' => 'override/controllers/admin/AdminAccountingExportController.php',
'AdminAccountingExportControllerCore' => 'controllers/admin/AdminAccountingExportController.php',
'AdminAccountingManagementController' => 'override/controllers/admin/AdminAccountingManagementController.php',
diff --git a/classes/Accounting.php b/classes/Accounting.php
index 56f1f38f7..182a5a6ac 100644
--- a/classes/Accounting.php
+++ b/classes/Accounting.php
@@ -27,6 +27,24 @@
class AccountingCore
{
+ const CONF_NAME = 'ACCOUNTING_CONFIGURATION';
+
+ /**
+ * Default Values
+ *
+ * @var array
+ */
+ public static $acc_conf = array(
+ 'customer_prefix' => '411',
+ 'journal' => 'VE',
+ 'account_length' => 13,
+ 'account_submit_shipping_charge' => '708510',
+ 'account_unsubmit_shipping_charge' => '708520',
+ 'account_gift_wripping' => ''
+ );
+
+ public static $acc_conf_cached = false;
+
/**
* 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
@@ -108,4 +126,73 @@ class AccountingCore
FROM `'._DB_PREFIX_.'accounting_zone_shop`
WHERE `id_shop` = '.(int)$id_shop);
}
+
+ /**
+ * Get the Accounting Configuration
+ * If a key is defined, then it will try to get the value
+ *
+ * @static
+ * @param null $key
+ * @return array|bool
+ */
+ public static function getConfiguration($key = null)
+ {
+ // Cache for call performance
+ if (!self::$acc_conf_cached)
+ {
+ // Merge default values with the configured values
+ if ($conf = unserialize(Configuration::get(Accounting::CONF_NAME)))
+ self::$acc_conf = array_merge(self::$acc_conf, $conf);
+ self::$acc_conf_cached = true;
+ }
+
+
+ // Return value key or the complete configuration depending of the $key definition
+ return (!$key) ? self::$acc_conf : ((isset(self::$acc_conf[$key]) ? self::$acc_conf[$key] : false));
+ }
+
+ /**
+ * Get the list of export done
+ *
+ * @static
+ * @return array
+ */
+ public static function getExportedList()
+ {
+ return Db::getInstance()->executeS('
+ SELECT * FROM `'._DB_PREFIX_.'accounting_export` ORDER BY `date` DESC');
+ }
+
+ /**
+ * Get the displayed customer account.
+ * Pad with / without prefix if the account is set
+ *
+ * @static
+ * @param $id_customer
+ * @param $default_value
+ * @return string
+ */
+ public static function getDisplayedCustomerAccount($id_customer, $default_value = false)
+ {
+ $acc_num = Db::getInstance()->getValue('
+ SELECT account_number FROM `'._DB_PREFIX_.'customer`
+ WHERE id_customer = '.(int)$id_customer);
+
+ $display = $acc_num;
+ if (empty($acc_num) || $default_value)
+ {
+ $display = Accounting::getConfiguration('customer_prefix');
+ $max_len = Accounting::getConfiguration('account_length');
+ $len = Tools::strlen($display) + Tools::strlen((string)$id_customer);
+
+ // Pad the displayed string
+ while ($max_len > 0 && $max_len > $len)
+ {
+ $display .= '0';
+ --$max_len;
+ }
+ $display .= (string)$id_customer;
+ }
+ return $display;
+ }
}
diff --git a/classes/Customer.php b/classes/Customer.php
index 94a83aaec..f5d1fe4d2 100644
--- a/classes/Customer.php
+++ b/classes/Customer.php
@@ -133,7 +133,7 @@ class CustomerCore extends ObjectModel
public $groupBox;
- public $account_number;
+ public $account_number = '';
protected $webserviceParameters = array(
'fields' => array(
diff --git a/classes/LocalizationPack.php b/classes/LocalizationPack.php
index b4f832a63..19eb68ce1 100644
--- a/classes/LocalizationPack.php
+++ b/classes/LocalizationPack.php
@@ -151,6 +151,7 @@ class LocalizationPackCore
$tax = new Tax();
$tax->name[(int)Configuration::get('PS_LANG_DEFAULT')] = (string)$attributes['name'];
$tax->rate = (float)$attributes['rate'];
+ $tax->account_number = isset($attributes['account_number']) ? (string)$attributes['account_number'] : '';
$tax->active = 1;
if (!$tax->validateFields())
diff --git a/controllers/admin/AdminAccountingConfigurationController.php b/controllers/admin/AdminAccountingConfigurationController.php
new file mode 100644
index 000000000..b232a4755
--- /dev/null
+++ b/controllers/admin/AdminAccountingConfigurationController.php
@@ -0,0 +1,136 @@
+
+* @copyright 2007-2012 PrestaShop SA
+* @version Release: $Revision: 9841 $
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+class AdminAccountingConfigurationControllerCore extends AdminController
+{
+ public $acc_conf = array();
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->acc_conf = Accounting::getConfiguration();
+ $this->className = 'Accounting';
+
+ $this->options = array(
+ 'general' => array(
+ 'title' => $this->l('Export'),
+ 'fields' => array(
+ 'customer_prefix' => array(
+ 'title' => $this->l('Customer prefix:'),
+ 'desc' => $this->l('Set your default customer prefix'),
+ 'type' => 'text',
+ 'value' => $this->acc_conf['customer_prefix'],
+ 'size' => '15',
+ 'auto_value' => false
+ ),
+ 'journal' => array(
+ 'title' => $this->l('Journal:'),
+ 'desc' => '',
+ 'type' => 'text',
+ 'value' => $this->acc_conf['journal'],
+ 'size' => '15',
+ 'auto_value' => false
+ ),
+ 'account_length' => array(
+ 'title' => $this->l('Customer account length:'),
+ 'desc' => $this->l('Set the length of the customer account number (the prefix will always be displayed with the customer id)'),
+ 'type' => 'text',
+ 'value' => $this->acc_conf['account_length'],
+ 'size' => '15',
+ 'auto_value' => false
+ ),
+ 'account_submit_shipping_charge' => array(
+ 'title' => $this->l('Submited shipping charge account:'),
+ 'desc' => $this->l('Set the account for submited shipping charged'),
+ 'type' => 'text',
+ 'value' => $this->acc_conf['account_submit_shipping_charge'],
+ 'size' => '15',
+ 'auto_value' => false
+ ),
+ 'account_unsubmit_shipping_charge' => array(
+ 'title' => $this->l('Unsubmited shipping charge account:'),
+ 'desc' => $this->l('Set the account for unsubmited shipping charged'),
+ 'type' => 'text',
+ 'value' => $this->acc_conf['account_unsubmit_shipping_charge'],
+ 'size' => '15',
+ 'auto_value' => false
+ ),
+ 'account_gift_wripping' => array(
+ 'title' => $this->l('Gift-wrapping account number:'),
+ 'desc' => $this->l('Set the account number for the gift-wrapping'),
+ 'type' => 'text',
+ 'value' => $this->acc_conf['account_gift_wripping'],
+ 'size' => '15',
+ 'auto_value' => false
+ )
+ ),
+ 'submit' => array('name' => 'update_cfg')
+ ),
+ );
+ }
+
+ public function initToolbar()
+ {
+ $this->initToolbarTitle();
+ $this->toolbar_btn['save'] = array(
+ 'href' => '#',
+ 'desc' => $this->l('Save')
+ );
+
+ }
+
+ public function initContent()
+ {
+ $this->display = 'options';
+ parent::initContent();
+
+ $this->initToolbar();
+ //$this->initInputList();
+
+ $this->context->smarty->assign(array(
+ 'title' => $this->l('Accounting Configuration'),
+ 'acc_conf' => $this->acc_conf,
+ 'table' => 'accounting',
+ 'toolbar_btn' => $this->toolbar_btn
+ ));
+ }
+
+ public function postProcess()
+ {
+ if (Tools::isSubmit('update_cfg'))
+ {
+ foreach ($this->acc_conf as $name => $val)
+ $this->acc_conf[$name] = Tools::getValue($name);
+
+ Configuration::updateValue(Accounting::CONF_NAME, serialize($this->acc_conf));
+ Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&update=true');
+ }
+ else if (Tools::getValue('update'))
+ $this->confirmations[] = $this->l('Configuration updated');
+ }
+}
diff --git a/controllers/admin/AdminAccountingExportController.php b/controllers/admin/AdminAccountingExportController.php
index 8c7de858f..20223b240 100644
--- a/controllers/admin/AdminAccountingExportController.php
+++ b/controllers/admin/AdminAccountingExportController.php
@@ -29,13 +29,13 @@ class AdminAccountingExportControllerCore extends AdminController
{
public $exportTypeList = array();
- public $pathTheme = '';
-
- public $defaultType = 'block_global_export';
-
public $downloadDir = '';
public $downloadFile = '';
+
+ public $file = '';
+
+ public $already_generated = false;
public $exportSelected = '';
@@ -48,12 +48,14 @@ class AdminAccountingExportControllerCore extends AdminController
public $prevent = array(
'errors' => array(),
- 'warns' => array(),
+ 'warn' => array(),
'hints' => array());
public $exportedFilePath = '';
- public $clientPrefix = '';
+ public $acc_conf = array();
+
+ public $file_format;
public function __construct()
{
@@ -88,7 +90,8 @@ class AdminAccountingExportControllerCore extends AdminController
'payment_type' => $this->l('Payment Type', 'AdminTab', false, false),
'currency_code' => $this->l('Currency Code', 'AdminTab', false, false),
'wording' => $this->l('Wording', 'AdminTab', false, false)
- )
+ ),
+ 'type' => 0
),
'reconciliation_export' => array(
'name' => $this->l('Reconciliation Export'),
@@ -101,26 +104,12 @@ class AdminAccountingExportControllerCore extends AdminController
'invoice_date' => $this->l('Invoice Date', 'AdminTab', false, false),
'transaction_id' => $this->l('Transaction Number', 'AdminTab', false, false),
'account_client' => $this->l('Account client', 'AdminTab', false, false)
- )
+ ),
+ 'type' => 1
)
);
}
- /**
- * Init the block Menu
- */
- protected function initMenu()
- {
- $this->context->smarty->assign(array(
- 'exportTypeList' => $this->exportTypeList,
- 'defaultType' => $this->defaultType,
- 'preventList' => $this->prevent
- )
- );
-
- $this->content .= $this->createTemplate('menu.tpl')->fetch();
- }
-
/**
* AdminController::setMedia() override
* @see AdminController::setMedia()
@@ -135,40 +124,72 @@ class AdminAccountingExportControllerCore extends AdminController
protected function checkRights()
{
if (!is_writeable($this->downloadDir))
- $this->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->errors[] = $this->l('The file can\'t be opened or created, please check the right');
@chmod($this->downloadFile, 0777);
}
-
+
+ public function getExportedList()
+ {
+ $exported_list = Accounting::getExportedList();
+ foreach ($exported_list as &$export)
+ foreach ($this->exportTypeList as $export_type)
+ {
+ $export['title'] = $this->l('Undefined');
+ if (((int)$export_type['type']) == ((int)$export['type']))
+ {
+ $export['title'] = $export_type['name'];
+ break;
+ }
+ }
+ return $exported_list;
+ }
+
/**
* AdminController::init() override
* @see AdminController::init()
*/
public function initContent()
- {
- $this->initMenu();
-
+ {
$this->context->smarty->assign(array(
- 'clientPrefix' => Configuration::get('ACCOUNTING_CLIENT_PREFIX_EXPORT'),
- 'journal' => Configuration::get('ACCOUNTING_JOURNAL_EXPORT'),
- 'begin_date' => Tools::getValue('beginDate'),
- 'end_date' => Tools::getValue('endDate'),
- 'urlDownload' => Tools::getShopDomain().'/download/'
+ 'begin_date' => Tools::getValue('begin_date'),
+ 'end_date' => Tools::getValue('end_date'),
+ 'file_format' => $this->file_format,
+ 'export_type' => $this->exportSelected,
+ 'urlDownload' => Tools::getShopDomain().'/download/',
+ 'preventList' => $this->prevent,
+ 'export_type_list' => $this->exportTypeList,
+ 'exported_list' => $this->getExportedList(),
+ 'already_generated' => Configuration::get('REQUEST_URI').$this->already_generated,
));
-
- foreach ($this->exportTypeList as $exportType)
- {
- $this->context->smarty->assign(array(
- 'title' => $exportType['name'],
- 'type' => $exportType['type'],
- 'existingExport' => file_exists($this->downloadDir.$exportType['file']) ? true : false
- ));
-
- $this->content .= $this->createTemplate($exportType['type'].'.tpl')->fetch();
- }
+
parent::initContent();
}
+
+ public function saveRangeDate()
+ {
+ $keys = array('`begin_to`', '`end_to`', '`type`', '`file`');
+
+ $values = array(
+ '"'.pSQL($this->date['begin']).'"',
+ '"'.pSQL($this->date['end']).'"',
+ (int)$this->exportTypeList[$this->exportSelected]['type'],
+ '"'.pSQL($this->file).'"'
+ );
+
+ if (!($id_acc_export = Tools::getValue('regenerate')))
+ $query = '
+ INSERT INTO `'._DB_PREFIX_.'accounting_export`
+ ('.implode(', ', $keys).')
+ VALUES('.implode(', ', $values).')';
+ else
+ $query = 'UPDATE `'._DB_PREFIX_.'accounting_export`
+ SET `date` = CURRENT_TIMESTAMP, `file` = "'.$this->file.'"
+ WHERE `id_accounting_export` = '.(int)$id_acc_export;
+
+ Db::getInstance()->execute($query);
+ }
/**
* AdminController::postProcess() override
@@ -176,38 +197,71 @@ class AdminAccountingExportControllerCore extends AdminController
*/
public function postProcess()
{
- if (Tools::isSubmit('submitAccountingExportType'))
+ $succeed = false;
+
+ if (Tools::isSubmit('accounting_export'))
{
- $this->date['begin'] = Tools::getValue('beginDate');
- $this->date['end'] = Tools::getValue('endDate');
- $this->clientPrefix = Tools::getValue('clientPrefix');
- $this->exportSelected = Tools::getValue('exportType');
- $this->downloadFile = $this->downloadDir.'accounting_'.$this->exportSelected.'.csv';
-
- Configuration::updateValue('ACCOUNTING_CLIENT_PREFIX_EXPORT', $this->clientPrefix);
+ $this->acc_conf = Accounting::getConfiguration();
+ $this->date['begin'] = Tools::getValue('begin_date');
+ $this->date['end'] = Tools::getValue('end_date');
+ $this->exportSelected = Tools::getValue('type');
+ $this->file_format = Tools::getValue('format');
+ $this->file = $this->exportSelected.'-'.$this->date['begin'].
+ 'to'.$this->date['end'].'.'.$this->file_format;
+ $this->downloadFile = $this->downloadDir.$this->file;
+
// Depends of the number of order and the range dates
// Switch to ajax if there is any problems with time
ini_set('max_execution_time', 0);
-
- switch ($this->exportSelected)
+ if (!in_array($this->file_format, array('csv', 'txt')))
+ $this->prevent['error'][] = $this->l('Please select file format');
+ else if (!empty($this->date['begin']) && !empty($this->date['end']) &&
+ (Tools::getValue('regenerate') || !$this->isAlreadyGenerated()))
{
- case 'reconciliation_export':
- $this->runReconciliationExport();
- break;
- case 'global_export':
- $this->runGlobalExport();
- Configuration::updateValue('ACCOUNTING_JOURNAL_EXPORT', Tools::getValue('journal'));
- break;
- default:
- // If not defined, set export type to default
- $this->exportSelected = 'global_export';
+ switch ($this->exportSelected)
+ {
+ case 'reconciliation_export':
+ $succeed = $this->runReconciliationExport();
+ break;
+ case 'global_export':
+ $succeed = $this->runGlobalExport();
+ break;
+ default:
+ $this->prevent['error'][] = $this->l('Please select a export type');
+ }
+ if ($succeed)
+ $this->saveRangeDate();
}
-
- // Set back the default block type to display
- $this->defaultType = 'block_'.$this->exportSelected.'';
+ else if (!$this->already_generated)
+ $this->prevent['error'][] = $this->l('Please select the date');
}
- else if (($type = Tools::getValue('download')) && array_key_exists($type, $this->exportTypeList))
- $this->downloadFile($this->exportTypeList[$type]['file']);
+ else if (($file = Tools::getValue('download')) && file_exists($this->downloadDir.$file))
+ $this->launchDownloadFile($this->downloadDir.$file);
+ }
+
+ public function isAlreadyGenerated()
+ {
+ $query = '
+ SELECT ae.`type`, ae.`id_accounting_export`
+ FROM `'._DB_PREFIX_.'accounting_export` ae
+ WHERE ae.`begin_to` = "'.pSQL($this->date['begin']).'"
+ AND ae.`end_to` = "'.pSQL($this->date['end']).'"
+ AND ae.`type` = '.(int)$this->exportTypeList[$this->exportSelected]['type'];
+
+ if (($entry = Db::getInstance()->getRow($query)) !== false)
+ {
+ if ($this->exportTypeList[$this->exportSelected]['type'] == $entry['type'])
+ {
+ $this->prevent['warn'][] = $this->l('This export has already be proceed with this file format');
+ $this->already_generated = $entry['id_accounting_export'];
+ }
+ else
+ {
+ $this->prevent['warn'][] = $this->l('This export has already be proceed with a different file format');
+ $this->already_generated = true;
+ }
+ }
+ return (bool)$this->already_generated;
}
/**
@@ -235,7 +289,9 @@ class AdminAccountingExportControllerCore extends AdminController
fwrite($this->fd, mb_convert_encoding(rtrim($buffer, ';')."\r\n", 'UTF-16LE'));
}
$this->confirmations[] = $this->l('Export has been successfully done');
+ return true;
}
+ return false;
}
/**
@@ -253,7 +309,7 @@ class AdminAccountingExportControllerCore extends AdminController
o.`total_paid_real`,
oi.`date_add` as invoice_date,
pcc.`transaction_id`,
- CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(c.`id_customer`, 6, "0")) AS account_client
+ CONCAT(\''.pSQL($this->acc_conf['client_prefix']).'\', LPAD(c.`id_customer`, 6, "0")) AS account_client
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = o.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'address` a ON a.`id_customer` = o.`id_customer`
@@ -266,7 +322,7 @@ class AdminAccountingExportControllerCore extends AdminController
$list = Db::getInstance()->executeS($query);
- $this->writeExportToFile($list);
+ return $this->writeExportToFile($list);
}
/**
@@ -282,7 +338,7 @@ class AdminAccountingExportControllerCore extends AdminController
// Default Values
$line[0] = $row['invoice_date'];
- $line[1] = Tools::getValue('journal');
+ $line[1] = $this->acc_conf['journal'];
$line[2] = ''; // account number
$line[3] = $row['invoice_number'];
$line[4] = 0.00; // Credit TTC (Total for first csv line, 0 for others)
@@ -418,8 +474,9 @@ class AdminAccountingExportControllerCore extends AdminController
pcc.`transaction_id`,
o.`payment` AS payment_type,
currency.`iso_code` AS currency_code,
- CONCAT(\''.pSQL($this->clientPrefix).'\', LPAD(customer.`id_customer`, 6, "0")) AS account_client,
- CASE
+ CONCAT(\''.pSQL($this->acc_conf['client_prefix']).'\', LPAD(customer.`id_customer`, 6, "0")) AS account_client,
+ CASE
+ WHEN (customer.`account_number` != "" AND customer.`account_number` IS NOT NULL) THEN customer.`account_number`
WHEN (a.`company` != "" AND a.`company` IS NOT NULL) THEN a.`company`
ELSE a.`lastname`
END AS wording,
@@ -455,14 +512,14 @@ class AdminAccountingExportControllerCore extends AdminController
ORDER BY o.`id_order` ASC';
$list = $this->buildGlobalExportlist(Db::getInstance()->executeS($query));
- $this->writeExportToFile($list);
+ return $this->writeExportToFile($list);
}
/**
* Allow to download the last export file
* @var string File name
*/
- protected function downloadFile($fileName)
+ protected function launchDownloadFile($fileName)
{
$path = $this->downloadDir.$fileName;
header('Content-length: '.filesize($path));
diff --git a/controllers/admin/AdminAccountingRegisteredNumberController.php b/controllers/admin/AdminAccountingRegisteredNumberController.php
index 936a69dfe..a320d4793 100644
--- a/controllers/admin/AdminAccountingRegisteredNumberController.php
+++ b/controllers/admin/AdminAccountingRegisteredNumberController.php
@@ -47,7 +47,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'COUNT(*) AS total' => $this->l('Number of product associated to this account')
),
'group_by' => 'account_number',
- 'condition' => 'p.account_number <> ""',
+ 'condition' => 'p.account_number <> "" AND account_number IS NOT NULL',
'title' => $this->l('Product account number list'),
'list' => array()),
@@ -59,7 +59,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'COUNT(*) AS total' => $this->l('Number of taxes associated to this account')
),
'group_by' => 'account_number',
- 'condition' => 'account_number <> ""',
+ 'condition' => 'account_number <> "" AND account_number IS NOT NULL',
'title' => $this->l('Taxes Account number list'),
'list' => array()),
@@ -70,7 +70,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'account_number' => $this->l('Account number'),
'total' => $this->l('Number of gift-wrapping associated to this account')
),
- 'condition' => 'account_number <> ""',
+ 'condition' => 'account_number <> "" AND account_number IS NOT NULL',
'group_by' => 'account_number',
'title' => $this->l('Gift wrapping account number list'),
'list' => array()),
@@ -84,7 +84,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'lastname' => $this->l('Last name')
),
'group_by' => 'account_number',
- 'condition' => 'account_number <> ""',
+ 'condition' => 'account_number <> "" AND account_number IS NOT NULL',
'title' => $this->l('Customer account number list'),
'list' => array()),
@@ -96,7 +96,7 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
'COUNT(*) AS total' => $this->l('Number of zone associated to this account')
),
'group_by' => 'account_number',
- 'condition' => 'account_number <> ""',
+ 'condition' => 'account_number <> "" AND account_number IS NOT NULL',
'title' => $this->l('Zone shop account number list'),
'list' => array())
);
@@ -113,6 +113,13 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
{
$this->initToolbar();
$this->initAccountNumberList();
+
+ $this->context->smarty->assign(array(
+ 'toolbar_btn' => $this->toolbar_btn,
+ 'title' => $this->l('Accounting Plan'),
+ 'account_number_list' => $this->account_number_list));
+
+ parent::initContent();
}
public function initAccountNumberList()
@@ -144,13 +151,6 @@ class AdminAccountingRegisteredNumberControllerCore extends AdminController
$num = Configuration::get('PS_GIFT_WRAPPING_ACCOUNT_NUMBER');
if (!empty($num))
- $this->account_number_list['gift_wrapping']['list'][] = array($num, '1');
-
- $this->context->smarty->assign(array(
- 'toolbar_btn' => $this->toolbar_btn,
- 'title' => $this->l('Accounting Plan'),
- 'account_number_list' => $this->account_number_list));
-
- parent::initContent();
+ $this->account_number_list['gift_wrapping']['list'][] = array($num, '1');
}
}
diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php
index 046cf9bda..61b0c75f5 100644
--- a/controllers/admin/AdminCustomersController.php
+++ b/controllers/admin/AdminCustomersController.php
@@ -278,7 +278,8 @@ class AdminCustomersControllerCore extends AdminController
'name' => 'account_number',
'size' => 33,
'required' => false,
- 'desc' => $this->l('Used for the accounting export')
+ 'desc' => $this->l('Used for the accounting export. If this field is empty, the accounting export will use this number ').
+ Accounting::getDisplayedCustomerAccount($this->getFieldValue($obj, 'id_customer'), true)
),
array(
'type' => 'birthday',
diff --git a/controllers/admin/AdminOrderPreferencesController.php b/controllers/admin/AdminOrderPreferencesController.php
index 36a53c1f0..f2aee70fe 100644
--- a/controllers/admin/AdminOrderPreferencesController.php
+++ b/controllers/admin/AdminOrderPreferencesController.php
@@ -158,13 +158,6 @@ class AdminOrderPreferencesControllerCore extends AdminController
'cast' => 'intval',
'type' => 'bool'
),
- 'PS_GIFT_WRAPPING_ACCOUNT_NUMBER' => array(
- 'title' => $this->l('Gift-wrapping account number'),
- 'desc' => $this->l('Set an account number for your gift-wrapping (used for accounting)'),
- 'validation' => 'isString',
- 'type' => 'text',
- 'size' => 30,
- ),
),
'submit' => array('title' => $this->l(' Save '), 'class' => 'button'),
),
diff --git a/img/admin/page_white_text.png b/img/admin/page_white_text.png
new file mode 100755
index 000000000..f64dd0117
Binary files /dev/null and b/img/admin/page_white_text.png differ
diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql
index 0dc3fd39e..41507f225 100644
--- a/install-dev/data/db_structure.sql
+++ b/install-dev/data/db_structure.sql
@@ -542,7 +542,7 @@ CREATE TABLE `PREFIX_customer` (
`passwd` varchar(32) NOT NULL,
`last_passwd_gen` timestamp NOT NULL default CURRENT_TIMESTAMP,
`birthday` date default NULL,
- `account_number` varchar(128) NULL,
+ `account_number` varchar(128) NULL,
`newsletter` tinyint(1) unsigned NOT NULL default '0',
`ip_registration_newsletter` varchar(15) default NULL,
`newsletter_date_add` datetime default NULL,
@@ -2305,6 +2305,26 @@ CREATE TABLE `PREFIX_supplier_rates` (
PRIMARY KEY (`id_product_supplier`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
+CREATE TABLE IF NOT EXISTS `ps_accounting_export` (
+ `id_accounting_export` int(11) NOT NULL AUTO_INCREMENT,
+ `begin_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `end_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `type` int(11) NOT NULL,
+ `file` varchar(256) NOT NULL,
+ `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id_accounting_export`)
+) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `PREFIX_accounting_export` (
+ `id_accounting_export` int(11) NOT NULL AUTO_INCREMENT,
+ `begin_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `end_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `type` int(11) NOT NULL,
+ `file` varchar(256) NOT NULL,
+ `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id_accounting_export`)
+) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
+
CREATE TABLE `PREFIX_accounting_zone_shop` (
`id_accounting_zone_shop` int(11) NOT NULL AUTO_INCREMENT,
`id_zone` int(11) NOT NULL,
diff --git a/install-dev/data/xml/tab.xml b/install-dev/data/xml/tab.xml
index 9d0c171a0..a5bce2fe9 100644
--- a/install-dev/data/xml/tab.xml
+++ b/install-dev/data/xml/tab.xml
@@ -250,7 +250,10 @@
AdminRequestSql
- AdminAccountingManagement
+ AdminAccountingConfiguration
+
+
+ AdminAccountingRegisteredNumber
AdminLogs
diff --git a/install-dev/langs/de/data/tab.xml b/install-dev/langs/de/data/tab.xml
index 2cb1469ca..bb3e4349d 100644
--- a/install-dev/langs/de/data/tab.xml
+++ b/install-dev/langs/de/data/tab.xml
@@ -82,6 +82,7 @@
+
diff --git a/install-dev/langs/en/data/tab.xml b/install-dev/langs/en/data/tab.xml
index ab8ee897f..1152157bd 100644
--- a/install-dev/langs/en/data/tab.xml
+++ b/install-dev/langs/en/data/tab.xml
@@ -82,6 +82,7 @@
+
diff --git a/install-dev/langs/es/data/tab.xml b/install-dev/langs/es/data/tab.xml
index 83ada8a0f..171576e71 100644
--- a/install-dev/langs/es/data/tab.xml
+++ b/install-dev/langs/es/data/tab.xml
@@ -82,6 +82,7 @@
+
diff --git a/install-dev/langs/fr/data/tab.xml b/install-dev/langs/fr/data/tab.xml
index 9a1cfc005..c10e8a7dc 100644
--- a/install-dev/langs/fr/data/tab.xml
+++ b/install-dev/langs/fr/data/tab.xml
@@ -82,6 +82,7 @@
+
diff --git a/install-dev/langs/it/data/tab.xml b/install-dev/langs/it/data/tab.xml
index 4303ce2a6..5fe2584b5 100644
--- a/install-dev/langs/it/data/tab.xml
+++ b/install-dev/langs/it/data/tab.xml
@@ -82,6 +82,7 @@
+
diff --git a/install-dev/upgrade/sql/1.5.0.8.sql b/install-dev/upgrade/sql/1.5.0.8.sql
index 82d4d5d8f..bef7be94b 100644
--- a/install-dev/upgrade/sql/1.5.0.8.sql
+++ b/install-dev/upgrade/sql/1.5.0.8.sql
@@ -2,4 +2,12 @@ SET NAMES 'utf8';
ALTER TABLE `PREFIX_product` ADD `visibility` ENUM('both', 'catalog', 'search', 'none') NOT NULL default 'both' AFTER `indexed`;
-
\ No newline at end of file
+CREATE TABLE IF NOT EXISTS `PREFIX_accounting_export` (
+ `id_accounting_export` int(11) NOT NULL AUTO_INCREMENT,
+ `begin_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `end_to` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `type` int(11) NOT NULL,
+ `file` varchar(256) NOT NULL,
+ `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id_accounting_export`)
+) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
diff --git a/localization/fr.xml b/localization/fr.xml
index 2e4ab2445..bb3ed9773 100644
--- a/localization/fr.xml
+++ b/localization/fr.xml
@@ -8,10 +8,10 @@
-
-
-
-
+
+
+
+