From ba87549124c4579b4fd6736655d4abd5720ab0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Mon, 19 Jun 2017 18:07:43 +0200 Subject: [PATCH 01/33] FIX #5640 Prices of a predefined product/service were incorrect under certain circumstances --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d9b5b37d8f3..5e9786f2ba4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -725,7 +725,7 @@ function setforpredef() { jQuery("#select_type").val(-1); jQuery("#prod_entry_mode_free").prop('checked',false); jQuery("#prod_entry_mode_predef").prop('checked',true); - jQuery("#price_ht").hide(); + jQuery("#price_ht").val('').hide(); jQuery("#multicurrency_price_ht").hide(); jQuery("#price_ttc").hide(); // May no exists jQuery("#tva_tx").hide(); From eaaee59f92abba096890ee867d968c0dfe20e3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Mon, 19 Jun 2017 19:23:00 +0200 Subject: [PATCH 02/33] FIX #6541 since 4.0.4 to 5.0.0 autofill zip/town not working --- htdocs/core/class/conf.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index dc06bfe9ffa..203d41571a9 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -489,8 +489,8 @@ class Conf // By default, we propagate contacts if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) - // By default, we use the zip town autofill - if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=1; + // By default, we do not use the zip town autofill + if (! isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY=0; // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent'; // '' means 'all'. Note that contact is added here as it should be a module later. From c381c213a50af78bcf7f6b877e81493bdee2adfd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 20 Jun 2017 06:52:41 +0200 Subject: [PATCH 03/33] Fix : Accountancy --- htdocs/accountancy/admin/accountmodel.php | 1 - htdocs/accountancy/admin/defaultaccounts.php | 16 +- htdocs/accountancy/bookkeeping/card.php | 3 +- htdocs/accountancy/bookkeeping/list.php | 1 - htdocs/accountancy/customer/index.php | 232 +++++++++---------- htdocs/accountancy/expensereport/index.php | 3 - htdocs/langs/en_US/salaries.lang | 3 +- 7 files changed, 125 insertions(+), 134 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index ff908d6d066..e57354f8566 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -1148,7 +1148,6 @@ else * Show list of dictionary to show */ - $var=true; $lastlineisempty=false; print ''; print ''; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 227949a3c1c..9cf4d2977fd 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -1,11 +1,11 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro - * Copyright (C) 2014-2015 Ari Elbaz (elarifr) +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -23,7 +23,7 @@ */ /** - * \file htdocs/accountancy/admin/index.php + * \file htdocs/accountancy/admin/defaultaccounts.php * \ingroup Advanced accountancy * \brief Setup page to configure accounting expert module */ @@ -53,10 +53,10 @@ $action = GETPOST('action', 'alpha'); $list_account_main = array ( 'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_SUPPLIER', + 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); $list_account = array ( - 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'ACCOUNTING_SERVICE_BUY_ACCOUNT', diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3c6d2faec94..28b7b177860 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -500,8 +500,7 @@ if ($action == 'create') { print "\n"; foreach ( $book->linesmvt as $line ) { - $var = ! $var; - print ''; + print ''; $total_debit += $line->debit; $total_credit += $line->credit; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 1062fd50d87..16d27df15fd 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -438,7 +438,6 @@ $total_debit = 0; $total_credit = 0; foreach ($object->lines as $line ) { - $var = ! $var; $total_debit += $line->debit; $total_credit += $line->credit; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 24e066917bc..10322c68077 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,9 +1,9 @@ +/* Copyright (C) 2013 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -40,7 +40,7 @@ $langs->load("accountancy"); // Security check if (empty($conf->accounting->enabled)) { - accessforbidden(); + accessforbidden(); } if ($user->societe_id > 0) accessforbidden(); @@ -187,7 +187,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } 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.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); @@ -203,10 +203,6 @@ $buttonbind = '' . $langs->trans("CleanHistory", $year_current) . ''; - - -$var = true; - print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print '
'; @@ -269,14 +265,14 @@ print '
'; print ''; print ''; for($i = 1; $i <= 12; $i ++) { - print ''; + print ''; } print ''; $sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,"; $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,"; for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; } $sql .= " SUM(fd.total_ht) as total"; $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; @@ -296,22 +292,22 @@ $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ( $row = $db->fetch_row($resql)) { - print ''; - print ''; - for($i = 2; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - print ''; - } - $db->free($resql); + print ''; + print ''; + for($i = 2; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + print ''; + } + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "
' . $langs->trans("Account") . '' . $langs->trans("Label") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[$i]) . '' . price($row[13]) . '' . price($row[14]) . '
\n"; @@ -319,101 +315,101 @@ print "\n"; if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? { - print '
'; - print '
'; - - print_fiche_titre($langs->trans("OtherInfo"), '', ''); - - print "
\n"; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; - for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM(fd.total_ht) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity('facture', 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 . ")"; - } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; - } - - dol_syslog('htdocs/accountancy/customer/index.php'); - $resql = $db->query($sql); - if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - $i ++; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; - - if (! empty($conf->margin->enabled)) { - print "
\n"; - print ''; - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - - $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; - for($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; - } - $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; - $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; - $sql .= " AND f.entity IN (" . getEntity('facture', 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 . ")"; - } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; - } - - dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - - print ''; - for($i = 1; $i <= 12; $i ++) { - print ''; - } - print ''; - print ''; - } - $db->free($resql); - } else { - print $db->lasterror(); // Show last sql error - } - print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; - } + print '
'; + print '
'; + + print_fiche_titre($langs->trans("OtherInfo"), '', ''); + + print "
\n"; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM(fd.total_ht) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity('facture', 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 . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php'); + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + $i ++; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalVente") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price($row[$i]) . '' . price($row[13]) . '
\n"; + + if (! empty($conf->margin->enabled)) { + print "
\n"; + print ''; + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + + $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,"; + for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql .= " AND f.entity IN (" . getEntity('facture', 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 . ")"; + } else { + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + } + + dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + while ($row = $db->fetch_row($resql)) { + + print ''; + for($i = 1; $i <= 12; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); + } else { + print $db->lasterror(); // Show last sql error + } + print "
' . $langs->trans("TotalMarge") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("Total") . '
' . $row[0] . '' . price(price2num($row[$i])) . '' . price(price2num($row[13])) . '
\n"; + } } diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index e9ce1b2e729..fdbf4d1ce4b 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -178,9 +178,6 @@ $buttonreset = ' Date: Tue, 20 Jun 2017 10:24:54 +0200 Subject: [PATCH 04/33] FIX #7040 --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d98625db1cc..2d52a7ee2d1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1469,7 +1469,7 @@ abstract class CommonObject $fieldname = 'multicurrency_code'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' SET '.$fieldname.' = "'.$this->db->escape($code).'"'; + $sql .= ' SET '.$fieldname." = '".$this->db->escape($code)."'"; $sql .= ' WHERE rowid='.$this->id; if ($this->db->query($sql)) From 6d42922839c41bf205f985b69b7cc83cab167be4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 10:37:42 +0200 Subject: [PATCH 05/33] FIX #7012 --- htdocs/supplier_proposal/card.php | 68 +++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 55da718cebc..a336a96b5e0 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -510,7 +510,7 @@ if (empty($reshook)) } // Add a product line - if ($action == 'addline' && $user->rights->supplier_proposal->creer) + if ($action == 'addline' && $user->rights->supplier_proposal->creer) { $langs->load('errors'); $error = 0; @@ -520,7 +520,7 @@ if (empty($reshook)) $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - + if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; @@ -577,7 +577,7 @@ if (empty($reshook)) if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { $productsupplier = new ProductFournisseur($db); - + if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) { $idprod=0; @@ -597,7 +597,7 @@ if (empty($reshook)) $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist $res=$productsupplier->fetch($idprod); } - + if ($idprod > 0) { $pu_ht = $productsupplier->fourn_pu; @@ -606,7 +606,7 @@ if (empty($reshook)) $label = $productsupplier->label; $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); - + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); if (empty($tva_tx)) $tva_npr=0; @@ -664,13 +664,13 @@ if (empty($reshook)) $type = GETPOST('type'); $fk_unit= GETPOST('units', 'alpha'); - + $tva_tx = price2num($tva_tx); // When vat is text input field - + // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - + if (GETPOST('price_ht')!=='') { $price_base_type = 'HT'; @@ -683,13 +683,13 @@ if (empty($reshook)) $ht = $ttc / (1 + ($tva_tx / 100)); $price_base_type = 'HT'; } - + $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn, $fk_unit); //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } - if (! $error && $result > 0) + if (! $error && $result > 0) { $db->commit(); @@ -706,7 +706,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } @@ -716,7 +716,7 @@ if (empty($reshook)) unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); - unset($_POST['pu']); + unset($_POST['pu']); unset($_POST['price_ht']); unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); @@ -747,8 +747,8 @@ if (empty($reshook)) unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - } - else + } + else { $db->rollback(); @@ -1367,11 +1367,11 @@ if ($action == 'create') // Print form confirm print $formconfirm; - + // Supplier proposal card $linkback = '' . $langs->trans("BackToList") . ''; - - + + $morehtmlref='
'; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); @@ -1392,7 +1392,7 @@ if ($action == 'create') $morehtmlref.='
'; $morehtmlref.=''; $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=''; $morehtmlref.='
'; } else { @@ -1411,15 +1411,15 @@ if ($action == 'create') } } $morehtmlref.='
'; - - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
'; print '
'; print '
'; - + print ''; // Payment term @@ -1562,14 +1562,14 @@ if ($action == 'create') include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT @@ -1587,7 +1587,7 @@ if ($action == 'create') print ''; print ''; } - + // Amount HT print ''; print ''; @@ -1618,18 +1618,18 @@ if ($action == 'create') print ''; print '
' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
'; - + // Margin Infos /*if (! empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); - }*/ + }*/ print '
'; print '
'; print '
'; - + print '

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); @@ -1666,7 +1666,7 @@ if ($action == 'create') // Add free products/services form global $forceall, $senderissupplier, $dateSelector; $forceall=1; $senderissupplier=2; $dateSelector=0; // $senderissupplier=2 is same than 1 but disable test on minimum qty. - + if (! empty($object->lines)) $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); @@ -1814,12 +1814,12 @@ if ($action == 'create') print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - + // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_proposal')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + print '
'; // List of actions on element From d572bd4f34e6ab85718a035d0300ea48dfe53cef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 10:45:20 +0200 Subject: [PATCH 06/33] FIX #7003 --- htdocs/projet/ganttchart.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/ganttchart.inc.php b/htdocs/projet/ganttchart.inc.php index f60ada41bb1..8ac203500b3 100644 --- a/htdocs/projet/ganttchart.inc.php +++ b/htdocs/projet/ganttchart.inc.php @@ -141,7 +141,7 @@ else function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_id=null) { global $dateformatinput2; - + $start_date = $task["task_start_date"]; $end_date = $task["task_end_date"]; if (!$end_date) $end_date = $start_date; @@ -206,7 +206,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_ $s = "\n// Add taks id=".$task["task_id"]." level = ".$level."\n"; // $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js($name)."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."', '".$note."'));"; // For JSGanttImproved - $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".$task['note']."'));"; + $s.= "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".dol_escape_js(trim($name))."','".$start_date."', '".$end_date."', '".$task['task_css']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".($percent >= 0 ? $percent : 0).", ".($task["task_is_group"]).", '".$parent."', 1, '".($depend?$depend:$parent."SS")."', '".($percent >= 0 ? $percent.'%' : '0%')."','".dol_escape_js($task['note'])."'));"; echo $s; From 3ec0e6f7efc965da8991a17541e20e1c28cf6b0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Jun 2017 12:31:08 +0200 Subject: [PATCH 07/33] FIX #6885 --- htdocs/core/ajax/ajaxdirpreview.php | 16 ++----- htdocs/core/class/html.formfile.class.php | 56 +++++++++++------------ 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index bbc7647c802..f6077bf6261 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -162,21 +162,13 @@ if ($type == 'directory') // Auto area for suppliers invoices else if ($module == 'invoice') $upload_dir = $conf->facture->dir_output; // Auto area for suppliers invoices - else if ($module == 'invoice_supplier') - { - $relativepath='facture'; - $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath; - } + else if ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output; // Auto area for customers orders else if ($module == 'propal') $upload_dir = $conf->propal->dir_output; // Auto area for customers orders else if ($module == 'order') $upload_dir = $conf->commande->dir_output; // Auto area for suppliers orders - else if ($module == 'order_supplier') - { - $relativepath='commande'; - $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath; - } + else if ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output; // Auto area for suppliers invoices else if ($module == 'contract') $upload_dir = $conf->contrat->dir_output; // Auto area for products @@ -197,10 +189,12 @@ if ($type == 'directory') $param.='&module='.$module; $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); + if ($module == 'company') $excludefiles[]='^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. + $filearray=dol_dir_list($upload_dir,"files",1,'', $excludefiles, $sortfield, $sorting,1); $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname,$url); } - //Manual area + // Manual area else { $relativepath=$ecmdir->getRelativePath(); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6e46efe3fdf..05c5982dc00 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -331,11 +331,11 @@ class FormFile jQuery(\'#togglemassfilesarea\').text("('.dol_escape_js($langs->trans("Hide")).')"); } return false; - }); + }); }); '; - } - + } + $titletoshow=$langs->trans("Documents"); if (! empty($title)) $titletoshow=$title; @@ -556,7 +556,7 @@ class FormFile if (empty($noform)) $out.= '
'; $out.= ''; $out.= ''; - + $out.= load_fiche_titre($titletoshow, '', ''); $out.= ''; @@ -644,9 +644,9 @@ class FormFile $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - + $out.= ''."\n"; - + // Show title of array if not already shown if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) && ! $headershown) { @@ -671,7 +671,7 @@ class FormFile $documenturl = DOL_URL_ROOT.'/document.php'; if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; - + // Show file name with link to download $out.= ''; @@ -799,7 +799,7 @@ class FormFile $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); if (! empty($conf->dol_use_jmobile)) return ''; - + $file_list=dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir),'/').'[^\-]+', '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) // For ajax treatment @@ -919,7 +919,7 @@ class FormFile if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; } } - if (empty($conf->global->MAIN_UPLOAD_DOC)) + if (empty($conf->global->MAIN_UPLOAD_DOC)) { $permtoeditline=0; $permonobject=0; @@ -928,7 +928,7 @@ class FormFile // Show list of existing files if (empty($useinecm)) print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - + print ''."\n"; if (GETPOST('action') == 'editfile' && $permtoeditline) { @@ -938,7 +938,7 @@ class FormFile print ''; } print '
'; $out.= '"; $out.=''; $out.=''; @@ -756,7 +756,7 @@ class FormFile } $this->numoffiles++; } - + if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { $out.='
'.$langs->trans("None").'
'."\n"; - + print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); @@ -971,13 +971,13 @@ class FormFile $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; } $var=!$var; - + $editline=0; - + print ''."\n"; print ''; print '"; @@ -1103,7 +1103,7 @@ class FormFile { print ''; } - + return $nboffiles; } } @@ -1489,11 +1489,11 @@ class FormFile return $nboflinks; } - - + + /** * Show detail icon with link for preview - * + * * @param array $file File * @param string $modulepart propal, facture, facture_fourn, ... * @param string $relativepath Relative path of docs From 3a400c46adeb32582c99c4b8b986bd90ade33d90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 10:15:32 +0200 Subject: [PATCH 08/33] Fix preselected email not done --- htdocs/core/class/html.formmail.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d59ac6c25af..d6089ebdb54 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -528,7 +528,12 @@ class FormMail extends Form { $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $out.= $form->multiselectarray("receiver", $tmparray, GETPOST("receiver"), null, null, 'inline-block minwidth500', null, ""); + $withtoselected=GETPOST("receiver"); // Array of selected value + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action') == 'presend') + { + $withtoselected = array_keys($tmparray); + } + $out.= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); } } $out.= "\n"; @@ -556,7 +561,8 @@ class FormMail extends Form { $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $out.= $form->multiselectarray("receivercc", $tmparray, GETPOST("receivercc"), null, null, 'inline-block minwidth500',null, ""); + $withtoccselected=GETPOST("receivercc"); // Array of selected value + $out.= $form->multiselectarray("receivercc", $tmparray, $withtoccselected, null, null, 'inline-block minwidth500',null, ""); } } $out.= "\n"; @@ -584,8 +590,8 @@ class FormMail extends Form { $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - //$out.= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1); - $out.= $form->multiselectarray("receiverccc", $tmparray, GETPOST("receiverccc"), null, null, null,null, "90%"); + $withtocccselected=GETPOST("receiverccc"); // Array of selected value + $out.= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null,null, "90%"); } } From ecae2fc6b681a67bc7c85373bf87a9b610d257da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 11:08:49 +0200 Subject: [PATCH 09/33] Fix translation --- htdocs/compta/facture.php | 126 +++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 2d0208d0c2b..bc51f0b226b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1003,7 +1003,7 @@ if (empty($reshook)) } $id = $object->create($user); // This include class to add_object_linked() and add add_contact() - + if ($id > 0) { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); @@ -1052,7 +1052,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - + $result = $object->addline( $langs->trans('Deposit'), $amountdeposit, // subprice @@ -1155,7 +1155,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - + // View third's localtaxes for NOW and do not use value from origin. // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); @@ -1456,7 +1456,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { @@ -1718,7 +1718,7 @@ if (empty($reshook)) } } } - + $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'), @@ -2024,11 +2024,11 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } - + if (!empty($soc->id)) $absolute_discount = $soc->getAvailableDiscounts(); $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null)); $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null)); - + if (! empty($conf->use_javascript_ajax)) { require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; @@ -2110,7 +2110,7 @@ if ($action == 'create') print '' . "\n"; $exampletemplateinvoice=new FactureRec($db); - + // Overwrite value if creation of invoice is from a predefined invoice if (empty($origin) && empty($originid) && GETPOST('fac_rec','int') > 0) { @@ -2232,7 +2232,7 @@ if ($action == 'create') if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) { // Deposit - if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) + if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) { print '
'; $tmp=' '; @@ -2243,7 +2243,7 @@ if ($action == 'create') }); }); '; - + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); print '
'; - + //print "XX".$file['name']; //$file['name'] must be utf8 print '\n"; @@ -1038,7 +1038,7 @@ class FormFile // Delete or view link // ($param must start with &) print ''; - if ($useinecm) + if ($useinecm) { print ''.img_view('default', 0, 'class="paddingrightonly"').''; } @@ -1046,10 +1046,10 @@ class FormFile { $newmodulepart=$modulepart; if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; - - $disablecrop=1; + + $disablecrop=1; if (in_array($modulepart, array('product','produit','service','holiday','project'))) $disablecrop=0; - + if (! $disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) @@ -1058,7 +1058,7 @@ class FormFile print ''.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','class="paddingrightonly"',1).''; } } - + if ($permtoeditline) { print ''.img_edit('default',0,'class="paddingrightonly"').''; @@ -1076,7 +1076,7 @@ class FormFile if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - + print ''.img_delete().''; } print "
'; print $desc; @@ -2257,7 +2257,7 @@ if ($action == 'create') print '' . $langs->trans('Value') . ':'; } print '
'; - + print '
'; } } @@ -2289,7 +2289,7 @@ if ($action == 'create') } // Replacement - if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT)) + if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT)) { print ''; print '
'; @@ -2336,7 +2336,7 @@ if ($action == 'create') if ($socid > 0) { // Credit note - if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) + if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { print '
'; $tmp='textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - + print '
'; print '    0 ? 'checked':'').' /> "; print '
    0 ? 'checked':'').' /> "; print '
