From da17e6e676de53dd5dafcc2c2746aa7b136e1f36 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 10 Mar 2016 23:52:06 +0100 Subject: [PATCH 01/46] New add sync with api to create/update all rates --- htdocs/admin/multicurrency.php | 103 ++++++++++++++++-- .../class/multicurrency.class.php | 11 ++ 2 files changed, 106 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index b1ad347d8b7..afb396a0217 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; + // Translations $langs->load("multicurrency"); @@ -41,10 +42,17 @@ if (! $user->admin) { // Parameters $action = GETPOST('action', 'alpha'); - +$sync_response = GETPOST('sync_response'); /* * Actions */ +if (!empty($sync_response)) +{ + $sync_response = json_decode($sync_response); + MultiCurrency::syncRates($sync_response); + exit; +} + if (preg_match('/set_(.*)/',$action,$reg)) { $code=$reg[1]; @@ -64,7 +72,7 @@ if (preg_match('/del_(.*)/',$action,$reg)) $code=$reg[1]; if (dolibarr_del_const($db, $code, 0) > 0) { - Header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"]); exit; } else @@ -224,8 +232,8 @@ print ' '; print ''; print '
'; print ''; -print ''; -print ' '; +print ''; +print ' '; print ''; print '
'; print ''; @@ -244,16 +252,95 @@ print ''; print ''; print ''; - -print ''; - print '
'; + +print ''; + + print ''; print ''; print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; $var=!$var; print ''; diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index fd6da3816ea..c78e7784ad1 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -520,6 +520,17 @@ class MultiCurrency extends CommonObject return false; } + + /** + * Sync rates from api + * + * @param array $response array of reponse from api to sync dolibarr rates + */ + public static function syncRates($response) + { + $TRate = $response['quotes']; + $timestamp = $response['timestamp']; + } } /** From 3134af5013984bb356716e9254891788f4312ef4 Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 11 Mar 2016 23:42:02 +0100 Subject: [PATCH 02/46] Fix sync with currencylayer --- htdocs/admin/multicurrency.php | 84 ++++++++++------ .../class/multicurrency.class.php | 95 +++++++++++++++++-- 2 files changed, 142 insertions(+), 37 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index afb396a0217..e4f4fc34301 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -225,32 +225,6 @@ print '' print ''; print ''; -$var=!$var; -print ''; -print ''; -print ''; -print ''; - -$var=!$var; -print ''; -print ''; -print ''; -print ''; - print '
'.$langs->trans("Currencies").' '.$langs->trans("Rate").''.$langs->trans("Rate").' 
'.$langs->transnoentitiesnoconv("multicurrency_appId").' '; -print '
'; -print ''; -print ''; -print ' '; -print ''; -print '
'; -print '
'.$langs->transnoentitiesnoconv("multicurrency_currencyFromToRate").' '; -print '
'; -print ''; -print ''; -print ' '; // CURRENCY_BASE - CURRENCY_ENTITY - ID_ENTITY -print ''; -print '
'; -print '
'; print '
'; @@ -306,7 +280,8 @@ print ''; +$var=false; +print ''; +print ''; +print ''."\n"; +print ''; +print ''."\n"; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +print '
'.$langs->trans("CurrencyLayerAccount").' '.$langs->trans("Value").' 
'.$langs->transnoentitiesnoconv("multicurrency_appId").' '; +print '
'; +print ''; +print ''; +print ' '; +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").' '; +print '
'; +print ''; +print ''; +print ' '; // Default: USD +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").' '; +print '
'; +print ''; +print ''; +print ' '; // Example: EUR +print ''; +print '
'; +print '
'; +print '
'; print ''; print ''; print ''."\n"; print ''; -print ''."\n"; +print ''."\n"; $var=!$var; print ''; diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index c78e7784ad1..36c392b5930 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -208,7 +208,7 @@ class MultiCurrency extends CommonObject $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR); - return - 1; + return -1; } } @@ -383,7 +383,7 @@ class MultiCurrency extends CommonObject * * @param double $rate rate value * - * @return bool false if KO, true if OK + * @return int -1 if KO, 1 if OK */ public function addRate($rate) { @@ -402,6 +402,40 @@ class MultiCurrency extends CommonObject } } + /** + * Try get label of code in llx_currency then add rate + * + * @param string $code currency code + * @param double $rate new rate + * + * @return int -1 if KO, 1 if OK, 2 if label found and OK + */ + function addRateFromDolibarr($code, $rate) + { + global $db, $user; + + $currency = new MultiCurrency($db); + $currency->code = $code; + $currency->name = $code; + + $sql = 'SELECT label FROM '.MAIN_DB_PREFIX.'c_currencies WHERE code_iso = "'.$db->escape($code).'"'; + $resql = $db->query($sql); + if ($resql && ($line = $db->fetch_object($resql))) + { + $currency->name = $line->label; + } + + if ($currency->create($user) > 0) + { + $currency->addRate($rate); + + if (!empty($line)) return 2; + else return 1; + } + + return -1; + } + /** * Update rate in database * @@ -520,7 +554,37 @@ class MultiCurrency extends CommonObject return false; } - + + /** + * With free account we can't set source then recalcul all rates to force another source + * + * @param stdClass $TRate Object containing all currencies rates + * @return -1 if KO, 0 if nothing, 1 if OK + */ + public static function recalculRates(&$TRate) + { + global $conf; + + if (!empty($conf->global->MULTICURRENCY_ALTERNATE_SOURCE)) + { + $alternate_source = 'USD'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE; + if (!empty($TRate->{$alternate_source})) + { + $coef = $TRate->USDUSD / $TRate->{$alternate_source}; + foreach ($TRate as $attr => &$rate) + { + $rate *= $coef; + } + + return 1; + } + + return -1; // Alternate souce not found + } + + return 0; // Nothing to do + } + /** * Sync rates from api * @@ -528,8 +592,27 @@ class MultiCurrency extends CommonObject */ public static function syncRates($response) { - $TRate = $response['quotes']; - $timestamp = $response['timestamp']; + global $db,$conf; + + $TRate = $response->quotes; + $timestamp = $response->timestamp; + + if (self::recalculRates($TRate) >= 0) + { + foreach ($TRate as $currency_code => $rate) + { + $code = substr($currency_code, 3, 3); + $obj = new MultiCurrency($db); + if ($obj->fetch(null, $code) > 0) + { + $obj->updateRate($rate); + } + else + { + self::addRateFromDolibarr($code, $rate); + } + } + } } } @@ -724,7 +807,7 @@ class CurrencyRate extends CommonObjectLine if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); From 0a533660b8834d83a5738e42c6da4e33c4bfdddb Mon Sep 17 00:00:00 2001 From: phf Date: Sat, 12 Mar 2016 21:17:09 +0100 Subject: [PATCH 03/46] Fix travis phpcs --- htdocs/compta/prelevement/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 33d02bff05b..c2607d5b83d 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -65,7 +65,7 @@ if ($action == 'create') $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET); if ($result < 0) { - setEventMessages($bprev->error , $bprev->errors, 'errors'); + setEventMessages($bprev->error, $bprev->errors, 'errors'); } if ($result == 0) { From 661ee72d55a377932068266d271a7e6c88f6ddea Mon Sep 17 00:00:00 2001 From: phf Date: Sun, 20 Mar 2016 15:17:30 +0100 Subject: [PATCH 04/46] UPDATE move ajax request in js file and call a new php file to update all rates --- htdocs/admin/multicurrency.php | 91 +----------------- htdocs/multicurrency/ajax/updaterates.php | 35 +++++++ htdocs/multicurrency/js/currencylayer.js.php | 98 ++++++++++++++++++++ 3 files changed, 136 insertions(+), 88 deletions(-) create mode 100644 htdocs/multicurrency/ajax/updaterates.php create mode 100644 htdocs/multicurrency/js/currencylayer.js.php diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index e4f4fc34301..235b16ba100 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -42,16 +42,10 @@ if (! $user->admin) { // Parameters $action = GETPOST('action', 'alpha'); -$sync_response = GETPOST('sync_response'); /* * Actions */ -if (!empty($sync_response)) -{ - $sync_response = json_decode($sync_response); - MultiCurrency::syncRates($sync_response); - exit; -} + if (preg_match('/set_(.*)/',$action,$reg)) { @@ -145,8 +139,9 @@ if ($resql) */ $page_name = "MultiCurrency"; +$morejs = array('/multicurrency/js/currencylayer.js.php'); -llxHeader('', $langs->trans($page_name)); +llxHeader('', $langs->trans($page_name), '', '', '', '', $morejs); // Subheader $linkback = '' @@ -228,86 +223,6 @@ print ''; print '
'.$langs->trans("Currencies").' '.$langs->trans("Rate").' '.$langs->trans("Rate").'
'; print '
'; -print ''; - $var=false; print ''; print ''; diff --git a/htdocs/multicurrency/ajax/updaterates.php b/htdocs/multicurrency/ajax/updaterates.php new file mode 100644 index 00000000000..663e68a647c --- /dev/null +++ b/htdocs/multicurrency/ajax/updaterates.php @@ -0,0 +1,35 @@ + + * Copyright (C) 2016 Pierre-Henry Favre + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; + +$sync_response = GETPOST('sync_response'); + +if (!empty($sync_response)) +{ + $sync_response = json_decode($sync_response); + MultiCurrency::syncRates($sync_response); +} \ No newline at end of file diff --git a/htdocs/multicurrency/js/currencylayer.js.php b/htdocs/multicurrency/js/currencylayer.js.php new file mode 100644 index 00000000000..0b563aae266 --- /dev/null +++ b/htdocs/multicurrency/js/currencylayer.js.php @@ -0,0 +1,98 @@ + + * Copyright (C) 2016 Pierre-Henry Favre + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +include '../../main.inc.php'; +$langs->load('errors'); + +?> + +function getXMLHttpRequest() +{ + var xhr = null; + if (window.XMLHttpRequest || window.ActiveXObject) + { + if (window.ActiveXObject) + { + try + { + xhr = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch(e) + { + xhr = new ActiveXObject("Microsoft.XMLHTTP"); + } + } + else + { + xhr = new XMLHttpRequest(); + } + } + else + { + if (typeof $ !== "undefined") $.jnotify("transnoentitiesnoconv('multicurrency_error_browser_incompatible'); ?>", "error"); + else alert("transnoentitiesnoconv('multicurrency_error_browser_incompatible'); ?>"); + + return null; + } + + return xhr; +} + +function request(url, callback) +{ + var xhr = getXMLHttpRequest(); + xhr.onreadystatechange = function() + { + if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) + { + callback(xhr.responseText); + } + + }; + + xhr.open("GET", url, true); + xhr.send(null); +} + +function syncronize_rates() +{ + document.getElementById("bt_sync").disabled = true; + var url_sync = "http://apilayer.net/api/live?access_key=global->MULTICURRENCY_APP_ID; ?>&format=1global->MULTICURRENCY_APP_SOURCE)) echo '&source='.$conf->global->MULTICURRENCY_APP_SOURCE; ?>"; + request(url_sync, update_rates); +} + +function update_rates(responseText) +{ + var response = JSON.parse(responseText); + if (response.success) + { + var url = "/multicurrency/ajax/updaterates.php?sync_response="+JSON.stringify(response); + request(url, reloadpage); + } + else + { + if (typeof $ !== "undefined") $.jnotify("transnoentitiesnoconv('multicurrency_syncronize_error'); ?>: "+response.error.info, "error"); + else alert("transnoentitiesnoconv('multicurrency_syncronize_error'); ?>: "+response.error.info); + } +} + +function reloadpage(responseText) +{ + document.getElementById("bt_sync").disabled = false; + window.location.href = window.location.pathname; +} From b8f3264f60b7174674746b3ea9499e64d7c14162 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 29 Mar 2016 11:37:35 +0200 Subject: [PATCH 05/46] FIX: dont retrieve new buying price on margin display --- htdocs/margin/lib/margins.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index 1f904c44f2d..fa33db181ec 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -104,7 +104,7 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta $marge_tx_ret=''; $marque_tx_ret=''; - if ($fk_pa > 0) { + if ($fk_pa > 0 && empty($paht)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $product = new ProductFournisseur($db); if ($product->fetch_product_fournisseur_price($fk_pa)) From 024f55d46182eb5d10035161fb396d687d2d0376 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 29 Mar 2016 12:02:36 +0200 Subject: [PATCH 06/46] FIX: systematic rounding causes prices to be updated without reason --- htdocs/core/tpl/objectline_create.tpl.php | 6 ------ htdocs/core/tpl/objectline_edit.tpl.php | 6 ------ 2 files changed, 12 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 108fb8e1339..feeb61a11e4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -320,18 +320,12 @@ if (! empty($usemargins) && $user->rights->margins->creer) jQuery(document).ready(function() { global->DISPLAY_MARGIN_RATES)) { ?> - $('#addline').click(function (e) { - return checkFreeLine(e, "np_marginRate"); - }); $("input[name='np_marginRate']:first").blur(function(e) { return checkFreeLine(e, "np_marginRate"); }); global->DISPLAY_MARK_RATES)) { ?> - $('#addline').click(function (e) { - return checkFreeLine(e, "np_markRate"); - }); $("input[name='np_markRate']:first").blur(function(e) { return checkFreeLine(e, "np_markRate"); }); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index bb75b007524..a9f86f3123c 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -247,9 +247,6 @@ if (! empty($conf->margin->enabled)) if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?> - $('#savelinebutton').click(function (e) { - return checkEditLine(e, "np_marginRate"); - }); $("input[name='np_marginRate']:first").blur(function(e) { return checkEditLine(e, "np_marginRate"); }); @@ -258,9 +255,6 @@ if (! empty($conf->margin->enabled)) if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?> - $('#savelinebutton').click(function (e) { - return checkEditLine(e, "np_markRate"); - }); $("input[name='np_markRate']:first").blur(function(e) { return checkEditLine(e, "np_markRate"); }); From 1f723cb8d0b15e922e36532cedf164ed5b6a655d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 7 Apr 2016 14:16:10 +0200 Subject: [PATCH 07/46] FIX : Template email must take care of positino column --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a815875dc52..97a7434fd02 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -859,13 +859,13 @@ class FormMail extends Form { $ret=array(); - $sql = "SELECT rowid, label, topic, content, lang"; + $sql = "SELECT rowid, label, topic, content, lang, position"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; $sql.= " AND entity IN (".getEntity("c_email_templates").")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - $sql.= $this->db->order("lang,label","ASC"); + $sql.= $this->db->order("position,lang,label","ASC"); //print $sql; $resql = $this->db->query($sql); From 9d6efde9357d5025745206730651797fb4615862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 7 Apr 2016 17:12:06 +0200 Subject: [PATCH 08/46] Prevent sentry logging error with 3.9 update Since we don't ship the required libraries anymore, if the module had been enabled before upgrade, the code was failing making Dolibarr totally unusable. Mitigated the issue by disabling sentry logging if the required libraries are unavailable. --- htdocs/core/modules/syslog/mod_syslog_sentry.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/syslog/mod_syslog_sentry.php b/htdocs/core/modules/syslog/mod_syslog_sentry.php index afea1a36375..a159a5edf2f 100644 --- a/htdocs/core/modules/syslog/mod_syslog_sentry.php +++ b/htdocs/core/modules/syslog/mod_syslog_sentry.php @@ -145,6 +145,10 @@ class mod_syslog_sentry extends LogHandler implements LogHandlerInterface */ public function export($content) { + if (! $this->isActive()) { + return; + } + global $conf; $dsn = $conf->global->SYSLOG_SENTRY_DSN; $client = new Raven_Client( From eb7bba956805d9b3e582e96fc688c056a1472050 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 15:41:01 +0200 Subject: [PATCH 09/46] Fix translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e621d98641c..069ced7854e 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1494,7 +1494,7 @@ FCKeditorForProduct=WYSIWIG creation/edition of products/services description an FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formating when building PDF files. FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing) FCKeditorForUserSignature=WYSIWIG creation/edition of user signature -FCKeditorForMail=WYSIWIG creation/edition for all mail (except Outils->eMailing) +FCKeditorForMail=WYSIWIG creation/edition for all mail (except Tools->eMailing) ##### OSCommerce 1 ##### OSCommerceErrorConnectOkButWrongDatabase=Connection succeeded but database doesn't look to be an OSCommerce database (Key %s not found in table %s). OSCommerceTestOk=Connection to server '%s' on database '%s' with user '%s' successfull. From 5753f217451b33a589feab210322e81f81cc9f56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 11:42:02 +0200 Subject: [PATCH 10/46] Missing translations --- htdocs/langs/en_US/agenda.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index cb7959a0901..d8747b74fe6 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -62,6 +62,9 @@ SupplierInvoiceSentByEMail=Supplier invoice %s sent by EMail ShippingSentByEMail=Shipment %s sent by EMail ShippingValidated= Shipment %s validated InterventionSentByEMail=Intervention %s sent by EMail +ProposalDeleted=Proposal deleted +OrderDeleted=Order deleted +InvoiceDeleted=Invoice deleted NewCompanyToDolibarr= Third party created DateActionPlannedStart= Planned start date DateActionPlannedEnd= Planned end date From 80caf58866d5de31f39d99d46d3b3155cea65134 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 19:16:40 +0200 Subject: [PATCH 11/46] FIX Default vat is not set correctly when an error occured and we use VAT identified by a code. --- htdocs/core/class/html.form.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c925a587b33..9a4fb17fa9c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4013,11 +4013,18 @@ class Form $return=''; - // Define defaultnpr and defaultttx + // Define defaultnpr, defaultttx and defaultcode $defaultnpr=($info_bits & 0x01); $defaultnpr=(preg_match('/\*/',$selectedrate) ? 1 : $defaultnpr); $defaulttx=str_replace('*','',$selectedrate); - + $defaultcode=''; + if (preg_match('/\s*\((.*)\)/', $defaulttx, $reg)) + { + $defaultcode=$reg[1]; + $defaulttx=preg_replace('/\s*\(.*\)/','',$defaulttx); + } + //var_dump($defaulttx.'-'.$defaultnpr.'-'.$defaultcode); + // Check parameters if (is_object($societe_vendeuse) && ! $societe_vendeuse->country_code) { @@ -4113,9 +4120,13 @@ class Form $return.= $rate['nprtva'] ? '*': ''; if ($addcode && $rate['code']) $return.=' ('.$rate['code'].')'; $return.= '"'; - if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) + if ($defaultcode) { - $return.= ' selected'; + if ($defaultcode == $rate['code']) $return.= ' selected'; + } + elseif ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) + { + $return.= ' selected'; } $return.= '>'.vatrate($rate['libtva']); //$return.=($rate['code']?' '.$rate['code']:''); From daa1aed3633ead45c650d16bfade6ca30075f21c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 19:31:18 +0200 Subject: [PATCH 12/46] Bad placeholder --- htdocs/societe/soc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 52f30317a3e..cb4f65abeed 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1885,7 +1885,7 @@ else 'name' => 'soc_origin', 'label' => $langs->trans('MergeOriginThirdparty'), 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 1, 0, 0, array(), 0, 'minwidth200') + 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') ) ); From f90cffd74ab07245968688514f0e7fd63040a71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 9 Apr 2016 15:42:53 +0200 Subject: [PATCH 13/46] Update nusoap.php re-establish user-agent --- htdocs/includes/nusoap/lib/nusoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/nusoap/lib/nusoap.php b/htdocs/includes/nusoap/lib/nusoap.php index 403d74b13e9..6defe0e6004 100644 --- a/htdocs/includes/nusoap/lib/nusoap.php +++ b/htdocs/includes/nusoap/lib/nusoap.php @@ -2217,7 +2217,7 @@ class soap_transport_http extends nusoap_base { } $this->use_curl = $use_curl; preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); - if (isset($rev[1])) $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); + $this->setHeader('User-Agent', $this->title.'/'.$this->version.(isset($rev[1])?' ('.$rev[1].')':'')); } /** From a33472942d22e7c6829cc8592fd86e9311192f9a Mon Sep 17 00:00:00 2001 From: phf Date: Sat, 9 Apr 2016 22:12:33 +0200 Subject: [PATCH 14/46] Fix synchronize rates for multicurrency module --- htdocs/admin/multicurrency.php | 48 +++++++++- htdocs/multicurrency/ajax/updaterates.php | 35 ------- htdocs/multicurrency/js/currencylayer.js.php | 98 -------------------- 3 files changed, 44 insertions(+), 137 deletions(-) delete mode 100644 htdocs/multicurrency/ajax/updaterates.php delete mode 100644 htdocs/multicurrency/js/currencylayer.js.php diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 235b16ba100..e09347099de 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -119,6 +119,21 @@ elseif ($action == 'update_currency') } } } +elseif ($action == 'synchronize') +{ + $response = GETPOST('response'); + $response = json_decode($response); + + if ($response->success) + { + MultiCurrency::syncRates($response); + } + else + { + setEventMessages($langs->trans('multicurrency_syncronize_error', $reponse->error->info), null, 'errors'); + } +} + $TCurrency = array(); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity; @@ -139,9 +154,7 @@ if ($resql) */ $page_name = "MultiCurrency"; -$morejs = array('/multicurrency/js/currencylayer.js.php'); - -llxHeader('', $langs->trans($page_name), '', '', '', '', $morejs); +llxHeader('', $langs->trans($page_name)); // Subheader $linkback = '' @@ -228,7 +241,14 @@ print '
'; print ''; print ''."\n"; print ''; -print ''."\n"; +print ''; + $var=!$var; print ''; @@ -311,6 +331,26 @@ foreach ($TCurrency as &$currency) print '
'.$langs->trans("CurrencyLayerAccount").' '.$langs->trans("Value").' '; +print '
'; +print ''; +print ''; +print $langs->trans("Value").' '; +print '
'; +print '
'; + + +print ' + +'; + llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/multicurrency/ajax/updaterates.php b/htdocs/multicurrency/ajax/updaterates.php deleted file mode 100644 index 663e68a647c..00000000000 --- a/htdocs/multicurrency/ajax/updaterates.php +++ /dev/null @@ -1,35 +0,0 @@ - - * Copyright (C) 2016 Pierre-Henry Favre - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; - -$sync_response = GETPOST('sync_response'); - -if (!empty($sync_response)) -{ - $sync_response = json_decode($sync_response); - MultiCurrency::syncRates($sync_response); -} \ No newline at end of file diff --git a/htdocs/multicurrency/js/currencylayer.js.php b/htdocs/multicurrency/js/currencylayer.js.php deleted file mode 100644 index 0b563aae266..00000000000 --- a/htdocs/multicurrency/js/currencylayer.js.php +++ /dev/null @@ -1,98 +0,0 @@ - - * Copyright (C) 2016 Pierre-Henry Favre - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -include '../../main.inc.php'; -$langs->load('errors'); - -?> - -function getXMLHttpRequest() -{ - var xhr = null; - if (window.XMLHttpRequest || window.ActiveXObject) - { - if (window.ActiveXObject) - { - try - { - xhr = new ActiveXObject("Msxml2.XMLHTTP"); - } - catch(e) - { - xhr = new ActiveXObject("Microsoft.XMLHTTP"); - } - } - else - { - xhr = new XMLHttpRequest(); - } - } - else - { - if (typeof $ !== "undefined") $.jnotify("transnoentitiesnoconv('multicurrency_error_browser_incompatible'); ?>", "error"); - else alert("transnoentitiesnoconv('multicurrency_error_browser_incompatible'); ?>"); - - return null; - } - - return xhr; -} - -function request(url, callback) -{ - var xhr = getXMLHttpRequest(); - xhr.onreadystatechange = function() - { - if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) - { - callback(xhr.responseText); - } - - }; - - xhr.open("GET", url, true); - xhr.send(null); -} - -function syncronize_rates() -{ - document.getElementById("bt_sync").disabled = true; - var url_sync = "http://apilayer.net/api/live?access_key=global->MULTICURRENCY_APP_ID; ?>&format=1global->MULTICURRENCY_APP_SOURCE)) echo '&source='.$conf->global->MULTICURRENCY_APP_SOURCE; ?>"; - request(url_sync, update_rates); -} - -function update_rates(responseText) -{ - var response = JSON.parse(responseText); - if (response.success) - { - var url = "/multicurrency/ajax/updaterates.php?sync_response="+JSON.stringify(response); - request(url, reloadpage); - } - else - { - if (typeof $ !== "undefined") $.jnotify("transnoentitiesnoconv('multicurrency_syncronize_error'); ?>: "+response.error.info, "error"); - else alert("transnoentitiesnoconv('multicurrency_syncronize_error'); ?>: "+response.error.info); - } -} - -function reloadpage(responseText) -{ - document.getElementById("bt_sync").disabled = false; - window.location.href = window.location.pathname; -} From 9169adf4ceab98ad04a180653f205b4b928b7cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:34:55 +0200 Subject: [PATCH 15/46] FIX #4766 VAT not shown in supplier invoice popup Close #4766 --- htdocs/compta/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 5fb1d638a88..5c93c1e62db 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Marcos García * * 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 @@ -230,7 +231,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) */ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $sql = "SELECT f.ref, f.rowid, f.total_ht, f.tva as total_tva, f.total_ttc, f.type"; + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type"; $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid"; $sql.= ", s.code_fournisseur"; From b2f922291fefb66eb845ae7fce78ef536bcf60ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:38:58 +0200 Subject: [PATCH 16/46] FIX #4851 Project selector in supplier invoices shows the project label twice Close #4851 --- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 2b7f76dedf9..4c094061ee4 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -180,7 +180,7 @@ class FormProjets continue; } - $labeltoshow=dol_trunc($obj->ref,18).' - '.$obj->title; + $labeltoshow=dol_trunc($obj->ref,18); //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 890772326ea..42418184c4f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1474,7 +1474,7 @@ class FactureFournisseur extends CommonInvoice if (! empty($this->total_ht)) $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('TVA') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_ttc)) $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); From 1026484da1ec129a47cc84d4ec16e3d4863189df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:48:42 +0200 Subject: [PATCH 17/46] FIX #4748 Supplier invoice payment confirmation amount is not translated Close #4748 --- htdocs/fourn/facture/paiement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 81fe1d6b345..d69c2df9a94 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -432,7 +432,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $preselectedchoice=$addwarning?'no':'yes'; print '
'; - $text=$langs->trans('ConfirmSupplierPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); + $text=$langs->trans('ConfirmSupplierPayment', price($totalpayment),$langs->trans("Currency".$conf->currency)); if (GETPOST('closepaidinvoices')) { $text.='
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); From 7cc1288bb2c4c9b86802f761664ff5903ff1b8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:54:13 +0200 Subject: [PATCH 18/46] FIX #4743 UI glitch in project summary page Close #4743 --- htdocs/projet/element.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 1be43fe94dd..c475dcbcae0 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -344,8 +344,7 @@ $langs->load("orders"); $langs->load("proposals"); $langs->load("margins"); -//print load_fiche_titre($langs->trans("Profit"),'','title_accountancy'); -print '
'.img_picto("", "title_accountancy").' '.$langs->trans("Profit").'

'; +print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy'); print ''; print ''; From 3135cf720d8ccfc8ff09b821e664fd4be3a66edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:56:45 +0200 Subject: [PATCH 19/46] FIX #4737 Bank transacion type selector translation is cropped Close #4737 --- htdocs/compta/bank/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 80befe3d433..d4f4b82a96b 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -210,7 +210,7 @@ if ($resql) print ''; print ''; print ''; print ''; print ''; print "\n"; From af473df2143a275a4d1704a2ac2dfaaefa5dfa48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:27:42 +0200 Subject: [PATCH 22/46] FIX #4742 Able to delete a supplier invoice with a registered payment Close #4742 --- htdocs/fourn/facture/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c2b2c587736..7887e8cc6ed 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2270,7 +2270,11 @@ else // Delete if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) { - print ''.$langs->trans('Delete').''; + if ($object->getSommePaiement()) { + print ''; + } else { + print ''.$langs->trans('Delete').''; + } } print ''; print '
'; From 15d927375132469cd89c7fcf834be5ccc9886495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 10 Apr 2016 00:30:31 +0200 Subject: [PATCH 23/46] FIX #4747 Missing UI background when registering a supplier invoice payment Close #4747 --- htdocs/fourn/facture/paiement.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 758885cef58..dcaabd160f8 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -281,9 +281,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; + dol_fiche_head(); + print '
  '; - $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 8); + $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1); print ''; From b9de3d5852d59d0ca9ca0f73852ffdb431e29fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:03:00 +0200 Subject: [PATCH 20/46] FIX #4442 Missing translation in Banks menu Close #4442 --- htdocs/core/menus/standard/eldy.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8d6882c26c2..b6a98b1c2d3 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -970,6 +970,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("withdrawals"); $langs->load("banks"); $langs->load("bills"); + $langs->load('categories'); // Bank-Caisse if (! empty($conf->banque->enabled)) From 865f9defff1b2ca8b23684c59e44f03b94bd0d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:08:47 +0200 Subject: [PATCH 21/46] FIX #4424 Missing email of user popup in supplier orders area Close #4424 --- htdocs/fourn/commande/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index c877589851d..510ca2755be 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -245,7 +245,7 @@ if (! empty($conf->fournisseur->enabled)) /* * List of users allowed */ -$sql = "SELECT u.rowid, u.lastname, u.firstname"; +$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u,"; $sql.= " ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as rd"; @@ -278,6 +278,7 @@ if ($resql) $userstatic->id=$obj->rowid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->email=$obj->email; print $userstatic->getNomUrl(1); print '
