From c84f44a508d2a1a5b60c5468fe18c3340b506a19 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 1 May 2018 12:30:22 +0200 Subject: [PATCH 1/4] fix accountanty in multientity --- .../class/accountancycategory.class.php | 16 ++++++++++++---- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 13 +++++++++++-- .../mysql/tables/llx_accounting_journal.key.sql | 2 +- .../tables/llx_c_accounting_category.key.sql | 2 +- .../mysql/tables/llx_c_accounting_category.sql | 1 + 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 0a538f0a6ae..27254ef31d1 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -360,9 +360,11 @@ class AccountancyCategory // extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ public function display($id) { + global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = " . $id; + $sql .= " AND t.entity = " . $conf->entity; $this->lines_display = array(); @@ -400,13 +402,14 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " SELECT t.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = " . $id . ")"; + $sql .= " WHERE t.fk_accounting_category = " . $id . " AND t.entity = " . $conf->entity.")"; $sql .= " AND t.numero_compte IN ("; $sql .= " SELECT DISTINCT aa.account_number"; $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"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1)"; + $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = = " . $conf->entity . ")"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " ORDER BY t.numero_compte"; @@ -448,6 +451,7 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; @@ -492,6 +496,7 @@ class AccountancyCategory // extends CommonObject $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $this->db->begin(); @@ -581,7 +586,7 @@ class AccountancyCategory // extends CommonObject */ public function getCatsCpts() { - global $mysoc; + global $mysoc,$conf; $sql = ""; @@ -595,8 +600,10 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1"; + $sql .= " AND c.entity = " . $conf->entity; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " AND t.entity = " . $conf->entity; $sql .= " ORDER BY cat.position ASC"; $resql = $this->db->query($sql); @@ -685,7 +692,7 @@ class AccountancyCategory // extends CommonObject */ public function getCats($categorytype=-1) { - global $db, $langs, $user, $mysoc; + global $db, $langs, $user, $mysoc, $conf; if (empty($mysoc->country_id)) { dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); @@ -695,6 +702,7 @@ class AccountancyCategory // extends CommonObject $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1 "; + $sql .= " AND c.entity = " . $conf->entity; if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " ORDER BY c.position ASC"; diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 70cbaeb7e04..9fa2849b757 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -9,8 +9,8 @@ -- 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 drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 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_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; @@ -441,3 +441,12 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; + +ALTER TABLE llx_c_accounting_category ADD COLUMN entity integer NOT NULL DEFAULT 1 AFTER rowid; +-- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category +-- VPGSQL8.2 DROP INDEX uk_c_accounting_category +ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); +-- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal +-- VPGSQL8.2 DROP INDEX uk_accounting_journal_code +ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); + diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.key.sql b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql index e5083aa83d7..701c39e06a2 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql @@ -17,4 +17,4 @@ -- =========================================================================== -ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code); +ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); diff --git a/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql b/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql index 6b2d520a156..be927f6e761 100644 --- a/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql +++ b/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql @@ -17,5 +17,5 @@ -- Table with category for accounting account -- =================================================================== -ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code); +ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); diff --git a/htdocs/install/mysql/tables/llx_c_accounting_category.sql b/htdocs/install/mysql/tables/llx_c_accounting_category.sql index 253ff6aef46..9df9a9d6ab0 100644 --- a/htdocs/install/mysql/tables/llx_c_accounting_category.sql +++ b/htdocs/install/mysql/tables/llx_c_accounting_category.sql @@ -22,6 +22,7 @@ CREATE TABLE llx_c_accounting_category ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + entity integer NOT NULL DEFAULT 1, code varchar(16) NOT NULL, label varchar(255) NOT NULL, range_account varchar(255) NOT NULL, -- Comment From 12440e6a7e62087adb32a07b17abf9f64ac9f018 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 2 May 2018 11:30:35 +0200 Subject: [PATCH 2/4] Do not display multicurrency cols if currency of object is same as main currency --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 046097eec86..4c236324373 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3677,7 +3677,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3716,7 +3716,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index fdef8a03ed8..61818d4deb9 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -111,7 +111,7 @@ if ($nolinesbefore) { trans('VAT'); ?> trans('PriceUHT'); ?> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> trans('PriceUHTCurrency'); ?> @@ -345,7 +345,7 @@ else { "> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> "> @@ -462,7 +462,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index a6f5fef5310..d3dc9807c5a 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -53,7 +53,7 @@ $colspan = 3; // Col total ht + col edit + col delete if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc if (in_array($object->element,array('propal','supplier_proposal','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button if (empty($user->rights->margins->creer)) $colspan++; -if (!empty($conf->multicurrency->enabled)) $colspan+=2; +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; ?> @@ -148,7 +148,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled)) { + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index f48b0b917a1..b36159f9340 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -195,7 +195,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; subprice); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> multicurrency_subprice); ?> @@ -261,7 +261,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; trans('Option'); ?> total_ht); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> multicurrency_total_ht); ?> From 73c3529831ce3b4eabc38afaece66d3f5f12784d Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 2 May 2018 14:36:55 +0200 Subject: [PATCH 3/4] NEW : Display price HT on all commercial area boards --- htdocs/comm/index.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 48d989d0cdc..eab813653d6 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -349,7 +349,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'customer',16); print ''; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } $i++; $total += $obj->total_ttc; } @@ -432,7 +437,12 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'supplier',16); print ''; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } $i++; $total += $obj->total_ttc; } @@ -744,7 +754,12 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''; print dol_print_date($db->jdate($obj->dp),'day').''."\n"; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } print ''.$propalstatic->LibStatut($obj->fk_statut,3).''."\n"; print ''."\n"; $i++; @@ -843,7 +858,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; print ''; print dol_print_date($db->jdate($obj->dp),'day').''."\n"; - print ''.price($obj->total_ttc).''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''.price($obj->total_ht).''; + } + else { + print ''.price($obj->total_ttc).''; + } print ''.$orderstatic->LibStatut($obj->fk_statut,$obj->billed,3).''."\n"; print ''."\n"; $i++; From 739317a794eedeab00bea35ae2895b223351879e Mon Sep 17 00:00:00 2001 From: bafbes Date: Wed, 2 May 2018 08:10:58 +0100 Subject: [PATCH 4/4] New : option to show database name in upper help menu --- htdocs/main.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 72a7327a1a1..eaea0dc420c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1581,6 +1581,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if ($helpbaseurl && $helppage) { $text=''; + if(!empty($conf->global->MAIN_SHOWDATABASENAMEINHELPPAGESLINK)) { + $langs->load('admin'); + $appli .= '
' . $langs->trans("Database") . ': ' . $db->database_name; + } $title=$appli.'
'; $title.=$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage'); if ($mode == 'wiki') $title.=' - '.$langs->trans("PageWiki").' "'.dol_escape_htmltag(strtr($helppage,'_',' ')).'"';