'; - + print '
'; } } @@ -2393,7 +2393,7 @@ if ($action == 'create') print '
' . "\n"; } } - + // Template invoice print '
'; $tmp=' '; @@ -2428,7 +2428,7 @@ if ($action == 'create') } $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - + // Date invoice print '' . $langs->trans('DateInvoice') . ''; print $form->select_date($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1, 1); @@ -2534,15 +2534,15 @@ if ($action == 'create') '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')', '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')' ); - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) { $htmltext.=$key.' = '.$langs->trans($val).'
'; } - $htmltext.='
'; + $htmltext.=''; } - + // Public note print ''; print ''; @@ -2630,9 +2630,9 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { - print '' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; - print '' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; - print '' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; + print '' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; + print '' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; + print '' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; } } @@ -3336,9 +3336,9 @@ else if ($id > 0 || ! empty($ref)) $prevsits_total_amount += $object->total_ht; print price($prevsits_total_amount, 0, $langs, 1, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency) ); - + print ''; - + // Previous situation(s) deduction(s) for ($i = 0; $i < $cprevsits; $i++) { @@ -3352,7 +3352,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print '- ' . price($prevsits[$i]->total_ht, 0, $langs, 1, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency) ); print ''; - + } } } @@ -3390,21 +3390,21 @@ else if ($id > 0 || ! empty($ref)) print '
'; print '
'; print '
'; - + print ''; - + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print ''; print ''; print ''; - + // Multicurrency Amount VAT print ''; print ''; print ''; - + // Multicurrency Amount TTC print ''; print ''; @@ -3463,7 +3463,7 @@ else if ($id > 0 || ! empty($ref)) print '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'; - + // List of previous situation invoices $sign = 1; @@ -3486,12 +3486,12 @@ else if ($id > 0 || ! empty($ref)) $nbrows += 5; if (! empty($conf->incoterm->enabled)) $nbrows += 1; - - if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) + + if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) { if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print ''; - + if (count($object->tab_previous_situation_invoice) > 0) { // List of previous invoices print ''; @@ -3503,7 +3503,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $total_prev_ht = $total_prev_ttc = 0; $var = true; foreach ($object->tab_previous_situation_invoice as $prev_invoice) { @@ -3519,10 +3519,10 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $var = ! $var; } - + print ''; print ''; print ''; @@ -3530,7 +3530,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - + if (count($object->tab_next_situation_invoice) > 0) { // List of next invoices print ''; @@ -3542,9 +3542,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $total_next_ht = $total_next_ttc = 0; - + $var = true; foreach ($object->tab_next_situation_invoice as $next_invoice) { $totalpaye = $next_invoice->getSommePaiement(); @@ -3559,10 +3559,10 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $var = ! $var; } - + print ''; print ''; print ''; @@ -3570,14 +3570,14 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - + if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print '
' . $langs->trans('AmountTTC') . ' 
' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_prev_ht) . ' 
' . $langs->trans('AmountTTC') . ' 
' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_next_ht) . ' 
'; } - + // List of payments already done - + print ''; print ''; @@ -3735,7 +3735,7 @@ else if ($id > 0 || ! empty($ref)) // Billed print ''; - + // Remainder to pay print ''; print ''; print ''; - } + } else // Credit note { $cssforamountpaymentcomplete=''; - + // Total already paid back print '
' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' 
'; if ($resteapayeraffiche >= 0) @@ -3745,11 +3745,11 @@ else if ($id > 0 || ! empty($ref)) print ' :' . price($resteapayeraffiche) . ' 
'; print $langs->trans('AlreadyPaidBack'); @@ -3807,15 +3807,15 @@ else if ($id > 0 || ! empty($ref)) { if ($object->situation_cycle_ref && $object->statut == 0) { print '
'; - + print '
'; print ''; print ''; print ''; - + print ''; print ''; - + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } @@ -3838,7 +3838,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print "\n"; - + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } @@ -3851,19 +3851,19 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + print '
   
 %