'; - print ''; print '
'.$langs->trans('Payment').'
'.$langs->trans('Company').''; $supplierstatic->id=$obj->socid; $supplierstatic->name=$obj->name; @@ -311,6 +312,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print '
'; + dol_fiche_end(); $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -337,7 +339,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $i = 0; print '
'; - print $langs->trans('Invoices').'
'; if(!empty($conf->global->FAC_AUTO_FILLJS)){ //Add js for AutoFill From 7acbf1dd92112dfbdfdc6228ac4e8f0660531a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 10 Apr 2016 01:00:27 +0200 Subject: [PATCH 24/46] FIX #4874 SQL error when listing users Close #4874 --- htdocs/user/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 8710dc87e04..3d787762a8c 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Marcos García * * 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 @@ -201,7 +202,9 @@ if ($search_login != '') $sql.= natural_search("u.login", $search_login); if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname); if ($search_gender != '' && $search_gender != '-1') $sql.= " AND u.gender = '".$search_gender."'"; -if ($search_employee >= 0) $sql.= natural_search("u.employee", $search_employee); +if (is_numeric($search_employee) && $search_employee >= 0) { + $sql .= ' AND u.employee = '.(int) $search_employee; +} if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code); if ($search_email != '') $sql.= natural_search("u.email", $search_email); if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; From 9f019a0ec3193f1080acd30ae8eaf5a6007a5761 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Apr 2016 20:50:55 +0200 Subject: [PATCH 25/46] Debug supplier proposal module --- htdocs/supplier_proposal/card.php | 57 +++++++++++++++++-------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 36d04f559e1..be07d022fdb 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1089,7 +1089,7 @@ if ($action == 'create') print ''; // Reference - print ''; + print ''; // Third party print ''; @@ -1419,7 +1419,7 @@ if ($action == 'create') $linkback = '' . $langs->trans("BackToList") . ''; // Ref - print ''; @@ -1469,7 +1469,7 @@ if ($action == 'create') // Payment mode print ''; - print ''; @@ -230,6 +230,7 @@ print '' print ''; print ''; +/* This property seems not used in code, so i comment it $var=!$var; print ''; print ''; @@ -242,6 +243,7 @@ print ''; print ''; print ''; +*/ print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . ''; + print '
' . $langs->trans('Ref') . ''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '
'; + print ''; print ''; @@ -1519,18 +1519,18 @@ if ($action == 'create') } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if ( empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; - print ''; - print ''; @@ -1589,17 +1589,22 @@ if ($action == 'create') } // Other attributes - $cols = 3; + $cols = 2; + if (empty($conf->margin->enabled)) $cols++; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Amount HT - print ''; - print ''; - print ''; + print ''; + print ''; // Margin Infos if (! empty($conf->margin->enabled)) { - print ''; } @@ -1607,48 +1612,48 @@ if ($action == 'create') // Amount VAT print ''; - print ''; - print ''; + print ''; + print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { print ''; - print ''; - print ''; + print ''; + print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { print ''; - print ''; - print ''; + print ''; + print ''; } // Amount TTC print ''; - print ''; - print ''; + print ''; + print ''; if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT print ''; - print ''; + print ''; print ''; // Multicurrency Amount VAT print ''; - print ''; + print ''; print ''; // Multicurrency Amount TTC print ''; - print ''; + print ''; print ''; } // Statut - print ''; + print ''; print '
'; print $langs->trans('PaymentMode'); print '
'; + print ''; print ''; if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) print ''; print '
'; print fieldLabel('Currency','multicurrency_code'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; + print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { @@ -1540,14 +1540,14 @@ if ($action == 'create') // Multicurrency rate print '
'; + print ''; print ''; if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) print ''; print '
'; print fieldLabel('Rate','multicurrency_tx'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; + print ''; if ($action == 'editmulticurrencyrate') { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); } else { @@ -1561,7 +1561,7 @@ if ($action == 'create') // Outstanding Bill print '
'; print $langs->trans('OutstandingBill'); - print ''; + print ''; print price($soc->get_OutstandingBill()) . ' / '; print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + $rowspan=4; + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) $rowspan++; + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) $rowspan++; + if (!empty($conf->multicurrency->enabled)) $rowspan+=3; + print ''; $formmargin->displayMarginInfos($object); print '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '' . 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)) . '' . 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)) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '

