From a4b152ff1b776b839841270ce19865f9bf5eb0ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Oct 2017 13:28:45 +0200 Subject: [PATCH 01/12] Fix get lines of contracts done in one request instead of 2 --- htdocs/contrat/class/api_contracts.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 124 +++---------------- 2 files changed, 16 insertions(+), 110 deletions(-) diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 7e92b8d6efe..69f1d541988 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -207,7 +207,7 @@ class Contracts extends DolibarrApi } /** - * Get lines of an contract + * Get lines of a contract * * @param int $id Id of contract * diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 5c350b9cb60..5ff8dd182bb 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -691,8 +691,8 @@ class Contrat extends CommonObject $sql.= " d.fk_user_ouverture,"; $sql.= " d.fk_user_cloture,"; $sql.= " d.fk_unit"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE d.fk_contrat = ".$this->id ." AND d.fk_product = p.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; + $sql.= " WHERE d.fk_contrat = ".$this->id; $sql.= " ORDER by d.rowid ASC"; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); @@ -728,7 +728,7 @@ class Contrat extends CommonObject $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->fk_product = $objp->fk_product; + $line->fk_product = (($objp->fk_product > 0)?$objp->fk_product:0); $line->info_bits = $objp->info_bits; $line->fk_fournprice = $objp->fk_fournprice; @@ -740,9 +740,17 @@ class Contrat extends CommonObject $line->fk_user_cloture = $objp->fk_user_cloture; $line->fk_unit = $objp->fk_unit; - $line->ref = $objp->product_ref; // deprecated - $line->label = $objp->product_label; // deprecated - $line->libelle = $objp->product_label; // deprecated + $line->ref = $objp->product_ref; // deprecated + if (empty($objp->fk_product)) + { + $line->label = ''; // deprecated + $line->libelle = $objp->description; // deprecated + } + else + { + $line->label = $objp->product_label; // deprecated + $line->libelle = $objp->product_label; // deprecated + } $line->product_ref = $objp->product_ref; // Ref product $line->product_desc = $objp->product_desc; // Description product $line->product_label = $objp->product_label; // Label product @@ -759,7 +767,7 @@ class Contrat extends CommonObject $line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite); $line->date_fin_reel = $this->db->jdate($objp->date_cloture); - // Retreive all extrafield for propal + // Retreive all extrafield for contract // fetch optionals attributes and labels $line->fetch_optionals($line->id,$extralabelsline); @@ -789,108 +797,6 @@ class Contrat extends CommonObject return -3; } - // Selectionne les lignes contrat liees a aucun produit - $sql = "SELECT d.rowid, d.fk_contrat, d.statut, d.qty, d.description, d.price_ht, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.rowid, d.remise_percent, d.subprice,"; - $sql.= " d.total_ht,"; - $sql.= " d.total_tva,"; - $sql.= " d.total_localtax1,"; - $sql.= " d.total_localtax2,"; - $sql.= " d.total_ttc,"; - $sql.= " d.info_bits, d.fk_product,"; - $sql.= " d.date_ouverture_prevue, d.date_ouverture,"; - $sql.= " d.date_fin_validite, d.date_cloture,"; - $sql.= " d.fk_user_author,"; - $sql.= " d.fk_user_ouverture,"; - $sql.= " d.fk_user_cloture,"; - $sql.= " d.fk_unit"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d"; - $sql.= " WHERE d.fk_contrat = ".$this->id; - $sql.= " AND (d.fk_product IS NULL OR d.fk_product = 0)"; // fk_product = 0 gardee pour compatibilitee - - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - - while ($i < $num) - { - $objp = $this->db->fetch_object($result); - - $line = new ContratLigne($this->db); - $line->id = $objp->rowid; - $line->fk_contrat = $objp->fk_contrat; - $line->libelle = $objp->description; - $line->desc = $objp->description; - $line->qty = $objp->qty; - $line->statut = $objp->statut; - $line->ref = ''; - $line->tva_tx = $objp->tva_tx; - $line->localtax1_tx = $objp->localtax1_tx; - $line->localtax2_tx = $objp->localtax2_tx; - $line->localtax1_type = $objp->localtax1_type; - $line->localtax2_type = $objp->localtax2_type; - $line->subprice = $objp->subprice; - $line->remise_percent = $objp->remise_percent; - $line->price_ht = $objp->price_ht; - $line->price = (isset($objp->price)?$objp->price:null); // For backward compatibility - $line->total_ht = $objp->total_ht; - $line->total_tva = $objp->total_tva; - $line->total_localtax1= $objp->total_localtax1; - $line->total_localtax2= $objp->total_localtax2; - $line->total_ttc = $objp->total_ttc; - $line->fk_product = 0; - $line->info_bits = $objp->info_bits; - - $line->fk_user_author = $objp->fk_user_author; - $line->fk_user_ouverture= $objp->fk_user_ouverture; - $line->fk_user_cloture = $objp->fk_user_cloture; - - $line->description = $objp->description; - - $line->date_ouverture_prevue = $this->db->jdate($objp->date_ouverture_prevue); - $line->date_ouverture = $this->db->jdate($objp->date_ouverture); - $line->date_fin_validite = $this->db->jdate($objp->date_fin_validite); - $line->date_cloture = $this->db->jdate($objp->date_cloture); - // For backward compatibility - $line->date_debut_prevue = $this->db->jdate($objp->date_ouverture_prevue); - $line->date_debut_reel = $this->db->jdate($objp->date_ouverture); - $line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite); - $line->date_fin_reel = $this->db->jdate($objp->date_cloture); - $line->fk_unit = $objp->fk_unit; - - if ($line->statut == 0) $this->nbofserviceswait++; - if ($line->statut == 4 && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++; - if ($line->statut == 4 && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; - if ($line->statut == 5) $this->nbofservicesclosed++; - - - // Retreive all extrafield for propal - // fetch optionals attributes and labels - - $line->fetch_optionals($line->id,$extralabelsline); - - - $this->lines[$pos] = $line; - $this->lines_id_index_mapper[$line->id] = $pos; - - $total_ttc+=$objp->total_ttc; - $total_vat+=$objp->total_tva; - $total_ht+=$objp->total_ht; - - $i++; - $pos++; - } - - $this->db->free($result); - } - else - { - dol_syslog(get_class($this)."::Fetch Erreur lecture des lignes de contrat non liees aux produits"); - $this->error=$this->db->error(); - return -2; - } - $this->nbofservices=count($this->lines); $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products $this->total_vat = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products From f083ac5e6bc04c8dad30dce3a168e2d53b054bc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Oct 2017 18:56:09 +0200 Subject: [PATCH 02/12] Prepare database to store country int accounting_system table --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_accounting_system.sql | 1 + 2 files changed, 3 insertions(+) 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 index 67d43fa9437..7dd690784bb 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -365,6 +365,8 @@ UPDATE llx_const set name = 'ONLINE_PAYMENT_CSS_URL' where name = 'PAYPAL_CS UPDATE llx_const set name = 'ONLINE_PAYMENT_NEWFORMTEXT' where name = 'PAYPAL_NEWFORMTEXT'; UPDATE llx_const set name = 'ONLINE_PAYMENT_LOGO' where name = 'PAYPAL_LOGO'; +ALTER TABLE llx_accounting_system ADD COLUMN fk_country integer; + UPDATE llx_accounting_account SET pcg_type = 'INCOME' where pcg_type = 'PROD'; UPDATE llx_accounting_account SET pcg_type = 'EXPENSE' where pcg_type = 'CHARGE'; UPDATE llx_accounting_account SET pcg_type = 'INCOME' where pcg_type = 'VENTAS_E_INGRESOS'; diff --git a/htdocs/install/mysql/tables/llx_accounting_system.sql b/htdocs/install/mysql/tables/llx_accounting_system.sql index 16acd31b079..69f31eaa15f 100644 --- a/htdocs/install/mysql/tables/llx_accounting_system.sql +++ b/htdocs/install/mysql/tables/llx_accounting_system.sql @@ -21,6 +21,7 @@ create table llx_accounting_system ( rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_country integer, pcg_version varchar(32) NOT NULL, label varchar(128) NOT NULL, active smallint DEFAULT 0 From 9df3f5c75e3fbc187cd5ad19d7bfc2492c88d908 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Oct 2017 19:18:17 +0200 Subject: [PATCH 03/12] Migration of data --- htdocs/install/mysql/data/llx_accounting_abc.sql | 12 ++++++------ htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_abc.sql index 4da1f48a0e3..ad132ab4df0 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_abc.sql @@ -37,21 +37,21 @@ INSERT INTO llx_accounting_journal (code, label, nature, active) VALUES ('ER', ' -- Description of chart of account FR PCG99-ABREGE -INSERT INTO llx_accounting_system (pcg_version, label, active) VALUES ('PCG99-ABREGE', 'The simple accountancy french plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG99-ABREGE', 'The simple accountancy french plan', 1); -- Description of chart of account FR PCG99-BASE -INSERT INTO llx_accounting_system (pcg_version, label, active) VALUES ('PCG99-BASE', 'The base accountancy french plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 1, 'PCG99-BASE', 'The base accountancy french plan', 1); -- Description of chart of account BE PCMN-BASE -INSERT INTO llx_accounting_system (pcg_version, label, active) VALUES ('PCMN-BASE', 'The base accountancy belgium plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 2, 'PCMN-BASE', 'The base accountancy belgium plan', 1); -- Description of chart of account ES PCG08-PYME -INSERT INTO llx_accounting_system (pcg_version, label, active) VALUES ('PCG08-PYME', 'The PYME accountancy spanish plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 4, 'PCG08-PYME', 'The PYME accountancy spanish plan', 1); -- Description of chart of account DK DK-STD -INSERT INTO llx_accounting_system (pcg_version, label, active) VALUES ('DK-STD', 'Standardkontoplan fra SKAT', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (80, 'DK-STD', 'Standardkontoplan fra SKAT', 1); -- Description of chart of account CL CL-PYME -INSERT INTO llx_accounting_system (pcg_version, label, active) VALUES ('PC-MIPYME', 'The PYME accountancy Chile plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (67, 'PC-MIPYME', 'The PYME accountancy Chile plan', 1); 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 index 7dd690784bb..706e363921b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -436,5 +436,16 @@ create table llx_c_email_senderprofile ALTER TABLE llx_c_email_senderprofile ADD UNIQUE INDEX uk_c_email_senderprofile(entity, label, email); +-- Description of chart of account CL CL-PYME +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (67, 'PC-MIPYME', 'The PYME accountancy Chile plan', 1); + +UPDATE llx_accounting_system SET fk_country = 1 WHERE pcg_version = 'PCG99-ABREGE'; +UPDATE llx_accounting_system SET fk_country = 1 WHERE pcg_version = 'PCG99-BASE'; +UPDATE llx_accounting_system SET fk_country = 2 WHERE pcg_version = 'PCMN-BASE'; +UPDATE llx_accounting_system SET fk_country = 4 WHERE pcg_version = 'PCG08-PYME'; +UPDATE llx_accounting_system SET fk_country = 80 WHERE pcg_version = 'DK-STD'; +UPDATE llx_accounting_system SET fk_country = 67 WHERE pcg_version = 'PC-MIPYME'; + + -- May have error due to duplicate keys ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity); From ef628025d20c8425374a7d37d3b5c3d632538306 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Oct 2017 20:01:38 +0200 Subject: [PATCH 04/12] NEW Add and edit country for chart of accounts systems --- htdocs/accountancy/admin/accountmodel.php | 21 ++++++++------------ htdocs/accountancy/admin/categories_list.php | 1 + 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 03565528fc1..5adb9760c9c 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -41,14 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -$langs->load("errors"); -$langs->load("admin"); -$langs->load("main"); -$langs->load("companies"); -$langs->load("resource"); -$langs->load("holiday"); -$langs->load("accountancy"); -$langs->load("hrm"); +$langs->loadLangs(array("errors","admin","companies","resource","holiday","compta","accountancy","hrm")); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); @@ -100,7 +93,7 @@ $tablib[32]= "DictionaryAccountancyCategory"; // Requests to extract data $tabsql=array(); -$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; +$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1"; $tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; // Criteria to sort dictionaries @@ -110,17 +103,17 @@ $tabsqlsort[32]="position ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); -$tabfield[31]= "pcg_version,label"; +$tabfield[31]= "pcg_version,label,country_id,country"; $tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); -$tabfieldvalue[31]= "pcg_version,label"; +$tabfieldvalue[31]= "pcg_version,label,country"; $tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[31]= "pcg_version,label"; +$tabfieldinsert[31]= "pcg_version,label,fk_country"; $tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; // Nom du rowid si le champ n'est pas de type autoincrement @@ -173,7 +166,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=1; foreach ($listfield as $f => $value) { - if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancysystem','DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory + if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryVAT','DictionaryRegion','DictionaryCompanyType','DictionaryHolidayTypes','DictionaryRevenueStamp','DictionaryAccountancyCategory','Pcg_version'))) continue; // For some pages, country is not mandatory if ($value == 'country' && in_array($tablib[$id],array('DictionaryCanton','DictionaryCompanyType','DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; @@ -188,6 +181,8 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=0; $fieldnamekey=$listfield[$f]; // We take translate key of field + + if ($fieldnamekey == 'pcg_version') $fieldnamekey='Pcg_version'; if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label'; if ($fieldnamekey == 'libelle_facture') $fieldnamekey = 'LabelOnDocuments'; if ($fieldnamekey == 'nbjour') $fieldnamekey='NbOfDays'; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 53569c50b00..d5fb2175b5f 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -569,6 +569,7 @@ if ($id) print ""; $colspan=count($fieldlist)+3; + if ($id == 32) $colspan++; print ' '; // Keep   to have a line with enough height } From 2a75f09070c521cff0fa3ced48e458333ead5d4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Oct 2017 20:14:14 +0200 Subject: [PATCH 05/12] NEW Use autocompletion on selection of chart of account --- htdocs/accountancy/admin/account.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index fb48bc8094f..300c9535633 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2016-2017 Laurent Destailleur * * 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 @@ -216,25 +216,29 @@ if ($resql) // Box to select active chart of account print $langs->trans("Selectchartofaccounts") . " : "; print '"; + print ajax_combobox("chartofaccounts"); print ''; print '
'; print '
'; From e0c9c00827bcc1c5a28dec2480ef6e9a0a1fb0a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Oct 2017 20:17:57 +0200 Subject: [PATCH 06/12] Add field to list --- htdocs/accountancy/admin/account.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 300c9535633..49e183e1695 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -67,8 +67,8 @@ $arrayfields=array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>0), - 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'), - 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'), + 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); From 28ae602b7e6ea871ffc17e6bcfcce9bc7d93ad2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Oct 2017 20:42:09 +0200 Subject: [PATCH 07/12] NEW Chart of account is loaded when selected into accounting setup --- htdocs/accountancy/admin/account.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 49e183e1695..4dcc4be7b01 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -105,14 +105,32 @@ if (empty($reshook)) $search_array_options=array(); } - if (GETPOST('change_chart')) + if (GETPOST('change_chart','alpha')) { $chartofaccounts = GETPOST('chartofaccounts', 'int'); - if (! empty($chartofaccounts)) { + if ($chartofaccounts > 0) + { + // Get language code for this $chartofaccounts + $sql ='SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; + $sql.=' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $country_code = $obj->code; + } + else dol_print_error($db); + + // Try to load sql file + if ($country_code) + { + $sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql'; + $result = run_sql($sqlfile, 1, 0, 1); + } if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { - $error ++; + $error++; } } else { $error ++; From e257da6b198c3e75846dc3936acfbd89a30d682b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 09:47:18 +0200 Subject: [PATCH 08/12] Reload of menu auguria done when required --- htdocs/admin/menus.php | 27 ++++++++++++++------------- htdocs/install/upgrade2.php | 27 +++------------------------ 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 888045f3297..5e0b6fac6f6 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $action=GETPOST('action','aZ09'); +$cancel=GETPOST('cancel','alpha'); $langs->load("companies"); $langs->load("products"); @@ -62,22 +63,22 @@ error_reporting($err); * Actions */ -if ($action == 'update' && empty($_POST["cancel"])) +if ($action == 'update' && ! $cancel) { $_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer - dolibarr_set_const($db, "MAIN_MENU_STANDARD", $_POST["MAIN_MENU_STANDARD"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", $_POST["MAIN_MENU_SMARTPHONE"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD','alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", GETPOST('MAIN_MENU_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", $_POST["MAIN_MENUFRONT_STANDARD"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE",$_POST["MAIN_MENUFRONT_SMARTPHONE"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", GETPOST('MAIN_MENUFRONT_STANDARD','alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE", GETPOST('MAIN_MENUFRONT_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity); // Define list of menu handlers to initialize $listofmenuhandler=array(); - $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1; - $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1; - if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1; - if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1; + $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',GETPOST('MAIN_MENU_STANDARD','alpha'))]=1; + $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',GETPOST('MAIN_MENUFRONT_STANDARD','alpha'))]=1; + if (GETPOST('MAIN_MENU_SMARTPHONE','alpha')) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',GETPOST('MAIN_MENU_SMARTPHONE','alpha'))]=1; + if (GETPOST('MAIN_MENUFRONT_SMARTPHONE','alpha')) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',GETPOST('MAIN_MENUFRONT_SMARTPHONE','alpha'))]=1; // Initialize menu handlers foreach ($listofmenuhandler as $key => $val) @@ -179,7 +180,7 @@ if ($action == 'edit') print ''; // Menu top - + print ''.$langs->trans("DefaultMenuManager").''; print ''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled'); @@ -190,7 +191,7 @@ if ($action == 'edit') print ''; // Menu smartphone - + print ''.$langs->trans("DefaultMenuSmartphoneManager").''; print ''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled'); @@ -217,7 +218,7 @@ else print ''; print ''; - + print ''.$langs->trans("DefaultMenuManager").''; print ''; $filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED)); @@ -229,7 +230,7 @@ else print ''; print ''; - + print ''; print ''.$langs->trans("DefaultMenuSmartphoneManager").''; print ''; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index f273474ab09..d52bd5ff84c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4361,31 +4361,10 @@ function migrate_reload_menu($db,$langs,$conf,$versionto) // Define list of menu handlers to initialize $listofmenuhandler=array(); - - $versiontoarray=explode('.',$versionto); - - // Migration required when target version is between - $afterversionarray=explode('.','2.8.9'); - $beforeversionarray=explode('.','2.9.9'); - if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) + if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' + || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') { - $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers - } - - // Migration required when target version is between - $afterversionarray=explode('.','3.1.9'); - $beforeversionarray=explode('.','3.2.9'); - if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) - { - $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers - } - - // Migration required when target version is between - $afterversionarray=explode('.','3.7.9'); - $beforeversionarray=explode('.','4.0.9'); - if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) - { - $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers + $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers } foreach ($listofmenuhandler as $key => $val) From 6b65a9ac566432f5397cdb5a8ad232718eb38d59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 09:58:32 +0200 Subject: [PATCH 09/12] Fix position of resource menu --- htdocs/core/modules/modResource.class.php | 14 +++++++------- .../template/core/modules/modMyModule.class.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 7ab7afc1e4b..dd09b148453 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -226,7 +226,7 @@ class modResource extends DolibarrModules 'type'=> 'left', // Toujours un menu gauche 'titre'=> 'MenuResourceAdd', 'mainmenu'=> 'tools', - 'leftmenu'=> '', // On n'indique rien ici car on ne souhaite pas intégrer de sous-menus à ce menu + 'leftmenu'=> 'resource_add', 'url'=> '/resource/add.php', 'langs'=> 'resource', 'position'=> 101, @@ -241,7 +241,7 @@ class modResource extends DolibarrModules 'type'=> 'left', // Toujours un menu gauche 'titre'=> 'List', 'mainmenu'=> 'tools', - 'leftmenu'=> '', // On n'indique rien ici car on ne souhaite pas intégrer de sous-menus à ce menu + 'leftmenu'=> 'resource_list', 'url'=> '/resource/list.php', 'langs'=> 'resource', 'position'=> 102, @@ -255,7 +255,7 @@ class modResource extends DolibarrModules // Exports //-------- $r=0; - + $r++; $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]="ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found) @@ -265,19 +265,19 @@ class modResource extends DolibarrModules $this->export_entities_array[$r]=array('r.rowid'=>'resource','r.ref'=>'resource','c.code'=>'resource','c.label'=>'resource','r.description'=>'resource','r.note_private'=>"resource",'r.resource'=>"resource",'r.asset_number'=>'resource','r.datec'=>"resource",'r.tms'=>"resource"); $keyforselect='resource'; $keyforelement='resource'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - + $this->export_dependencies_array[$r]=array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'resource as r '; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .=' AND r.entity IN ('.getEntity('resource').')'; - + // Imports //-------- $r=0; - + // Import list of third parties and attributes $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; @@ -307,7 +307,7 @@ class modResource extends DolibarrModules $this->import_regex_array[$r]=array('s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); $this->import_examplevalues_array[$r]=array('r.ref'=>"REF1",'r.fk_code_type_resource'=>"Code from dictionary resource type",'r.datec'=>"2017-01-01 or 2017-01-01 12:30:00"); $this->import_updatekeys_array[$r]=array('r.rf'=>'ResourceFormLabel_ref'); - + } /** diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 6892bcab104..c73fcfb3e8e 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -253,7 +253,7 @@ class modMyModule extends DolibarrModules 'type'=>'left', // This is a Left menu entry 'titre'=>'List MyObject', 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_list', 'url'=>'/mymodule/myobject_list.php', 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, @@ -265,7 +265,7 @@ class modMyModule extends DolibarrModules 'type'=>'left', // This is a Left menu entry 'titre'=>'New MyObject', 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_new', 'url'=>'/mymodule/myobject_page.php?action=create', 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>1000+$r, From d47ab77123b9386c27196e66071ea7e4d4f492e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 10:02:33 +0200 Subject: [PATCH 10/12] Check module is on --- test/phpunit/SupplierProposalTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index 757449af8bc..ee4729ed47f 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -81,6 +81,8 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + if (empty($conf->global->MAIN_MODULE_SUPPLIERPROPOSAL)) { print "\n".__METHOD__." module Supplier proposal must be enabled.\n"; die(); } + print __METHOD__."\n"; } From 4d4f1ab6ecb1646801d849f29957814dd459aee7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 10:09:20 +0200 Subject: [PATCH 11/12] Fix html entities --- htdocs/admin/pdf.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index a7ed12a5336..8028c81cf04 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -110,10 +110,10 @@ $formother=new FormOther($db); $formadmin=new FormAdmin($db); $arraydetailsforpdffoot = array( - 0 => $langs->trans('NoDetails'), - 1 => $langs->trans('DisplayCompanyInfo'), - 2 => $langs->trans('DisplayCompanyManagers'), - 3 => $langs->trans('DisplayCompanyInfoAndManagers') + 0 => $langs->transnoentitiesnoconv('NoDetails'), + 1 => $langs->transnoentitiesnoconv('DisplayCompanyInfo'), + 2 => $langs->transnoentitiesnoconv('DisplayCompanyManagers'), + 3 => $langs->transnoentitiesnoconv('DisplayCompanyInfoAndManagers') ); print load_fiche_titre($langs->trans("PDF"),'','title_setup'); @@ -589,7 +589,7 @@ else // Show print ''.$langs->trans("ShowDetailsInPDFPageFoot").''; - print $arraydetailsforpdffoot[$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS]; + print $arraydetailsforpdffoot[($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0)]; print ''; print ''; From 15bed6d5e872b664d53d86bf541a9cced3e4c705 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 10:28:15 +0200 Subject: [PATCH 12/12] Force reload of module --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ad8eb84a225..ff8350a6446 100644 --- a/.travis.yml +++ b/.travis.yml @@ -319,7 +319,7 @@ script: php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log - php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log cd - set +e