'; - + print '
'; - + print '
'; - + } - + } - - - + + + print '
@@ -3899,7 +3899,7 @@ else if ($id > 0 || ! empty($ref)) print "
\n"; print "
"; - + print "\n"; dol_fiche_end(); @@ -3998,7 +3998,7 @@ else if ($id > 0 || ! empty($ref)) //print ''.$langs->trans("MakeWithdrawRequest").''; } } - + // Create payment if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement) { if ($objectidnext) { @@ -4149,7 +4149,7 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + // Link for paypal payment if (! empty($conf->paypal->enabled) && $object->statut != 0) { include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; From a05bbd651cc208a8e75f923a7ed4c7d096f404af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 11:09:29 +0200 Subject: [PATCH 10/33] Fix translation --- htdocs/compta/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8ad11189313..6c2ab5786b7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2729,9 +2729,9 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled)) { - print '' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; - print '' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; - print '' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; + print '' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; + print '' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; + print '' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; } } From 45004493e0cb17248fbd0fc5211d30526e407a46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 11:12:17 +0200 Subject: [PATCH 11/33] Fix multicurrency and vat_src_code not propaged on invoice from shipment. --- htdocs/core/lib/functions.lib.php | 18 +++++++------- htdocs/expedition/class/expedition.class.php | 26 ++++++++++++++------ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f9f9c8557ee..aa70c2680dd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3891,7 +3891,7 @@ function getTaxesFromId($vatrowid) * @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, ...) + * @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type1, rate localtax2, accountancycodecust, accountancycodesupp) */ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0) { @@ -3927,22 +3927,22 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi { if (! isOnlyOneLocalTax(1)) { - return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell, $obj->accountancy_code_buy); } } elseif ($local == 2) { if (! isOnlyOneLocalTax(2)) { - return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell, $obj->accountancy_code_buy); } } else @@ -3951,22 +3951,22 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi { if(! isOnlyOneLocalTax(2)) { - return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy); } } else { if(! isOnlyOneLocalTax(2)) { - return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type,get_localtax($vatrate, 2, $buyer, $seller) ,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); + return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy); } } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 971a2189854..28e47ad4c98 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -49,7 +49,7 @@ class Expedition extends CommonObject public $table_element_line="expeditiondet"; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'sending'; - + var $socid; var $ref_customer; var $ref_int; @@ -396,7 +396,7 @@ class Expedition extends CommonObject { $error++; } - + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $expeditionline = new ExpeditionLigne($this->db); @@ -915,7 +915,7 @@ class Expedition extends CommonObject $this->error='ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH'; return -4; } - + // extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used $line->array_options = $array_options; @@ -1316,7 +1316,8 @@ class Expedition extends CommonObject $sql = "SELECT cd.rowid, cd.fk_product, cd.label as custom_label, cd.description, cd.qty as qty_asked, cd.product_type"; $sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva"; - $sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql.= ", cd.vat_src_code, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.price, cd.subprice, cd.remise_percent,cd.buy_price_ht as pa_ht"; + $sql.= ", cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc"; $sql.= ", ed.rowid as line_id, ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type"; $sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.tobatch as product_tobatch"; @@ -1389,8 +1390,10 @@ class Expedition extends CommonObject $line->pa_ht = $obj->pa_ht; + $localtax_array=array(0=>$obj->localtax1_type, 1=>$obj->localtax1_tx, 2=>$obj->localtax2_type, 3=>$obj->localtax2_tx); + // For invoicing - $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc); // We force type to 0 + $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0 $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) $line->qty = $line->qty_shipped; $line->total_ht = $tabprice[0]; @@ -1398,6 +1401,7 @@ class Expedition extends CommonObject $line->total_localtax2 = $tabprice[10]; $line->total_ttc = $tabprice[2]; $line->total_tva = $tabprice[1]; + $line->vat_src_code = $obj->vat_src_code; $line->tva_tx = $obj->tva_tx; $line->localtax1_tx = $obj->localtax1_tx; $line->localtax2_tx = $obj->localtax2_tx; @@ -1411,6 +1415,14 @@ class Expedition extends CommonObject $this->total_localtax1+= $tabprice[9]; $this->total_localtax2+= $tabprice[10]; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_subprice = $obj->multicurrency_subprice; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + if ($originline != $obj->fk_origin_line) { $line->detail_batch = array(); @@ -1479,7 +1491,7 @@ class Expedition extends CommonObject $label = '' . $langs->trans("ShowSending") . ''; $label .= '
' . $langs->trans('Ref') . ': '.$this->ref; $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); - + $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; if ($short) return $url; @@ -1495,7 +1507,7 @@ class Expedition extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; From 1211e0d7abcc165cbd50992f8da9f7bc006adca5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 12:09:21 +0200 Subject: [PATCH 12/33] FIX vat code not saved during product creation. --- htdocs/core/class/html.form.class.php | 2 +- htdocs/product/card.php | 44 ++++++++++++++++++++++---- htdocs/product/class/product.class.php | 5 +-- htdocs/product/price.php | 7 ++-- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b440c012f04..321a4752006 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4332,7 +4332,7 @@ class Form * Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle. * Sinon la TVA proposee par defaut=0. Fin de regle. * @param bool $options_only Return HTML options lines only (for ajax treatment) - * @param int $mode 1=Add code into key in select list + * @param int $mode 0=Use vat rate as key in combo list, 1=Add VAT code after vat rate into key, -1=Use id of vat line as key * @return string */ function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $mode=0) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 31a865132c8..833330126bb 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -239,12 +239,43 @@ if (empty($reshook)) else $object->price_min = GETPOST('price_min'); - $object->tva_tx = str_replace('*','',GETPOST('tva_tx')); - $object->tva_npr = preg_match('/\*/',GETPOST('tva_tx'))?1:0; + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' - // local taxes. - $object->localtax1_tx = get_localtax($object->tva_tx,1); - $object->localtax2_tx = get_localtax($object->tva_tx,2); + // We must define tva_tx, npr and local taxes + $vatratecode = ''; + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; + // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. + $vatratecode=$reg[1]; + // Get record from code + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; + $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.code ='".$vatratecode."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $npr = $obj->recuperableonly; + $localtax1 = $obj->localtax1; + $localtax2 = $obj->localtax2; + $localtax1_type = $obj->localtax1_type; + $localtax2_type = $obj->localtax2_type; + } + } + + $object->default_vat_code = $vatratecode; + $object->tva_tx = $tva_tx; + $object->tva_npr = $npr; + $object->localtax1_tx = $localtax1; + $object->localtax2_tx = $localtax2; + $object->localtax1_type = $localtax1_type; + $object->localtax2_type = $localtax2_type; $object->type = $type; $object->status = GETPOST('statut'); @@ -1109,7 +1140,8 @@ else // VAT print ''.$langs->trans("VATRate").''; - print $form->load_tva("tva_tx",-1,$mysoc,''); + $defaultva=get_default_tva($mysoc, $mysoc); + print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); print ''; print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0f28ffdea30..2e2f3007540 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -396,7 +396,7 @@ class Product extends CommonObject $sql = "SELECT count(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE entity IN (".getEntity('product', 1).")"; - $sql.= " AND ref = '" .$this->ref."'"; + $sql.= " AND ref = '" .$this->db->escape($this->ref)."'"; $result = $this->db->query($sql); if ($result) @@ -1285,7 +1285,7 @@ class Product extends CommonObject if (empty($this->price_by_qty)) $this->price_by_qty=0; // Add new price - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; $sql.= " VALUES(".($level?$level:1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx.", ".($this->default_vat_code?("'".$this->default_vat_code."'"):"null").",".$this->tva_npr.","; $sql.= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->localtax1_type."', '".$this->localtax2_type."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0?$this->fk_price_expression:'null'); @@ -1721,6 +1721,7 @@ class Product extends CommonObject $this->tva_tx = $obj->tva_tx; //! French VAT NPR $this->tva_npr = $obj->tva_npr; + $this->recuperableonly = $obj->tva_npr; // For backward compatibility //! Local taxes $this->localtax1_tx = $obj->localtax1_tx; $this->localtax2_tx = $obj->localtax2_tx; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index cbfe90a5a52..2b5617c601d 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -113,7 +113,7 @@ if (empty($reshook)) // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { - // We look into database using code + // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in create product. $vatratecode=$reg[1]; // Get record from code $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; @@ -1819,7 +1819,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print "" . ""; print '' . $langs->trans($object->price_base_type) . ""; - print '' . vatrate($object->tva_tx, true, $object->recuperableonly) . ""; + print ''; + print vatrate($object->tva_tx, true, $object->recuperableonly); + print $object->default_vat_code?' ('.$object->default_vat_code.')':''; + print ""; print '' . price($object->price) . ""; print '' . price($object->price_ttc) . ""; print '' . price($object->price_min) . ''; From 247803f894f4c2f4c174fbe45e5df1522873bc52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 20:03:15 +0200 Subject: [PATCH 13/33] Better templates --- htdocs/modulebuilder/template/admin/about.php | 15 ++++++++-- htdocs/modulebuilder/template/admin/setup.php | 16 +++++++++-- .../template/css/mymodule.css.php | 15 ++++++++-- .../modulebuilder/template/js/mymodule.js.php | 20 +++++++++++++ .../modulebuilder/template/myobject_card.php | 21 ++++++++------ .../modulebuilder/template/myobject_list.php | 28 +++++++++++-------- 6 files changed, 87 insertions(+), 28 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index 1306b0aef6a..532c3f36454 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -23,9 +23,18 @@ */ // Load Dolibarr environment -if (false === (@include '../../main.inc.php')) { // From htdocs directory - require '../../../main.inc.php'; // From "custom" directory -} +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); // Libraries require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 421452f06e8..be5797337dd 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -23,9 +23,19 @@ */ // Load Dolibarr environment -if (false === (@include '../../main.inc.php')) { // From htdocs directory - require '../../../main.inc.php'; // From "custom" directory -} +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); + global $langs, $user; diff --git a/htdocs/modulebuilder/template/css/mymodule.css.php b/htdocs/modulebuilder/template/css/mymodule.css.php index 0dbfae5b9ef..3722fc1e06e 100644 --- a/htdocs/modulebuilder/template/css/mymodule.css.php +++ b/htdocs/modulebuilder/template/css/mymodule.css.php @@ -33,15 +33,24 @@ if (! defined('NOLOGIN')) define('NOLOGIN',1); // File must be if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); - -session_cache_limiter(FALSE); - +// Load Dolibarr environment $res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +// Try main.inc.php using relative path if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +session_cache_limiter(FALSE); + // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) and load permission if we need to use them in CSS /*if (empty($user->id) && ! empty($_SESSION['dol_login'])) { diff --git a/htdocs/modulebuilder/template/js/mymodule.js.php b/htdocs/modulebuilder/template/js/mymodule.js.php index 32915dbe34e..2d6a940c373 100644 --- a/htdocs/modulebuilder/template/js/mymodule.js.php +++ b/htdocs/modulebuilder/template/js/mymodule.js.php @@ -22,4 +22,24 @@ * \brief JavaScript file for module MyModule. */ +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); + +// Define js type header('Content-Type: application/javascript'); +// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access. +// You can use CTRL+F5 to refresh your browser cache. +if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); +else header('Cache-Control: no-cache'); + diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 03dfd62f5d3..5ef7be8afbe 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -35,20 +35,25 @@ //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -// Change this following line to use the correct relative path (../, ../../, etc) +// Load Dolibarr environment $res=0; -if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory -if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory -if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); if (! $res) die("Include of main fails"); -// Change this following line to use the correct relative path from htdocs + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); dol_include_once('/mymodule/class/myobject.class.php'); // Load traductions files requiredby by page -$langs->load("mymodule"); -$langs->load("other"); +$langs->loadLangs(array("mymodule","other")); // Get parameters $id = GETPOST('id','int'); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 57958bb25b8..479b3a200fa 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -35,14 +35,20 @@ //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -// Change this following lines to use the correct relative path (../, ../../, etc) +// Load Dolibarr environment $res=0; -if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory -if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory -if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); if (! $res) die("Include of main fails"); -// Change this following line to use the correct relative path from htdocs + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -51,11 +57,11 @@ dol_include_once('/mymodule/class/myobject.class.php'); // Load traductions files requiredby by page $langs->loadLangs(array("mymodule","other")); -$action=GETPOST('action','alpha'); -$massaction=GETPOST('massaction','alpha'); -$show_files=GETPOST('show_files','int'); -$confirm=GETPOST('confirm','alpha'); -$toselect = GETPOST('toselect', 'array'); +$action = GETPOST('action','alpha'); +$massaction = GETPOST('massaction','alpha'); +$show_files = GETPOST('show_files','int'); +$confirm = GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); $id = GETPOST('id','int'); $backtopage = GETPOST('backtopage'); From d2fd4d6978dc7dd2d2f7e861cd466aa7007a1af5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 23:36:25 +0200 Subject: [PATCH 14/33] Better path to laod main.inc.php --- htdocs/modulebuilder/template/admin/about.php | 2 +- htdocs/modulebuilder/template/admin/setup.php | 3 +-- htdocs/modulebuilder/template/myobject_card.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index 532c3f36454..d73fa237b88 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -30,7 +30,7 @@ if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); // Try main.inc.php using relative path if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index be5797337dd..9e9dbdaf1ac 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -30,13 +30,12 @@ if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); // Try main.inc.php using relative path if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); if (! $res) die("Include of main fails"); - global $langs, $user; // Libraries diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 5ef7be8afbe..62739e2a0a1 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -43,7 +43,7 @@ if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); // Try main.inc.php using relative path if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 479b3a200fa..2cfc4f293fe 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -43,7 +43,7 @@ if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER $tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); // Try main.inc.php using relative path if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); From 81a473d547458ce523fe34c98d4dd526f9fff3bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Jun 2017 23:40:02 +0200 Subject: [PATCH 15/33] Warning not required for the moment --- htdocs/core/modules/modCashDesk.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index e5ba473c1c7..f153631dc20 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -70,8 +70,8 @@ class modCashDesk extends DolibarrModules $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') + //$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(); From ba82bc39c87beaba640dc6fb584c6d396dc1b342 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 00:25:29 +0200 Subject: [PATCH 16/33] Fix missing alias --- htdocs/societe/list.php | 81 +++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3bde7f09967..252bfc9383c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -50,6 +50,7 @@ $result = restrictedArea($user,'societe',$socid,''); $search_all=trim(GETPOST('sall', 'alphanohtml')); $search_nom=trim(GETPOST("search_nom")); +$search_alias=trim(GETPOST("search_alias")); $search_nom_only=trim(GETPOST("search_nom_only")); $search_barcode=trim(GETPOST("sbarcode")); $search_customer_code=trim(GETPOST('search_customer_code')); @@ -70,7 +71,7 @@ $search_idprof5=trim(GETPOST('search_idprof5')); $search_idprof6=trim(GETPOST('search_idprof6')); $search_sale=trim(GETPOST("search_sale",'int')); $search_categ=trim(GETPOST("search_categ",'int')); -$search_country=GETPOST("search_country",'int'); +$search_country=GETPOST("search_country",'intcomma'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_status=GETPOST("search_status",'int'); $search_type=GETPOST('search_type','alpha'); @@ -151,7 +152,8 @@ $checkedprofid6=0; $checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0); $checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0); $arrayfields=array( - 's.nom'=>array('label'=>"Company", 'checked'=>1), + 's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode), 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), @@ -210,6 +212,7 @@ if (empty($reshook)) if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_nom=''; + $search_alias=''; $search_categ=0; $search_sale=''; $search_barcode=""; @@ -406,6 +409,7 @@ if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_c if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_nom) $sql.= natural_search("s.nom",$search_nom); +if ($search_alias) $sql.= natural_search("s.name_alias",$search_alias); if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only); if ($search_customer_code) $sql.= natural_search("s.code_client",$search_customer_code); if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur",$search_supplier_code); @@ -488,37 +492,38 @@ llxHeader('',$langs->trans("ThirdParty"),$help_url); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_all != '') $param = "&sall=".urlencode($search_all); -if ($sall != '') $param .= "&sall=".urlencode($sall); -if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ); -if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); -if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); -if ($search_town != '') $param.= "&search_town=".urlencode($search_town); -if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); -if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); -if ($search_email != '') $param.= "&search_email=".urlencode($search_email); -if ($search_url != '') $param.= "&search_url=".urlencode($search_url); -if ($search_state != '') $param.= "&search_state=".urlencode($search_state); -if ($search_country != '') $param.= "&search_country=".urlencode($search_country); -if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code); -if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code); -if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); -if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); -if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode); -if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1); -if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2); -if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3); -if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4); -if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5); -if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6); -if ($search_country != '') $param.='&search_country='.urlencode($search_country); -if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); -if ($search_status != '') $param.='&search_status='.urlencode($search_status); +if ($search_all != '') $param = "&sall=".urlencode($search_all); +if ($sall != '') $param .= "&sall=".urlencode($sall); +if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ); +if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); +if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); +if ($search_alias != '') $param.= "&search_alias=".urlencode($search_alias); +if ($search_town != '') $param.= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); +if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); +if ($search_email != '') $param.= "&search_email=".urlencode($search_email); +if ($search_url != '') $param.= "&search_url=".urlencode($search_url); +if ($search_state != '') $param.= "&search_state=".urlencode($search_state); +if ($search_country != '') $param.= "&search_country=".urlencode($search_country); +if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code); +if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code); +if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); +if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); +if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode); +if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1); +if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2); +if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3); +if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4); +if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5); +if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6); +if ($search_country != '') $param.='&search_country='.urlencode($search_country); +if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm; if ($search_level_from != '') $param.='&search_level_from='.$search_level_from; if ($search_level_to != '') $param.='&search_level_to='.$search_level_to; -if ($type != '') $param.='&type='.urlencode($type); +if ($type != '') $param.='&type='.urlencode($type); // Add $param from extra fields foreach ($search_array_options as $key => $val) { @@ -633,6 +638,12 @@ if (! empty($arrayfields['s.nom']['checked'])) print ''; print ''; } +if (! empty($arrayfields['s.name_alias']['checked'])) +{ + print ''; + print ''; + print ''; +} // Barcode if (! empty($arrayfields['s.barcode']['checked'])) { @@ -882,6 +893,7 @@ print "\n"; print ''; if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); @@ -948,7 +960,6 @@ while ($i < min($num, $limit)) $companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur; $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; - $companystatic->name_alias=$obj->name_alias; print ''; if (! empty($arrayfields['s.nom']['checked'])) @@ -958,6 +969,14 @@ while ($i < min($num, $limit)) print "\n"; if (! $i) $totalarray['nbfield']++; } + if (! empty($arrayfields['s.name_alias']['checked'])) + { + $companystatic->name_alias=$obj->name_alias; // Added after the getNomUrl + print ''; + print $companystatic->name_alias; + print "\n"; + if (! $i) $totalarray['nbfield']++; + } // Barcode if (! empty($arrayfields['s.barcode']['checked'])) { From ee8924e1015fe3e5a14acdb3a99c219fe96b1e20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 10:23:38 +0200 Subject: [PATCH 17/33] Fix position of accounting periods --- htdocs/core/menus/init_menu_auguria.sql | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 5aa272380cc..b40eb4bafa9 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -220,6 +220,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/admin/dict.php?id=7&from=accountancy&search_country_id=__MYCOUNTRYID__&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2461__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_expensereport', 2451__+MAX_llx_menu__, '/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuExpenseReportAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2462__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 70, __ENTITY__); + -- Accounting period + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin" && $conf->global->MAIN_FEATURES_LEVEL > 0', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2451__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'FiscalPeriod', 1, 'admin', '', '', 2, 80, __ENTITY__); -- Binding insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__); @@ -245,8 +247,6 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2445__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/casoc.php?leftmenu=ca', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 22, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2446__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 23, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2447__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 24, __ENTITY__); - -- Accounting period - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2450__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_period', 2400__+MAX_llx_menu__, '/accountancy/admin/fiscalyear.php?mainmenu=setup', 'FiscalPeriod', 1, 'admin', '', '', 2, 4, __ENTITY__); -- Rapports compta simple insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled', __HANDLER__, 'left', 2700__+MAX_llx_menu__, 'accountancy', 'ca', 6__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 0, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 11, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2701__+MAX_llx_menu__, 'accountancy', '', 2700__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 66fe9f993a9..e96ac4a7193 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -966,7 +966,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47); }*/ - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); + + // Fiscal year + if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods. + { + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); + } // Binding if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); @@ -1039,12 +1045,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report", $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire); - - // Fiscal year - if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods. - { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"),1,$user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); - } } // Accountancy (simple) From 3b2eb97d722a8d8f9cb081c12ba84faea4c54802 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 10:29:07 +0200 Subject: [PATCH 18/33] Fix menu position --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 65488a3181e..cd53f913780 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -983,7 +983,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Fiscal year if ($conf->global->MAIN_FEATURES_LEVEL > 0) // Not yet used. In a future will lock some periods. { - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); } // Binding From 509aad9bcea13498dc561b4f40ffe303eeb44824 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 11:35:53 +0200 Subject: [PATCH 19/33] Fix README --- htdocs/api/README.md | 47 ++-- htdocs/modulebuilder/README.md | 216 +----------------- htdocs/modulebuilder/template/README.md | 94 ++++++++ .../template/dev/git-hooks/README | 15 ++ htdocs/theme/eldy/style.css.php | 7 + htdocs/theme/md/style.css.php | 7 + 6 files changed, 163 insertions(+), 223 deletions(-) create mode 100644 htdocs/modulebuilder/template/dev/git-hooks/README diff --git a/htdocs/api/README.md b/htdocs/api/README.md index b4ff7a89f7b..d57c9e61ef1 100644 --- a/htdocs/api/README.md +++ b/htdocs/api/README.md @@ -1,41 +1,54 @@ -API REST howto -============== +API REST +======== -This directory contains files to make Dolibarr a server of REST Web Services. -It depends on external library Restler. +## Integrate your ERP with any other applications using Dolibarr APIs, Triggers or Hooks + +This module provides the service to make Dolibarr a server of REST Web Services. It depends on external library Restler. + +Extract any data or push insert, update or delete record using our new REST APIs. Using standard HTTP and Json format, it is compatible with any language (PHP, Java, Ruby, Python, C#, C++, JavaScript, JQuery, Basic, ...). Use the embedded APIs explorer tool to test APIs or get generated URLs to use in your own code. -Explore the api ---------------- +
+ Dolibarr API explorer +
-You can explore API method by using web interface : https://**yourdolibarr.tld**/mydolibarr/api/admin/explorer.php (replace **yourdolibarr.tld** by real hostname of your Dolibarr installation) -Access to the API + +Explore the APIs +---------------- + +You can explore all available APIs by using the API explorer : [**yourdolibarr.tld**/api/index.php/explorer](../api/index.php/explorer) (replace **yourdolibarr.tld** by real hostname of your Dolibarr installation) + + +Access to an API ----------------- -> **Warning : access to the API should (or better : must!) be secured with SSL connection** +> **Warning : access to any API should (or better : must!) be secured with SSL connection** -To access to the API you need a token to identify. When you access the API for the first time, you need to log in with user name and password to get a token. **Only** this token will allow to access API with. +To access to the API you need a token to identify. **Only** this token will allow to access API with. +The token is dedicated to a user and it **must** be put into requests as **DOLAPIKEY** parameter in HTTP header (or among URL parameters, but this is less secured). -To log in with the API, use this uri : https://**yourdolibarr.tld**/mydolibarr/api/index.php/login?login=**username**&password=**password** (replace bold strings with real values) +To get a token you can: -The token will be saved by Dolibarr for next user accesses to the API and it **must** be put into request uri as **api_key** parameter. +* Edit the user card to set the value of token. Each user can have a different token. +* or Call the *login* API with login and password. This will return the value of token for the user used to login. Then call other services with -https://**yourdolibarr.tld**/mydolibarr/api/index.php/otherservice?api_key=**api_key** +https://**yourdolibarr.tld**/mydolibarr/api/index.php/otherservice?DOLAPIKEY=**api_key** -Develop the API ---------------- +Develop an API +-------------- The API uses Lucarast Restler framework. Please check documentation https://www.luracast.com/products/restler and examples http://help.luracast.com/restler/examples/ + Github contains also usefull informations : https://github.com/Luracast/Restler -To implement it into Dolibarr, we need to create a specific class for object we want to use. A skeleton file is available into /dev directory : *skeleton_api_class.class.php* +To implement it into Dolibarr, you need to create a specific class for object we want to use. A skeleton file is available into /modulebuilder/class directory : *api_mymodule_class.class.php* The API class file must be put into object class directory, with specific file name. By example, API class file for '*myobject*' must be put as : /htdocs/*myobject*/class/api_*myobject*.class.php. Class must be named **MyobjectApi**. -If a module provide several object, use a different name for '*myobject*' and put the file into the same directory. +If a module provide several object, use a different name for *'myobject'* and put the file into the same directory. **Define url for methods** diff --git a/htdocs/modulebuilder/README.md b/htdocs/modulebuilder/README.md index 548e87b7912..e5d9e63d7a3 100644 --- a/htdocs/modulebuilder/README.md +++ b/htdocs/modulebuilder/README.md @@ -1,10 +1,15 @@ -Dolibarr Module Template (aka My Module) -======================================== +Module Builder +============== -This is a full featured module template for Dolibarr. -It's a tool for module developers to kickstart their project and give an hands-on sample of which features Dolibarr has to offer for module development. +This is a module to provide embedded tools to develop your own application/features inside Dolibarr ERP CRM software. +It provide tools for module developers to kickstart their project and give an hands-on sample of which features Dolibarr +has to offer for module development. + +If you don't need to develop your own module/application, you just don't need this. + + +After enabling this module, you should find features to generate or edit modules/application from menu *Home - Admin tools - Module builder* -If you're not a module developer you have no use for this. Documentation ------------- @@ -12,204 +17,3 @@ Documentation [Module tutorial](https://wiki.dolibarr.org/index.php/Module_development) [Dolibarr development](https://wiki.dolibarr.org/index.php/Developer_documentation) - -### Translations - -Dolibarr uses [Transifex](https://transifex.com) to manage it's translations. - -This template also contains a sample configuration for Transifex managed translations under the hidden [.tx](.tx) directory. - -For more informations, see the [translator's documentation](http://wiki.dolibarr.org/index.php/Translator_documentation). - -There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module-template) for this module. - -Install -------- - -### Manually - -- Make sure Dolibarr is already installed and configured on your workstation or development server. - -- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file - -- Find the following lines: - ```php - //$dolibarr_main_url_root_alt ... - //$dolibarr_main_document_root_alt ... - ``` - -- Uncomment these lines (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation - - For example : - - - UNIX: - ```php - $dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs'; - $dolibarr_main_document_root = '/var/www/Dolibarr/htdocs'; - $dolibarr_main_url_root_alt = '/custom'; - $dolibarr_main_document_root_alt = '/var/www/Dolibarr/htdocs/custom'; - ``` - - - Windows: - ```php - $dolibarr_main_url_root = 'http://localhost/Dolibarr/htdocs'; - $dolibarr_main_document_root = 'C:/My Web Sites/Dolibarr/htdocs'; - $dolibarr_main_url_root_alt = '/custom'; - $dolibarr_main_document_root_alt = 'C:/My Web Sites/Dolibarr/htdocs/custom'; - ``` - - For more information about the ```conf.php``` file take a look at the conf.php.example file. - -- Clone the repository in ```$dolibarr_main_document_root_alt/mymodule``` - -*(You may have to create the ```htdocs/custom``` directory first if it doesn't exist yet.)* -```sh -git clone git@github.com:Dolibarr/dolibarr-module-template.git mymodule -``` - -- Install [Composer](https://getcomposer.org) dependencies: -```sh -composer install -``` - -Follow the [final steps](#final_steps). - -### Using [Composer](https://getcomposer.org) -Require this repository from Dolibarr's composer: -```json -{ - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/dolibarr/dolibarr-module-template" - } - ], - "require": { - "dolibarr/mymodule": "dev-master" - } -} -``` - -Run -```sh -composer update -``` - -Follow the [final steps](#final_steps). - -### Final steps - -From your browser: - - - Log into Dolibarr as a super-administrator - - Under "Setup" -> "Other setup", set ```MAIN_FEATURES_LEVEL``` to ```2``` - - Go to "Setup" -> "Modules" - - The module is under one of the tabs - - You should now be able to enable the new module and start coding ;) - -Provided tools --------------- - -### Starting a new module - -A [script](dev/newmodule.sh) allows you to rename most of the code to your own module name. -It requires ```find```, ```sed``` and ```rename``` commands on your system. -Just make sure you provide a CamelCase name. -```sh -./dev/newmodule.sh [NewName] -``` - -Some work still has to be done manually: -- Rename the directory holding the code -- Maybe rename some other bits (Search for 'my' in filenames and code) -- Update your module ID in the module descriptor -- Update your language files - - Keywords based on the module ID - - String referencing the template -- Remove the features you don't plan to use -- Fill the copyright notices at the top of each file -- Add your logo: see [images README](dev/img/README.md) for specifications -- Start a new GIT history -``` -git checkout --orphan [new_branch_name] -``` -- Build an awesome module ;) - -### Composer scripts - -Only the main commands are listed here. -See the [composer comments](composer-comments.md) or the [composer.json](composer.json) itself for more informations. - -#### Check - -Run a linter, a PHP compatibility version checker and checks coding style. -```sh -composer check -``` - -#### Test - -Run unit and functional tests. -```sh -composer test -``` - -#### Doc -Build code and user documentation. - -#### Release - -Run the checks and tests then build a distribution ZIP. -```sh -composer release -``` - -#### Git hooks - -Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided. -These are just wrappers calling composer scripts. -They ensure best practices are followed during module development. - -Install: -```sh -composer git_hooks_install -``` - -Remove: -```sh -composer git_hooks_remove -``` - -## Publishing the module -The de-facto standard for publishing and marketing modules for Dolibarr is the [Dolistore](https://www.dolistore.com). -Templates for required images and texts are [provided](dev/dolistore). -Check the dedicated [README](dev/dolistore/README.md) for more informations. - - -Licenses --------- - -### Main code - -![GPLv3 logo](img/gplv3.png) - -GPLv3 or (at your option) any later version. - -See [COPYING](COPYING) for more information. - -### Other Licenses - -#### [Parsedown](http://parsedown.org/) - -Used to display this README in the module's about page. -Licensed under MIT. - -#### [GNU Licenses logos](https://www.gnu.org/graphics/license-logos.html) - -Public domain - -#### Documentation - -All texts and readmes. - -![GFDL logo](img/gfdl.png) diff --git a/htdocs/modulebuilder/template/README.md b/htdocs/modulebuilder/template/README.md index 3d2d8f6102b..3385110838d 100644 --- a/htdocs/modulebuilder/template/README.md +++ b/htdocs/modulebuilder/template/README.md @@ -4,3 +4,97 @@ MyModuleDescription Other modules are available on Dolistore.com. + + + +### Translations + +This module contains a sample configuration for Transifex, under the hidden directory [.tx](.tx), so it is possible to manage translation using this service. +Translations can be define manually by editing files into directories [langs](langs). + + + + + + + +Licenses +-------- + +### Main code + +![GPLv3 logo](img/gplv3.png) + +GPLv3 or (at your option) any later version. + +See [COPYING](COPYING) for more information. + +#### Documentation + +All texts and readmes. + +![GFDL logo](img/gfdl.png) diff --git a/htdocs/modulebuilder/template/dev/git-hooks/README b/htdocs/modulebuilder/template/dev/git-hooks/README new file mode 100644 index 00000000000..a5d024c1bf5 --- /dev/null +++ b/htdocs/modulebuilder/template/dev/git-hooks/README @@ -0,0 +1,15 @@ +# Git hooks + +Optional [GIT hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) are provided. +These are just wrappers calling composer scripts. +They ensure best practices are followed during module development. + +Install: +```sh +composer git_hooks_install +``` + +Remove: +```sh +composer git_hooks_remove +``` diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 562d707c454..67359ea650f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -666,11 +666,18 @@ div.myavailability { margin-bottom: 12px; } + /* For the long description of module */ .moduledesclong p img, .moduledesclong p a img { max-width: 90% !important; height: auto !important; } +.imgdoc { + margin: 18px; + border: 1px solid #ccc; + box-shadow: 1px 1px 25px #aaa; + max-width: calc(100% - 56px); +} /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 802eb46f6af..8543b2ecc0f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -667,11 +667,18 @@ div.myavailability { margin-bottom: 12px; } + /* For the long description of module */ .moduledesclong p img,.moduledesclong p a img { max-width: 90% !important; height: auto !important; } +.imgdoc { + margin: 18px; + border: 1px solid #ccc; + box-shadow: 1px 1px 25px #aaa; + max-width: calc(100% - 56px); +} /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ From 1eee7297dce5fef69dcfc3a02288289a5948bfeb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 12:56:55 +0200 Subject: [PATCH 20/33] Fix typo --- htdocs/api/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/README.md b/htdocs/api/README.md index d57c9e61ef1..0b773888882 100644 --- a/htdocs/api/README.md +++ b/htdocs/api/README.md @@ -1,7 +1,7 @@ API REST ======== -## Integrate your ERP with any other applications using Dolibarr APIs, Triggers or Hooks +## Integrate your ERP with any other applications using Dolibarr APIs This module provides the service to make Dolibarr a server of REST Web Services. It depends on external library Restler. From b0c5616ff08c62d8c571abfd08b3ad705f1521eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 16:01:18 +0200 Subject: [PATCH 21/33] Fix in the way markdown README and ChangeLog are output on module page. --- htdocs/admin/modulehelp.php | 43 +++++++++++----- htdocs/core/modules/DolibarrModules.class.php | 51 ++++++++++++++++++- 2 files changed, 79 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 21e3afb3921..143ebc627f8 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -225,20 +225,6 @@ asort($orders); //var_dump($modules); - -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc'; -$head[$h][1] = $langs->trans("Description"); -$head[$h][2] = 'desc'; -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature'; -$head[$h][1] = $langs->trans("TechnicalServicesProvided"); -$head[$h][2] = 'feature'; -$h++; - - $i=0; foreach($orders as $tmpkey => $tmpvalue) { @@ -257,6 +243,28 @@ $special = $objMod->special; $tab=explode('_',$value); $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3]; + + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc'; +$head[$h][1] = $langs->trans("Description"); +$head[$h][2] = 'desc'; +$h++; + +$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature'; +$head[$h][1] = $langs->trans("TechnicalServicesProvided"); +$head[$h][2] = 'feature'; +$h++; + +if ($objMod->isCoreOrExternalModule() == 'external') +{ + $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=changelog'; + $head[$h][1] = $langs->trans("ChangeLog"); + $head[$h][2] = 'changelog'; + $h++; +} + // Check filters $modulename=$objMod->getName(); $moduledesc=$objMod->getDesc(); @@ -536,6 +544,13 @@ if ($mode == 'feature') } +if ($mode == 'changelog') +{ + $changelog=$objMod->getChangeLog(); + if ($changelog) $text.='
'.$changelog.'
'; + else $text.='
'.$langs->trans("NotAvailable").'
'; +} + print $text; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 37e72024e2a..f05b549fe18 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -652,7 +652,7 @@ class DolibarrModules // Can not be abstract, because we need to insta if ((float) DOL_VERSION >= 6.0) { @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; - $content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath('cabinetmed/doc/', 1))); + $content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1))); } else { @@ -678,6 +678,55 @@ class DolibarrModules // Can not be abstract, because we need to insta return $content; } + /** + * Gives the changelog. First check ChangeLog-la_LA.md then ChangeLog.md + * + * @return string Content of ChangeLog + */ + function getChangeLog() + { + global $langs; + $langs->load("admin"); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + + $filefound= false; + + // Define path to file README.md. + // First check README-la_LA.md then README.md + $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog-'.$langs->defaultlang.'.md', 0); + if (dol_is_file($pathoffile)) + { + $filefound = true; + } + if (! $filefound) + { + $pathoffile = dol_buildpath(strtolower($this->name).'/ChangeLog.md', 0); + if (dol_is_file($pathoffile)) + { + $filefound = true; + } + } + + if ($filefound) // Mostly for external modules + { + $content = file_get_contents($pathoffile); + + if ((float) DOL_VERSION >= 6.0) + { + @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; + $content = dolMd2Html($content, 'parsedown', array('doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1))); + } + else + { + $content = nl2br($content); + } + } + + return $content; + } + /** * Gives the publisher name * From e79f3715b4cfb5c07071c4edbf773503089ac75b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 16:21:25 +0200 Subject: [PATCH 22/33] FIX #7048 #6075 --- htdocs/compta/bank/bankentries.php | 161 +++++++++++++++-------------- 1 file changed, 81 insertions(+), 80 deletions(-) diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 4845012a3e0..c3afc9634cf 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -107,7 +107,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder='ASC'; -if (! $sortfield) $sortfield='b.datev'; +if (! $sortfield) $sortfield='b.datev, b.dateo, b.rowid'; $mode_balance_ok=false; //if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected @@ -194,7 +194,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_num_releve=''; $search_conciliated=''; $thirdparty=''; - + $account=""; if ($id > 0 || ! empty($ref)) $account=$object->id; } @@ -396,18 +396,18 @@ if ($id > 0 || ! empty($ref)) foreach ($bankcateg->fetchAll() as $bankcategory) { $options[$bankcategory->id] = $bankcategory->label; } - + // Bank card - + $head=bank_prepare_head($object); dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); - + $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - + dol_fiche_end(); - + /* @@ -416,7 +416,7 @@ if ($id > 0 || ! empty($ref)) if ($action != 'addline' && $action != 'reconcile') { print '
'; - + if ($action != 'addline') { if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) @@ -438,7 +438,7 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("Conciliate").''; } } - + print '
'; } } @@ -524,10 +524,10 @@ if (($id > 0 || ! empty($ref)) && ((string) $page == '')) $offset = $limit * $page; if ($page < 0) $page = 0; } -if ($page >= $nbtotalofpages) +if ($page >= $nbtotalofpages) { // If we made a search and result has low page than the page number we were on - $page = ($nbtotalofpages -1); + $page = ($nbtotalofpages -1); $offset = $limit * $page; if ($page < 0) $page = 0; } @@ -550,9 +550,9 @@ if ($resql) { $var=True; $num = $db->num_rows($resql); - + $arrayofselected=is_array($toselect)?$toselect:array(); - + // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), @@ -561,16 +561,16 @@ if ($resql) //if ($user->rights->bank->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - - + + // Confirmation delete if ($action == 'delete') { $text=$langs->trans('ConfirmDeleteTransaction'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } - - + + // Lines of title fields print '
'."\n"; if ($optioncss != '') print ''; @@ -583,7 +583,7 @@ if ($resql) print ''; print ''; if (GETPOST('bid')) print ''; - + // Form to reconcile if ($user->rights->banque->consolidate && $action == 'reconcile') { @@ -602,7 +602,7 @@ if ($resql) print ''; print ' '.$langs->trans("or").' '; print ''; - + // Show last bank statements $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) $liste=""; @@ -644,7 +644,7 @@ if ($resql) if ($user->rights->banque->modifier && $action == 'addline') { print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); - + print ''; print ''; print ''; @@ -656,7 +656,7 @@ if ($resql) print ''; print ''; print ''; - + print ''; print ''; print '
'.$langs->trans("Date").''.$langs->trans("Credit").' 
'; $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction'); @@ -680,9 +680,9 @@ if ($resql) print '
'; print '
'; - } - - + } + + /// ajax to adjust value date with plus and less picto print ' - - '; - + + '; + $i = 0; - + // Title $bankcateg=new BankCateg($db); $morehtml='
'; @@ -713,7 +713,7 @@ if ($resql) $morehtml.=''; $morehtml.='/'.$nbtotalofpages.' '; $morehtml.='
'; - + $picto='title_bank'; if ($id > 0 || ! empty($ref)) $picto=''; if (GETPOST("bid")) @@ -725,13 +725,13 @@ if ($resql) { print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); } - + // We can add page now to param if ($page != '') $param.='&page='.urlencode($page); - - + + $moreforfilter = ''; - + $moreforfilter.='
'; $moreforfilter .= $langs->trans('DateOperationShort').' : '; $moreforfilter .= '
'.$langs->trans('From') . ' '; @@ -739,7 +739,7 @@ if ($resql) //$moreforfilter .= ' - '; $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= '
'; - + $moreforfilter.='
'; $moreforfilter .= $langs->trans('DateValueShort').' : '; $moreforfilter .= '
'.$langs->trans('From') . ' '; @@ -747,25 +747,25 @@ if ($resql) //$moreforfilter .= ' - '; $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->select_date($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= '
'; - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - - if ($moreforfilter) + + if ($moreforfilter) { print '
'; print $moreforfilter; print '
'."\n"; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''."\n"; - + // Fields title print ''; if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder); @@ -784,9 +784,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -802,7 +802,7 @@ if ($resql) print "\n"; print ''; - if (! empty($arrayfields['b.rowid']['checked'])) + if (! empty($arrayfields['b.rowid']['checked'])) { print '"; // Ref - if (! empty($arrayfields['b.rowid']['checked'])) + if (! empty($arrayfields['b.rowid']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } - + // Date ope - if (! empty($arrayfields['b.dateo']['checked'])) + if (! empty($arrayfields['b.dateo']['checked'])) { print '\n"; if (! $i) $totalarray['nbfield']++; } // Date value - if (! empty($arrayfields['b.datev']['checked'])) + if (! empty($arrayfields['b.datev']['checked'])) { print '\n"; if (! $i) $totalarray['nbfield']++; } - + // Third party - if (! empty($arrayfields['bu.label']['checked'])) + if (! empty($arrayfields['bu.label']['checked'])) { print "'; if (! $i) $totalarray['nbfield']++; } - + // Bank account - if (! empty($arrayfields['ba.ref']['checked'])) + if (! empty($arrayfields['ba.ref']['checked'])) { print '\n"; if (! $i) $totalarray['nbfield']++; } - + // Debit if (! empty($arrayfields['b.debit']['checked'])) { @@ -1192,7 +1193,7 @@ if ($resql) if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; } - + // Balance if (! empty($arrayfields['balance']['checked'])) { @@ -1212,7 +1213,7 @@ if ($resql) print ''; } } - + if (! empty($arrayfields['b.num_releve']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } - + // Action edit/delete print ''; - if (! $i) $totalarray['nbfield']++; - + if (! $i) $totalarray['nbfield']++; + // Action column print '
'; print ''; @@ -884,25 +884,25 @@ if ($resql) $balance = 0; // For balance $balancecalculated = false; - + // Loop on each record $sign = 1; - + $totalarray=array(); - while ($i < min($num,$limit)) + while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); // If we are in a situation where we need/can show balance, we calculate the start of balance if (! $balancecalculated && ! empty($arrayfields['balance']['checked']) && $mode_balance_ok) { - if (! $account) + if (! $account) { dol_print_error('', 'account is not defined but $mode_balance_ok is true'); exit; } - - //Loop on each record + + // Loop on each record before $sign = 1; $i = 0; $sqlforbalance='SELECT SUM(b.amount) as balance'; @@ -912,7 +912,8 @@ if ($resql) $sqlforbalance.= " WHERE b.fk_account = ba.rowid"; $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; $sqlforbalance.= " AND b.fk_account = ".$account; - $sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'"; + //$sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "')"; + $sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "' OR (b.datev = '" . $db->idate($db->jdate($objp->dv)) . "' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; $resqlforbalance = $db->query($sqlforbalance); //print $sqlforbalance; if ($resqlforbalance) @@ -924,12 +925,12 @@ if ($resql) } } else dol_print_error($db); - + $balancecalculated=true; } - + $balance = price2num($balance + ($sign * $objp->amount),'MT'); - + if (empty($cachebankaccount[$objp->bankid])) { $bankaccounttmp = new Account($db); @@ -941,13 +942,13 @@ if ($resql) { $bankaccount = $cachebankaccount[$objp->bankid]; } - + $var=!$var; print "
'; print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."   "; @@ -959,14 +960,14 @@ if ($resql) if (! empty($arrayfields['description']['checked'])) { print ""; - + //print "rowid."&account=".$objp->fk_account."\">"; $reg=array(); preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); else print dol_trunc($objp->label,40); //print " "; - + // Add links after description $links = $bankaccountstatic->get_url($objp->rowid); $cachebankaccount=array(); @@ -1054,19 +1055,19 @@ if ($resql) } elseif ($links[$key]['type']=='company') { - + } elseif ($links[$key]['type']=='user') { - + } elseif ($links[$key]['type']=='member') { - + } elseif ($links[$key]['type']=='sc') { - + } else { @@ -1086,20 +1087,20 @@ if ($resql) print ''; } } - + print ''.dol_print_date($db->jdate($objp->do),"day")."'; print ''.dol_print_date($db->jdate($objp->dv),"day").""; @@ -1115,7 +1116,7 @@ if ($resql) } // Payment type - if (! empty($arrayfields['type']['checked'])) + if (! empty($arrayfields['type']['checked'])) { print ''; $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle'); @@ -1131,9 +1132,9 @@ if ($resql) print ''.($objp->num_chq?$objp->num_chq:"").""; if ($objp->url_id) @@ -1156,16 +1157,16 @@ if ($resql) print ''; print $bankaccount->getNomUrl(1); print "-'; @@ -1224,7 +1225,7 @@ if ($resql) print ''.$objp->num_releve.''; } else if ($action == 'reconcile') - { + { print 'rowid])?' checked':'').'>'; } } @@ -1239,7 +1240,7 @@ if ($resql) print ''; // Transaction reconciliated or edit link @@ -1279,8 +1280,8 @@ if ($resql) } } print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined @@ -1296,7 +1297,7 @@ if ($resql) $i++; } - + // Show total line if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) { @@ -1319,7 +1320,7 @@ if ($resql) print "
"; print "
"; - + print ''; $db->free($resql); } From 0f5dc90bae34e6c6e3250254767fcc9b3bda9486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Bautista=20Mesa=20Rold=C3=A1n?= Date: Sat, 24 Jun 2017 16:45:45 +0200 Subject: [PATCH 23/33] Fixing pages warning when value is null --- htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/accountancy/admin/journals_list.php | 2 +- htdocs/adherents/document.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/admin/dict.php | 2 +- htdocs/admin/mails_templates.php | 2 +- htdocs/admin/tools/listsessions.php | 2 +- htdocs/admin/websites.php | 2 +- htdocs/comm/action/listactions.php | 2 +- htdocs/comm/action/rapport/index.php | 2 +- htdocs/compta/prelevement/ligne.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/fourn/facture/paiement.php | 2 +- htdocs/societe/notify/index.php | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index ff908d6d066..a29cce64749 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -68,7 +68,7 @@ $active = 1; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index e71482b0efa..cb852d82e0c 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -74,7 +74,7 @@ $active = 1; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 3dc932dbab5..dca29fd28b8 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -58,7 +58,7 @@ $active = 1; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index dd22a74577d..65dbadb11a6 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -52,7 +52,7 @@ $result=restrictedArea($user,'adherent',$id); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 628ceb390e3..369c56b068c 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -46,7 +46,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 6db098f0750..485c5713636 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -73,7 +73,7 @@ $active = 1; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 123877f7f4e..16277811b72 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -67,7 +67,7 @@ $active = 1; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index 56db6eb2ad7..c57a78974ed 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -47,7 +47,7 @@ $langs->load("other"); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 1dc91786ada..4dbd154096f 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -54,7 +54,7 @@ $status = 1; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $listlimit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 01094a78164..35fccdef2c8 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -80,7 +80,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $limit * $page ; if (! $sortorder) { diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index e83506d8206..dcda4e0cf04 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -42,7 +42,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $limit * $page ; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="a.datep"; diff --git a/htdocs/compta/prelevement/ligne.php b/htdocs/compta/prelevement/ligne.php index 933c23b0e7e..20ac3d18082 100644 --- a/htdocs/compta/prelevement/ligne.php +++ b/htdocs/compta/prelevement/ligne.php @@ -251,7 +251,7 @@ if ($id) - if ($page == -1) { $page = 0 ; } + if ($page == -1 || $page == null) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index a9e372a9709..056a1961b4c 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -109,7 +109,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 59b6e2a27e9..fcf7dc92ebf 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -601,7 +601,7 @@ if (empty($action)) $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); - if ($page == -1) { $page = 0 ; } + if ($page == -1 || $page == null) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/notify/index.php b/htdocs/societe/notify/index.php index ebebb23494c..4b7a5a3a111 100644 --- a/htdocs/societe/notify/index.php +++ b/htdocs/societe/notify/index.php @@ -42,7 +42,7 @@ if ($sortfield == "") $sortfield="s.nom"; } -if ($page == -1) { $page = 0 ; } +if ($page == -1 || $page == null) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; From fed5999a6c1edcbf8e86db0812fba2557b5d3cc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 16:57:42 +0200 Subject: [PATCH 24/33] Update doc --- htdocs/install/mysql/tables/llx_default_values.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_default_values.sql b/htdocs/install/mysql/tables/llx_default_values.sql index ca9849c681d..4212b602bf7 100644 --- a/htdocs/install/mysql/tables/llx_default_values.sql +++ b/htdocs/install/mysql/tables/llx_default_values.sql @@ -20,7 +20,7 @@ create table llx_default_values ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id - type varchar(10), -- 'createform', 'filters', 'sortorder' + type varchar(10), -- 'createform', 'filters', 'sortorder', 'focus', 'transform' user_id integer DEFAULT 0 NOT NULL, -- 0 or user id page varchar(255), -- relative url of page param varchar(255), -- parameter From 03cb850442c27558a0ba2f737e877a5bbe3b113f Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 24 Jun 2017 20:48:11 +0200 Subject: [PATCH 25/33] $forceimgscaleheight instead $forceimgscalewidth --- .../core/modules/printsheet/doc/pdf_standardlabel.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 5fce4c63a51..6411e97c423 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -61,11 +61,11 @@ class pdf_standardlabel extends CommonStickerGenerator */ function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='') { - global $mysoc,$conf,$langs; - global $forceimgscalewidth,$forceimgscaleheight; + global $mysoc, $conf, $langs; + global $forceimgscalewidth, $forceimgscaleheight; $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker) - $imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker) + $imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight); // Scale of image for height (1=Full height of sticker) // We are in a new page, then we must add a page if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) { From ab9be29356f548a4ef11745234c12f406171c84c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 21:36:51 +0200 Subject: [PATCH 26/33] Fix installers --- build/exe/doliwamp/install.forced.php.install | 2 +- build/rpm/install.forced.php.fedora | 2 +- build/rpm/install.forced.php.generic | 2 +- build/rpm/install.forced.php.mandriva | 2 +- build/rpm/install.forced.php.opensuse | 2 +- htdocs/install/fileconf.php | 26 ++++++++++++------- htdocs/install/step1.php | 5 ++-- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/build/exe/doliwamp/install.forced.php.install b/build/exe/doliwamp/install.forced.php.install index fd98dbf3984..5b186c17268 100644 --- a/build/exe/doliwamp/install.forced.php.install +++ b/build/exe/doliwamp/install.forced.php.install @@ -5,7 +5,7 @@ // during install process to be used. // // -$force_install_noedit=2; +$force_install_noedit=2; // 1=To block vars specific to distrib, 2 to block all technical parameters $force_install_message='KeepDefaultValuesWamp'; $force_install_main_data_root='WAMPROOT/dolibarr_documents'; $force_install_type='mysqli'; diff --git a/build/rpm/install.forced.php.fedora b/build/rpm/install.forced.php.fedora index 108455a9403..a8db3e25c9e 100644 --- a/build/rpm/install.forced.php.fedora +++ b/build/rpm/install.forced.php.fedora @@ -1,7 +1,7 @@ " - 0 && ! empty($force_install_databaserootlogin)) { print ' disabled'; } ?> > @@ -499,26 +500,28 @@ if (! empty($force_install_message)) trans("Password"); ?> + " - 0 && ! empty($force_install_databaserootpass)) { + print ' disabled'; // May be removed by javascript } ?> > @@ -561,7 +564,10 @@ jQuery(document).ready(function() { if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked")) { jQuery(".hideroot").show(); - jQuery(".needroot").removeAttr('disabled'); + + jQuery(".needroot").removeAttr('disabled'); + } else { diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index b323c970a9d..486b156fcaf 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -88,6 +88,7 @@ if (@file_exists($forcedfile)) { $main_data_dir = detect_dolibarr_main_data_root($main_dir); } $main_url = detect_dolibarr_main_url_root(); + if (!empty($force_install_databaserootlogin)) { $userroot = parse_database_login($force_install_databaserootlogin); } @@ -542,7 +543,7 @@ if (! $error && $db->connected && $action == "set") if ($db->connected) { $resultbis = 1; - + // Create user $result=$db->DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name); // Create user bis @@ -553,7 +554,7 @@ if (! $error && $db->connected && $action == "set") $resultbis=$db->DDLCreateUser('%', $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name); } } - + if ($result > 0 && $resultbis > 0) { From e6e8a014a3c3e4aafbb3af737deb6c811dcb5111 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 21:39:01 +0200 Subject: [PATCH 27/33] Prepare 5.0.4 --- ChangeLog | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c43fd92f676..228a2fd6291 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,10 +2,17 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + ***** ChangeLog for 5.0.4 compared to 5.0.3 ***** -FIX: #6880 -FIX: #6925 +FIX: #5640 Prices of a predefined product/service were incorrect under certain circumstances +FIX: #6541 since 4.0.4 to 5.0.0 autofill zip/town not working +FIX: #6880 #6925 +FIX: #6885 FIX: #6926 +FIX: #7003 +FIX: #7012 +FIX: #7040 +FIX: #7048 #6075 FIX: Can set supplier invoice to billed. FIX: Can't create invoice if PO disapproved FIX: contratligne update @@ -17,6 +24,7 @@ FIX: Redirect to payment page from member subscription page failed if a unique s FIX: REST api to get project when user has permission to read all. FIX: situation_progress param default value must be 100 and not 0 FIX: SQL injection on user/index.php parameter search_statut. +FIX: vat code not saved during product creation. FIX: Warnings ***** ChangeLog for 5.0.3 compared to 5.0.2 ***** From 778e581aca95af64b5ccc017072fb708b3189253 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Jun 2017 22:13:00 +0200 Subject: [PATCH 28/33] Fix: avoid warning on permission if there is only admin users --- htdocs/admin/modules.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 23d87791103..a59d6fca3bb 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -207,8 +207,19 @@ if ($action == 'set' && $user->admin) //var_dump($resarray);exit; if ($resarray['nbperms'] > 0) { - $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); - setEventMessages($msg, null, 'warnings'); + $tmpsql="SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; + $resqltmp=$db->query($tmpsql); + if ($resqltmp) + { + $obj=$db->fetch_object($resqltmp); + //var_dump($obj->nb);exit; + if ($obj && $obj->nb > 1) + { + $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); + setEventMessages($msg, null, 'warnings'); + } + } + else dol_print_error($db); } } header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:'')); From 6298436a1bae5e96086e4fd8b3d327133d2081dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Jun 2017 02:26:30 +0200 Subject: [PATCH 29/33] Clean old lot numbers --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 3 +++ htdocs/install/mysql/migration/repair.sql | 3 +++ 2 files changed, 6 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 637648be3ba..096b82a7768 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 @@ -497,3 +497,6 @@ CREATE TABLE llx_blockedlog_authority ) ENGINE=innodb; ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature); + +-- VMYSQL4.1 INSERT IGNORE INTO llx_product_lot (entity, fk_product, batch, eatby, sellby, datec, fk_user_creat, fk_user_modif) SELECT DISTINCT e.entity, ps.fk_product, pb.batch, pb.eatby, pb.sellby, pb.tms, e.fk_user_author, e.fk_user_author from llx_product_batch as pb, llx_product_stock as ps, llx_entrepot as e WHERE pb.fk_product_stock = ps.rowid AND ps.fk_entrepot = e.rowid + diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 75e2e27ac2e..a5549d33b25 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -92,6 +92,9 @@ delete from llx_product_extrafields where fk_object not in (select rowid from ll update llx_product_batch set batch = '' where batch = 'Non défini'; update llx_product_batch set batch = '' where batch = 'Non défini'; +update llx_stock_mouvement set batch = null where batch = 'Non défini'; +update llx_stock_mouvement set batch = null where batch = 'Non défini'; + DELETE FROM llx_product_lot WHERE fk_product NOT IN (select rowid from llx_product); DELETE FROM llx_product_stock WHERE fk_product NOT IN (select rowid from llx_product); DELETE FROM llx_product_stock WHERE reel = 0 AND rowid NOT IN (SELECT fk_product_stock FROM llx_product_batch as pb); From 480587c8263398aad02a1961892a2ce2ab122d45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Jun 2017 02:28:07 +0200 Subject: [PATCH 30/33] Fix travis errors --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8655b27d4ed..4c18c5caa3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ php: - '5.3' - '5.4' - '5.5' -- '5.6' +- '5.6.29' - '7.0' - nightly From 8bfda8d4eec675dc71ed34ca9d34aa02cfeefb57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Jun 2017 12:26:16 +0200 Subject: [PATCH 31/33] Code comment --- htdocs/api/class/api_access.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 407f94ac915..b2dcfefa49f 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -80,25 +80,25 @@ class DolibarrApiAccess implements iAuthenticate { dol_syslog($key.' - '.$val); }*/ - + // api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx $api_key = ''; - if (isset($_GET['api_key'])) + if (isset($_GET['api_key'])) { // TODO Add option to disable use of api key on url. Return errors if used. $api_key = $_GET['api_key']; // For backward compatibility } - if (isset($_GET['DOLAPIKEY'])) + if (isset($_GET['DOLAPIKEY'])) { // TODO Add option to disable use of api key on url. Return errors if used. $api_key = $_GET['DOLAPIKEY']; // With GET method } - if (isset($_SERVER['HTTP_DOLAPIKEY'])) + if (isset($_SERVER['HTTP_DOLAPIKEY'])) // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY { $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) } - - if ($api_key) + + if ($api_key) { $sql = "SELECT u.login, u.datec, u.api_key, "; $sql.= " u.tms as date_modification, u.entity"; From 63dcdc3a03f1a03915f39d06f21fbb0f27ee2f49 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Jun 2017 17:09:08 +0200 Subject: [PATCH 32/33] Fix API was loading definition of all APIs at each call. --- htdocs/api/class/api_login.class.php | 31 +-- htdocs/api/index.php | 223 ++++++++++-------- htdocs/core/lib/functions2.lib.php | 71 +++++- htdocs/societe/class/api_contacts.class.php | 3 + .../class/api_deprecated_thirdparty.class.php | 110 ++++----- htdocs/user/class/user.class.php | 7 +- 6 files changed, 272 insertions(+), 173 deletions(-) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 9b965e24c33..c6b71e8b25c 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -34,25 +34,25 @@ class Login /** * Login * - * Request the API token for a couple username / password. + * Request the API token for a couple username / password. * Using method POST is recommanded for security reasons (method GET is often logged by default by web servers with parameters so with login and pass into server log file). - * Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "api_key" into field at the top right of page (Note: "api_key" can be found/set on the user page). - * + * Both methods are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "api_key" into field at the top right of page (Note: "api_key" can be found/set on the user page). + * * @param string $login User login * @param string $password User password - * @param int $entity Entity (when multicompany module is used). Empty means 1=first company. + * @param string $entity Entity (when multicompany module is used). '' means 1=first company. * @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access) * @return array Response status and user token * * @throws RestException - * + * * @url GET / * @url POST / */ - public function index($login, $password, $entity=0, $reset=0) { + public function index($login, $password, $entity='', $reset=0) { global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; - + // Authentication mode if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'http,dolibarr'; @@ -62,6 +62,8 @@ class Login // Set authmode $authmode = explode(',', $dolibarr_main_authentication); + if ($entity == '') $entity=1; + include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; $login = checkLoginPassEntity($login, $password, $entity, $authmode); if (empty($login)) @@ -70,21 +72,21 @@ class Login } $token = 'failedtogenerateorgettoken'; - + $tmpuser=new User($this->db); - $tmpuser->fetch(0, $login); - + $tmpuser->fetch(0, $login, 0, 0, $entity); + // Renew the hash if (empty($tmpuser->api_key) || $reset) { // Generate token for user $token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1); - + // We store API token into database $sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql.= " SET api_key = '".$this->db->escape($token)."'"; $sql.= " WHERE login = '".$this->db->escape($login)."'"; - + dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log $result = $this->db->query($sql); if (!$result) @@ -96,13 +98,14 @@ class Login { $token = $tmpuser->api_key; } - + //return token return array( 'success' => array( 'code' => 200, 'token' => $token, - 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') + 'entity' => $tmpuser->entity, + 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); } diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 1e04590da14..7a99490a48f 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -21,9 +21,7 @@ * \defgroup api Module DolibarrApi * \brief API loader * Search files htdocs//class/api_.class.php - * \file htdocs/api/indexphp - * - * @todo User authentication with api_key + * \file htdocs/api/index.php */ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); @@ -79,110 +77,94 @@ $api->r->addAuthenticationClass('DolibarrApiAccess',''); // Define accepted mime types UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream'); -$listofapis = array(); -$modulesdir = dolGetModulesDirs(); -foreach ($modulesdir as $dir) +// Analyze URLs +// index.php/explorer do a redirect to index.php/explorer/ +// index.php/explorer/ called by swagger to build explorer page +// index.php/explorer/.../....png|.css|.js called by swagger for resources to build explorer page +// index.php/explorer/resources.json called by swagger to get list of all services +// index.php/explorer/resources.json/xxx called by swagger to get detail of services xxx +// index.php/xxx called by any REST client to run API + + +preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg); +// .../index.php/categories?sortfield=t.rowid&sortorder=ASC + + +// Call Explorer file for all APIs definitions +if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { - /* - * Search available module - */ - //dol_syslog("Scan directory ".$dir." for API modules"); + // Scan all API files to load them - $handle=@opendir(dol_osencode($dir)); - if (is_resource($handle)) + $listofapis = array(); + + $modulesdir = dolGetModulesDirs(); + foreach ($modulesdir as $dir) { - while (($file = readdir($handle))!==false) + // Search available module + dol_syslog("Scan directory ".$dir." for module descriptor to after search for API files"); + + $handle=@opendir(dol_osencode($dir)); + if (is_resource($handle)) { - if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i",$file,$reg)) + while (($file = readdir($handle))!==false) { - $module = strtolower($reg[1]); - $moduledirforclass = $module; - $moduleforperm = $module; - - if ($module == 'propale') { - $moduledirforclass = 'comm/propal'; - $moduleforperm='propal'; - } - elseif ($module == 'agenda') { - $moduledirforclass = 'comm/action'; - } - elseif ($module == 'adherent') { - $moduledirforclass = 'adherents'; - } - elseif ($module == 'banque') { - $moduledirforclass = 'compta/bank'; - } - elseif ($module == 'categorie') { - $moduledirforclass = 'categories'; - } - elseif ($module == 'facture') { - $moduledirforclass = 'compta/facture'; - } - elseif ($module == 'project') { - $moduledirforclass = 'projet'; - } - elseif ($module == 'task') { - $moduledirforclass = 'projet'; - } - elseif ($module == 'stock') { - $moduledirforclass = 'product/stock'; - } - elseif ($module == 'fournisseur') { - $moduledirforclass = 'fourn'; - } - //dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass); - - // Defined if module is enabled - $enabled=true; - if (empty($conf->$moduleforperm->enabled)) $enabled=false; - - if ($enabled) + if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i",$file,$reg)) { - /* - * If exists, load the API class for enable module - * - * Search files named api_.class.php into /htdocs//class directory - * - * @todo : use getElementProperties() function ? - */ - $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); + $module = strtolower($reg[1]); + $moduledirforclass = getModuleDirForApiClass($module); + $moduleforperm = $module; + if ($module == 'propale') { $moduleforperm='propal'; } - $handle_part=@opendir(dol_osencode($dir_part)); - if (is_resource($handle_part)) + //dol_syslog("Found module file ".$file." - module=".$module." - moduledirforclass=".$moduledirforclass); + + // Defined if module is enabled + $enabled=true; + if (empty($conf->$moduleforperm->enabled)) $enabled=false; + + if ($enabled) { - while (($file_searched = readdir($handle_part))!==false) - { - if ($file_searched == 'api_access.class.php') continue; + // If exists, load the API class for enable module + // Search files named api_.class.php into /htdocs//class directory + // @todo : use getElementProperties() function ? + $dir_part = dol_buildpath('/'.$moduledirforclass.'/class/'); - // Support of the deprecated API. - if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg)) + $handle_part=@opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) + { + while (($file_searched = readdir($handle_part))!==false) { - $classname = ucwords($reg[1]).'Api'; - require_once $dir_part.$file_searched; - if (class_exists($classname)) + if ($file_searched == 'api_access.class.php') continue; + + // Support of the deprecated API. + if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg)) { - //dol_syslog("Found deprecated API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); - $api->r->addAPIClass($classname, '/'); + $classname = ucwords($reg[1]).'Api'; + require_once $dir_part.$file_searched; + if (class_exists($classname)) + { + //dol_syslog("Found deprecated API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); + $api->r->addAPIClass($classname, '/'); + } + else + { + dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); + } } - else + elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg)) { - dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); - } - } - elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg)) - { - $classname = ucwords($reg[1]); - $classname = str_replace('_', '', $classname); - require_once $dir_part.$file_searched; - if (class_exists($classname)) - { - //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); - $listofapis[] = $classname; - } - else - { - dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); + $classname = ucwords($reg[1]); + $classname = str_replace('_', '', $classname); + require_once $dir_part.$file_searched; + if (class_exists($classname)) + { + //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); + $listofapis[] = $classname; + } + else + { + dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); + } } } } @@ -191,20 +173,61 @@ foreach ($modulesdir as $dir) } } } + + // Sort the classes before adding them to Restler. The Restler API Explorer + // shows the classes in the order they are added and it's a mess if they are not sorted. + sort($listofapis); + //var_dump($listofapis); + foreach ($listofapis as $classname) + { + $api->r->addAPIClass($classname); + } } -// Sort the classes before adding them to Restler. The Restler API Explorer -// shows the classes in the order they are added and it's a mess if they are -// not sorted. -sort($listofapis); -//var_dump($listofapis); -foreach ($listofapis as $classname) +// Call one APIs or one definition of an API +if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' && preg_match('/^\/resources.json\/(.+)$/', $reg[2], $regbis)))) { - $api->r->addAPIClass($classname); + $module = $reg[1]; + if ($module == 'explorer') // If we call page to explore details of a service + { + $module = $regbis[1]; + } + + // Load a dedicated API file + dol_syslog("Load a dedicated API file"); + + $module=strtolower($module); + $moduledirforclass = getModuleDirForApiClass($module); + + if (in_array($module, array('category','contact','customer','invoice','order','product','thirdparty','user'))) // Old Apis + { + $classfile = $module; + if ($module == 'customer') { $classfile = 'thirdparty'; } + if ($module == 'order') { $classfile = 'commande'; } + $dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_deprecated_'.$classfile.'.class.php'); + $classname=ucwords($module); + if ($module == 'customer') { $classname='Thirdparty'; } + if ($module == 'order') { $classname='Commande'; } + //var_dump($classfile);var_dump($classname);exit; + + require_once $dir_part_file; + if (class_exists($classname.'Api')) $api->r->addAPIClass($classname.'Api', '/'); + } + else + { + $classfile = str_replace('_', '', $module); + if ($module == 'supplierinvoices') $classfile = 'supplier_invoices'; + $dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php'); + $classname=ucwords($module); + + require_once $dir_part_file; + if (class_exists($classname)) $api->r->addAPIClass($classname); + } } // TODO If not found, redirect to explorer //var_dump($api); +//exit; // Call API (we suppose we found it) $api->r->handle(); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index b68d7706e43..72f27a16602 100755 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2121,8 +2121,8 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) * Applies the Cartesian product algorithm to an array * Source: http://stackoverflow.com/a/15973172 * - * @param array $input Array of products - * @return array Array of combinations + * @param array $input Array of products + * @return array Array of combinations */ function cartesianArray(array $input) { // filter out empty values @@ -2145,3 +2145,70 @@ function cartesianArray(array $input) { return $result; } + + +/** + * Get name of directory where the api_...class.php file is stored + * + * @param string $module Module name + * @return string Directory name + */ +function getModuleDirForApiClass($module) +{ + $moduledirforclass=$module; + + if (in_array($module, array('login', 'access', 'status', 'documents'))) { + $moduledirforclass = 'api'; + } + if (preg_match('/^dictionary/', $module)) { + $moduledirforclass = 'api'; + } + + if ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') { + $moduledirforclass = 'societe'; + } + if ($module == 'propale' || $module == 'proposals') { + $moduledirforclass = 'comm/propal'; + } + elseif ($module == 'agenda' || $module == 'agendaevents') { + $moduledirforclass = 'comm/action'; + } + elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') { + $moduledirforclass = 'adherents'; + } + elseif ($module == 'banque' || $module == 'bankaccounts') { + $moduledirforclass = 'compta/bank'; + } + elseif ($module == 'category' || $module == 'categorie') { + $moduledirforclass = 'categories'; + } + elseif ($module == 'order' || $module == 'orders') { + $moduledirforclass = 'commande'; + } + elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') { + $moduledirforclass = 'compta/facture'; + } + elseif ($module == 'products') { + $moduledirforclass = 'product'; + } + elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') { + $moduledirforclass = 'projet'; + } + elseif ($module == 'task') { + $moduledirforclass = 'projet'; + } + elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') { + $moduledirforclass = 'product/stock'; + } + elseif ($module == 'fournisseur' || $module == 'supplierinvoices') { + $moduledirforclass = 'fourn'; + } + elseif ($module == 'expensereports') { + $moduledirforclass = 'expensereport'; + } + elseif ($module == 'users') { + $moduledirforclass = 'user'; + } + + return $moduledirforclass; +} diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index f136d6895b2..fcfdf4ad084 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -47,6 +47,9 @@ class Contacts extends DolibarrApi { global $db, $conf; $this->db = $db; + + include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $this->contact = new Contact($this->db); } diff --git a/htdocs/societe/class/api_deprecated_thirdparty.class.php b/htdocs/societe/class/api_deprecated_thirdparty.class.php index bca74ba8ae2..b335fb35183 100644 --- a/htdocs/societe/class/api_deprecated_thirdparty.class.php +++ b/htdocs/societe/class/api_deprecated_thirdparty.class.php @@ -22,7 +22,7 @@ * API class for thirdparty object * * @smart-auto-routing false - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} * @deprecated Use Thirdparties instead (defined in api_thirdparties.class.php) */ @@ -30,7 +30,7 @@ class ThirdpartyApi 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( 'name' @@ -49,15 +49,17 @@ class ThirdpartyApi extends DolibarrApi * Constructor Warning: Deprecated * * @url thirdparty/ - * + * */ function __construct() { + include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; + global $db, $conf; $this->db = $db; $this->company = new Societe($this->db); $this->customer = new Client($this->db); - + if (! empty($conf->global->SOCIETE_MAIL_REQUIRED)) { static::$FIELDS[] = 'email'; } @@ -70,21 +72,21 @@ class ThirdpartyApi extends DolibarrApi * * @param int $id ID of customer * @return array|mixed data without useless information - * + * * @url GET customer/{id} * @throws RestException */ function getCustomer($id) - { + { if(! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - + $result = $this->customer->fetch($id); if( ! $result ) { throw new RestException(404, 'Customer not found'); } - + if( ! DolibarrApi::_checkAccessToResource('societe',$this->customer->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -94,11 +96,11 @@ class ThirdpartyApi extends DolibarrApi /** * Search customer by email Warning: Deprecated - * + * * @param string $email email id * * @return object client with given email - * + * * @url GET customer/byemail/{email} */ function getByEmail($email) { @@ -117,21 +119,21 @@ class ThirdpartyApi extends DolibarrApi * * @param int $id ID of thirdparty * @return array|mixed data without useless information - * + * * @url GET thirdparty/{id} * @throws RestException */ function get($id) - { + { if(! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - + $result = $this->company->fetch($id); if( ! $result ) { throw new RestException(404, 'Thirdparty not found'); } - + if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -141,10 +143,10 @@ class ThirdpartyApi extends DolibarrApi /** * List thirdparties Warning: Deprecated - * + * * Get a list of thirdparties - * - * @param int $mode Set to 1 to show only customers + * + * @param int $mode Set to 1 to show only customers * Set to 2 to show only prospects * Set to 3 to show only those are not customer neither prospect * @param Text $email Search by email filter @@ -153,17 +155,17 @@ class ThirdpartyApi extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @return array Array of thirdparty objects - * + * * @url GET /thirdparty/list * */ function getList($mode=0, $email=NULL, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { global $db, $conf; - + $obj_ret = array(); - + $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; - + // If the internal user must only see his customers, force searching by him $search_sale = 0; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; @@ -171,7 +173,7 @@ class ThirdpartyApi extends DolibarrApi $sql = "SELECT s.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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."societe as s"; - + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; $sql.= " WHERE s.fk_stcomm = st.id"; @@ -183,13 +185,13 @@ class ThirdpartyApi extends DolibarrApi if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - + // Insert sale filter if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } - + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -233,47 +235,47 @@ class ThirdpartyApi extends DolibarrApi } return $obj_ret; } - + /** * Show customers Warning: Deprecated - * + * * @return array List of customers - * + * * @url GET /thirdparty/list/customers * @url GET /customer/list */ function getListCustomers() { return $this->getList(1); } - + /** * Show prospects Warning: Deprecated - * + * * @return array List of prospects - * + * * @url GET /thirdparty/list/prospects */ function getListProspects() { return $this->getList(2); } - + /** * Show other Warning: Deprecated - * + * * @return array List of thirpdparties who are not customer neither prospect - * + * * @url GET /thirdparty/list/others */ function getListOthers() { return $this->getList(3); } - + /** * Create thirdparty object Warning: Deprecated * * @param array $request_data Request datas * @return int ID of thirdparty - * + * * @url POST thirdparty/ */ function post($request_data = NULL) @@ -283,7 +285,7 @@ class ThirdpartyApi extends DolibarrApi } // Check mandatory fields $result = $this->_validate($request_data); - + foreach($request_data as $field => $value) { $this->company->$field = $value; } @@ -296,7 +298,7 @@ class ThirdpartyApi extends DolibarrApi * * @param array $request_data Request datas * @return int ID of thirdparty - * + * * @url POST customer/ */ function postCustomer($request_data) { @@ -309,9 +311,9 @@ class ThirdpartyApi extends DolibarrApi * Update thirdparty Warning: Deprecated * * @param int $id Id of thirdparty to update - * @param array $request_data Datas - * @return int - * + * @param array $request_data Datas + * @return int + * * @url PUT thirdparty/{id} */ function put($id, $request_data = NULL) @@ -319,12 +321,12 @@ class ThirdpartyApi extends DolibarrApi if(! DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - + $result = $this->company->fetch($id); if( ! $result ) { throw new RestException(404, 'Thirdparty not found'); } - + if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -333,19 +335,19 @@ class ThirdpartyApi extends DolibarrApi if ($field == 'id') continue; $this->company->$field = $value; } - + if($this->company->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get ($id); - + return false; } /** * Update customer Warning: Deprecated * * @param int $id Id of thirdparty to update - * @param array $request_data Datas - * @return int - * + * @param array $request_data Datas + * @return int + * * @url PUT customer/{id} */ function putClient($id, $request_data = NULL) { @@ -363,19 +365,19 @@ class ThirdpartyApi extends DolibarrApi foreach($request_data as $field => $value) { $this->customer->$field = $value; } - + if($this->customer->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get ($id); - + return false; } - + /** * Delete thirdparty Warning: Deprecated * * @param int $id Thirparty ID * @return integer - * + * * @url DELETE thirdparty/{id} * @url DELETE customer/{id} */ @@ -393,13 +395,13 @@ class ThirdpartyApi extends DolibarrApi } return $this->company->delete($id); } - + /** * Validate fields before create or update object - * + * * @param array $data Datas to validate * @return array - * + * * @throws RestException */ function _validate($data) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6b39158a87b..577a6389b6f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -221,7 +221,7 @@ class User extends CommonObject if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database else - $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; + $sql.= " WHERE u.entity IN (0, ".($entity!=''?$entity:$conf->entity).")"; // search in entity provided in parameter } if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba @@ -236,6 +236,7 @@ class User extends CommonObject { $sql.= " AND u.rowid = ".$id; } + $sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities $result = $this->db->query($sql); if ($result) @@ -310,8 +311,8 @@ class User extends CommonObject $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - // Protection when module multicompany was set, admin was set to first entity and the module disabled, - // then this admin user must be admin for all entities. + // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, + // in such case, this admin user must be admin for ALL entities. if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; // Retreive all extrafield for thirdparty From 0b7c768f2997fb77047ddefb52af323820b2c690 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Jun 2017 18:18:17 +0200 Subject: [PATCH 33/33] FIX Usage of production mode with REST Api. --- htdocs/api/class/api.class.php | 17 +++--- htdocs/api/index.php | 55 +++++++++++++------ .../modulebuilder/template/myobject_list.php | 2 +- 3 files changed, 48 insertions(+), 26 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 190e24d326c..40e00d01ffd 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -42,10 +42,11 @@ class DolibarrApi /** * Constructor * - * @param DoliDb $db Database handler - * @param string $cachedir Cache dir + * @param DoliDb $db Database handler + * @param string $cachedir Cache dir + * @param boolean $refreshCache Update cache */ - function __construct($db, $cachedir='') + function __construct($db, $cachedir='', $refreshCache=false) { global $conf; @@ -54,7 +55,7 @@ class DolibarrApi $this->db = $db; $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); - $this->r = new Restler($production_mode); + $this->r = new Restler($production_mode, $refreshCache); $this->r->setAPIVersion(1); } @@ -66,7 +67,7 @@ class DolibarrApi * * @return array */ - /* Disabled, most APIs does not share same signature for method index + /* Disabled, most APIs does not share same signature for method index function index() { return array( @@ -93,9 +94,9 @@ class DolibarrApi unset($object->linkedObjects); unset($object->lines); // should be ->lines - + unset($object->fields); - + unset($object->oldline); unset($object->error); @@ -175,7 +176,7 @@ class DolibarrApi * @throws RestException */ static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') { - + // Features/modules to check $featuresarray = array($resource); if (preg_match('/&/', $resource)) { diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 7a99490a48f..0e54d0cb8af 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -24,8 +24,18 @@ * \file htdocs/api/index.php */ -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); -if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",'1'); +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + $res=0; if (! $res && file_exists("../main.inc.php")) $res=include '../main.inc.php'; @@ -65,17 +75,6 @@ if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($ } -$api = new DolibarrApi($db); - -// Enable the Restler API Explorer. -// See https://github.com/Luracast/Restler-API-Explorer for more info. -$api->r->addAPIClass('Luracast\\Restler\\Explorer'); - -$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); -$api->r->addAuthenticationClass('DolibarrApiAccess',''); - -// Define accepted mime types -UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream'); // Analyze URLs @@ -91,6 +90,29 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg); // .../index.php/categories?sortfield=t.rowid&sortorder=ASC +// Set the flag to say to refresh (when we reload the explorer, production must be for API call only) +$refreshcache=false; +if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) +{ + $refreshcache=true; +} + + +$api = new DolibarrApi($db, '', $refreshcache); +//var_dump($api->r->apiVersionMap); + +// Enable the Restler API Explorer. +// See https://github.com/Luracast/Restler-API-Explorer for more info. +$api->r->addAPIClass('Luracast\\Restler\\Explorer'); + +$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); +$api->r->addAuthenticationClass('DolibarrApiAccess',''); + +// Define accepted mime types +UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream'); + + + // Call Explorer file for all APIs definitions if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { @@ -174,10 +196,9 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' | } } - // Sort the classes before adding them to Restler. The Restler API Explorer - // shows the classes in the order they are added and it's a mess if they are not sorted. + // Sort the classes before adding them to Restler. + // The Restler API Explorer shows the classes in the order they are added and it's a mess if they are not sorted. sort($listofapis); - //var_dump($listofapis); foreach ($listofapis as $classname) { $api->r->addAPIClass($classname); @@ -226,7 +247,7 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' } // TODO If not found, redirect to explorer -//var_dump($api); +//var_dump($api->r->apiVersionMap); //exit; // Call API (we suppose we found it) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 2cfc4f293fe..a578a683131 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -32,7 +32,7 @@ //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) // Load Dolibarr environment