From ef0907d89e6d44daa701fc4cea194451867ad368 Mon Sep 17 00:00:00 2001 From: alexis Algoud Date: Tue, 13 Jun 2017 15:55:22 +0200 Subject: [PATCH 01/27] NEW log download or preview event on a validate bill --- htdocs/blockedlog/ajax/block-add.php | 19 ++++++++++++ htdocs/compta/facture/card.php | 31 +++++++++++++++++++ htdocs/core/class/html.formfile.class.php | 2 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 3 +- htdocs/langs/en_US/blockedlog.lang | 4 ++- 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 htdocs/blockedlog/ajax/block-add.php diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php new file mode 100644 index 00000000000..247b01186fe --- /dev/null +++ b/htdocs/blockedlog/ajax/block-add.php @@ -0,0 +1,19 @@ +fetch($id)>0) { + $facture->call_trigger($action, $user); + } + + } + \ No newline at end of file diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c4bf83293de..ffab33275a7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4248,6 +4248,37 @@ else if ($id > 0 || ! empty($ref)) $delallowed = $user->rights->facture->supprimer; print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + + if(!empty($conf->blockedlog->enabled) && $object->statut>0) { + ?> + + numoffiles; // Show links to link elements diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 89cf70951ad..44a90794790 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -712,7 +712,7 @@ class FormFile $out.= ''; $tmp = $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= ($tmp?$tmp.' ':''); - $out.= 'total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 7e64bfad17f..fcad52508bd 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -18,4 +18,6 @@ logBILL_VALIDATE=Customer bill set valid from draft logBILL_SENTBYMAIL=Customer bill send by mail BlockedlogInfoDialog=Log Details Fingerprint=Fingerprint -DownloadLogCSV=Download fingerprints CSV \ No newline at end of file +DownloadLogCSV=Download fingerprints CSV +logPREVIEW_BILL=Preview of a validated customer bill in order to print or download +logDOWNLOAD_BILL=Download of a validated customer bill in order to print or send \ No newline at end of file From 50aa40da3b67077476fefb70d5fdcb23d7be7714 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 14 Jun 2017 07:40:11 +0200 Subject: [PATCH 02/27] Fix: error when the project module not enabled --- htdocs/comm/action/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 60486ac6f01..5e38a85898e 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Cedric GROSS @@ -585,8 +585,6 @@ if ($action == 'mupdate') * View */ -$formproject=new FormProjets($db); - $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); From 73977639ac44215c6680110fc3d5f4babdf761fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Jun 2017 18:34:39 +0200 Subject: [PATCH 03/27] Update doc --- README-FR.md | 31 ++++++++++++++++++++++++++++--- README.md | 14 ++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/README-FR.md b/README-FR.md index 4129e2b7452..8e6a2c5aac0 100644 --- a/README-FR.md +++ b/README-FR.md @@ -98,7 +98,10 @@ Voir fichier ChangeLog. - Rapports - Imports/Exports des données - Connectivité LDAP -- De nombreuses autres fonctionnalités issues de modules officiels ou non (AWStats, Bittorrent, Gravatar, Google, Webcalendar...) +- Intégratn de ClickToDial +- Intégration RSS +- Intégation Skype +- Intégration de système de paiements (Paypal, Strip, Paybox...) - … ### Divers: @@ -114,17 +117,39 @@ Voir fichier ChangeLog. - Code simple et facilement personnalisable (pas de framework lourd; mécanisme de hook et triggers). - APIs. - Génération PDF et ODT des éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) +- … + +### Extension + +Dolibarr peut aussi être étendu à volonté avec l'ajout de module/applications externes développées par des développeus tiers, disponible sur [DoliStore](https://www.dolistore.com). -## CE QUE DOLIBARR NE PEUT PAS FAIRE (TACHES A FAIRE) +## CE QUE DOLIBARR NE PEUT PAS (ENCORE) FAIRE Voici un liste de fonctionnalites pas encore gérées par Dolibarr: - Dolibarr ne contient pas de module de Gestion de la paie. - Les tâches du module de gestion de projets n'ont pas de dépendances entre elle. -- Dolibarr ne contient pas de Webmail. +- Dolibarr n'embarque pas de Webmail intégré nativement. - Dolibarr ne fait pas le café (pas encore). +## DOCUMENTATION + +Les documentations utilisateur, développeur et traducteur sont disponible sous forme de ressources de la communautés via la site [Wiki](https://wiki.dolibarr.org). + + +## CONTRIBUTING + +Voir le fichier [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) + + +## CREDITS + +Dolibarr est le résultat du travail de nombreux contributeurs depuis des années et utilise des librairies d'autres contributeurs. + +Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) + + ## ACTUALITES ET RESEAUX SOCIAUX Suivez le projet Dolibarr project sur les réseaux francophones diff --git a/README.md b/README.md index 29a7d4f9545..fbbbdddf665 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ You can use it as a standalone application or as a web application to be able to ![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x400.png) + ## LICENSE Dolibarr is released under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version (GPL-3+). @@ -20,6 +21,7 @@ See the [COPYING](https://github.com/Dolibarr/dolibarr/blob/develop/COPYING) fil Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list. + ## INSTALLING ### Download @@ -67,6 +69,7 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql) - Follow the installer instructions + ## UPGRADING - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. @@ -75,10 +78,12 @@ You can use a Web server and a supported database (MariaDb, MySql or Postgresql) *Note: migration process can safely be done multiple times by calling the page /install/index.php* + ## WHAT'S NEW See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file. + ## FEATURES ### Main application/modules (all optional) @@ -120,7 +125,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - ClickToDial integration - RSS integration - Skype integration -- Payment platforms integration (PayBox, PayPal) +- Payment platforms integration (PayPal, Stripe, Paybox...) - … ### Other general features @@ -149,29 +154,34 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Dolibarr can be extended with a lot of other external application or modules from third party developers available at the [DoliStore](https://www.dolistore.com). + ## FUTURE These are features that Dolibarr does **not** yet fully support: - Tasks dependencies in projects - Payroll module -- Webmail +- No native embedded Webmail - Dolibarr can't do coffee (yet) + ## DOCUMENTATION Administrator, user, developer and translator's documentations are available along with other community resources on the [Wiki](https://wiki.dolibarr.org). + ## CONTRIBUTING See file [CONTRIBUTING](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md) + ## CREDITS Dolibarr is the work of many contributors over the years and uses some fine libraries. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file. + ## NEWS AND SOCIAL NETWORKS Follow Dolibarr project on: From 71c0be20b972d0fd3efac0da60a2980d92bb83a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 10:30:32 +0200 Subject: [PATCH 04/27] Change data structure for bookkeeping v6 --- dev/translation/erp_comparison_translation.txt | 4 ++-- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 11 ++++++++++- .../mysql/tables/llx_accounting_bookkeeping.sql | 5 +++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dev/translation/erp_comparison_translation.txt b/dev/translation/erp_comparison_translation.txt index daa1bc79e92..fb96c17e3f9 100644 --- a/dev/translation/erp_comparison_translation.txt +++ b/dev/translation/erp_comparison_translation.txt @@ -8,7 +8,7 @@ Contact/address Contact person Partner/Contact (individual) Financial ?? Invoicing Income / Expense ?? Profit / Loss -Balance Net profit - +Balance ?? Net profit +Subledger account Subledger account ?? diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index bc09bf25ca3..46e3b698100 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -188,9 +188,18 @@ ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal --Update general ledger for FEC format & harmonization ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_tiers varchar(32); +ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN code_tiers thirdparty_code varchar(32); + +--Subledger account +ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_account varchar(32); +ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN thirdparty_label subledger_label varchar(255); -- If field was already created, rename it +ALTER TABLE llx_accounting_bookkeeping ADD COLUMN subledger_label varchar(255) AFTER subledger_account; -- If field dod not exists yet + +update llx_accounting_bookkeeping set subledger_account = numero_compte where subledger_account IS NULL; + ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN label_compte varchar(255); ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_journal varchar(32); -ALTER TABLE llx_accounting_bookkeeping ADD COLUMN thirdparty_label varchar(255) AFTER code_tiers; + ALTER TABLE llx_accounting_bookkeeping ADD COLUMN label_operation varchar(255) AFTER label_compte; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN multicurrency_amount double AFTER sens; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN multicurrency_code varchar(255) AFTER multicurrency_amount; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 651fee6c339..ad1160c356d 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,8 +26,9 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - code_tiers varchar(32), -- FEC:CompAuxNum | account number of auxiliary account - thirdparty_label varchar(255), -- FEC:CompAuxLib | label of auxiliary account + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account + subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation From 4009b1837cf1db251c8c5bab6fe185a1960be279 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 11:17:02 +0200 Subject: [PATCH 05/27] Fix permissions --- htdocs/societe/class/api_contacts.class.php | 55 ++++++++++++--------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index ad82db3e008..58fe15cf282 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -22,14 +22,14 @@ use Luracast\Restler\RestException; /** * API class for contacts * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Contacts extends DolibarrApi { /** * - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'lastname' @@ -56,13 +56,13 @@ class Contacts extends DolibarrApi * * @param int $id ID of contact * @return array|mixed data without useless information - * + * * @throws RestException */ function get($id) { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { - throw new RestException(401); + throw new RestException(401, 'No permission to read contacts'); } $result = $this->contact->fetch($id); @@ -81,9 +81,9 @@ class Contacts extends DolibarrApi /** * List contacts - * + * * Get a list of contacts - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -91,7 +91,7 @@ class Contacts extends DolibarrApi * @param string $thirdparty_ids Thirdparty ids to filter projects of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contact objects - * + * * @throws RestException */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { @@ -99,6 +99,11 @@ class Contacts extends DolibarrApi $obj_ret = array(); + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) + { + throw new RestException(401, 'No permission to read contacts'); + } + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; @@ -111,7 +116,7 @@ class Contacts extends DolibarrApi $sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { // We need this table joined to the select in order to filter by sale - $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON t.fk_soc = s.rowid"; $sql.= ' WHERE t.entity IN (' . getEntity('socpeople') . ')'; @@ -127,7 +132,7 @@ class Contacts extends DolibarrApi $sql .= " AND sc.fk_user = " . $search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -136,7 +141,7 @@ class Contacts extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) @@ -164,7 +169,7 @@ class Contacts extends DolibarrApi } $i++; } - } + } else { throw new RestException(503, 'Error when retreive contacts : ' . $sql); } @@ -184,7 +189,7 @@ class Contacts extends DolibarrApi function post($request_data = NULL) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); + throw new RestException(401, 'No permission to create/update contacts'); } // Check mandatory fields $result = $this->_validate($request_data); @@ -203,13 +208,13 @@ class Contacts extends DolibarrApi * Update contact * * @param int $id Id of contact to update - * @param array $request_data Datas - * @return int + * @param array $request_data Datas + * @return int */ function put($id, $request_data = NULL) { if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { - throw new RestException(401); + throw new RestException(401, 'No permission to create/update contacts'); } $result = $this->contact->fetch($id); @@ -244,7 +249,7 @@ class Contacts extends DolibarrApi function delete($id) { if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) { - throw new RestException(401); + throw new RestException(401, 'No permission to delete contacts'); } $result = $this->contact->fetch($id); if (!$result) @@ -273,23 +278,29 @@ class Contacts extends DolibarrApi //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); //} - + if (!isset($request_data["login"])) throw new RestException(400, "login field missing"); if (!isset($request_data["password"])) throw new RestException(400, "password field missing"); + if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { - throw new RestException(401); + throw new RestException(401, 'No permission to read contacts'); } + if (!DolibarrApiAccess::$user->rights->user->user->creer) { + throw new RestException(401, 'No permission to create user'); + } + $contact = new Contact($this->db); $contact->fetch($id); if ($contact->id <= 0) { throw new RestException(404, 'Contact not found'); } - + if (!DolibarrApi::_checkAccessToResource('contact', $contact->id, 'socpeople&societe')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } + // Check mandatory fields $login = $request_data["login"]; $password = $request_data["password"]; @@ -300,10 +311,10 @@ class Contacts extends DolibarrApi } // password parameter not used in create_from_contact $useraccount->setPassword($useraccount,$password); - + return $result; } - + /** * Get categories for a contact * @@ -324,7 +335,7 @@ class Contacts extends DolibarrApi /** * Validate fields before create or update object - * + * * @param array|null $data Data to validate * @return array * @throws RestException From 097be322a60c9365f12dd364ac1bd878f15d6e55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 19:29:00 +0200 Subject: [PATCH 06/27] Modify code to match new v6 structure. --- htdocs/accountancy/admin/categories_list.php | 22 +- htdocs/accountancy/admin/defaultaccounts.php | 94 +++++-- htdocs/accountancy/admin/journals_list.php | 27 +- htdocs/accountancy/bookkeeping/card.php | 46 ++-- htdocs/accountancy/bookkeeping/list.php | 38 +-- .../accountancy/bookkeeping/listbyaccount.php | 37 ++- htdocs/accountancy/bookkeeping/listbyyear.php | 58 +++-- .../class/accountancycategory.class.php | 20 +- .../class/accountancyexport.class.php | 34 +-- .../class/accountingjournal.class.php | 16 +- .../accountancy/class/bookkeeping.class.php | 234 +++++++++++------- htdocs/accountancy/index.php | 2 - htdocs/accountancy/journal/bankjournal.php | 28 +-- .../journal/expensereportsjournal.php | 15 +- .../accountancy/journal/purchasesjournal.php | 21 +- htdocs/accountancy/journal/sellsjournal.php | 24 +- htdocs/core/modules/modAccounting.class.php | 12 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 1 + htdocs/langs/en_US/accountancy.lang | 24 +- htdocs/langs/en_US/compta.lang | 6 +- 20 files changed, 433 insertions(+), 326 deletions(-) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 1bf9a693efd..b10015baa6c 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -151,7 +151,7 @@ $sourceList=array(); if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary @@ -479,7 +479,7 @@ if ($id) else $sql.=" WHERE "; $sql.= " c.rowid = ".$search_country_id; } - + if ($sortfield) { // If sort order is "country", we use country_code instead @@ -506,7 +506,7 @@ if ($id) print '
'; print ''; print ''; - + print ''; // Form to add a new line @@ -546,9 +546,9 @@ if ($id) if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); } if ($fieldlist[$field]=='pcg_version' || $fieldlist[$field]=='fk_pcg_version') { $valuetoshow=$langs->trans("Pcg_version"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } - + if ($valuetoshow != '') { print ''; print ''; - + // Title of lines print ''; foreach ($fieldlist as $field => $value) @@ -700,7 +700,7 @@ if ($id) if ($fieldlist[$field]=='pcg_subtype') { $valuetoshow=$langs->trans("Pcg_subtype"); } if ($fieldlist[$field]=='type_template') { $valuetoshow=$langs->trans("TypeOfTemplate"); } if ($fieldlist[$field]=='range_account') { $valuetoshow=$langs->trans("Range"); } - if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } + if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Direction"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } // Affiche nom du champ if ($showfield) @@ -754,7 +754,7 @@ if ($id) { foreach ($fieldlist as $field => $value) { - + $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index aaf98a0fa8b..ef39252ff87 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -50,23 +50,26 @@ if (! empty($user->rights->accountancy->chartofaccount)) $action = GETPOST('action', 'alpha'); +$list_account_main = array ( + 'ACCOUNTING_ACCOUNT_SUPPLIER', + 'ACCOUNTING_ACCOUNT_CUSTOMER', +); + $list_account = array ( - 'ACCOUNTING_ACCOUNT_SUPPLIER', - 'ACCOUNTING_ACCOUNT_CUSTOMER', - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', - 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', - 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', - 'ACCOUNTING_SERVICE_BUY_ACCOUNT', - 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_BUY_ACCOUNT', - 'ACCOUNTING_VAT_SOLD_ACCOUNT', - 'ACCOUNTING_VAT_PAY_ACCOUNT', - 'ACCOUNTING_ACCOUNT_SUSPENSE', - 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', - 'DONATION_ACCOUNTINGACCOUNT', - 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', - 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', - 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', + 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', + 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', + 'ACCOUNTING_SERVICE_BUY_ACCOUNT', + 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_BUY_ACCOUNT', + 'ACCOUNTING_VAT_SOLD_ACCOUNT', + 'ACCOUNTING_VAT_PAY_ACCOUNT', + 'ACCOUNTING_ACCOUNT_SUSPENSE', + 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', + 'DONATION_ACCOUNTINGACCOUNT', + 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', + 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', + 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' ); @@ -93,15 +96,23 @@ if (GETPOST('change_chart')) if ($action == 'update') { $error = 0; - - foreach ( $list_account as $constname ) { + + foreach ( $list_account_main as $constname ) { $constvalue = GETPOST($constname, 'alpha'); - + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error ++; } } - + + foreach ( $list_account as $constname ) { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } + if (! $error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -114,11 +125,11 @@ if ($action == 'update') { * View */ -llxHeader(); - $form = new Form($db); $formaccounting = new FormAccounting($db); +llxHeader(); + $linkback = ''; print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy'); @@ -129,18 +140,47 @@ print ''; print ''; print ''; -// Define Chart of accounts + +// Define main accounts for thirdparty print '
'; @@ -617,7 +617,7 @@ if ($id) if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - + // There is several pages if ($num > $listlimit) { @@ -632,9 +632,9 @@ if ($id) foreach ($fieldlist as $field => $value) { $showfield=1; // By defaut - + if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - + if ($showfield) { if ($value == 'country') @@ -661,7 +661,7 @@ if ($id) } print '
'; -foreach ( $list_account as $key ) { - +foreach ($list_account_main as $key) { + + print ''; + // Param + $label = $langs->trans($key); + $keydesc=$key.'_Desc'; + + $htmltext = $langs->trans($keydesc); + print ''; + // Value + print ''; + print ''; +} + + +print "
'; + print $form->textwithpicto($label, $htmltext); + print ''; // Do not force align=right, or it align also the content of the select box + print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); + print '
\n"; + + +print '
'; + +// Define default accounts + +print ''; + +foreach ($list_account as $key) { + print ''; // Param $label = $langs->trans($key); - print ''; + print ''; // Value - print ''; print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 68d5e5af5c0..dd1982d057c 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -127,7 +127,7 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort, // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") $elementList = array(); - // Must match ids defined into eldy.lib.php + // Must match ids defined into eldy.lib.php $sourceList = array( '1' => $langs->trans('AccountingJournalType1'), '2' => $langs->trans('AccountingJournalType2'), @@ -142,7 +142,7 @@ $elementList = array(); if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - $search_country_id = ''; + $search_country_id = ''; } // Actions add or modify an entry into a dictionary @@ -371,13 +371,6 @@ if ($id) print load_fiche_titre($titre,$linkback,$titlepicto); -if (empty($id)) -{ - print $langs->trans("DictionaryDesc"); - print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; -} -print "
\n"; - // Confirmation de la suppression de la ligne if ($action == 'delete') @@ -400,7 +393,7 @@ if ($id) else $sql.=" WHERE "; $sql.= " c.rowid = ".$search_country_id; } - + if ($sortfield) { // If sort order is "country", we use country_code instead @@ -427,7 +420,7 @@ if ($id) print ''; print ''; print ''; - + print '
' . $label . '' . $label . ''; // Do not force align=right, or it align also the content of the select box + print ''; // Do not force align=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print '
'; // Form to add a new line @@ -453,7 +446,7 @@ if ($id) $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); } - + if ($valuetoshow != '') { print ''; print ''; - + if ($num) { // Lines with values @@ -621,7 +614,7 @@ if ($id) { foreach ($fieldlist as $field => $value) { - + $showfield=1; $align="left"; $valuetoshow=$obj->{$fieldlist[$field]}; @@ -682,10 +675,10 @@ if ($id) else print ''; print ''; - + print ''; } - + print "\n"; $i++; } diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 4443fb959b2..3ef418e2e20 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -48,9 +48,9 @@ $piece_num = GETPOST("piece_num"); $mesg = ''; $account_number = GETPOST('account_number'); -$code_tiers = GETPOST('code_tiers'); -if ($code_tiers == - 1) { - $code_tiers = null; +$subledger_account = GETPOST('subledger_account'); +if ($subledger_account == - 1) { + $subledger_account = null; } $label_compte = GETPOST('label_compte'); $debit = price2num(GETPOST('debit')); @@ -82,7 +82,7 @@ if ($action == "confirm_update") { setEventMessages($book->error, $book->errors, 'errors'); } else { $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; + $book->subledger_account = $subledger_account; $book->label_compte = $label_compte; $book->debit = $debit; $book->credit = $credit; @@ -119,7 +119,7 @@ else if ($action == "add") { $book = new BookKeeping($db); $book->numero_compte = $account_number; - $book->code_tiers = $code_tiers; + $book->subledger_account = $subledger_account; $book->label_compte = $label_compte; $book->debit = $debit; $book->credit = $credit; @@ -171,7 +171,7 @@ else if ($action == "confirm_delete") { else if ($action == "confirm_create") { $error = 0; - + $book = new BookKeeping($db); if (! GETPOST('next_num_mvt')) @@ -179,7 +179,7 @@ else if ($action == "confirm_create") { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); $error++; } - + if (! $error) { $book->label_compte = ''; @@ -192,9 +192,9 @@ else if ($action == "confirm_create") { $book->code_journal = GETPOST('code_journal'); $book->fk_doc = 0; $book->fk_docdet = 0; - + $book->montant = 0; - + $result = $book->createStd($user); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); @@ -289,9 +289,9 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("UpdateMvts"), '' . $langs->trans('BackToList') . ''); dol_fiche_head(); - + print '
'; - + print '
'; @@ -522,7 +515,7 @@ if ($id) if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); - + // There is several pages if ($num > $listlimit) { @@ -582,7 +575,7 @@ if ($id) } print '
 
'; print ''; @@ -306,12 +306,12 @@ if ($action == 'create') { print ''; print ''; - print ''; - + print ''; print ''; print ''; @@ -335,13 +335,13 @@ if ($action == 'create') { print ''; print ''; print '
' . $langs->trans("Codejournal") . ''; + print ''; $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch('',$book->code_journal); - print $accountingjournal->getNomUrl(0,1,1,'',1); + print $accountingjournal->getNomUrl(0,1,1,'',1); print '
' . $langs->trans("Docref") . '' . $book->doc_ref . '' . $typelabel . '
'; - + print ''; - + dol_fiche_end(); print '
'; - + $result = $book->fetch_all_per_mvt($piece_num); if ($result < 0) { setEventMessages($book->error, $book->errors, 'errors'); @@ -358,7 +358,7 @@ if ($action == 'create') { print '' . "\n"; $var=False; - + print ""; if (count($book->linesmvt) > 0) { @@ -368,7 +368,7 @@ if ($action == 'create') { print ''; print_liste_field_titre($langs->trans("AccountAccountingShort")); - print_liste_field_titre($langs->trans("Code_tiers")); + print_liste_field_titre($langs->trans("subledger_account")); print_liste_field_titre($langs->trans("Labelcompte")); print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"'); @@ -390,7 +390,7 @@ if ($action == 'create') { print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); print ''; print ''; print ''; print ''; @@ -403,7 +403,7 @@ if ($action == 'create') { print ''; } else { print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -423,7 +423,7 @@ if ($action == 'create') { print "\n"; } - if ($total_debit != $total_credit) + if ($total_debit != $total_credit) { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings'); } @@ -434,7 +434,7 @@ if ($action == 'create') { print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 26ab0fa4c4d..b6685248ca7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -171,15 +171,15 @@ if (! empty($search_accountancy_code_end)) { $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end; } if (! empty($search_accountancy_aux_code)) { - $filter['t.code_tiers'] = $search_accountancy_aux_code; + $filter['t.subledger_account'] = $search_accountancy_aux_code; $param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code; } if (! empty($search_accountancy_aux_code_start)) { - $filter['t.code_tiers>='] = $search_accountancy_aux_code_start; + $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; $param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start; } if (! empty($search_accountancy_aux_code_end)) { - $filter['t.code_tiers<='] = $search_accountancy_aux_code_end; + $filter['t.subledger_account<='] = $search_accountancy_aux_code_end; $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; } if (! empty($search_mvt_label)) { @@ -223,7 +223,7 @@ if ($action == 'delbookkeepingyearconfirm') { $deljournal=0; } - if (! empty($delyear) || ! empty($deljournal)) + if (! empty($delyear) || ! empty($deljournal)) { $result = $object->deleteByYearAndJournal($delyear,$deljournal); if ($result < 0) { @@ -365,7 +365,7 @@ $groupby = ' ' . "\n"; +print '
'; - print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); print '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '
'; - print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1); + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch('',$line->code_journal); - print ''; + $result = $accountingjournal->fetch('',$line->code_journal); + $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal); + print ''; print '\n"; print ''; -$var = True; $total_debit = 0; $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; -$displayed_account_number = null; // Start with undefined to be able to distinguish with empty +$displayed_account_number = null; // Start with undefined to be able to distinguish with empty foreach ( $object->lines as $line ) { @@ -272,10 +271,10 @@ foreach ( $object->lines as $line ) { $accountg = length_accountg($line->numero_compte); //if (empty($accountg)) $accountg = '-'; - + // Is it a break ? if ($accountg != $displayed_account_number || ! isset($displayed_account_number)) { - + // Affiche un Sous-Total par compte comptable if (isset($displayed_account_number)) { print ''; @@ -283,7 +282,7 @@ foreach ( $object->lines as $line ) { print "\n"; print ''; } - + // Show the break account $colspan = 9; print ""; @@ -292,7 +291,7 @@ foreach ( $object->lines as $line ) { else print ''.$langs->trans("Unknown").''; print ''; print ''; - + $displayed_account_number = $accountg; //if (empty($displayed_account_number)) $displayed_account_number='-'; $sous_total_debit = 0; @@ -303,24 +302,24 @@ foreach ( $object->lines as $line ) { print ''; print ''; print ''; - + // TODO Add a link according to doc_type and fk_doc print ''; - + // Affiche un lien vers la facture client/fournisseur $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); - print strlen(length_accounta($line->code_tiers)) == 0 ? '' : ''; + print strlen(length_accounta($line->subledger_account)) == 0 ? '' : ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print "\n"; @@ -355,6 +354,4 @@ print "
'; +print '
'; print $langs->trans('From') . ': '; print $form->select_date($search_date_start, 'date_start', 0, 0, 1); -print '
'; +print '
'; +print '
'; print $langs->trans('to') . ': '; print $form->select_date($search_date_end, 'date_end', 0, 0, 1); +print '
'; print '
'; +print '
'; print $langs->trans('From'); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); -print '
'; +print '
'; +print '
'; print $langs->trans('to'); print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print '
'; print '
'; +print '
'; print $langs->trans('From'); print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); -print '
'; +print '
'; +print '
'; print $langs->trans('to'); print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); +print '
'; print '
'; print ''; @@ -414,7 +423,7 @@ print_liste_field_titre($langs->trans("TransactionNumShort"), $_SERVER['PHP_SELF print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); @@ -440,14 +449,15 @@ foreach ($object->lines as $line ) { print '' . dol_print_date($line->doc_date, 'day') . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '' . ($line->debit ? price($line->debit) : ''). '' . ($line->credit ? price($line->credit) : '') . '' . $accountingjournal->getNomUrl(0,0,0,'',0) . '' . $journaltoshow . ''; print '' . img_edit() . ' '; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index b9a5526a7ab..7d0ba2280ea 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -75,10 +75,6 @@ if (empty($search_date_end)) $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_ $object = new BookKeeping($db); -$formaccounting = new FormAccounting($db); -$formother = new FormOther($db); -$form = new Form($db); - $options = ''; $filter = array (); @@ -126,7 +122,7 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot * Action */ -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_doc_date = ''; $search_accountancy_code = ''; @@ -156,6 +152,10 @@ if ($action == 'delmouvconfirm') { * View */ +$formaccounting = new FormAccounting($db); +$formother = new FormOther($db); +$form = new Form($db); + $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting"); llxHeader('', $title_page); @@ -217,7 +217,7 @@ if ( preg_match('/^asc/i', $sortorder) ) else $sortorder = "desc"; -print '
' . "\n"; +print ''; @@ -257,13 +257,12 @@ print "
'.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).' 
 '.$line->piece_num.'' . dol_print_date($line->doc_date, 'day') . ''; //if ($line->doc_type == 'supplier_invoice') //if ($line->doc_type == 'customer_invoice') print $line->doc_ref; print '' . $line->label_compte . '' . $line->label_compte . '
(' . length_accounta($line->code_tiers) . ')
' . $line->label_compte . '' . $line->label_compte . '
(' . length_accounta($line->subledger_account) . ')
' . price($line->debit) . '' . price($line->credit) . '' . ($line->debit ? price($line->debit) :''). '' . ($line->credit ? price($line->credit) : '') . '' . $line->code_journal . ''; - print '' . img_edit() . ' '; + print '' . img_edit() . ' '; print '' . img_delete() . ''; print '
"; print '
'; llxFooter(); - - $db->close(); diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index f4134a2e028..e7e51ae67e0 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -52,14 +52,14 @@ $search_numero_compte_end = GETPOST('search_numero_compte_end', 'alpha'); if ($search_numero_compte_end == - 1) { $search_numero_compte_end = ''; } -$search_code_tiers = GETPOST('search_code_tiers', 'alpha'); -$search_code_tiers_start = GETPOST('search_code_tiers_start', 'alpha'); -if ($search_code_tiers_start == - 1) { - $search_code_tiers_start = ''; +$search_subledger_account = GETPOST('search_subledger_account', 'alpha'); +$search_subledger_account_start = GETPOST('search_subledger_account_start', 'alpha'); +if ($search_subledger_account_start == - 1) { + $search_subledger_account_start = ''; } -$search_code_tiers_end = GETPOST('search_code_tiers_end', 'alpha'); -if ($search_code_tiers_end == - 1) { - $search_code_tiers_end = ''; +$search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha'); +if ($search_subledger_account_end == - 1) { + $search_subledger_account_end = ''; } $search_label_compte = GETPOST('search_label_compte', 'alpha'); $search_sens = GETPOST('search_sens', 'alpha'); @@ -81,15 +81,18 @@ if ($sortfield == "") $offset = $limit * $page; -llxHeader('', $langs->trans("Bookkeeping")); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +/* + * Actions + */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_doc_type = ""; $search_doc_date = ""; $search_doc_ref = ""; $search_numero_compte = ""; - $search_code_tiers = ""; + $search_subledger_account = ""; $search_label_compte = ""; $search_sens = ""; $search_code_journal = ""; @@ -129,17 +132,17 @@ if (! empty($search_numero_compte_end)) { $filter['t.numero_compte<='] = $search_numero_compte_end; $options .= '&search_numero_compte_end=' . $search_numero_compte_end; } -if (! empty($search_code_tiers)) { - $filter['t.code_tiers'] = $search_code_tiers; - $options .= '&search_code_tiers=' . $search_code_tiers; +if (! empty($search_subledger_account)) { + $filter['t.subledger_account'] = $search_subledger_account; + $options .= '&search_subledger_account=' . $search_subledger_account; } -if (! empty($search_code_tiers_start)) { - $filter['t.code_tiers>='] = $search_code_tiers_start; - $options .= '&search_code_tiers_start=' . $search_code_tiers_start; +if (! empty($search_subledger_account_start)) { + $filter['t.subledger_account>='] = $search_subledger_account_start; + $options .= '&search_subledger_account_start=' . $search_subledger_account_start; } -if (! empty($search_code_tiers_end)) { - $filter['t.code_tiers<='] = $search_code_tiers_end; - $options .= '&search_code_tiers_end=' . $search_code_tiers_end; +if (! empty($search_subledger_account_end)) { + $filter['t.subledger_account<='] = $search_subledger_account_end; + $options .= '&search_subledger_account_end=' . $search_subledger_account_end; } if (! empty($search_label_compte)) { $filter['t.label_compte'] = $search_label_compte; @@ -154,10 +157,13 @@ if (! empty($search_code_journal)) { $options .= '&search_code_journal=' . $search_code_journal; } + /* - * Mode List + * Actions */ +llxHeader('', $langs->trans("Bookkeeping")); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0); @@ -188,9 +194,9 @@ print $formaccounting->select_account($search_numero_compte_end, 'search_numero_ print ''; print '
'; print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1); +print $formaccounting->select_auxaccount($search_subledger_account_start, 'search_subledger_account_start', 1); print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': '; -print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1); +print $formaccounting->select_auxaccount($search_subledger_account_end, 'search_subledger_account_end', 1); print '
'; print ""; @@ -200,7 +206,7 @@ print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_t print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); -print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder); +print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder); @@ -232,7 +238,7 @@ print ''; print ''; print ''; print "\n"; -$var = True; - foreach ( $object->lines as $line ) { print ''; @@ -274,7 +278,7 @@ foreach ( $object->lines as $line ) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 139498bd0b2..e4e3017ab15 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -138,7 +138,7 @@ class AccountancyCategory */ public function getAccountsWithNoCategory($id) { global $conf; - + $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; @@ -147,9 +147,9 @@ class AccountancyCategory $sql .= " AND aa.active = 1"; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; - + $this->lines_CptBk = array (); - + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -159,17 +159,17 @@ class AccountancyCategory $this->lines_cptbk[] = $obj; } } - + return $num; } else { $this->error = "Error " . $this->db->lasterror(); $this->errors[] = $this->error; dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR); - + return - 1; } } - + /** * Function to add an accounting account in an accounting category * @@ -191,7 +191,7 @@ class AccountancyCategory $sql .= " AND aa.active = 1"; $this->db->begin(); - + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { @@ -201,9 +201,9 @@ class AccountancyCategory return -1; } - while ( $obj = $this->db->fetch_object($resql)) + while ( $obj = $this->db->fetch_object($resql)) { - if (array_key_exists(length_accountg($obj->account_number), $cpts)) + if (array_key_exists(length_accountg($obj->account_number), $cpts)) { $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " SET fk_accounting_category=" . $id_cat; @@ -332,7 +332,7 @@ class AccountancyCategory } /** - * Function to show result of an accounting account from the general ledger with a sens and a period + * Function to show result of an accounting account from the ledger with a direction and a period * * @param int $cpt Id accounting account * @param string $month Specifig month - Can be empty diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 1af9e5d1a6b..dc2b3195ee3 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -172,7 +172,7 @@ class AccountancyExport print $date . $this->separator; print $line->doc_ref . $this->separator; print length_accountg($line->numero_compte) . $this->separator; - print length_accounta($line->code_tiers) . $this->separator; + print length_accounta($line->subledger_account) . $this->separator; print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print $line->code_journal . $this->separator; @@ -195,7 +195,7 @@ class AccountancyExport print $date . $separator; print $line->code_journal . $separator; print length_accountg($line->numero_compte) . $separator; - print length_accounta($line->code_tiers) . $separator; + print length_accounta($line->subledger_account) . $separator; print $line->sens . $separator; print price($line->montant) . $separator; print $line->label_compte . $separator; @@ -254,7 +254,7 @@ class AccountancyExport print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print 'E' . $this->separator; - print length_accountg($line->code_tiers) . $this->separator; + print length_accountg($line->subledger_account) . $this->separator; print $this->end_line; } } @@ -274,7 +274,7 @@ class AccountancyExport $date = dol_print_date($line->doc_date, '%d/%m/%Y'); print $date . $this->separator; - if (empty($line->code_tiers)) { + if (empty($line->subledger_account)) { print 'G' . $this->separator; print length_accounta($line->numero_compte) . $this->separator; } else { @@ -284,7 +284,7 @@ class AccountancyExport if (substr($line->numero_compte, 0, 3) == '401') { print 'F' . $this->separator; } - print length_accountg($line->code_tiers) . $this->separator; + print length_accountg($line->subledger_account) . $this->separator; } print price($line->debit) . $this->separator; @@ -307,11 +307,11 @@ class AccountancyExport $this->end_line ="\r\n"; $i = 1; - $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd + $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (! empty($data->code_tiers)) - $code_compta = $data->code_tiers; + if (! empty($data->subledger_account)) + $code_compta = $data->subledger_account; $Tab = array (); $Tab['num_ecriture'] = str_pad($i, 5); @@ -349,8 +349,8 @@ class AccountancyExport $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ( $TData as $data ) { $code_compta = $data->numero_compte; - if (! empty($data->code_tiers)) - $code_compta = $data->code_tiers; + if (! empty($data->subledger_account)) + $code_compta = $data->subledger_account; $Tab = array (); $Tab['type_ligne'] = 'M'; @@ -436,19 +436,21 @@ class AccountancyExport print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print $date . $this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; - - if (empty($line->code_tiers)) { + + if (empty($line->subledger_account)) { print length_accountg($line->numero_compte) . $this->separator; } else { + // FIXME Because the subledger_account is already an accounting account, does we really need + // to concat 4011 or 401 to it ? if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') { - print '411' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + print '411' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator; } if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') { - print '401' . substr(str_replace(" ", "", $line->code_tiers), 0, 5) . $this->separator; + print '401' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator; } } - - print length_accounta($line->code_tiers) . $this->separator; + + print length_accounta($line->subledger_account) . $this->separator; print price($line->debit) . $this->separator; print price($line->credit) . $this->separator; print price($line->montant).$this->separator; diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 168934ee5a5..f47715ace58 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -46,7 +46,7 @@ class AccountingJournal extends CommonObject function __construct($db) { $this->db = $db; } - + /** * Load an object from database * @@ -62,9 +62,9 @@ class AccountingJournal extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " WHERE"; if ($rowid) { - $sql .= " rowid = '" . $rowid . "'"; + $sql .= " rowid = " . (int) $rowid; } elseif ($journal_code) { - $sql .= " code = '" . $journal_code . "'"; + $sql .= " code = '" . $this->db->escape($journal_code) . "'"; } dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); @@ -96,7 +96,7 @@ class AccountingJournal extends CommonObject } return -1; } - + /** * Return clicable name (with picto eventually) * @@ -147,7 +147,7 @@ class AccountingJournal extends CommonObject { $linkstart = ''; $linkclose = ''; - $linkend = ''; + $linkend = ''; } $label_link = $this->code; @@ -158,7 +158,7 @@ class AccountingJournal extends CommonObject if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; } - + /** * Retourne le libelle du statut d'un user (actif, inactif) * @@ -169,7 +169,7 @@ class AccountingJournal extends CommonObject { return $this->LibType($this->nature,$mode); } - + /** * Return type of an accounting journal * @@ -182,7 +182,7 @@ class AccountingJournal extends CommonObject global $langs; $langs->load("accountancy"); - + if ($mode == 0) { $prefix=''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0fc4a936117..f7c1b4d8b89 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -20,14 +20,14 @@ /** * \file htdocs/accountancy/class/bookkeeping.class.php * \ingroup Advanced accountancy - * \brief File of class to manage general ledger + * \brief File of class to manage Ledger (General Ledger and Subledger) */ // Class require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; /** - * Class to manage general ledger + * Class to manage Ledger (General Ledger and Subledger) */ class BookKeeping extends CommonObject { @@ -53,7 +53,7 @@ class BookKeeping extends CommonObject * * @var string Name of table without prefix where object is stored */ - public $table_element = 'accounting_bookkeeping'; + public $table_element = 'accounting_bookkeeping'; public $entity = 1; @@ -75,7 +75,9 @@ class BookKeeping extends CommonObject public $doc_ref; public $fk_doc; public $fk_docdet; - public $code_tiers; + public $thirdparty_code; + public $subledger_account; + public $subledger_label; public $numero_compte; public $label_compte; public $debit; @@ -127,8 +129,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -165,7 +173,7 @@ class BookKeeping extends CommonObject } if (empty($this->debit)) $this->debit = 0; if (empty($this->credit)) $this->credit = 0; - + // Check parameters if (empty($this->numero_compte) || $this->numero_compte == '-1') { @@ -176,7 +184,7 @@ class BookKeeping extends CommonObject } else { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); } return -1; @@ -191,7 +199,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; $sql .= " AND fk_doc = " . $this->fk_doc; - $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines + $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 is record is for several lines $sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -199,12 +207,12 @@ class BookKeeping extends CommonObject if ($resql) { $row = $this->db->fetch_object($resql); - if ($row->nb == 0) + if ($row->nb == 0) { // Determine piece_num $sqlnum = "SELECT piece_num"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' + $sqlnum .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'"; // For example doc_type = 'bank' $sqlnum .= " AND fk_docdet = " . $this->db->escape($this->fk_docdet); // fk_docdet is rowid into llx_bank or llx_facturedet or llx_facturefourndet, or ... $sqlnum .= " AND doc_ref = '" . $this->db->escape($this->doc_ref) . "'"; // ref of source object $sqlnum .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -244,7 +252,9 @@ class BookKeeping extends CommonObject $sql .= ", doc_ref"; $sql .= ", fk_doc"; $sql .= ", fk_docdet"; - $sql .= ", code_tiers"; + $sql .= ", thirdparty_code"; + $sql .= ", subledger_account"; + $sql .= ", subledger_label"; $sql .= ", numero_compte"; $sql .= ", label_compte"; $sql .= ", debit"; @@ -256,25 +266,27 @@ class BookKeeping extends CommonObject $sql .= ", code_journal"; $sql .= ", journal_label"; $sql .= ", piece_num"; - $sql .= ', entity'; + $sql .= ', entity'; $sql .= ") VALUES ("; $sql .= "'" . $this->db->idate($this->doc_date) . "'"; - $sql .= ",'" . $this->doc_type . "'"; - $sql .= ",'" . $this->doc_ref . "'"; + $sql .= ",'" . $this->db->escape($this->doc_type) . "'"; + $sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; $sql .= "," . $this->fk_doc; $sql .= "," . $this->fk_docdet; - $sql .= ",'" . $this->code_tiers . "'"; - $sql .= ",'" . $this->numero_compte . "'"; + $sql .= ",'" . $this->db->escape($this->thirdparty_code) . "'"; + $sql .= ",'" . $this->db->escape($this->subledger_account) . "'"; + $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; + $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; $sql .= "," . $this->debit; $sql .= "," . $this->credit; $sql .= "," . $this->montant; - $sql .= ",'" . $this->sens . "'"; - $sql .= ",'" . $this->fk_user_author . "'"; + $sql .= ",'" . $this->db->escape($this->sens) . "'"; + $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; $sql .= ",'" . $this->db->idate($this->date_create). "'"; - $sql .= ",'" . $this->code_journal . "'"; - $sql .= ",'" . $this->journal_label . "'"; - $sql .= "," . $this->piece_num; + $sql .= ",'" . $this->db->escape($this->code_journal) . "'"; + $sql .= ",'" . $this->db->escape($this->journal_label) . "'"; + $sql .= "," . $this->db->escape($this->piece_num); $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; @@ -282,7 +294,7 @@ class BookKeeping extends CommonObject $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - + if ($id > 0) { $this->id = $id; $result = 0; @@ -312,11 +324,11 @@ class BookKeeping extends CommonObject } if (! $error) { - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_CREATE',$user); // if ($result < 0) $error++; @@ -360,8 +372,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -409,7 +427,9 @@ class BookKeeping extends CommonObject $sql .= 'doc_ref,'; $sql .= 'fk_doc,'; $sql .= 'fk_docdet,'; - $sql .= 'code_tiers,'; + $sql .= 'thirdparty,'; + $sql .= 'subledger_account,'; + $sql .= 'subledger_label,'; $sql .= 'numero_compte,'; $sql .= 'label_compte,'; $sql .= 'debit,'; @@ -428,7 +448,9 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ','; $sql .= ' ' . (empty($this->fk_doc) ? '0' : $this->fk_doc) . ','; $sql .= ' ' . (empty($this->fk_docdet) ? '0' : $this->fk_docdet) . ','; - $sql .= ' ' . (! isset($this->code_tiers) ? 'NULL' : "'" . $this->db->escape($this->code_tiers) . "'") . ','; + $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; + $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; + $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; $sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; @@ -458,7 +480,7 @@ class BookKeeping extends CommonObject if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_CREATE',$user); // if ($result < 0) $error++; @@ -483,7 +505,7 @@ class BookKeeping extends CommonObject * * @param int $id Id object * @param string $ref Ref - * + * * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null) { @@ -498,7 +520,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -532,7 +556,9 @@ class BookKeeping extends CommonObject $this->doc_ref = $obj->doc_ref; $this->fk_doc = $obj->fk_doc; $this->fk_docdet = $obj->fk_docdet; - $this->code_tiers = $obj->code_tiers; + $this->thirdparty_code = $obj->thirdparty_code; + $this->subledger_account = $obj->subledger_account; + $this->subledger_label = $obj->subledger_label; $this->numero_compte = $obj->numero_compte; $this->label_compte = $obj->label_compte; $this->debit = $obj->debit; @@ -555,11 +581,11 @@ class BookKeeping extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); - + return - 1; } } - + /** * Load object in memory from the database * @@ -569,7 +595,7 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) - * + * * @return int <0 if KO, >0 if OK */ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { @@ -584,7 +610,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -604,11 +632,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } elseif ($key == 't.label_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; @@ -630,7 +658,7 @@ class BookKeeping extends CommonObject } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); - } + } $this->lines = array (); $resql = $this->db->query($sql); @@ -647,7 +675,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -672,8 +702,8 @@ class BookKeeping extends CommonObject return - 1; } } - - + + /** * Load object in memory from the database * @@ -683,7 +713,7 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) - * + * * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { @@ -698,7 +728,9 @@ class BookKeeping extends CommonObject $sql .= " t.doc_ref,"; $sql .= " t.fk_doc,"; $sql .= " t.fk_docdet,"; - $sql .= " t.code_tiers,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; $sql .= " t.numero_compte,"; $sql .= " t.label_compte,"; $sql .= " t.debit,"; @@ -719,11 +751,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; @@ -758,7 +790,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -814,11 +848,11 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key . '=' . $value; - } elseif ($key == 't.code_tiers' || $key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; } else { $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; @@ -834,7 +868,7 @@ class BookKeeping extends CommonObject $sql .= ' GROUP BY t.numero_compte'; if (! empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } if (! empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); @@ -869,7 +903,7 @@ class BookKeeping extends CommonObject * * @param User $user User that modifies * @param bool $notrigger false=launch triggers after, true=disable triggers - * + * * @return int <0 if KO, >0 if OK */ public function update(User $user, $notrigger = false) { @@ -890,8 +924,14 @@ class BookKeeping extends CommonObject if (isset($this->fk_docdet)) { $this->fk_docdet = trim($this->fk_docdet); } - if (isset($this->code_tiers)) { - $this->code_tiers = trim($this->code_tiers); + if (isset($this->thirdparty_code)) { + $this->thirdparty_code = trim($this->thirdparty_code); + } + if (isset($this->subledger_account)) { + $this->subledger_account = trim($this->subledger_account); + } + if (isset($this->subledger_label)) { + $this->subledger_label = trim($this->subledger_label); } if (isset($this->numero_compte)) { $this->numero_compte = trim($this->numero_compte); @@ -937,7 +977,9 @@ class BookKeeping extends CommonObject $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; $sql .= ' fk_doc = ' . (isset($this->fk_doc) ? $this->fk_doc : "null") . ','; $sql .= ' fk_docdet = ' . (isset($this->fk_docdet) ? $this->fk_docdet : "null") . ','; - $sql .= ' code_tiers = ' . (isset($this->code_tiers) ? "'" . $this->db->escape($this->code_tiers) . "'" : "null") . ','; + $sql .= ' thirdparty_code = ' . (isset($this->thirdparty_code) ? "'" . $this->db->escape($this->thirdparty_code) . "'" : "null") . ','; + $sql .= ' subledger_account = ' . (isset($this->subledger_account) ? "'" . $this->db->escape($this->subledger_account) . "'" : "null") . ','; + $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; @@ -963,7 +1005,7 @@ class BookKeeping extends CommonObject if (! $error && ! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // $result=$this->call_trigger('MYOBJECT_MODIFY',$user); // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} @@ -987,7 +1029,7 @@ class BookKeeping extends CommonObject * * @param User $user User that deletes * @param bool $notrigger false=launch triggers after, true=disable triggers - * + * * @return int <0 if KO, >0 if OK */ public function delete(User $user, $notrigger = false) { @@ -1070,7 +1112,7 @@ class BookKeeping extends CommonObject function deleteByYearAndJournal($delyear='', $journal='') { global $conf; - if (empty($delyear) && empty($journal)) + if (empty($delyear) && empty($journal)) { return -1; } @@ -1137,7 +1179,7 @@ class BookKeeping extends CommonObject * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone - * + * * @return int New id of clone */ public function createFromClone($fromid) { @@ -1196,8 +1238,10 @@ class BookKeeping extends CommonObject $this->doc_ref = ''; $this->fk_doc = ''; $this->fk_docdet = ''; - $this->code_tiers = ''; - $this->numero_compte = ''; + $this->thirdparty_code = 'CU001'; + $this->subledger_account = '410CU001'; + $this->subledger_label = 'My customer company'; + $this->numero_compte = '410'; $this->label_compte = ''; $this->debit = 99.9; $this->credit = ''; @@ -1205,8 +1249,8 @@ class BookKeeping extends CommonObject $this->sens = ''; $this->fk_user_author = $user->id; $this->import_key = ''; - $this->code_journal = ''; - $this->journal_label = ''; + $this->code_journal = 'VT'; + $this->journal_label = 'Journal de vente'; $this->piece_num = ''; } @@ -1249,7 +1293,7 @@ class BookKeeping extends CommonObject * * @return string Next numero to use */ - public function getNextNumMvt() + public function getNextNumMvt() { global $conf; @@ -1281,7 +1325,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; + $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -1303,7 +1347,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -1335,7 +1381,7 @@ class BookKeeping extends CommonObject global $conf; $sql = "SELECT rowid, doc_date, doc_type,"; - $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; + $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; @@ -1359,7 +1405,9 @@ class BookKeeping extends CommonObject $line->doc_ref = $obj->doc_ref; $line->fk_doc = $obj->fk_doc; $line->fk_docdet = $obj->fk_docdet; - $line->code_tiers = $obj->code_tiers; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->numero_compte = $obj->numero_compte; $line->label_compte = $obj->label_compte; $line->debit = $obj->debit; @@ -1380,9 +1428,9 @@ class BookKeeping extends CommonObject return - 1; } } - - - + + + /** * Return list of accounts with label by chart of accounts * @@ -1397,11 +1445,11 @@ class BookKeeping extends CommonObject */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { global $conf; - + require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - + $pcgver = $conf->global->CHARTOFACCOUNTS; - + $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; @@ -1410,43 +1458,43 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; $sql .= " ORDER BY account_number ASC"; - + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - + if (! $resql) { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); return - 1; } - + $out = ajax_combobox($htmlname, $event); - + $options = array(); $selected = null; - + while ($obj = $this->db->fetch_object($resql)) { $label = length_accountg($obj->account_number) . ' - ' . $obj->label; - + $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; - + if ($select_in == 1) { $select_value_in = $obj->account_number; } if ($select_out == 1) { $select_value_out = $obj->account_number; } - + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number // Because same account_number can be share between different accounting_system and do have the same meaning if (($selectid != '') && $selectid == $select_value_in) { $selected = $select_value_out; } - + $options[$select_value_out] = $label; } - + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); $this->db->free($resql); return $out; @@ -1454,7 +1502,7 @@ class BookKeeping extends CommonObject /** - * Description of a root accounting account + * Description of a root accounting account * * @param string $account Accounting account * @return string Root account @@ -1470,7 +1518,7 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid"; - $sql .= " WHERE aa.account_number = '" . $account . "'"; + $sql .= " WHERE aa.account_number = '" . $account . "'"; $sql .= " AND parent.active = 1"; $sql .= " AND root.active = 1"; $sql .= " AND aa.entity IN (" . getEntity('accountancy') . ")"; @@ -1480,7 +1528,7 @@ class BookKeeping extends CommonObject if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } return $obj->label; @@ -1492,8 +1540,8 @@ class BookKeeping extends CommonObject return -1; } } - - + + /** * Description of accounting account * @@ -1519,7 +1567,7 @@ class BookKeeping extends CommonObject if ($resql) { $obj = ''; if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); } if(empty($obj->category)){ return $obj->label; @@ -1532,7 +1580,7 @@ class BookKeeping extends CommonObject return -1; } } - + } @@ -1547,7 +1595,9 @@ class BookKeepingLine public $doc_ref; public $fk_doc; public $fk_docdet; - public $code_tiers; + public $thirdparty_code; + public $subledger_account; + public $subledger_label; public $numero_compte; public $label_compte; public $debit; diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 02549be2a94..bf3e80fe866 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -63,8 +63,6 @@ print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy' $step = 0; -print "
\n"; - print $langs->trans("AccountancyAreaDescIntro")."
\n"; print "
\n";print "
\n"; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 9eae2072243..6c391531662 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -364,7 +364,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; if ($tabtype[$key] == 'payment') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; @@ -378,7 +378,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice } } else if ($tabtype[$key] == 'payment_supplier') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $sqlmid = 'SELECT facf.ref_supplier, facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; @@ -392,7 +392,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice } } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $sqlmid = 'SELECT e.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; @@ -405,13 +405,13 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment } @@ -458,7 +458,7 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->date_create = $now; if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice $sqlmid = 'SELECT fac.facnumber'; @@ -472,7 +472,7 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->facnumber; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; @@ -486,23 +486,23 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_vat') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat } else if ($tabtype[$key] == 'payment_donation') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation } else if ($tabtype[$key] == 'payment_salary') { - $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment } else if ($tabtype[$key] == 'banktransfert') { - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; $bookkeeping->numero_compte = $k; } else { // FIXME Should be a temporary account ??? @@ -758,7 +758,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 557218a0ee6..759dca8dae9 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -62,7 +62,7 @@ if ($user->societe_id > 0) /* * Actions */ - + // Get informations of journal $accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic->fetch($id_journal); @@ -175,7 +175,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; + $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; $bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->montant = $mt; @@ -222,7 +223,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -267,7 +269,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'expense_report'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -462,7 +465,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; @@ -576,7 +579,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print "
"; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 3729860d29d..506c5517821 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -131,7 +131,7 @@ if ($result) { // contrôles $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; - + $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) @@ -214,9 +214,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->thirdparty_code = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->debit = ($mt <= 0) ? $mt : 0; @@ -261,7 +262,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -306,7 +308,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; @@ -479,7 +482,7 @@ $companystatic = new Fournisseur($db); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("subledger_account") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'; } @@ -518,7 +521,7 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; @@ -635,7 +638,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print "
"; + print ""; // print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 0d2e7ac19cc..8506b2a480b 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -231,10 +231,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta']; - // $bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); + $bookkeeping->thirdparty_code = $tabcompany[$key]['code_client']; + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt >= 0) ? $mt : 0; @@ -277,7 +277,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->montant = $mt; @@ -321,7 +322,8 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; + $bookkeeping->subledger_account = ''; + $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; $bookkeeping->montant = $mt; @@ -373,7 +375,7 @@ if ($action == 'writebookkeeping') { { setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - + $action=''; } @@ -416,7 +418,7 @@ $form = new Form($db); print length_accounta(html_entity_decode($k)) . $sep; print ($mt < 0 ? 'C' : 'D') . $sep; print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; + print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . $sep; print $val["ref"]; print "\n"; } @@ -469,7 +471,7 @@ $form = new Form($db); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; @@ -535,7 +537,7 @@ if (empty($action) || $action == 'view') { } else { print ''; }*/ - print '
'; + print '
'; print ''; print '
'; @@ -602,7 +604,7 @@ if (empty($action) || $action == 'view') { // print "
'; - print ""; + print ""; print ""; print ""; print ""; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 1780da06456..af0874b8c30 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -224,7 +224,7 @@ class modAccounting extends DolibarrModules $this->rights[$r][4] = 'chartofaccount'; $this->rights[$r][5] = ''; $r++; - + $this->rights[$r][0] = 50401; $this->rights[$r][1] = 'Bind products and invoices with accounting accounts'; $this->rights[$r][2] = 'r'; @@ -242,9 +242,9 @@ class modAccounting extends DolibarrModules $this->rights[$r][5] = 'dispatch_advanced'; $r++; */ - + $this->rights[$r][0] = 50411; - $this->rights[$r][1] = 'Read operations in General Ledger'; + $this->rights[$r][1] = 'Read operations in Ledger'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'mouvements'; @@ -252,7 +252,7 @@ class modAccounting extends DolibarrModules $r++; $this->rights[$r][0] = 50412; - $this->rights[$r][1] = 'Write/Edit operations in General Ledger'; + $this->rights[$r][1] = 'Write/Edit operations in Ledger'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'mouvements'; @@ -260,7 +260,7 @@ class modAccounting extends DolibarrModules $r++; $this->rights[$r][0] = 50420; - $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, general ledger)'; + $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'comptarapport'; @@ -279,7 +279,7 @@ class modAccounting extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + // Exports //-------- $r=0; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 46e3b698100..e5ee1866567 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -187,6 +187,7 @@ UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM ll ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); --Update general ledger for FEC format & harmonization + ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_tiers varchar(32); ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN code_tiers thirdparty_code varchar(32); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 5f3d4eef2da..8ff65371fa5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -49,8 +49,8 @@ AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. F AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s. AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s. -AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this, use the menu entry %s. -AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the General Ledger. For this, go into menu %s, and click into button %s. +AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in Ledger in one click. Complete missing bindings. For this, use the menu entry %s. +AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the Ledger. For this, go into menu %s, and click into button %s. AccountancyAreaDescAnalyze=STEP %s: Add or edit existing transactions and generate reports and exports. AccountancyAreaDescClosePeriod=STEP %s: Close period so we can't make modification in a future. @@ -61,6 +61,8 @@ ChangeAndLoad=Change and load Addanaccount=Add an accounting account AccountAccounting=Accounting account AccountAccountingShort=Account +SubledgerAccount=Subledger Account +subledger_account=Subledger Account ShowAccountingAccount=Show accounting account ShowAccountingJournal=Show accounting journal AccountAccountingSuggest=Accounting account suggested @@ -77,8 +79,8 @@ SuppliersVentilation=Supplier invoice binding ExpenseReportsVentilation=Expense report binding CreateMvts=Create new transaction UpdateMvts=Modification of a transaction -WriteBookKeeping=Journalize transactions in General Ledger -Bookkeeping=General ledger +WriteBookKeeping=Journalize transactions in Ledger +Bookkeeping=Ledger AccountBalance=Account balance CAHTF=Total purchase supplier before tax @@ -141,16 +143,16 @@ TransactionNumShort=Num. transaction AccountingCategory=Accounting account groups GroupByAccountAccounting=Group by accounting account NotMatch=Not Set -DeleteMvt=Delete general ledger lines +DeleteMvt=Delete Ledger lines DelYear=Year to delete DelJournal=Journal to delete -ConfirmDeleteMvt=This will delete all lines of the general ledger for year and/or from a specific journal. At least one criteria is required. -ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger -DelBookKeeping=Delete record of the general ledger +ConfirmDeleteMvt=This will delete all lines of the Ledger for year and/or from a specific journal. At least one criteria is required. +ConfirmDeleteMvtPartial=This will delete the selected line(s) of the Ledger +DelBookKeeping=Delete record of the Ledger FinanceJournal=Finance journal ExpenseReportsJournal=Expense reports journal DescFinanceJournal=Finance journal including all the types of payments by bank account -DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the General Ledger. +DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the Ledger. VATAccountNotDefined=Account for VAT not defined ThirdpartyAccountNotDefined=Account for third party not defined ProductAccountNotDefined=Account for product not defined @@ -192,7 +194,7 @@ AutomaticBindingDone=Automatic binding done ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s FicheVentilation=Binding card -GeneralLedgerIsWritten=Transactions are written in the general ledger +GeneralLedgerIsWritten=Transactions are written in the Ledger GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be dispatched. If there is no other error message, this is probably because they were already dispatched. NoNewRecordSaved=No new record dispatched ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account @@ -261,4 +263,4 @@ NoJournalDefined=No journal defined Binded=Lines bound ToBind=Lines to bind -WarningReportNotReliable=Warning, this report is not based on the General Ledger, so does not contains transaction modified manualy in the General ledger. It will be replaced by a more complete report in a next version. +WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. It will be replaced by a more complete report in a next version. diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c85a2671c21..6f8a1b5e301 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -190,8 +190,10 @@ AccountancyJournal=Accountancy code journal ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for collecting VAT - VAT on sales (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for recovered VAT - VAT on purchases (used if not defined on VAT dictionary setup) ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT -ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account by default for customer third parties (used if not defined on third party card) -ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account by default for supplier third parties (used if not defined on third party card) +ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties +ACCOUNTING_ACCOUNT_CUSTOMER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated customer accouting account on third party is not defined +ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties +ACCOUNTING_ACCOUNT_SUPPLIER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined CloneTax=Clone a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment CloneTaxForNextMonth=Clone it for next month From f39fb5187a4f490378d672a88794f254af27c055 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 20:27:40 +0200 Subject: [PATCH 07/27] Fix component to select journal --- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 6 +++--- htdocs/compta/bank/card.php | 4 ++-- htdocs/core/class/html.formaccounting.class.php | 17 +++++++---------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3ef418e2e20..f40bfda856f 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -256,7 +256,7 @@ if ($action == 'create') { print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b6685248ca7..cd93b1142f8 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -322,7 +322,7 @@ if ($action == 'delbookkeepingyear') { $delyear = dol_print_date(dol_now(), '%Y'); } $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); $form_question['delyear'] = array ( 'name' => 'delyear', @@ -333,9 +333,9 @@ if ($action == 'delbookkeepingyear') { ); $form_question['deljournal'] = array ( 'name' => 'deljournal', - 'type' => 'select', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component 'label' => $langs->trans('DelJournal'), - 'values' => $journal_array, + 'value' => $journal_array, 'default' => $deljournal ); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 06918ff2846..1f55698d13f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -524,7 +524,7 @@ if ($action == 'create') { print ''; print ''; } @@ -982,7 +982,7 @@ else { print ''; print ''; } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 2d444c1aefe..e37e1690ca2 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -54,15 +54,14 @@ class FormAccounting extends Form * @param string $htmlname Name of field in html form * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) * @param int $showempty Add an empty field - * @param array $event Event options * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code * @param int $select_out Set value returned by select. 0=rowid (default), 1=code * @param string $morecss More css non HTML object * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. - * + * @param int $disabledajaxcombo Disable ajax combo box. * @return string String with HTML select */ - function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') + function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0) { global $conf; @@ -92,8 +91,6 @@ class FormAccounting extends Form return -1; } - $out = ajax_combobox($htmlname, $event); - $selected = 0; while ($obj = $this->db->fetch_object($resql)) { @@ -125,7 +122,7 @@ class FormAccounting extends Form } } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo?0:1)); return $out; } @@ -204,9 +201,9 @@ class FormAccounting extends Form { dol_print_error($db,$db->lasterror()); } - - $out .= ajax_combobox($htmlname, $event); - + + $out .= ajax_combobox($htmlname, array()); + print $out; } @@ -260,7 +257,7 @@ class FormAccounting extends Form require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; $out = ''; - + $options = array(); if ($usecache && ! empty($this->options_cache[$usecache])) { From 78d5520741746af4874f0a628d48996a83e95094 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Jun 2017 21:23:35 +0200 Subject: [PATCH 08/27] Fix: missing _cleanObjectDatas function --- htdocs/admin/agenda.php | 3 +- htdocs/admin/agenda_other.php | 1 + .../action/class/api_agendaevents.class.php | 58 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 22679ca697b..a30ebad4703 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -33,6 +33,7 @@ if (!$user->admin) $langs->load("admin"); $langs->load("other"); +$langs->load("agenda"); $action = GETPOST('action','alpha'); $cancel = GETPOST('cancel','alpha'); @@ -172,7 +173,7 @@ if (! empty($triggers)) if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; - + print ''; print ''; print ''; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 44ec3ade889..31bcf1077e6 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -36,6 +36,7 @@ if (!$user->admin) $langs->load("admin"); $langs->load("other"); +$langs->load("agenda"); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index f32c721a826..40737a83799 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -111,8 +111,11 @@ class AgendaEvents extends DolibarrApi if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.id as rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter @@ -298,4 +301,59 @@ class AgendaEvents extends DolibarrApi } return $event; } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->import_key); + unset($object->array_options); + unset($object->linkedObjectsIds); + unset($object->context); + unset($object->canvas); + unset($object->fk_project); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->statut); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->contact); + unset($object->societe); + + return $object; + } } From 8b7ca1f280e5b6f1465caddd1cd4d9c12adf920f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 21:27:20 +0200 Subject: [PATCH 09/27] Fix missing vat_src_code into table of expense report --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_expensereport_det.sql | 1 + 2 files changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index e5ee1866567..a66ef47fba6 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -90,6 +90,8 @@ ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_so ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14); ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255); + + ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30); @@ -230,6 +232,7 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoic ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier_source FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid); ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT ''; +ALTER TABLE llx_expensereport_det ADD COLUMN vat_src_code varchar(10) DEFAULT ''; DELETE FROM llx_const WHERE name = __ENCRYPT('ADHERENT_BANK_USE_AUTO')__; diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 069cd534e4f..8d01f29de68 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -27,6 +27,7 @@ CREATE TABLE llx_expensereport_det qty real NOT NULL, value_unit real NOT NULL, remise_percent real, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- Vat rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type From 9410466d727f94f6e2b99c390f43a2e4a4bc8e00 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Jun 2017 21:51:31 +0200 Subject: [PATCH 10/27] Fix: better check and security --- .../action/class/api_agendaevents.class.php | 31 ++++++++++--------- htdocs/core/lib/security.lib.php | 4 +-- htdocs/societe/class/api_contacts.class.php | 10 +++--- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 40737a83799..40fce1fd640 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -63,20 +63,20 @@ class AgendaEvents extends DolibarrApi */ function get($id) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insuffisant rights to read an event"); } $result = $this->actioncomm->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Agenda Events not found'); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->ownerid != DolibarrApiAccess::$user->id) { throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { + if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -102,6 +102,10 @@ class AgendaEvents extends DolibarrApi $obj_ret = array(); + if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + throw new RestException(401, "Insuffisant rights to read events"); + } + // case of external user $socid = 0; if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; @@ -155,7 +159,7 @@ class AgendaEvents extends DolibarrApi { $obj = $db->fetch_object($result); $actioncomm_static = new ActionComm($db); - if($actioncomm_static->fetch($obj->rowid)) { + if ($actioncomm_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($actioncomm_static); } $i++; @@ -164,7 +168,7 @@ class AgendaEvents extends DolibarrApi else { throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if ( ! count($obj_ret)) { throw new RestException(404, 'No Agenda Event found'); } return $obj_ret; @@ -178,10 +182,10 @@ class AgendaEvents extends DolibarrApi */ function post($request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } @@ -216,19 +220,19 @@ class AgendaEvents extends DolibarrApi */ /* function put($id, $request_data = NULL) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } $result = $this->expensereport->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + if ( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach($request_data as $field => $value) { @@ -236,7 +240,7 @@ class AgendaEvents extends DolibarrApi $this->expensereport->$field = $value; } - if($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) + if ($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get($id); return false; @@ -314,7 +318,6 @@ class AgendaEvents extends DolibarrApi unset($object->import_key); unset($object->array_options); - unset($object->linkedObjectsIds); unset($object->context); unset($object->canvas); unset($object->fk_project); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 9a9e78513c3..d3250263a6f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -403,9 +403,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh else if (in_array($feature,$checksoc)) // We check feature = checksoc { // If external user: Check permission for external users - if ($user->societe_id > 0) + if ($user->socid > 0) { - if ($user->societe_id <> $objectid) return false; + if ($user->socid <> $objectid) return false; } // If internal user: Check permission for internal users that are restricted on their objects else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 58fe15cf282..f136d6895b2 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -43,7 +43,8 @@ class Contacts extends DolibarrApi /** * Constructor */ - function __construct() { + function __construct() + { global $db, $conf; $this->db = $db; $this->contact = new Contact($this->db); @@ -59,7 +60,8 @@ class Contacts extends DolibarrApi * * @throws RestException */ - function get($id) { + function get($id) + { if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { throw new RestException(401, 'No permission to read contacts'); @@ -105,7 +107,7 @@ class Contacts extends DolibarrApi } // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; @@ -171,7 +173,7 @@ class Contacts extends DolibarrApi } } else { - throw new RestException(503, 'Error when retreive contacts : ' . $sql); + throw new RestException(503, 'Error when retrieve contacts : ' . $sql); } if (!count($obj_ret)) { From 8149bf62a89ca60b0dfd44ec88bff6b600121ea1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 23:47:19 +0200 Subject: [PATCH 11/27] Fix ajaxcombo broken on accouting account edition on vat dictionary. --- htdocs/admin/dict.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index c83a3aa39be..f920b04bf62 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1502,9 +1502,12 @@ if ($id) } $class='tddict'; + if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto'; if ($fieldlist[$field] == 'code') $class.=' width100'; if ($fieldlist[$field] == 'position') $class.=' right'; + if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap'; + if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap'; // Show value for field if ($showfield) print ''; } @@ -1694,7 +1697,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } // For state page, we do not show the country input (we link to region, not country) print ''; } elseif ($fieldlist[$field] == 'country_id') @@ -1820,7 +1823,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { $fieldname = $fieldlist[$field]; $accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0); - print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); + print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone'); } else { From ac708a8ee993457e43da17b7ddbcb1a06cd1e296 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jun 2017 23:58:56 +0200 Subject: [PATCH 12/27] Debug accounting module with new structure v6 Make accounting module compatible with the new vat code to identify 2 vat code with same rate. --- .../accountancy/class/bookkeeping.class.php | 7 +- htdocs/accountancy/journal/bankjournal.php | 10 ++- .../journal/expensereportsjournal.php | 28 ++++--- .../accountancy/journal/purchasesjournal.php | 47 ++++++++---- htdocs/accountancy/journal/sellsjournal.php | 48 +++++++----- .../core/class/html.formaccounting.class.php | 4 +- htdocs/core/lib/functions.lib.php | 73 ++++++++++++------- htdocs/langs/en_US/errors.lang | 2 + 8 files changed, 142 insertions(+), 77 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index f7c1b4d8b89..9ed4ef29ac1 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -184,7 +184,8 @@ class BookKeeping extends CommonObject } else { - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->fk_doc, $this->doc_type); + //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $this->label_compte); } return -1; @@ -451,7 +452,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; - $sql .= ' ' . (! isset($this->numero_compte) ? "'NotDefined'" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; + $sql .= ' ' . (! isset($this->numero_compte) ? "NULL" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; @@ -461,7 +462,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; - $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).','; + $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).','; $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 6c391531662..568edf051ff 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -103,8 +103,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; @@ -144,6 +143,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); + // Variables $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); @@ -537,6 +537,12 @@ if (! $error && $action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 759dca8dae9..ca9d05e7e93 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -86,13 +86,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; -$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation,"; +$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; -$sql .= " f.accountancy_code, ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; +$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; @@ -110,7 +110,8 @@ dol_syslog('accountancy/journal/expensereportsjournal.php:: $sql=' . $sql); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - // les variables + + // Variables $account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"); $account_vat = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); @@ -130,8 +131,11 @@ if ($result) { $compta_fees = $obj->compte; $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat); - // Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } $taber[$obj->rowid]["date"] = $db->jdate($obj->de); $taber[$obj->rowid]["ref"] = $obj->ref; @@ -271,7 +275,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->label_compte = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -307,6 +311,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -556,7 +566,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 506c5517821..b5f763fe2b1 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -85,26 +85,27 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; -$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,"; +$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; +$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql .= " WHERE f.fk_statut > 0 "; +$sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? $sql .= " AND fd.fk_code_ventilation > 0 "; $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) - $sql .= " AND f.type IN (0,1,2)"; -else - $sql .= " AND f.type IN (0,1,2,3)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +} else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; +} if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " ORDER BY f.datef"; @@ -114,7 +115,7 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - // les variables + // Variables $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"); $cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"); @@ -139,10 +140,15 @@ if ($result) { else $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"); } - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - //Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); + + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')'; @@ -214,8 +220,9 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->montant = $mt; @@ -262,6 +269,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; @@ -308,9 +316,10 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'supplier_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->numero_compte = $k; $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; @@ -346,6 +355,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -615,7 +630,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; print '"; print '"; print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 8506b2a480b..24f5ae6e7aa 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -89,27 +89,26 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); -$idpays = $p[0]; +$idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,"; -$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,"; +$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " fd.situation_percent,ct.accountancy_code_sell as account_tva"; +$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +//$sql .= " ct.accountancy_code_sell as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON ((fd.vat_src_code <> '' AND fd.vat_src_code = ct.code) OR (fd.vat_src_code = '' AND fd.tva_tx = ct.taux)) AND ct.fk_pays = '" . $idpays . "'"; $sql .= " WHERE fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ? if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) @@ -127,29 +126,33 @@ if ($result) { $tabcompany = array (); $num = $db->num_rows($result); - $i = 0; + // Variables $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); + $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - // les variables $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_prod = $obj->compte; if (empty($compta_prod)) { if ($obj->product_type == 0) $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + else + $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); } - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); - //Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + // Define array to display all VAT rates that use this accounting account $compta_tva + if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + { + $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); + } // Situation invoices handling $line = new FactureLigne($db); @@ -231,8 +234,9 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->thirdparty_code = $tabcompany[$key]['code_client']; + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->montant = $mt; @@ -277,6 +281,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; @@ -322,10 +327,11 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_type = 'customer_invoice'; $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_client; $bookkeeping->subledger_account = ''; $bookkeeping->subledger_label = ''; $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); $bookkeeping->montant = $mt; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->debit = ($mt < 0) ? $mt : 0; @@ -360,6 +366,12 @@ if ($action == 'writebookkeeping') { else { $db->rollback(); + + if ($error >= 10) + { + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); + break; // Break in the foreach + } } } @@ -651,7 +663,7 @@ if (empty($action) || $action == 'view') { } else print $accountoshow; print ""; - print ""; + print ""; // print ""; print ""; print ""; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e37e1690ca2..7248c4bda3a 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -241,7 +241,7 @@ class FormAccounting extends Form * Return list of accounts with label by chart of accounts * * @param string $selectid Preselected id or code of accounting accounts (depends on $select_in) - * @param string $htmlname Name of field in html form + * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. * @param int $showempty Add an empty field * @param array $event Event options * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number @@ -284,8 +284,6 @@ class FormAccounting extends Form return -1; } - $out .= ajax_combobox($htmlname, $event); - $selected = 0; while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 49bcc265050..a582263185b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4099,29 +4099,49 @@ function get_localtax_by_third($local) /** - * Get vat rate and npr from id. - * You can call getLocalTaxesFromRate after to get other fields + * Get vat main information from Id. + * You can call getLocalTaxesFromRate after to get other fields. * - * @param int $vatrowid Line ID into vat rate table. - * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is id into table (use this if you can) + * @return array array('rowid'=> , 'code'=> ...) + * @see getLocalTaxesFromRate */ -function getTaxesFromId($vatrowid) +function getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1) { global $db, $mysoc; - dol_syslog("getTaxesFromId vatrowid=".$vatrowid); + dol_syslog("getTaxesFromId vatrowid=".$vatrate); // Search local taxes - $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr"; + $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; - $sql.= " WHERE t.rowid ='".$vatrowid."'"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; + else + { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; + if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? + else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; + $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; + } $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - - return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr); + if ($obj) return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr, 'accountancy_code_sell'=>$obj->accountancy_code_sell, 'accountancy_code_buy'=>$obj->accountancy_code_buy); + else return array(); } else dol_print_error($db); @@ -4135,12 +4155,13 @@ function getTaxesFromId($vatrowid) * Instead this function must be called when adding a line to get the array of localtax and type, and then * provide it to the function calcul_price_total. * - * @param string $vatrate VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. - * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) - * @param Societe $buyer Company object - * @param Societe $seller Company object - * @param int $firstparamisid 1 if first param is id into table (use this if you can) - * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is id into table (use this if you can) + * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...) + * @see getTaxesFromId */ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0) { @@ -4148,25 +4169,25 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); - $vatratecleaned = $vatrate; - $vatratecode = ''; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" - { - $vatratecleaned = $reg[1]; - $vatratecode = $reg[2]; - } - // Search local taxes $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; - if ($firstparamisid) $sql.= " WHERE t.rowid ='".$vatrate."'"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; else { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; - if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; } $resql=$db->query($sql); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0f49bd832d6..0f57a23d23c 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -182,6 +182,7 @@ ErrorFailedToLoadLoginFileForMode=Failed to get the login key for mode '%s'. ErrorModuleNotFound=File of module was not found. ErrorFieldAccountNotDefinedForBankLine=Value for Accounting account not defined for source line id %s (%s) ErrorFieldAccountNotDefinedForInvoiceLine=Value for Accounting account not defined for invoice id %s (%s) +ErrorFieldAccountNotDefinedForLine=Value for Accounting account not defined for the line (%s) ErrorBankStatementNameMustFollowRegex=Error, bank statement name must follow the following syntax rule %s ErrorPhpMailDelivery=Check that you don't use a too high number of recipients and that your email content is not similar to a Spam. Ask also your administrator to check firewall and server logs files for a more complete information. ErrorUserNotAssignedToTask=User must be assigned to task to be able to enter time consumed. @@ -191,6 +192,7 @@ ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package ( Date: Fri, 16 Jun 2017 00:49:52 +0200 Subject: [PATCH 13/27] Debug accounting module with new structure v6 Make accounting module compatible with the new vat code to identify 2 vat code with same rate. --- htdocs/accountancy/admin/defaultaccounts.php | 2 +- htdocs/accountancy/bookkeeping/card.php | 8 +++--- htdocs/accountancy/bookkeeping/list.php | 4 +-- .../accountancy/class/bookkeeping.class.php | 7 ++++- .../journal/expensereportsjournal.php | 12 +++++---- .../accountancy/journal/purchasesjournal.php | 26 +++++++++++++------ htdocs/accountancy/journal/sellsjournal.php | 14 +++++++++- .../core/class/html.formaccounting.class.php | 16 +++++------- htdocs/langs/en_US/accountancy.lang | 1 + 9 files changed, 59 insertions(+), 31 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index ef39252ff87..227949a3c1c 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -51,8 +51,8 @@ $action = GETPOST('action', 'alpha'); $list_account_main = array ( - 'ACCOUNTING_ACCOUNT_SUPPLIER', 'ACCOUNTING_ACCOUNT_CUSTOMER', + 'ACCOUNTING_ACCOUNT_SUPPLIER', ); $list_account = array ( diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f40bfda856f..5c558ca0a90 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -387,10 +387,10 @@ if ($action == 'create') { if ($action == 'update' && $line->id == $id) { print ''; print ''; print ''; print ''; @@ -431,10 +431,10 @@ if ($action == 'create') { if ($action == "" || $action == 'add') { print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index cd93b1142f8..4a7bca5e1b7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -389,11 +389,11 @@ print ''; print ''; } - // Assujeti a TVA ou pas + // VAT is used print ''; - print ''; + print ''; print ''; // Local Taxes - if ($mysoc->useLocalTax(1)) + // TODO Move this on same record than VATIsUsed + if ($mysoc->localtax1_assuj=="1") { print ''; } - if ($mysoc->useLocalTax(2)) + if ($mysoc->localtax1_assuj=="1") { print ''; - print ''; - print ''; From b416b22bcc00d198ff3ddfdc9e90ebd7187eaf69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:27:28 +0200 Subject: [PATCH 16/27] Fix phpcs --- htdocs/accountancy/journal/expensereportsjournal.php | 2 +- htdocs/accountancy/journal/purchasesjournal.php | 2 +- htdocs/accountancy/journal/sellsjournal.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index f73596c5aa4..3da9e09aeda 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -134,7 +134,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 27dfd532981..9ef1afdac38 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -145,7 +145,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 3150b74e9bd..4eb4dc72171 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -150,7 +150,7 @@ if ($result) { $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); // Define array to display all VAT rates that use this accounting account $compta_tva - if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) + if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) { $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); } From f424f96589b6d43d2a0abb4631470717c9a464b3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 16 Jun 2017 05:15:00 +0200 Subject: [PATCH 17/27] Fix SPEC #7013 : use database type "numeric" to store monetary values --- .../install/mysql/migration/6.0.0-7.0.0.sql | 64 +++++++++++++++++++ .../tables/llx_accounting_bookkeeping.sql | 10 +-- .../install/mysql/tables/llx_blockedlog.sql | 2 +- .../mysql/tables/llx_chargesociales.sql | 2 +- htdocs/install/mysql/tables/llx_commande.sql | 2 +- .../mysql/tables/llx_commande_fournisseur.sql | 2 +- htdocs/install/mysql/tables/llx_don.sql | 2 +- .../mysql/tables/llx_loan_schedule.sql | 6 +- .../mysql/tables/llx_paiementcharge.sql | 2 +- .../mysql/tables/llx_paiementfourn.sql | 2 +- .../mysql/tables/llx_payment_donation.sql | 2 +- .../tables/llx_payment_expensereport.sql | 2 +- .../install/mysql/tables/llx_payment_loan.sql | 6 +- .../mysql/tables/llx_payment_salary.sql | 4 +- .../mysql/tables/llx_prelevement_bons.sql | 2 +- .../llx_prelevement_facture_demande.sql | 2 +- .../mysql/tables/llx_prelevement_lignes.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 2 +- htdocs/install/mysql/tables/llx_tva.sql | 4 +- 19 files changed, 92 insertions(+), 28 deletions(-) create mode 100644 htdocs/install/mysql/migration/6.0.0-7.0.0.sql diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql new file mode 100644 index 00000000000..545b52ea4a7 --- /dev/null +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -0,0 +1,64 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 6.0.0 or higher. +-- +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): -- VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. +-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); +-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + + +-- Clean corrupted values for tms +-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; +-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; +-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE'; +-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL; +-- Remove default not null on date_fin +-- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL; +-- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL; + +-- Move real to numeric for more precision for storing monetary amounts (no rouding) +-- https://wiki.dolibarr.org/index.php/Langages_et_normes#Structure_des_tables_et_champs +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN debit numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN credit numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant numeric(24,8); +ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount numeric(24,8); +ALTER TABLE llx_blockedlog MODIFY COLUMN amounts numeric(24,8); +ALTER TABLE llx_chargessociales MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_commande MODIFY COLUMN amount_ht numeric(24,8); +ALTER TABLE llx_commande_fournisseur MODIFY COLUMN amount_ht numeric(24,8); +ALTER TABLE llx_don MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_capital numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_insurance numeric(24,8); +ALTER TABLE llx_loan_schedule MODIFY COLUMN amount_interest numeric(24,8); +ALTER TABLE llx_paiementcharge MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_paiementfourn MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_donation MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_expensereport MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_capital numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_insurance numeric(24,8); +ALTER TABLE llx_payment_loan MODIFY COLUMN amount_interest numeric(24,8); +ALTER TABLE llx_payment_salary MODIFY COLUMN salary numeric(24,8); +ALTER TABLE llx_payment_salary MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_bons MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_prelevement_lignes MODIFY COLUMN amount numeric(24,8); +ALTER TABLE llx_societe MODIFY COLUMN capital numeric(24,8); +ALTER TABLE llx_tva MODIFY COLUMN amount numeric(24,8); diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index ad1160c356d..01ced5b07f4 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -26,17 +26,17 @@ CREATE TABLE llx_accounting_bookkeeping doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid - thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) + thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug) subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account label_operation varchar(255), -- FEC:EcritureLib | label of the operation - debit double NOT NULL, -- FEC:Debit - credit double NOT NULL, -- FEC:Credit - montant double NOT NULL, -- FEC:Montant (Not necessary) + debit numeric(24,8) NOT NULL, -- FEC:Debit + credit numeric(24,8) NOT NULL, -- FEC:Credit + montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary) sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary) - multicurrency_amount double, -- FEC:Montantdevise + multicurrency_amount numeric(24,8), -- FEC:Montantdevise multicurrency_code varchar(255), -- FEC:Idevise lettering_code varchar(255), -- FEC:EcritureLet date_lettering datetime, -- FEC:DateLet diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql index ae696a0d6d1..59c8e262817 100644 --- a/htdocs/install/mysql/tables/llx_blockedlog.sql +++ b/htdocs/install/mysql/tables/llx_blockedlog.sql @@ -4,7 +4,7 @@ CREATE TABLE llx_blockedlog rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, action varchar(50), - amounts real NOT NULL, + amounts numeric(24,8) NOT NULL, signature varchar(100) NOT NULL, signature_line varchar(100) NOT NULL, element varchar(50), diff --git a/htdocs/install/mysql/tables/llx_chargesociales.sql b/htdocs/install/mysql/tables/llx_chargesociales.sql index 519ceacc9e5..093b635a964 100644 --- a/htdocs/install/mysql/tables/llx_chargesociales.sql +++ b/htdocs/install/mysql/tables/llx_chargesociales.sql @@ -34,7 +34,7 @@ create table llx_chargesociales fk_type integer NOT NULL, fk_account integer, -- bank account fk_mode_reglement integer, -- mode de reglement - amount real default 0 NOT NULL, + amount numeric(24,8) default 0 NOT NULL, paye smallint default 0 NOT NULL, periode date, fk_projet integer DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 98740c232ac..6964abdcd57 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -42,7 +42,7 @@ create table llx_commande fk_user_cloture integer, -- user closing source smallint, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, - amount_ht real default 0, + amount_ht numeric(24,8) default 0, remise_percent real default 0, remise_absolue real default 0, remise real default 0, diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 6d291dcfa00..24158903eb1 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -46,7 +46,7 @@ create table llx_commande_fournisseur source smallint NOT NULL, -- not used, except by setting this to 42 for orders coming for replenishment and 0 in other case ? fk_statut smallint default 0, billed smallint default 0, - amount_ht real default 0, + amount_ht numeric(24,8) default 0, remise_percent real default 0, remise real default 0, tva double(24,8) default 0, diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index b7b7c89f9cd..63b2cd111ea 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -28,7 +28,7 @@ create table llx_don tms timestamp, fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate datedon datetime, -- Date of the donation/promise - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_payment integer, paid smallint default 0 NOT NULL, firstname varchar(50), diff --git a/htdocs/install/mysql/tables/llx_loan_schedule.sql b/htdocs/install/mysql/tables/llx_loan_schedule.sql index c682b22f276..eb43238255a 100644 --- a/htdocs/install/mysql/tables/llx_loan_schedule.sql +++ b/htdocs/install/mysql/tables/llx_loan_schedule.sql @@ -24,9 +24,9 @@ create table llx_loan_schedule datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital real DEFAULT 0, - amount_insurance real DEFAULT 0, - amount_interest real DEFAULT 0, + amount_capital numeric(24,8) DEFAULT 0, + amount_insurance numeric(24,8) DEFAULT 0, + amount_interest numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_paiementcharge.sql b/htdocs/install/mysql/tables/llx_paiementcharge.sql index 2efca933dba..086bafae0fa 100644 --- a/htdocs/install/mysql/tables/llx_paiementcharge.sql +++ b/htdocs/install/mysql/tables/llx_paiementcharge.sql @@ -23,7 +23,7 @@ create table llx_paiementcharge datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepaiement integer NOT NULL, num_paiement varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 0e9b1885c97..16d63a32076 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -25,7 +25,7 @@ create table llx_paiementfourn tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement - amount real DEFAULT 0, -- montant + amount numeric(24,8) DEFAULT 0, -- montant multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount fk_user_author integer, -- auteur fk_paiement integer NOT NULL, -- moyen de paiement diff --git a/htdocs/install/mysql/tables/llx_payment_donation.sql b/htdocs/install/mysql/tables/llx_payment_donation.sql index afa5075cd4e..1859c7aa796 100644 --- a/htdocs/install/mysql/tables/llx_payment_donation.sql +++ b/htdocs/install/mysql/tables/llx_payment_donation.sql @@ -23,7 +23,7 @@ create table llx_payment_donation datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_expensereport.sql b/htdocs/install/mysql/tables/llx_payment_expensereport.sql index 40e39771978..1857246e22e 100644 --- a/htdocs/install/mysql/tables/llx_payment_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_payment_expensereport.sql @@ -23,7 +23,7 @@ create table llx_payment_expensereport datec datetime, -- date de creation tms timestamp, datep datetime, -- payment date - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note text, diff --git a/htdocs/install/mysql/tables/llx_payment_loan.sql b/htdocs/install/mysql/tables/llx_payment_loan.sql index d023c039391..3b6111a7b2f 100644 --- a/htdocs/install/mysql/tables/llx_payment_loan.sql +++ b/htdocs/install/mysql/tables/llx_payment_loan.sql @@ -24,9 +24,9 @@ create table llx_payment_loan datec datetime, -- creation date tms timestamp, datep datetime, -- payment date - amount_capital real DEFAULT 0, - amount_insurance real DEFAULT 0, - amount_interest real DEFAULT 0, + amount_capital numeric(24,8) DEFAULT 0, + amount_insurance numeric(24,8) DEFAULT 0, + amount_interest numeric(24,8) DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), note_private text, diff --git a/htdocs/install/mysql/tables/llx_payment_salary.sql b/htdocs/install/mysql/tables/llx_payment_salary.sql index 38364c6812e..3b6da16b9cb 100644 --- a/htdocs/install/mysql/tables/llx_payment_salary.sql +++ b/htdocs/install/mysql/tables/llx_payment_salary.sql @@ -24,8 +24,8 @@ create table llx_payment_salary fk_user integer NOT NULL, datep date, -- date de paiement datev date, -- date de valeur (this field should not be here, only into bank tables) - salary real, -- salary of user when payment was done - amount real NOT NULL DEFAULT 0, + salary numeric(24,8), -- salary of user when payment was done + amount numeric(24,8) NOT NULL DEFAULT 0, fk_typepayment integer NOT NULL, num_payment varchar(50), -- ref label varchar(255), diff --git a/htdocs/install/mysql/tables/llx_prelevement_bons.sql b/htdocs/install/mysql/tables/llx_prelevement_bons.sql index e92342eb001..40fff2e842d 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_bons.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_bons.sql @@ -29,7 +29,7 @@ create table llx_prelevement_bons ref varchar(12), -- reference entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, -- date de creation - amount real DEFAULT 0, -- montant total du prelevement + amount numeric(24,8) DEFAULT 0, -- montant total du prelevement statut smallint DEFAULT 0, -- statut credite smallint DEFAULT 0, -- indique si le prelevement a ete credite note text, diff --git a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql index 3bdc0e2ed81..1d1b59bf3f5 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_facture_demande.sql @@ -21,7 +21,7 @@ create table llx_prelevement_facture_demande ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - amount real NOT NULL, + amount numeric(24,8) NOT NULL, date_demande datetime NOT NULL, traite smallint DEFAULT 0, date_traite datetime, diff --git a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql index 04b6e1ebf5e..448b3846d71 100644 --- a/htdocs/install/mysql/tables/llx_prelevement_lignes.sql +++ b/htdocs/install/mysql/tables/llx_prelevement_lignes.sql @@ -24,7 +24,7 @@ create table llx_prelevement_lignes statut smallint DEFAULT 0, client_nom varchar(255), - amount real DEFAULT 0, + amount numeric(24,8) DEFAULT 0, code_banque varchar(128), code_guichet varchar(6), number varchar(255), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 20440b692d7..7c88a74de07 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -64,7 +64,7 @@ create table llx_societe idprof5 varchar(128), -- IDProf5: nu for france idprof6 varchar(128), -- IDProf6: nu for france tva_intra varchar(20), -- tva - capital real, -- capital de la societe + capital numeric(24,8), -- capital de la societe fk_stcomm integer DEFAULT 0 NOT NULL, -- commercial statut note_private text, -- note_public text, -- diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index 9abf63d6ad9..d2a7b67c835 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -24,11 +24,11 @@ create table llx_tva datec datetime, -- Create date datep date, -- date de paiement datev date, -- date de valeur - amount real NOT NULL DEFAULT 0, + amount numeric(24,8) NOT NULL DEFAULT 0, fk_typepayment integer NULL, num_payment varchar(50), label varchar(255), - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id note text, fk_bank integer, fk_user_creat integer, -- utilisateur who create record From c2901ae8cda0ec59b5ff61327e60112077eb1558 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Jun 2017 11:01:58 +0200 Subject: [PATCH 18/27] Fix: add/remove unset unsused fields --- htdocs/comm/action/class/api_agendaevents.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 40fce1fd640..a607998cfa8 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -316,11 +316,12 @@ class AgendaEvents extends DolibarrApi $object = parent::_cleanObjectDatas($object); + unset($object->usermod); + unset($object->libelle); unset($object->import_key); unset($object->array_options); unset($object->context); unset($object->canvas); - unset($object->fk_project); unset($object->contact); unset($object->contact_id); unset($object->thirdparty); From 1c8daf9700676064bd7adaac2dcee8e30cec2f65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 11:51:33 +0200 Subject: [PATCH 19/27] Standardize and debug code of module BlockedLog --- htdocs/blockedlog/admin/blockedlog.php | 13 +- htdocs/blockedlog/admin/fingerprints.php | 103 ++++--- htdocs/blockedlog/ajax/authority.php | 112 +++++--- htdocs/blockedlog/ajax/block-add.php | 64 +++-- htdocs/blockedlog/ajax/block-info.php | 58 +++- htdocs/blockedlog/ajax/check_signature.php | 83 ++++-- htdocs/blockedlog/class/blockedlog.class.php | 262 +++++++++--------- htdocs/blockedlog/lib/blockedlog.lib.php | 8 +- htdocs/compta/facture/card.php | 31 --- htdocs/core/modules/modBlockedLog.class.php | 6 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 24 +- htdocs/langs/en_US/admin.lang | 4 +- htdocs/langs/en_US/blockedlog.lang | 23 +- htdocs/main.inc.php | 36 ++- 14 files changed, 486 insertions(+), 341 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php index f77c6e9edd8..b3822a9acb7 100644 --- a/htdocs/blockedlog/admin/blockedlog.php +++ b/htdocs/blockedlog/admin/blockedlog.php @@ -17,7 +17,7 @@ /** * \file htdocs/blockedlog/admin/blockedlog.php - * \ingroup system + * \ingroup blockedlog * \brief Page setup for blockedlog module */ @@ -31,12 +31,13 @@ $langs->load("other"); $langs->load("blockedlog"); if (! $user->admin) accessforbidden(); - + $action = GETPOST('action','alpha'); /* * Actions */ + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -77,7 +78,7 @@ $form=new Form($db); llxHeader('',$langs->trans("BlockedLogSetup")); $linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback); $head=blockedlogadmin_prepare_head(); @@ -95,13 +96,11 @@ print "\n"; print ''; print ''; -if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { +if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { // Example with a yes / no select $var=!$var; print ''; diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php index f585b883c65..da149d4340d 100644 --- a/htdocs/blockedlog/admin/fingerprints.php +++ b/htdocs/blockedlog/admin/fingerprints.php @@ -16,8 +16,8 @@ */ /** - * \file htdocs/blockedlog/admin/blockedlog.php - * \ingroup system + * \file htdocs/blockedlog/admin/fingerprints.php + * \ingroup blockedlog * \brief Page setup for blockedlog module */ @@ -32,39 +32,39 @@ $langs->load("other"); $langs->load("blockedlog"); if (! $user->admin) accessforbidden(); - + $action = GETPOST('action','alpha'); $showonlyerrors = GETPOST('showonlyerrors','int'); $block_static = new BlockedLog($db); if($action === 'downloadblockchain') { - + $auth = new BlockedLogAuthority($db); - + $bc = $auth->getLocalBlockChain(); - + header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); - header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); - + header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\""); + echo $bc; - + exit; } else if($action === 'downloadcsv') { - + $res = $db->query("SELECT rowid,tms,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user FROM ".MAIN_DB_PREFIX."blockedlog ORDER BY rowid ASC"); - + if($res) { - + $signature = $block_static->getSignature(); - + header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"" .$signature. ".csv\""); - + print $langs->transnoentities('Id') .';'.$langs->transnoentities('Timestamp') .';'.$langs->transnoentities('Action') @@ -75,9 +75,9 @@ else if($action === 'downloadcsv') { .';'.$langs->transnoentities('Ref') .';'.$langs->transnoentities('Fingerprint') .';'.$langs->transnoentities('User')."\n"; - + while($obj = $db->fetch_object($res)) { - + print $obj->rowid .';'.$obj->tms .';'.$obj->action @@ -88,15 +88,15 @@ else if($action === 'downloadcsv') { .';'.$obj->ref_object .';'.$obj->signature .';'.$obj->fk_user."\n"; - + } - + exit; } else{ setEventMessage($db->lasterror, 'errors'); } - + } /* @@ -110,7 +110,7 @@ $form=new Form($db); llxHeader('',$langs->trans("BlockedLogSetup")); $linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); +print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback); $head=blockedlogadmin_prepare_head(); @@ -131,52 +131,63 @@ print ' '; print '
'; -print ''; +print ''; print ''; @@ -264,8 +270,6 @@ print '
' . dol_print_date($line->doc_date) . '' . $line->doc_ref . '' . length_accountg($line->numero_compte) . '' . length_accounta($line->code_tiers) . '' . length_accounta($line->subledger_account) . '' . $line->label_compte . '' . price($line->debit) . '' . price($line->credit) . '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("Code_tiers") . "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("subledger_account") . "' . ($mt < 0 ? - price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account") . "" . $langs->trans("ThirdParty"); // print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; // print "" . $langs->trans("ThirdParty"); // print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')'; print '" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
'.$langs->trans("AccountancyJournal").''; - print $formaccountancy->select_journal('', 'code_journal', '', 0, '', 1, 1, 1, 1); + print $formaccountancy->select_journal('', 'code_journal', '', 0, 1, 1, 1, 1); print '
'.$langs->trans("AccountancyJournal").''; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
'.$langs->trans("AccountancyJournal").''; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '
'.$trigger['code'].''.$trigger['label'].''.$valuetoshow.''; $fieldname='country'; - print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); print '" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]). "' . ($mt >= 0 ? price($mt) : '') . "' . ($mt < 0 ? price(- $mt) : '') . "
" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.join(', ',$def_tva[$key][$k]). "" . $langs->trans("VAT") . "" . ($mt < 0 ? price(- $mt) : '') . "" . ($mt >= 0 ? price($mt) : '') . "'; - print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print ''; - print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1); + print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1, 'maxwidth300'); print '
'; - print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); + print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print ''; - print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1); + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, 'maxwidth300'); print ''; print '
'; print $langs->trans('From'); -print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200'); print '
'; print '
'; print $langs->trans('to'); -print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); +print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200'); print '
'; print '
'; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 9ed4ef29ac1..d607c1dc287 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -185,7 +185,12 @@ class BookKeeping extends CommonObject else { //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); - $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $this->label_compte); + $mesg=$this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; + if ($this->subledger_account && $this->subledger_account != $this->numero_compte) + { + $mesg.=', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; + } + $this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); } return -1; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index ca9d05e7e93..f73596c5aa4 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -92,15 +92,15 @@ $sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " ct.accountancy_code_buy as account_tva"; +//$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " JOIN " . MAIN_DB_PREFIX . "user as u ON u.rowid = er.fk_user_author"; -$sql .= " WHERE er.fk_statut > 0 "; -$sql .= " AND erd.fk_code_ventilation > 0 "; +$sql .= " WHERE er.fk_statut > 0"; +$sql .= " AND erd.fk_code_ventilation > 0"; $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND er.date_debut >= '" . $db->idate($date_start) . "' AND er.date_debut <= '" . $db->idate($date_end) . "'"; @@ -129,7 +129,9 @@ if ($result) { // Controls $compta_user = (! empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary; $compta_fees = $obj->compte; - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $account_vat); + + $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0); + $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $account_vat); // Define array to display all VAT rates that use this accounting account $compta_tva if (! empty(price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index b5f763fe2b1..27dfd532981 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -90,21 +90,21 @@ $idpays = $mysoc->country_id; $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,"; $sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; -$sql .= " ct.accountancy_code_buy as account_tva"; +$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +//$sql .= " ct.accountancy_code_buy as account_tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; +//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0"; // TODO Facture annulée ? -$sql .= " AND fd.fk_code_ventilation > 0 "; +$sql .= " AND fd.fk_code_ventilation > 0"; $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; } if ($date_start && $date_end) $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; @@ -130,7 +130,7 @@ if ($result) { while ( $i < $num ) { $obj = $db->fetch_object($result); - // contrôles + // Controls $compta_soc = (! empty($obj->code_compta_fournisseur)) ? $obj->code_compta_fournisseur : $cptfour; $compta_prod = $obj->compte; @@ -536,8 +536,18 @@ if (empty($action) || $action == 'view') { print ''; }*/ + // Button to write into Ledger + if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } print '
'; - print ''; + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print ''; + } + else { + print ''; + } print '
'; print ' diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 24f5ae6e7aa..3150b74e9bd 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -135,6 +135,7 @@ if ($result) { while ( $i < $num ) { $obj = $db->fetch_object($result); + // Controls $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; $compta_prod = $obj->compte; @@ -549,8 +550,19 @@ if (empty($action) || $action == 'view') { } else { print ''; }*/ + + // Button to write into Ledger + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); + print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + } print '
'; - print ''; + if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { + print ''; + } + else { + print ''; + } print '
'; print ' diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 7248c4bda3a..8a348dba57a 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -325,14 +325,13 @@ class FormAccounting extends Form /** * Return list of auxilary thirdparty accounts * - * @param string $selectid Preselected pcg_type - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param array $event Event options - * - * @return string String with HTML select + * @param string $selectid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param string $morecss More css + * @return string String with HTML select */ - function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) { + function select_auxaccount($selectid, $htmlname='account_num_aux', $showempty=0, $morecss='maxwidth200') { $aux_account = array(); @@ -377,8 +376,7 @@ class FormAccounting extends Form $this->db->free($resql); // Build select - $out = ajax_combobox($htmlname, $event); - $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); + $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8ff65371fa5..64744eedf4a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -256,6 +256,7 @@ Calculated=Calculated Formula=Formula ## Error +SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) ExportNotSupported=The export format setuped is not supported into this page BookeppingLineAlreayExists=Lines already existing into bookeeping From 07b676792a26886170eb657e23410686c0f2236a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:02:53 +0200 Subject: [PATCH 14/27] Fix do not show localtax info if not used. --- htdocs/comm/card.php | 12 +++++++----- htdocs/societe/card.php | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index b8906bd1038..a51ef902eb6 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -175,7 +175,7 @@ if (empty($reshook)) $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - + if ($action == 'update_extras') { $object->fetch($id); @@ -262,21 +262,23 @@ if ($id > 0) print '
'.$langs->trans('VATIsUsed').''; + print ''.$langs->trans('VATIsUsed').''; print yn($object->tva_assuj); print '
'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; print yn($object->localtax1_assuj); print '
'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; print yn($object->localtax2_assuj); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b5afba996b8..46e6366bba1 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1766,8 +1766,9 @@ else $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''; } + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) { From b1945daf6c7eaa1d57d5bd1bf52f2c973d7b4d57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 01:07:44 +0200 Subject: [PATCH 15/27] Fix alignement --- htdocs/societe/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 1fcd73f0ddc..834131a86a8 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -365,7 +365,7 @@ if ($sql_select) print ''; print ''; print ''; // date + print ''; // date print $formother->select_month($month?$month:-1,'month',1); $formother->select_year($year?$year:-1,'year',1, 20, 1); print '
'; -print $langs->trans("EntityKey").''; - +print $langs->trans("CompanyInitialKey").''; print $block_static->getSignature(); - print '
'; print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print ''; +print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; - + print ''; foreach($blocks as &$block) { $checksignature = $block->checkSignature(); $object_link = $block->getObjectLink(); - + if(!$showonlyerrors || $block->error>0) { - + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; - + } } print '
'.$langs->trans('Date').''.$langs->trans('Ref').''.$langs->trans('#').''.$langs->trans('Date').''.$langs->trans('Author').''.$langs->trans('Action').''.$langs->trans('Ref').''.$langs->trans('Element').''.$langs->trans('Amount').''.$langs->trans('Author').''.$langs->trans('DataOfArchivedEvent').''.$langs->trans('Fingerprint').'
'.$block->id.''.dol_print_date($block->tms,'dayhour').''.$block->ref_object.''.$langs->trans('log'.$block->action).''.$object_link.''.img_info($langs->trans('ShowDetails')).''.price($block->amounts).''.$block->getUser().''.$block->signature.''.$langs->trans('log'.$block->action).''.$block->ref_object.''.$object_link.''.price($block->amounts).''.img_info($langs->trans('ShowDetails')).''; - - print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'on') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'off'); + print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature); + print ''; + print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'tick') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8'); + if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); } print '
'; + + ?> -global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { ?> - + + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - $user=new User($db); - $user->fetch(1); //TODO conf user authority - - $auth = new BlockedLogAuthority($db); - - $signature = GETPOST('s'); - $newblock = GETPOST('b'); - $hash = GETPOST('h'); - - if($auth->fetch(0, $signature)<=0) { - $auth->signature = $signature; - $auth->create($user); - } - - - if(!empty($hash)) { - - echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; - - } - elseif(!empty($newblock)){ - if($auth->checkBlock($newblock)) { - $auth->addBlock($newblock); - $auth->update($user); - - echo 'blockadded'; - } - else{ - - echo 'blockalreadyadded'; - - } +/** + * \file htdocs/blockedlog/ajax/authority.php + * \ingroup blockedlog + * \brief authority + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$res=require '../../master.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; + +$user=new User($db); +$user->fetch(1); //TODO conf user authority + +$auth = new BlockedLogAuthority($db); + +$signature = GETPOST('s'); +$newblock = GETPOST('b'); +$hash = GETPOST('h'); + +if($auth->fetch(0, $signature)<=0) { + $auth->signature = $signature; + $auth->create($user); +} + + +if(!empty($hash)) { + + echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; + +} +elseif(!empty($newblock)){ + if($auth->checkBlock($newblock)) { + $auth->addBlock($newblock); + $auth->update($user); + + echo 'blockadded'; } else{ - echo 'idontunderstandwhatihavetodo'; + + echo 'blockalreadyadded'; + } - - +} +else{ + echo 'idontunderstandwhatihavetodo'; +} + + diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index 247b01186fe..c82eac81e7b 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -1,19 +1,49 @@ - + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $id = GETPOST('id','int'); - $element = GETPOST('element','alpha'); - $action = GETPOST('action','alpha'); - - if($element === 'facture') { - dol_include_once('/compta/facture/class/facture.class.php'); - - $facture = new Facture($db); - if($facture->fetch($id)>0) { - $facture->call_trigger($action, $user); - } - +/** + * \file htdocs/blockedlog/ajax/block-add.php + * \ingroup blockedlog + * \brief Block-add + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +$res=require '../../main.inc.php'; + +$id = GETPOST('id','int'); +$element = GETPOST('element','alpha'); +$action = GETPOST('action','alpha'); + +if ($element === 'facture') { + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $facture = new Facture($db); + if($facture->fetch($id)>0) { + $facture->call_trigger($action, $user); } - \ No newline at end of file +} diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index 7a5f531e8f1..83317f33d57 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -1,15 +1,47 @@ + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - - $id = GETPOST('id'); - - $block = new BlockedLog($db); - if($block->fetch($id)>0) { - echo json_encode($block->object_data); - } - else { - echo json_encode(false); - } - \ No newline at end of file +/** + * \file htdocs/blockedlog/ajax/block-info.php + * \ingroup blockedlog + * \brief block-info + */ + + +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + +$id = GETPOST('id'); + +$block = new BlockedLog($db); +if($block->fetch($id)>0) { + echo json_encode($block->object_data); +} +else { + echo json_encode(false); +} diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php index bb018508a31..170693a2ece 100644 --- a/htdocs/blockedlog/ajax/check_signature.php +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -1,30 +1,63 @@ + * Copyright (C) 2017 ATM Consulting + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - require '../../main.inc.php'; +/** + * \file htdocs/blockedlog/ajax/block-info.php + * \ingroup blockedlog + * \brief block-info + */ - if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set'); - - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; - - $auth=new BlockedLogAuthority($db); - $auth->syncSignatureWithAuthority(); - - $block_static = new BlockedLog($db); - - $blocks = $block_static->getLog('just_certified', 0, 0, 1) ; - $auth->signature = $block_static->getSignature(); - - foreach($blocks as &$b) { - $auth->blockchain.=$b->signature; - - } - - $hash = $auth->getBlockchainHash(); - - $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; +// This script is called with a POST method. +// Directory to scan (full path) is inside POST['dir']. - $res = file_get_contents($url); - //echo $url; - echo $res; \ No newline at end of file +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + + +require '../../main.inc.php'; + +if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set'); + +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; +require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; + +$auth=new BlockedLogAuthority($db); +$auth->syncSignatureWithAuthority(); + +$block_static = new BlockedLog($db); + +$blocks = $block_static->getLog('just_certified', 0, 0, 1) ; + +$auth->signature = $block_static->getSignature(); + +foreach($blocks as &$b) { + $auth->blockchain.=$b->signature; + +} + +$hash = $auth->getBlockchainHash(); + +$url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; + +$res = file_get_contents($url); +//echo $url; +echo $res; \ No newline at end of file diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index b0cddd66f75..8a1508b7a04 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -21,65 +21,65 @@ class BlockedLog { - + /** * Id of the log * @var int */ public $id; - + /** * Unique fingerprint of the log * @var string */ public $signature = ''; - + /** * Unique fingerprint of the line log content * @var string */ public $signature_line = ''; - + public $amounts = null; - + /** * trigger action * @var string */ public $action = ''; - + /** * Object element * @var string */ public $element = ''; - + /** * Object id * @var int */ public $fk_object = 0; - + /** * Log certified by remote authority or not * @var boolean */ public $certified = false; - + /** * Author * @var int */ public $fk_user = 0; - + public $date_object = 0; - + public $ref_object = ''; - + public $object_data = null; - + public $error = 0; - + /** * Constructor * @@ -88,7 +88,7 @@ class BlockedLog public function __construct(DoliDB $db) { $this->db = $db; - + } /** @@ -96,10 +96,10 @@ class BlockedLog */ public function getObjectLink() { global $langs; - + if($this->element === 'facture') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - + $object = new Facture($this->db); if($object->fetch($this->fk_object)>0) { return $object->getNomUrl(1); @@ -110,7 +110,7 @@ class BlockedLog } else if($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - + $object = new Paiement($this->db); if($object->fetch($this->fk_object)>0) { return $object->getNomUrl(1); @@ -119,61 +119,61 @@ class BlockedLog $this->error++; } } - + return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object); - + } - + /** * try to retrieve user author */ public function getUser() { global $langs, $cachedUser; - + if(empty($cachedUser))$cachedUser=array(); - + if(empty($cachedUser[$this->fk_user])) { $u=new User($this->db); if($u->fetch($this->fk_user)>0) { $cachedUser[$this->fk_user] = $u; } } - + if(!empty($cachedUser[$this->fk_user])) { return $cachedUser[$this->fk_user]->getNomUrl(1); } - + return $langs->trans('ImpossibleToRetrieveUser', $this->fk_user); } - + /** * populate log by object * * @param payment|facture $object object to store */ public function setObjectData(&$object) { - + if($object->element=='payment') { $this->date_object = $object->datepaye; } else{ $this->date_object = $object->date; } - + $this->ref_object = $object->ref; $this->element = $object->element; $this->fk_object = $object->id; - + $this->object_data=new stdClass(); - + if($this->element === 'facture') { if(empty($object->thirdparty))$object->fetch_thirdparty(); $this->object_data->thirdparty = new stdClass(); - + foreach($object->thirdparty as $key=>$value) { if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value; } - + $this->object_data->total_ht = (double) $object->total_ht; $this->object_data->total_tva = (double) $object->total_tva; $this->object_data->total_ttc = (double) $object->total_ttc; @@ -181,17 +181,17 @@ class BlockedLog $this->object_data->total_localtax2= (double) $object->total_localtax2; $this->object_data->note_public = (double) $object->note_public; $this->object_data->note_private= (double) $object->note_private; - + } elseif($this->element==='payment'){ - + $this->object_data->amounts = $object->amounts; - + } - - + + } - + /** * Get object from database * @@ -199,50 +199,50 @@ class BlockedLog * @return int >0 if OK, <0 if KO, 0 if not found */ public function fetch($id) { - + global $langs; - + dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); - + if (empty($id)) { $this->error='BadParameter'; return -1; } - + $langs->load("blockedlog"); - + $sql = "SELECT b.rowid, b.signature, b.amounts, b.action, b.element, b.fk_object, b.certified, b.tms, b.fk_user, b.date_object, b.ref_object, b.object_data"; $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; if ($id) $sql.= " WHERE b.rowid = ". $id; - + $resql=$this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - + $this->id = $obj->rowid; $this->ref = $obj->rowid; - + $this->signature = $obj->signature; $this->amounts = (double) $obj->amounts; $this->action = $obj->action; $this->element = $obj->element; - + $this->fk_object = trim($obj->fk_object); $this->date_object = $this->db->jdate($obj->date_object); $this->ref_object = $obj->ref_object; - + $this->certified = ($obj->certified == 1); - + $this->fk_user = $obj->fk_user; - + $this->tms = $this->db->jdate($obj->tms); - + $this->object_data = unserialize($obj->object_data); - + return 1; } else @@ -256,24 +256,24 @@ class BlockedLog $this->error=$this->db->error(); return -1; } - + } - + /** * Set block certified by authority * * @return boolean */ public function setCertified() { - + $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id); if($res===false) return false; - + return true; - - + + } - + /** * Create blocked log in database. * @@ -281,31 +281,31 @@ class BlockedLog * @return int <0 if KO, >0 if OK */ public function create($user) { - + global $conf,$langs,$hookmanager; - + $langs->load('blockedlog'); - + $error=0; - + dol_syslog(get_class($this).'::create', LOG_DEBUG); - + $this->getSignatureRecursive(); - - + + if (is_null($this->amounts)) { $this->error=$langs->trans("BlockLogNeedAmountsValue"); dol_syslog($this->error, LOG_WARNING); return -1; } - + if(empty($this->element)) { $this->error=$langs->trans("BlockLogNeedElement"); dol_syslog($this->error, LOG_WARNING); return -2; } - + if(empty($this->action)) { $this->error=$langs->trans("BlockLogNeedAction"); dol_syslog($this->error, LOG_WARNING); @@ -313,9 +313,9 @@ class BlockedLog } $this->fk_user = $user->id; - + $this->db->begin(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; $sql.= "action,"; $sql.= " amounts,"; @@ -343,18 +343,18 @@ class BlockedLog $sql.= "".$user->id.","; $sql.= $conf->entity; $sql.= ")"; - + $res = $this->db->query($sql); if ($res) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog"); - + if ($id > 0) { $this->id = $id; - + $this->db->commit(); - + return $this->id; } else @@ -369,9 +369,9 @@ class BlockedLog $this->db->rollback(); return -1; } - + } - + /** * return crypted value. * @@ -379,56 +379,56 @@ class BlockedLog * @return string crypted string */ private function crypt($value) { - + return hash('sha256',$value); - + } - + /** * check if current signature still correct compare to the chain * - * @return boolean + * @return boolean */ public function checkSignature() { - + $signature_to_test = $this->signature; - + $this->getSignatureRecursive(); - + $res = ($signature_to_test === $this->signature); - + if(!$res) { $this->error++; } - + return $res; } - + /** - * set current signatures + * set current signatures */ private function getSignatureRecursive(){ - + $this->signature_line = $this->crypt( $this->action . $this->getSignature() . $this->amounts . print_r($this->object_data, true) ); /*if($this->signature=='d6320580a02c1ab67fcc0a6d49d453c7d96dda0148901736f7f55725bfe1b900' || $this->signature=='ea65d435ff12ca929936a406aa9d707d99fb334c127878d256b602a5541bbbc9') { var_dump($this->signature_line,$this->action ,$this->getSignature() , $this->amounts , $this->object_data); }*/ $this->signature = $this->signature_line; - + $logs = $this->getLog('all', 0, 0, 1) ; if($logs!==false) { foreach($logs as &$b) { - + if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature - + $b->getCurrentValue(); // on récupère la valeur actuelle en base de l'élément enregistré - + $this->signature = $this->crypt($this->signature. $this->action . $b->signature . $b->amounts); } } - + } - + /** * return log object for a element. * @@ -439,110 +439,110 @@ class BlockedLog * @return array array of object log */ public function getLog($element, $fk_object, $limit = 0, $order = -1) { - global $conf,$cachedlogs ; - + global $conf,$cachedlogs ; + /* $cachedlogs allow fastest search */ if(empty($cachedlogs)) $cachedlogs=array(); - - + + if($element=='all') { - + $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity; - + } else if($element=='not_certified') { $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 0"; - + } else if($element=='just_certified') { $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 1"; - + } else{ $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE element='".$element."' AND fk_object=".(int) $fk_object; - + } - + $sql.=($order<0 ? ' ORDER BY rowid DESC ' : ' ORDER BY rowid ASC '); - + if($limit > 0 )$sql.=' LIMIT '.$limit; - + $res = $this->db->query($sql); - + if($res) { - + $results=array(); - + while($obj = $this->db->fetch_object($res)) { - + if(!isset($cachedlogs[$obj->rowid])) { $b=new BlockedLog($this->db); $b->fetch($obj->rowid); - + $cachedlogs[$obj->rowid] = $b; } - + $results[] = $cachedlogs[$obj->rowid]; - + } - + return $results; } else{ return false; } } - + /** * set amounts of log from current element value in order to compare signature. */ private function getCurrentValue() { - + if($this->element === 'payment') { $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object; - + $res = $this->db->query($sql); - + if($res && $obj = $this->db->fetch_object($res)) { $this->amounts = (double) $obj->amount; } } elseif($this->element === 'facture') { $sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object; - + $res = $this->db->query($sql); if($res && $obj = $this->db->fetch_object($res)) { $this->amounts = (double) $obj->total_ttc; } } - + } - + /** - * return and set the entity signature included into line signature + * Return and set the entity signature included into line signature * * @return string current entity signature */ public function getSignature() { global $db,$conf,$mysoc; - - if(empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint - + + if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint + require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - + $fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000)); - + dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine',0,'Numeric Unique Fingerprint', $conf->entity); - - $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT= $fingerprint; + + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint; } - + return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; } - + } diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php index a7fca40d116..cffac7cbff9 100644 --- a/htdocs/blockedlog/lib/blockedlog.lib.php +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -32,17 +32,17 @@ function blockedlogadmin_prepare_head() $h = 0; $head = array(); - + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/blockedlog.php"; - $head[$h][1] = $langs->trans("BlockedLog"); + $head[$h][1] = $langs->trans("Setup"); $head[$h][2] = 'blockedlog'; $h++; - + $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/fingerprints.php"; $head[$h][1] = $langs->trans("Fingerprints"); $head[$h][2] = 'fingerprints'; $h++; - + $object=new stdClass(); // Show more tabs from modules diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ce16d6b9931..223acb91fb3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4247,37 +4247,6 @@ else if ($id > 0 || ! empty($ref)) $delallowed = $user->rights->facture->supprimer; print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - - if(!empty($conf->blockedlog->enabled) && $object->statut>0) { - ?> - - numoffiles; // Show links to link elements diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index b149471cd20..f3f3be971b5 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -43,15 +43,15 @@ class modBlockedLog extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "base"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); - $this->description = "Enable a log on some business events into a reserved log. This module may be mandatory for some countries."; + $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries."; $this->version = 'development'; // 'development', 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; + $this->special = 2; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 004c4eecd78..6759d18ba5d 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -50,9 +50,9 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers if (empty($conf->blockedlog->enabled)) { return 0; } - - if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' - || $action === 'BILL_SENTBYMAIL' || $action === 'DOWNLOAD_BILL' || $action === 'PREVIEW_BILL') { + + if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' + || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { $amounts= (double) $object->total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { @@ -62,8 +62,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts+= price2num($amount); } } - - + + } else if(strpos($action,'PAYMENT')!==false) { $amounts= (double) $object->amount; @@ -71,25 +71,25 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers else { return 0; // not implemented action log } - + $b=new BlockedLog($this->db); $b->action = $action; $b->amounts= $amounts; $b->setObjectData($object); - + $res = $b->create($user); - + if($res<0) { setEventMessage($b->error,'errors'); - + return -1; } else { - + return 1; } - - + + } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 695373e22b5..1aa79c2dced 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -467,7 +467,7 @@ Module30Desc=Invoice and credit note management for customers. Invoice managemen Module40Name=Suppliers Module40Desc=Supplier management and buying (orders and invoices) Module42Name=Logs -Module42Desc=Logging facilities (file, syslog, ...) +Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. For legal purpose, see instead module 'Non Reversible Logs'. Module49Name=Editors Module49Desc=Editor management Module50Name=Products @@ -565,6 +565,8 @@ Module2900Name=GeoIPMaxmind Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into users / third parties / contacts / members cards +Module3200Name=Non Reversible Logs +Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table that can be then exported. This module may be mandatory for some countries. Module4000Name=HRM Module4000Desc=Human resources management (mangement of department, employee contracts and feelings) Module5000Name=Multi-company diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index fcad52508bd..7129b65257d 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -1,12 +1,14 @@ +BlockedLog=Non Reversible Logs Field=Field -BlockedLogDesc=This module store event for invoice and payments as block chain -FingerprintsDesc=All fingerprints stored -EntityKey=Entity Key -ShowAllFingerPrintsMightBeTooLong=Show all fingerprints (might be long) -ShowAllFingerPrintsErrorsMightBeTooLong=Show all fingerprints with error (might be long) +BlockedLogDesc=This module store event for invoice and payments into a block chain +Fingerprints=Archived events and fingerprints +FingerprintsDesc=Archived business events and fingerprints +CompanyInitialKey=Company initial key +ShowAllFingerPrintsMightBeTooLong=Show all archived logs (might be long) +ShowAllFingerPrintsErrorsMightBeTooLong=Show all archive logs with error (might be long) DownloadBlockChain=Download fingerprints -KoCheckFingerprintValidity=Fingerprint is not valid -OkCheckFingerprintValidity=Fingerprint is valid +KoCheckFingerprintValidity=Archived log is not valid. It means someone (a hacker ?) has modified some datas of this archived log after it was recorded, or has erased the previous archived record (check that line with previous # exists). +OkCheckFingerprintValidity=Archived log is valid. It means all data on this line were not modified and record follow the previous one. AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority ShowDetails=Show stored details @@ -18,6 +20,7 @@ logBILL_VALIDATE=Customer bill set valid from draft logBILL_SENTBYMAIL=Customer bill send by mail BlockedlogInfoDialog=Log Details Fingerprint=Fingerprint -DownloadLogCSV=Download fingerprints CSV -logPREVIEW_BILL=Preview of a validated customer bill in order to print or download -logDOWNLOAD_BILL=Download of a validated customer bill in order to print or send \ No newline at end of file +DownloadLogCSV=Download archive logs (CSV) +logDOC_PREVIEW=Preview of a validated document in order to print or download +logDOC_DOWNLOAD=Download of a validated document in order to print or send +DataOfArchivedEvent=Full datas of archived event \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6b75b957590..33b155bb64c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1891,7 +1891,7 @@ if (! function_exists("llxFooter")) */ function llxFooter($comment='',$zone='private') { - global $conf, $langs, $user; + global $conf, $langs, $user, $object; global $delayedhtmlcontent; // Global html output events ($mesgs, $errors, $warnings) @@ -2026,6 +2026,40 @@ if (! function_exists("llxFooter")) '; } + // Wrapper to add log when clicking on download or preview + if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0) + { + if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture' + { + print "\n\n"; + ?> + + \n"; print ''."\n"; From e813fd2dfa69d3ce67ab5aec2af6df34970e3c16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 12:57:30 +0200 Subject: [PATCH 20/27] Fix missing key import_key and extraparams --- htdocs/adherents/class/api_memberstypes.class.php | 1 - htdocs/comm/action/class/api_agendaevents.class.php | 1 - htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 7 +++++-- htdocs/install/mysql/tables/llx_actioncomm.sql | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 9457b910c5d..ff8064d80fb 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -274,7 +274,6 @@ class MembersTypes extends DolibarrApi unset($object->cotisation); unset($object->libelle); - unset($object->import_key); unset($object->array_options); unset($object->linkedObjectsIds); unset($object->context); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index a607998cfa8..4edd656da53 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -318,7 +318,6 @@ class AgendaEvents extends DolibarrApi unset($object->usermod); unset($object->libelle); - unset($object->import_key); unset($object->array_options); unset($object->context); unset($object->canvas); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index a66ef47fba6..5e46393768a 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -82,14 +82,17 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent ALTER TABLE llx_ecm_files ADD INDEX idx_ecm_files_label (label); +ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_soc; + + ALTER TABLE llx_holiday ADD COLUMN import_key varchar(14); ALTER TABLE llx_holiday ADD COLUMN extraparams varchar(255); -ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_soc; - ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14); ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255); +ALTER TABLE llx_actioncomm ADD COLUMN import_key varchar(14); +ALTER TABLE llx_actioncomm ADD COLUMN extraparams varchar(255); ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255); diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 4849aacb690..48b73bcaa65 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -69,8 +69,10 @@ create table llx_actioncomm recurdateend datetime, -- no more recurring event after this date fk_element integer DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...) - elementtype varchar(255) DEFAULT NULL -- For link to an element (proposal, invoice, order, ...) + elementtype varchar(255) DEFAULT NULL, -- For link to an element (proposal, invoice, order, ...) + import_key varchar(14), + extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; From b228fe6a2ae6aa5ac265fcb1aca90c5247c2d4d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Jun 2017 16:06:20 +0200 Subject: [PATCH 21/27] Fix auto focus on module page --- htdocs/admin/modules.php | 4 +++- htdocs/core/lib/functions.lib.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8bea1c6dcb7..5d5886b5415 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -430,6 +430,8 @@ print "
\n"; if ($mode == 'common') { + dol_set_focus('#search_keyword'); + print '
'; if ($optioncss != '') print ''; print ''; @@ -441,7 +443,7 @@ if ($mode == 'common') $moreforfilter = ''; $moreforfilter.='
'; - $moreforfilter.= $langs->trans('Keyword') . ': '; + $moreforfilter.= $langs->trans('Keyword') . ': '; $moreforfilter.= '
'; $moreforfilter.='
'; $moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a582263185b..fd3b0012165 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6089,12 +6089,12 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') /** * Set focus onto field with selector * - * @param string $selector Selector ('#id') + * @param string $selector Selector ('#id') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char. * @return string HTML code to set focus */ function dol_set_focus($selector) { - print ''."\n"; + print "\n".''."\n"; print ''."\n"; } From 1d91ce90d33b3909c6a5e968ad0152c2b6b05735 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 00:13:09 +0200 Subject: [PATCH 22/27] FIX image from medias directory into PDF free text --- htdocs/admin/chequereceipts.php | 2 +- htdocs/admin/commande.php | 2 +- htdocs/admin/contract.php | 2 +- htdocs/admin/expedition.php | 2 +- htdocs/admin/expensereport.php | 2 +- htdocs/admin/facture.php | 2 +- htdocs/admin/fichinter.php | 2 +- htdocs/admin/livraison.php | 2 +- htdocs/admin/propal.php | 2 +- htdocs/admin/supplier_invoice.php | 2 +- htdocs/admin/supplier_order.php | 2 +- htdocs/admin/supplier_proposal.php | 2 +- htdocs/core/lib/pdf.lib.php | 7 +++++++ 13 files changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index f88dfc6f5a6..3d3db2451d2 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -274,7 +274,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index f4104e2007f..e9ad5ab6ed6 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -559,7 +559,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index e2f865f61f6..427b3a531c4 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -493,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 12d0b7951d5..af932b94b45 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -493,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print "\n"; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 24aaeede5b4..cd14d472057 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -497,7 +497,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 57ff2321a12..85ee8c09934 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -731,7 +731,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 68d2d87800a..926a3651362 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -525,7 +525,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 0136f6cc9d9..fe41afabfb8 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -474,7 +474,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 8acbf19f939..2f90145f3cc 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -564,7 +564,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 17501cdb4f9..6d65af336b9 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -487,7 +487,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 13499af551a..21b3de68835 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -553,7 +553,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 8c52ee83dda..4e7efa4d922 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -520,7 +520,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_details'); + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 9220725dc8e..a9fb8e52734 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -861,6 +861,13 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $substitutionarray['__FROM_EMAIL__']=$fromcompany->email; complete_substitutions_array($substitutionarray, $outputlangs, $object); $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray, $outputlangs); + + // Make a change into HTML code to allow to include images from medias directory. + // + // become + // + $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); + $line.=$outputlangs->convToOutputCharset($newfreetext); } From 5b7a8e9c90f82b4abe7c0a4dff84603b16f5884f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 10:17:36 +0200 Subject: [PATCH 23/27] Fix missing signature when sending email from user card --- htdocs/commande/card.php | 25 ++++++++----- htdocs/core/class/html.formmail.class.php | 6 ++-- htdocs/langs/en_US/other.lang | 1 + htdocs/user/card.php | 43 ++++------------------- 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 83135a8c0f5..f837119730c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2621,6 +2621,19 @@ if ($action == 'create' && $user->rights->commande->creer) $outputlangs->load('commercial'); } + // Show email form + + // By default if $action=='presend' + $titreform='SendOrderByMail'; + $topicmail=''; + if (empty($object->ref_client)) { + $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); + } else if (! empty($object->ref_client)) { + $topicmail = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); + } + $action='send'; + $modelmail='order_send'; + // Build document if it not exists if (! $file || ! is_readable($file)) { $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2635,7 +2648,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '
'; print '
'; print '
'; - print load_fiche_titre($langs->trans('SendOrderByMail')); + print load_fiche_titre($langs->trans($titreform)); dol_fiche_head(''); @@ -2662,11 +2675,7 @@ if ($action == 'create' && $user->rights->commande->creer) $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; $formmail->withtocc = $liste; $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; - if (empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__'); - } else if (! empty($object->ref_client)) { - $formmail->withtopic = $outputlangs->trans('SendOrderRef', '__ORDERREF__ (__REFCLIENT__)'); - } + $formmail->withtopic = $topicmail; $formmail->withfile = 2; $formmail->withbody = 1; $formmail->withdeliveryreceipt = 1; @@ -2696,8 +2705,8 @@ if ($action == 'create' && $user->rights->commande->creer) } // Tableau des parametres complementaires - $formmail->param['action'] = 'send'; - $formmail->param['models'] = 'order_send'; + $formmail->param['action'] = $action; + $formmail->param['models'] = $modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['orderid'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 860d3fcfb1c..d59ac6c25af 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -288,14 +288,15 @@ class FormMail extends Form $outputlangs->load('other'); } - // Get message template + // Get message template for $this->param["models"] into c_email_templates $model_id=0; if (array_key_exists('models_id',$this->param)) { $model_id=$this->param["models_id"]; } $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); - //var_dump($arraydefaultmessage); + //var_dump($this->param["models"]); + //var_dump($arraydefaultmessage); $out.= "\n".'
'."\n"; if ($this->withform == 1) @@ -876,6 +877,7 @@ class FormMail extends Form elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } + elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } $ret['label']='default'; $ret['topic']=''; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a14bfffffb6..b151614ce3c 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -81,6 +81,7 @@ PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find her PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __SHIPPINGREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __FICHINTERREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ PredefinedMailContentThirdparty=__CONTACTCIVNAME__\n\n__PERSONALIZED__\n\n__SIGNATURE__ +PredefinedMailContentUser=aa__PERSONALIZED__\n\n__SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 089820da442..a2938a89712 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1659,13 +1659,11 @@ else } if ($action == 'presend') { - /* - * Affiche formulaire mail - */ + // Show email form // By default if $action=='presend' $titreform='SendMail'; - $topicmail=''; + $topicmail=1; $action='send'; $modelmail='user'; @@ -1680,9 +1678,8 @@ else $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; - - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->default_lang; + //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + // $newlang = $object->thirdparty->default_lang; // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; @@ -1701,7 +1698,7 @@ else $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id); } $formmail->withfrom=1; - $formmail->withtopic=1; + $formmail->withtopic=$topicmail; $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$object->email; $formmail->withtofree=1; $formmail->withtocc=1; @@ -1711,37 +1708,9 @@ else $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions - //$formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object); $formmail->substit['__LASTNAME__']=$object->lastname; $formmail->substit['__FIRSTNAME__']=$object->firstname; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - - //Find the good contact adress - /* - $custcontact=''; - $contactarr=array(); - $contactarr=$object->liste_contact(-1,'external'); - - if (is_array($contactarr) && count($contactarr)>0) - { - foreach($contactarr as $contact) - { - if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) { - - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - - $contactstatic=new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact=$contactstatic->getFullName($langs,1); - } - } - - if (!empty($custcontact)) { - $formmail->substit['__CONTACTCIVNAME__']=$custcontact; - } - }*/ - // Tableau des parametres complementaires du post $formmail->param['action']=$action; From bebe7baa80990fa25f37b25c5ac8620cbf90ea6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 10:44:08 +0200 Subject: [PATCH 24/27] Fix images into medias not reabable into send emails --- htdocs/core/actions_sendmails.inc.php | 31 ++++++++++++++++++--------- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/langs/en_US/errors.lang | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index dded23e6cbf..7bb3e8aec49 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -31,7 +31,7 @@ /* * Add file in email form -*/ + */ if (GETPOST('addfile')) { $trackid = GETPOST('trackid','aZ09'); @@ -137,7 +137,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $sendtosocid=$possibleaccounts[1]['id']; $result=$object->fetch($sendtosocid); - + setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); } else @@ -229,7 +229,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (dol_strlen($sendto)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $langs->load("commercial"); @@ -254,11 +259,17 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $message = $_POST['message']; - + + // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. + // + // become + // + $message=preg_replace('/()/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); + $sendtobcc= GETPOST('sendtoccc'); - if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); + if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); + if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); + if ($mode == 'emailfrominvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); if ($mode == 'emailfromsupplierproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); if ($mode == 'emailfromsupplierorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); if ($mode == 'emailfromsupplierinvoice') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); @@ -371,7 +382,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (is_object($object)) { if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically - + $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array. $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) @@ -392,7 +403,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } - + if ($error) { dol_print_error($db); @@ -403,7 +414,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) + if ($conf->dolimail->enabled) { header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); exit; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a9fb8e52734..3c771220c70 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -865,7 +865,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass // Make a change into HTML code to allow to include images from medias directory. // // become - // + // $newfreetext=preg_replace('/()/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext); $line.=$outputlangs->convToOutputCharset($newfreetext); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0f57a23d23c..ac982973ef3 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -44,6 +44,7 @@ ErrorFailedToWriteInDir=Failed to write in directory %s ErrorFoundBadEmailInFile=Found incorrect email syntax for %s lines in file (example line %s with email=%s) ErrorUserCannotBeDelete=User cannot be deleted. May be it is associated to Dolibarr entities. ErrorFieldsRequired=Some required fields were not filled. +ErrorSubjectIsRequired=The email topic is required ErrorFailedToCreateDir=Failed to create a directory. Check that Web server user has permissions to write into Dolibarr documents directory. If parameter safe_mode is enabled on this PHP, check that Dolibarr php files owns to web server user (or group). ErrorNoMailDefinedForThisUser=No mail defined for this user ErrorFeatureNeedJavascript=This feature need javascript to be activated to work. Change this in setup - display. From 7c41c9a3e4aedb97742ab505afe957281e9527e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 11:43:00 +0200 Subject: [PATCH 25/27] Fix activation of dependency for a dedicated country. BlockedLog depends now on CashDesk only. --- htdocs/admin/modules.php | 8 +++-- htdocs/core/lib/admin.lib.php | 20 ++++++------ htdocs/core/modules/modBlockedLog.class.php | 6 ++-- htdocs/core/modules/modCashDesk.class.php | 6 ++-- htdocs/core/modules/modFacture.class.php | 31 +++++++++---------- htdocs/langs/en_US/admin.lang | 6 ++-- htdocs/langs/en_US/main.lang | 3 +- .../core/modules/modMyModule.class.php | 2 ++ htdocs/theme/md/style.css.php | 1 - 9 files changed, 45 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5d5886b5415..d3221f40505 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -80,7 +80,7 @@ $urldolibarrmodules='https://www.dolistore.com/'; * Actions */ -if (GETPOST('buttonreset')) +if (GETPOST('buttonreset','alpha')) { $search_keyword=''; $search_status=''; @@ -738,13 +738,17 @@ if ($mode == 'common') print ''."\n"; foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) { - if (! empty($modules[$keymodule]->const_name)) // If module that request warning is on + $keymodulelowercase=strtolower(preg_replace('/^mod/','',$keymodule)); + if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on { foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) { if ($keycountry == 'always' || $keycountry == $mysoc->country_code) { $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); + $warningmessage .= ($warningmessage?"\n":"").($warningmessage?"\n":"").$langs->trans("Module").' : '.$objMod->getName(); + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("Publisher").' : '.$objMod->editor_name; + if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName(); } } } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index ba5f099365c..e90f006ac7e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -756,7 +756,7 @@ function purgeSessions($mysessionid) */ function activateModule($value,$withdeps=1) { - global $db, $modules, $langs, $conf; + global $db, $modules, $langs, $conf, $mysoc; // Check parameters if (empty($value)) { @@ -813,7 +813,7 @@ function activateModule($value,$withdeps=1) } $result=$objMod->init(); // Enable module - if ($result <= 0) + if ($result <= 0) { $ret['errors'][]=$objMod->error; } @@ -848,19 +848,19 @@ function activateModule($value,$withdeps=1) break; } } - + if ($activate) { $ret['nbmodules']+=$resarray['nbmodules']; $ret['nbperms']+=$resarray['nbperms']; } - else + else { $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $modulestring); } } } - + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) { // Desactivation des modules qui entrent en conflit @@ -879,12 +879,12 @@ function activateModule($value,$withdeps=1) } } - if (! count($ret['errors'])) + if (! count($ret['errors'])) { $ret['nbmodules']++; $ret['nbperms']+=count($objMod->rights); } - + return $ret; } @@ -1221,7 +1221,7 @@ function form_constantes($tableau, $strictw3c=0, $helptext='') if ($result) { $obj = $db->fetch_object($result); // Take first result of select - + // For avoid warning in strict mode if (empty($obj)) { @@ -1360,7 +1360,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); - + if ($i > 0) $text.=', '; else $text.=' '; $i++; @@ -1391,7 +1391,7 @@ function addDocumentModel($name, $type, $label='', $description='') $sql.= ($label?"'".$db->escape($label)."'":'null').", "; $sql.= (! empty($description)?"'".$db->escape($description)."'":"null"); $sql.= ")"; - + dol_syslog("admin.lib::addDocumentModel", LOG_DEBUG); $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index f3f3be971b5..3125627c007 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -65,9 +65,9 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- $this->hidden = false; // A condition to disable module - $this->depends = array('modFacture'); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array(); // Constants diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ec8764c9017..e5ba473c1c7 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -65,11 +65,13 @@ class modCashDesk extends DolibarrModules $this->config_page_url = array("cashdesk.php@cashdesk"); // Dependencies - $this->depends = array("modBanque","modFacture","modProduct"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(4,1); // Minimum version of PHP required by module $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module $this->langfiles = array("cashdesk"); + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') // Constants $this->const = array(); diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 3af85a1944d..40e2a03d161 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -64,14 +64,13 @@ class modFacture extends DolibarrModules $this->dirs = array("/facture/temp"); // Dependencies - $this->depends = array('always'=>"modSociete", 'FR'=>'modBlockedLog'); + $this->depends = array('always'=>"modSociete"); $this->requiredby = array("modComptabilite","modAccounting"); $this->conflictwith = array(); $this->langfiles = array("bills","companies","compta","products"); - $this->warnings_activation = array('FR'=>'WarningNoteModuleInvoiceForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') - $this->warnings_activation = array(); - $this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') - + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') + // Config pages $this->config_page_url = array("facture.php"); @@ -99,7 +98,7 @@ class modFacture extends DolibarrModules $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "__(Draft)__"; @@ -107,7 +106,7 @@ class modFacture extends DolibarrModules $this->const[$r][4] = 0; $r++;*/ - + // Boxes //$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php')); $this->boxes = array( @@ -116,16 +115,16 @@ class modFacture extends DolibarrModules 2=>array('file'=>'box_graph_invoices_permonth.php','enabledbydefaulton'=>'Home') ); - // Cronjobs + // Cronjobs $this->cronjobs = array( - 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), + 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) - ); - // List of cron jobs entries to add - // Example: + ); + // List of cron jobs entries to add + // Example: // $this->cronjobs=array( - // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600) // ); // Permissions @@ -206,8 +205,8 @@ class modFacture extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=1; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1aa79c2dced..0ba5ab270bc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -104,7 +104,7 @@ MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (empty for a top menu) DetailPosition=Sort number to define menu position AllMenus=All -NotConfigured=Module not configured +NotConfigured=Module/Application not configured Active=Active SetupShort=Setup OtherOptions=Other options @@ -114,7 +114,6 @@ CurrentValueSeparatorThousand=Thousand separator Destination=Destination IdModule=Module ID IdPermissions=Permissions ID -Modules=Modules LanguageBrowserParameter=Parameter %s LocalisationDolibarrParameters=Localisation parameters ClientTZ=Client Time Zone (user) @@ -1700,7 +1699,8 @@ UserHasNoPermissions=This user has no permission defined TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")
Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)
Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days") BaseCurrency=Reference currency of the company (go into setup of company to change this) WarningNoteModuleInvoiceForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016). -WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the editor of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. +WarningNoteModulePOSForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016) because module Non Reversible Logs is automatically activated. +WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the publisher of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8ea14fdb305..a35342f2af9 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -366,7 +366,8 @@ VATRate=Tax Rate Average=Average Sum=Sum Delta=Delta -Module=Module +Module=Module/Application +Modules=Modules/Applications Option=Option List=List FullList=Full list diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index dc98c327cb3..60889bdf279 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -114,6 +114,8 @@ class modMyModule extends DolibarrModules $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->langfiles = array("mymodule@mymodule"); + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5fbd8455919..e96fa032538 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2528,7 +2528,6 @@ div.pagination li.noborder a:hover { div.pagination li a, div.pagination li span { background-color: #fff; - border: 1px solid #ddd; } div.pagination li:first-child a, div.pagination li:first-child span { From a4f34539ea92cf634c49a98904c6aa92eb0015b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 11:46:45 +0200 Subject: [PATCH 26/27] Fix translation --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0ba5ab270bc..e2b5825f14f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -466,7 +466,7 @@ Module30Desc=Invoice and credit note management for customers. Invoice managemen Module40Name=Suppliers Module40Desc=Supplier management and buying (orders and invoices) Module42Name=Logs -Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. For legal purpose, see instead module 'Non Reversible Logs'. +Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. Module49Name=Editors Module49Desc=Editor management Module50Name=Products @@ -565,7 +565,7 @@ Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into users / third parties / contacts / members cards Module3200Name=Non Reversible Logs -Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table that can be then exported. This module may be mandatory for some countries. +Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table of chained event that can be then read and exported. This module may be mandatory for some countries. Module4000Name=HRM Module4000Desc=Human resources management (mangement of department, employee contracts and feelings) Module5000Name=Multi-company From 8a1de52f3c5b80c10c290c6028e0cc61cdf003f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Jun 2017 12:00:33 +0200 Subject: [PATCH 27/27] Fix translation --- htdocs/admin/index.php | 6 +++--- htdocs/langs/en_US/admin.lang | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index a1ac45244e1..9ac33f1cc3d 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -70,13 +70,13 @@ if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) print $langs->trans("SetupDescription1").' '; print $langs->trans("AreaForAdminOnly").' '; -print $langs->trans("SetupDescription2")."