'; From b7275edfb8db5a92e19a901ac61b22a0bd107370 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:24:31 +0200 Subject: [PATCH 26/46] FIX #4989 --- htdocs/admin/dict.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index bc56f13cc66..a5a3139353a 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -232,7 +232,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -$tabfield[25]= "label,type_template,position,topic,content"; +$tabfield[25]= "label,type_template,private,position,topic,content"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country"; @@ -264,7 +264,7 @@ $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; $tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24]= "code,label"; -$tabfieldvalue[25]= "label,type_template,position,topic,content"; +$tabfieldvalue[25]= "label,type_template,private,position,topic,content"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country"; @@ -585,7 +585,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors'); } - + // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 @@ -685,7 +685,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - + print $sql; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); @@ -1330,7 +1330,7 @@ if ($id) if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } $canbemodified=$iserasable; if ($obj->code == 'RECEP') $canbemodified=1; - + $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; // Favorite From 23bb2eaf8a4e1be3fdf22db1d4b05324bf6287a3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:27:17 +0200 Subject: [PATCH 27/46] remove debug --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index a5a3139353a..5e9fc895f0b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -685,7 +685,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - print $sql; + dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); From 695cccca1c4dbef1610eb3970354a24746b11fd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2016 14:44:14 +0200 Subject: [PATCH 28/46] Import wizard accept both id or ref into imported fields. But if the ref is numeric, there is no way to know if it is a ref or id. So i introduct support of syntax id: or ref: into value of field to import to force type. --- htdocs/core/modules/import/import_csv.modules.php | 10 ++++++++-- htdocs/core/modules/import/import_xlsx.modules.php | 13 ++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index da59679b1be..da927dbdbe1 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -319,7 +319,7 @@ class ImportCsv extends ModeleImports * * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... - * @param Object $objimport Object import (contains objimport->import_tables_array, objimport->import_fields_array, objimport->import_convertvalue_array, ...) + * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) * @param int $maxfields Max number of fields to use * @param string $importid Import key * @return int <0 if KO, >0 if OK @@ -420,7 +420,13 @@ class ImportCsv extends ModeleImports || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' ) { - if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor + // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. + $isidorref='id'; + if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref'; + $newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref + //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; + + if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { $file=$objimport->array_import_convertvalue[0][$val]['classfile']; $class=$objimport->array_import_convertvalue[0][$val]['class']; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 637cf35cc79..47c5fa3feaf 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -336,7 +336,7 @@ class Importxlsx extends ModeleImports * * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... - * @param Object $objimport Object import (contains objimport->import_tables_array, objimport->import_fields_array, objimport->import_convertvalue_array, ...) + * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) * @param int $maxfields Max number of fields to use * @param string $importid Import key * @return int <0 if KO, >0 if OK @@ -438,7 +438,13 @@ class Importxlsx extends ModeleImports || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel' ) { - if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor + // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. + $isidorref='id'; + if (! is_numeric($newval) && $newval != '' && ! preg_match('/^id:/i',$newval)) $isidorref='ref'; + $newval=preg_replace('/^(id|ref):/i','',$newval); // Remove id: or ref: that was used to force if field is id or ref + //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; + + if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor { $file=$objimport->array_import_convertvalue[0][$val]['classfile']; $class=$objimport->array_import_convertvalue[0][$val]['class']; @@ -645,7 +651,8 @@ class Importxlsx extends ModeleImports } if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$user->id; $sql.=')'; -print($sql); + + //print($sql).'
'; dol_syslog("import_csv.modules", LOG_DEBUG); //print '> '.join(',',$arrayrecord); From 8035742779d1b7f9c4afe90fb6b6fd44a3a9aa2e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:52:22 +0200 Subject: [PATCH 29/46] FIX fetchAllEMailTemplate --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index bc185ef6d71..f8f6afcf1ff 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -334,7 +334,7 @@ class FormMail extends Form $out.= '   '; $out.= ''; } - + $out.= ''."\n"; @@ -894,7 +894,7 @@ class FormMail extends Form $line->id=$obj->rowid; $line->label=$obj->label; $line->topic=$obj->topic; - $line->content=$obj->lacontentbel; + $line->content=$obj->content; $line->lang=$obj->lang; $this->lines_model[]=$line; } From 0e7fb80a3428fcf7857160669f4ea2dbce9efded Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2016 14:56:42 +0200 Subject: [PATCH 30/46] FIX: We should be able to import value '0' --- htdocs/core/modules/import/import_csv.modules.php | 2 +- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index da927dbdbe1..8f25a38d322 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -401,7 +401,7 @@ class ImportCsv extends ModeleImports // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ($newval=='')) + if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval=='')) { $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key); $this->errors[$error]['type']='NOTNULL'; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 47c5fa3feaf..34139820ba8 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -419,7 +419,7 @@ class Importxlsx extends ModeleImports // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ($newval=='')) + if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval == '')) { $this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key); $this->errors[$error]['type']='NOTNULL'; From 03f43d7c5561feb2276585a3028e831e74df1a40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2016 15:19:58 +0200 Subject: [PATCH 31/46] Removed a TODO by moving detection of line of records of a file to import into the import driver. --- .../modules/import/import_csv.modules.php | 13 +++++++++++ .../modules/import/import_xlsx.modules.php | 23 +++++++++++++++++++ htdocs/imports/import.php | 4 ++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 8f25a38d322..85689edcf7c 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -49,6 +49,7 @@ class ImportCsv extends ModeleImports var $separator; + var $file; // Path of file var $handle; // Handle fichier var $cacheconvert=array(); // Array to cache list of value found after a convertion @@ -236,6 +237,18 @@ class ImportCsv extends ModeleImports return $ret; } + + /** + * Return nb of records. File must be closed. + * + * @return int <0 if KO, >=0 if OK + */ + function import_get_nb_of_lines($file) + { + return dol_count_nb_of_line($file); + } + + /** * Input header line from file * diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 34139820ba8..a821540f29b 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -49,6 +49,7 @@ class Importxlsx extends ModeleImports var $separator; + var $file; // Path of file var $handle; // Handle fichier var $cacheconvert=array(); // Array to cache list of value found after a convertion @@ -276,9 +277,31 @@ class Importxlsx extends ModeleImports $reader = new PHPExcel_Reader_Excel2007(); $this->workbook = $reader->load($file); $this->record = 1; + $this->file = $file; + return $ret; } + + /** + * Return nb of records. File must be closed. + * + * @return int <0 if KO, >=0 if OK + */ + function import_get_nb_of_lines($file) + { + $reader = new PHPExcel_Reader_Excel2007(); + $this->workbook = $reader->load($file); + + $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); + + $this->workbook->disconnectWorksheets(); + unset($this->workbook); + + return $rowcount; + } + + /** * Input header line from file * diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 23d5a61415b..eae01880f90 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1142,6 +1142,7 @@ if ($step == 5 && $datatoimport) // Load source fields in input file $fieldssource=array(); $result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs); + if ($result >= 0) { // Read first line @@ -1156,8 +1157,7 @@ if ($step == 5 && $datatoimport) $obj->import_close_file(); } - // TODO, remove this, since it only works for csv - $nboflines=dol_count_nb_of_line($conf->import->dir_temp.'/'.$filetoimport); + $nboflines=$obj->import_get_nb_of_lines($conf->import->dir_temp.'/'.$filetoimport); $param='&leftmenu=import&format='.$format.'&datatoimport='.$datatoimport.'&filetoimport='.urlencode($filetoimport).'&nboflines='.$nboflines.'&separator='.urlencode($separator).'&enclosure='.urlencode($enclosure); $param2 = $param; // $param2 = $param without excludefirstline and endatlinenb From 3678e052709c5f565c6227f876c577a8a1b965b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2016 16:36:00 +0200 Subject: [PATCH 32/46] Mutualize code by moving getter into parent class. --- .../modules/import/import_csv.modules.php | 70 --------------- .../modules/import/import_xlsx.modules.php | 89 ++----------------- htdocs/core/modules/import/modules_import.php | 72 +++++++++++++++ 3 files changed, 81 insertions(+), 150 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 85689edcf7c..245f1a15794 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -86,76 +86,6 @@ class ImportCsv extends ModeleImports if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); } - /** - * getDriverId - * - * @return string Id - */ - function getDriverId() - { - return $this->id; - } - - /** - * getDriverLabel - * - * @return string Label - */ - function getDriverLabel() - { - return $this->label; - } - - /** - * getDriverDesc - * - * @return string Description - */ - function getDriverDesc() - { - return $this->desc; - } - - /** - * getDriverExtension - * - * @return string Driver suffix - */ - function getDriverExtension() - { - return $this->extension; - } - - /** - * getDriverVersion - * - * @return string Driver version - */ - function getDriverVersion() - { - return $this->version; - } - - /** - * getDriverLabel - * - * @return string Label of external lib - */ - function getLibLabel() - { - return $this->label_lib; - } - - /** - * getLibVersion - * - * @return string Version of external lib - */ - function getLibVersion() - { - return $this->version_lib; - } - /** * Output header of an example file for this format diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index a821540f29b..309e3dd7085 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -73,100 +73,29 @@ class Importxlsx extends ModeleImports // this is used as an extension from the example file code, so we have to put xlsx here !!! $this->id='xlsx'; // Same value as xxx in file name export_xxx.modules.php - $this->label='Excel'; // Label of driver - $this->desc=$langs->trans("ExcelFormatDesc",$this->separator,$this->enclosure,$this->escape); + $this->label='Excel 2007'; // Label of driver + $this->desc=$langs->trans("Excel2007FormatDesc"); $this->extension='xlsx'; // Extension for generated file by this driver $this->picto='mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) $this->version='1.0'; // Driver version // If driver use an external library, put its name here - require_once PHPEXCEL_PATH.'PHPExcel.php'; + require_once PHPEXCEL_PATH.'PHPExcel.php'; require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive - { + if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive + { $langs->load("errors"); $this->error=$langs->trans('ErrorPHPNeedModule','zip'); return -1; - } - $this->label_lib='PhpExcel'; - $this->version_lib='1.8.0'; + } + $this->label_lib='PhpExcel'; + $this->version_lib='1.8.0'; $this->datatoimport=$datatoimport; if (preg_match('/^societe_/',$datatoimport)) $this->thirpartyobject=new Societe($this->db); } -// Those Get methods should all be in the parent class !!! - /** - * getDriverId - * - * @return string Id - */ - function getDriverId() - { - return $this->id; - } - - /** - * getDriverLabel - * - * @return string Label - */ - function getDriverLabel() - { - return $this->label; - } - - /** - * getDriverDesc - * - * @return string Description - */ - function getDriverDesc() - { - return $this->desc; - } - - /** - * getDriverExtension - * - * @return string Driver suffix - */ - function getDriverExtension() - { - return $this->extension; - } - - /** - * getDriverVersion - * - * @return string Driver version - */ - function getDriverVersion() - { - return $this->version; - } - - /** - * getDriverLabel - * - * @return string Label of external lib - */ - function getLibLabel() - { - return $this->label_lib; - } - - /** - * getLibVersion - * - * @return string Version of external lib - */ - function getLibVersion() - { - return $this->version_lib; - } - - + /** * Output header of an example file for this format * diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index a27b0fd9426..11b81ecb820 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -59,6 +59,78 @@ class ModeleImports { } + + /** + * getDriverId + * + * @return string Id + */ + function getDriverId() + { + return $this->id; + } + + /** + * getDriverLabel + * + * @return string Label + */ + function getDriverLabel() + { + return $this->label; + } + + /** + * getDriverDesc + * + * @return string Description + */ + function getDriverDesc() + { + return $this->desc; + } + + /** + * getDriverExtension + * + * @return string Driver suffix + */ + function getDriverExtension() + { + return $this->extension; + } + + /** + * getDriverVersion + * + * @return string Driver version + */ + function getDriverVersion() + { + return $this->version; + } + + /** + * getDriverLabel + * + * @return string Label of external lib + */ + function getLibLabel() + { + return $this->label_lib; + } + + /** + * getLibVersion + * + * @return string Version of external lib + */ + function getLibVersion() + { + return $this->version_lib; + } + + /** * Charge en memoire et renvoie la liste des modeles actifs * From 791df0c9ea4e657c2d80c51d91b9c41886463551 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:27:34 +0200 Subject: [PATCH 33/46] FIX: correct display of minimum buying price --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 344fa3ffa56..50613103848 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -540,7 +540,7 @@ class ProductFournisseur extends Product { global $langs; $langs->load("suppliers"); - $out=($showunitprice?price($this->fourn_unitprice).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); return $out; } From 983b2c9a210c11a56f7af7376686afaef70ba8b6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:40:47 +0200 Subject: [PATCH 34/46] FIX: real min buying price --- htdocs/product/composition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 89760dc66ba..10d50acebe0 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -354,7 +354,7 @@ if ($id > 0 || ! empty($ref)) else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; } } print ''; - $totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges), 'MT'); $total+=$totalline; print ''; if (! empty($conf->stock->enabled)) print ''; // Real stock From 292373cf8401f190ccc7269838d0e0efdff5d0c6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:43:10 +0200 Subject: [PATCH 35/46] forgot new discount field --- htdocs/product/composition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 10d50acebe0..6cb6424bdc4 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -354,7 +354,7 @@ if ($id > 0 || ! empty($ref)) else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; } } print ''; - $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges), 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; print ''; if (! empty($conf->stock->enabled)) print ''; // Real stock From b60e90a7b7ff1c61733707207e770dc32a55e043 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Apr 2016 18:08:03 +0200 Subject: [PATCH 36/46] NEW A module can add, into its import profiles, a sql request to execute at end of import. This allow to update dernormalized data after import. --- htdocs/core/modules/modStock.class.php | 6 +++- htdocs/imports/class/import.class.php | 3 ++ htdocs/imports/import.php | 46 ++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 81454a52222..7bdf5d1d641 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -194,8 +194,12 @@ class modStock extends DolibarrModules $this->import_convertvalue_array[$r]=array( 'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'), 'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label') + ); + $this->import_examplevalues_array[$r]=array( + 'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" ); - $this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" + $this->import_run_sql_after_array[$r]=array( // Because we may change data that are denormalized, we must update dernormalized data after. + 'UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid);' ); } diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 9a4d58aa65f..fb842ef56ca 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -38,6 +38,7 @@ class Import var $array_import_regex; var $array_import_examplevalues; var $array_import_convertvalue; + var $array_import_run_sql_after; /** @@ -151,6 +152,8 @@ class Import $this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r]; // Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles) $this->array_import_convertvalue[$i]=(isset($module->import_convertvalue_array[$r])?$module->import_convertvalue_array[$r]:''); + // Sql request to run after import + $this->array_import_run_sql_after[$i]=(isset($module->import_run_sql_after_array[$r])?$module->import_run_sql_after_array[$r]:''); // Module $this->array_import_module[$i]=$module; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index eae01880f90..9b40c35ead6 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1415,6 +1415,25 @@ if ($step == 5 && $datatoimport) print $langs->trans("ErrorFailedToOpenFile",$pathfile); } + $error=0; + + // Run the sql after import if defined + //var_dump($objimport->array_import_run_sql_after[0]); + if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) + { + $i=0; + foreach($objimport->array_import_run_sql_after[0] as $sqlafterimport) + { + $i++; + $resqlafterimport=$db->query($sqlafterimport); + if (! $resqlafterimport) + { + $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); + $error++; + } + } + } + $db->rollback(); // We force rollback because this was just a simulation. // Show OK @@ -1740,8 +1759,31 @@ if ($step == 6 && $datatoimport) } if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors. - else $db->commit(); // We can commit if no errors. - + else + { + $error=0; + + // Run the sql after import if defined + //var_dump($objimport->array_import_run_sql_after[0]); + if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) + { + $i=0; + foreach($objimport->array_import_run_sql_after[0] as $sqlafterimport) + { + $i++; + $resqlafterimport=$db->query($sqlafterimport); + if (! $resqlafterimport) + { + $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); + $error++; + } + } + } + + if (! $error) $db->commit(); // We can commit if no errors. + else $db->rollback(); + } + dol_fiche_end(); From 872c99afe951b1ed23611681c0f68e73625dc5b3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 12 Apr 2016 11:35:39 +0200 Subject: [PATCH 37/46] FIX Hook resprint be printed --- htdocs/core/tpl/objectline_create.tpl.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 31ad9716155..71d34ac4cd4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -32,7 +32,7 @@ $usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) { $usemargins=1; } @@ -193,11 +193,17 @@ else { { $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } if (is_object($hookmanager) && ! empty($senderissupplier)) { $parameters=array('htmlname'=>'addproduct'); $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } @@ -476,7 +482,7 @@ jQuery(document).ready(function() { $("#select_type").change(function() { setforfree(); - if (jQuery('#select_type').val() >= 0) + if (jQuery('#select_type').val() >= 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); @@ -582,7 +588,7 @@ jQuery(document).ready(function() { /* To set focus */ - if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); From 56c64f22bec579fbe8d67d8e0142588725451017 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 13:30:47 +0200 Subject: [PATCH 38/46] Prepare menu icon to hide/show left menu --- htdocs/theme/eldy/img/menus/menu.png | Bin 0 -> 166 bytes htdocs/theme/eldy/img/menus_black/menu.png | Bin 0 -> 101 bytes htdocs/theme/md/img/menu.png | Bin 0 -> 166 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/theme/eldy/img/menus/menu.png create mode 100644 htdocs/theme/eldy/img/menus_black/menu.png create mode 100644 htdocs/theme/md/img/menu.png diff --git a/htdocs/theme/eldy/img/menus/menu.png b/htdocs/theme/eldy/img/menus/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..e8ef108b1275503b5da65e98c326ba7c89c4c9ac GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;M!Q z+`=Ht$S`Y;1W=H@#M9T6{Q(OPx2#;w2eBhSA#+a`$B>A_Z!a$t1RBR+c;i5)Gg-^b@sk}t>*8+f6Ol&*dgeEykch)?FB=LnFmNz${AJE7 yXCby@2~%AbQ%$h9@C^13%#42=80-ZY^s?9ex4rLXcYi8SAA_f>pUXO@geCw|yc$0M literal 0 HcmV?d00001 diff --git a/htdocs/theme/md/img/menu.png b/htdocs/theme/md/img/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..e8ef108b1275503b5da65e98c326ba7c89c4c9ac GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}trX+877l!}s{b%+Ad7K3vk;M!Q z+`=Ht$S`Y;1W=H@#M9T6{Q(OPx2#;w2eBhSA#+a`$B>A_Z!a$t1RBR+c;i5)Gg-^b@sk}t>*8+f6Ol&*dgeEy Date: Tue, 12 Apr 2016 13:38:41 +0200 Subject: [PATCH 39/46] Removed hidden option MAIN_MENU_USE_JQUERY_LAYOUT. This feature will be implemented with pure CSS/Jquery so no more need of not maintained external library. --- htdocs/admin/menus/other.php | 33 -------------- htdocs/main.inc.php | 79 ++------------------------------- htdocs/theme/eldy/style.css.php | 4 +- htdocs/theme/md/style.css.php | 4 +- 4 files changed, 8 insertions(+), 112 deletions(-) diff --git a/htdocs/admin/menus/other.php b/htdocs/admin/menus/other.php index 73dc0fe3b85..471edf58e79 100644 --- a/htdocs/admin/menus/other.php +++ b/htdocs/admin/menus/other.php @@ -50,25 +50,11 @@ else if ($action == 'disable_hidemenu') exit; } -if ($action == 'activate_layoutmenu') -{ - dolibarr_set_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT", '1','chaine',0,'',$conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; -} -else if ($action == 'disable_layoutmenu') -{ - dolibarr_del_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT",$conf->entity); - header("Location: ".$_SERVER["PHP_SELF"]); - exit; -} - /* * View */ - llxHeader('',$langs->trans("Setup")); print load_fiche_titre($langs->trans("Menus"),'','title_setup'); @@ -119,25 +105,6 @@ else print ""; print ''; -// Use a flip-hide menu -if (isset($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 1) -{ - $var=!$var; - print ""; - print ''; - print '"; - print ''; -} - print '
'.($notdefined?'':price($totalline,'','',0,0,-1,$conf->currency)).''.$langs->trans("Stock").': '.$value['stock'].''.($notdefined?'':price($totalline,'','',0,0,-1,$conf->currency)).''.$langs->trans("Stock").': '.$value['stock'].'
'.$langs->trans("MenuUseLayout").''; - if (empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) - { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - } - else - { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; - } - print "
'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8652af27d82..697b2ab9ab9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1033,13 +1033,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs else print ''."\n"; // JQuery print ''."\n"; // Tooltip print ''."\n"; // JNotify - /*if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) || (defined('REQUIRE_JQUERY_FILEUPLOAD') && constant('REQUIRE_JQUERY_FILEUPLOAD'))) // jQuery fileupload - { - print ''."\n"; - }*/ if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES'))) // jQuery datatables { - //print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -1131,11 +1126,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs else print ''."\n"; print ''."\n"; print ''."\n"; - // jQuery Layout - if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) || defined('REQUIRE_JQUERY_LAYOUT')) - { - print ''."\n"; - } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) { @@ -1374,60 +1364,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if ($conf->use_javascript_ajax) { - if (empty($conf->dol_use_jmobile) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) - { - print '' . "\n"; - } - // Raven.js for client-side Sentry logging support if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN)) { @@ -1448,8 +1384,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a */ print "\n".''."\n"; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; - if (empty($conf->dol_hide_topmenu)) { print '
'; @@ -1579,11 +1513,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a //unset($form); } - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "
\n"; print '
'; print "\n\n"; - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'; + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'; } @@ -1616,8 +1549,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra // Instantiate hooks of thirdparty module $hookmanager->initHooks(array('searchform','leftblock')); - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n".''."\n".'
'."\n"; - else print "\n".''."\n".'
'."\n"; + print "\n".''."\n".'
'."\n"; print "\n"; @@ -1779,8 +1711,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra $reshook=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; - else print '
'; // End div id="id-left" + print '
'; // End div id="id-left" } print "\n"; @@ -1800,7 +1731,6 @@ function main_area($title='') { global $conf, $langs; - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; if (empty($conf->dol_hide_leftmenu)) print '
'; print "\n"; @@ -1944,7 +1874,6 @@ if (! function_exists("llxFooter")) print '
'."\n"; if (! empty($conf->dol_use_jmobile)) print '
'; // end data-role="page" - if (empty($conf->dol_use_jmobile) && ! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; if (empty($conf->dol_hide_leftmenu)) print '
'; // End div id-right print "\n"; @@ -1953,7 +1882,7 @@ if (! function_exists("llxFooter")) printCommonFooter($zone); //var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; // End div container + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) print '
'."\n"; // End div container if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b772f741219..7454229aec0 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -646,7 +646,7 @@ td.showDragHandle { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px; + margin-: px; margin-: dol_optimize_smallscreen)?'12':'6')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } @@ -683,7 +683,7 @@ div.ficheaddleft { @media only screen and (max-width: 900px) { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'6':'20'):'24')); ?>px; + margin-: px; margin-: px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9644232d2c6..78a8eaf79b2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -699,7 +699,7 @@ td.showDragHandle { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px; + margin-: px; margin-: dol_optimize_smallscreen)?'16':'4')); ?>px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; @@ -737,7 +737,7 @@ div.ficheaddleft { @media only screen and (max-width: 900px) { div.fiche { - margin-: global->MAIN_MENU_USE_JQUERY_LAYOUT))?($dol_hide_leftmenu?'4':'20'):'24')); ?>px; + margin-: px; margin-: px; dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> margin-bottom: 15px; From 357877b1fe1c3e90cae0feeba5e7af7cf128205e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 14:10:27 +0200 Subject: [PATCH 40/46] Debug multicurrency and clean properties of some modules --- htdocs/admin/multicurrency.php | 6 ++-- htdocs/comm/propal.php | 10 +++--- htdocs/commande/card.php | 6 ++-- htdocs/compta/facture.php | 6 ++-- htdocs/contrat/card.php | 1 + htdocs/core/class/html.form.class.php | 31 +++++++++++++------ htdocs/core/modules/modCategorie.class.php | 3 +- .../modules/modDocumentGeneration.class.php | 2 +- htdocs/core/modules/modExport.class.php | 2 +- htdocs/core/modules/modFckeditor.class.php | 1 + htdocs/core/modules/modImport.class.php | 2 +- htdocs/core/modules/modLabel.class.php | 1 + .../core/modules/modMultiCurrency.class.php | 4 +-- htdocs/core/modules/modWebsites.class.php | 2 +- htdocs/fourn/commande/card.php | 5 +-- htdocs/fourn/facture/card.php | 5 +-- .../install/mysql/migration/3.9.0-4.0.0.sql | 3 +- .../mysql/tables/llx_multicurrency_rate.sql | 3 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/receiptprinter.lang | 2 +- .../class/multicurrency.class.php | 2 ++ htdocs/supplier_proposal/card.php | 6 ++-- 22 files changed, 66 insertions(+), 38 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index b1ad347d8b7..b77606a60ed 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -136,7 +136,7 @@ if ($resql) * View */ -$page_name = "MultiCurrency"; +$page_name = "MultiCurrencySetup"; llxHeader('', $langs->trans($page_name)); @@ -212,7 +212,7 @@ print '
'; print '
'; print ''; print ''; -print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY')); +print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY'), $conf->global->MULTICURRENCY_MODIFY_RATE_APPLICATION); print ''; print '
'; print '
'.$langs->transnoentitiesnoconv("multicurrency_currencyFromToRate").'
'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index dea894a0258..d05f9078828 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -911,6 +911,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1040,6 +1041,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1325,7 +1327,7 @@ if ($action == 'create') } } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { @@ -1465,7 +1467,7 @@ if ($action == 'create') print ''.fieldLabel('Currency','multicurrency_code').''; print ''; $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 1); print ''; } @@ -1978,9 +1980,9 @@ if ($action == 'create') print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9b5c29f55db..db80893f426 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -833,6 +833,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -963,6 +964,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -2205,9 +2207,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 00498b870a7..491c4ca041a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1522,6 +1522,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1682,6 +1683,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -3516,9 +3518,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index b38787a4067..36c79c0f7c5 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -621,6 +621,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 082f362458b..4c32664630f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -902,7 +902,7 @@ class Form * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') - * @param string $showempty Add an empty field (Can be '1' or text to use on empty line like 'SelectThirdParty') + * @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) @@ -3779,7 +3779,7 @@ class Form print ''; print ''; print ''; print ''; print '
'; - print $this->selectMultiCurrency($selected,$htmlname); + print $this->selectMultiCurrency($selected, $htmlname, 1); print '
'; @@ -3797,11 +3797,13 @@ class Form * @param string $page Page * @param double $rate Current rate * @param string $htmlname Name of select html field + * @param string $currency Currency code to explain the rate * @return void */ - function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx') + function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx', $currency='') { - global $langs; + global $langs, $mysoc, $conf; + if ($htmlname != "none") { print '
'; @@ -3816,7 +3818,15 @@ class Form } else { - print !empty($rate) ? price(price2num($rate), 1, $langs) : 1; + if (! empty($rate)) + { + print price($rate, 1, $langs, 1, 0); + if ($currency && $rate != 1) print '   ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')'; + } + else + { + print 1; + } } } @@ -4030,17 +4040,17 @@ class Form * @param integer $useempty 1=Add empty line * @return string */ - function selectMultiCurrency($selected='',$htmlname='multicurrency_code', $useempty=0) + function selectMultiCurrency($selected='', $htmlname='multicurrency_code', $useempty=0) { global $db,$conf,$langs,$user; - $langs->loadCacheCurrencies(''); + $langs->loadCacheCurrencies(''); // Load ->cache_currencies $TCurrency = array(); $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; + $sql.= " WHERE entity IN ('".getEntity('mutlicurrency')."')"; $resql = $db->query($sql); - if ($resql) { while ($obj = $db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code; @@ -4048,14 +4058,14 @@ class Form $out=''; $out.= ''; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index ad4c2bba16a..17141b6200d 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -45,6 +45,7 @@ class modCategorie extends DolibarrModules $this->numero = 1780; $this->family = "technic"; + $this->module_position = 20; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des categories (produits, clients, fournisseurs...)"; @@ -53,7 +54,7 @@ class modCategorie extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 2; + $this->special = 0; $this->picto = 'category'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 9111ec11099..0648eb8bf0b 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -45,7 +45,7 @@ class modDocumentGeneration extends DolibarrModules $this->numero = 1520; $this->family = "technic"; - $this->module_position = 10000; + $this->module_position = 80; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Direct mail document generation"; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index cb3d104e096..e8a6baa8509 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -44,7 +44,7 @@ class modExport extends DolibarrModules $this->numero = 240; $this->family = "technic"; - $this->module_position = 520; + $this->module_position = 72; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Outils d'exports de donnees Dolibarr (via un assistant)"; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 4735b0811a3..31b3fafff16 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -45,6 +45,7 @@ class modFckeditor extends DolibarrModules $this->numero = 2000; $this->family = "technic"; + $this->module_position = 20; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Editeur WYSIWYG"; diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index 63af9dc9064..8f3faad9bd1 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -44,7 +44,7 @@ class modImport extends DolibarrModules $this->numero = 250; $this->family = "technic"; - $this->module_position = 510; + $this->module_position = 70; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)"; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 0b282584261..05e98d36454 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -44,6 +44,7 @@ class modLabel extends DolibarrModules $this->numero = 60; $this->family = "technic"; + $this->module_position = 80; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion des etiquettes"; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 48ce8bc3bc0..7ae613edd49 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -52,9 +52,9 @@ class modMultiCurrency extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "financial"; + $this->family = "technic"; // Module position in the family - $this->module_position = 555; + $this->module_position = 40; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index 8e019fabed8..e3b500b0e0d 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -46,7 +46,7 @@ class modWebsites extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "portal"; - $this->module_position = 20; + $this->module_position = 50; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the public website with CMS features"; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8bff36e159e..59bc805a120 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -472,6 +472,7 @@ if (empty($reshook)) unset($_POST['remise_percent']); unset($_POST['pu']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['label']); @@ -2027,9 +2028,9 @@ elseif (! empty($object->id)) print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d14dd97e6b3..08748bef416 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -830,6 +830,7 @@ if (empty($reshook)) unset($_POST['remise_percent']); unset($_POST['pu']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['label']); @@ -2053,9 +2054,9 @@ else print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 15de62fb3e8..8296aa82e74 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -190,8 +190,7 @@ CREATE TABLE llx_multicurrency_rate rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, rate double NOT NULL DEFAULT 0, - fk_multicurrency integer NOT NULL, - entity integer NOT NULL DEFAULT 1 + fk_multicurrency integer NOT NULL ) ENGINE=innodb; ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer; diff --git a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql index e6b90382dcd..333f5deab52 100644 --- a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql +++ b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql @@ -22,6 +22,5 @@ CREATE TABLE llx_multicurrency_rate rowid integer AUTO_INCREMENT PRIMARY KEY, date_sync datetime DEFAULT NULL, rate double NOT NULL DEFAULT 0, - fk_multicurrency integer NOT NULL, - entity integer DEFAULT 1 + fk_multicurrency integer NOT NULL ) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3468dc43eee..b37083ca091 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -99,6 +99,7 @@ AntiVirusParamExample= Example for ClamWin: --database="C:\Program Files (x86)\C ComptaSetup=Accounting module setup UserSetup=User management setup MenuSetup=Menu management setup +MultiCurrencySetup=Multi-currency setup MenuLimits=Limits and accuracy MenuIdParent=Parent menu ID DetailMenuIdParent=ID of parent menu (empty for a top menu) diff --git a/htdocs/langs/en_US/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 7b52f072eaf..189a8f25e38 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -5,7 +5,7 @@ PrinterUpdated=Printer %s updated PrinterDeleted=Printer %s deleted TestSentToPrinter=Test Sent To Printer %s ReceiptPrinter=Receipt printers -ReceiptPrinterDesc=Setup of printers +ReceiptPrinterDesc=Setup of receipt printers ReceiptPrinterTemplateDesc=Setup of Templates ReceiptPrinterTypeDesc=Description of Receipt Printer's type ReceiptPrinterProfileDesc=Description of Receipt Printer's Profile diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index fd6da3816ea..834d5b38605 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -471,7 +471,9 @@ class MultiCurrency extends CommonObject { $sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; + // FIXME Is this comptible with SQL ? $sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)'; + $sql.= " AND m.entity IN '".getEntity('multicurrency', 1)."'"; $resql = $db->query($sql); if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); else return array(0, 1); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index be07d022fdb..9101b6efda2 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -717,6 +717,7 @@ if (empty($reshook)) unset($_POST['type']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -841,6 +842,7 @@ if (empty($reshook)) unset($_POST['productid']); unset($_POST['remise_percent']); unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); unset($_POST['product_ref']); @@ -1549,9 +1551,9 @@ if ($action == 'create') print ''; print ''; if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); } print ''; } From df8bbaee3410864e1db7c35c31fb2ea18395a305 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 18:24:35 +0200 Subject: [PATCH 41/46] Add icone for website module --- htdocs/theme/eldy/style.css.php | 7 ++++++- htdocs/theme/md/style.css.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7454229aec0..ce97dd1c14f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1021,6 +1021,10 @@ div.mainmenu.tools { background-image: url(); } +div.mainmenu.websites { + background-image: url(); +} + 'name of class for div') @@ -1040,7 +1044,8 @@ foreach($conf->modules as $val) $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); +// Put here list of menu entries when the div.mainmenu.menuentry was previously defined +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 78a8eaf79b2..8997231230f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1072,6 +1072,10 @@ div.mainmenu.tools { background-image: url(); } +div.mainmenu.websites { + background-image: url(); +} + 'name of class for div') @@ -1091,7 +1095,8 @@ foreach($conf->modules as $val) $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); $generic=1; -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices'); +// Put here list of menu entries when the div.mainmenu.menuentry was previously defined +$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','holiday','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices','websites'); foreach($mainmenuusedarray as $val) { if (empty($val) || in_array($val,$divalreadydefined)) continue; From 87702f89fc7b9dca28972d376b872f468d20af28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 19:17:50 +0200 Subject: [PATCH 42/46] Work on website module --- htdocs/websites/class/website.class.php | 640 ++++++++++++++++++++++++ htdocs/websites/index.php | 64 ++- 2 files changed, 694 insertions(+), 10 deletions(-) create mode 100644 htdocs/websites/class/website.class.php diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php new file mode 100644 index 00000000000..46a0bfe495a --- /dev/null +++ b/htdocs/websites/class/website.class.php @@ -0,0 +1,640 @@ + + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) ---Put here your own copyright and developer email--- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file websites/website.class.php + * \ingroup websites + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Put some comments here + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class Website + * + * Put here description of your class + * @see CommonObject + */ +class Website extends CommonObject +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'website'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'website'; + + /** + * @var WebsiteLine[] Lines + */ + public $lines = array(); + + /** + */ + + public $entity; + public $shortname; + public $description; + public $status; + public $date_creation = ''; + public $date_modification = ''; + public $tms = ''; + + /** + */ + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + return 1; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + // Clean parameters + + if (isset($this->entity)) { + $this->entity = trim($this->entity); + } + if (isset($this->shortname)) { + $this->shortname = trim($this->shortname); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + + $sql.= 'entity,'; + $sql.= 'shortname,'; + $sql.= 'description,'; + $sql.= 'status,'; + $sql.= 'date_creation,'; + $sql.= 'date_modification'; + + + $sql .= ') VALUES ('; + + $sql .= ' '.(! isset($this->entity)?'NULL':$this->entity).','; + $sql .= ' '.(! isset($this->shortname)?'NULL':"'".$this->db->escape($this->shortname)."'").','; + $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").','; + $sql .= ' '.(! isset($this->status)?'NULL':$this->status).','; + $sql .= ' '.(! isset($this->date_creation) || dol_strlen($this->date_creation)==0?'NULL':"'".$this->db->idate($this->date_creation)."'").','; + $sql .= ' '.(! isset($this->date_modification) || dol_strlen($this->date_modification)==0?'NULL':"'".$this->db->idate($this->date_modification)."'"); + + + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_CREATE',$user); + //if ($result < 0) $error++; + //// End call triggers + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.entity,"; + $sql .= " t.shortname,"; + $sql .= " t.description,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + if (null !== $ref) { + $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + } else { + $sql .= ' WHERE t.rowid = ' . $id; + } + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->entity = $obj->entity; + $this->shortname = $obj->shortname; + $this->description = $obj->description; + $this->status = $obj->status; + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_modification = $this->db->jdate($obj->date_modification); + $this->tms = $this->db->jdate($obj->tms); + + + } + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' t.rowid,'; + + $sql .= " t.entity,"; + $sql .= " t.shortname,"; + $sql .= " t.description,"; + $sql .= " t.status,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_modification,"; + $sql .= " t.tms"; + + + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield,$sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + } + $this->lines = array(); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new WebsiteLine(); + + $line->id = $obj->rowid; + + $line->entity = $obj->entity; + $line->shortname = $obj->shortname; + $line->description = $obj->description; + $line->status = $obj->status; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_modification = $this->db->jdate($obj->date_modification); + $line->tms = $this->db->jdate($obj->tms); + + + + $this->lines[] = $line; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + // Clean parameters + + if (isset($this->entity)) { + $this->entity = trim($this->entity); + } + if (isset($this->shortname)) { + $this->shortname = trim($this->shortname); + } + if (isset($this->description)) { + $this->description = trim($this->description); + } + if (isset($this->status)) { + $this->status = trim($this->status); + } + + + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + + $sql .= ' entity = '.(isset($this->entity)?$this->entity:"null").','; + $sql .= ' shortname = '.(isset($this->shortname)?"'".$this->db->escape($this->shortname)."'":"null").','; + $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").','; + $sql .= ' status = '.(isset($this->status)?$this->status:"null").','; + $sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; + $sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').','; + $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'"); + + + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error && !$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_MODIFY',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + + $this->db->begin(); + + if (!$error) { + if (!$notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action calls a trigger. + + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_DELETE',$user); + //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + //// End call triggers + } + } + + if (!$error) { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; + $sql .= ' WHERE rowid=' . $this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param int $fromid Id of object to clone + * + * @return int New id of clone + */ + public function createFromClone($fromid) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + global $user; + $error = 0; + $object = new Website($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error ++; + $this->errors = $object->errors; + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + } + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return - 1; + } + } + + /** + * Return a link to the user card (with optionaly the picto) + * Use this->id,this->lastname, this->firstname + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to + * @param integer $notooltip 1=Disable tooltip + * @param int $maxlen Max length of visible user name + * @param string $morecss Add more css on link + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') + { + global $langs, $conf, $db; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("MyModule") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $link = 'ref . $linkend; + return $result; + } + + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Renvoi le libelle d'un status donne + * + * @param int $status Id status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function LibStatut($status,$mode=0) + { + global $langs; + + if ($mode == 0) + { + $prefix=''; + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 1) + { + if ($status == 1) return $langs->trans('Enabled'); + if ($status == 0) return $langs->trans('Disabled'); + } + if ($mode == 2) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 3) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + } + if ($mode == 4) + { + if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); + if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + } + if ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } + } + + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->entity = ''; + $this->shortname = ''; + $this->description = ''; + $this->status = ''; + $this->date_creation = ''; + $this->date_modification = ''; + $this->tms = ''; + + + } + +} + +/** + * Class WebsiteLine + */ +class WebsiteLine +{ + /** + * @var int ID + */ + public $id; + /** + * @var mixed Sample line property 1 + */ + + public $entity; + public $shortname; + public $description; + public $status; + public $date_creation = ''; + public $date_modification = ''; + public $tms = ''; + + /** + * @var mixed Sample line property 2 + */ + +} diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 7c52b440f44..a975bac297a 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -21,8 +21,49 @@ * \brief Page to setup the module Website */ + +/** + * Show HTML header HTML + BODY + Top menu + left menu + DIV + * + * @param string $head Optionnal head lines + * @param string $title HTML title + * @param string $help_url Url links to help page + * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage + * For other external page: http://server/url + * @param string $target Target to use on links + * @param int $disablejs More content into html header + * @param int $disablehead More content into html header + * @param array $arrayofjs Array of complementary js files + * @param array $arrayofcss Array of complementary css files + * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @return void + */ +function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') +{ + global $conf; + + // html header + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + + // top menu and left menu area + if (empty($conf->dol_hide_topmenu)) + { + top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); + } + if (empty($conf->dol_hide_leftmenu)) + { + left_menu('', $help_url, '', '', 1, $title, 1); + } + + // main area + //main_area($title); +} + + + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php'; $langs->load("admin"); $langs->load("other"); @@ -36,7 +77,7 @@ $conf->dol_hide_leftmenu = 1; $website='website1'; - +$object=new Website($db); /* @@ -75,12 +116,21 @@ $form = new Form($db); $help_url=''; -llxHeader('',$langs->trans("WebsiteSetup"),$help_url); +llxHeader('', $langs->trans("WebsiteSetup"), $help_url); +$style=' style="padding-top: 4px; padding-left: 10px; border-bottom: 1px solid #888; height: 20px; vertical-align: middle; margin-bottom: 5px;"'; -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("WebsiteSetup"),$linkback,'title_setup'); +print '
'; +// Loop on each sites + +$tmp = $object->fetchAll(); +foreach($object->lines as $websitearray) +{ + var_dump($websitearray); +} + +print '
'; $head = array(); @@ -95,10 +145,6 @@ if ($_SESSION['website_mode'] == 'edit') print ''; print ''; - dol_fiche_head($head, 'general', $langs->trans("Page").': '.$langs->trans("Home"), 0, 'globe'); - - print load_fiche_titre($langs->trans("SEO"),'',''); - print ''; print ''; print ''; @@ -152,8 +198,6 @@ if ($_SESSION['website_mode'] == 'edit') $doleditor=new DolEditor('WEBSITE_FOOTER',$obj->value,'',160,'dolibarr_notes','',false,false,$conf->fckeditor->enabled,5,60); $doleditor->Create(); - dol_fiche_end(); - print '
'; print ''; From e1d35c279787e21930270206ac33a8f082edb4f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Apr 2016 19:29:32 +0200 Subject: [PATCH 43/46] Fix waarnings --- htdocs/imports/class/import.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index fb842ef56ca..254628b38fa 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -33,13 +33,18 @@ class Import var $array_import_code; var $array_import_label; var $array_import_tables; + var $array_import_tables_creator; var $array_import_fields; + var $array_import_fieldshidden; var $array_import_entities; var $array_import_regex; var $array_import_examplevalues; var $array_import_convertvalue; var $array_import_run_sql_after; + var $error; + var $errors; + /** * Constructor @@ -138,7 +143,7 @@ class Import $this->array_import_label[$i]=$module->getImportDatasetLabel($r); // Array of tables to import (key=alias, value=tablename) $this->array_import_tables[$i]=$module->import_tables_array[$r]; - // Array of tables creator field to import (key=alias, value=creator field) + // Array of tables creator field to import (key=alias, value=creator field name) $this->array_import_tables_creator[$i]=(isset($module->import_tables_creator_array[$r])?$module->import_tables_creator_array[$r]:''); // Array of fields to import (key=field, value=label) $this->array_import_fields[$i]=$module->import_fields_array[$r]; From 9de6d31c87d21642b5ce5a5167d5979cf9499dd5 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 13 Apr 2016 15:57:46 +0200 Subject: [PATCH 44/46] New add link to widthdraw slip card on bank transaction --- htdocs/compta/paiement/class/paiement.class.php | 12 ++++++++++++ .../prelevement/class/bonprelevement.class.php | 1 + 2 files changed, 13 insertions(+) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index daf43ec9d64..9e81180c4fe 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -563,6 +563,18 @@ class Paiement extends CommonObject } } + // Add link 'WithdrawalPayment' in bank_url + if (! $error && $label == '(WithdrawalPayment)') + { + $result=$acc->add_url_line( + $bank_line_id, + $this->id_prelevement, + DOL_URL_ROOT.'/compta/prelevement/card.php?id=', + $this->num_paiement, + 'withdraw' + ); + } + if (! $error && ! $notrigger) { // Appel des triggers diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3c3a7d14ca0..31d9e4d67c1 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -462,6 +462,7 @@ class BonPrelevement extends CommonObject $paiement->amounts = $amounts; $paiement->paiementid = 3; // $paiement->num_paiement = $this->ref ; + $paiement->id_prelevement = $this->id ; $paiement_id = $paiement->create($user); if ($paiement_id < 0) From b5f7f962cc835d39c8e0faeeaf3b6311b452f581 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 16:05:47 +0200 Subject: [PATCH 45/46] FIX Travis fails --- htdocs/core/modules/import/import_csv.modules.php | 3 ++- htdocs/core/modules/import/import_xlsx.modules.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 245f1a15794..895ed6de89d 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * * 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 @@ -171,6 +171,7 @@ class ImportCsv extends ModeleImports /** * Return nb of records. File must be closed. * + * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ function import_get_nb_of_lines($file) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 309e3dd7085..627fcfd6fd9 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * * 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 @@ -214,7 +214,8 @@ class Importxlsx extends ModeleImports /** * Return nb of records. File must be closed. - * + * + * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ function import_get_nb_of_lines($file) From f86952dfaa5fef098a89332f23c9d44f1dcd1e15 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 16:57:11 +0200 Subject: [PATCH 46/46] FIX Add missing field fk_shipping_method_id --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 1 + htdocs/install/mysql/tables/llx_societe.sql | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index 8296aa82e74..70cb245c772 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -382,3 +382,4 @@ ALTER TABLE llx_product_fournisseur_price ADD supplier_reputation varchar(10) NU -- Delete old deprecated field ALTER TABLE llx_product_stock DROP COLUMN pmp; +ALTER TABLE llx_societe ADD COLUMN fk_shipping_method_id integer; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 9822272e7c2..e5d6f722d2c 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -103,5 +103,6 @@ create table llx_societe webservices_key varchar(128), -- supplier webservice key fk_multicurrency integer, - multicurrency_code varchar(255) + multicurrency_code varchar(255), + fk_shipping_method_id integer )ENGINE=innodb;
'.$langs->trans("Description").'