"; +print $langs->trans("SetupDescription2", $langs->trans("MenuCompanySetup"), $langs->trans("Modules"))."

"; print '
'; // Show info setup company if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; -print img_picto('','puce').' '.$langs->trans("SetupDescription3",DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit')); +print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->trans("Setup"), $langs->trans("MenuCompanySetup")); if (! empty($setupcompanynotcomplete)) { $langs->load("errors"); @@ -88,7 +88,7 @@ print '
'; print '
'; // Show info setup module -print img_picto('','puce').' '.$langs->trans("SetupDescription4",DOL_URL_ROOT.'/admin/modules.php?mainmenu=home'); +print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->trans("Setup"), $langs->trans("Modules")); if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { $langs->load("errors"); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e2b5825f14f..23b207b4fea 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -190,7 +190,7 @@ FeatureAvailableOnlyOnStable=Feature only available on official stable versions Rights=Permissions BoxesDesc=Widgets are components showing some information that you can add to personalize some pages. You can choose between showing the widget or not by selecting target page and clicking 'Activate', or by clicking the dustbin to disable it. OnlyActiveElementsAreShown=Only elements from enabled modules are shown. -ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after enabling module. Click on button on/off to enable an application/module. +ModulesDesc=Dolibarr modules define which application/feature is enabled in software. Some application/modules require permissions you must grant to users, after activating it. Click on button on/off to enable a module/application. ModulesMarketPlaceDesc=You can find more modules to download on external websites on the Internet... ModulesDeployDesc=If permissions on your file system allows it, you can use this tool to deploy an external module. The module wil then be visible on the tab %s. ModulesMarketPlaces=Find external modules... @@ -270,7 +270,7 @@ FeatureNotAvailableOnLinux=Feature not available on Unix like systems. Test your SubmitTranslation=If translation for this language is not complete or you find errors, you can correct this by editing files into directory langs/%s and submit your change to www.transifex.com/dolibarr-association/dolibarr/ SubmitTranslationENUS=If translation for this language is not complete or you find errors, you can correct this by editing files into directory langs/%s and submit modified files on dolibarr.org/forum or for developers on github.com/Dolibarr/dolibarr. ModuleSetup=Module setup -ModulesSetup=Modules setup +ModulesSetup=Modules/Application setup ModuleFamilyBase=System ModuleFamilyCrm=Customer Relation Management (CRM) ModuleFamilySrm=Supplier Relation Management (SRM) @@ -997,9 +997,9 @@ Delays_MAIN_DELAY_MEMBERS=Tolerance delay (in days) before alert on delayed memb Delays_MAIN_DELAY_CHEQUES_TO_DEPOSIT=Tolerance delay (in days) before alert for cheques deposit to do Delays_MAIN_DELAY_EXPENSEREPORTS=Tolerance delay (in days) before alert for expense reports to approve SetupDescription1=The setup area is for initial setup parameters before starting to use Dolibarr. -SetupDescription2=The two most important setup steps are the first two in the setup menu on the left: Company/Organisation setup page and Modules setup page: -SetupDescription3=Parameters in menu Setup -> Company/Organisation are required because submitted data are used on Dolibarr displays and to customize the default behaviour of the software (for country-related features for example). -SetupDescription4=Parameters in menu Setup -> Modules are required because Dolibarr is not a monolithic ERP/CRM but a collection of several modules, all more or less independent. New features will be added to menus for every module you'll enable. +SetupDescription2=The two mandatory setup steps are the first two in the setup menu on the left: %s setup page and %s setup page : +SetupDescription3=Parameters in menu %s -> %s are required because defined data are used on Dolibarr screens and to customize the default behavior of the software (for country-related features for example). +SetupDescription4=Parameters in menu %s -> %s are required because Dolibarr ERP/CRM is a collection of several modules/applications, all more or less independent. New features will be added to menus for every module you will activate. SetupDescription5=Other menu entries manage optional parameters. LogEvents=Security audit events Audit=Audit @@ -1015,7 +1015,7 @@ BrowserOS=Browser OS ListOfSecurityEvents=List of Dolibarr security events SecurityEventsPurged=Security events purged LogEventDesc=You can enable here the logging for Dolibarr security events. Administrators can then see its content via menu System tools - Audit. Warning, this feature can consume a large amount of data in database. -AreaForAdminOnly=Those features can be used by administrator users only. +AreaForAdminOnly=Setup parameters can be set by administrator users only. SystemInfoDesc=System information is miscellaneous technical information you get in read only mode and visible for administrators only. SystemAreaForAdminOnly=This area is available for administrator users only. None of the Dolibarr permissions can reduce this limit. CompanyFundationDesc=Edit on this page all known information of the company or foundation you need to manage (For this, click on "Modify" or "Save" button at bottom of page)