From 2fe0736b87e215ab823e9dbf172fe95b25b30016 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 12:32:50 +0200 Subject: [PATCH 001/128] Update qty dispatched on qty change Store qty dispatched and qty ordered only once per orderline --- htdocs/fourn/js/lib_dispatch.js | 55 +++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/js/lib_dispatch.js b/htdocs/fourn/js/lib_dispatch.js index 84f74c30c54..50b6809a979 100644 --- a/htdocs/fourn/js/lib_dispatch.js +++ b/htdocs/fourn/js/lib_dispatch.js @@ -1,5 +1,5 @@ // Copyright (C) 2014 Cedric GROSS -// Copyright (C) 2015 Francis Appels +// Copyright (C) 2017 Francis Appels // // 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 @@ -24,7 +24,7 @@ * addDispatchLine * Adds new table row for dispatching to multiple stock locations * - * @param index int index of produt line. 0 = first product line + * @param index int index of product line. 0 = first product line * @param type string type of dispatch (batch = batch dispatch, dispatch = non batch dispatch) * @param mode string 'qtymissing' will create new line with qty missing, 'lessone' will keep 1 in old line and the rest in new one */ @@ -35,17 +35,17 @@ function addDispatchLine(index, type, mode) console.log("Split line type="+type+" index="+index+" mode="+mode); var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch - qtyOrdered = parseFloat($("#qty_ordered_"+(nbrTrs - 1)+"_"+index).val()), + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qtyDispatched; if (mode === 'lessone') { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + 1; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + 1; } else { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + qty; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + qty; } if (qtyDispatched < qtyOrdered) @@ -63,10 +63,10 @@ function addDispatchLine(index, type, mode) //insert new row before last row $("tr[name^='"+type+"_'][name$='_"+index+"']:last").after($row); //remove cloned select2 with duplicate id. - $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); + $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); /* Suffix of lines are: _ trs.length _ index */ $("#qty_"+nbrTrs+"_"+index).focus(); - $("#qty_dispatched_"+(nbrTrs)+"_"+index).val(qtyDispatched); + $("#qty_dispatched_0_"+index).val(qtyDispatched); //hide all buttons then show only the last one $("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide(); @@ -79,10 +79,47 @@ function addDispatchLine(index, type, mode) } else { - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + // Store arbitrary data for dispatch qty input field change event + $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); + $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); + $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); + // Update dispatched qty when value dispatch qty input field changed + $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); } - //set focus on lot of new line (if it exists) $("#lot_number_"+(nbrTrs)+"_"+index).focus(); } +} + +/** + * onChangeDispatchLineQty + * + * event handler for dispatch qty input field + * + * element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line) + */ + +function onChangeDispatchLineQty() { + var index = $(this).data('index'), + type = $(this).data('type'), + qty = parseFloat($(this).data('qty')), + changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched; + + if (index >= 0 && type && qty >= 0) { + nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length; + qtyChanged = parseFloat($(this).val()) - qty; // qty changed + qtyDispatching = parseFloat($("#qty_"+(nbrTrs-1)+"_"+index).val()); // qty currently being dispatched + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // qty ordered + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()); // qty already dispatched + + // console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); + + if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { + $("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged); + } else { + $(this).val($(this).data('qty')); + } + $(this).data('qty', $(this).val()); + } } \ No newline at end of file From d4488cb040beebd84ff0a1e2843c7e9ebea331a1 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 15:44:40 +0200 Subject: [PATCH 002/128] Fix for 'lessone' mode --- htdocs/fourn/js/lib_dispatch.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/fourn/js/lib_dispatch.js b/htdocs/fourn/js/lib_dispatch.js index 50b6809a979..2b39c18cbb2 100644 --- a/htdocs/fourn/js/lib_dispatch.js +++ b/htdocs/fourn/js/lib_dispatch.js @@ -35,7 +35,7 @@ function addDispatchLine(index, type, mode) console.log("Split line type="+type+" index="+index+" mode="+mode); var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch - qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qtyDispatched; @@ -74,19 +74,16 @@ function addDispatchLine(index, type, mode) if (mode === 'lessone') { - $("#qty_"+(nbrTrs)+"_"+index).val(qty-1); - $("#qty_"+(nbrTrs-1)+"_"+index).val(1); - } - else - { - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); - // Store arbitrary data for dispatch qty input field change event - $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); - $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); - $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); - // Update dispatched qty when value dispatch qty input field changed - $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); + qty = 1; // keep 1 in old line + $("#qty_"+(nbrTrs-1)+"_"+index).val(qty); } + $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + // Store arbitrary data for dispatch qty input field change event + $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); + $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); + $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); + // Update dispatched qty when value dispatch qty input field changed + $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); //set focus on lot of new line (if it exists) $("#lot_number_"+(nbrTrs)+"_"+index).focus(); } @@ -95,7 +92,9 @@ function addDispatchLine(index, type, mode) /** * onChangeDispatchLineQty * - * event handler for dispatch qty input field + * Change event handler for dispatch qty input field, + * recalculate qty dispatched when qty input has changed. + * If qty is more then qty ordered reset input qty to max qty to dispatch. * * element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line) */ @@ -113,7 +112,7 @@ function onChangeDispatchLineQty() { qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // qty ordered qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()); // qty already dispatched - // console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); + console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { $("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged); From d808add49905eec4fcbc07bea250e606b5a60559 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Oct 2017 15:48:48 +0200 Subject: [PATCH 003/128] FIX #7567 --- htdocs/langs/en_US/interventions.lang | 1 + htdocs/projet/element.php | 49 +++++++++++++++++---------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index b151565f3a3..3f7c84cd23f 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -53,6 +53,7 @@ UseDateWithoutHourOnFichinter=Hides hours and minutes off the date field for int InterventionStatistics=Statistics of interventions NbOfinterventions=Nb of intervention cards NumberOfInterventionsByMonth=Nb of intervention cards by month (date of validation) +AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit. Add option PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT to 1 into home-setup-other to include them. ##### Exports ##### InterId=Intervention id InterRef=Intervention ref. diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index bda8d793840..ae9872b70a0 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -610,23 +610,31 @@ foreach ($listofreferent as $key => $value) if ($qualifiedfortotal) $total_ttc = $total_ttc + $total_ttc_by_line; } - // Calculate margin - if ($margin=="add") - { - $balance_ht+= $total_ht; - $balance_ttc+= $total_ttc; - } - else - { - $balance_ht-= $total_ht; - $balance_ttc-= $total_ttc; - } + // Each element with at least one line is output + $qualifiedforfinalprofit=true; + if ($key == 'intervention' && empty($conf->global->PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT)) $qualifiedforfinalprofit=false; + //var_dump($key); - // Show $total_ht & $total_ttc -- add a minus when necessary - if ($margin!="add") + // Calculate margin + if ($qualifiedforfinalprofit) { - $total_ht = -$total_ht; - $total_ttc = -$total_ttc; + if ($margin=="add") + { + $balance_ht+= $total_ht; + $balance_ttc+= $total_ttc; + } + else + { + $balance_ht-= $total_ht; + $balance_ttc-= $total_ttc; + } + + // Show $total_ht & $total_ttc -- add a minus when necessary + if ($margin!="add") + { + $total_ht = -$total_ht; + $total_ttc = -$total_ttc; + } } /*switch ($classname) { @@ -655,16 +663,21 @@ foreach ($listofreferent as $key => $value) $newclassname = $classname; }*/ - $var = ! $var; print ''; // Module print ''.$name.''; // Nb print ''.$i.''; // Amount HT - print ''.price($total_ht).''; + print ''; + if (! $qualifiedforfinalprofit) print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; + else print price($total_ht); + print ''; // Amount TTC - print ''.price($total_ttc).''; + print ''; + if (! $qualifiedforfinalprofit) print ''.$form->textwithpicto($langs->trans("NA"), $langs->trans("AmountOfInteventionNotIncludedByDefault")).''; + else print price($total_ttc); + print ''; print ''; } } From 7b853d8981b22b600c1d2d1b005f4cbd9eedbfd0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Oct 2017 15:50:37 +0200 Subject: [PATCH 004/128] FIX #7567 --- htdocs/langs/en_US/interventions.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index 3f7c84cd23f..15415a7fcd5 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -53,7 +53,7 @@ UseDateWithoutHourOnFichinter=Hides hours and minutes off the date field for int InterventionStatistics=Statistics of interventions NbOfinterventions=Nb of intervention cards NumberOfInterventionsByMonth=Nb of intervention cards by month (date of validation) -AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit. Add option PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT to 1 into home-setup-other to include them. +AmountOfInteventionNotIncludedByDefault=Amount of intervention is not included by default into profit (in most cases, timesheets are used to count time spent). Add option PROJECT_INCLUDE_INTERVENTION_AMOUNT_IN_PROFIT to 1 into home-setup-other to include them. ##### Exports ##### InterId=Intervention id InterRef=Intervention ref. From 8104c97f77144c259db137778f92878f13f10be5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Oct 2017 11:53:26 +0200 Subject: [PATCH 005/128] Prepare 6.0.2 --- ChangeLog | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ChangeLog b/ChangeLog index 994e1702407..ce7d35884fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,41 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 6.0.2 compared to 6.0.1 ***** + +FIX: #7148 +FIX: #7288 +FIX: #7366 renaming table with pgsql +FIX: #7435 Can't add payment term +FIX: #7461 +FIX: #7464 +FIX: #7471 +FIX: #7473 Mass update of vat rates and other bugs on localtax +FIX: #7475 +FIX: #7486 Empty value for multicurrency rate must be forbidden +FIX: #7490 +FIX: #7505 +FIX: #7510 Bug: extrafield content disappear when generate pdf within intervention +FIX: #7514 +FIX: #7531 #7537 +FIX: #7541 +FIX: #7546 +FIX: #7550 +FIX: #7554 +FIX: #7567 +FIX: Accountancy export model for Agiris Isacompta +FIX: Allow create shipping if STOCK_SUPPORTS_SERVICES option is enabled +FIX: Bad preview on scroping when special file names +FIX: Generation of invoice from bulk action "Bill Orders" +FIX: Implementation of a Luracast recommandation for the REST api server (#7370) +FIX: Missing space in request +FIX: Only modified values must be modified +FIX: replenish if line test GETPOST on line 0 +FIX: Stripe not working on live mode +FIX: wrong basePath in the swagger view +FIX: Implementation of a Luracast recommandation for the REST api server + ***** ChangeLog for 6.0.1 compared to 6.0.* ***** FIX: #7000 Dashboard link for late pending payment supplier invoices do not work From 8513ddb9b4081279e720e1b8e872952973c93ebb Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 8 Oct 2017 10:08:49 +0200 Subject: [PATCH 006/128] Fix : missing new target type in advance target selection --- htdocs/core/modules/mailings/advthirdparties.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 497d3c54f54..9252ae5ec3a 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -116,7 +116,7 @@ class mailing_advthirdparties extends MailingTargets } } - if (($type_of_target==1) || ($type_of_target==2)) { + if (($type_of_target==1) || ($type_of_target==2) || ($type_of_target==4)) { // Select the third parties from category if (count($socid)>0 || count($contactid)>0) { From 257fe68f1388ac31d30d96364c3ddbaded21e769 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Oct 2017 19:46:24 +0200 Subject: [PATCH 007/128] Prepare 6.0.3 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 394686cc5e4..624808dd0d9 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.2'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 64d9b625ffc74ea6f133c9f47bf1780199d014ee Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 11:03:16 +0200 Subject: [PATCH 008/128] Fix: wrong POST GET name --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dcba7e20739..5c6e41a7127 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -248,7 +248,7 @@ function dol_shutdown() */ function GETPOSTISSET($paramname) { - return (isset($_POST['name']) || isset($_GET['name'])); + return (isset($_POST[$paramname]) || isset($_GET[$paramname])); } /** From 3d3f6d14b5d21647ffa12b634db6b437ed54793a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 11:26:49 +0200 Subject: [PATCH 009/128] Fix: uniformize fields size and maxlength compared to db size --- htdocs/adherents/card.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 5ab8ff1cc99..6e5389e346a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -843,7 +843,7 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; } // Password @@ -852,7 +852,7 @@ else require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generated_password=getRandomPassword(false); print ''.$langs->trans("Password").''; - print ''; + print ''; print ''; } @@ -875,7 +875,7 @@ else print "\n"; // Company - print ''.$langs->trans("Company").''; + print ''.$langs->trans("Company").''; // Civility print ''.$langs->trans("UserTitle").''; @@ -883,15 +883,15 @@ else print ''; // Lastname - print ''.$langs->trans("Lastname").''; + print ''.$langs->trans("Lastname").''; print ''; // Firstname - print ''.$langs->trans("Firstname").''; + print ''.$langs->trans("Firstname").''; print ''; // EMail - print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; + print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; // Address print ''.$langs->trans("Address").''; @@ -1081,13 +1081,13 @@ else // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; + print ''.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">'; } // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Password").'pass).'">'; + print ''.$langs->trans("Password").'pass).'">'; } // Morphy $morphys["phy"] = $langs->trans("Physical"); @@ -1110,7 +1110,7 @@ else print ""; // Company - print ''.$langs->trans("Company").'societe).'">'; + print ''.$langs->trans("Company").'societe).'">'; // Civility print ''.$langs->trans("UserTitle").''; @@ -1119,11 +1119,11 @@ else print ''; // Lastname - print ''.$langs->trans("Lastname").'lastname).'">'; + print ''.$langs->trans("Lastname").'lastname).'">'; print ''; // Firstname - print ''.$langs->trans("Firstname").'firstname).'">'; + print ''.$langs->trans("Firstname").'firstname).'">'; print ''; // Photo @@ -1142,7 +1142,7 @@ else print ''; // EMail - print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">'; + print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">'; // Address print ''.$langs->trans("Address").''; From 4a30448ff47543ae6efcc7f990cc47663b9a3a6b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 11:34:28 +0200 Subject: [PATCH 010/128] Fix: use fullname instead id is more explicit --- .../interface_20_all_Logevents.class.php | 10 +++--- ...terface_50_modAgenda_ActionsAuto.class.php | 32 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 466712260c6..c2f15bd336d 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2014 Marcos García +/* Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2014 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 @@ -63,7 +63,7 @@ class InterfaceLogevents extends DolibarrTriggers if ($action == 'USER_LOGIN') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - + $langs->load("users"); // Initialisation donnees (date,duree,texte,desc) $text="(UserLogged,".$object->login.")"; @@ -177,7 +177,7 @@ class InterfaceLogevents extends DolibarrTriggers // Add more information into desc from the context property if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit']; - + // Add entry in event table include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index ec1fa9465b5..3c34d0a3ee0 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2009-2011 Regis Houssin - * Copyright (C) 2011-2014 Juanjo Menent - * Copyright (C) 2013 Cedric GROSS - * Copyright (C) 2014 Marcos García - * Copyright (C) 2015 Bahfir Abbes +/* Copyright (C) 2005-2017 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2013 Cedric GROSS + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -635,8 +635,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); - $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->getFullName($langs)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; @@ -648,8 +648,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref); - $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->getFullName($langs)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; @@ -661,8 +661,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref); - $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->getFullName($langs)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; $object->actionmsg.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount; @@ -676,8 +676,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); - $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->getFullName($langs)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; @@ -689,8 +689,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); - $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs)); + $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->getFullName($langs)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg.="\n".$langs->transnoentities("Type").': '.$object->type; From f2d9288db534d450e4966a83ab75baa358138426 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 12:38:44 +0200 Subject: [PATCH 011/128] NEW add company alias name when create company from member --- htdocs/adherents/card.php | 19 +++++++++++++------ htdocs/adherents/subscription.php | 24 +++++++++++++++--------- htdocs/core/class/html.form.class.php | 6 ++++-- htdocs/societe/class/societe.class.php | 8 ++++++-- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6e5389e346a..c95b62e1dc0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -223,7 +223,7 @@ if (empty($reshook)) { // User creation $company = new Societe($db); - $result=$company->create_from_member($object,GETPOST('companyname')); + $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); if ($result < 0) { @@ -1319,18 +1319,25 @@ else // Confirm create third party if ($action == 'create_thirdparty') { - $name = $object->getFullName($langs); - if (! empty($name)) + $companyalias=''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { - if ($object->societe) $name.=' ('.$object->societe.')'; + $companyname=$object->societe; + if (! empty($fullname)) $companyalias=$fullname; } else { - $name=$object->societe; + $companyname=$fullname; + if (! empty($object->societe)) $companyalias=$object->societe; } // Create a form array - $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); + $formquestion=array( + array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"'), + array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"') + ); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); } diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 4b8f3b50648..405fe689816 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -109,7 +109,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights { // Creation user $company = new Societe($db); - $result=$company->create_from_member($object,$_POST["companyname"]); + $result=$company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); if ($result < 0) { @@ -960,19 +960,25 @@ if ($rowid > 0) // Confirm create third party if ($action == 'create_thirdparty') { - $name = $object->getFullName($langs); - if (! empty($name)) + $companyalias=''; + $fullname = $object->getFullName($langs); + + if ($object->morphy == 'mor') { - if ($object->morphy == 'mor' && ! empty($object->societe)) $name=$object->societe.' ('.$name.')'; - else if ($object->societe) $name.=' ('.$object->societe.')'; + $companyname=$object->societe; + if (! empty($fullname)) $companyalias=$fullname; } else { - $name=$object->societe; + $companyname=$fullname; + if (! empty($object->societe)) $companyalias=$object->societe; } // Create a form array - $formquestion=array(array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); + $formquestion=array( + array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"'), + array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"') + ); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 93c24990af0..d4c8ce6f288 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3572,14 +3572,16 @@ class Form if (is_array($input) && ! empty($input)) { $size=(! empty($input['size'])?' size="'.$input['size'].'"':''); + $moreattr=(! empty($input['moreattr'])?' '.$input['moreattr']:''); + $css=(! empty($input['css'])?' '.$input['css']:''); if ($input['type'] == 'text') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'password') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'select') { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1c8c515545a..bf449f30976 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2981,19 +2981,23 @@ class Societe extends CommonObject * Create a third party into database from a member object * * @param Adherent $member Object member - * @param string $socname Name of third party to force + * @param string $socname Name of third party to force + * @param string $socalias Alias name of third party to force * @return int <0 if KO, id of created account if OK */ - function create_from_member(Adherent $member,$socname='') + function create_from_member(Adherent $member, $socname='', $socalias='') { global $user,$langs; $name = $socname?$socname:$member->societe; if (empty($name)) $name=$member->getFullName($langs); + $alias = $socalias?$socalias:''; + // Positionne parametres $this->nom=$name; // TODO deprecated $this->name=$name; + $this->name_alias=$alias; $this->address=$member->address; $this->zip=$member->zip; $this->town=$member->town; From 6402d5a2e42c1b0743952b40fc40280fdecf049b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 13:30:08 +0200 Subject: [PATCH 012/128] Fix translation --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/projet/admin/project.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1e7dc926ff9..cb0cb9fcdaa 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1627,7 +1627,7 @@ ProjectsSetup=Project module setup ProjectsModelModule=Project reports document model TasksNumberingModules=Tasks numbering module TaskModelModule=Tasks reports document model -UseSearchToSelectProject=Use autocompletion fields to choose project (instead of using a list box) +UseSearchToSelectProject=Wait you press a key before loading content of project combo list (This may increase performance if you have a large number of project, but it is less convenient) ##### ECM (GED) ##### ##### Fiscal Year ##### AccountingPeriods=Accounting periods diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 53444a7580c..b9778b73a42 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -912,10 +912,10 @@ print ''; print ''; print ''.$langs->trans("AllowToSelectProjectFromOtherCompany").''; -print ''; +print ' '; +print ''; echo ajax_constantonoff('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY'); print ''; -print ' '; print ''; /* Kept as hidden feature because this will be "probaly be supported by standard event feature in a future From 8f24a86352def847d5524c2549e1290cf7a324a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 14:16:22 +0200 Subject: [PATCH 013/128] NEW If max nb of generation is reached, date for next gen is striked --- .../facture/class/facture-rec.class.php | 24 +++++++++++++++++++ htdocs/compta/facture/fiche-rec.php | 2 +- .../compta/facture/invoicetemplate_list.php | 4 +++- htdocs/core/class/html.form.class.php | 10 ++++++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 0a9fa2872eb..dd42c8d3fb7 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -823,6 +823,30 @@ class FactureRec extends CommonInvoice return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); } + /** + * Return if maximum number of generation is reached + * + * @return boolean False by default, True if maximum number of generation is reached + */ + function isMaxNbGenReached() + { + $ret = false; + if ($this->nb_gen_max > 0 && ($this->nb_gen_done >= $this->nb_gen_max)) $ret = true; + return $ret; + } + + /** + * Format string to output with by striking the string if max number of generation was reached + * + * @param string $ret Default value to output + * @return boolean False by default, True if maximum number of generation is reached + */ + function strikeIfMaxNbGenReached($ret) + { + // Special case to strike the date + return ($this->isMaxNbGenReached()?'':'').$ret.($this->isMaxNbGenReached()?'':''); + } + /** * Create all recurrents invoices (for all entities if multicompany is used). * A result may also be provided into this->output. diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 60156e0d047..dd37828fae6 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1430,7 +1430,7 @@ else print ''; if ($action == 'date_when' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day'); + print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); } print ''; print ''; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index f39fc7a3185..201a2806188 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -520,6 +520,8 @@ if ($resql) $invoicerectmp->frequency=$objp->frequency; $invoicerectmp->suspend=$objp->suspend; $invoicerectmp->unit_frequency=$objp->unit_frequency; + $invoicerectmp->nb_gen_max=$objp->nb_gen_max; + $invoicerectmp->nb_gen_done=$objp->nb_gen_done; print ''; @@ -603,7 +605,7 @@ if ($resql) if (! empty($arrayfields['f.date_when']['checked'])) { print ''; - print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : ''.$langs->trans('NA').''); + print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 93c24990af0..6f968db22d3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -128,7 +128,7 @@ class Form } /** - * Output val field for an editable field + * Output value of a field for an editable field * * @param string $text Text of label (not used in this function) * @param string $htmlname Name of select field @@ -141,9 +141,10 @@ class Form * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') * @param string $moreparam More param to add on a href URL * @param int $notabletag Do no output table tags + * @param string $formatfunc Call a specific function to output field * @return string HTML edit field */ - function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='', $notabletag=0) + function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata='string', $editvalue='', $extObject=null, $custommsg=null, $moreparam='', $notabletag=0, $formatfunc='') { global $conf,$langs,$db; @@ -257,6 +258,11 @@ class Form $ret.=$tmpcontent; } else $ret.=$value; + + if ($formatfunc && method_exists($object, $formatfunc)) + { + $ret=$object->$formatfunc($ret); + } } } return $ret; From 084dc7798dfe3f7dccd1e882b1d7f370bbb28b0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 14:51:42 +0200 Subject: [PATCH 014/128] Standardize use of function getCommonSubstitutionArray --- htdocs/comm/mailing/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 29 ++++---- htdocs/compta/facture/fiche-rec.php | 69 ++++++++----------- htdocs/core/lib/functions.lib.php | 25 ++++--- scripts/emailings/mailing-send.php | 2 +- 5 files changed, 61 insertions(+), 66 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 9f67db88bbb..539f8bede92 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -203,7 +203,7 @@ if (empty($reshook)) $targetobject = null; // Not defined with mass emailing $parameters=array('mode'=>'emailing'); - $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $targetobject); // Note: On mass emailing, this is null because be don't know object // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fcf41e090cc..6452c689215 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -351,22 +351,19 @@ class Facture extends CommonInvoice } // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) - $substitutionarray=array( - '__TOTAL_HT__' => price($this->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency_code), - '__TOTAL_TTC__' => price($this->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code), - '__INVOICE_PREVIOUS_MONTH__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'), - '__INVOICE_MONTH__' => dol_print_date($this->date, '%m'), - '__INVOICE_NEXT_MONTH__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'), - '__INVOICE_PREVIOUS_MONTH_TEXT__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'), - '__INVOICE_MONTH_TEXT__' => dol_print_date($this->date, '%B'), - '__INVOICE_NEXT_MONTH_TEXT__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'), - '__INVOICE_PREVIOUS_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'), - '__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'), - '__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'), - // Only for tempalte invoice - '__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__' => dol_print_date($originaldatewhen, 'dayhour'), - '__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__' => dol_print_date(dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency), 'dayhour') - ); + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $this); + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%m'); + $substitutionarray['__INVOICE_MONTH__'] = dol_print_date($this->date, '%m'); + $substitutionarray['__INVOICE_NEXT_MONTH__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%m'); + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'm'), '%B'); + $substitutionarray['__INVOICE_MONTH_TEXT__'] = dol_print_date($this->date, '%B'); + $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'm'), '%B'); + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); + $substitutionarray['__INVOICE_YEAR__'] = dol_print_date($this->date, '%Y'); + $substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); + // Only for tempalte invoice + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour'); + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date(dol_time_plus_duree($originaldatewhen, $_facrec->frequency, $_facrec->unit_frequency), 'dayhour'); //var_dump($substitutionarray);exit; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index dd37828fae6..17cc14eba84 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -969,26 +969,20 @@ if ($action == 'create') $note_private=GETPOST('note_private','none')?GETPOST('note_private','none'):$object->note_private; // Help of substitution key - $substitutionarray=array( - //'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', - //'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', - '__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', - '__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')', - '__AMOUNT__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', - '__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')', - '__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')', - '__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')', - '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')', - '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')', - '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')', - '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')', - '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')', - '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')', - // Only on template invoices - '__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__' => $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')', - '__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__' => $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')', - ); - $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); + $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); + + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%m').')'; + $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%m').')'; + $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'),'%m').')'; + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'),'%B').')'; + $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%B').')'; + $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'),'%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')'; + $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')'; + // Only on template invoices + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')'; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) @@ -1294,26 +1288,21 @@ else // Help of substitution key $dateexample=dol_now(); if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; - $substitutionarray=array( - //'__TOTAL_HT__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', - //'__TOTAL_TTC__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', - '__AMOUNT_EXCL_TAX__' => $langs->trans("AmountHT").' ('.$langs->trans("Example").': '.price($object->total_ht).')', - '__AMOUNT_VAT__' => $langs->trans("AmountVAT").' ('.$langs->trans("Example").': '.price($object->total_tva).')', - '__AMOUNT__' => $langs->trans("AmountTTC").' ('.$langs->trans("Example").': '.price($object->total_ttc).')', - '__INVOICE_PREVIOUS_MONTH__' => $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')', - '__INVOICE_MONTH__' => $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')', - '__INVOICE_NEXT_MONTH__' => $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')', - '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')', - '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')', - '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')', - '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')', - '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')', - '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')', - // Only on template invoices - '__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__' => $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')', - '__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__' => $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')', - ); - $substitutionarray['__(TransKey)__']=$langs->trans("TransKey"); + + $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); + + $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%m').')'; + $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%m').')'; + $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'),'%m').')'; + $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'),'%B').')'; + $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%B').')'; + $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'),'%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')'; + $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'; + // Only on template invoices + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')'; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($substitutionarray as $key => $val) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dcba7e20739..1d173d103fb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5287,13 +5287,15 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; - $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; - $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; - $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; - + if (is_object($object) && $object->element == 'shipping') + { + $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; + $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; + $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; + } $substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__'; $substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__'; - $substitutionarray['__PROJECT_NAME__'] = '__PROJECT_REF__'; + $substitutionarray['__PROJECT_NAME__'] = '__PROJECT_NAME__'; $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = 'Highest date planned for a service start'; $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = 'Highest date and hour planned for service start'; @@ -5307,9 +5309,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = 'Security key for payment on an invoice'; $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'Security key for payment on a a service'; - $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number'; - $substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url'; - + if (is_object($object) && $object->element == 'shipping') + { + $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number'; + $substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url'; + } } else { @@ -5396,6 +5400,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:''; $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object)?$object->total_ht:''; $substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; + /* TODO Add key for multicurrency + $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; + $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; + $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat?price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency_code):price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency_code)):''; + */ // For backward compatibility if ($onlykey != 2) { diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index a6cf54ab40d..836f435890b 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -165,7 +165,7 @@ if ($resql) $object = null; // Not defined with mass emailing $parameters=array('mode'=>'emailing'); - $substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On mass emailing, this is null because we don't know object + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'), $object); // Note: On mass emailing, this is null because we don't know object // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; From 16b766182c40dbb55fa62acedd591041f2688d86 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 15:35:08 +0200 Subject: [PATCH 015/128] NEW view company name if different of fullname in dol_banner --- htdocs/core/class/html.form.class.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d4c8ce6f288..3a571a7d75b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3581,7 +3581,7 @@ class Form } else if ($input['type'] == 'password') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'select') { @@ -6017,7 +6017,16 @@ class Form { $ret.=dol_htmlentities($object->name); } - else if (in_array($object->element, array('contact', 'user', 'usergroup', 'member'))) + else if ($object->element == 'member') + { + $fullname=$object->getFullName($langs); + if ($object->morphy == 'mor') { + $ret.= dol_htmlentities($object->societe) . (($object->societe != $fullname)?' ('.dol_htmlentities($fullname).')':''); + } else { + $ret.= dol_htmlentities($fullname) . (($object->societe != $fullname)?' ('.dol_htmlentities($object->societe).')':''); + } + } + else if (in_array($object->element, array('contact', 'user', 'usergroup'))) { $ret.=dol_htmlentities($object->getFullName($langs)); } From 86c301f197866bbae6b1f0cf33b8957ed2522e96 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 15:49:10 +0200 Subject: [PATCH 016/128] Fix: uniformize parameters --- htdocs/adherents/card.php | 4 ++-- htdocs/adherents/subscription.php | 4 ++-- htdocs/core/class/html.form.class.php | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index c95b62e1dc0..3d203334648 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1335,8 +1335,8 @@ else // Create a form array $formquestion=array( - array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"'), - array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"') + array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'), + array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') ); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 405fe689816..9fa30981a9f 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -976,8 +976,8 @@ if ($rowid > 0) // Create a form array $formquestion=array( - array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"'), - array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'css' => 'minwidth300', 'moreattr' => 'maxlength="128"') + array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'), + array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') ); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3a571a7d75b..e7902fe3289 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3573,28 +3573,28 @@ class Form { $size=(! empty($input['size'])?' size="'.$input['size'].'"':''); $moreattr=(! empty($input['moreattr'])?' '.$input['moreattr']:''); - $css=(! empty($input['css'])?' '.$input['css']:''); + $morecss=(! empty($input['morecss'])?' '.$input['morecss']:''); if ($input['type'] == 'text') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'password') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'select') { $more.=''; if (! empty($input['label'])) $more.=$input['label'].''; - $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1); + $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1,0,0,$moreattr,0,0,0,'',$morecss); $more.=''."\n"; } else if ($input['type'] == 'checkbox') { $more.=''; $more.=''.$input['label'].' '; - $more.=''; else $more.=' '; - $more.=' Date: Mon, 9 Oct 2017 16:13:53 +0200 Subject: [PATCH 017/128] NEW A module can change order of element in the quick search combo --- htdocs/core/ajax/selectsearchbox.php | 62 ++++++++++--------- .../template/class/actions_mymodule.class.php | 4 +- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 2d92bc8f938..f04e2e95b18 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -56,85 +56,85 @@ $arrayresult=array(); // Define $searchform if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) { - $arrayresult['searchintothirdparty']=array('img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintothirdparty']=array('position'=>10, 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('','object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) { - $arrayresult['searchintocontact']=array('img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintocontact']=array('position'=>15, 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('','object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php?sall='.urlencode($search_boxvalue)); +} + +if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) +{ + $arrayresult['searchintomember']=array('position'=>20, 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php?sall='.urlencode($search_boxvalue)); } if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) { - $arrayresult['searchintoproduct']=array('img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue),'text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoproduct']=array('position'=>30, 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue),'text'=>img_picto('','object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) { - $arrayresult['searchintoprojects']=array('img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php?search_all='.urlencode($search_boxvalue)); + $arrayresult['searchintoprojects']=array('position'=>40, 'img'=>'object_projectpub', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('','object_projectpub').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php?search_all='.urlencode($search_boxvalue)); } if (! empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) { - $arrayresult['searchintotasks']=array('img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php?search_all='.urlencode($search_boxvalue)); -} - -if (! empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) -{ - $arrayresult['searchintomember']=array('img'=>'object_user', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php?sall='.urlencode($search_boxvalue)); -} - -if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) -{ - $arrayresult['searchintouser']=array('img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/index.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintotasks']=array('position'=>45, 'img'=>'object_task', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('','object_task').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php?search_all='.urlencode($search_boxvalue)); } if (! empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) { - $arrayresult['searchintopropal']=array('img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintopropal']=array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) { - $arrayresult['searchintoorder']=array('img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php?sall='.urlencode($search_boxvalue)); -} -if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) -{ - $arrayresult['searchintoinvoice']=array('img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoorder']=array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) { - $arrayresult['searchintoshipment']=array('img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoshipment']=array('position'=>80, 'img'=>'object_sending', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('','object_sending').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php?sall='.urlencode($search_boxvalue)); +} +if (! empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) +{ + $arrayresult['searchintoinvoice']=array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) { - $arrayresult['searchintosupplierpropal']=array('img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintosupplierpropal']=array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire) { - $arrayresult['searchintosupplierorder']=array('img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue)); + $arrayresult['searchintosupplierorder']=array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue)); } if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) && $user->rights->fournisseur->facture->lire) { - $arrayresult['searchintosupplierinvoice']=array('img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintosupplierinvoice']=array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('','object_bill').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { - $arrayresult['searchintocontract']=array('img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintocontract']=array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('','object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode($search_boxvalue)); } if (! empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) { - $arrayresult['searchintointervention']=array('img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php?sall='.urlencode($search_boxvalue)); + $arrayresult['searchintointervention']=array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('','object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php?sall='.urlencode($search_boxvalue)); } + // HR +if (! empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) +{ + $arrayresult['searchintouser']=array('position'=>200, 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('','object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/index.php?sall='.urlencode($search_boxvalue)); +} if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) { - $arrayresult['searchintoexpensereport']=array('img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoexpensereport']=array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('','object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); } if (! empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) { - $arrayresult['searchintoleaves']=array('img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); + $arrayresult['searchintoleaves']=array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('','object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm&sall='.urlencode($search_boxvalue)); } @@ -147,7 +147,7 @@ if (! empty($conf->hrm->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_EMPLO */ // Execute hook addSearchEntry -$parameters=array('search_boxvalue'=>$search_boxvalue); +$parameters=array('search_boxvalue'=>$search_boxvalue, 'arrayresult'=>$arrayresult); $reshook=$hookmanager->executeHooks('addSearchEntry',$parameters); if (empty($reshook)) { @@ -155,6 +155,8 @@ if (empty($reshook)) } else $arrayresult=$hookmanager->resArray; +// Sort on position +$arrayresult = dol_sort_array($arrayresult, 'position'); // Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include if (! isset($usedbyinclude) || empty($usedbyinclude)) diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 7b353113c00..b0265a28e3f 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -81,8 +81,8 @@ class ActionsMyModule /* print_r($parameters); print_r($object); echo "action: " . $action; */ if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' { - - + // Do what you want here... + // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. } if (! $error) { From e2206d9bf2082475fdf675d379fc2dac4af0488a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 16:33:22 +0200 Subject: [PATCH 018/128] Fix: uniformize substitution tags --- htdocs/adherents/admin/adherent.php | 12 +-- htdocs/adherents/admin/adherent_emails.php | 12 +-- htdocs/adherents/cartes/carte.php | 40 ++++----- .../modules/member/doc/pdf_standard.class.php | 90 +++++++++---------- htdocs/core/modules/modAdherent.class.php | 14 +-- 5 files changed, 84 insertions(+), 84 deletions(-) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 93b90c01c92..ada5dd82060 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -240,9 +240,9 @@ $constantes=array( print load_fiche_titre($langs->trans("MembersCards"),'',''); $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; -$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; -$helptext.='%YEAR%, %MONTH%, %DAY%'; +$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; +$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; +$helptext.='__YEAR__, __MONTH__, __DAY__'; form_constantes($constantes, 0, $helptext); @@ -257,9 +257,9 @@ $constantes=array('ADHERENT_ETIQUETTE_TYPE','ADHERENT_ETIQUETTE_TEXT'); print load_fiche_titre($langs->trans("MembersTickets"),'',''); $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; -$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; -$helptext.='%YEAR%, %MONTH%, %DAY%'; +$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; +$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; +$helptext.='__YEAR__, __MONTH__, __DAY__'; form_constantes($constantes, 0, $helptext); diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index a4c2f937146..ac4d88b1bba 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -171,14 +171,14 @@ $constantes=array( ); $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; -$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; -$helptext.='%YEAR%, %MONTH%, %DAY%'; +$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; +$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; +$helptext.='__YEAR__, __MONTH__, __DAY__'; $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; -$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, '; -$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, '; -//$helptext.='%YEAR%, %MONTH%, %DAY%'; // Not supported +$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, '; +$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, '; +//$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported form_constantes($constantes, 0, $helptext); diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 63fd59f01e9..487dfa7f225 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -116,25 +116,25 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg // List of values to scan for a replacement $substitutionarray = array ( - '%ID%'=>$objp->rowid, - '%LOGIN%'=>$objp->login, - '%FIRSTNAME%'=>$objp->firstname, - '%LASTNAME%'=>$objp->lastname, - '%FULLNAME%'=>$adherentstatic->getFullName($langs), - '%COMPANY%'=>$objp->company, - '%ADDRESS%'=>$objp->address, - '%ZIP%'=>$objp->zip, - '%TOWN%'=>$objp->town, - '%COUNTRY%'=>$objp->country, - '%COUNTRY_CODE%'=>$objp->country_code, - '%EMAIL%'=>$objp->email, - '%BIRTH%'=>dol_print_date($objp->birth,'day'), - '%TYPE%'=>$objp->type, - '%YEAR%'=>$year, - '%MONTH%'=>$month, - '%DAY%'=>$day, - '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, - '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" + '__ID__'=>$objp->rowid, + '__LOGIN__'=>$objp->login, + '__FIRSTNAME__'=>$objp->firstname, + '__LASTNAME__'=>$objp->lastname, + '__FULLNAME__'=>$adherentstatic->getFullName($langs), + '__COMPANY__'=>$objp->company, + '__ADDRESS__'=>$objp->address, + '__ZIP__'=>$objp->zip, + '__TOWN__'=>$objp->town, + '__COUNTRY__'=>$objp->country, + '__COUNTRY_CODE__'=>$objp->country_code, + '__EMAIL__'=>$objp->email, + '__BIRTH__'=>dol_print_date($objp->birth,'day'), + '__TYPE__'=>$objp->type, + '__YEAR__'=>$year, + '__MONTH__'=>$month, + '__DAY__'=>$day, + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, + '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" ); complete_substitutions_array($substitutionarray, $langs, $adherentstatic); @@ -179,7 +179,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg // For labels if ($mode == 'label') { - if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="%FULLNAME%\n%ADDRESS%\n%ZIP% %TOWN%\n%COUNTRY%"; + if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); $textheader=''; $textfooter=''; diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 6fd8ecfee70..4d08be83a43 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -48,8 +48,8 @@ class pdf_standard extends CommonStickerGenerator /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) - * - %LOGO% is replace with company logo - * - %PHOTO% is replace with photo provided as parameter + * - __LOGO__ is replace with company logo + * - __PHOTO__ is replace with photo provided as parameter * * @param PDF $pdf PDF * @param string $textleft Text left @@ -58,7 +58,7 @@ class pdf_standard extends CommonStickerGenerator * @param Translate $outputlangs Output langs * @param string $textright Text right * @param int $idmember Id member - * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text) + * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) * @return void */ function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='') @@ -95,7 +95,7 @@ class pdf_standard extends CommonStickerGenerator $member=new Adherent($db); $member->id = $idmember; $member->ref = $idmember; - + // Define photo $dir=$conf->adherent->dir_output; if (! empty($photo)) @@ -161,8 +161,8 @@ class pdf_standard extends CommonStickerGenerator if ($textright=='') // Only a left part { // Output left area - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); else { $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); @@ -171,17 +171,17 @@ class pdf_standard extends CommonStickerGenerator } else if ($textleft!='' && $textright!='') // { - if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') + if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') { - if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); - else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop); $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); } - else if ($textright == '%LOGO%' || $textright == '%PHOTO%') + else if ($textright == '__LOGO__' || $textright == '__PHOTO__') { - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L'); } @@ -196,8 +196,8 @@ class pdf_standard extends CommonStickerGenerator else // Only a right part { // Output right area - if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); - else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); + else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse); else { $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop); @@ -247,34 +247,34 @@ class pdf_standard extends CommonStickerGenerator function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0) { global $user,$conf,$langs,$mysoc,$_Avery_Labels; - + $this->code=$srctemplatepath; - + if (is_object($object)) { if ($object->country == '-') $object->country=''; // List of values to scan for a replacement $substitutionarray = array ( - '%ID%'=>$object->rowid, - '%LOGIN%'=>$object->login, - '%FIRSTNAME%'=>$object->firstname, - '%LASTNAME%'=>$object->lastname, - '%FULLNAME%'=>$object->getFullName($langs), - '%COMPANY%'=>$object->company, - '%ADDRESS%'=>$object->address, - '%ZIP%'=>$object->zip, - '%TOWN%'=>$object->town, - '%COUNTRY%'=>$object->country, - '%COUNTRY_CODE%'=>$object->country_code, - '%EMAIL%'=>$object->email, - '%BIRTH%'=>dol_print_date($object->birth,'day'), - '%TYPE%'=>$object->type, - '%YEAR%'=>$year, - '%MONTH%'=>$month, - '%DAY%'=>$day, - '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, - '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" + '__ID__'=>$object->rowid, + '__LOGIN__'=>$object->login, + '__FIRSTNAME__'=>$object->firstname, + '__LASTNAME__'=>$object->lastname, + '__FULLNAME__'=>$object->getFullName($langs), + '__COMPANY__'=>$object->company, + '__ADDRESS__'=>$object->address, + '__ZIP__'=>$object->zip, + '__TOWN__'=>$object->town, + '__COUNTRY__'=>$object->country, + '__COUNTRY_CODE__'=>$object->country_code, + '__EMAIL__'=>$object->email, + '__BIRTH__'=>dol_print_date($object->birth,'day'), + '__TYPE__'=>$object->type, + '__YEAR__'=>$year, + '__MONTH__'=>$month, + '__DAY__'=>$day, + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, + '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" ); complete_substitutions_array($substitutionarray, $langs); @@ -283,10 +283,10 @@ class pdf_standard extends CommonStickerGenerator $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); - + $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY']; if ($nb <= 0) $nb=1; // Protection to avoid empty page - + for($j=0;$j<$nb;$j++) { $arrayofmembers[]=array( @@ -298,7 +298,7 @@ class pdf_standard extends CommonStickerGenerator 'photo'=>$object->photo ); } - + $arrayofrecords = $arrayofmembers; } else @@ -348,7 +348,7 @@ class pdf_standard extends CommonStickerGenerator $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member'); $file = $dir.'/'.$filename; } - else + else { $outputdir = $conf->adherent->dir_temp; $dir = $outputdir; @@ -419,28 +419,28 @@ class pdf_standard extends CommonStickerGenerator $this->result = array('fullpath'=>$file); - + // Output to http stream if (empty($nooutput)) { clearstatcache(); - + $attachment=true; if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; $type=dol_mimetype($filename); - + //if ($encoding) header('Content-Encoding: '.$encoding); if ($type) header('Content-Type: '.$type); if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"'); - + // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); header('Pragma: public'); - + readfile($file); } - + return 1; } diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index ade0e2c7e75..aa098146dc7 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -93,7 +93,7 @@ class modAdherent extends DolibarrModules $this->const[$r][0] = "ADHERENT_MAIL_VALID"; $this->const[$r][1] = "texte"; - $this->const[$r][2] = "Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n%INFOS%\r\n\r\n"; + $this->const[$r][2] = "Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n__INFOS__\r\n\r\n"; $this->const[$r][3] = "Mail de validation"; $this->const[$r][4] = 0; $r++; @@ -121,7 +121,7 @@ class modAdherent extends DolibarrModules $this->const[$r][0] = "ADHERENT_MAIL_COTIS"; $this->const[$r][1] = "texte"; - $this->const[$r][2] = "Bonjour %FIRSTNAME%,\r\nCet email confirme que votre cotisation a été reçue\r\net enregistrée"; + $this->const[$r][2] = "Bonjour __FIRSTNAME__,\r\nCet email confirme que votre cotisation a été reçue\r\net enregistrée"; $this->const[$r][3] = "Mail de validation de cotisation"; $this->const[$r][4] = 0; $r++; @@ -135,21 +135,21 @@ class modAdherent extends DolibarrModules $this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "%YEAR%"; + $this->const[$r][2] = "__YEAR__"; $this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent"; $this->const[$r][4] = 0; $r++; $this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "%COMPANY%"; + $this->const[$r][2] = "__COMPANY__"; $this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent"; $this->const[$r][4] = 0; $r++; $this->const[$r][0] = "ADHERENT_CARD_TEXT"; $this->const[$r][1] = "texte"; - $this->const[$r][2] = "%FULLNAME%\r\nID: %ID%\r\n%EMAIL%\r\n%ADDRESS%\r\n%ZIP% %TOWN%\r\n%COUNTRY%"; + $this->const[$r][2] = "__FULLNAME__\r\nID: __ID__\r\n__EMAIL__\r\n__ADDRESS__\r\n__ZIP__ __TOWN__\r\n__COUNTRY__"; $this->const[$r][3] = "Text to print on member cards"; $this->const[$r][4] = 0; $r++; @@ -184,7 +184,7 @@ class modAdherent extends DolibarrModules $this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT"; $this->const[$r][1] = "texte"; - $this->const[$r][2] = "%FULLNAME%\n%ADDRESS%\n%ZIP% %TOWN%\n%COUNTRY%"; + $this->const[$r][2] = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY%"; $this->const[$r][3] = "Text to print on member address sheets"; $this->const[$r][4] = 0; $r++; @@ -324,7 +324,7 @@ class modAdherent extends DolibarrModules // End add extra fields $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array('a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); - $this->import_examplevalues_array[$r]=array('a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); + $this->import_examplevalues_array[$r]=array('a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')); } From 4e34c13e49b770748955f4541b5723a10a7de8ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 16:49:17 +0200 Subject: [PATCH 019/128] Debug --- htdocs/modulebuilder/template/myobject_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 5677ab3baf2..b6c2f86e13f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -369,7 +369,7 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''."\n"; @@ -633,7 +633,7 @@ print ''."\n"; print ''."\n"; -if ($nbtotalofrecords === '' || $nbtotalofrecords) +if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { From 625e440653b71b0b18821408fafd61e6cf064953 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 16:50:20 +0200 Subject: [PATCH 020/128] Fix: wrong test --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e7902fe3289..3066c7c9518 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6021,9 +6021,9 @@ class Form { $fullname=$object->getFullName($langs); if ($object->morphy == 'mor') { - $ret.= dol_htmlentities($object->societe) . (($object->societe != $fullname)?' ('.dol_htmlentities($fullname).')':''); + $ret.= dol_htmlentities($object->societe) . ((! empty($fullname) && $object->societe != $fullname)?' ('.dol_htmlentities($fullname).')':''); } else { - $ret.= dol_htmlentities($fullname) . (($object->societe != $fullname)?' ('.dol_htmlentities($object->societe).')':''); + $ret.= dol_htmlentities($fullname) . ((! empty($object->societe) && $object->societe != $fullname)?' ('.dol_htmlentities($object->societe).')':''); } } else if (in_array($object->element, array('contact', 'user', 'usergroup'))) From 2bd66290a34e1cb24e0ea3fb15e79d8e24baa85c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 16:58:17 +0200 Subject: [PATCH 021/128] Fix: for avoid scroll bar --- htdocs/adherents/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 3d203334648..0fa17e39167 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1354,8 +1354,8 @@ else $texttosend=$object->makeSubstitution($adht->getMailOnValid()); $tmp=$langs->trans("SendAnEMailToMember"); - $tmp.='
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; - $tmp.=$langs->trans("MailRecipient").': '.$object->email.')'; + $tmp.='
'.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; + $tmp.='
'.$langs->trans("MailRecipient").': '.$object->email.''; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; From 19de053054ce0912023ec44349fb160fc2c1519c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 17:43:57 +0200 Subject: [PATCH 022/128] Fix itf8 mix collation --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index a2534728683..634045d3e4e 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -26,6 +26,12 @@ +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) COLLATE utf8_unicode_ci; + + ALTER TABLE llx_holiday_config MODIFY COLUMN name varchar(128); ALTER TABLE llx_supplier_proposaldet CHANGE COLUMN fk_askpricesupplier fk_supplier_proposal integer NOT NULL; From 15911a9b649a6cbc79b71ba8e4c716c60f163bd4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 17:45:08 +0200 Subject: [PATCH 023/128] Fix illegal mix collation --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 4 ++++ htdocs/install/mysql/migration/repair.sql | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 223a8aeeeb4..bc9fad269a9 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -338,6 +338,10 @@ DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPENSEREPORT_JOURNAL') -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index ee4c549ccd3..7bc403fd3b3 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -31,6 +31,10 @@ -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; From dcf497f3327aafc00b390e3fb0b355e37835052f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 9 Oct 2017 17:55:14 +0200 Subject: [PATCH 024/128] Fix: add $confirm value inside doAction hook parameters --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0fa17e39167..95cfd729fe5 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -121,7 +121,7 @@ $hookmanager->initHooks(array('membercard','globalcard')); * Actions */ -$parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas); +$parameters=array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'=>$confirm); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); From 4de1ade605f3722dd7b7e2e87e6ffe4b63b20f11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 18:15:10 +0200 Subject: [PATCH 025/128] Fix mix collation --- .../install/mysql/migration/6.0.0-7.0.0.sql | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index bc9fad269a9..3ecf4b405c8 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -25,6 +25,28 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batch MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batch MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_sell VARCHAR(32) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_sell VARCHAR(32) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_buy VARCHAR(32) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_buy VARCHAR(32) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_c_type_fees MODIFY accountancy_code VARCHAR(32) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_c_type_fees MODIFY accountancy_code VARCHAR(32) COLLATE utf8_unicode_ci; + + -- Missing in 5.0 ALTER TABLE llx_user MODIFY login varchar(50) NOT NULL; @@ -334,27 +356,6 @@ DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_DEVISE')__; DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPORT_PIECE')__; DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_EXPENSEREPORT_JOURNAL')__; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batch MODIFY batch VARCHAR(30) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batch MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_sell VARCHAR(32) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_sell VARCHAR(32) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_buy VARCHAR(32) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_product MODIFY accountancy_code_buy VARCHAR(32) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_c_type_fees MODIFY accountancy_code VARCHAR(32) CHARACTER SET utf8; --- VMYSQLUTF8UNICODECI ALTER TABLE llx_c_type_fees MODIFY accountancy_code VARCHAR(32) COLLATE utf8_unicode_ci; - ALTER TABLE llx_c_paiement DROP PRIMARY KEY; ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement; From 9427655dd09bdacc2f38e9c9d4886b78a474eaf4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 18:18:34 +0200 Subject: [PATCH 026/128] Option PROJECT_LINES_PERxxx_SHOW_THIRDPARTY is the default --- htdocs/core/lib/project.lib.php | 30 ++++++++++++------------------ htdocs/projet/activity/perday.php | 10 +++------- htdocs/projet/activity/perweek.php | 10 +++------- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e6c49492769..05bbcf26098 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -663,15 +663,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); print ""; - if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) - { - // Thirdparty - print '
'; - } + // Thirdparty + print ''; // Ref print '"; - if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) - { - // Thirdparty - print ''; - } + // Thirdparty + print ''; // Ref print ''."\n"; print ''."\n"; print ''."\n"; @@ -343,7 +345,7 @@ foreach($configfileparameters as $key => $value) { $newkey = preg_replace('/^\?/','',$key); - if (preg_match('/^\?/',$key) && empty(${$newkey})) + if (preg_match('/^\?/',$key) && empty(${$newkey})) { if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) continue; // We discard parameters starting with ? diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a47f6d9735d..046fb1e6967 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1723,6 +1723,7 @@ MultiPriceRuleDesc=When option "Several level of prices per product/service" is ModelModulesProduct=Templates for product documents ToGenerateCodeDefineAutomaticRuleFirst=To be able to generate automatically codes, you must first define a manager to auto define barcode number. SeeSubstitutionVars=See * note for list of possible substitution variables +SeeChangeLog=See ChangeLog file (english only) AllPublishers=All publishers UnknownPublishers=Unknown publishers AddRemoveTabs=Add or remove tabs From 2a76cc6f5434a6839c84d0835dbec57ef43fa9c3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 10 Oct 2017 06:34:16 +0200 Subject: [PATCH 032/128] Fix : missing class AccountingJournal in subscription member page when accountancy not activated --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8002b33b1f6..9bb4565d6c9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; $langs->load("companies"); $langs->load("bills"); From 00db16e0deab03cb0fcf85458db42d6f7d1acfe4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 08:49:00 +0200 Subject: [PATCH 033/128] Fix: force jquery cal if MAIN_POPUP_CALENDAR=eldy (showDP commented) --- htdocs/core/class/html.form.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 93c24990af0..7c4948789b1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4742,7 +4742,9 @@ class Form // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' $usecalendar='combo'; - if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) $usecalendar=empty($conf->global->MAIN_POPUP_CALENDAR)?'jquery':$conf->global->MAIN_POPUP_CALENDAR; + if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) { + $usecalendar = ((empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR == 'eldy')?'jquery':$conf->global->MAIN_POPUP_CALENDAR); + } //if (! empty($conf->browser->phone)) $usecalendar='combo'; if ($d) From f51c0db7059862c78ecd5fb8d9e4941f9e19c732 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 09:16:14 +0200 Subject: [PATCH 034/128] NEW add translation and possibility to change month and year --- htdocs/core/class/html.form.class.php | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 7c4948789b1..4af8364a751 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4790,7 +4790,54 @@ class Form $retstring.="'."\n"; - // Add datepicker default options - /*if (! defined('DISABLE_DATE_PICKER')) + // Add datepicker default options (needed by jquery datepicker!) + if (! defined('DISABLE_DATE_PICKER')) { print ''."\n"; - }*/ + } // JS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) From 4530f94fa67b93675619a4903771a21c097c37ac Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 10:07:52 +0200 Subject: [PATCH 038/128] Fix: restore parameters, needed for save in place --- htdocs/core/js/datepicker.js.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/js/datepicker.js.php b/htdocs/core/js/datepicker.js.php index a763533f9b3..3de57f0543f 100644 --- a/htdocs/core/js/datepicker.js.php +++ b/htdocs/core/js/datepicker.js.php @@ -119,7 +119,9 @@ $(document).ready(function() { $.datepicker.setDefaults({ autoSize: true, changeMonth: true, - changeYear: true + changeYear: true, + altField: '#timestamp', + altFormat: '@' // Gives a timestamp dateformat }); }); From 572a64bdbf67021cf4e12105cbf9ba9e509cf455 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Tue, 10 Oct 2017 10:19:04 +0200 Subject: [PATCH 039/128] display mobile picto runs with #6617 --- htdocs/core/lib/functions.lib.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1d173d103fb..cbad1ab7e62 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2194,9 +2194,21 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep $titlealt=($withpicto=='fax'?$langs->trans("Fax"):$langs->trans("Phone")); } $rep=''; + $picto = ''; + if($withpicto){ + if($withpicto=='fax'){ + $picto = 'phoning_fax'; + }elseif($withpicto=='phone'){ + $picto = 'phoning'; + }elseif($withpicto=='mobile'){ + $picto = 'phoning_mobile'; + }else{ + $picto = ''; + } + } if ($adddivfloat) $rep.='
'; else $rep.=''; - $rep.=($withpicto?img_picto($titlealt, 'object_'.($withpicto=='fax'?'phoning_fax':'phoning').'.png').' ':'').$newphone; + $rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone; if ($adddivfloat) $rep.='
'; else $rep.=''; return $rep; @@ -6776,4 +6788,4 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield=' if ($id > 0) return $id; return ''; } -} \ No newline at end of file +} From ce6d6dcfbc7bc31604ad5c52717fc5e81fcd5d96 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 10:37:57 +0200 Subject: [PATCH 040/128] NEW add image object_phoning_mobile.png --- htdocs/theme/eldy/img/object_phoning_mobile.png | Bin 0 -> 435 bytes htdocs/theme/md/img/object_phoning_mobile.png | Bin 0 -> 435 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/theme/eldy/img/object_phoning_mobile.png create mode 100644 htdocs/theme/md/img/object_phoning_mobile.png diff --git a/htdocs/theme/eldy/img/object_phoning_mobile.png b/htdocs/theme/eldy/img/object_phoning_mobile.png new file mode 100644 index 0000000000000000000000000000000000000000..c94fd72ae14fdf3d710071304d1bcdf8e8e51c36 GIT binary patch literal 435 zcmV;k0ZjghP)DJU3+O^@f!8|0tDT3y z=U_0P+wJ1QZntB(TmrlRU(NfED2j9oVHgT{Kan140;bpNIXl&a%bp)5;`F;23zmi2mlQ9R}H{F{+FEdWGOM3N-5S}jJS5tGRTfFwzXOPDg-(AdoTUwuSL{OrGZ$ zW0=q9WLXA4p65)b)3dJiDOfoEbX8SIV!z*WI2-_|stRlEsrK7tVaVU7@az(R<2sjD dh$W46{sB@}vq%b)znTC5002ovPDHLkV1ig?w`c$W literal 0 HcmV?d00001 diff --git a/htdocs/theme/md/img/object_phoning_mobile.png b/htdocs/theme/md/img/object_phoning_mobile.png new file mode 100644 index 0000000000000000000000000000000000000000..c94fd72ae14fdf3d710071304d1bcdf8e8e51c36 GIT binary patch literal 435 zcmV;k0ZjghP)DJU3+O^@f!8|0tDT3y z=U_0P+wJ1QZntB(TmrlRU(NfED2j9oVHgT{Kan140;bpNIXl&a%bp)5;`F;23zmi2mlQ9R}H{F{+FEdWGOM3N-5S}jJS5tGRTfFwzXOPDg-(AdoTUwuSL{OrGZ$ zW0=q9WLXA4p65)b)3dJiDOfoEbX8SIV!z*WI2-_|stRlEsrK7tVaVU7@az(R<2sjD dh$W46{sB@}vq%b)znTC5002ovPDHLkV1ig?w`c$W literal 0 HcmV?d00001 From 0abc16b27fc926a0dfb60ed59bb13742445fd96d Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Tue, 10 Oct 2017 14:55:42 +0200 Subject: [PATCH 041/128] Add class Add oddeven class to tr tag --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 06f7af5b8d6..ce5d4ec55eb 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -623,7 +623,7 @@ if ($mode == 'common') $imginfo="info_black"; } - print '
'."\n"; + print ''."\n"; // Picto + Name of module print ' '; From 6d5c2bf7b2fe29383d76107d0d19f3c32f7df818 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 07:56:10 +0200 Subject: [PATCH 044/128] Fix: check if module bank activated Conflicts: htdocs/adherents/subscription.php --- htdocs/adherents/class/subscription.class.php | 9 ++--- htdocs/adherents/subscription.php | 30 +++++++------- htdocs/adherents/subscription/card.php | 33 ++++++++-------- htdocs/adherents/subscription/list.php | 39 ++++++++++--------- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 733524e53c0..bdb43dd41d3 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -33,7 +33,7 @@ class Subscription extends CommonObject public $element='subscription'; public $table_element='subscription'; public $picto='payment'; - + var $datec; // Date creation var $datem; // Date modification var $dateh; // Subscription start date (date subscription) @@ -193,12 +193,11 @@ class Subscription extends CommonObject */ function delete($user) { - $accountline=new AccountLine($this->db); - // It subscription is linked to a bank transaction, we get it if ($this->fk_bank > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline=new AccountLine($this->db); $result=$accountline->fetch($this->fk_bank); } @@ -288,7 +287,7 @@ class Subscription extends CommonObject { return ''; } - + /** * Renvoi le libelle d'un statut donne * @@ -301,7 +300,7 @@ class Subscription extends CommonObject $langs->load("members"); return ''; } - + /** * Load information of the subscription object * diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 7c0a0cfe407..2bdbe821105 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -32,7 +32,10 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // TODO a lot of dependency on the bank module, but no test if this module is not activated! +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } @@ -823,7 +826,6 @@ if ($rowid > 0) if ($result) { $subscriptionstatic=new Subscription($db); - $accountstatic=new Account($db); $num = $db->num_rows($result); $i = 0; @@ -853,15 +855,17 @@ if ($rowid > 0) print '\n"; print '\n"; print ''; - if (! empty($conf->banque->enabled)) - { - print ''; - } + print ''; + } } print '
'; - $thirdpartystatic->id=$lines[$i]->socid; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - print $thirdpartystatic->getNomUrl(1, 'project', 10); - print ''; + $thirdpartystatic->id=$lines[$i]->socid; + $thirdpartystatic->name=$lines[$i]->thirdparty_name; + print $thirdpartystatic->getNomUrl(1, 'project', 10); + print ''; @@ -897,15 +894,12 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); print "'; - $thirdpartystatic->id=$lines[$i]->thirdparty_id; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - print $thirdpartystatic->getNomUrl(1, 'project'); - print ''; + $thirdpartystatic->id=$lines[$i]->thirdparty_id; + $thirdpartystatic->name=$lines[$i]->thirdparty_name; + print $thirdpartystatic->getNomUrl(1, 'project'); + print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 4947e71f8c8..ba703f6128c 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -444,7 +444,7 @@ print ''; print ''; -if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) print ''; +print ''; print ''; print ''; print ''; @@ -463,10 +463,7 @@ print "\n"; print ''; print ''; -if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) -{ - print ''; -} +print ''; print ''; print ''; print ''; @@ -498,8 +495,7 @@ if (count($tasksarray) > 0) $j=0; projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable); - $colspan = 8; - if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY)) $colspan++; + $colspan = 9; print ''; + print ''; } print "
'.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").'
'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 873ebfdb442..a12d53cf60a 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -440,7 +440,7 @@ print ''; print ''; -if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) print ''; +print ''; print ''; print ''; print ''; @@ -460,10 +460,7 @@ print "\n"; print ''; print ''; -if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) -{ - print ''; -} +print ''; print ''; print ''; print ''; @@ -511,8 +508,7 @@ if (count($tasksarray) > 0) $level=0; projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable); - $colspan=7; - if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++; + $colspan=8; print ''; + print ''; } print "
'.$langs->trans("ProjectRef").''.$langs->trans("ThirdParty").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("PlannedWorkload").'
'; From dce71d6e7db2fe3b06783d27e2668e332e0274f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 18:51:33 +0200 Subject: [PATCH 027/128] Fix loose filter --- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/perweek.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 64ced5f3a5a..b767c35e329 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -493,7 +493,7 @@ if (count($tasksarray) > 0) } else { - print '
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index f7a1397f475..438d71cbdba 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -283,8 +283,17 @@ if ($action == 'addtime' && $user->rights->projet->lire) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $param=''; + $param.=($mode?'&mode='.$mode:''); + $param.=($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''); + $param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); + $param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:''); + $param.=($search_thirdparty?'&search_thirdparty='.$search_thirdparty:''); + $param.=($search_task_ref?'&search_task_ref='.$search_task_ref:''); + $param.=($search_task_label?'&search_task_label='.$search_task_label:''); + // Redirect to avoid submit twice on back - header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:'')); + header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); exit; } } @@ -511,7 +520,7 @@ if (count($tasksarray) > 0) } else { - print '
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; print ''; From 666e62b440116f5de1df05bae6cf11ea88ce72be Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Mon, 9 Oct 2017 17:54:15 +0100 Subject: [PATCH 028/128] Fixed issue with inexistent constant in commande STATUS_ACCEPTED --- htdocs/commande/card.php | 4 ++-- htdocs/commande/list.php | 2 +- htdocs/commande/stats/index.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8d500f55e69..312ccebfb69 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2479,7 +2479,7 @@ if ($action == 'create' && $user->rights->commande->creer) } // Create contract - if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED || $object->statut == Commande::STATUS_CLOSED)) { + if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { $langs->load("contracts"); if ($user->rights->contrat->creer) { @@ -2512,7 +2512,7 @@ if ($action == 'create' && $user->rights->commande->creer) } // Set to shipped - if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED) && $user->rights->commande->cloturer) { + if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $user->rights->commande->cloturer) { print ''; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index c5cc5f9b715..72f2ac61213 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -917,7 +917,7 @@ if ($resql) $liststatus=array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 6a8b57e3707..b1baf7332a1 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -280,7 +280,7 @@ if ($mode == 'customer') $liststatus=array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSent"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSent"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") ); From dd69f762129222c4c95e493eeb4fc0e5b7efebda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 19:21:25 +0200 Subject: [PATCH 029/128] Move translation key --- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/products.lang | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7383cdea931..91d642bef7e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -27,6 +27,7 @@ DatabaseConnection=Database connection NoTemplateDefined=No template available for this email type AvailableVariables=Available substitution variables NoTranslation=No translation +Translation=Translation NoRecordFound=No record found NoRecordDeleted=No record deleted NotEnoughDataYet=Not enough data diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b324154e9d0..55138235335 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -100,7 +100,6 @@ ParentProductsNumber=Number of parent packaging product ParentProducts=Parent products IfZeroItIsNotAVirtualProduct=If 0, this product is not a virtual product IfZeroItIsNotUsedByVirtualProduct=If 0, this product is not used by any virtual product -Translation=Translation KeywordFilter=Keyword filter CategoryFilter=Category filter ProductToAddSearch=Search product to add From 3b6f6c40274fa51fb85cad0920d6197d294792de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 19:51:42 +0200 Subject: [PATCH 030/128] Translation --- htdocs/langs/en_US/admin.lang | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cb0cb9fcdaa..a47f6d9735d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1753,7 +1753,11 @@ TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta i BaseCurrency=Reference currency of the company (go into setup of company to change this) WarningNoteModuleInvoiceForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016). WarningNoteModulePOSForFrenchLaw=This module %s is compliant with french laws (Loi Finance 2016) because module Non Reversible Logs is automatically activated. -WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the publisher of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. +WarningInstallationMayBecomeNotCompliantWithLaw=You try to install the module %s that is an external module. Activating an external module means you trust the publisher of the module and you are sure that this module does not alterate negatively the behavior of your application and is compliant with laws of your country (%s). If the module bring a non legal feature, you become responsible for the use of a non legal software. +MAIN_PDF_MARGIN_LEFT=Left margin on PDF +MAIN_PDF_MARGIN_RIGHT=Right margin on PDF +MAIN_PDF_MARGIN_TOP=Top margin on PDF +MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From 0b7aa204643fc9cd59475f7720a7c965efcb4f54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Oct 2017 22:52:26 +0200 Subject: [PATCH 031/128] Add link to ChangeLog --- htdocs/admin/system/dolibarr.php | 12 +++++++----- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 36260c0a228..5daaca5e29e 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -54,7 +54,7 @@ if ($action == 'getlastversion') $sfurl = simplexml_load_string($result['content']); } - + /* * View */ @@ -107,19 +107,21 @@ if (function_exists('curl_init')) } // Show version - print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .'
'; + print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .''; } else { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("UpdateServerOffline").'
'; + print $langs->trans("LastStableVersion").' : ' .$langs->trans("UpdateServerOffline").''; } } else { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").'
'; + print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").''; } } +print '     -     '; +print ''.$langs->trans("SeeChangeLog").''; print '
'.$langs->trans("VersionLastUpgrade").' ('.$langs->trans("Database").')'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'
'.$langs->trans("VersionLastInstall").''.$conf->global->MAIN_VERSION_LAST_INSTALL.'
'; From d404d8be9f8675ad769635b17771685c88e065e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Oct 2017 18:54:30 +0200 Subject: [PATCH 042/128] Debug to make MAIN_ODT_AS_PDF workign with unoconv --- htdocs/includes/odtphp/odf.php | 89 ++++++++++++++++++++++++---------- scripts/odt2pdf/odt2pdf.sh | 31 ++++++++++-- 2 files changed, 89 insertions(+), 31 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 01633634705..19fd3390937 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -36,14 +36,14 @@ class Odf protected $images = array(); protected $vars = array(); protected $segments = array(); - + public $creator; public $title; public $subject; public $userdefined=array(); - + const PIXEL_TO_CM = 0.026458333; - + /** * Class constructor * @@ -113,7 +113,7 @@ class Odf copy($filename, $this->tmpfile); - // Now file has been loaded, we must move the [!-- BEGIN and [!-- END tags outside the + // Now file has been loaded, we must move the [!-- BEGIN and [!-- END tags outside the // _moveRowSegments(); } @@ -124,7 +124,7 @@ class Odf * @param string $key Name of the variable within the template * @param string $value Replacement value * @param bool $encode If true, special XML characters are encoded - * @param string $charset Charset + * @param string $charset Charset * @throws OdfException * @return odf */ @@ -211,7 +211,7 @@ class Odf { preg_match_all('/[\{\<]\?(php)?\s+(?P.+)\?[\}\>]/iU',$this->contentXml, $matches); // detecting all {?php code ?} or $nbfound=count($matches['content']); - for ($i=0; $i < $nbfound; $i++) + for ($i=0; $i < $nbfound; $i++) { try { $ob_output = ''; // flush the output for each code. This var will be filled in by the eval($code) and output buffering : any print or echo or output will be redirected into this variable @@ -268,7 +268,7 @@ IMG; $this->contentXml = preg_replace('/\[!--\sBEGIN]>(row.[\S]*)\s--\]/sm', '[!-- BEGIN \\1 --]', $this->contentXml); // Replace ENDxxx into END xxx $this->contentXml = preg_replace('/\[!--\sEND]>(row.[\S]*)\s--\]/sm', '[!-- END \\1 --]', $this->contentXml); - + // Search all possible rows in the document $reg1 = "#]*>(.*)#smU"; preg_match_all($reg1, $this->contentXml, $matches); @@ -302,7 +302,7 @@ IMG; // Search all tags fou into condition to complete $this->vars, so we will proceed all tests even if not defined $reg='@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; preg_match_all($reg, $this->contentXml, $matches, PREG_SET_ORDER); - + //var_dump($this->vars);exit; foreach($matches as $match) // For each match, if there is no entry into this->vars, we add it { @@ -312,7 +312,7 @@ IMG; } } //var_dump($this->vars);exit; - + // Conditionals substitution // Note: must be done before static substitution, else the variable will be replaced by its value and the conditional won't work anymore foreach($this->vars as $key => $value) @@ -358,7 +358,7 @@ IMG; if ($type == 'content') $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml); if ($type == 'styles') $this->stylesXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->stylesXml); if ($type == 'meta') $this->metaXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->metaXml); - + } /** @@ -467,7 +467,7 @@ IMG; $this->setMetaData(); //print $this->metaXml;exit; - + if (! $this->file->addFromString('content.xml', $this->contentXml)) { throw new OdfException('Error during file export addFromString content'); } @@ -477,7 +477,7 @@ IMG; if (! $this->file->addFromString('styles.xml', $this->stylesXml)) { throw new OdfException('Error during file export addFromString styles'); } - + foreach ($this->images as $imageKey => $imageValue) { // Add the image inside the ODT document $this->file->addFile($imageKey, 'Pictures/' . $imageValue); @@ -499,12 +499,12 @@ IMG; public function setMetaData() { if (empty($this->creator)) $this->creator=''; - + $this->metaXml = preg_replace('/.*<\/dc:date>/', ''.gmdate("Y-m-d\TH:i:s").'', $this->metaXml); $this->metaXml = preg_replace('/.*<\/dc:creator>/', ''.htmlspecialchars($this->creator).'', $this->metaXml); $this->metaXml = preg_replace('/.*<\/dc:title>/', ''.htmlspecialchars($this->title).'', $this->metaXml); $this->metaXml = preg_replace('/.*<\/dc:subject>/', ''.htmlspecialchars($this->subject).'', $this->metaXml); - + if (count($this->userdefined)) { foreach($this->userdefined as $key => $val) @@ -515,7 +515,7 @@ IMG; } } } - + /** * Update Manifest file according to added image files * @@ -569,24 +569,58 @@ IMG; { global $conf; - if( $name == "" ) $name = md5(uniqid()); + if( $name == "" ) $name = "temp".md5(uniqid()); dol_syslog(get_class($this).'::exportAsAttachedPDF $name='.$name, LOG_DEBUG); $this->saveToDisk($name); $execmethod=(empty($conf->global->MAIN_EXEC_USE_POPEN)?1:2); // 1 or 2 + // Method 1 sometimes hang the server. - $name=preg_replace('/\.odt/i', '', $name); - if (!empty($conf->global->MAIN_DOL_SCRIPTS_ROOT)) + if (preg_match('/unoconv/', $conf->global->MAIN_ODT_AS_PDF)) { - $command = $conf->global->MAIN_DOL_SCRIPTS_ROOT.'/scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($name).' '.(is_numeric($conf->global->MAIN_ODT_AS_PDF)?'jodconverter':$conf->global->MAIN_ODT_AS_PDF); + // If issue with unoconv, see https://github.com/dagwieers/unoconv/issues/87 + + // MAIN_ODT_AS_PDF should be "sudo -u unoconv /usr/bin/unoconv" and userunoconv must have sudo to be root by adding file /etc/sudoers.d/unoconv with content www-data ALL=(unoconv) NOPASSWD: /usr/bin/unoconv . + + // Try this with www-data user: /usr/bin/unoconv -vvvv -f pdf /tmp/document-example.odt + // It must return: + //Verbosity set to level 4 + //Using office base path: /usr/lib/libreoffice + //Using office binary path: /usr/lib/libreoffice/program + //DEBUG: Connection type: socket,host=127.0.0.1,port=2002;urp;StarOffice.ComponentContext + //DEBUG: Existing listener not found. + //DEBUG: Launching our own listener using /usr/lib/libreoffice/program/soffice.bin. + //LibreOffice listener successfully started. (pid=9287) + //Input file: /tmp/document-example.odt + //unoconv: file `/tmp/document-example.odt' does not exist. + //unoconv: RuntimeException during import phase: + //Office probably died. Unsupported URL : "type detection failed" + //DEBUG: Terminating LibreOffice instance. + //DEBUG: Waiting for LibreOffice instance to exit + + // It fails: + // - set shel of user to bash instead of nologin. + // - set permission to read/write to user on home directory /var/www so user can create the libreoffice , dconf and .cache dir and files then set permission back + + $command = $conf->global->MAIN_ODT_AS_PDF.' '.escapeshellcmd($name); + //$command = '/usr/bin/unoconv -vvv '.escapeshellcmd($name); } else { - dol_syslog(get_class($this).'::exportAsAttachedPDF is used but the constant MAIN_DOL_SCRIPTS_ROOT with path to script directory was not defined.', LOG_WARNING); - $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($name).' '.(is_numeric($conf->global->MAIN_ODT_AS_PDF)?'jodconverter':$conf->global->MAIN_ODT_AS_PDF); - } + // deprecated old method + $name=preg_replace('/\.odt/i', '', $name); + if (!empty($conf->global->MAIN_DOL_SCRIPTS_ROOT)) + { + $command = $conf->global->MAIN_DOL_SCRIPTS_ROOT.'/scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($name).' '.(is_numeric($conf->global->MAIN_ODT_AS_PDF)?'jodconverter':$conf->global->MAIN_ODT_AS_PDF); + } + else + { + dol_syslog(get_class($this).'::exportAsAttachedPDF is used but the constant MAIN_DOL_SCRIPTS_ROOT with path to script directory was not defined.', LOG_WARNING); + $command = '../../scripts/odt2pdf/odt2pdf.sh '.escapeshellcmd($name).' '.(is_numeric($conf->global->MAIN_ODT_AS_PDF)?'jodconverter':$conf->global->MAIN_ODT_AS_PDF); + } + } //$dirname=dirname($name); //$command = DOL_DOCUMENT_ROOT.'/includes/odtphp/odt2pdf.sh '.$name.' '.$dirname; @@ -598,16 +632,19 @@ IMG; } if ($execmethod == 2) { + $outputfile = DOL_DATA_ROOT.'/odt2pdf.log'; + $ok=0; $handle = fopen($outputfile, 'w'); if ($handle) { dol_syslog(get_class($this)."Run command ".$command,LOG_DEBUG); + fwrite($handle, $command."\n"); $handlein = popen($command, 'r'); while (!feof($handlein)) { $read = fgets($handlein); - fwrite($handle,$read); + fwrite($handle, $read); $output_arr[]=$read; } pclose($handlein); @@ -616,7 +653,7 @@ IMG; if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); } - if($retval == 0) + if ($retval == 0) { dol_syslog(get_class($this).'::exportAsAttachedPDF $ret_val='.$retval, LOG_DEBUG); if (headers_sent($filename, $linenum)) { @@ -686,7 +723,7 @@ IMG; /** * Empty the temporary working directory recursively - * + * * @param string $dir The temporary working directory * @return void */ @@ -709,7 +746,7 @@ IMG; /** * return the value present on odt in [valuename][/valuename] - * + * * @param string $valuename Balise in the template * @return string The value inside the balise */ diff --git a/scripts/odt2pdf/odt2pdf.sh b/scripts/odt2pdf/odt2pdf.sh index 4cf1ab54013..2a3550de29b 100755 --- a/scripts/odt2pdf/odt2pdf.sh +++ b/scripts/odt2pdf/odt2pdf.sh @@ -3,20 +3,26 @@ # @copyright GPL License 2013 - Florian HEnry - florian.henry@open-concept.pro # @copyright GPL License 2017 - Laurent Destailleur - eldy@users.sourceforge.net # -# Convert an ODT into a PDF using "jodconverter" or "pyodconverter" tool. -# Dolibarr variable MAIN_ODT_AS_PDF must be defined to value "jodconverter" to call jodconverter wrapper after ODT generation +# Convert an ODT into a PDF using "jodconverter" or "pyodconverter" or "unoconv" tool. +# Dolibarr variable MAIN_ODT_AS_PDF must be defined +# to value "unoconv" to call unoconv CLI tool after ODT generation. # or value "pyodconverter" to call DocumentConverter.py after ODT generation. +# or value "jodconverter" to call jodconverter wrapper after ODT generation # or value "/pathto/jodconverter-cli-file.jar" to call jodconverter java tool without wrapper after ODT generation. # Dolibarr variable MAIN_DOL_SCRIPTS_ROOT must be defined to path of script directories (otherwise dolibarr will try to guess). if [ "x$1" == "x" ] then - echo "Usage: odt2pdf.sh fullfilename [jodconverter|pyodconverter|pathtojodconverterjar]" + echo "Usage: odt2pdf.sh fullfilename [unoconv|jodconverter|pyodconverter|pathtojodconverterjar]" + echo "Example: odt2pdf.sh myfile unoconv" echo "Example: odt2pdf.sh myfile ~/jodconverter/jodconverter-cli-2.2.2.jar" exit fi + + + # Full patch where soffice is installed soffice="/usr/bin/soffice" @@ -26,7 +32,21 @@ home_java="/tmp" # Main program if [ -f "$1.odt" ] - then +then + + if [ "x$2" == "xunoconv" ] + then + # See issue https://github.com/dagwieers/unoconv/issues/87 + /usr/bin/unoconv -vvv "$1.odt" + retcode=$? + if [ $retcode -ne 0 ] + then + echo "Error while converting odt to pdf: $retcode" + exit 1 + fi + exit 0 + fi + nbprocess=$(pgrep -c soffice) if [ $nbprocess -ne 1 ] # If there is some soffice process running then @@ -59,8 +79,9 @@ if [ -f "$1.odt" ] echo "Error while converting odt to pdf: $retcode" exit 1 fi + sleep 1 - else +else echo "Error: Odt file $1.odt does not exist" exit 1 fi From 913a5d1df2104a18e2c9d45fe034c49a49687cfe Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 07:37:39 +0200 Subject: [PATCH 043/128] Fix: if module is not activated, functionality of module is deactivated! --- htdocs/adherents/subscription.php | 43 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8002b33b1f6..7c0a0cfe407 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -31,10 +31,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // TODO a lot of dependency on the bank module, but no test if this module is not activated! +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +} +if (! empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +} $langs->load("companies"); $langs->load("bills"); @@ -859,10 +863,13 @@ if ($rowid > 0) $accountstatic->number=$objp->number; $accountstatic->account_number=$objp->account_number; - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->fk_accountancy_journal); + if (! empty($conf->accounting->enabled)) + { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + } $accountstatic->ref=$objp->ref; print $accountstatic->getNomUrl(1); @@ -1093,12 +1100,12 @@ if ($rowid > 0) print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - $prodtmp=new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product - } + if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + { + $prodtmp=new Product($db); + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product + } print '
'; } // Add invoice with payments @@ -1118,12 +1125,12 @@ if ($rowid > 0) print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - $prodtmp=new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product - } + if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + { + $prodtmp=new Product($db); + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product + } print '
'; } print '
'.dol_print_date($db->jdate($objp->dateh),'day')."'.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->subscription).''; - if ($objp->bid) - { - $accountstatic->label=$objp->label; - $accountstatic->id=$objp->baid; - $accountstatic->number=$objp->number; - $accountstatic->account_number=$objp->account_number; + if (! empty($conf->banque->enabled)) + { + print ''; + if ($objp->bid) + { + $accountstatic=new Account($db); + + $accountstatic->label=$objp->label; + $accountstatic->id=$objp->baid; + $accountstatic->number=$objp->number; + $accountstatic->account_number=$objp->account_number; if (! empty($conf->accounting->enabled)) { diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 3faa45d7d84..3c368c05c9a 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -25,7 +25,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} $langs->load("companies"); $langs->load("bills"); @@ -231,20 +233,20 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') if (! empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print '
'.$langs->trans("BankTransactionLine").''; + { + print '
'.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); + $bankline=new AccountLine($db); + $result=$bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1,0,'showall'); } else { print $langs->trans("NoneF"); } - print '
'; @@ -326,27 +328,26 @@ if ($rowid && $action != 'edit') // Amount print ''.$langs->trans("Label").''.$object->note.''; - // Bank line + // Bank line if (! empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print ''.$langs->trans("BankTransactionLine").''; + { + print ''.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); - print $bankline->getNomUrl(1,0,'showall'); + $bankline=new AccountLine($db); + $result=$bankline->fetch($object->fk_bank); + print $bankline->getNomUrl(1,0,'showall'); } else { print $langs->trans("NoneF"); } - print ''; - } + print ''; + } } - print "\n"; print '
'; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 1fee5ac545c..adbc0ea98b6 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -26,7 +26,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} $langs->load("members"); @@ -267,7 +269,6 @@ if ($result) // Static objects $subscription=new Subscription($db); $adherent=new Adherent($db); - $accountstatic=new Account($db); $total=0; while ($i < min($num, $limit)) @@ -304,22 +305,24 @@ if ($result) print dol_trunc($obj->note,32); print ''; - // Banque - if (! empty($conf->banque->enabled)) - { - if ($obj->fk_account) - { - $accountstatic->id=$obj->fk_account; - $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print ''.$accountstatic->getNomUrl(1).''; - } - else - { - print ""; - print "\n"; - } - } + // Banque + if (! empty($conf->banque->enabled)) + { + $accountstatic=new Account($db); + + if ($obj->fk_account) + { + $accountstatic->id=$obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print ''.$accountstatic->getNomUrl(1).''; + } + else + { + print ""; + print "\n"; + } + } // Date start print ''.dol_print_date($db->jdate($obj->dateadh),'day')."\n"; From f2ad2055382105d653fa5ecdb0baecc50d8dd716 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 08:07:09 +0200 Subject: [PATCH 045/128] Fix: wrong copy/paste ! --- htdocs/adherents/subscription.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 2bdbe821105..23876545a60 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -35,7 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (! empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; } -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } From 7e79c3a79526d59002f309f5ea4e80e004c32bf9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 11 Oct 2017 10:10:27 +0200 Subject: [PATCH 046/128] Fix: label not translated if special lang file used --- htdocs/core/class/extrafields.class.php | 2 +- .../core/tpl/admin_extrafields_view.tpl.php | 62 ++++++++++--------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 277ff7a3895..43af66e51e7 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -747,7 +747,7 @@ class ExtraFields $this->attribute_pos[$tab->name]=$tab->pos; $this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable; $this->attribute_perms[$tab->name]=$tab->perms; - $this->attribute_langfile[$tab->langs]=$tab->langs; + $this->attribute_langfile[$tab->name]=$tab->langs; $this->attribute_list[$tab->name]=$tab->list; $this->attribute_hidden[$tab->name]=$tab->ishidden; $this->attribute_entityid[$tab->name]=$tab->entity; diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 30b4299a21e..04037368fbc 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012-2017 Regis Houssin * * 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 @@ -61,39 +61,43 @@ print "\n"; if (count($extrafields->attribute_type)) { - foreach($extrafields->attribute_type as $key => $value) - { + foreach($extrafields->attribute_type as $key => $value) + { + // Load language if required + if (! empty($extrafields->attribute_langfile[$key])) { + $langs->load($extrafields->attribute_langfile[$key]); + } - print ''; - print "".$extrafields->attribute_pos[$key]."\n"; - print "".$extrafields->attribute_label[$key]."\n"; - print "".$key."\n"; - print "".$type2label[$extrafields->attribute_type[$key]]."\n"; - print ''.$extrafields->attribute_size[$key]."\n"; - print ''.yn($extrafields->attribute_unique[$key])."\n"; - print ''.dol_trunc($extrafields->attribute_computed[$key], 20)."\n"; - print ''.yn($extrafields->attribute_required[$key])."\n"; - print ''.yn($extrafields->attribute_alwayseditable[$key])."\n"; - print ''.$extrafields->attribute_list[$key]."\n"; - if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.yn($extrafields->attribute_hidden[$key])."\n"; // Add hidden option on not working feature. Why hide if user can't see it. - if ($conf->multicompany->enabled) { - print ''.($extrafields->attribute_entityid[$key]==0?$langs->trans("All"):$extrafields->attribute_entitylabel[$key]).''; - } - print ''.img_edit().''; - print "  ".img_delete()."\n"; - print ""; - } + print ''; + print "".$extrafields->attribute_pos[$key]."\n"; + print "".$langs->trans($extrafields->attribute_label[$key])."\n"; + print "".$key."\n"; + print "".$type2label[$extrafields->attribute_type[$key]]."\n"; + print ''.$extrafields->attribute_size[$key]."\n"; + print ''.yn($extrafields->attribute_unique[$key])."\n"; + print ''.dol_trunc($extrafields->attribute_computed[$key], 20)."\n"; + print ''.yn($extrafields->attribute_required[$key])."\n"; + print ''.yn($extrafields->attribute_alwayseditable[$key])."\n"; + print ''.$extrafields->attribute_list[$key]."\n"; + if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''.yn($extrafields->attribute_hidden[$key])."\n"; // Add hidden option on not working feature. Why hide if user can't see it. + if (! empty($conf->multicompany->enabled)) { + print ''.($extrafields->attribute_entityid[$key]==0?$langs->trans("All"):$extrafields->attribute_entitylabel[$key]).''; + } + print ''.img_edit().''; + print "  ".img_delete()."\n"; + print ""; + } } else { - $colspan=9; - if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) $colspan++; + $colspan=9; + if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) $colspan++; - print ''; - print ''; - print $langs->trans("None"); - print ''; - print ''; + print ''; + print ''; + print $langs->trans("None"); + print ''; + print ''; } print ""; From 1b3f746ce0dd52b5d4820c62af01300d258135e0 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Wed, 11 Oct 2017 11:16:01 +0200 Subject: [PATCH 047/128] Fix translation error InvoiceProForma translation is available in bills.lang --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index cdff9317446..2d5a27bb3df 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1566,7 +1566,7 @@ class pdf_crabe extends ModelePDFFactures if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit"); - if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat"); + if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma"); if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation"); $pdf->MultiCell($w, 3, $title, '', 'R'); From 051d49732deb4a0398f528338b3886ac0f91a0cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:36:24 +0200 Subject: [PATCH 048/128] Keep compatiblity of status key --- htdocs/commande/class/commande.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 824d8faeb88..1ad2d876478 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -172,6 +172,8 @@ class Commande extends CommonOrder * Shipment on process */ const STATUS_SHIPMENTONPROCESS = 2; + const STATUS_ACCEPTED = 2; // For backward compatibility. Use key STATUS_SHIPMENTONPROCESS instead. + /** * Closed (Sent, billed or not) */ From f8771c22149e95e0762128f9364a9d805ac77b8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:39:56 +0200 Subject: [PATCH 049/128] Update list.php --- htdocs/adherents/subscription/list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index adbc0ea98b6..2a839106f05 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -269,6 +269,7 @@ if ($result) // Static objects $subscription=new Subscription($db); $adherent=new Adherent($db); + $accountstatic=new Account($db); $total=0; while ($i < min($num, $limit)) @@ -308,9 +309,7 @@ if ($result) // Banque if (! empty($conf->banque->enabled)) { - $accountstatic=new Account($db); - - if ($obj->fk_account) + if ($obj->fk_account > 0) { $accountstatic->id=$obj->fk_account; $accountstatic->fetch($obj->fk_account); From 7e999603fc2b48e504b478a93867282a4fb56bd7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:40:19 +0200 Subject: [PATCH 050/128] Update list.php --- htdocs/adherents/subscription/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 2a839106f05..e831a4449ab 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -26,9 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -if (! empty($conf->banque->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -} +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("members"); From d59d7887bb9db0c7d05190342bd94ef2c70e8c65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:42:39 +0200 Subject: [PATCH 051/128] Update subscription.php --- htdocs/adherents/subscription.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index e6caae34d6a..36f8968587a 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -32,13 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->banque->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -} -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -} -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("companies"); $langs->load("bills"); @@ -841,6 +837,8 @@ if ($rowid > 0) } print "\n"; + $accountstatic=new Account($db); + while ($i < $num) { $objp = $db->fetch_object($result); @@ -857,8 +855,6 @@ if ($rowid > 0) print ''; if ($objp->bid) { - $accountstatic=new Account($db); - $accountstatic->label=$objp->label; $accountstatic->id=$objp->baid; $accountstatic->number=$objp->number; From 5aa3352e58b1a29f8ad33e572a552cbffb4ea74a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:48:38 +0200 Subject: [PATCH 052/128] Restore TODO for future feature --- htdocs/core/js/datepicker.js.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/js/datepicker.js.php b/htdocs/core/js/datepicker.js.php index 3de57f0543f..32b7ca43f5e 100644 --- a/htdocs/core/js/datepicker.js.php +++ b/htdocs/core/js/datepicker.js.php @@ -139,7 +139,9 @@ jQuery(function($){ weekHeader: 'trans("Week"); ?>', dateFormat: 'trans("FormatDateShortJQuery"); ?>', firstDay: global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'); ?>, - isRTL: trans("DIRECTION")=='rtl'?'true':'false'); ?> + isRTL: trans("DIRECTION")=='rtl'?'true':'false'); ?>, + showMonthAfterYear: false, /* TODO add specific to country */ + yearSuffix: '' /* TODO add specific to country */ }; $.datepicker.setDefaults($.datepicker.regional['defaultlang ?>']); }); From 220b37133bb74a37a6d46befc7b994a7f463022a Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Tue, 10 Oct 2017 09:43:03 +0200 Subject: [PATCH 053/128] Wrong test https://github.com/Dolibarr/dolibarr/issues/7604#issuecomment-335387587 --- htdocs/admin/modulehelp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 143ebc627f8..f60f5922160 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -365,7 +365,7 @@ if ($mode == 'desc') if ($mode == 'feature') { $text.='
'.$langs->trans("DependsOn").': '; - if (count($objMod->requiredby)) $text.=join(',', $objMod->depends); + if (count($objMod->depends)) $text.=join(',', $objMod->depends); else $text.=$langs->trans("None"); $text.='
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) $text.=join(',', $objMod->requiredby); From 118b3cdf7918da49a92b32003349a819bf78341e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:56:22 +0200 Subject: [PATCH 054/128] Update admin_extrafields_view.tpl.php --- htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 04037368fbc..4975e00279d 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -70,7 +70,7 @@ if (count($extrafields->attribute_type)) print ''; print "".$extrafields->attribute_pos[$key]."\n"; - print "".$langs->trans($extrafields->attribute_label[$key])."\n"; + print "".$extrafields->attribute_label[$key]."\n"; // We don't translate here, we want admin to know what is the key not translated value print "".$key."\n"; print "".$type2label[$extrafields->attribute_type[$key]]."\n"; print ''.$extrafields->attribute_size[$key]."\n"; From 68ec8ef313580c71fcd0e29b0545f7b8c42367f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 12:05:48 +0200 Subject: [PATCH 055/128] Fix lang missing --- htdocs/fourn/commande/card.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 43ce10ba2f6..03a39f2a5e3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -54,16 +54,7 @@ if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -$langs->load('admin'); -$langs->load('orders'); -$langs->load('sendings'); -$langs->load('companies'); -$langs->load('bills'); -$langs->load('propal'); -$langs->load('supplier_proposal'); -$langs->load('deliveries'); -$langs->load('products'); -$langs->load('stocks'); +$langs->loadLangs(array('admin','orders','sendings','companies','bills','propal','supplier_proposal','deliveries','products','stocks','productbatch')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); $id = GETPOST('id','int'); From 99afa3a3e0fb3dbe9adb038d1d03f1988e665009 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 12:19:44 +0200 Subject: [PATCH 056/128] Use a shorter key for column title --- .../core/modules/livraison/doc/pdf_typhon.modules.php | 10 +++++----- htdocs/langs/en_US/sendings.lang | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index eeba25962cb..fcb0bb6b057 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -283,11 +283,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } @@ -567,7 +567,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - + return 1; // pas d'erreur } else @@ -662,14 +662,14 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->line($this->posxqty, $tab_top, $this->posxqty, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxqty, $tab_top+1); - $pdf->MultiCell($this->posxremainingqty - $this->posxqty, 2, $outputlangs->transnoentities("QtyShipped"),'','R'); + $pdf->MultiCell($this->posxremainingqty - $this->posxqty, 2, $outputlangs->transnoentities("QtyShippedShort"),'','R'); } // Remain to ship $pdf->line($this->posxremainingqty, $tab_top, $this->posxremainingqty, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxremainingqty, $tab_top+1); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxremainingqty, 2, $outputlangs->transnoentities("KeepToShip"),'','R'); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxremainingqty, 2, $outputlangs->transnoentities("KeepToShipShort"),'','R'); } } diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index fcd28cc9f56..47012406b74 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -18,11 +18,13 @@ SendingCard=Shipment card NewSending=New shipment CreateShipment=Create shipment QtyShipped=Qty shipped +QtyShippedShort=Qty ship. QtyPreparedOrShipped=Qty prepared or shipped QtyToShip=Qty to ship QtyReceived=Qty received QtyInOtherShipments=Qty in other shipments KeepToShip=Remain to ship +KeepToShipShort=Remain OtherSendingsForSameOrder=Other shipments for this order SendingsAndReceivingForSameOrder=Shipments and receipts for this order SendingsToValidate=Shipments to validate From c9066afa36c5385fa3d19dad055d613253bd107e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 11 Oct 2017 14:22:59 +0200 Subject: [PATCH 057/128] NEW add translation column for extrafields list --- htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 4975e00279d..95a9ea250a1 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -44,6 +44,7 @@ print ''.$langs->trans("Position"); print ''; print ''; print ''.$langs->trans("Label").''; +print ''.$langs->trans("TranslationString").''; print ''.$langs->trans("AttributeCode").''; print ''.$langs->trans("Type").''; print ''.$langs->trans("Size").''; @@ -71,6 +72,7 @@ if (count($extrafields->attribute_type)) print ''; print "".$extrafields->attribute_pos[$key]."\n"; print "".$extrafields->attribute_label[$key]."\n"; // We don't translate here, we want admin to know what is the key not translated value + print "".$langs->trans($extrafields->attribute_label[$key])."\n"; print "".$key."\n"; print "".$type2label[$extrafields->attribute_type[$key]]."\n"; print ''.$extrafields->attribute_size[$key]."\n"; From cd814d420b956a4d7c1f9ba06fb992054cf39383 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 16:54:17 +0200 Subject: [PATCH 058/128] Fix repair utf8 mix collation --- htdocs/install/mysql/migration/repair.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 46f75ff0d7f..68671ecd4d7 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -31,6 +31,10 @@ -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; From bcf56e3140f064f32ec64499c6d67d23759b3f5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 19:41:19 +0200 Subject: [PATCH 059/128] Introduce table c_email_senderprofile to have several profils --- htdocs/admin/mails.php | 90 ++++++++++++++----- htdocs/core/actions_massactions.inc.php | 9 ++ htdocs/core/actions_sendmails.inc.php | 9 ++ htdocs/core/class/html.formmail.class.php | 27 +++++- .../install/mysql/migration/6.0.0-7.0.0.sql | 17 ++++ htdocs/modulebuilder/index.php | 16 +++- 6 files changed, 143 insertions(+), 25 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index aa859b18a7e..961491cce2e 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -69,20 +69,20 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity); // Send mode parameters - dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"),'chaine',0,'',$conf->entity); // Content parameters - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE',GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'),'chaine',0,'',$conf->entity); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -427,13 +427,30 @@ if ($action == 'edit') print '">'; // Default from type - - $liste = array(); - $liste['user'] = $langs->trans('UserEmail'); - $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $liste = array(); + $liste['user'] = $langs->trans('UserEmail'); + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + /* + $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i=0; + while($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; + } + $i++; + } + } + else dol_print_error($db);*/ print ''.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; - print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE',$liste,$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE,0); + print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE, 0); print ''; // Separator @@ -569,13 +586,46 @@ else print ''; // Default from type + $liste = array(); + $liste['user'] = $langs->trans('UserEmail'); + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i=0; + while($i < $num) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $liste['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; + } + $i++; + } + } + else dol_print_error($db); print ''.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; print ''; - if($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user'){ + if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'user') + { print $langs->trans('UserEmail'); - } else { - print $langs->trans('CompanyEmail'); + } + else if ($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE === 'company') + { + print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>'); + } + else { + $id = preg_replace('/senderprofile_/', '', $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE); + if ($id > 0) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; + $emailsenderprofile = new EmailSenderProfile($db); + $emailsenderprofile->fetch($id); + print $emailsenderprofile->label.' '.dol_escape_htmltag('<'.$emailsenderprofile->email.'>'); + } } print ''; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 67fde5dbd48..76534211481 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -306,6 +306,15 @@ if (! $error && $massaction == 'confirm_presend') $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); } + elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { + $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $from = $obj->label.' <'.$obj->email.'>'; + } + } else { $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 7b1db834d22..57b6ae80b6c 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -258,6 +258,15 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); } + elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { + $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $from = $obj->label.' <'.$obj->email.'>'; + } + } else { $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 788fa723cdb..77f3d30c93b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -444,6 +444,8 @@ class FormMail extends Form } } else { $liste = array(); + + // Add user email if (empty($user->email)) { $langs->load('errors'); @@ -453,9 +455,32 @@ class FormMail extends Form { $liste['user'] = $user->getFullName($langs) .' <'.$user->email.'>'; } + + // Add also company main email $liste['company'] = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - // Add also email aliases if there is one + + // Add also email aliases if there is some $listaliases=array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); + + // Add also email aliases from the c_email_senderprofile table + $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1 ORDER BY position'; + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i=0; + while($i < $num) + { + $obj = $this->db->fetch_object($resql); + if ($obj) + { + $listaliases['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; + } + $i++; + } + } + else dol_print_error($db); + foreach($listaliases as $typealias => $listalias) { $posalias=0; diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 3ecf4b405c8..b5e274c9d90 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -364,3 +364,20 @@ ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(id, entity, code); ALTER TABLE llx_c_payment_term DROP PRIMARY KEY; ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code); + + +create table llx_c_email_senderprofile +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + private smallint DEFAULT 0 NOT NULL, -- Template public or private + date_creation datetime, + tms timestamp, + label varchar(255), -- Label of predefined email + email varchar(255), -- Email + signature text -- Predefined signature + position smallint, -- Position + active tinyint DEFAULT 1 NOT NULL, +)ENGINE=innodb; + +ALTER TABLE llx_c_email_senderprofile ADD UNIQUE INDEX uk_c_email_senderprofile(entity, label, email); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index efd0404ee72..40a69851a0e 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -86,7 +86,7 @@ if (empty($newmask)) // This should no happen if ($dirins && $action == 'initmodule' && $modulename) { - if (preg_match('/\s/', $modulename)) + if (preg_match('/[^a-z0-9_]/i', $modulename)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); @@ -174,7 +174,7 @@ if ($dirins && $action == 'initmodule' && $modulename) if ($dirins && $action == 'initobject' && $module && $objectname) { - if (preg_match('/\s/', $objectname)) + if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); @@ -183,6 +183,14 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $destdir = $dirins.'/'.strtolower($module); + // The dir was not created by init + dol_mkdir($destdir.'/class'); + dol_mkdir($destdir.'/img'); + dol_mkdir($destdir.'/lib'); + dol_mkdir($destdir.'/scripts'); + dol_mkdir($destdir.'/sql'); + dol_mkdir($destdir.'/test/phpunit'); + // Scan dir class to find if an object with same name already exists. if (! $error) { @@ -443,7 +451,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) if ($dirins && $action == 'confirm_delete') { - if (preg_match('/\s/', $module)) + if (preg_match('/[^a-z0-9_]/i', $module)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); @@ -476,7 +484,7 @@ if ($dirins && $action == 'confirm_delete') if ($dirins && $action == 'confirm_deleteobject' && $objectname) { - if (preg_match('/[^a-z0-9]/i', $objectname)) + if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); From 56be9e2b60b8d2816813ed7a924783e9607d9d4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 19:41:45 +0200 Subject: [PATCH 060/128] Introduce table c_email_senderprofile to have several profils --- htdocs/admin/emailsenderprofile_card.php | 622 ++++++++++++++++ htdocs/admin/emailsenderprofile_list.php | 661 ++++++++++++++++++ .../core/class/emailsenderprofile.class.php | 445 ++++++++++++ .../tables/llx_c_email_senderprofile.key.sql | 21 + .../tables/llx_c_email_senderprofile.sql | 32 + 5 files changed, 1781 insertions(+) create mode 100644 htdocs/admin/emailsenderprofile_card.php create mode 100644 htdocs/admin/emailsenderprofile_list.php create mode 100644 htdocs/core/class/emailsenderprofile.class.php create mode 100644 htdocs/install/mysql/tables/llx_c_email_senderprofile.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_email_senderprofile.sql diff --git a/htdocs/admin/emailsenderprofile_card.php b/htdocs/admin/emailsenderprofile_card.php new file mode 100644 index 00000000000..547f810fa15 --- /dev/null +++ b/htdocs/admin/emailsenderprofile_card.php @@ -0,0 +1,622 @@ + + * 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 emailsenderprofile_card.php + * \ingroup monmodule + * \brief Page to create/edit/view emailsenderprofile + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); + +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); +include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); +dol_include_once('/monmodule/class/emailsenderprofile.class.php'); +dol_include_once('/monmodule/lib/emailsenderprofile.lib.php'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("monmodule@monmodule","other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object=new EmailSenderProfile($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->monmodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('emailsenderprofilecard')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('emailsenderprofile'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'monmodule', $id); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals + + + +/* + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + $error=0; + + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } + + // Action to add record + if ($action == 'add' && ! empty($user->rights->monmodule->create)) + { + foreach ($object->fields as $key => $val) + { + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + + $object->$key=GETPOST($key,'alpha'); + if ($val['notnull'] > 0 && $object->$key == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); + } + } + + if (! $error) + { + $result=$object->createCommon($user); + if ($result > 0) + { + // Creation OK + $urltogo=$backtopage?$backtopage:dol_buildpath('/monmodule/emailsenderprofile_list.php',1); + header("Location: ".$urltogo); + exit; + } + else + { + // Creation KO + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + $action='create'; + } + } + else + { + $action='create'; + } + } + + // Action to update record + if ($action == 'update' && ! empty($user->rights->monmodule->create)) + { + foreach ($object->fields as $key => $val) + { + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields + + $object->$key=GETPOST($key,'alpha'); + if ($val['notnull'] > 0 && $object->$key == '') + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv($val['label'])), null, 'errors'); + } + } + + if (! $error) + { + $result=$object->updateCommon($user); + if ($result > 0) + { + $action='view'; + } + else + { + // Creation KO + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + $action='edit'; + } + } + else + { + $action='edit'; + } + } + + // Action to delete + if ($action == 'confirm_delete' && ! empty($user->rights->monmodule->delete)) + { + $result=$object->deleteCommon($user); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".dol_buildpath('/monmodule/emailsenderprofile_list.php',1)); + exit; + } + else + { + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } + } + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + $trigger_name='MYOBJECT_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; + $trackid='emailsenderprofile'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * VIEW + * + * Put here all code to build page + */ + +$form=new Form($db); +$formfile=new FormFile($db); + +llxHeader('','EmailSenderProfile',''); + +// Example : Adding jquery code +print ''; + + +// Part to create +if ($action == 'create') +{ + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("EmailSenderProfile"))); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(array(), ''); + + print ''."\n"; + foreach($object->fields as $key => $val) + { + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; + print ''; + print ''; + print $langs->trans($val['label']); + print ''; + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + + print '
'; + $defaultcss='minwidth100'; + if ($val['type'] == 'text') + { + print ''; + } + elseif (is_array($val['arrayofkeyval'])) + { + print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')); + } + else + { + $cssforinput = empty($val['css'])?$defaultcss:$val['css']; + print ''; + } + print '
'."\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '  '; + print ''; // Cancel for create doe not post form + print '
'; + + print '
'; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') +{ + print load_fiche_titre($langs->trans("EmailSenderProfile")); + + print '
'; + print ''; + print ''; + print ''; + + dol_fiche_head(); + + print ''."\n"; + foreach($object->fields as $key => $val) + { + if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; + + print ''.$langs->trans($val['label']).''; + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + $defaultcss='minwidth100'; + if ($val['type'] == 'text') + { + print ''; + } + elseif (is_array($val['arrayofkeyval'])) + { + print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key); + } + else + { + $cssforinput = empty($val['css'])?$defaultcss:$val['css']; + print ''; + } + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals($object->id, $extralabels); + + $head = emailsenderprofilePrepareHead($object); + dol_fiche_head($head, 'card', $langs->trans("EmailSenderProfile"), -1, 'emailsenderprofile@monmodule'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteEmailSenderProfile'), $langs->trans('ConfirmDeleteEmailSenderProfile'), 'confirm_delete', '', 0, 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); + }*/ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + if (! $formconfirm) { + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->monmodule->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->monmodule->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->monmodule->creer) + { + if ($action != 'classify') + { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + foreach($object->fields as $key => $val) + { + if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; + + print ''.$langs->trans($val['label']).''; + print ''; + print ''; + + //if ($key == 'targetsrcfile3') break; // key used for break on second column + } + + print '
'; + print dol_escape_htmltag($object->$key, 1, 1); + print '
'; + print '
'; + print '
'; + print '
'; + print '
'; + print ''; + + $alreadyoutput = 1; + foreach($object->fields as $key => $val) + { + if ($alreadyoutput) + { + //if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column + continue; + } + + if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; + + print ''.$langs->trans($val['label']).''; + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print dol_escape_htmltag($object->$key, 1, 1); + print '
'; + print '
'; + print '
'; + print '
'; + + print '

'; + + dol_fiche_end(); + + + // Buttons for actions + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print ''."\n"; + + if ($user->rights->monmodule->write) + { + print ''."\n"; + } + + /* + if ($user->rights->sellyoursaas->create) + { + if ($object->status == 1) + { + print ''."\n"; + } + else + { + print ''."\n"; + } + } + */ + + if ($user->rights->monmodule->delete) + { + print ''."\n"; + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + // Documents + $comref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->monmodule->dir_output . '/' . $comref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->monmodule->creer; + $delallowed = $user->rights->monmodule->supprimer; + print $formfile->showdocuments('monmodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + + + // Show links to link elements + $linktoelem = $form->showLinkToObjectBlock($object, null, array('emailsenderprofile')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + $MAXEVENT = 10; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'emailsenderprofile', $socid, 1, '', $MAXEVENT); + + print '
'; + } + + // Presend form + $modelmail='emailsenderprofile'; + $defaulttopic='Information'; + $diroutput = $conf->monmodule->dir_output; + $trackid = 'emailsenderprofile'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; +} + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/emailsenderprofile_list.php b/htdocs/admin/emailsenderprofile_list.php new file mode 100644 index 00000000000..dd2372443b3 --- /dev/null +++ b/htdocs/admin/emailsenderprofile_list.php @@ -0,0 +1,661 @@ + + * 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 emailsenderprofile_list.php + * \ingroup monmodule + * \brief List page for emailsenderprofile + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) + + +// Load Dolibarr environment +$res=0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); +// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME +$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; +while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } +if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); +if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); +// Try main.inc.php using relative path +if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); + +require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +dol_include_once('/monmodule/class/emailsenderprofile.class.php'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("monmodule@monmodule","other")); + +$action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'emailsenderprofilelist'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') + +$id = GETPOST('id','int'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Initialize technical objects +$object=new EmailSenderProfile($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->monmodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('emailsenderprofile'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (! $sortorder) $sortorder="ASC"; + +// Protection if external user +$socid=0; +if ($user->societe_id > 0) +{ + //$socid = $user->societe_id; + accessforbidden(); +} + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all",'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; +} + +// Definition of fields for list +$arrayfields=array(); +foreach($object->fields as $key => $val) +{ + // If $val['visible']==0, then we never show the field + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + + + + +/* + * ACTIONS + * + * Put here all code to do according to value of "$action" parameter + */ + +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='EmailSenderProfile'; + $objectlabel='EmailSenderProfile'; + $permtoread = $user->rights->monmodule->read; + $permtodelete = $user->rights->monmodule->delete; + $uploaddir = $conf->monmodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + + +/* + * VIEW + * + * Put here all code to build page + */ + +$form=new Form($db); + +$now=dol_now(); + +//$help_url="EN:Module_EmailSenderProfile|FR:Module_EmailSenderProfile_FR|ES:Módulo_EmailSenderProfile"; +$help_url=''; +$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailSenderProfiles")); + + +// Build and execute select +// -------------------------------------------------------------------- +$sql = 'SELECT '; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); +$sql.= " FROM ".MAIN_DB_PREFIX."emailsenderprofile as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."emailsenderprofile_extrafields as ef on (t.rowid = ef.fk_object)"; +$sql.= " WHERE t.entity IN (".getEntity('emailsenderprofile').")"; +foreach($search as $key => $val) +{ + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); +} +if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode_search=0; + if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); + } +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +*/ + +$sql.=$db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit+1, $offset); + +dol_syslog($script_file, LOG_DEBUG); +$resql=$db->query($sql); +if (! $resql) +{ + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + +// Direct jump if only one record found +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/monmodule/emailsenderprofile_card.php?id='.$id); + exit; +} + + +// Output page +// -------------------------------------------------------------------- + +llxHeader('', $title, $help_url); + +// Example : Adding jquery code +print ''; + +$arrayofselected=is_array($toselect)?$toselect:array(); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +foreach($search as $key => $val) +{ + $param.= '&search_'.$key.'='.urlencode($search[$key]); +} +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->monmodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($massaction == 'presend') $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); +} + +$moreforfilter = ''; +$moreforfilter.='
'; +$moreforfilter.= $langs->trans('MyFilter') . ': '; +$moreforfilter.= '
'; + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + + +// Fields title search +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } +} +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Rest of fields search +foreach($object->fields as $key => $val) +{ + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; +} +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +foreach($object->fields as $key => $val) +{ + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; + } + } +} +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Rest of fields title +foreach($object->fields as $key => $val) +{ + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; +} +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +foreach ($extrafields->attribute_computed as $key => $val) +{ + if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object +} + + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1); + elseif ($key == 'status') print $object->getLibStatut(3); + else print $obj->$key; + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; + $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; + } + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Rest of fields + foreach($object->fields as $key => $val) + { + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + elseif ($key == 'status') print $object->getLibStatut(3); + else print $obj->$key; + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; +} + +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; +} + + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + +if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->monmodule->read; + $delallowed=$user->rights->monmodule->read; + + print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php new file mode 100644 index 00000000000..f1e8332d116 --- /dev/null +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -0,0 +1,445 @@ + + * Copyright (C) 2014-2016 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 class/emailsenderprofile.class.php + * \ingroup monmodule + * \brief This file is a CRUD class file for EmailSenderProfile (Create/Read/Update/Delete) + */ + +// 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 for EmailSenderProfile + */ +class EmailSenderProfile extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'emailsenderprofile'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'c_email_senderprofile'; + + /** + * @var array Does this field is linked to a thirdparty ? + */ + protected $isnolinkedbythird = 1; + /** + * @var array Does emailsenderprofile support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + protected $ismultientitymanaged = 1; + /** + * @var string String with name of icon for emailsenderprofile + */ + public $picto = 'emailsenderprofile@monmodule'; + + + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the filed must be managed. + * 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1), + 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + //'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), + //'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), + 'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), + 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,), + 'active' => array('type'=>'integer', 'label'=>'Active', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1), + ); + public $rowid; + public $entity; + public $label; + public $email; + public $date_creation; + public $tms; + //public $fk_user_creat; + //public $fk_user_modif; + public $signature; + public $position; + public $active; + // END MODULEBUILDER PROPERTIES + + + + // If this object has a subtable with lines + + /** + * @var int Name of subtable line + */ + //public $table_element_line = 'emailsenderprofiledet'; + /** + * @var int Field with ID of parent key if this field has a parent + */ + //public $fk_element = 'fk_emailsenderprofile'; + /** + * @var int Name of subtable class that manage subtable lines + */ + //public $class_element_line = 'EmailSenderProfileline'; + /** + * @var array Array of child tables (child tables to delete before deleting a record) + */ + //protected $childtables=array('emailsenderprofiledet'); + /** + * @var EmailSenderProfileLine[] Array of subtable lines + */ + //public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; + } + + /** + * 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) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $hookmanager, $langs; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * 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) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines 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 fetchLines($id, $ref = null) + { + $this->lines=array(); + + // Load lines with object EmailSenderProfileLine + + return count($this->lines)?1:0; + } + + /** + * 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) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * 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) + { + return $this->deleteCommon($user, $trigger); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @return string String with URL + */ + function getNomUrl($withpicto=0) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $url=''; + //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; + + $linkstart = ''; + $linkend=''; + + if ($withpicto) + { + $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); + if ($withpicto != 2) $result.=' '; + } + $result.= $linkstart . $this->label . $linkend; + return $result; + } + + /** + * Return link to download file from a direct external access + * + * @param int $withpicto Add download picto into link + * @return string HTML link to file + */ + function getDirectExternalLink($withpicto=0) + { + return 'todo'; + } + + /** + * 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); + } + + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + static 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'); + } + if ($mode == 6) + { + 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'); + } + } + + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + + } + else + { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } + +} + +/** + * Class EmailSenderProfileLine. You can also remove this and generate a CRUD class for lines objects. + */ +/* +class EmailSenderProfileLine +{ + // @var int ID + public $id; + // @var mixed Sample line property 1 + public $prop1; + // @var mixed Sample line property 2 + public $prop2; +} +*/ \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_c_email_senderprofile.key.sql b/htdocs/install/mysql/tables/llx_c_email_senderprofile.key.sql new file mode 100644 index 00000000000..a4896ea162c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_email_senderprofile.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2017 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- 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 . +-- +-- Table with templates of emails +-- =================================================================== + +ALTER TABLE llx_c_email_senderprofile ADD UNIQUE INDEX uk_c_email_senderprofile(entity, label, email); + diff --git a/htdocs/install/mysql/tables/llx_c_email_senderprofile.sql b/htdocs/install/mysql/tables/llx_c_email_senderprofile.sql new file mode 100644 index 00000000000..24a050ca45a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_email_senderprofile.sql @@ -0,0 +1,32 @@ +-- =================================================================== +-- Copyright (C) 2001-2017 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- 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 . +-- +-- Table with templates of emails +-- =================================================================== + +create table llx_c_email_senderprofile +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + private smallint DEFAULT 0 NOT NULL, -- Template public or private + date_creation datetime, + tms timestamp, + label varchar(255), -- Label of predefined email + email varchar(255) NOT NULL, -- Email + signature text -- Predefined signature + position smallint DEFAULT 0, -- Position + active tinyint DEFAULT 1 NOT NULL, +)ENGINE=innodb; From 37272b264c5d2a6b5f90e449c84104fa922751fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 19:45:18 +0200 Subject: [PATCH 061/128] Fix sql --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index b5e274c9d90..2380f13a06d 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -375,9 +375,9 @@ create table llx_c_email_senderprofile tms timestamp, label varchar(255), -- Label of predefined email email varchar(255), -- Email - signature text -- Predefined signature + signature text, -- Predefined signature position smallint, -- Position - active tinyint DEFAULT 1 NOT NULL, + active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; ALTER TABLE llx_c_email_senderprofile ADD UNIQUE INDEX uk_c_email_senderprofile(entity, label, email); From 0d0030cff4ee6c92bab3191100d48a4107a0628b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 19:57:53 +0200 Subject: [PATCH 062/128] Fix use of sender profiles --- htdocs/core/class/html.formmail.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 77f3d30c93b..3ad460a8688 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -426,7 +426,8 @@ class FormMail extends Form if (! ($this->fromtype === 'user' && $this->fromid > 0) && ! ($this->fromtype === 'company') && ! preg_match('/user_aliases/', $this->fromtype) - && ! preg_match('/global_aliases/', $this->fromtype)) + && ! preg_match('/global_aliases/', $this->fromtype) + && ! preg_match('/senderprofile/', $this->fromtype)) { // Use this->fromname and this->frommail or error if not defined $out.= $this->fromname; From d36af4a46a577c8496212fe7bcdbd210129a305b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 23:06:23 +0200 Subject: [PATCH 063/128] RUM number start with RUM- --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a3d50d58143..99b087e1939 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1503,7 +1503,7 @@ class BonPrelevement extends CommonObject static function buildRumNumber($row_code_client, $row_datec, $row_drum) { global $langs; - $pre = ($row_datec > 1359673200) ? $langs->trans('RUM').'-' : '++R'; + $pre = $langs->trans('RUM').'-'; return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } From 918738ce464166f8a606b0495a6c8d0efd3032b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 23:06:49 +0200 Subject: [PATCH 064/128] Set creation date --- htdocs/societe/rib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 7372229266c..6642cc62aac 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -205,7 +205,8 @@ if (empty($reshook)) $account->owner_address = GETPOST('owner_address','alpha'); $account->frstrecur = GETPOST('frstrecur'); $account->rum = GETPOST('rum','alpha'); - + $account->datec = dol_now(); + // This test can be done only once properties were set if ($account->needIBAN() == 1) { From 8674867db2368cce0d529519d8f3456391ceac8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 23:43:42 +0200 Subject: [PATCH 065/128] Fix creation/edit rum number --- .../class/companybankaccount.class.php | 80 +++++++++---------- htdocs/societe/rib.php | 57 +++++++++---- 2 files changed, 77 insertions(+), 60 deletions(-) diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 65c3ca37e0a..4853c54fdd9 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -70,7 +70,7 @@ class CompanyBankAccount extends Account function create(User $user = null, $notrigger=0) { $now = dol_now(); - $error = 0; + $error = 0; // Correct default_rib to be sure to have always one default $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1"; $result = $this->db->query($sql); @@ -89,29 +89,27 @@ class CompanyBankAccount extends Account if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); - - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('COMPANY_RIB_CREATE',$user); - if ($result < 0) $error++; - // End call triggers - if(! $error ) - { - return 1; - } - else - { - return 0; - } - - } - else - { - return 1; - } - + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('COMPANY_RIB_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + + if (! $error) + { + return 1; + } + else + { + return 0; + } + } + else + { + return 1; + } } } else @@ -132,14 +130,10 @@ class CompanyBankAccount extends Account { global $conf; $error = 0; - - if (! $this->id) - { - $this->create(); - } - - if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); + if (! $this->id) return -1; + + if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1); $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET"; @@ -169,8 +163,8 @@ class CompanyBankAccount extends Account $result = $this->db->query($sql); if ($result) { - - + + if (! $notrigger) { // Call trigger @@ -190,7 +184,7 @@ class CompanyBankAccount extends Account { return 1; } - + } else { @@ -265,13 +259,13 @@ class CompanyBankAccount extends Account function delete(User $user = null, $notrigger=0) { global $conf; - + $error = 0; - + dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); - + $this->db->begin(); - + if (! $error && ! $notrigger) { // Call trigger @@ -284,14 +278,14 @@ class CompanyBankAccount extends Account { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib"; $sql .= " WHERE rowid = " . $this->id; - + if (! $this->db->query($sql)) { $error++; $this->errors[]=$this->db->lasterror(); } } - + if (! $error) { $this->db->commit(); @@ -380,7 +374,7 @@ class CompanyBankAccount extends Account return -1; } } - + /** * Initialise an instance with random values. * Used to build previews or test instances. @@ -406,13 +400,13 @@ class CompanyBankAccount extends Account $this->proprio = 'Owner'; $this->owner_address = 'Owner address'; $this->country_id = 1; - + $this->rum = 'UMR-CU1212-0007-5-1475405262'; $this->date_rum =dol_now() - 10000; $this->frstrecur = 'FRST'; - + $this->socid = 0; } - + } diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 6642cc62aac..0be8b7f0d42 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -207,6 +207,8 @@ if (empty($reshook)) $account->rum = GETPOST('rum','alpha'); $account->datec = dol_now(); + $db->begin(); + // This test can be done only once properties were set if ($account->needIBAN() == 1) { @@ -226,26 +228,44 @@ if (empty($reshook)) if (! $error) { - if (empty($account->rum)) + $result = $account->create($user); + if ($result < 0) { - $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); - $account->date_rum = dol_now(); + $error++; + setEventMessages($account->error, $account->errors, 'errors'); + $action='create'; // Force chargement page création } + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + } + + if (! $error) + { $result = $account->update($user); // This will set the UMR number. - // TODO Use create and include update into create method - if (! $result) - { + if ($result < 0) + { + $error++; setEventMessages($account->error, $account->errors, 'errors'); - $_GET["action"]='create'; // Force chargement page création - } - else - { - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; + $action='create'; } } + + if (! $error) + { + $db->commit(); + + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + else + { + $db->rollback(); + } } } @@ -321,11 +341,14 @@ $formfile = new FormFile($db); llxHeader(); $head=societe_prepare_head($object); - if (! $id) - $account->fetch(0,$object->id); +{ + $account->fetch(0,$object->id); +} else +{ $account->fetch($id); +} if (empty($account->socid)) $account->socid=$object->id; if ($socid && $action == 'edit' && $user->rights->societe->creer) @@ -775,7 +798,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) // RUM print ''.$langs->trans("RUM").''; - print ''; + print ''; print ''.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); @@ -872,7 +895,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // RUM print ''.$langs->trans("RUM").''; - print '
'.$langs->trans("RUMWillBeGenerated").''; + print '
'.$langs->trans("RUMWillBeGenerated").''; print ''.$langs->trans("WithdrawMode").''; $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); From 5715f44fe648381b404a26587f0452c80f6c4552 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 00:02:24 +0200 Subject: [PATCH 066/128] Better error messages --- .../prelevement/class/bonprelevement.class.php | 13 +++++++++++-- htdocs/compta/prelevement/create.php | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 99b087e1939..25a4a6b18e2 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -849,7 +849,7 @@ class BonPrelevement extends CommonObject if ($soc->fetch($fact->socid) >= 0) { $bac = new CompanyBankAccount($this->db); - $bac->fetch(0,$soc->id); + $bac->fetch(0, $soc->id); if ($bac->verif() >= 1) //if (true) @@ -862,7 +862,8 @@ class BonPrelevement extends CommonObject else { dol_syslog(__METHOD__."::Check RIB Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR); - $this->invoice_in_error[$fac[0]]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty (reported by function verif) ".$soc->getNomUrl(0); + $this->invoice_in_error[$fac[0]]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); + $this->thirdparty_in_error[$soc->id]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); } } else @@ -889,6 +890,14 @@ class BonPrelevement extends CommonObject //print $out."\n"; dol_syslog($out); + // Return warning + $i=0; + foreach ($this->thirdparty_in_error as $key => $val) + { + if ($i < 10) setEventMessages($val, null, 'warnings'); + else setEventMessages('More error were discarded...', null, 'warnings'); + $i++; + } if (count($factures_prev) > 0) { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 09102ec1309..6c7eacc4015 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -192,7 +192,9 @@ if ($resql) if ($num) { - $var = True; + require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + $bac = new CompanyBankAccount($db); + while ($i < $num && $i < 20) { $obj = $db->fetch_object($resql); @@ -211,6 +213,8 @@ if ($resql) // RIB print ''; print $thirdpartystatic->display_rib(); + $bac->fetch(0, $obj->id); + if ($bac->verif() <= 0) print img_warning('Error on default bank number RIB/IBAN'); print ''; // RUM print ''; From 56e437a6c312fd84db38fa5763a3824536aeb8ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 00:03:24 +0200 Subject: [PATCH 067/128] Bed fetch --- 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 6c7eacc4015..5109a96c050 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -213,7 +213,7 @@ if ($resql) // RIB print ''; print $thirdpartystatic->display_rib(); - $bac->fetch(0, $obj->id); + $bac->fetch(0, $obj->socid); if ($bac->verif() <= 0) print img_warning('Error on default bank number RIB/IBAN'); print ''; // RUM From 31ab73ff3c36b4c87eb5ea7f2ff9f42fb19e526a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 00:12:26 +0200 Subject: [PATCH 068/128] Fix when verif is called several times --- htdocs/compta/bank/class/account.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 8ff51305e08..7b084b9e5ae 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1345,6 +1345,8 @@ class Account extends CommonObject { require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; + $this->error_number = 0; + // Call function to check BAN if (! checkBanForAccount($this)) { From 15bcbc8b437ed1a17ac69755b3b9bf83bcb6b420 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 00:38:59 +0200 Subject: [PATCH 069/128] FIX Check on bank info for sepa must be done on iban/swift not on ban --- htdocs/compta/bank/class/account.class.php | 14 ++++++++++---- .../prelevement/class/bonprelevement.class.php | 15 +++++++-------- htdocs/compta/prelevement/create.php | 5 +++-- htdocs/societe/class/societe.class.php | 5 +++++ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7b084b9e5ae..9d1bf141dc5 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1337,7 +1337,7 @@ class Account extends CommonObject /** - * Return if an account has valid information + * Return if an account has valid information for Direct debit payment * * @return int 1 if correct, <=0 if wrong */ @@ -1348,11 +1348,17 @@ class Account extends CommonObject $this->error_number = 0; // Call function to check BAN - if (! checkBanForAccount($this)) + + if (! checkIbanForAccount($bac) || ! checkSwiftForAccount($bac)) + { + $this->error_number = 12; + $this->error_message = 'IBANSWIFTControlError'; + } + /*if (! checkBanForAccount($this)) { $this->error_number = 12; - $this->error_message = 'RIBControlError'; - } + $this->error_message = 'BANControlError'; + }*/ if ($this->error_number == 0) { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 25a4a6b18e2..1036fe9041c 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -851,8 +851,7 @@ class BonPrelevement extends CommonObject $bac = new CompanyBankAccount($this->db); $bac->fetch(0, $soc->id); - if ($bac->verif() >= 1) - //if (true) + if ($bac->verif() >= 1) { $factures_prev[$i] = $fac; /* second tableau necessaire pour BonPrelevement */ @@ -861,9 +860,9 @@ class BonPrelevement extends CommonObject } else { - dol_syslog(__METHOD__."::Check RIB Error on default bank number RIB/IBAN for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR); - $this->invoice_in_error[$fac[0]]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); - $this->thirdparty_in_error[$soc->id]="Error on default bank number RIB/IBAN for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); + dol_syslog(__METHOD__."::Check RIB Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_ERR); + $this->invoice_in_error[$fac[0]]="Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); + $this->thirdparty_in_error[$soc->id]="Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0); } } else @@ -1525,9 +1524,9 @@ class BonPrelevement extends CommonObject * @param string $row_zip soc.zip * @param string $row_town soc.town * @param string $row_country_code c.code AS country, - * @param string $row_cb pl.code_banque AS cb, - * @param string $row_cg pl.code_guichet AS cg, - * @param string $row_cc pl.number AS cc, + * @param string $row_cb pl.code_banque AS cb, Not used for SEPA + * @param string $row_cg pl.code_guichet AS cg, Not used for SEPA + * @param string $row_cc pl.number AS cc, Not used for SEPA * @param string $row_somme pl.amount AS somme, * @param string $row_facnumber f.facnumber * @param string $row_idfac pf.fk_facture AS idfac, diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 5109a96c050..1cdfe8d9a7c 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -28,6 +28,7 @@ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -208,13 +209,13 @@ if ($resql) // Thirdparty print ''; $thirdpartystatic->fetch($obj->socid); - print $thirdpartystatic->getNomUrl(1,'card'); + print $thirdpartystatic->getNomUrl(1,'ban'); print ''; // RIB print ''; print $thirdpartystatic->display_rib(); $bac->fetch(0, $obj->socid); - if ($bac->verif() <= 0) print img_warning('Error on default bank number RIB/IBAN'); + if ($bac->verif() <= 0) print img_warning('Error on default bank number for IBAN : '.$bac->error_message); print ''; // RUM print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index bf449f30976..b8f54d86984 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1903,6 +1903,11 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowContacts") . ''; $linkstart = ''; + $linkstart = 'db, $conf->global->PRELEVEMENT_USER); - /* - * Read invoices - */ + $this->invoice_in_error = array(); + $this->thirdparty_in_error = array(); + + // Read invoices $factures = array(); $factures_prev = array(); $factures_result = array(); @@ -851,6 +856,9 @@ class BonPrelevement extends CommonObject $bac = new CompanyBankAccount($this->db); $bac->fetch(0, $soc->id); + if ($format == 'FRST' && $bac->frstrecur != 'FRST') continue; + if ($format == 'RCUR' && $bac->frstrecur != 'RCUR') continue; + if ($bac->verif() >= 1) { $factures_prev[$i] = $fac; @@ -890,13 +898,13 @@ class BonPrelevement extends CommonObject dol_syslog($out); // Return warning - $i=0; + /*$i=0; foreach ($this->thirdparty_in_error as $key => $val) { if ($i < 10) setEventMessages($val, null, 'warnings'); else setEventMessages('More error were discarded...', null, 'warnings'); $i++; - } + }*/ if (count($factures_prev) > 0) { @@ -1060,7 +1068,7 @@ class BonPrelevement extends CommonObject $this->factures = $factures_prev_id; // Generation of SEPA file $this->filename - $this->generate(); + $this->generate($format); } dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } @@ -1255,14 +1263,16 @@ class BonPrelevement extends CommonObject * - Others countries: Warning message * File is generated with name this->filename * - * @return int 0 if OK, <0 if KO + * @param string $format FRST, RCUR or ALL + * @return int 0 if OK, <0 if KO */ - //TODO: Optimize code to read lines in a single function - function generate() + function generate($format='ALL') { - global $conf,$langs,$mysoc; + global $conf,$langs,$mysoc; - $result = 0; + //TODO: Optimize code to read lines in a single function + + $result = 0; dol_syslog(get_class($this)."::generate build file ".$this->filename); @@ -1340,7 +1350,7 @@ class BonPrelevement extends CommonObject // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf if ($result != -2) { - $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf); + $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format); } else { @@ -1663,9 +1673,10 @@ class BonPrelevement extends CommonObject * @param int $nombre 0 or 1 * @param float $total Total * @param string $CrLf End of line character + * @param string $format FRST or RCUR or ALL * @return string String with SEPA Sender */ - function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n') + function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n', $format='FRST') { // SEPA INITIALISATION global $conf; @@ -1706,7 +1717,7 @@ class BonPrelevement extends CommonObject $country = explode(':', $configuration->global->MAIN_INFO_SOCIETE_COUNTRY); $IdBon = sprintf("%05d", $obj->rowid); $RefBon = $obj->ref; - $type = ($nombre == 1) ? 'FRST' : 'RCUR' ; + // SEPA Paiement Information $XML_SEPA_INFO = ''; $XML_SEPA_INFO .= ' '.$CrLf; @@ -1721,7 +1732,7 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' CORE'.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$type.''.$CrLf; + $XML_SEPA_INFO .= ' '.$format.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 1cdfe8d9a7c..700e587a6a6 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -45,6 +45,8 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons'); // Get supervariables $action = GETPOST('action','alpha'); +$mode = GETPOST('mode','alpha')?GETPOST('mode','alpha'):'real'; +$format = GETPOST('format','alpha'); /* @@ -63,7 +65,7 @@ if ($action == 'create') { // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty $bprev = new BonPrelevement($db); - $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET); + $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format); if ($result < 0) { setEventMessages($bprev->error, $bprev->errors, 'errors'); @@ -76,7 +78,7 @@ if ($action == 'create') $mesg.='
'."\n"; foreach($bprev->invoice_in_error as $key => $val) { - $mesg.=$val."
\n"; + $mesg.=''.$val."
\n"; } } else @@ -146,8 +148,30 @@ print "
\n"; if ($nb) { - if ($pricetowithdraw) print ''.$langs->trans("CreateAll")."\n"; - else print ''.$langs->trans("CreateAll")."\n"; + if ($pricetowithdraw) + { + if ($mysoc->isInEEC()) + { + print ''.$langs->trans("CreateForSepaFRST")."\n"; + print ''.$langs->trans("CreateForSepaRCUR")."\n"; + } + else + { + print ''.$langs->trans("CreateAll")."\n"; + } + } + else + { + if ($mysoc->isInEEC()) + { + print ''.$langs->trans("CreateForSepaFRST")."\n"; + print ''.$langs->trans("CreateForSepaRCUR")."\n"; + } + else + { + print ''.$langs->trans("CreateAll")."\n"; + } + } } else { @@ -220,6 +244,8 @@ if ($resql) // RUM print ''; print $thirdpartystatic->display_rib('rum'); + $format = $thirdpartystatic->display_rib('format'); + if ($format) print ' ('.$format.')'; print ''; // Amount print ''; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 308987575f5..6b1babf9d88 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -55,7 +55,9 @@ StatusMotif5=RIB unusable StatusMotif6=Account without balance StatusMotif7=Judicial Decision StatusMotif8=Other reason -CreateAll=Withdraw all +CreateForSepaFRST=Create direct debit file (SEPA FRST) +CreateForSepaRCUR=Create direct debit file (SEPA RCUR) +CreateAll=Create direct debit file (all) CreateGuichet=Only office CreateBanque=Only bank OrderWaiting=Waiting for treatment diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index b8f54d86984..d1d218a0061 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2254,7 +2254,7 @@ class Societe extends CommonObject /** * Return bank number property of thirdparty (label or rum) * - * @param string $mode 'label' or 'rum' + * @param string $mode 'label' or 'rum' or 'format' * @return string Bank number */ function display_rib($mode='label') @@ -2279,6 +2279,10 @@ class Societe extends CommonObject } return $bac->rum; } + elseif ($mode == 'format') + { + return $bac->frstrecur; + } return 'BadParameterToFunctionDisplayRib'; } From dd15884f830beeba51f0743049bf00a0635f34cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 01:35:04 +0200 Subject: [PATCH 072/128] Fix recur - rcur --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- htdocs/compta/prelevement/create.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 54990330135..e4156db8a5d 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -857,7 +857,7 @@ class BonPrelevement extends CommonObject $bac->fetch(0, $soc->id); if ($format == 'FRST' && $bac->frstrecur != 'FRST') continue; - if ($format == 'RCUR' && $bac->frstrecur != 'RCUR') continue; + if ($format == 'RCUR' && ($bac->frstrecur != 'RCUR' && $bac->frstrecur != 'RECUR')) continue; if ($bac->verif() >= 1) { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 700e587a6a6..380132058fd 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -46,7 +46,7 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons'); // Get supervariables $action = GETPOST('action','alpha'); $mode = GETPOST('mode','alpha')?GETPOST('mode','alpha'):'real'; -$format = GETPOST('format','alpha'); +$format = GETPOST('format','aZ09'); /* From 08c94f11b6b00bbf5e34ec97da8fb78ff487f92c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 01:44:26 +0200 Subject: [PATCH 073/128] FIX SEPA file if address is empty --- htdocs/compta/prelevement/class/bonprelevement.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index e4156db8a5d..3e8eb876a81 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1580,8 +1580,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$row_country_code.''.$CrLf; - $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).''.$CrLf; - $XML_DEBITOR .=' '.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).''.$CrLf; + if (trim($row_address)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).''.$CrLf; + if (trim($row_zip) || trim($row_town)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_zip.($row_zip && $row_town)?' ':''.$row_town), array(CHR(13) => ", ", CHR(10) => "")),70,'right','UTF-8',true)).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; From 1d92e807887d3e73a859b40c7f51272fca9e94d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 02:07:51 +0200 Subject: [PATCH 074/128] Fix line addr in xml sepa file --- .../prelevement/class/bonprelevement.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3e8eb876a81..972f67095e3 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1580,8 +1580,10 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$row_country_code.''.$CrLf; - if (trim($row_address)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).''.$CrLf; - if (trim($row_zip) || trim($row_town)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_zip.($row_zip && $row_town)?' ':''.$row_town), array(CHR(13) => ", ", CHR(10) => "")),70,'right','UTF-8',true)).''.$CrLf; + $addressline1 = dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))); + $addressline2 = dol_string_unaccent(strtr($row_zip.(($row_zip && $row_town)?' ':''.$row_town)), array(CHR(13) => ", ", CHR(10) => "")); + if (trim($addressline1)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc($addressline1,70,'right','UTF-8',true)).''.$CrLf; + if (trim($addressline2)) $XML_DEBITOR .=' '.dolEscapeXML(dol_trunc($addressline2,70,'right','UTF-8',true)).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1739,8 +1741,10 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($configuration->global->MAIN_INFO_SOCIETE_ADDRESS)).''.$CrLf; - $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($configuration->global->MAIN_INFO_SOCIETE_ZIP.' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN)).''.$CrLf; + $addressline1 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => ""))); + $addressline2 = dol_string_unaccent(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN)?' ':'').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => ""))); + if ($addressline1) $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf; + if ($addressline2) $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; From 5fd6a27c62597a23258bcdfe910d09a067b6a5c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 02:16:54 +0200 Subject: [PATCH 075/128] Fix position of top menu --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f79ac461828..3af93cbcbf6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -182,7 +182,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='accountancy'; - $menu->add('/accountancy/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("Accountancy"), 0, $showmode, $atarget, "accountancy", '', 50, $id, $idsel, $classname); + $menu->add('/accountancy/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("Accountancy"), 0, $showmode, $atarget, "accountancy", '', 52, $id, $idsel, $classname); } From ca0af5cddf99dc60053bb918047b4407c9932a74 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 02:25:17 +0200 Subject: [PATCH 076/128] NEW Bulk action validate on customer invoices --- htdocs/compta/facture/list.php | 6 ++++-- htdocs/core/actions_massactions.inc.php | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index be81fe48a0c..1f22bf31523 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -233,7 +233,8 @@ if (empty($reshook)) $objectclass='Facture'; $objectlabel='Invoices'; $permtoread = $user->rights->facture->lire; - $permtodelete = $user->rights->facture->supprimer; + $permtocreate = $user->rights->facture->creer; + $permtodelete = $user->rights->facture->supprimer; $uploaddir = $conf->facture->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -573,7 +574,8 @@ if ($resql) } $arrayofmassactions=array( - 'presend'=>$langs->trans("SendByMail"), + 'validate'=>$langs->trans("Validate"), + 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); if ($conf->prelevement->enabled) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 76534211481..0b196699dc0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -663,6 +663,12 @@ if ($action == 'remove_file') // Validate records if (! $error && $massaction == 'validate' && $permtocreate) { + if ($object->element == 'invoice' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); + $error++; + } if ($object->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { $langs->load("errors"); From 4a93b709ad8b14de33e71def7cb6f7207e9b1bf7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 02:46:49 +0200 Subject: [PATCH 077/128] Add param desc on payment link --- htdocs/public/payment/newpayment.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1862a5b8a47..73fe099f09b 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -712,6 +712,7 @@ if ($source == 'order') // Object $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; + if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; @@ -824,6 +825,7 @@ if ($source == 'invoice') // Object $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; + if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; @@ -1006,7 +1008,7 @@ if ($source == 'contractline') { $text.='
'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite); } - + if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; @@ -1149,6 +1151,7 @@ if ($source == 'membersubscription') // Object $text=''.$langs->trans("PaymentSubscription").''; + if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; From 3dbd7e600f6ca7f958230500a1f32dc9f7dce497 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 02:47:53 +0200 Subject: [PATCH 078/128] Fix param desc --- htdocs/public/payment/newpayment.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 73fe099f09b..345504b2f1d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -712,7 +712,7 @@ if ($source == 'order') // Object $text=''.$langs->trans("PaymentOrderRef",$order->ref).''; - if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; + if (GETPOST('desc','alpha')) $text=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; @@ -825,7 +825,7 @@ if ($source == 'invoice') // Object $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).''; - if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; + if (GETPOST('desc','alpha')) $text=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; @@ -1008,7 +1008,7 @@ if ($source == 'contractline') { $text.='
'.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite); } - if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; + if (GETPOST('desc','alpha')) $text=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; @@ -1151,7 +1151,7 @@ if ($source == 'membersubscription') // Object $text=''.$langs->trans("PaymentSubscription").''; - if (GETPOST('desc','alpha')) $text.=''.$langs->trans(GETPOST('desc','alpha')).''; + if (GETPOST('desc','alpha')) $text=''.$langs->trans(GETPOST('desc','alpha')).''; print ''.$langs->trans("Designation"); print ''.$text; print ''; From f8eca95c8257052fcc6bbff9ec4ad444cd527f36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 02:59:00 +0200 Subject: [PATCH 079/128] Better param desc --- htdocs/public/payment/newpayment.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 345504b2f1d..5e3428019d6 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -277,7 +277,7 @@ if ($action == 'dopayment') $shipToStreet2=GETPOST("shipToStreet2"); $phoneNum=GETPOST("phoneNum"); $email=GETPOST("email"); - $desc=GETPOST("desc"); + $desc=GETPOST("desc",'alpha'); $mesg=''; if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); @@ -772,7 +772,9 @@ if ($source == 'order') print ''."\n"; } print ''."\n"; - print 'ref.'">'."\n"; + $labeldesc=$langs->trans("Order").' '.$order->ref; + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } @@ -893,7 +895,9 @@ if ($source == 'invoice') print ''."\n"; } print ''."\n"; - print 'ref.'">'."\n"; + $labeldesc=$langs->trans("Invoice").' '.$invoice->ref; + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } // Payment on contract line @@ -1096,7 +1100,9 @@ if ($source == 'contractline') print ''."\n"; } print ''."\n"; - print 'ref.'">'."\n"; + $labeldesc=$langs->trans("Contract").' '.$contract->ref; + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } // Payment on member subscription @@ -1252,7 +1258,9 @@ if ($source == 'membersubscription') print ''."\n"; } print ''."\n"; - print ''."\n"; + $labeldesc = $langs->trans("PaymentSubscription"); + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } From 8d3df7ea5751136bc01cdbca4608d16255766475 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 12 Oct 2017 09:59:25 +0200 Subject: [PATCH 080/128] Fix can not distinct which credit note are in select list --- htdocs/core/class/html.form.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 25cdfa2d887..5330ce24048 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1188,12 +1188,17 @@ class Form // On recherche les remises $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql.= " re.description, re.fk_facture_source"; + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= ", f.facnumber"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re"; + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture f ON (f.rowid = re.fk_facture_source)"; $sql.= " WHERE re.fk_soc = ".(int) $socid; $sql.= " AND re.entity = " . $conf->entity; if ($filter) $sql.= " AND ".$filter; $sql.= " ORDER BY re.description ASC"; + // Prevent sql error on the ambiguous column + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql = preg_replace('/(.*)(?!re\.)fk_facture_source(.*)/m', '\1 re.fk_facture_source \2', $sql); + dol_syslog(get_class($this)."::select_remises", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1225,6 +1230,8 @@ class Form $disabled=' disabled'; } + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->facnumber)) $desc=$desc.' - '.$obj->facnumber; + print ''; $i++; } From 151fb72183c21b8c630ba75955498229cf4f3631 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 12 Oct 2017 12:28:10 +0200 Subject: [PATCH 081/128] NEW documents REST API return list of documents by element --- htdocs/api/class/api_documents.class.php | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 6339ce4a91a..397910a6e2f 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -129,6 +129,75 @@ class Documents extends DolibarrApi return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); } + /** + * Return the list of documents of an element + * + * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) + * @param int $id ID of element + * @param string $ref Ref of element + * @return array Array of documents with path + * + * @throws RestException + * + * @url GET list + */ + function getDocumentsListByElement($modulepart, $id=0, $ref='') + { + global $conf; + + if (empty($modulepart)) { + throw new RestException(400, 'bad value for parameter modulepart'); + } + + if (empty($id) && empty($ref)) { + throw new RestException(400, 'bad value for parameter id or ref'); + } + + $id = (empty($id)?0:$id); + + if ($modulepart == 'societe' || $modulepart == 'thirdparty') + { + if (!DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + $object = new Societe($this->db); + $result=$object->fetch($id, $ref); + if ( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; + } + else if ($modulepart == 'adherent' || $modulepart == 'member') + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + + if (!DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } + + $object = new Adherent($this->db); + $result=$object->fetch($id, $ref); + if ( ! $result ) { + throw new RestException(404, 'Member not found'); + } + + $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); + } + else + { + throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); + } + + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + if (empty($filearray)) { + throw new RestException(404, 'Modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' and Ref '.$object->ref:'').' does not have any documents.'); + } + + return $filearray; + } + /** * Return a document. From 3f36cf23f59e83949c1b5e72e6093df9ea1543c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 13:03:45 +0200 Subject: [PATCH 082/128] NEW Break lines per project on the new timesheet page --- htdocs/core/lib/project.lib.php | 106 ++++++++++++++++++++--------- htdocs/projet/activity/perday.php | 17 ++--- htdocs/projet/activity/perweek.php | 16 ++--- htdocs/projet/class/task.class.php | 44 ++++++------ htdocs/theme/eldy/style.css.php | 23 ++++--- htdocs/theme/md/style.css.php | 7 ++ 6 files changed, 133 insertions(+), 80 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 05bbcf26098..b9c1eb1f1fb 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -611,6 +611,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr } } + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_BREAK_ON_PROJECT)?0:-1); // 0 to start break , -1 no break + //dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); for ($i = 0 ; $i < $numlines ; $i++) { @@ -648,6 +650,31 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr $projectstatic->public=$lines[$i]->public; $taskstatic->id=$lines[$i]->id; + $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); + $taskstatic->id=$lines[$i]->id; + $taskstatic->label=$lines[$i]->label; + $taskstatic->date_start=$lines[$i]->date_start; + $taskstatic->date_end=$lines[$i]->date_end; + + $thirdpartystatic->id=$lines[$i]->socid; + $thirdpartystatic->name=$lines[$i]->thirdparty_name; + $thirdpartystatic->email=$lines[$i]->thirdparty_email; + + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) + { + print ''."\n"; + print ''; + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($projectstatic->title) + { + print ' - '; + print $projectstatic->title; + } + print ''; + print ''; + } + + if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; print ''."\n"; @@ -660,30 +687,23 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Project print ""; - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); print ""; // Thirdparty print ''; - $thirdpartystatic->id=$lines[$i]->socid; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - print $thirdpartystatic->getNomUrl(1, 'project', 10); + if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); print ''; // Ref print ''; - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); - print $taskstatic->getNomUrl(1, 'withproject', 'time'); - print ''; - - // Label task - print ""; + print ''; for ($k = 0 ; $k < $level ; $k++) print "   "; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->label; - $taskstatic->date_start=$lines[$i]->date_start; - $taskstatic->date_end=$lines[$i]->date_end; - print $taskstatic->getNomUrl(0, 'withproject', 'time'); + print $taskstatic->getNomUrl(1, 'withproject', 'time'); + // Label task + print '
'; + for ($k = 0 ; $k < $level ; $k++) print "   "; + print $taskstatic->label; //print "
"; //for ($k = 0 ; $k < $level ; $k++) print "   "; //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); @@ -773,7 +793,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''; - print ''; + // Note + print ''; print ''; print ''; @@ -850,6 +871,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0)); + $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_BREAK_ON_PROJECT)?0:-1); // 0 = start break, -1 = never break + for ($i = 0 ; $i < $numlines ; $i++) { if ($parent == 0) $level = 0; @@ -880,6 +903,33 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $projectstatic->public=$lines[$i]->public; $projectstatic->thirdparty_name=$lines[$i]->thirdparty_name; + $taskstatic->id=$lines[$i]->id; + $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); + $taskstatic->id=$lines[$i]->id; + $taskstatic->label=$lines[$i]->label; + $taskstatic->date_start=$lines[$i]->date_start; + $taskstatic->date_end=$lines[$i]->date_end; + + $thirdpartystatic->id=$lines[$i]->thirdparty_id; + $thirdpartystatic->name=$lines[$i]->thirdparty_name; + $thirdpartystatic->email=$lines[$i]->thirdparty_email; + + if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) + { + print ''."\n"; + print ''; + print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($projectstatic->title) + { + print ' - '; + print $projectstatic->title; + } + print ''; + print ''; + } + + if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id; + print ''."\n"; // User @@ -891,32 +941,24 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ // Project print ''; - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); print ""; // Thirdparty print ''; - $thirdpartystatic->id=$lines[$i]->thirdparty_id; - $thirdpartystatic->name=$lines[$i]->thirdparty_name; - print $thirdpartystatic->getNomUrl(1, 'project'); + if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); print ''; // Ref print ''; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); - print $taskstatic->getNomUrl(1, 'withproject', 'time'); - print ''; - - // Label task - print ""; print ''; for ($k = 0 ; $k < $level ; $k++) print "   "; - $taskstatic->id=$lines[$i]->id; - $taskstatic->ref=$lines[$i]->label; - $taskstatic->date_start=$lines[$i]->date_start; - $taskstatic->date_end=$lines[$i]->date_end; - print $taskstatic->getNomUrl(0, 'withproject', 'time'); + print $taskstatic->getNomUrl(1, 'withproject', 'time'); + // Label task + print '
'; + for ($k = 0 ; $k < $level ; $k++) print "   "; + //print $taskstatic->getNomUrl(0, 'withproject', 'time'); + print $taskstatic->label; //print "
"; //for ($k = 0 ; $k < $level ; $k++) print "   "; //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 061c522918a..5cea39bc59e 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -324,9 +324,10 @@ if ($id) $onlyopenedproject=1; // or -1 $morewherefilter=''; -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label); +if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); + $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); @@ -445,7 +446,7 @@ print ''; print ''; print ''; -print ''; +//print ''; print ''; print ''; print ''; @@ -462,10 +463,10 @@ print ''; print "\n"; print ''; -print ''; +print ''; print ''; -print ''; -print ''; +//print ''; +print ''; print ''; print ''; /*print ''; @@ -475,7 +476,7 @@ print ''; print ''; print ''; -print ''; +print ''; print ''; print "\n"; @@ -495,7 +496,7 @@ if (count($tasksarray) > 0) $j=0; projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable); - $colspan = 9; + $colspan = 8; print ''; if (! $i) $totalarray['nbfield']++; } @@ -854,7 +854,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } From 50da6a0c9e4c013a4afa4958fcfd1c2df5c4e1c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 14:59:38 +0200 Subject: [PATCH 085/128] Prepare code for removing adodb --- htdocs/core/lib/functions.lib.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 96823262800..aa5628f02b9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1599,7 +1599,7 @@ function dol_strftime($fmt, $ts=false, $is_gmt=false) * @param string $tzoutput true or 'gmt' => string is for Greenwich location * false or 'tzserver' => output string is for local PHP server TZ usage * 'tzuser' => output string is for user TZ (current browser TZ with current dst) - * 'tzuserrel' => output string is for user TZ (current browser TZ with dst or not, depending on date position) + * 'tzuserrel' => output string is for user TZ (current browser TZ with dst or not, depending on date position) (TODO not implemented yet) * @param Translate $outputlangs Object lang that contains language for text translation. * @param boolean $encodetooutput false=no convert into output pagecode * @return string Formated date or '' if time is null @@ -1698,14 +1698,14 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e $ssec = (! empty($reg[6]) ? $reg[6] : ''); $time=dol_mktime($shour,$smin,$ssec,$smonth,$sday,$syear,true); - $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); + $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. } else { // Date is a timestamps if ($time < 100000000000) // Protection against bad date values { - $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. } else $ret='Bad value '.$time.' for date'; } @@ -1713,8 +1713,8 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e if (preg_match('/__b__/i',$format)) { // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. - $month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. + $month=adodb_strftime('%m', $time+$offsettz+$offsetdst); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. + $month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. if ($encodetooutput) { $monthtext=$outputlangs->transnoentities('Month'.$month); @@ -1733,7 +1733,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e } if (preg_match('/__a__/i',$format)) { - $w=adodb_strftime('%w',$time+$offsettz+$offsetdst); // TODO Remove this + $w=adodb_strftime('%w', $time+$offsettz+$offsetdst); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. $dayweek=$outputlangs->transnoentitiesnoconv('Day'.$w); $ret=str_replace('__A__',$dayweek,$ret); $ret=str_replace('__a__',dol_substr($dayweek,0,3),$ret); From 1fba58b9ce1d359cb8700be09e4addea170c7ef7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 17:09:17 +0200 Subject: [PATCH 086/128] Fix bookmark list --- htdocs/bookmarks/list.php | 22 ++++--------------- .../install/mysql/migration/6.0.0-7.0.0.sql | 1 + htdocs/install/mysql/tables/llx_projet.sql | 2 +- htdocs/projet/list.php | 4 ++-- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index c9387561837..81205e4d6f8 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -83,7 +83,7 @@ llxHeader('', $langs->trans("ListOfBookmarks")); print load_fiche_titre($langs->trans("ListOfBookmarks")); -$sql = "SELECT b.fk_soc as rowid, b.dateb, b.rowid as bid, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,"; +$sql = "SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,"; $sql.= " u.login, u.lastname, u.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid"; $sql.= " WHERE 1=1"; @@ -107,7 +107,7 @@ if ($resql) print ""; //print ""; - print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"bid","", $param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"rowid","", $param,'align="left"',$sortfield,$sortorder); print_liste_field_titre("Title",$_SERVER["PHP_SELF"],"title","", $param,'align="left"',$sortfield,$sortorder); print_liste_field_titre("Link",'',''); print_liste_field_titre("Target",'','','','','align="center"'); @@ -127,7 +127,7 @@ if ($resql) // Id print ''; $linkintern=0; @@ -136,21 +136,7 @@ if ($resql) // Title print "'; if (! $i) $totalarray['nbfield']++; } @@ -854,7 +854,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } From 074eda016b193af0ab773bfe81ffe9f73e9ca0f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 17:12:42 +0200 Subject: [PATCH 087/128] Fix redirect to bookmark only if not external link --- htdocs/bookmarks/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 2c3b200b4e4..3a4ae51d62d 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -65,7 +65,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if (GETPOST('cancel','alpha')) { - if (empty($backtopage)) $backtopage=($urlsource?$urlsource:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/list.php')); + if (empty($backtopage)) $backtopage=($urlsource?$urlsource:((! empty($url) && ! preg_match('/^http/i', $url))?$url:DOL_URL_ROOT.'/bookmarks/list.php')); header("Location: ".$backtopage); exit; } From 31aa1faa325c253ab18ff5dfc703f1f7b2529656 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 17:18:05 +0200 Subject: [PATCH 088/128] Fix bookmark edit --- htdocs/bookmarks/card.php | 2 +- htdocs/bookmarks/list.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 3a4ae51d62d..dcc6d8cdeab 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -98,7 +98,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if ($res > 0) { - if (empty($backtopage)) $backtopage=($urlsource?$urlsource:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/list.php')); + if (empty($backtopage)) $backtopage=($urlsource?$urlsource:((! empty($url) && ! preg_match('/^http/i', $url))?$url:DOL_URL_ROOT.'/bookmarks/list.php')); header("Location: ".$backtopage); exit; } diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 81205e4d6f8..0e22e2112cd 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -50,7 +50,7 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='position'; if (! $sortorder) $sortorder='ASC'; -$id = GETPOST("bid",'int'); +$id = GETPOST("id",'int'); /* @@ -179,11 +179,11 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } @@ -833,7 +833,7 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['d.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 0f2fd46c3f6..5e893a3ab44 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -866,7 +866,7 @@ if ($resql) if (! empty($arrayfields['p.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -874,7 +874,7 @@ if ($resql) if (! empty($arrayfields['p.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 72f2ac61213..49386538468 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1307,7 +1307,7 @@ if ($resql) if (! empty($arrayfields['c.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -1315,7 +1315,7 @@ if ($resql) if (! empty($arrayfields['c.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1f22bf31523..a7cc2f9e719 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1157,7 +1157,7 @@ if ($resql) if (! empty($arrayfields['f.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -1165,7 +1165,7 @@ if ($resql) if (! empty($arrayfields['f.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 05fcf3e0916..ac953d802de 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -821,7 +821,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -829,7 +829,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index dfc00f95e11..d32986cbeeb 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -795,7 +795,7 @@ if ($resql) if (! empty($arrayfields['c.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -803,7 +803,7 @@ if ($resql) if (! empty($arrayfields['c.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 945b5b8b983..d39c61e397c 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -720,7 +720,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['cd.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -728,7 +728,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['cd.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 4cdff0bd38c..2c1427c87f5 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -625,7 +625,7 @@ if ($resql) if (! empty($arrayfields['e.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -633,7 +633,7 @@ if ($resql) if (! empty($arrayfields['e.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index c483dae647f..ef97d487298 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -558,7 +558,7 @@ if ($resql) if (! empty($arrayfields['f.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -566,7 +566,7 @@ if ($resql) if (! empty($arrayfields['f.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ce95cfc7ebf..3894cf28cc4 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1180,7 +1180,7 @@ if ($resql) if (! empty($arrayfields['cf.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -1188,7 +1188,7 @@ if ($resql) if (! empty($arrayfields['cf.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 9d6c5e4ccd3..e74a3b4df8e 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1074,7 +1074,7 @@ if ($resql) if (! empty($arrayfields['f.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -1082,7 +1082,7 @@ if ($resql) if (! empty($arrayfields['f.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index b6c2f86e13f..4c314661959 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -504,7 +504,7 @@ while ($i < min($num, $limit)) print ''; foreach($object->fields as $key => $val) { - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Discard some field output at end $align=''; if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; @@ -512,7 +512,8 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); + elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1); elseif ($key == 'status') print $object->getLibStatut(3); else print $obj->$key; @@ -555,7 +556,7 @@ while ($i < min($num, $limit)) // Rest of fields foreach($object->fields as $key => $val) { - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Keep only field not yet already output $align=''; if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; @@ -563,7 +564,8 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); + if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); + elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); elseif ($key == 'status') print $object->getLibStatut(3); else print $obj->$key; print ''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index df3a04d3233..525bd96ed90 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -963,7 +963,7 @@ else if (! empty($arrayfields['p.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -971,7 +971,7 @@ else if (! empty($arrayfields['p.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 6c282f12101..7d236c904f5 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -527,7 +527,7 @@ if ($resql) if (! empty($arrayfields['t.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -535,7 +535,7 @@ if ($resql) if (! empty($arrayfields['t.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index f2da27ea56f..ccc2c12584e 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -816,7 +816,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['t.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -824,7 +824,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['t.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 4f8b5513016..f9e10667ccd 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1261,7 +1261,7 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['s.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -1269,7 +1269,7 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['s.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 013ad832898..9b345827a8e 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -853,7 +853,7 @@ if ($resql) if (! empty($arrayfields['sp.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -861,7 +861,7 @@ if ($resql) if (! empty($arrayfields['sp.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 91fe86517c6..15571755944 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -644,7 +644,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['u.datec']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } @@ -652,7 +652,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['u.tms']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } From 6497ca53942213bd933b45a1e4f194e13ff9deff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 18:14:02 +0200 Subject: [PATCH 090/128] prepare tzuserrel --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index aa5628f02b9..c3c7913e2d4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1625,7 +1625,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e $offsettz=0; $offsetdst=0; } - elseif ($tzoutput == 'tzuser') + elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') { $to_gmt=true; $offsettzstring=(empty($_SESSION['dol_tz_string'])?'UTC':$_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' From 86f7add3556e328a5264162c776905c815c10e95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 19:12:52 +0200 Subject: [PATCH 091/128] FIX Default value was not set --- htdocs/societe/rib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 0be8b7f0d42..7bfc5a482fe 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -571,6 +571,7 @@ if ($socid && $action != 'edit' && $action != "create") include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; $modellist=ModeleBankAccountDoc::liste_modeles($db); + $out = ''; if (is_array($modellist) && count($modellist)) { @@ -585,6 +586,8 @@ if ($socid && $action != 'edit' && $action != "create") $arraykeys=array_keys($modellist); $modelselected=$arraykeys[0]; } + if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; + $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); $out.= ajax_combobox('modelrib'.$rib->id); From 6455e6d4725bc2e0279889ffef16aab7b6a9a848 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Thu, 12 Oct 2017 21:19:24 +0200 Subject: [PATCH 092/128] Use billed field from database on fetch shipping --- htdocs/expedition/class/expedition.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index d440396d0c3..cf1c7afad9c 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -481,7 +481,7 @@ class Expedition extends CommonObject // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; + $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.billed"; $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; $sql.= ", e.fk_shipping_method, e.tracking_number"; @@ -525,7 +525,7 @@ class Expedition extends CommonObject $this->tracking_number = $obj->tracking_number; $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility $this->origin_id = $obj->origin_id; - $this->billed = ($obj->fk_statut==2?1:0); + $this->billed = $obj->billed; $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; From e0a8f03f06382325339ed45dcd7a6c175aefc8db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 23:45:53 +0200 Subject: [PATCH 093/128] Disable prof id 4,5,6 by default --- htdocs/langs/fr_FR/companies.lang | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 67ef632a010..ffed13c0c69 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -101,15 +101,15 @@ Gencod=Code-barres ProfId1Short=Id. prof. 1 ProfId2Short=Id. prof. 2 ProfId3Short=Id. prof. 3 -ProfId4Short=Id. prof. 4 -ProfId5Short=Id. prof. 5 -ProfId6Short=Id prof. 6 +ProfId4Short=- +ProfId5Short=- +ProfId6Short=- ProfId1=Identifiant professionnel 1 ProfId2=Identifiant professionnel 2 ProfId3=Identifiant professionnel 3 -ProfId4=Identifiant professionnel 4 -ProfId5=Identifiant professionnel 5 -ProfId6=Identifiant professionnel 6 +ProfId4=- +ProfId5=- +ProfId6=- ProfId1AR=Id. prof. 1 (CUIT/CUIL) ProfId2AR=Id. prof. 2 (Revenus brutes) ProfId3AR=- From 558f261b604a196bad04f7a6cc7d1b3c9b09ce33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 01:03:33 +0200 Subject: [PATCH 094/128] FIX #7593 --- htdocs/comm/remx.php | 2 +- htdocs/compta/facture/card.php | 12 ++++++------ htdocs/core/class/discount.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 17 ++++++++++++++--- htdocs/langs/en_US/companies.lang | 1 + 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 94142b6ec54..17e2feb4a84 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -389,7 +389,7 @@ if ($socid > 0) $facturestatic->id=$obj->fk_facture_source; $facturestatic->ref=$obj->ref; $facturestatic->type=$obj->type; - print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1); + print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("ExcessReceived"),$obj->description).' '.$facturestatic->getNomURl(1); print ''; } else diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1d621d153f5..9c0aff43abf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2843,12 +2843,12 @@ else if ($id > 0 || ! empty($ref)) $resteapayer = 0; $resteapayeraffiche = $resteapayer; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%'))"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'"; + $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'))"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); @@ -2871,9 +2871,9 @@ else if ($id > 0 || ! empty($ref)) // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { - if($object->type == 0) $type_fac = 'ExcessReceived'; - elseif($object->type == 2) $type_fac = 'CreditNote'; - elseif($object->type == 3) $type_fac = 'Deposit'; + if($object->type == Facture::TYPE_STANDARD) $type_fac = 'ExcessReceived'; + elseif($object->type == Facture::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; + elseif($object->type == Facture::TYPE_DEPOSIT) $type_fac = 'Deposit'; $text = $langs->trans('ConfirmConvertToReduc', strtolower($langs->transnoentities($type_fac))); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 89bb230d34f..bef86a320ab 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -445,14 +445,14 @@ class DiscountAbsolute $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql.= ' AND f.type = 2'; + $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received } else if ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql.= ' AND f.type = 2'; + $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received } else { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 25cdfa2d887..05b976ad4d2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4153,15 +4153,26 @@ class Form print ''; print ''; print '
'; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) // Never use this option. { if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); // If we want deposit to be substracted to payments only and not to total of final invoice else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); } else { - if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%'))") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); - else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); + if (! $filter) + { + print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); + } + elseif ($filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'))") + { + // Replace trans key with CompanyHasDownPaymentOrCommercialDiscount + print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); + } + else + { + print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); + } } if (empty($hidelist)) print ': '; print '
'; diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index bd7d7983191..2be010b8803 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -265,6 +265,7 @@ CustomerAbsoluteDiscountShort=Absolute discount CompanyHasRelativeDiscount=This customer has a default discount of %s%% CompanyHasNoRelativeDiscount=This customer has no relative discount by default CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for %s %s +CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for %s %s CompanyHasCreditNote=This customer still has credit notes for %s %s CompanyHasNoAbsoluteDiscount=This customer has no discount credit available CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users) From c3ada198927600fad1a7009551155a48f23d5ac1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 01:27:49 +0200 Subject: [PATCH 095/128] Fix demo backup --- dev/initdemo/savedemo.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/initdemo/savedemo.sh b/dev/initdemo/savedemo.sh index fd3f8caafd5..20aebb29b28 100755 --- a/dev/initdemo/savedemo.sh +++ b/dev/initdemo/savedemo.sh @@ -187,6 +187,7 @@ export list=" --ignore-table=$base.llx_bt_webseedfiles --ignore-table=$base.llx_c_civilite --ignore-table=$base.llx_c_dolicloud_plans + --ignore-table=$base.llx_c_pays --ignore-table=$base.llx_c_source --ignore-table=$base.llx_cabinetmed_c_banques --ignore-table=$base.llx_cabinetmed_c_ccam From 857b59409c832ca1b3e6b49a6b8a0f50a3093d09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 01:50:00 +0200 Subject: [PATCH 096/128] FIX sql syntax error because of old field accountancy_journal --- htdocs/compta/charges/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index e048de2deb7..c9a58670897 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -135,7 +135,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; @@ -256,7 +256,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; @@ -470,7 +470,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; From 6fcc0bfdcab95996d7ed5a998ee878f5c75a9cc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 02:02:13 +0200 Subject: [PATCH 097/128] Remove deprecated option --- htdocs/accountancy/admin/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index bc078c062c6..5ce7d6c0413 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +20,6 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ /** @@ -167,7 +167,7 @@ print '' print ''; // Default mode for calculating turnover (parameter ACCOUNTING_MODE) - +/* print '
'.$langs->trans("ProjectRef").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("RefTask").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpent").'
( print '
'.$langs->trans("TimeSpent").''.$langs->trans("HourStart").''.$langs->trans("Duration").''.$langs->trans("Note").''.$langs->trans("Note").'
'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 1d71608e634..f44a03b0cd9 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -328,8 +328,8 @@ if ($id) $onlyopenedproject=1; // or -1 $morewherefilter=''; -if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); -if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label); +if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); +if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. @@ -450,7 +450,7 @@ print ''; print ''; print ''; -print ''; +//print ''; print ''; print ''; print ''; @@ -468,10 +468,10 @@ print ''; print "\n"; print ''; -print ''; +print ''; print ''; -print ''; -print ''; +//print ''; +print ''; print ''; print ''; /*print ''; @@ -517,7 +517,7 @@ if (count($tasksarray) > 0) $level=0; projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable); - $colspan=8; + $colspan=7; print ''; + print ''; } print "
'.$langs->trans("ProjectRef").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("RefTask").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").'
'; @@ -536,7 +536,7 @@ if (count($tasksarray) > 0) } else { - print '
'.$langs->trans("NoTasks").'
'.$langs->trans("NoTasks").'
"; print ''; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index f6969075b2a..e5c9e169b5c 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -669,14 +669,14 @@ class Task extends CommonObject * @param int $projectid Project id * @param int $socid Third party id * @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists - * @param string $filteronprojref Filter on project ref + * @param string $filteronproj Filter on project ref or label * @param string $filteronprojstatus Filter on project status * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') * @param string $filteronprojuser Filter on user that is a contact of project * @param string $filterontaskuser Filter on user assigned to task * @return array Array of tasks */ - function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0, $filteronprojref='', $filteronprojstatus=-1, $morewherefilter='',$filteronprojuser=0,$filterontaskuser=0) + function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0, $mode=0, $filteronproj='', $filteronprojstatus=-1, $morewherefilter='',$filteronprojuser=0,$filterontaskuser=0) { global $conf; @@ -690,7 +690,7 @@ class Task extends CommonObject $sql.= " p.rowid as projectid, p.ref, p.title as plabel, p.public, p.fk_statut as projectstatus,"; $sql.= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,"; $sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,"; - $sql.= " s.rowid as thirdparty_id, s.nom as thirdparty_name"; + $sql.= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; if ($mode == 0) @@ -751,7 +751,7 @@ class Task extends CommonObject } if ($socid) $sql.= " AND p.fk_soc = ".$socid; if ($projectid) $sql.= " AND p.rowid in (".$projectid.")"; - if ($filteronprojref) $sql.= " AND p.ref LIKE '%".$this->db->escape($filteronprojref)."%'"; + if ($filteronproj) $sql.= " AND (p.ref LIKE '%".$this->db->escape($filteronproj)."%' OR p.title LIKE '%".$this->db->escape($filteronproj)."%')"; if ($filteronprojstatus > -1) $sql.= " AND p.fk_statut = ".$filteronprojstatus; if ($morewherefilter) $sql.=$morewherefilter; $sql.= " ORDER BY p.ref, t.rang, t.dateo"; @@ -807,8 +807,10 @@ class Task extends CommonObject $tasks[$i]->date_end = $this->db->jdate($obj->date_end); $tasks[$i]->rang = $obj->rang; + $tasks[$i]->socid = $obj->thirdparty_id; // For backward compatibility $tasks[$i]->thirdparty_id = $obj->thirdparty_id; $tasks[$i]->thirdparty_name = $obj->thirdparty_name; + $tasks[$i]->thirdparty_email= $obj->thirdparty_email; } $i++; @@ -1695,8 +1697,8 @@ class Task extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - - + + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1706,12 +1708,12 @@ class Task extends CommonObject function load_board($user) { global $conf, $langs; - + $mine=0; $socid=$user->societe_id; - + $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); - + // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; @@ -1734,29 +1736,29 @@ class Task extends CommonObject if ($resql) { $task_static = new Task($this->db); - + $response = new WorkboardResponse(); $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; $response->label = $langs->trans("OpenedTasks"); if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; $response->img = img_object('',"task"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - + $task_static->projectstatus = $obj->projectstatus; $task_static->progress = $obj->progress; $task_static->fk_statut = $obj->status; $task_static->date_end = $this->db->jdate($obj->datee); - + if ($task_static->hasDelay()) { $response->nbtodolate++; } } - + return $response; } else @@ -1765,8 +1767,8 @@ class Task extends CommonObject return -1; } } - - + + /** * Charge indicateurs this->nb de tableau de bord * @@ -1775,12 +1777,12 @@ class Task extends CommonObject function load_state_board() { global $user; - + $mine=0; $socid=$user->societe_id; - + $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); - + // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; @@ -1794,11 +1796,11 @@ class Task extends CommonObject //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - + $resql=$this->db->query($sql); if ($resql) { - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b0ccd0ab097..7faca1aee80 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -47,6 +47,7 @@ $colorbacklineimpair2='255,255,255'; // line impair $colorbacklinepair1='248,248,248'; // line pair $colorbacklinepair2='248,248,248'; // line pair $colorbacklinepairhover='238,246,252'; // line pair +$colorbacklinebreak='214,218,220'; // line break $colorbackbody='255,255,255'; $colortexttitlenotab='100,60,20'; $colortexttitle='0,0,0'; @@ -100,7 +101,7 @@ $dol_no_mouse_hover=$conf->dol_no_mouse_hover; //$user->conf->THEME_ELDY_ENABLE_PERSONALIZED=0; //var_dump($user->conf->THEME_ELDY_RGB); -$useboldtitle=(isset($conf->global->THEME_ELDY_USEBOLDTITLE)?$conf->global->THEME_ELDY_USEBOLDTITLE:1); +$useboldtitle=(isset($conf->global->THEME_ELDY_USEBOLDTITLE)?$conf->global->THEME_ELDY_USEBOLDTITLE:0); $borderwith=2; // Case of option always editable @@ -109,6 +110,7 @@ if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_ if (! isset($conf->global->THEME_ELDY_VERMENU_BACK1)) $conf->global->THEME_ELDY_VERMENU_BACK1=$colorbackvmenu1; if (! isset($conf->global->THEME_ELDY_BACKTITLE1)) $conf->global->THEME_ELDY_BACKTITLE1=$colorbacktitle1; if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER=$colorbacklinepairhover; +if (! isset($conf->global->THEME_ELDY_LINEBREAK)) $conf->global->THEME_ELDY_LINEBREAK=$colorbacklinebreak; if (! isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) $conf->global->THEME_ELDY_TEXTTITLENOTAB=$colortexttitlenotab; if (! isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTLINK=$colortextlink; @@ -133,6 +135,7 @@ $colorbacklineimpair1=empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty( $colorbacklineimpair2=empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEIMPAIR2) ?$colorbacklineimpair2:$conf->global->THEME_ELDY_LINEIMPAIR2):(empty($user->conf->THEME_ELDY_LINEIMPAIR2)?$colorbacklineimpair2:$user->conf->THEME_ELDY_LINEIMPAIR2); $colorbacklinepair1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEPAIR1) ?$colorbacklinepair1:$conf->global->THEME_ELDY_LINEPAIR1) :(empty($user->conf->THEME_ELDY_LINEPAIR1)?$colorbacklinepair1:$user->conf->THEME_ELDY_LINEPAIR1); $colorbacklinepair2 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEPAIR2) ?$colorbacklinepair2:$conf->global->THEME_ELDY_LINEPAIR2) :(empty($user->conf->THEME_ELDY_LINEPAIR2)?$colorbacklinepair2:$user->conf->THEME_ELDY_LINEPAIR2); +$colorbacklinebreak =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEBREAK) ?$colorbacklinebreak:$conf->global->THEME_ELDY_LINEBREAK) :(empty($user->conf->THEME_ELDY_LINEBREAK)?$colorbacklinebreak:$user->conf->THEME_ELDY_LINEBREAK); $colorbackbody =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_BACKBODY) ?$colorbackbody:$conf->global->THEME_ELDY_BACKBODY) :(empty($user->conf->THEME_ELDY_BACKBODY)?$colorbackbody:$user->conf->THEME_ELDY_BACKBODY); $colortexttitlenotab =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TEXTTITLENOTAB)?$colortexttitlenotab:$conf->global->THEME_ELDY_TEXTTITLENOTAB) :(empty($user->conf->THEME_ELDY_TEXTTITLENOTAB)?$colortexttitlenotab:$user->conf->THEME_ELDY_TEXTTITLENOTAB); $colortexttitle =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TEXTTITLE) ?$colortexttitle:$conf->global->THEME_ELDY_TEXTTITLE) :(empty($user->conf->THEME_ELDY_TEXTTITLE)?$colortexttitle:$user->conf->THEME_ELDY_TEXTTITLE); @@ -248,7 +251,8 @@ body { trans("DIRECTION").";\n"; ?> } -th a, .thumbstat, a.tab { color: rgb() !important; font-weight: bold !important; } +.thumbstat, a.tab { color: rgb() !important; font-weight: bold !important; } +th a { font-weight: !important; } a.tab { font-weight: bold !important; } a:link, a:visited, a:hover, a:active { font-family: ; font-weight: normal; color: rgb(); text-decoration: none; } @@ -2414,6 +2418,7 @@ table.liste th, table.noborder th, table.noborder tr.liste_titre td, table.nobor } table.liste td, table.noborder td, div.noborder form div { padding: 7px 2px 7px 3px; /* t r b l */ + line-height: 1.2em; } div.liste_titre_bydiv .divsearchfield { padding: 2px 1px 2px 0px; /* t r b l */ @@ -2653,7 +2658,9 @@ td.evenodd, tr.nohoverpair td { background-color: # !important; background: # !important; } - +.trforbreak td { + background-color: # !important; +} table.dataTable td { padding: 5px 2px 5px 3px !important; @@ -2677,18 +2684,11 @@ tr.nobottom td, tr.nobottom , td.nobottom { div.liste_titre .tagtd { vertical-align: middle; } -/*div.liste_titre { - box-shadow: 2px 2px 4px #CCC; -}*/ div.liste_titre { min-height: 26px !important; /* We cant use height because it's a div and it should be higher if content is more. but min-height does not work either for div */ padding-top: 2px; padding-bottom: 2px; - -/* border-top-width: 1px; - border-top-color: #BBB; - border-top-style: solid;*/ } div.liste_titre_bydiv { border-top-width: px; @@ -2699,7 +2699,8 @@ div.liste_titre_bydiv { display: table; padding: 2px 0px 2px 0; box-shadow: none; - width: calc(100% - 1px); /* 1px more, i don't know why */ + /*width: calc(100% - 1px); 1px more, i don't know why so i remove */ + width: calc(100%); } tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index c5577469182..7cec201021e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -48,6 +48,7 @@ $colorbacklineimpair2='255,255,255'; // line impair $colorbacklinepair1='250,250,250'; // line pair $colorbacklinepair2='248,248,248'; // line pair $colorbacklinepairhover='244,244,244'; // line pair +$colorbacklinebreak='214,218,220'; $colorbackbody='248,248,248'; $colortexttitlenotab='90,90,90'; $colortexttitle='20,20,20'; @@ -107,8 +108,10 @@ $borderwith=2; // Case of option always editable if (! isset($conf->global->THEME_ELDY_BACKBODY)) $conf->global->THEME_ELDY_BACKBODY=$colorbackbody; if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1=$colorbackhmenu1; +if (! isset($conf->global->THEME_ELDY_VERMENU_BACK1)) $conf->global->THEME_ELDY_VERMENU_BACK1=$colorbackvmenu1; if (! isset($conf->global->THEME_ELDY_BACKTITLE1)) $conf->global->THEME_ELDY_BACKTITLE1=$colorbacktitle1; if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER==$colorbacklinepairhover; +if (! isset($conf->global->THEME_ELDY_LINEBREAK)) $conf->global->THEME_ELDY_LINEBREAK=$colorbacklinebreak; if (! isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) $conf->global->THEME_ELDY_TEXTTITLENOTAB=$colortexttitlenotab; if (! isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTLINK=$colortextlink; @@ -136,6 +139,7 @@ $colorbacklineimpair1=empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty( $colorbacklineimpair2=empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEIMPAIR2) ?$colorbacklineimpair2:$conf->global->THEME_ELDY_LINEIMPAIR2):(empty($user->conf->THEME_ELDY_LINEIMPAIR2)?$colorbacklineimpair2:$user->conf->THEME_ELDY_LINEIMPAIR2); $colorbacklinepair1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEPAIR1) ?$colorbacklinepair1:$conf->global->THEME_ELDY_LINEPAIR1) :(empty($user->conf->THEME_ELDY_LINEPAIR1)?$colorbacklinepair1:$user->conf->THEME_ELDY_LINEPAIR1); $colorbacklinepair2 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEPAIR2) ?$colorbacklinepair2:$conf->global->THEME_ELDY_LINEPAIR2) :(empty($user->conf->THEME_ELDY_LINEPAIR2)?$colorbacklinepair2:$user->conf->THEME_ELDY_LINEPAIR2); +$colorbacklinebreak =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_LINEBREAK) ?$colorbacklinebreak:$conf->global->THEME_ELDY_LINEBREAK) :(empty($user->conf->THEME_ELDY_LINEBREAK)?$colorbacklinebreak:$user->conf->THEME_ELDY_LINEBREAK); $colorbackbody =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_BACKBODY) ?$colorbackbody:$conf->global->THEME_ELDY_BACKBODY) :(empty($user->conf->THEME_ELDY_BACKBODY)?$colorbackbody:$user->conf->THEME_ELDY_BACKBODY); $colortexttitlenotab =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TEXTTITLENOTAB)?$colortexttitlenotab:$conf->global->THEME_ELDY_TEXTTITLENOTAB) :(empty($user->conf->THEME_ELDY_TEXTTITLENOTAB)?$colortexttitlenotab:$user->conf->THEME_ELDY_TEXTTITLENOTAB); $colortexttitle =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TEXTTITLE) ?$colortext:$conf->global->THEME_ELDY_TEXTTITLE) :(empty($user->conf->THEME_ELDY_TEXTTITLE)?$colortexttitle:$user->conf->THEME_ELDY_TEXTTITLE); @@ -2762,6 +2766,9 @@ td.evenodd, tr.nohoverpair td { background-color: # !important; background: # !important; } +.trforbreak td { + background-color: # !important; +} table.dataTable td { padding: 5px 2px 5px 3px !important; From 45b4572ad48d990fb402a9d6a54c83856c2cf3e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 13:30:28 +0200 Subject: [PATCH 083/128] Label shorter --- htdocs/compta/facture/invoicetemplate_list.php | 2 +- htdocs/langs/en_US/bills.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 201a2806188..9c1e6519db9 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -126,7 +126,7 @@ $arrayfields=array( 'recurring'=>array('label'=>$langs->trans("RecurringInvoiceTemplate"), 'checked'=>1), 'f.frequency'=>array('label'=>$langs->trans("Frequency"), 'checked'=>1), 'f.unit_frequency'=>array('label'=>$langs->trans("FrequencyUnit"), 'checked'=>1), - 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1), + 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDoneShort"), 'checked'=>1), 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100), diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index f093726ed4b..b3f9c030d3e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -337,6 +337,7 @@ NextDateToExecution=Date for next invoice generation DateLastGeneration=Date of latest generation MaxPeriodNumber=Max nb of invoice generation NbOfGenerationDone=Nb of invoice generation already done +NbOfGenerationDoneShort=Nb of generation done MaxGenerationReached=Maximum nb of generations reached InvoiceAutoValidate=Validate invoices automatically GeneratedFromRecurringInvoice=Generated from template recurring invoice %s From 2fd0ffbfec8958ac66dce877ed9028e18e616598 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 14:50:25 +0200 Subject: [PATCH 084/128] Fix tz for date creation/update --- htdocs/projet/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 5d0af329952..6eaf231a5cb 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -846,7 +846,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.datec']['checked'])) { print '
'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '
 '; - print "bid."\">".img_object($langs->trans("ShowBookmark"),"bookmark").' '.$obj->bid.""; + print "rowid."\">".img_object($langs->trans("ShowBookmark"),"bookmark").' '.$obj->rowid.""; print '"; - if ($obj->rowid) - { - // Lien interne societe - $linkintern=1; - $link="Dolibarr"; - if (! $obj->title) - { - // For compatibility with old Dolibarr bookmarks - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $societe=new Societe($db); - $societe->fetch($obj->rowid); - $obj->title=$societe->name; - } - $title=img_object($langs->trans("ShowCompany"),"company").' '.$obj->title; - } + $linkintern=1; if ($linkintern) print "url."\">"; print $title; if ($linkintern) print ""; diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 2380f13a06d..b02fb81495b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -365,6 +365,7 @@ ALTER TABLE llx_c_payment_term DROP PRIMARY KEY; ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code); +ALTER TABLE llx_projet CHANGE datec datec datetime; create table llx_c_email_senderprofile ( diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index 8ca404d3a0e..3875e64e1a7 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -21,7 +21,7 @@ create table llx_projet ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_soc integer, - datec date, -- date creation project + datec datetime, -- date creation project tms timestamp, dateo date, -- date start project datee date, -- date end project diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 8eb9ba4b421..50a2148603b 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -846,7 +846,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.datec']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; if ($user->rights->bookmark->creer) { - print "bid."&backtopage=".urlencode($_SERVER["PHP_SELF"])."\">".img_edit()." "; + print "rowid."&backtopage=".urlencode($_SERVER["PHP_SELF"])."\">".img_edit()." "; } if ($user->rights->bookmark->supprimer) { - print "bid\">".img_delete().""; + print "rowid\">".img_delete().""; } else { @@ -209,7 +209,7 @@ print "
\n"; if ($user->rights->bookmark->creer) { - print ''.$langs->trans("NewBookmark").''; + print ''.$langs->trans("NewBookmark").''; } print '
'; From 8c5cf9ea45738a81dd1cce332f32b5ffe5c3d62a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 18:04:47 +0200 Subject: [PATCH 089/128] Fix date output --- htdocs/adherents/list.php | 4 ++-- htdocs/comm/propal/list.php | 4 ++-- htdocs/commande/list.php | 4 ++-- htdocs/compta/facture/list.php | 4 ++-- htdocs/contact/list.php | 4 ++-- htdocs/contrat/list.php | 4 ++-- htdocs/contrat/services.php | 4 ++-- htdocs/expedition/list.php | 4 ++-- htdocs/fichinter/list.php | 4 ++-- htdocs/fourn/commande/list.php | 4 ++-- htdocs/fourn/facture/list.php | 4 ++-- htdocs/modulebuilder/template/myobject_list.php | 10 ++++++---- htdocs/product/list.php | 4 ++-- htdocs/product/stock/productlot_list.php | 4 ++-- htdocs/projet/tasks/list.php | 4 ++-- htdocs/societe/list.php | 4 ++-- htdocs/supplier_proposal/list.php | 4 ++-- htdocs/user/index.php | 4 ++-- 18 files changed, 40 insertions(+), 38 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 398d5b62adc..85c22a535bd 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -825,7 +825,7 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['d.datec']['checked'])) { print '
'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '
'; - print dol_print_date($obj->date_creation, 'dayhour'); + print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); print ''; - print dol_print_date($obj->date_update, 'dayhour'); + print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '
'; print ''; @@ -194,7 +194,7 @@ print "
\n"; print '
'; - +*/ // Others params From 647c4036cf105436048febbefd391702193fd845 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 13 Oct 2017 09:21:37 +0200 Subject: [PATCH 098/128] Fix simplification of code --- htdocs/core/class/html.form.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5330ce24048..8de5ba47ceb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1188,17 +1188,12 @@ class Form // On recherche les remises $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql.= " re.description, re.fk_facture_source"; - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= ", f.facnumber"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re"; - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture f ON (f.rowid = re.fk_facture_source)"; $sql.= " WHERE re.fk_soc = ".(int) $socid; $sql.= " AND re.entity = " . $conf->entity; if ($filter) $sql.= " AND ".$filter; $sql.= " ORDER BY re.description ASC"; - // Prevent sql error on the ambiguous column - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql = preg_replace('/(.*)(?!re\.)fk_facture_source(.*)/m', '\1 re.fk_facture_source \2', $sql); - dol_syslog(get_class($this)."::select_remises", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1230,7 +1225,11 @@ class Form $disabled=' disabled'; } - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->facnumber)) $desc=$desc.' - '.$obj->facnumber; + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) + { + $tmpfac = new Facture($this->db); + if ($tmpfac->fetch($obj->fk_facture_source) > 0) $desc=$desc.' - '.$tmpfac->ref; + } print ''; $i++; From 2b55fb81b9fdf9e357e63ee331c1b8994d8a8f9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 10:35:21 +0200 Subject: [PATCH 099/128] Standardize substition keys. --- ChangeLog | 8 ++++--- htdocs/admin/mails.php | 2 +- htdocs/admin/mails_emailing.php | 2 +- htdocs/comm/mailing/card.php | 3 ++- htdocs/core/class/html.formmail.class.php | 8 +++---- htdocs/core/lib/functions.lib.php | 4 +++- htdocs/langs/en_US/other.lang | 26 +++++++++++------------ scripts/emailings/mailing-send.php | 3 ++- 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40b4b40eb4a..9b5eef7aca5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,14 +13,16 @@ NEW: complete_head_from_modules() in ldap_prepare_head() WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* The methode "cloture" on contact were renamed into "closeAll". +* The methode "cloture" on contract were renamed into "closeAll". * The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__, __PROPALREF__, ...) +* The substition key __SIGNATURE__ was renamed into __USER_SIGNATURE__ to standardize naming conventions. +* Substitution keys with syntax %XXX% were renamed into __XXX__ to match others. * Some REST API to access the dictionary (country, town, ...) were moved into a common API. * Page bank/index.php and bank/bankentries.php were renamed into bank/list.php and bank/bankentries_list.php to follow page naming conventions (so default filter/sort order features can also work). -* The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed ORDER_SUPPLIER_STATUS_ORDERED -* The trigger ORDER_SUPPLIER_STATUS_RECEIVED_ALL was renamed ORDER_SUPPLIER_STATUS_RECEIVED_COMPLETELY +* The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed into ORDER_SUPPLIER_STATUS_ORDERED +* The trigger ORDER_SUPPLIER_STATUS_RECEIVED_ALL was renamed into ORDER_SUPPLIER_STATUS_RECEIVED_COMPLETELY ***** ChangeLog for 6.0.2 compared to 6.0.1 ***** diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 961491cce2e..42fbd3903c0 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -50,7 +50,7 @@ $substitutionarrayfortest=array( '__ID__' => 'RecipientIdRecord', //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails '__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'':'', -'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), // Done into actions_sendmails +'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), // Done into actions_sendmails '__LOGIN__' => 'RecipientLogin', '__LASTNAME__' => 'RecipientLastname', '__FIRSTNAME__' => 'RecipientFirstname', diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index b98661edab5..fc4b41bd6ab 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -51,7 +51,7 @@ $substitutionarrayfortest=array( '__EMAIL__' => 'TESTEMail', '__LASTNAME__' => 'TESTLastname', '__FIRSTNAME__' => 'TESTFirstname', -'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), +'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), //'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet ); complete_substitutions_array($substitutionarrayfortest, $langs); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 539f8bede92..c8338d22379 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -216,7 +216,8 @@ if (empty($reshook)) $substitutionarray['__OTHER3__'] = $other3; $substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER5__'] = $other5; - $substitutionarray['__SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility $substitutionarray['__CHECK_READ__'] = ''; $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3ad460a8688..93d2244a6ec 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -858,9 +858,9 @@ class FormMail extends Form $defaultmessage=str_replace('\n',"\n",$defaultmessage); // Deal with format differences between message and signature (text / HTML) - if(dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) { - $this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']); - } else if(!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) { + if(dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) { + $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']); + } else if(!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { $defaultmessage = dol_nl2br($defaultmessage); } @@ -1213,7 +1213,7 @@ class FormMail extends Form $tmparray['__OTHER3__'] = 'Other3'; $tmparray['__OTHER4__'] = 'Other4'; $tmparray['__OTHER5__'] = 'Other5'; - $tmparray['__SIGNATURE__'] = 'TagSignature'; + $tmparray['__USER_SIGNATURE__'] = 'TagSignature'; $tmparray['__CHECK_READ__'] = 'TagCheckMail'; $tmparray['__UNSUBSCRIBE__'] = 'TagUnsubscribe'; //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c3c7913e2d4..6aafc6c2bbd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5511,7 +5511,9 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) // Make substitition for array $substitutionarray foreach ($substitutionarray as $key => $value) { - if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; + if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection + if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection + $text=str_replace("$key","$value",$text); // We must keep the " to work when value is 123.5 for example } diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index bbc8f34a92e..e1270533ae2 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -76,19 +76,19 @@ MaxSize=Maximum size AttachANewFile=Attach a new file/document LinkedObject=Linked object NbOfActiveNotifications=Number of notifications (nb of recipient emails) -PredefinedMailTest=This is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__SIGNATURE__ -PredefinedMailTestHtml=This is a test mail (the word test must be in bold).
The two lines are separated by a carriage return.

__SIGNATURE__ -PredefinedMailContentSendInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendInvoiceReminder=__CONTACTCIVNAME__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendProposal=__CONTACTCIVNAME__\n\nYou will find here the commercial proposal __PREF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendSupplierProposal=__CONTACTCIVNAME__\n\nYou will find here the price request __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendOrder=__CONTACTCIVNAME__\n\nYou will find here the order __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendSupplierOrder=__CONTACTCIVNAME__\n\nYou will find here our order __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendSupplierInvoice=__CONTACTCIVNAME__\n\nYou will find here the invoice __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendShipping=__CONTACTCIVNAME__\n\nYou will find here the shipping __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentSendFichInter=__CONTACTCIVNAME__\n\nYou will find here the intervention __REF__\n\n__PERSONALIZED__Sincerely\n\n__SIGNATURE__ -PredefinedMailContentThirdparty=\n\n__SIGNATURE__ -PredefinedMailContentUser=\n\n__SIGNATURE__ +PredefinedMailTest=__(Hello)__\nThis is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__USER_SIGNATURE__ +PredefinedMailTestHtml=__(Hello)__\nThis is a test mail (the word test must be in bold).
The two lines are separated by a carriage return.

__USER_SIGNATURE__ +PredefinedMailContentSendInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendProposal=__(Hello)__\n\nYou will find here the commercial proposal __PREF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendSupplierProposal=__(Hello)__\n\nYou will find here the price request __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendOrder=__(Hello)__\n\nYou will find here the order __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendSupplierOrder=__(Hello)__\n\nYou will find here our order __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendSupplierInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendShipping=__(Hello)__\n\nYou will find here the shipping __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendFichInter=__(Hello)__\n\nYou will find here the intervention __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentThirdparty=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentUser=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available. ChooseYourDemoProfil=Choose the demo profile that best suits your needs... ChooseYourDemoProfilMore=...or build your own profile
(manual module selection) diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 836f435890b..7daf0dace88 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -178,7 +178,8 @@ if ($resql) $substitutionarray['__OTHER3__'] = $other3; $substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER5__'] = $other5; - $substitutionarray['__SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) + $substitutionarray['__SIGNATURE__'] = $signature; // For backward compatibility $substitutionarray['__CHECK_READ__'] = ''; $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; From ec54621b6224e4d252ca107161626860f17fb55a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 11:08:30 +0200 Subject: [PATCH 100/128] FIX Tooltip using dialog are kept into visible screen --- htdocs/langs/en_US/mails.lang | 2 +- htdocs/main.inc.php | 5 +++-- htdocs/theme/eldy/style.css.php | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 0caae25c1d5..ccf52302e9a 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -115,7 +115,7 @@ DeliveryReceipt=Delivery Ack. YouCanUseCommaSeparatorForSeveralRecipients=You can use the comma separator to specify several recipients. TagCheckMail=Track mail opening TagUnsubscribe=Unsubscribe link -TagSignature=Signature sending user +TagSignature=Signature of sending user EMailRecipient=Recipient EMail TagMailtoEmail=Recipient EMail (including html "mailto:" link) NoEmailSentBadSenderOrRecipientEmail=No email sent. Bad sender or recipient email. Verify user profile. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6aadcb7cd0a..205f9677d82 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1971,13 +1971,14 @@ if (! function_exists("llxFooter")) print ''; - - -// Part to create -if ($action == 'create') -{ - print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("EmailSenderProfile"))); - - print '
'; - print ''; - print ''; - print ''; - - dol_fiche_head(array(), ''); - - print ''."\n"; - foreach($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; - print ''; - print ''; - print $langs->trans($val['label']); - print ''; - print ''; - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; - - print '
'; - $defaultcss='minwidth100'; - if ($val['type'] == 'text') - { - print ''; - } - elseif (is_array($val['arrayofkeyval'])) - { - print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')); - } - else - { - $cssforinput = empty($val['css'])?$defaultcss:$val['css']; - print ''; - } - print '
'."\n"; - - dol_fiche_end(); - - print '
'; - print ''; - print '  '; - print ''; // Cancel for create doe not post form - print '
'; - - print '
'; -} - -// Part to edit record -if (($id || $ref) && $action == 'edit') -{ - print load_fiche_titre($langs->trans("EmailSenderProfile")); - - print '
'; - print ''; - print ''; - print ''; - - dol_fiche_head(); - - print ''."\n"; - foreach($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; - - print ''.$langs->trans($val['label']).''; - print ''; - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; - - print '
'; - $defaultcss='minwidth100'; - if ($val['type'] == 'text') - { - print ''; - } - elseif (is_array($val['arrayofkeyval'])) - { - print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key); - } - else - { - $cssforinput = empty($val['css'])?$defaultcss:$val['css']; - print ''; - } - print '
'; - - dol_fiche_end(); - - print '
'; - print '   '; - print '
'; - - print '
'; -} - -// Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) -{ - $res = $object->fetch_optionals($object->id, $extralabels); - - $head = emailsenderprofilePrepareHead($object); - dol_fiche_head($head, 'card', $langs->trans("EmailSenderProfile"), -1, 'emailsenderprofile@monmodule'); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteEmailSenderProfile'), $langs->trans('ConfirmDeleteEmailSenderProfile'), 'confirm_delete', '', 0, 1); - } - - // Confirmation of action xxxx - if ($action == 'xxx') - { - $formquestion=array(); - /* - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); - }*/ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - - if (! $formconfirm) { - $parameters = array('lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - - // Object card - // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; - - $morehtmlref='
'; - /* - // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->monmodule->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->monmodule->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->monmodule->creer) - { - if ($action != 'classify') - { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } - } - */ - $morehtmlref.='
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - print '
'; - print ''."\n"; - - foreach($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; - - print ''.$langs->trans($val['label']).''; - print ''; - print ''; - - //if ($key == 'targetsrcfile3') break; // key used for break on second column - } - - print '
'; - print dol_escape_htmltag($object->$key, 1, 1); - print '
'; - print '
'; - print '
'; - print '
'; - print '
'; - print ''; - - $alreadyoutput = 1; - foreach($object->fields as $key => $val) - { - if ($alreadyoutput) - { - //if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column - continue; - } - - if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue; - - print ''.$langs->trans($val['label']).''; - print ''; - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print dol_escape_htmltag($object->$key, 1, 1); - print '
'; - print '
'; - print '
'; - print '
'; - - print '

'; - - dol_fiche_end(); - - - // Buttons for actions - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters=array(); - $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - if (empty($reshook)) - { - // Send - print ''."\n"; - - if ($user->rights->monmodule->write) - { - print ''."\n"; - } - - /* - if ($user->rights->sellyoursaas->create) - { - if ($object->status == 1) - { - print ''."\n"; - } - else - { - print ''."\n"; - } - } - */ - - if ($user->rights->monmodule->delete) - { - print ''."\n"; - } - } - print '
'."\n"; - } - - - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - - if ($action != 'presend') - { - print '
'; - print ''; // ancre - // Documents - $comref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->monmodule->dir_output . '/' . $comref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->monmodule->creer; - $delallowed = $user->rights->monmodule->supprimer; - print $formfile->showdocuments('monmodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - - - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('emailsenderprofile')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - - - print '
'; - - $MAXEVENT = 10; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'emailsenderprofile', $socid, 1, '', $MAXEVENT); - - print '
'; - } - - // Presend form - $modelmail='emailsenderprofile'; - $defaulttopic='Information'; - $diroutput = $conf->monmodule->dir_output; - $trackid = 'emailsenderprofile'.$object->id; - - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; -} - - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 42fbd3903c0..ac06a302947 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -124,27 +124,7 @@ llxHeader('',$langs->trans("Setup"),$wikihelp); print load_fiche_titre($langs->trans("EMailsSetup"),'','title_setup'); - -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/mails.php"; -$head[$h][1] = $langs->trans("OutGoingEmailSetup"); -$head[$h][2] = 'common'; -$h++; - -if ($conf->mailing->enabled) -{ - $head[$h][0] = DOL_URL_ROOT."/admin/mails_emailing.php"; - $head[$h][1] = $langs->trans("OutGoingEmailSetupForEmailing"); - $head[$h][2] = 'common_emailing'; - $h++; -} - -$head[$h][0] = DOL_URL_ROOT."/admin/mails_templates.php"; -$head[$h][1] = $langs->trans("DictionaryEMailTemplates"); -$head[$h][2] = 'templates'; -$h++; - +$head = email_admin_prepare_head(); // List of sending methods $listofmethods=array(); diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index fc4b41bd6ab..1202e9817d3 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -114,27 +114,7 @@ llxHeader('',$langs->trans("Setup"),$wikihelp); print load_fiche_titre($langs->trans("EMailsSetup"),'','title_setup'); - -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/mails.php"; -$head[$h][1] = $langs->trans("OutGoingEmailSetup"); -$head[$h][2] = 'common'; -$h++; - -if ($conf->mailing->enabled) -{ - $head[$h][0] = DOL_URL_ROOT."/admin/mails_emailing.php"; - $head[$h][1] = $langs->trans("OutGoingEmailSetupForEmailing"); - $head[$h][2] = 'common_emailing'; - $h++; -} - -$head[$h][0] = DOL_URL_ROOT."/admin/mails_templates.php"; -$head[$h][1] = $langs->trans("DictionaryEMailTemplates"); -$head[$h][2] = 'templates'; -$h++; - +$head = email_admin_prepare_head(); // List of sending methods $listofmethods=array(); diff --git a/htdocs/admin/emailsenderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php similarity index 91% rename from htdocs/admin/emailsenderprofile_list.php rename to htdocs/admin/mails_senderprofile_list.php index dd2372443b3..91f0a3a8037 100644 --- a/htdocs/admin/emailsenderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -1,6 +1,5 @@ - * 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 @@ -17,9 +16,9 @@ */ /** - * \file emailsenderprofile_list.php - * \ingroup monmodule - * \brief List page for emailsenderprofile + * \file htdocs/admin/mails_senderprofile_list.php + * \ingroup core + * \brief Page to adminsiter email sender profiles */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); @@ -37,30 +36,17 @@ //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -// Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"); -// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php"); -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"); -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -dol_include_once('/monmodule/class/emailsenderprofile.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; // Load traductions files requiredby by page -$langs->loadLangs(array("monmodule@monmodule","other")); +$langs->loadLangs(array("errors","admin","mails","languages")); -$action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm','alpha'); // Result of a confirmation @@ -138,9 +124,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab /* - * ACTIONS - * - * Put here all code to do according to value of "$action" parameter + * Actions */ if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } @@ -174,18 +158,16 @@ if (empty($reshook)) // Mass actions $objectclass='EmailSenderProfile'; $objectlabel='EmailSenderProfile'; - $permtoread = $user->rights->monmodule->read; - $permtodelete = $user->rights->monmodule->delete; - $uploaddir = $conf->monmodule->dir_output; + $permtoread = $user->admin; + $permtodelete = $user->admin; + $uploaddir = $conf->admin->dir_output.'/senderprofiles'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } /* - * VIEW - * - * Put here all code to build page + * View */ $form=new Form($db); @@ -197,6 +179,18 @@ $help_url=''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailSenderProfiles")); +llxHeader(); + +$titre=$langs->trans("EMailsSetup"); +$linkback=''; +$titlepicto='title_setup'; + +print load_fiche_titre($titre,$linkback,$titlepicto); + +$head = email_admin_prepare_head(); + +dol_fiche_head($head, 'senderprofiles', '', -1); + // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; @@ -211,7 +205,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."emailsenderprofile as t"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_email_senderprofile as t"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."emailsenderprofile_extrafields as ef on (t.rowid = ef.fk_object)"; $sql.= " WHERE t.entity IN (".getEntity('emailsenderprofile').")"; foreach($search as $key => $val) @@ -285,11 +279,6 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && } -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url); - // Example : Adding jquery code print ''; - } + } - $out.= "\n"; + $out.= "\n"; - return $out; - } - } + return $out; + } + } @@ -992,22 +992,22 @@ class FormMail extends Form { $defaultmessage=''; if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($type_template=='supplier_proposal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } - elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } - elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } + elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($type_template=='supplier_proposal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } + elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } + elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } - $ret['label']='default'; - $ret['lang']=$outputlangs->defaultlang; - $ret['topic']=''; - $ret['joinfiles']=1; - $ret['content']=$defaultmessage; + $ret['label']='default'; + $ret['lang']=$outputlangs->defaultlang; + $ret['topic']=''; + $ret['joinfiles']=1; + $ret['content']=$defaultmessage; $ret['content_lines']=''; } @@ -1130,41 +1130,41 @@ class FormMail extends Form $this->substit=$tmparray; - // Fill substit_lines with each object lines content - if (is_array($object->lines)) - { - foreach ($object->lines as $line) - { - $substit_line = array( - '__PRODUCT_REF__' => isset($line->product_ref) ? $line->product_ref : '', - '__PRODUCT_LABEL__' => isset($line->product_label) ? $line->product_label : '', - '__PRODUCT_DESCRIPTION__' => isset($line->product_desc) ? $line->product_desc : '', - '__LABEL__' => isset($line->label) ? $line->label : '', - '__DESCRIPTION__' => isset($line->desc) ? $line->desc : '', - '__DATE_START_YMD__' => dol_print_date($line->date_start, 'day', 0, $outputlangs), - '__DATE_END_YMD__' => dol_print_date($line->date_end, 'day', 0, $outputlangs), - '__QUANTITY__' => $line->qty, - '__SUBPRICE__' => price($line->subprice), - '__AMOUNT__' => price($line->total_ttc), - '__AMOUNT_EXCL_TAX__' => price($line->total_ht), - //'__PRODUCT_EXTRAFIELD_FIELD__' Done dinamically just after - ); + // Fill substit_lines with each object lines content + if (is_array($object->lines)) + { + foreach ($object->lines as $line) + { + $substit_line = array( + '__PRODUCT_REF__' => isset($line->product_ref) ? $line->product_ref : '', + '__PRODUCT_LABEL__' => isset($line->product_label) ? $line->product_label : '', + '__PRODUCT_DESCRIPTION__' => isset($line->product_desc) ? $line->product_desc : '', + '__LABEL__' => isset($line->label) ? $line->label : '', + '__DESCRIPTION__' => isset($line->desc) ? $line->desc : '', + '__DATE_START_YMD__' => dol_print_date($line->date_start, 'day', 0, $outputlangs), + '__DATE_END_YMD__' => dol_print_date($line->date_end, 'day', 0, $outputlangs), + '__QUANTITY__' => $line->qty, + '__SUBPRICE__' => price($line->subprice), + '__AMOUNT__' => price($line->total_ttc), + '__AMOUNT_EXCL_TAX__' => price($line->total_ht), + //'__PRODUCT_EXTRAFIELD_FIELD__' Done dinamically just after + ); - // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__ - if (!empty($line->fk_product)) - { - $extrafields = new ExtraFields($this->db); - $extralabels = $extrafields->fetch_name_optionals_label('product', true); - $product = new Product($this->db); - $product->fetch($line->fk_product, '', '', 1); - $product->fetch_optionals($product->id, $extralabels); - foreach ($extrafields->attribute_label as $key => $label) { - $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; - } - } - $this->substit_lines[] = $substit_line; - } - } + // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__ + if (!empty($line->fk_product)) + { + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label('product', true); + $product = new Product($this->db); + $product->fetch($line->fk_product, '', '', 1); + $product->fetch_optionals($product->id, $extralabels); + foreach ($extrafields->attribute_label as $key => $label) { + $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; + } + } + $this->substit_lines[] = $substit_line; + } + } } /** @@ -1188,11 +1188,11 @@ class FormMail extends Form if ($mode == 'formwithlines') { - $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function + $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function } if ($mode == 'formforlines') { - $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function + $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6aafc6c2bbd..f56cd2f523d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -275,17 +275,17 @@ function GETPOSTISSET($paramname) */ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=NULL) { - global $mysoc,$user,$conf; + global $mysoc,$user,$conf; - if (empty($paramname)) return 'BadFirstParameterForGETPOST'; - if (empty($check)) - { - dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING); - // Enable this line to know who call the GETPOST with '' $check parameter. - //var_dump(debug_backtrace()[0]); - } + if (empty($paramname)) return 'BadFirstParameterForGETPOST'; + if (empty($check)) + { + dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING); + // Enable this line to know who call the GETPOST with '' $check parameter. + //var_dump(debug_backtrace()[0]); + } - if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); + if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:''; elseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:''); @@ -295,38 +295,38 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N if (empty($method) || $method == 3 || $method == 4) { - $relativepathstring = $_SERVER["PHP_SELF"]; - // Clean $relativepathstring - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = $_SERVER["PHP_SELF"]; + // Clean $relativepathstring + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); //var_dump($relativepathstring); //var_dump($user->default_values); - // Code for search criteria persistence. - // Retrieve values if restore_lastsearch_values is set and there is saved values - if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here - { - $tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); - if (is_array($tmp)) - { - foreach($tmp as $key => $val) - { - if ($key == $paramname) - { - $out=$val; - break; - } - } - } - } - // Else, retreive default values if we are not doing a sort - elseif (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set - { - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - { - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' - { + // Code for search criteria persistence. + // Retrieve values if restore_lastsearch_values is set and there is saved values + if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here + { + $tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); + if (is_array($tmp)) + { + foreach($tmp as $key => $val) + { + if ($key == $paramname) + { + $out=$val; + break; + } + } + } + } + // Else, retreive default values if we are not doing a sort + elseif (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set + { + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + { if (isset($user->default_values[$relativepathstring]['createform'])) { foreach($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) @@ -348,107 +348,107 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N if ($qualified) { - //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); - if (isset($user->default_values[$relativepathstring]['createform'][$defkey][$paramname])) - { - $out = $user->default_values[$relativepathstring]['createform'][$defkey][$paramname]; - break; - } + //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); + if (isset($user->default_values[$relativepathstring]['createform'][$defkey][$paramname])) + { + $out = $user->default_values[$relativepathstring]['createform'][$defkey][$paramname]; + break; + } } } } } - } - // Management of default search_filters and sort order - //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) - { - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' - { - //var_dump($user->default_values[$relativepathstring]); - if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ? - { - if (isset($user->default_values[$relativepathstring]['sortorder'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] - { - foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) - { - $qualified = 0; - if ($defkey != '_noquery_') - { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) - { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; - } - if (! $foundintru) $qualified=1; - //var_dump($defkey.'-'.$qualified); - } - else $qualified = 1; + } + // Management of default search_filters and sort order + //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' + { + //var_dump($user->default_values[$relativepathstring]); + if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ? + { + if (isset($user->default_values[$relativepathstring]['sortorder'])) // Even if paramname is sortfield, data are stored into ['sortorder...'] + { + foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) + { + $qualified = 0; + if ($defkey != '_noquery_') + { + $tmpqueryarraytohave=explode('&', $defkey); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru=0; + foreach($tmpqueryarraytohave as $tmpquerytohave) + { + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + } + if (! $foundintru) $qualified=1; + //var_dump($defkey.'-'.$qualified); + } + else $qualified = 1; - if ($qualified) - { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , - foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) - { - if ($out) $out.=', '; - if ($paramname == 'sortfield') - { - $out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace); - } - if ($paramname == 'sortorder') - { - $out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace); - } - } - //break; // No break for sortfield and sortorder so we can cumulate fields (is it realy usefull ?) - } - } + if ($qualified) + { + $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) + { + if ($out) $out.=', '; + if ($paramname == 'sortfield') + { + $out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace); + } + if ($paramname == 'sortorder') + { + $out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace); + } + } + //break; // No break for sortfield and sortorder so we can cumulate fields (is it realy usefull ?) + } + } } - } - elseif (isset($user->default_values[$relativepathstring]['filters'])) - { - foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) - { - $qualified = 0; - if ($defkey != '_noquery_') - { - $tmpqueryarraytohave=explode('&', $defkey); - $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); - $foundintru=0; - foreach($tmpqueryarraytohave as $tmpquerytohave) - { - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; - } - if (! $foundintru) $qualified=1; - //var_dump($defkey.'-'.$qualified); - } - else $qualified = 1; + } + elseif (isset($user->default_values[$relativepathstring]['filters'])) + { + foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) + { + $qualified = 0; + if ($defkey != '_noquery_') + { + $tmpqueryarraytohave=explode('&', $defkey); + $tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); + $foundintru=0; + foreach($tmpqueryarraytohave as $tmpquerytohave) + { + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; + } + if (! $foundintru) $qualified=1; + //var_dump($defkey.'-'.$qualified); + } + else $qualified = 1; if ($qualified) { - if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) - { - // We made a search from quick search menu, do we still use default filter ? - if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) - { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , - $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); - } - } - else - { - $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , - $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); - } - break; + if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) + { + // We made a search from quick search menu, do we still use default filter ? + if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) + { + $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); + } + } + else + { + $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , + $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); + } + break; } - } - } - } - } - } + } + } + } + } + } } @@ -457,110 +457,110 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text. if (! is_array($out) && empty($_POST[$paramname])) { - $maxloop=20; $loopnb=0; // Protection against infinite loop - while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. - { - $loopnb++; $newout = ''; + $maxloop=20; $loopnb=0; // Protection against infinite loop + while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. + { + $loopnb++; $newout = ''; - if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; } - elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } - elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } - elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } - elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } - elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } - elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } - elseif ($reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') - { - $newout = $mysoc->country_id; - } - elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID') - { - $newout = $user->id; - } - elseif ($reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID') - { - $newout = $user->fk_user; - } - elseif ($reg[1] == 'ENTITYID') - { - $newout = $conf->entity; - } - else $newout = ''; // Key not found, we replace with empty string - //var_dump('__'.$reg[1].'__ -> '.$newout); - $out = preg_replace('/__'.preg_quote($reg[1],'/').'__/', $newout, $out); - } + if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; } + elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } + elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } + elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } + elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } + elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } + elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } + elseif ($reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') + { + $newout = $mysoc->country_id; + } + elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID') + { + $newout = $user->id; + } + elseif ($reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID') + { + $newout = $user->fk_user; + } + elseif ($reg[1] == 'ENTITYID') + { + $newout = $conf->entity; + } + else $newout = ''; // Key not found, we replace with empty string + //var_dump('__'.$reg[1].'__ -> '.$newout); + $out = preg_replace('/__'.preg_quote($reg[1],'/').'__/', $newout, $out); + } } - // Check is done after replacement - switch ($check) - { - case 'none': - break; - case 'int': // Check param is a numeric value (integer but also float or hexadecimal) - if (! is_numeric($out)) { $out=''; } - break; - case 'intcomma': - if (preg_match('/[^0-9,]+/i',$out)) $out=''; - break; - case 'alpha': - $out=trim($out); - // '"' is dangerous because param in url can close the href= or src= and add javascript functions. - // '../' is dangerous because it allows dir transversals - if (preg_match('/"/',$out)) $out=''; - else if (preg_match('/\.\.\//',$out)) $out=''; - break; - case 'san_alpha': - $out=filter_var($out,FILTER_SANITIZE_STRING); - break; - case 'aZ': - $out=trim($out); - if (preg_match('/[^a-z]+/i',$out)) $out=''; - break; - case 'aZ09': - $out=trim($out); - if (preg_match('/[^a-z0-9_\-\.]+/i',$out)) $out=''; - break; - case 'array': - if (! is_array($out) || empty($out)) $out=array(); - break; + // Check is done after replacement + switch ($check) + { + case 'none': + break; + case 'int': // Check param is a numeric value (integer but also float or hexadecimal) + if (! is_numeric($out)) { $out=''; } + break; + case 'intcomma': + if (preg_match('/[^0-9,]+/i',$out)) $out=''; + break; + case 'alpha': + $out=trim($out); + // '"' is dangerous because param in url can close the href= or src= and add javascript functions. + // '../' is dangerous because it allows dir transversals + if (preg_match('/"/',$out)) $out=''; + else if (preg_match('/\.\.\//',$out)) $out=''; + break; + case 'san_alpha': + $out=filter_var($out,FILTER_SANITIZE_STRING); + break; + case 'aZ': + $out=trim($out); + if (preg_match('/[^a-z]+/i',$out)) $out=''; + break; + case 'aZ09': + $out=trim($out); + if (preg_match('/[^a-z0-9_\-\.]+/i',$out)) $out=''; + break; + case 'array': + if (! is_array($out) || empty($out)) $out=array(); + break; case 'nohtml': - $out=dol_string_nohtmltag($out); + $out=dol_string_nohtmltag($out); break; case 'alphanohtml': // Recommended for search params - $out=trim($out); - // '"' is dangerous because param in url can close the href= or src= and add javascript functions. - // '../' is dangerous because it allows dir transversals - if (preg_match('/"/',$out)) $out=''; - else if (preg_match('/\.\.\//',$out)) $out=''; - $out=dol_string_nohtmltag($out); + $out=trim($out); + // '"' is dangerous because param in url can close the href= or src= and add javascript functions. + // '../' is dangerous because it allows dir transversals + if (preg_match('/"/',$out)) $out=''; + else if (preg_match('/\.\.\//',$out)) $out=''; + $out=dol_string_nohtmltag($out); break; case 'custom': - if (empty($filter)) return 'BadFourthParameterForGETPOST'; - $out=filter_var($out, $filter, $options); - break; - } + if (empty($filter)) return 'BadFourthParameterForGETPOST'; + $out=filter_var($out, $filter, $options); + break; + } - // Code for search criteria persistence. + // Code for search criteria persistence. // Save data into session if key start with 'search_' or is 'smonth', 'syear', 'month', 'year' if (empty($method) || $method == 3 || $method == 4) { - //if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder', 'sortfield", 'smonth', 'syear', 'month', 'year'))) - if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder','sortfield'))) - { - //var_dump($paramname.' - '.$out.' '.$user->default_values[$relativepathstring]['filters'][$paramname]); + //if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder', 'sortfield", 'smonth', 'syear', 'month', 'year'))) + if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder','sortfield'))) + { + //var_dump($paramname.' - '.$out.' '.$user->default_values[$relativepathstring]['filters'][$paramname]); - // We save search key only if: - // - not empty, or - // - if value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not). + // We save search key only if: + // - not empty, or + // - if value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not). - //if (! empty($out) || ! empty($user->default_values[$relativepathstring]['filters'][$paramname])) - if (! empty($out)) - { - $user->lastsearch_values_tmp[$relativepathstring][$paramname]=$out; - } - } + //if (! empty($out) || ! empty($user->default_values[$relativepathstring]['filters'][$paramname])) + if (! empty($out)) + { + $user->lastsearch_values_tmp[$relativepathstring][$paramname]=$out; + } + } } return $out; @@ -577,14 +577,14 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N */ function dol_getprefix($mode='') { - global $conf; + global $conf; - // If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email - if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) - { - if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; - else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"]; - } + // If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email + if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) + { + if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; + else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"]; + } if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) { @@ -670,18 +670,18 @@ function dol_buildpath($path, $type=0, $returnemptyifnotfound=0) { if ($key == 'main') { - if ($type == 3) - { - global $dolibarr_main_url_root; + if ($type == 3) + { + global $dolibarr_main_url_root; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).'/'.$path; // Test on start with http is for old conf syntax - } - continue; + $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).'/'.$path; // Test on start with http is for old conf syntax + } + continue; } preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i',$path,$regs); // Take part before '?' if (! empty($regs[1])) @@ -695,18 +695,18 @@ function dol_buildpath($path, $type=0, $returnemptyifnotfound=0) } if ($type == 2) { - $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; + $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path; } if ($type == 3) { - global $dolibarr_main_url_root; + global $dolibarr_main_url_root; - // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax + $res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax } break; } @@ -789,8 +789,8 @@ function dol_sanitizeFileName($str,$newstr='_',$unaccent=1) */ function dol_sanitizePathName($str,$newstr='_',$unaccent=1) { - $filesystem_forbidden_chars = array('<','>','?','*','|','"','°'); - return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); + $filesystem_forbidden_chars = array('<','>','?','*','|','"','°'); + return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars); } /** @@ -974,54 +974,54 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' if (! empty($message)) { - // Test log level - $logLevels = array(LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG); - if (!in_array($level, $logLevels, true)) - { - throw new Exception('Incorrect log level'); - } - if ($level > $conf->global->SYSLOG_LEVEL) return; + // Test log level + $logLevels = array(LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG); + if (!in_array($level, $logLevels, true)) + { + throw new Exception('Incorrect log level'); + } + if ($level > $conf->global->SYSLOG_LEVEL) return; - // If adding log inside HTML page is required - if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility - { - $conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; - } + // If adding log inside HTML page is required + if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility + { + $conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; + } - //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output - // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments - if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"])) - { - print "\n\n\n"; - } + //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output + // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments + if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"])) + { + print "\n\n\n"; + } - $data = array( - 'message' => $message, - 'script' => (isset($_SERVER['PHP_SELF'])? basename($_SERVER['PHP_SELF'],'.php') : false), - 'level' => $level, - 'user' => ((is_object($user) && $user->id) ? $user->login : false), - 'ip' => false - ); + $data = array( + 'message' => $message, + 'script' => (isset($_SERVER['PHP_SELF'])? basename($_SERVER['PHP_SELF'],'.php') : false), + 'level' => $level, + 'user' => ((is_object($user) && $user->id) ? $user->login : false), + 'ip' => false + ); - // This is when server run behind a reverse proxy - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"])?'':'->'.$_SERVER['REMOTE_ADDR']); - // This is when server run normally on a server - else if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR']; - // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) - else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR']; - // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). - else if (! empty($_SERVER['COMPUTERNAME'])) $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']); - // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). - else if (! empty($_SERVER['LOGNAME'])) $data['ip'] = '???@'.$_SERVER['LOGNAME']; - // Loop on each log handler and send output - foreach ($conf->loghandlers as $loghandlerinstance) - { - if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) continue; - $loghandlerinstance->export($data,$suffixinfilename); - } - unset($data); + // This is when server run behind a reverse proxy + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"])?'':'->'.$_SERVER['REMOTE_ADDR']); + // This is when server run normally on a server + else if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR']; + // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) + else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR']; + // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). + else if (! empty($_SERVER['COMPUTERNAME'])) $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']); + // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). + else if (! empty($_SERVER['LOGNAME'])) $data['ip'] = '???@'.$_SERVER['LOGNAME']; + // Loop on each log handler and send output + foreach ($conf->loghandlers as $loghandlerinstance) + { + if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) continue; + $loghandlerinstance->export($data,$suffixinfilename); + } + unset($data); } if (! empty($ident)) @@ -1099,7 +1099,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi $limittoshow=(empty($conf->global->MAIN_MAXTABS_IN_CARD)?99:$conf->global->MAIN_MAXTABS_IN_CARD); $displaytab=0; $nbintab=0; - $popuptab=0; $outmore=''; + $popuptab=0; $outmore=''; for ($i = 0 ; $i <= $maxkey ; $i++) { if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) @@ -1150,13 +1150,13 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi } else { - // The popup with the other tabs + // The popup with the other tabs if (! $popuptab) { - $popuptab=1; - $outmore.='
'; + $popuptab=1; + $outmore.='
'; } - $outmore.='
'; + $outmore.='
'; if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) @@ -1266,26 +1266,26 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (class_exists("Imagick")) { - if ($object->element == 'propal') $modulepart='propal'; + if ($object->element == 'propal') $modulepart='propal'; if ($object->element == 'commande') $modulepart='commande'; if ($object->element == 'facture') $modulepart='facture'; if ($object->element == 'fichinter') $modulepart='ficheinter'; if ($object->element == 'contrat') $modulepart='contract'; - if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal'; + if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal'; if ($object->element == 'order_supplier') $modulepart='supplier_order'; - if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice'; + if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice'; if ($object->element == 'expensereport') $modulepart='expensereport'; } if ($object->element == 'product') { - $width=80; $cssclass='photoref'; - $showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]); - $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); + $width=80; $cssclass='photoref'; + $showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]); + $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); if ($conf->browser->phone) $maxvisiblephotos=1; if ($showimage) $morehtmlleft.='
'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
'; - else - { + else + { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { $nophoto=''; $morehtmlleft.='
'; @@ -1294,153 +1294,153 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $nophoto='/public/theme/common/nophoto.png'; $morehtmlleft.='
No photo
'; //} - } + } } else { if ($showimage) - { - if ($modulepart != 'unknown') - { - $phototoshow=''; - // Check if a preview file is available - if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) - { - $objectref = dol_sanitizeFileName($object->ref); - $dir_output = $conf->$modulepart->dir_output . "/"; - if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) - { - $subdir = get_exdir($object->id, 2, 0, 0, $object, $modulepart).$objectref; - } - else - { - $subdir = get_exdir($object->id, 0, 0, 0, $object, $modulepart).$objectref; - } - $filepath = $dir_output . $subdir . "/"; - $file = $filepath . $objectref . ".pdf"; - $relativepath = $subdir.'/'.$objectref.'.pdf'; + { + if ($modulepart != 'unknown') + { + $phototoshow=''; + // Check if a preview file is available + if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) + { + $objectref = dol_sanitizeFileName($object->ref); + $dir_output = $conf->$modulepart->dir_output . "/"; + if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) + { + $subdir = get_exdir($object->id, 2, 0, 0, $object, $modulepart).$objectref; + } + else + { + $subdir = get_exdir($object->id, 0, 0, 0, $object, $modulepart).$objectref; + } + $filepath = $dir_output . $subdir . "/"; + $file = $filepath . $objectref . ".pdf"; + $relativepath = $subdir.'/'.$objectref.'.pdf'; - // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") - $fileimage = $file.'_preview.png'; // If PDF has 1 page - $fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page - $relativepathimage = $relativepath.'_preview.png'; + // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") + $fileimage = $file.'_preview.png'; // If PDF has 1 page + $fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page + $relativepathimage = $relativepath.'_preview.png'; - // Si fichier PDF existe - if (file_exists($file)) - { - $encfile = urlencode($file); - // Conversion du PDF en image png si fichier png non existant - if ( (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($file))) - && (! file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file))) - ) - { - if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here. - { - $ret = dol_convert_file($file, 'png', $fileimage); - if ($ret < 0) $error++; - } - } + // Si fichier PDF existe + if (file_exists($file)) + { + $encfile = urlencode($file); + // Conversion du PDF en image png si fichier png non existant + if ( (! file_exists($fileimage) || (filemtime($fileimage) < filemtime($file))) + && (! file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file))) + ) + { + if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here. + { + $ret = dol_convert_file($file, 'png', $fileimage); + if ($ret < 0) $error++; + } + } - $heightforphotref=70; - if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; - // Si fichier png PDF d'1 page trouve - if (file_exists($fileimage)) - { - $phototoshow = '
'; - $phototoshow.= ''; - $phototoshow.= '
'; - } - // Si fichier png PDF de plus d'1 page trouve - elseif (file_exists($fileimagebis)) - { - $preview = preg_replace('/\.png/','',$relativepathimage) . "-0.png"; - $phototoshow = '
'; - $phototoshow.= '

'; - $phototoshow.= '

'; - } - } - } - else if (! $phototoshow) - { - $phototoshow = $form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos); - } + $heightforphotref=70; + if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; + // Si fichier png PDF d'1 page trouve + if (file_exists($fileimage)) + { + $phototoshow = '
'; + $phototoshow.= ''; + $phototoshow.= '
'; + } + // Si fichier png PDF de plus d'1 page trouve + elseif (file_exists($fileimagebis)) + { + $preview = preg_replace('/\.png/','',$relativepathimage) . "-0.png"; + $phototoshow = '
'; + $phototoshow.= '

'; + $phototoshow.= '

'; + } + } + } + else if (! $phototoshow) + { + $phototoshow = $form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos); + } - if ($phototoshow) - { - $morehtmlleft.='
'; - $morehtmlleft.=$phototoshow; - $morehtmlleft.='
'; - } - } + if ($phototoshow) + { + $morehtmlleft.='
'; + $morehtmlleft.=$phototoshow; + $morehtmlleft.='
'; + } + } - if (! $phototoshow) // Show No photo link (picto of pbject) - { - $morehtmlleft.='
'; - if ($object->element == 'action') - { - $width=80; - $cssclass='photorefcenter'; - $nophoto=img_picto('', 'title_agenda', '', false, 1); - } - else - { - $width=14; $cssclass='photorefcenter'; - $picto = $object->picto; - if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub - $nophoto=img_picto('', 'object_'.$picto, '', false, 1); - } - $morehtmlleft.=''; - $morehtmlleft.='
No photo
'; + if (! $phototoshow) // Show No photo link (picto of pbject) + { + $morehtmlleft.='
'; + if ($object->element == 'action') + { + $width=80; + $cssclass='photorefcenter'; + $nophoto=img_picto('', 'title_agenda', '', false, 1); + } + else + { + $width=14; $cssclass='photorefcenter'; + $picto = $object->picto; + if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub + $nophoto=img_picto('', 'object_'.$picto, '', false, 1); + } + $morehtmlleft.=''; + $morehtmlleft.='
No photo
'; - $morehtmlleft.='
'; - } - } + $morehtmlleft.='
'; + } + } } if ($showbarcode) $morehtmlleft.='
'.$form->showbarcode($object).'
'; if ($object->element == 'societe') { - if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) - { - $morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); - } + if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) + { + $morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); + } } elseif ($object->element == 'product') { - //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - $morehtmlstatus.=''.$object->getLibStatut(5,0).''; - } - $morehtmlstatus.='   '; - //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - $morehtmlstatus.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - $morehtmlstatus.=''.$object->getLibStatut(5,1).''; - } + //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlstatus.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + } else { + $morehtmlstatus.=''.$object->getLibStatut(5,0).''; + } + $morehtmlstatus.='   '; + //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlstatus.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + } else { + $morehtmlstatus.=''.$object->getLibStatut(5,1).''; + } } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) { - $tmptxt=$object->getLibStatut(6, $object->totalpaye); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); + $tmptxt=$object->getLibStatut(6, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); $morehtmlstatus.=$tmptxt; } elseif ($object->element == 'contrat' || $object->element == 'contract') { - if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2); - else $morehtmlstatus.=$object->getLibStatut(4); + if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2); + else $morehtmlstatus.=$object->getLibStatut(4); } elseif ($object->element == 'facturerec') { - if ($object->frequency==0) $morehtmlstatus.=$object->getLibStatut(2); - else $morehtmlstatus.=$object->getLibStatut(4); + if ($object->frequency==0) $morehtmlstatus.=$object->getLibStatut(2); + else $morehtmlstatus.=$object->getLibStatut(4); } else { // Generic case - $tmptxt=$object->getLibStatut(6); - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); + $tmptxt=$object->getLibStatut(6); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); $morehtmlstatus.=$tmptxt; } if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; // For thirdparty @@ -1453,9 +1453,9 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories') { - $morehtmlref.='
'; - $morehtmlref.=$object->getBannerAddress('refaddress',$object); - $morehtmlref.='
'; + $morehtmlref.='
'; + $morehtmlref.=$object->getBannerAddress('refaddress',$object); + $morehtmlref.='
'; } if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) { @@ -1714,7 +1714,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e { // Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs. $month=adodb_strftime('%m', $time+$offsettz+$offsetdst); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. - $month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. + $month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'. if ($encodetooutput) { $monthtext=$outputlangs->transnoentities('Month'.$month); @@ -1898,7 +1898,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) */ function dol_now($mode='gmt') { - $ret=''; + $ret=''; // Note that gmmktime and mktime return same value (GMT) when used without parameters //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. @@ -2141,9 +2141,9 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep if (strtoupper($countrycode) == "CA") { - if (dol_strlen($phone) == 10) { - $newphone=($separ!=''?'(':'').substr($newphone,0,3).($separ!=''?')':'').$separ.substr($newphone,3,3).($separ!=''?'-':'').substr($newphone,6,4); - } + if (dol_strlen($phone) == 10) { + $newphone=($separ!=''?'(':'').substr($newphone,0,3).($separ!=''?')':'').$separ.substr($newphone,3,3).($separ!=''?'-':'').substr($newphone,6,4); + } } if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) @@ -2299,37 +2299,37 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0, $charfornl if ($address) { - if ($hookmanager) { - $parameters = array('element' => $mode, 'id' => $id); - $reshook = $hookmanager->executeHooks('printAddress', $parameters, $address); - $out.=$hookmanager->resPrint; - } - if (empty($reshook)) - { - if (empty($charfornl)) $out.=nl2br($address); - else $out.=preg_replace('/[\r\n]+/', $charfornl, $address); + if ($hookmanager) { + $parameters = array('element' => $mode, 'id' => $id); + $reshook = $hookmanager->executeHooks('printAddress', $parameters, $address); + $out.=$hookmanager->resPrint; + } + if (empty($reshook)) + { + if (empty($charfornl)) $out.=nl2br($address); + else $out.=preg_replace('/[\r\n]+/', $charfornl, $address); - $showgmap=$showomap=0; + $showgmap=$showomap=0; - // TODO Add a hook here - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; - if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; - if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; - if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; - if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; + // TODO Add a hook here + if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; + if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; + if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; + if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; + if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; + if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; - if ($showgmap) - { - $url=dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id,1); - $out.=' '; - } - if ($showomap) - { - $url=dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id,1); - $out.=' '; - } - } + if ($showgmap) + { + $url=dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id,1); + $out.=' '; + } + if ($showomap) + { + $url=dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id,1); + $out.=' '; + } + } } if ($noprint) return $out; else print $out; @@ -2432,9 +2432,9 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie', if ($shownographyet) { - print '
'; - print '
'.$langs->trans("NotEnoughDataYet").'
'; - return; + print '
'; + print '
'.$langs->trans("NotEnoughDataYet").'
'; + return; } if (empty($conf->use_javascript_ajax)) return; @@ -2928,9 +2928,9 @@ function img_delete($titlealt = 'default', $other = 'class="pictodelete"') */ function img_printer($titlealt = "default", $other='') { - global $conf,$langs; - if ($titlealt=="default") $titlealt=$langs->trans("Print"); - return img_picto($titlealt,'printer.png',$other); + global $conf,$langs; + if ($titlealt=="default") $titlealt=$langs->trans("Print"); + return img_picto($titlealt,'printer.png',$other); } /** @@ -3021,7 +3021,7 @@ function img_error($titlealt = 'default') * * @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title. * @param string $moreatt Add more attribute on img tag (For example 'style="float: right"') - * @return string Return img tag + * @return string Return img tag */ function img_next($titlealt = 'default', $moreatt='') { @@ -3320,8 +3320,8 @@ function dol_print_error($db='',$error='',$errors=null) } else // Mode CLI { - // No dol_escape_htmltag for output, we are in CLI mode - $out.='> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n"; + // No dol_escape_htmltag for output, we are in CLI mode + $out.='> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n"; $out.='> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror()?$db->lastqueryerror():$langs->transnoentities("ErrorNoRequestInError"))."\n"; $out.='> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno()?$db->lasterrno():$langs->transnoentities("ErrorNoRequestInError"))."\n"; $out.='> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror()?$db->lasterror():$langs->transnoentities("ErrorNoRequestInError"))."\n"; @@ -3439,7 +3439,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m $sortorder=strtoupper($sortorder); $out=''; - $sortimg=''; + $sortimg=''; $tag='th'; if ($thead==2) $tag='div'; @@ -3464,13 +3464,13 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m if ($field1 != $sortfield1) // We are on another field { - if (preg_match('/^DESC/', $sortorder)) $out.= ''; - else $out.= ''; + if (preg_match('/^DESC/', $sortorder)) $out.= ''; + else $out.= ''; } else // We are of first sorting criteria { - if (preg_match('/^ASC/', $sortorder)) $out.= ''; - else $out.= ''; + if (preg_match('/^ASC/', $sortorder)) $out.= ''; + else $out.= ''; } } @@ -3620,8 +3620,8 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so global $conf,$langs; $savlimit = $limit; - $savtotalnboflines = $totalnboflines; - $totalnboflines=abs($totalnboflines); + $savtotalnboflines = $totalnboflines; + $totalnboflines=abs($totalnboflines); if ($picto == 'setup') $picto='title_setup.png'; if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif'; @@ -3734,40 +3734,40 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee print ''; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if ($moreforfilter) - { + if ($moreforfilter) + { print '
'; - print $moreforfilter; - print '
'; - } + print $moreforfilter; + print '
'; + } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; // Line for filters print ''; // Ref if (! empty($arrayfields['f.ref']['checked'])) { - print ''; + print ''; } // Ref supplier if (! empty($arrayfields['f.ref_supplier']['checked'])) { - print ''; + print ''; } // Label if (! empty($arrayfields['f.label']['checked'])) { - print ''; + print ''; } // Date invoice if (! empty($arrayfields['f.datef']['checked'])) { - print ''; + print ''; } // Date due if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { - print ''; + print ''; } // Project if (! empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; } // Thirpdarty if (! empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; } // Town if (! empty($arrayfields['s.town']['checked'])) print ''; @@ -651,98 +651,98 @@ if ($resql) // State if (! empty($arrayfields['state.nom']['checked'])) { - print ''; + print ''; } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; + print ''; } // Company type if (! empty($arrayfields['typent.code']['checked'])) { - print ''; + print ''; } // Payment mode if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['f.total_ht']['checked'])) { - // Amount - print ''; + // Amount + print ''; } if (! empty($arrayfields['f.total_vat']['checked'])) { - // Amount - print ''; + // Amount + print ''; } if (! empty($arrayfields['f.total_localtax1']['checked'])) { - // Amount - print ''; + // Amount + print ''; } if (! empty($arrayfields['f.total_localtax2']['checked'])) { - // Amount - print ''; + // Amount + print ''; } if (! empty($arrayfields['f.total_ttc']['checked'])) { - // Amount - print ''; + // Amount + print ''; + } + if (! empty($arrayfields['dynamount_payed']['checked'])) + { + print ''; + } + if (! empty($arrayfields['rtp']['checked'])) + { + print ''; } - if (! empty($arrayfields['dynamount_payed']['checked'])) - { - print ''; - } - if (! empty($arrayfields['rtp']['checked'])) - { - print ''; - } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); @@ -751,22 +751,22 @@ if ($resql) // Date creation if (! empty($arrayfields['f.datec']['checked'])) { - print ''; + print ''; } // Date modification if (! empty($arrayfields['f.tms']['checked'])) { - print ''; + print ''; } // Status if (! empty($arrayfields['f.fk_statut']['checked'])) { - print ''; + print ''; } // Action column print '\n"; - $facturestatic=new FactureFournisseur($db); + $facturestatic=new FactureFournisseur($db); $supplierstatic=new Fournisseur($db); $projectstatic=new Project($db); if ($num > 0) - { + { $i=0; $var=true; - $totalarray=array(); + $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); @@ -838,7 +838,7 @@ if ($resql) $datelimit=$db->jdate($obj->datelimite); $facturestatic->id=$obj->facid; $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; + $facturestatic->type=$obj->type; $facturestatic->ref_supplier=$obj->ref_supplier; $facturestatic->date_echeance = $db->jdate($obj->datelimite); $facturestatic->statut = $obj->fk_statut; @@ -849,271 +849,271 @@ if ($resql) $totalpay = $paiement + $totalcreditnotes + $totaldeposits; $remaintopay = $obj->total_ttc - $totalpay; - print ''; - if (! empty($arrayfields['f.ref']['checked'])) - { - print ''; + if (! empty($arrayfields['f.ref']['checked'])) + { + print '
'; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year?$year:-1,'year',1, 20, 5); - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); - print '
'.$langs->trans("Late"); - print '
'; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); + print '
'.$langs->trans("Late"); + print '
'; - print ''; - print ''; + print ''; + print ''; - print $form->select_country($search_country,'search_country','',0,'maxwidth100'); - print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); - print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ''; - $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10); - print ''; + $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10); + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; - print ''; + print ''; - print ''; + print ''; - $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1); - print ''; + $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); + print $form->selectarray('search_status', $liststatus, $search_status, 1); + print ''; @@ -795,21 +795,21 @@ if ($resql) if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'],$_SERVER['PHP_SELF'],'f.localtax1','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'],$_SERVER['PHP_SELF'],'f.localtax2','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],'f.total_ttc','',$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } } // Hook fields $parameters=array('arrayfields'=>$arrayfields); @@ -821,16 +821,16 @@ if ($resql) print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "
'; + print '
'; - print ''; - // Picto + Ref - print ''; - // Warning - //print ''; - // Other picto tool - print '\n"; + print "\n"; if (! $i) $totalarray['nbfield']++; - } + } // Customer ref - if (! empty($arrayfields['f.ref_supplier']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + if (! empty($arrayfields['f.ref_supplier']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Label - if (! empty($arrayfields['f.label']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + if (! empty($arrayfields['f.label']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Date - if (! empty($arrayfields['f.datef']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + if (! empty($arrayfields['f.datef']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Date limit - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Date limit + if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Project - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Project + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Third party - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Town - if (! empty($arrayfields['s.town']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Zip - if (! empty($arrayfields['s.zip']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // State - if (! empty($arrayfields['state.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Country - if (! empty($arrayfields['country.code_iso']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Type ent - if (! empty($arrayfields['typent.code']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Third party + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Town + if (! empty($arrayfields['s.town']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Zip + if (! empty($arrayfields['s.zip']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Type ent + if (! empty($arrayfields['typent.code']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Payment mode + if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Amount HT - if (! empty($arrayfields['f.total_ht']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; - $totalarray['totalht'] += $obj->total_ht; - } - // Amount VAT - if (! empty($arrayfields['f.total_vat']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; - $totalarray['totalvat'] += $obj->total_vat; - } - // Amount LocalTax1 - if (! empty($arrayfields['f.total_localtax1']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield']; - $totalarray['totallocaltax1'] += $obj->total_localtax1; - } - // Amount LocalTax2 - if (! empty($arrayfields['f.total_localtax2']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield']; - $totalarray['totallocaltax2'] += $obj->total_localtax2; - } - // Amount TTC - if (! empty($arrayfields['f.total_ttc']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; - $totalarray['totalttc'] += $obj->total_ttc; - } + // Amount HT + if (! empty($arrayfields['f.total_ht']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; + $totalarray['totalht'] += $obj->total_ht; + } + // Amount VAT + if (! empty($arrayfields['f.total_vat']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; + $totalarray['totalvat'] += $obj->total_vat; + } + // Amount LocalTax1 + if (! empty($arrayfields['f.total_localtax1']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield']; + $totalarray['totallocaltax1'] += $obj->total_localtax1; + } + // Amount LocalTax2 + if (! empty($arrayfields['f.total_localtax2']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield']; + $totalarray['totallocaltax2'] += $obj->total_localtax2; + } + // Amount TTC + if (! empty($arrayfields['f.total_ttc']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; + $totalarray['totalttc'] += $obj->total_ttc; + } - if (! empty($arrayfields['dynamount_payed']['checked'])) - { - print ''; // TODO Use a denormalized field - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; - $totalarray['totalam'] += $totalpay; - } + if (! empty($arrayfields['dynamount_payed']['checked'])) + { + print ''; // TODO Use a denormalized field + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalamfield']=$totalarray['nbfield']; + $totalarray['totalam'] += $totalpay; + } - if (! empty($arrayfields['rtp']['checked'])) - { - print ''; // TODO Use a denormalized field - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; - $totalarray['totalrtp'] += $remaintopay; - } + if (! empty($arrayfields['rtp']['checked'])) + { + print ''; // TODO Use a denormalized field + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield']; + $totalarray['totalrtp'] += $remaintopay; + } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['f.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['f.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) - { - print '"; - if (! $i) $totalarray['nbfield']++; - } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['f.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['f.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['f.fk_statut']['checked'])) + { + print '"; + if (! $i) $totalarray['nbfield']++; + } - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; print "\n"; $i++; } - // Show total line - if (isset($totalarray['totalhtfield']) + // Show total line + if (isset($totalarray['totalhtfield']) || isset($totalarray['totalvatfield']) || isset($totalarray['totallocaltax1field']) || isset($totalarray['totallocaltax2field']) @@ -1121,29 +1121,29 @@ if ($resql) || isset($totalarray['totalamfield']) || isset($totalarray['totalrtpfield']) ) - { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print ''; - else print ''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''; - elseif ($totalarray['totalvatfield'] == $i) print ''; - elseif ($totalarray['totallocaltax1field'] == $i) print ''; - elseif ($totalarray['totallocaltax2field'] == $i) print ''; - elseif ($totalarray['totalttcfield'] == $i) print ''; - elseif ($totalarray['totalamfield'] == $i) print ''; - elseif ($totalarray['totalrtpfield'] == $i) print ''; - else print ''; - } - print ''; + { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit && empty($offset)) print ''; + else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totallocaltax1field'] == $i) print ''; + elseif ($totalarray['totallocaltax2field'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; + elseif ($totalarray['totalamfield'] == $i) print ''; + elseif ($totalarray['totalrtpfield'] == $i) print ''; + else print ''; + } + print ''; - } + } } $db->free($resql); @@ -1153,11 +1153,11 @@ if ($resql) print $hookmanager->resPrint; print "
'; - print $facturestatic->getNomUrl(1); - print ''; - //print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); + print ''; + // Picto + Ref + print ''; + // Warning + //print ''; + // Other picto tool + print '
'; + print $facturestatic->getNomUrl(1); + print ''; + //print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); $subdir = get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); print '
'; - print "
'; - print $obj->ref_supplier; - print ''; + print $obj->ref_supplier; + print ''; - print $obj->label; - print ''; + print $obj->label; + print ''; - print dol_print_date($db->jdate($obj->datef),'day'); - print ''; + print dol_print_date($db->jdate($obj->datef),'day'); + print ''.dol_print_date($datelimit,'day'); - if ($facturestatic->hasDelay()) - { - print img_warning($langs->trans('Late')); - } - print ''.dol_print_date($datelimit,'day'); + if ($facturestatic->hasDelay()) + { + print img_warning($langs->trans('Late')); + } + print ''; - if ($obj->project_id > 0) - { - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - print $projectstatic->getNomUrl(1); - } - print ''; + if ($obj->project_id > 0) + { + $projectstatic->id=$obj->project_id; + $projectstatic->ref=$obj->project_ref; + print $projectstatic->getNomUrl(1); + } + print ''; - $thirdparty=new Societe($db); - $thirdparty->id=$obj->socid; - $thirdparty->name=$obj->name; - $thirdparty->client=$obj->client; - $thirdparty->code_client=$obj->code_client; - print $thirdparty->getNomUrl(1,'supplier'); - print ''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays,'all'); - print $tmparray['label']; - print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); - print $typenArray[$obj->typent_code]; - print ''; + $thirdparty=new Societe($db); + $thirdparty->id=$obj->socid; + $thirdparty->name=$obj->name; + $thirdparty->client=$obj->client; + $thirdparty->code_client=$obj->code_client; + print $thirdparty->getNomUrl(1,'supplier'); + print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); - print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'.(! empty($totalpay)?price($totalpay,0,$langs):' ').''.(! empty($totalpay)?price($totalpay,0,$langs):' ').''.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').''.(! empty($remaintopay)?price($remaintopay,0,$langs):' ').''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - // TODO $paiement is not yet defined - print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); - print "'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + // TODO $paiement is not yet defined + print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type); + print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->facid, $arrayofselected)) $selected=1; - print ''; - } - print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->facid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totallocaltax1']).''.price($totalarray['totallocaltax2']).''.price($totalarray['totalttc']).''.price($totalarray['totalam']).''.price($totalarray['totalrtp']).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totallocaltax1']).''.price($totalarray['totallocaltax2']).''.price($totalarray['totalttc']).''.price($totalarray['totalam']).''.price($totalarray['totalrtp']).'
\n"; - print ''; + print ''; print "\n"; - /* + /* if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { // Show list of available documents diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 07f896d195c..b40f96f669a 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -99,7 +99,7 @@ if (! $sortorder) $sortorder="ASC"; $socid=0; if ($user->societe_id > 0) { - //$socid = $user->societe_id; + //$socid = $user->societe_id; accessforbidden(); } @@ -108,14 +108,14 @@ $search_all=trim(GETPOST("search_all",'alpha')); $search=array(); foreach($object->fields as $key => $val) { - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; } // Definition of fields for list @@ -123,15 +123,15 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } } @@ -152,32 +152,32 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers - { - foreach($object->fields as $key => $val) - { - $search[$key]=''; - } - $toselect=''; - $search_array_options=array(); - } - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') - || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) - { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } - // Mass actions - $objectclass='MyObject'; - $objectlabel='MyObject'; - $permtoread = $user->rights->mymodule->read; - $permtodelete = $user->rights->mymodule->delete; - $uploaddir = $conf->mymodule->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Mass actions + $objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -202,7 +202,7 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects")); $sql = 'SELECT '; foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql.='t.'.$key.', '; } // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -223,16 +223,16 @@ if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_a // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode_search=0; - if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode_search=0; + if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); + } } // Add where from hooks $parameters=array(); @@ -269,8 +269,8 @@ dol_syslog($script_file, LOG_DEBUG); $resql=$db->query($sql); if (! $resql) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $num = $db->num_rows($resql); @@ -278,10 +278,10 @@ $num = $db->num_rows($resql); // Direct jump if only one record found if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/mymodule/myobject_card.php?id='.$id); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/mymodule/myobject_card.php?id='.$id); + exit; } @@ -312,21 +312,21 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); foreach($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param.= '&search_'.$key.'='.urlencode($search[$key]); } if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } // List of mass actions available $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->mymodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); @@ -346,8 +346,8 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } $moreforfilter = ''; @@ -364,7 +364,7 @@ if (! empty($moreforfilter)) { print '
'; print $moreforfilter; - print '
'; + print ''; } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; @@ -380,35 +380,35 @@ print ''; foreach($object->fields as $key => $val) { - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); @@ -417,12 +417,12 @@ print $hookmanager->resPrint; // Rest of fields search foreach($object->fields as $key => $val) { - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } // Action column print ''."\n"; print ''; foreach($object->fields as $key => $val) { - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) - { + if (! empty($arrayfields["ef.".$key]['checked'])) + { $align=$extrafields->getAlignFlag($key); $sortonfield = "ef.".$key; if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; - } + } } } // Hook fields @@ -465,12 +465,12 @@ print $hookmanager->resPrint; // Rest of fields title foreach($object->fields as $key => $val) { - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; } print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print ''."\n"; @@ -480,7 +480,7 @@ print ''."\n"; $needToFetchEachLine=0; foreach ($extrafields->attribute_computed as $key => $val) { - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object } @@ -490,43 +490,43 @@ $i=0; $totalarray=array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen - // Store properties in $object + // Store properties in $object $object->id = $obj->rowid; foreach($object->fields as $key => $val) { if (isset($obj->$key)) $object->$key = $obj->$key; } - // Show here line of result - print ''; - foreach($object->fields as $key => $val) - { - if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Discard some field output at end - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; - if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); - elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); - elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1); - elseif ($key == 'status') print $object->getLibStatut(3); - else print $obj->$key; - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } - } - // Extra fields + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + if (in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Discard some field output at end + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); + elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); + elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1); + elseif ($key == 'status') print $object->getLibStatut(3); + else print $obj->$key; + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) @@ -540,87 +540,87 @@ while ($i < min($num, $limit)) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; - $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; - } + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; + $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; + } } } } - // Fields from hook + // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Rest of fields - foreach($object->fields as $key => $val) - { - if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Keep only field not yet already output - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; - if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); - elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); - elseif ($key == 'status') print $object->getLibStatut(3); - else print $obj->$key; - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } - } - // Action column - print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } + } + // Action column + print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; - print ''; + print ''; - $i++; + $i++; } // Show total line if (isset($totalarray['pos'])) { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if (! empty($totalarray['pos'][$i])) print ''; - else - { - if ($i == 1) - { - if ($num < $limit) print ''; - else print ''; - } - else print ''; - } - } - print ''; + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; } // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } - print ''; + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; } @@ -637,25 +637,25 @@ print ''."\n"; if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); - $formfile = new FormFile($db); + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->read; + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->read; - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } } // End of page diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 525bd96ed90..07a9da3bdb0 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -109,9 +109,9 @@ $canvas=GETPOST("canvas"); $objcanvas=null; if (! empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db,$action); - $objcanvas->getCanvas('product','list',$canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db,$action); + $objcanvas->getCanvas('product','list',$canvas); } // Security check @@ -123,16 +123,16 @@ else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas); $virtualdiffersfromphysical=0; if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. } // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'p.ref'=>"Ref", - 'pfp.ref_fourn'=>"RefSupplier", + 'pfp.ref_fourn'=>"RefSupplier", 'p.label'=>"ProductLabel", 'p.description'=>"Description", - "p.note"=>"Note", + "p.note"=>"Note", ); // multilang if (! empty($conf->global->MAIN_MULTILANGS)) @@ -156,34 +156,34 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) // Definition of fields for lists $arrayfields=array( - 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - //'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), - 'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled) && ! empty($conf->service->enabled))), - 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>($contextpage != 'servicelist'), 'enabled'=>(! empty($conf->barcode->enabled))), - 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), + 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + //'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), + 'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled) && ! empty($conf->service->enabled))), + 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>($contextpage != 'servicelist'), 'enabled'=>(! empty($conf->barcode->enabled))), + 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), 'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), - 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), + 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), - 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), + 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), + 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0), 'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0), 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), - 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Buy").')', 'checked'=>1, 'position'=>1000) + 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), + 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Buy").')', 'checked'=>1, 'position'=>1000) ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } @@ -202,35 +202,35 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers - { - $sall=""; - $search_ref=""; - $search_label=""; - $search_barcode=""; - $search_categ=0; - $search_tosell=""; - $search_tobuy=""; - $search_tobatch=''; - $search_type=''; - $search_accountancy_code_sell=''; - $search_accountancy_code_buy=''; - $search_array_options=array(); - } + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + $sall=""; + $search_ref=""; + $search_label=""; + $search_barcode=""; + $search_categ=0; + $search_tosell=""; + $search_tobuy=""; + $search_tobatch=''; + $search_type=''; + $search_accountancy_code_sell=''; + $search_accountancy_code_buy=''; + $search_array_options=array(); + } - // Mass actions - $objectclass='Product'; - if ((string) $search_type == '1') { $objectlabel='Services'; } - if ((string) $search_type == '0') { $objectlabel='Products'; } + // Mass actions + $objectclass='Product'; + if ((string) $search_type == '1') { $objectlabel='Services'; } + if ((string) $search_type == '0') { $objectlabel='Products'; } - $permtoread = $user->rights->produit->lire; - $permtodelete = $user->rights->produit->supprimer; - $uploaddir = $conf->product->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + $permtoread = $user->rights->produit->lire; + $permtodelete = $user->rights->produit->supprimer; + $uploaddir = $conf->product->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -243,7 +243,7 @@ $htmlother=new FormOther($db); if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $objcanvas->assign_values($action); // This must contains code to load data (must call LoadListDatas($limit, $offset, $sortfield, $sortorder)) - $objcanvas->display_canvas($action); // This is code to show template + $objcanvas->display_canvas($action); // This is code to show template } else { @@ -265,24 +265,24 @@ else $texte = $langs->trans("ProductsAndServices"); } - $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; - $sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; - $sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy,'; - $sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,'; - //$sql.= ' pfp.ref_fourn as ref_supplier, '; - $sql.= ' MIN(pfp.unitprice) as minsellprice'; + $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; + $sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; + $sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy,'; + $sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,'; + //$sql.= ' pfp.ref_fourn as ref_supplier, '; + $sql.= ' MIN(pfp.unitprice) as minsellprice'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { $sql .= ', pac.rowid prod_comb_id'; } // Add fields from extrafields - foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); + foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; - if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ + if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; // multilang if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang() ."'"; @@ -292,27 +292,27 @@ else $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); - // if the type is not 1, we show all products (type = 0,2,3) - if (dol_strlen($search_type) && $search_type != '-1') - { - if ($search_type == 1) $sql.= " AND p.fk_product_type = 1"; - else $sql.= " AND p.fk_product_type <> 1"; - } + // if the type is not 1, we show all products (type = 0,2,3) + if (dol_strlen($search_type) && $search_type != '-1') + { + if ($search_type == 1) $sql.= " AND p.fk_product_type = 1"; + else $sql.= " AND p.fk_product_type <> 1"; + } if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.label', $search_label); if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode); - if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell!=-1) $sql.= " AND p.tosell = ".$db->escape($search_tosell); - if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy!=-1) $sql.= " AND p.tobuy = ".$db->escape($search_tobuy); - if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; - if ($catid > 0) $sql.= " AND cp.fk_categorie = ".$catid; - if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; - if ($search_categ > 0) $sql.= " AND cp.fk_categorie = ".$db->escape($search_categ); - if ($search_categ == -2) $sql.= " AND cp.fk_categorie IS NULL"; - if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; - if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); - if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); - if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); - // Add where from extra fields + if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell!=-1) $sql.= " AND p.tosell = ".$db->escape($search_tosell); + if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy!=-1) $sql.= " AND p.tobuy = ".$db->escape($search_tobuy); + if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; + if ($catid > 0) $sql.= " AND cp.fk_categorie = ".$catid; + if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; + if ($search_categ > 0) $sql.= " AND cp.fk_categorie = ".$db->escape($search_categ); + if ($search_categ == -2) $sql.= " AND cp.fk_categorie IS NULL"; + if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; + if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); + if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); + if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); + // Add where from extra fields if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { $sql .= " AND pac.rowid IS NULL"; @@ -321,171 +321,171 @@ else // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } } // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; - $sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; - $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy, p.pmp'; + $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; + $sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; + $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy, p.pmp'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { $sql .= ', pac.rowid'; } // Add fields from extrafields - foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); + foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; - //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet - $sql.= $db->order($sortfield,$sortorder); + //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet + $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($limit + 1, $offset); + $sql.= $db->plimit($limit + 1, $offset); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected=is_array($toselect)?$toselect:array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) - { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/product/card.php?id='.$id); - exit; - } + if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/product/card.php?id='.$id); + exit; + } - $helpurl=''; - if ($search_type != '') - { - if ($search_type == 0) - { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; - } - else if ($search_type == 1) - { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - } - } + $helpurl=''; + if ($search_type != '') + { + if ($search_type == 0) + { + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + } + else if ($search_type == 1) + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + } + } - llxHeader('',$title,$helpurl,''); + llxHeader('',$title,$helpurl,''); - // Displays product removal confirmation - if (GETPOST('delprod')) { - setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); - } + // Displays product removal confirmation + if (GETPOST('delprod')) { + setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); + } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ); - if ($search_ref) $param="&search_ref=".urlencode($search_ref); - if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); - if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); - if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); - if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); - if ($type != '') $param.='&type='.urlencode($type); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); - if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sall) $param.="&sall=".urlencode($sall); + if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ); + if ($search_ref) $param="&search_ref=".urlencode($search_ref); + if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); + if ($search_label) $param.="&search_label=".urlencode($search_label); + if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); + if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); + if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); + if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); + if ($type != '') $param.='&type='.urlencode($type); + if ($search_type != '') $param.='&search_type='.urlencode($search_type); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } - // List of mass actions available - $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), - ); - if ($user->rights->produit->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); - if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + // List of mass actions available + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + if ($user->rights->produit->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); + if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); print ''; - if ($optioncss != '') print ''; + if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; print ''; - print ''; - print ''; - if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; + print ''; + print ''; + if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, '', '', $limit); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, '', '', $limit); - if (! empty($catid)) - { - print "
"; - $c = new Categorie($db); - $ways = $c->print_all_ways(' > ','product/list.php'); - print " > ".$ways[0]."
\n"; - print "

"; - } + if (! empty($catid)) + { + print "
"; + $c = new Categorie($db); + $ways = $c->print_all_ways(' > ','product/list.php'); + print " > ".$ways[0]."
\n"; + print "

"; + } - if (! empty($canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$canvas.'/actions_card_'.$canvas.'.class.php')) - { - $fieldlist = $object->field_list; - $datas = $object->list_datas; - $picto='title.png'; - $title_picto = img_picto('',$picto); - $title_text = $title; + if (! empty($canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$canvas.'/actions_card_'.$canvas.'.class.php')) + { + $fieldlist = $object->field_list; + $datas = $object->list_datas; + $picto='title.png'; + $title_picto = img_picto('',$picto); + $title_text = $title; - // Default templates directory - $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$canvas.'/tpl/'; - // Check if a custom template is present - if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/list.tpl.php')) - { - $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/'; - } + // Default templates directory + $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$canvas.'/tpl/'; + // Check if a custom template is present + if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/list.tpl.php')) + { + $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/'; + } - include $template_dir.'list.tpl.php'; // Include native PHP templates - } - else - { - if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); - } + include $template_dir.'list.tpl.php'; // Include native PHP templates + } + else + { + if ($sall) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + } - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) - { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); - $moreforfilter.='
'; - } + // Filter on categories + $moreforfilter=''; + if (! empty($conf->categorie->enabled)) + { + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); + $moreforfilter.='
'; + } //Show/hide child products. Hidden by default if (!empty($conf->variants->enabled) && $search_type === 0) { @@ -495,117 +495,117 @@ else $moreforfilter.=''; } - if ($moreforfilter) - { - print '
'; - print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; + } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - print '
'; - print '
'; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; @@ -437,25 +437,25 @@ print '
'; + print $hookmanager->resPrint; + // Rest of fields + foreach($object->fields as $key => $val) + { + if (! in_array($key, array('date_creation', 'tms', 'import_key', 'status'))) continue; // Keep only field not yet already output + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); + elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); + elseif ($key == 'status') print $object->getLibStatut(3); + else print $obj->$key; + print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; + { + $selected=0; if (in_array($obj->rowid, $arrayofselected)) $selected=1; print ''; - } + } print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; + print '
'; + print '
'."\n"; - // Lines with input filters - print ''; - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - } - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.label']['checked'])) - { - print ''; + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.label']['checked'])) + { + print ''; - } - // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) - { - print ''; + } + // Type + if (! empty($arrayfields['p.fk_product_type']['checked'])) + { + print ''; - } - // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) - { - print ''; - } - // Duration + print $form->selectarray('search_type', $array, $search_type); + print ''; + } + // Barcode + if (! empty($arrayfields['p.barcode']['checked'])) + { + print ''; + } + // Duration if (! empty($arrayfields['p.duration']['checked'])) - { - print ''; - } - // Sell price + { + print ''; + } + // Sell price if (! empty($arrayfields['p.sellprice']['checked'])) - { - print ''; - } - // Minimum buying Price + { + print ''; + } + // Minimum buying Price if (! empty($arrayfields['p.minbuyprice']['checked'])) - { - print ''; - } + { + print ''; + } // Number buying Price if (! empty($arrayfields['p.numbuyprice']['checked'])) - { - print ''; - } + { + print ''; + } // WAP if (! empty($arrayfields['p.pmp']['checked'])) - { - print ''; - } - // Limit for alert + { + print ''; + } + // Limit for alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { - print ''; - } - // Desired stock + { + print ''; + } + // Desired stock if (! empty($arrayfields['p.desiredstock']['checked'])) - { - print ''; - } - // Stock + { + print ''; + } + // Stock if (! empty($arrayfields['p.stock']['checked'])) print ''; - // Stock + // Stock if (! empty($arrayfields['stock_virtual']['checked'])) print ''; // To batch if (! empty($arrayfields['p.tobatch']['checked'])) print ''; // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; - // Extra fields + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) @@ -632,221 +632,221 @@ else } } } - // Fields from hook + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.tosell']['checked'])) - { - print ''; - } + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['p.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['p.tms']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tosell']['checked'])) + { + print ''; + } if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - } - print ''; + { + print ''; + } + print ''; - print ''; + print ''; - print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } - } - // Hook fields - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; + print ''; + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } + } + // Hook fields + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; - $product_static=new Product($db); - $product_fourn =new ProductFournisseur($db); + $product_static=new Product($db); + $product_fourn =new ProductFournisseur($db); - $i = 0; - $totalarray=array(); - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); + $i = 0; + $totalarray=array(); + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); - // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$obj->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; - $result = $db->query($sql); - if ($result) - { - $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $obj->label = $objtp->label; - } - } + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if (! empty($objtp->label)) $obj->label = $objtp->label; + } + } - $product_static->id = $obj->rowid; - $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; - $product_static->label = $obj->label; - $product_static->type = $obj->fk_product_type; - $product_static->status_buy = $obj->tobuy; - $product_static->status = $obj->tosell; + $product_static->id = $obj->rowid; + $product_static->ref = $obj->ref; + $product_static->ref_fourn = $obj->ref_supplier; + $product_static->label = $obj->label; + $product_static->type = $obj->fk_product_type; + $product_static->status_buy = $obj->tobuy; + $product_static->status = $obj->tosell; $product_static->entity = $obj->entity; $product_static->pmp = $obj->pmp; if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { - if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service - { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() - } + if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service + { + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() + } } - print ''; + print ''; - // Ref - if (! empty($arrayfields['p.ref']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Ref supplier - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Label - if (! empty($arrayfields['p.label']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Ref + if (! empty($arrayfields['p.ref']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + // Ref supplier + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + // Label + if (! empty($arrayfields['p.label']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Type + if (! empty($arrayfields['p.fk_product_type']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Barcode + if (! empty($arrayfields['p.barcode']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Duration - if (! empty($arrayfields['p.duration']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Duration + if (! empty($arrayfields['p.duration']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Sell price + if (! empty($arrayfields['p.sellprice']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Better buy price - if (! empty($arrayfields['p.minbuyprice']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Better buy price + if (! empty($arrayfields['p.minbuyprice']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Number of buy prices if (! empty($arrayfields['p.numbuyprice']['checked'])) @@ -871,73 +871,73 @@ else print ''; } - // Limit alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + // Limit alert + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Desired stock + if (! empty($arrayfields['p.desiredstock']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Stock - if (! empty($arrayfields['p.stock']['checked'])) - { + if (! empty($arrayfields['p.stock']['checked'])) + { print ''; - if (! $i) $totalarray['nbfield']++; - } - // Stock - if (! empty($arrayfields['stock_virtual']['checked'])) - { + print $product_static->stock_reel; + } + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Stock + if (! empty($arrayfields['stock_virtual']['checked'])) + { print ''; - if (! $i) $totalarray['nbfield']++; - } - // Lot/Serial - if (! empty($arrayfields['p.tobatch']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Extra fields + print $product_static->stock_theorique; + } + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Lot/Serial + if (! empty($arrayfields['p.tobatch']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) @@ -951,81 +951,81 @@ else $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } } } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['p.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['p.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Status (to sell) - if (! empty($arrayfields['p.tosell']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status (to buy) - if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Action - print ''; - if (! $i) $totalarray['nbfield']++; + // Status (to sell) + if (! empty($arrayfields['p.tosell']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status (to buy) + if (! empty($arrayfields['p.tobuy']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action + print ''; + if (! $i) $totalarray['nbfield']++; - print "\n"; - $i++; - } + print "\n"; + $i++; + } - $db->free($resql); + $db->free($resql); - print "
'; - print ''; - print ''; - print ''; - print ''; + // Lines with input filters + print '
'; + print ''; + print ''; + print ''; + print ''; print ''; - print ''; + print ''; $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); - print $form->selectarray('search_type', $array, $search_type); - print ''; - print ''; - print ''; + print ''; + print ''; - print ' '; - print ''; + print ' '; + print ''; - print ''; + print ''; - print ' '; - print ''; + print ' '; + print ''; - print ' '; - print ''; + print ' '; + print ''; - print ' '; - print ''; + print ' '; + print ''; - print ' '; - print ''; + print ' '; + print ''; - print ' '; - print ''; + print ' '; + print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''; - print ''; - print ''; - print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); - print ''; + print ''; + print ''; + print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); + print ''; - print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); - print ''; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print ''; + print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'; - print $product_static->getNomUrl(1,'',24); - print "'; - print $product_static->getNomUrl(1,'',24); - print "'.dol_trunc($obj->label,40).''; + print $product_static->getNomUrl(1,'',24); + print "'; + print $product_static->getNomUrl(1,'',24); + print "'.dol_trunc($obj->label,40).''.$obj->fk_product_type.''.$obj->fk_product_type.''.$obj->barcode.''.$obj->barcode.''; - if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) - { - if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); - elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); - else print $obj->duration; - } - print ''; + if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) + { + if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); + elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); + elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); + elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); + //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); + else print $obj->duration; + } + print ''; - if ($obj->tosell) - { - if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); - else print price($obj->price).' '.$langs->trans("HT"); - } - print ''; + if ($obj->tosell) + { + if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); + else print price($obj->price).' '.$langs->trans("HT"); + } + print ''; - if ($obj->tobuy && $obj->minsellprice != '') - { - //print price($obj->minsellprice).' '.$langs->trans("HT"); - if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) - { - if ($product_fourn->product_fourn_price_id > 0) - { - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) - { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"),$htmltext); - } - else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); - } - } - } - print ''; + if ($obj->tobuy && $obj->minsellprice != '') + { + //print price($obj->minsellprice).' '.$langs->trans("HT"); + if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) + { + if ($product_fourn->product_fourn_price_id > 0) + { + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); + print $form->textwithpicto(price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"),$htmltext); + } + else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); + } + } + } + print ''; - if ($obj->fk_product_type != 1) - { - print $obj->seuil_stock_alerte; - } - print ''; - if ($obj->fk_product_type != 1) - { - print $obj->desiredstock; - } - print ''; + if ($obj->fk_product_type != 1) + { + print $obj->seuil_stock_alerte; + } + print ''; + if ($obj->fk_product_type != 1) + { + print $obj->desiredstock; + } + print ''; - if ($obj->fk_product_type != 1) - { + if ($obj->fk_product_type != 1) + { if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - print $product_static->stock_reel; - } - print ''; - if ($obj->fk_product_type != 1) - { + if ($obj->fk_product_type != 1) + { if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - print $product_static->stock_theorique; - } - print ''; - print yn($obj->tobatch); - print ''.$obj->accountancy_code_sell.''.$obj->accountancy_code_buy.''; + print yn($obj->tobatch); + print ''.$obj->accountancy_code_sell.''.$obj->accountancy_code_buy.''; - print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); - print ''; - print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); - print ''; + print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); + print ''; + print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); + print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $product_static->LibStatut($obj->tosell,5,0); - } - print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $product_static->LibStatut($obj->tobuy,5,1); - } - print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print ''; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + } else { + print $product_static->LibStatut($obj->tosell,5,0); + } + print ''; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + } else { + print $product_static->LibStatut($obj->tobuy,5,1); + } + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
"; - print ""; - } - print ''; - } - else - { - dol_print_error($db); - } + print "
"; + print "
"; + } + print ''; + } + else + { + dol_print_error($db); + } } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 7d236c904f5..7880c262d04 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -76,7 +76,7 @@ if (! $sortorder) $sortorder="ASC"; $socid=0; if ($user->societe_id > 0) { - $socid = $user->societe_id; + $socid = $user->societe_id; //accessforbidden(); } @@ -90,31 +90,31 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 't.ref'=>'Ref', - 't.note_public'=>'NotePublic', + 't.ref'=>'Ref', + 't.note_public'=>'NotePublic', ); // Definition of fields for list $arrayfields=array( //'t.entity'=>array('label'=>$langs->trans("Fieldentity"), 'checked'=>1), 't.batch'=>array('label'=>$langs->trans("Batch"), 'checked'=>1), - 't.fk_product'=>array('label'=>$langs->trans("Product"), 'checked'=>1), + 't.fk_product'=>array('label'=>$langs->trans("Product"), 'checked'=>1), 't.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>1), 't.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>1), //'t.import_key'=>array('label'=>$langs->trans("ImportKey"), 'checked'=>1), - //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), - //'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500), + //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), + //'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500), //'t.fk_user_modif'=>array('label'=>$langs->trans("UserModificationShort"), 'checked'=>0, 'position'=>500), - 't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), - 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), + 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } @@ -122,8 +122,8 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $object=new Productlot($db); if (($id > 0 || ! empty($ref)) && $action != 'add') { - $result=$object->fetch($id,$ref); - if ($result < 0) dol_print_error($db); + $result=$object->fetch($id,$ref); + if ($result < 0) dol_print_error($db); } @@ -144,12 +144,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { - $search_entity=''; - $search_product=''; - $search_batch=''; - $search_fk_user_creat=''; - $search_fk_user_modif=''; - $search_import_key=''; + $search_entity=''; + $search_product=''; + $search_batch=''; + $search_fk_user_creat=''; + $search_fk_user_modif=''; + $search_import_key=''; $search_date_creation=''; $search_date_update=''; $toselect=''; @@ -159,12 +159,12 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', if (empty($reshook)) { - $objectclass='ProductLot'; - $objectlabel='LotSerial'; - $permtoread = $user->rights->stock->read; - $permtodelete = $user->rights->stock->delete; - $uploaddir = $conf->stock->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + $objectclass='ProductLot'; + $objectlabel='LotSerial'; + $permtoread = $user->rights->stock->read; + $permtodelete = $user->rights->stock->delete; + $uploaddir = $conf->stock->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -240,16 +240,16 @@ if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } } // Add where from hooks $parameters=array(); @@ -273,325 +273,325 @@ dol_syslog($script_file, LOG_DEBUG); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected=is_array($toselect)?$toselect:array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_entity != '') $param.= '&search_entity='.urlencode($search_entity); - if ($search_product != '') $param.= '&search_product='.urlencode($search_product); - if ($search_batch != '') $param.= '&search_batch='.urlencode($search_batch); - if ($search_fk_user_creat != '') $param.= '&search_fk_user_creat='.urlencode($search_fk_user_creat); - if ($search_fk_user_modif != '') $param.= '&search_fk_user_modif='.urlencode($search_fk_user_modif); - if ($search_import_key != '') $param.= '&search_import_key='.urlencode($search_import_key); - if ($optioncss != '') $param.='&optioncss='.$optioncss; - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_entity != '') $param.= '&search_entity='.urlencode($search_entity); + if ($search_product != '') $param.= '&search_product='.urlencode($search_product); + if ($search_batch != '') $param.= '&search_batch='.urlencode($search_batch); + if ($search_fk_user_creat != '') $param.= '&search_fk_user_creat='.urlencode($search_fk_user_creat); + if ($search_fk_user_modif != '') $param.= '&search_fk_user_modif='.urlencode($search_fk_user_modif); + if ($search_import_key != '') $param.= '&search_import_key='.urlencode($search_import_key); + if ($optioncss != '') $param.='&optioncss='.$optioncss; + // Add $param from extra fields + foreach ($search_array_options as $key => $val) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } - $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), - ); - //if ($user->rights->stock->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); - if ($massaction == 'presend') $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + //if ($user->rights->stock->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); + if ($massaction == 'presend') $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); print '
'; - if ($optioncss != '') print ''; + if ($optioncss != '') print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); - } + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + } - /*$moreforfilter = ''; + /*$moreforfilter = ''; $moreforfilter.='
'; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (! empty($moreforfilter)) { print '
'; print $moreforfilter; - print '
'; + print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; - // Fields title search - print ''; - if (! empty($arrayfields['t.entity']['checked'])) print ''; - if (! empty($arrayfields['t.batch']['checked'])) print ''; - if (! empty($arrayfields['t.fk_product']['checked'])) print ''; - if (! empty($arrayfields['t.eatby']['checked'])) print ''; - if (! empty($arrayfields['t.sellby']['checked'])) print ''; - if (! empty($arrayfields['t.fk_user_creat']['checked'])) print ''; - if (! empty($arrayfields['t.fk_user_modif']['checked'])) print ''; - if (! empty($arrayfields['t.import_key']['checked'])) print ''; - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['t.datec']['checked'])) - { - // Date creation - print ''; - } - if (! empty($arrayfields['t.tms']['checked'])) - { - // Date modification - print ''; - } - /*if (! empty($arrayfields['u.statut']['checked'])) + // Fields title search + print ''; + if (! empty($arrayfields['t.entity']['checked'])) print ''; + if (! empty($arrayfields['t.batch']['checked'])) print ''; + if (! empty($arrayfields['t.fk_product']['checked'])) print ''; + if (! empty($arrayfields['t.eatby']['checked'])) print ''; + if (! empty($arrayfields['t.sellby']['checked'])) print ''; + if (! empty($arrayfields['t.fk_user_creat']['checked'])) print ''; + if (! empty($arrayfields['t.fk_user_modif']['checked'])) print ''; + if (! empty($arrayfields['t.import_key']['checked'])) print ''; + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['t.datec']['checked'])) + { + // Date creation + print ''; + } + if (! empty($arrayfields['t.tms']['checked'])) + { + // Date modification + print ''; + } + /*if (! empty($arrayfields['u.statut']['checked'])) { // Status print ''; }*/ - // Action column - print ''; - print ''."\n"; + // Action column + print ''; + print ''."\n"; - // Fields title - print ''; - if (! empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'],$_SERVER['PHP_SELF'],'t.entity','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'],$_SERVER['PHP_SELF'],'t.batch','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'],$_SERVER['PHP_SELF'],'t.fk_product','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'],$_SERVER['PHP_SELF'],'t.eatby','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'],$_SERVER['PHP_SELF'],'t.sellby','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'],$_SERVER['PHP_SELF'],'t.fk_user_creat','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'],$_SERVER['PHP_SELF'],'t.fk_user_modif','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'],$_SERVER['PHP_SELF'],'t.import_key','',$param,'',$sortfield,$sortorder); + // Fields title + print ''; + if (! empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'],$_SERVER['PHP_SELF'],'t.entity','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'],$_SERVER['PHP_SELF'],'t.batch','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'],$_SERVER['PHP_SELF'],'t.fk_product','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'],$_SERVER['PHP_SELF'],'t.eatby','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'],$_SERVER['PHP_SELF'],'t.sellby','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'],$_SERVER['PHP_SELF'],'t.fk_user_creat','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'],$_SERVER['PHP_SELF'],'t.fk_user_modif','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'],$_SERVER['PHP_SELF'],'t.import_key','',$param,'',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) - { + if (! empty($arrayfields["ef.".$key]['checked'])) + { $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } } } - // Hook fields + // Hook fields $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); //if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($arrayfields['t.status']['label'],$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print ''."\n"; + print ''."\n"; $productlot = new Productlot($db); $i=0; $var=true; $totalarray=array(); - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - $var = !$var; + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + if ($obj) + { + $var = !$var; - $productlot->id = $obj->rowid; - $productlot->batch = $obj->batch; + $productlot->id = $obj->rowid; + $productlot->batch = $obj->batch; - // You can use here results - print ''; - if (! empty($arrayfields['t.entity']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.batch']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.fk_product']['checked'])) - { - $productstatic->id=$obj->fk_product; - $productstatic->type=$obj->product_type; - $productstatic->ref=$obj->product_ref; - $productstatic->label=$obj->product_label; - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.eatby']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.sellby']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.fk_user_creat']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.fk_user_modif']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['t.import_key']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['t.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['t.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - /* + // You can use here results + print ''; + if (! empty($arrayfields['t.entity']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['t.batch']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['t.fk_product']['checked'])) + { + $productstatic->id=$obj->fk_product; + $productstatic->type=$obj->product_type; + $productstatic->ref=$obj->product_ref; + $productstatic->label=$obj->product_label; + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['t.eatby']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['t.sellby']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['t.fk_user_creat']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['t.fk_user_modif']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['t.import_key']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['t.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['t.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + /* if (! empty($arrayfields['u.statut']['checked'])) { $userstatic->statut=$obj->statut; print ''; }*/ - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; - print ''; - } - $i++; - } + print ''; + } + $i++; + } - // Show total line - if (isset($totalarray['totalhtfield'])) - { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print ''; - else print ''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''; - elseif ($totalarray['totalvatfield'] == $i) print ''; - elseif ($totalarray['totalttcfield'] == $i) print ''; - else print ''; - } - print ''; - } + // Show total line + if (isset($totalarray['totalhtfield'])) + { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit && empty($offset)) print ''; + else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; + else print ''; + } + print ''; + } - $db->free($resql); + $db->free($resql); $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; - print ''; - print '
'; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); print ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); - print $searchpicto; - print '
'; + $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + print $searchpicto; + print '
'.$obj->entity.''.$productlot->getNomUrl(1).''.$productstatic->getNomUrl(1).''.dol_print_date($db->jdate($obj->eatby), 'day').''.dol_print_date($db->jdate($obj->sellby), 'day').''.$obj->fk_user_creat.''.$obj->fk_user_modif.''.$obj->import_key.''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print '
'.$obj->entity.''.$productlot->getNomUrl(1).''.$productstatic->getNomUrl(1).''.dol_print_date($db->jdate($obj->eatby), 'day').''.dol_print_date($db->jdate($obj->sellby), 'day').''.$obj->fk_user_creat.''.$obj->fk_user_modif.''.$obj->import_key.''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$userstatic->getLibStatut(3).''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
'."\n"; - print '
'; + print '
'; print ''."\n"; @@ -616,8 +616,8 @@ if ($resql) } else { - $error++; - dol_print_error($db); + $error++; + dol_print_error($db); } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index ccc2c12584e..12c8eb2038e 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -45,8 +45,8 @@ $search_categ=GETPOST("search_categ",'alpha'); $search_project=GETPOST('search_project'); if (! isset($_GET['search_projectstatus']) && ! isset($_POST['search_projectstatus'])) { - if ($search_all != '') $search_projectstatus=-1; - else $search_projectstatus=1; + if ($search_all != '') $search_projectstatus=-1; + else $search_projectstatus=1; } else $search_projectstatus=GETPOST('search_projectstatus'); $search_project_ref=GETPOST('search_project_ref'); @@ -99,36 +99,36 @@ if (! $sortorder) $sortorder='DESC'; // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 't.ref'=>"Ref", - 't.label'=>"Label", - 't.description'=>"Description", - 't.note_public'=>"NotePublic", + 't.label'=>"Label", + 't.description'=>"Description", + 't.note_public'=>"NotePublic", ); if (empty($user->socid)) $fieldstosearchall['t.note_private']="NotePrivate"; $arrayfields=array( - 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), - 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), - 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), - 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), - 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1), - 'p.title'=>array('label'=>$langs->trans("ProjectLabel"), 'checked'=>0), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>0), - 'p.fk_statut'=>array('label'=>$langs->trans("ProjectStatus"), 'checked'=>1), - 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>102), - 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>103), - 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>104), - 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>105), - 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), + 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), + 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), + 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), + 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1), + 'p.title'=>array('label'=>$langs->trans("ProjectLabel"), 'checked'=>0), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>0), + 'p.fk_statut'=>array('label'=>$langs->trans("ProjectStatus"), 'checked'=>1), + 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>102), + 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>103), + 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>104), + 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>105), + 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } } $object = new Task($db); @@ -147,40 +147,40 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers - { - $search_all=""; - $search_categ=""; - $search_project=""; - $search_projectstatus=-1; - $search_project_ref=""; - $search_project_title=""; - $search_task_ref=""; - $search_task_label=""; - $search_task_description=""; - $search_task_user=-1; - $search_project_user=-1; - $search_sday=''; - $search_smonth=''; - $search_syear=''; - $search_eday=''; - $search_emonth=''; - $search_eyear=''; - $toselect=''; - $search_array_options=array(); - } + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + $search_all=""; + $search_categ=""; + $search_project=""; + $search_projectstatus=-1; + $search_project_ref=""; + $search_project_title=""; + $search_task_ref=""; + $search_task_label=""; + $search_task_description=""; + $search_task_user=-1; + $search_project_user=-1; + $search_sday=''; + $search_smonth=''; + $search_syear=''; + $search_eday=''; + $search_emonth=''; + $search_eyear=''; + $toselect=''; + $search_array_options=array(); + } - // Mass actions - $objectclass='Task'; - $objectlabel='Tasks'; - $permtoread = $user->rights->projet->lire; - $permtodelete = $user->rights->projet->supprimer; - $uploaddir = $conf->projet->dir_output.'/tasks'; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Mass actions + $objectclass='Task'; + $objectlabel='Tasks'; + $permtoread = $user->rights->projet->lire; + $permtodelete = $user->rights->projet->supprimer; + $uploaddir = $conf->projet->dir_output.'/tasks'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1; @@ -223,10 +223,10 @@ $sql.= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) - { - $listofprojectcontacttype[$obj->rowid]=$obj->code; - } + while($obj = $db->fetch_object($resql)) + { + $listofprojectcontacttype[$obj->rowid]=$obj->code; + } } else dol_print_error($db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found @@ -238,10 +238,10 @@ $sql.= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) - { - $listoftaskcontacttype[$obj->rowid]=$obj->code; - } + while($obj = $db->fetch_object($resql)) + { + $listoftaskcontacttype[$obj->rowid]=$obj->code; + } } else dol_print_error($db); if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found @@ -281,35 +281,35 @@ if ($search_task_label) $sql .= natural_search('t.label', $search_task_label) if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_smonth > 0) { - if ($search_syear > 0 && empty($search_sday)) - $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,$search_smonth,false))."' AND '".$db->idate(dol_get_last_day($search_syear,$search_smonth,false))."'"; - else if ($search_syear > 0 && ! empty($search_sday)) - $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_smonth, $search_sday, $search_syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_smonth, $search_sday, $search_syear))."'"; - else - $sql.= " AND date_format(t.dateo, '%m') = '".$search_smonth."'"; + if ($search_syear > 0 && empty($search_sday)) + $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,$search_smonth,false))."' AND '".$db->idate(dol_get_last_day($search_syear,$search_smonth,false))."'"; + else if ($search_syear > 0 && ! empty($search_sday)) + $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_smonth, $search_sday, $search_syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_smonth, $search_sday, $search_syear))."'"; + else + $sql.= " AND date_format(t.dateo, '%m') = '".$search_smonth."'"; } else if ($search_syear > 0) { - $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,1,false))."' AND '".$db->idate(dol_get_last_day($search_syear,12,false))."'"; + $sql.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,1,false))."' AND '".$db->idate(dol_get_last_day($search_syear,12,false))."'"; } if ($search_emonth > 0) { - if ($search_eyear > 0 && empty($search_eday)) - $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,$search_emonth,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,$search_emonth,false))."'"; - else if ($search_eyear > 0 && ! empty($search_eday)) - $sql.= " AND t.datee BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_emonth, $search_eday, $search_eyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_emonth, $search_eday, $search_eyear))."'"; - else - $sql.= " AND date_format(t.datee, '%m') = '".$search_emonth."'"; + if ($search_eyear > 0 && empty($search_eday)) + $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,$search_emonth,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,$search_emonth,false))."'"; + else if ($search_eyear > 0 && ! empty($search_eday)) + $sql.= " AND t.datee BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_emonth, $search_eday, $search_eyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_emonth, $search_eday, $search_eyear))."'"; + else + $sql.= " AND date_format(t.datee, '%m') = '".$search_emonth."'"; } else if ($search_eyear > 0) { - $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'"; + $sql.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'"; } if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_projectstatus >= 0) { - if ($search_projectstatus == 99) $sql .= " AND p.fk_statut <> 2"; - else $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); + if ($search_projectstatus == 99) $sql .= " AND p.fk_statut <> 2"; + else $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); } if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; @@ -317,16 +317,16 @@ if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',',arr // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } } // Add where from hooks $parameters=array(); @@ -337,8 +337,8 @@ $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); } $sql.= $db->plimit($limit + 1,$offset); @@ -349,8 +349,8 @@ dol_syslog("list allowed project", LOG_DEBUG); $resql = $db->query($sql); if (! $resql) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $num = $db->num_rows($resql); @@ -359,10 +359,10 @@ $arrayofselected=is_array($toselect)?$toselect:array(); if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { - $obj = $db->fetch_object($resql); - $id = $obj->id; - header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1'); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->id; + header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1'); + exit; } $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; @@ -393,9 +393,9 @@ if ($optioncss != '') $param.='&optioncss='.$optioncss; // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } // List of mass actions available @@ -425,14 +425,14 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'

'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksOnProjectsDesc").'

'; - else print $langs->trans("TasksOnProjectsPublicDesc").'

'; + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksOnProjectsDesc").'

'; + else print $langs->trans("TasksOnProjectsPublicDesc").'

'; } if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } $morehtmlfilter = ''; @@ -440,11 +440,11 @@ $morehtmlfilter = ''; // Filter on categories if (! empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ProjectCategories'). ': '; - $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('ProjectCategories'). ': '; + $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); + $moreforfilter.='
'; } // If the user can view users @@ -483,60 +483,60 @@ print ''; if (! empty($arrayfields['t.ref']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['t.label']['checked'])) { - print ''; + print ''; } // Start date if (! empty($arrayfields['t.dateo']['checked'])) { - print ''; + print ''; } // End date if (! empty($arrayfields['t.datee']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['p.title']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['p.fk_statut']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['t.planned_workload']['checked'])) print ''; if (! empty($arrayfields['t.duration_effective']['checked'])) print ''; @@ -545,25 +545,25 @@ if (! empty($arrayfields['t.progress']['checked'])) print ''; - } - } + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); @@ -571,15 +571,15 @@ $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // N print $hookmanager->resPrint; if (! empty($arrayfields['t.datec']['checked'])) { - // Date creation - print ''; + // Date creation + print ''; } if (! empty($arrayfields['t.tms']['checked'])) { - // Date modification - print ''; + // Date modification + print ''; } // Action column print ''; - // Ref - if (! empty($arrayfields['t.ref']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Label - if (! empty($arrayfields['t.label']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date start - if (! empty($arrayfields['t.dateo']['checked'])) - { + // Ref + if (! empty($arrayfields['t.ref']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Label + if (! empty($arrayfields['t.label']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date start + if (! empty($arrayfields['t.dateo']['checked'])) + { print ''; - if (! $i) $totalarray['nbfield']++; - } + print dol_print_date($db->jdate($obj->date_start),'day'); + print ''; + if (! $i) $totalarray['nbfield']++; + } // Date end - if (! empty($arrayfields['t.datee']['checked'])) - { + if (! empty($arrayfields['t.datee']['checked'])) + { print ''; - if (! $i) $totalarray['nbfield']++; - } - // Project ref - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Project title - if (! empty($arrayfields['p.title']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Third party - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Project status - if (! empty($arrayfields['p.fk_statut']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + print dol_print_date($db->jdate($obj->date_end),'day'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Project ref + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Project title + if (! empty($arrayfields['p.title']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Third party + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Project status + if (! empty($arrayfields['p.fk_statut']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - // Planned workload - if (! empty($arrayfields['t.planned_workload']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield']; - $totalarray['totalplannedworkload'] += $obj->planned_workload; - } - // Time spent - if (! empty($arrayfields['t.duration_effective']['checked'])) - { - $showlineingray=0;$showproject=1; - print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield']; + $totalarray['totalplannedworkload'] += $obj->planned_workload; + } + // Time spent + if (! empty($arrayfields['t.duration_effective']['checked'])) + { + $showlineingray=0;$showproject=1; + print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield']; - $totalarray['totaldurationeffective'] += $obj->duration_effective; - } - // Calculated progress - if (! empty($arrayfields['t.progress_calculated']['checked'])) - { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield']; + $totalarray['totaldurationeffective'] += $obj->duration_effective; + } + // Calculated progress + if (! empty($arrayfields['t.progress_calculated']['checked'])) + { print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalprogress_calculated']=$totalarray['nbfield']; - } - // Declared progress - if (! empty($arrayfields['t.progress']['checked'])) - { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalprogress_calculated']=$totalarray['nbfield']; + } + // Declared progress + if (! empty($arrayfields['t.progress']['checked'])) + { print ''; - if (! $i) $totalarray['nbfield']++; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); @@ -815,18 +815,18 @@ while ($i < min($num,$limit)) // Date creation if (! empty($arrayfields['t.datec']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['t.tms']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } // Status /*if (! empty($arrayfields['p.fk_statut']['checked'])) @@ -834,16 +834,16 @@ while ($i < min($num,$limit)) $projectstatic->statut = $obj->fk_statut; print ''; }*/ - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; print "\n"; @@ -856,22 +856,22 @@ while ($i < min($num,$limit)) // Show total line if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield'])) { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print ''; - else print ''; - } - elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''; - elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''; - elseif ($totalarray['totalprogress_calculated'] == $i) print ''; - else print ''; - } - print ''; + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit && empty($offset)) print ''; + else print ''; + } + elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''; + elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''; + elseif ($totalarray['totalprogress_calculated'] == $i) print ''; + else print ''; + } + print ''; } $db->free($resql); diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 5e3428019d6..175f3e1510e 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -71,21 +71,21 @@ $download = GETPOST('d','int')?GETPOST('d','int'):GETPOST('download','int'); if (! $action) { - if (! GETPOST("amount",'alpha') && ! $source) - { - print $langs->trans('ErrorBadParameters')." - amount or source"; - exit; - } - if (is_numeric($amount) && ! GETPOST("tag",'alpha') && ! $source) - { - print $langs->trans('ErrorBadParameters')." - tag or source"; - exit; - } - if ($source && ! GETPOST("ref",'alpha')) - { - print $langs->trans('ErrorBadParameters')." - ref"; - exit; - } + if (! GETPOST("amount",'alpha') && ! $source) + { + print $langs->trans('ErrorBadParameters')." - amount or source"; + exit; + } + if (is_numeric($amount) && ! GETPOST("tag",'alpha') && ! $source) + { + print $langs->trans('ErrorBadParameters')." - tag or source"; + exit; + } + if ($source && ! GETPOST("ref",'alpha')) + { + print $langs->trans('ErrorBadParameters')." - ref"; + exit; + } } @@ -95,11 +95,11 @@ $validpaymentmethod=array(); // Detect $paymentmethod foreach($_POST as $key => $val) { - if (preg_match('/^dopayment_(.*)$/', $key, $reg)) - { - $paymentmethod=$reg[1]; - break; - } + if (preg_match('/^dopayment_(.*)$/', $key, $reg)) + { + $paymentmethod=$reg[1]; + break; + } } @@ -125,28 +125,28 @@ if (! empty($suffix)) } if ($source) { - $urlok.='s='.urlencode($source).'&'; - $urlko.='s='.urlencode($source).'&'; + $urlok.='s='.urlencode($source).'&'; + $urlko.='s='.urlencode($source).'&'; } if (! empty($REF)) { - $urlok.='ref='.urlencode($REF).'&'; - $urlko.='ref='.urlencode($REF).'&'; + $urlok.='ref='.urlencode($REF).'&'; + $urlko.='ref='.urlencode($REF).'&'; } if (! empty($TAG)) { - $urlok.='tag='.urlencode($TAG).'&'; - $urlko.='tag='.urlencode($TAG).'&'; + $urlok.='tag='.urlencode($TAG).'&'; + $urlko.='tag='.urlencode($TAG).'&'; } if (! empty($FULLTAG)) { - $urlok.='fulltag='.urlencode($FULLTAG).'&'; - $urlko.='fulltag='.urlencode($FULLTAG).'&'; + $urlok.='fulltag='.urlencode($FULLTAG).'&'; + $urlko.='fulltag='.urlencode($FULLTAG).'&'; } if (! empty($SECUREKEY)) { - $urlok.='securekey='.urlencode($SECUREKEY).'&'; - $urlko.='securekey='.urlencode($SECUREKEY).'&'; + $urlok.='securekey='.urlencode($SECUREKEY).'&'; + $urlko.='securekey='.urlencode($SECUREKEY).'&'; } if (! empty($entity)) { @@ -174,21 +174,21 @@ if (! empty($conf->paypal->enabled)) if ($urlko) $PAYPAL_API_KO=$urlko; if (empty($PAYPAL_API_USER)) { - dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); - return -1; + dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); + return -1; } if (empty($PAYPAL_API_PASSWORD)) { - dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); - return -1; + dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); + return -1; } if (empty($PAYPAL_API_SIGNATURE)) { - dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); - return -1; + dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); + return -1; } - $validpaymentmethod['paypal']='valid'; + $validpaymentmethod['paypal']='valid'; } if (! empty($conf->paybox->enabled)) @@ -221,23 +221,23 @@ if (! empty($conf->stripe->enabled)) $valid=true; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { - if ($source && $REF) $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $source . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical - else $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - } - else - { - $token = $conf->global->PAYMENT_SECURITY_TOKEN; - } - if ($SECUREKEY != $token) $valid=false; + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) + { + if ($source && $REF) $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $source . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical + else $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + } + else + { + $token = $conf->global->PAYMENT_SECURITY_TOKEN; + } + if ($SECUREKEY != $token) $valid=false; - if (! $valid) - { - print '
Bad value for key.
'; - //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; - exit; - } + if (! $valid) + { + print '
Bad value for key.
'; + //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; + exit; + } } @@ -265,19 +265,19 @@ if ($action == 'dopayment') if ($paymentmethod == 'paypal') { $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); - $PAYPAL_PAYMENT_TYPE='Sale'; + $PAYPAL_PAYMENT_TYPE='Sale'; - $origfulltag=GETPOST("fulltag",'alpha'); - $shipToName=GETPOST("shipToName"); - $shipToStreet=GETPOST("shipToStreet"); - $shipToCity=GETPOST("shipToCity"); - $shipToState=GETPOST("shipToState"); - $shipToCountryCode=GETPOST("shipToCountryCode"); - $shipToZip=GETPOST("shipToZip"); - $shipToStreet2=GETPOST("shipToStreet2"); - $phoneNum=GETPOST("phoneNum"); - $email=GETPOST("email"); - $desc=GETPOST("desc",'alpha'); + $origfulltag=GETPOST("fulltag",'alpha'); + $shipToName=GETPOST("shipToName"); + $shipToStreet=GETPOST("shipToStreet"); + $shipToCity=GETPOST("shipToCity"); + $shipToState=GETPOST("shipToState"); + $shipToCountryCode=GETPOST("shipToCountryCode"); + $shipToZip=GETPOST("shipToZip"); + $shipToStreet2=GETPOST("shipToStreet2"); + $phoneNum=GETPOST("phoneNum"); + $email=GETPOST("email"); + $desc=GETPOST("desc",'alpha'); $mesg=''; if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); @@ -285,7 +285,7 @@ if ($action == 'dopayment') //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); elseif (! $origfulltag) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); - //var_dump($_POST); + //var_dump($_POST); if (empty($mesg)) { dol_syslog("newpayment.php call paypal api and do redirect", LOG_DEBUG); @@ -294,35 +294,35 @@ if ($action == 'dopayment') $PAYPAL_API_DEVISE="USD"; //if ($currency == 'EUR') $PAYPAL_API_DEVISE="EUR"; //if ($currency == 'USD') $PAYPAL_API_DEVISE="USD"; - if (! empty($currency)) $PAYPAL_API_DEVISE=$currency; + if (! empty($currency)) $PAYPAL_API_DEVISE=$currency; - dol_syslog("Submit Paypal form", LOG_DEBUG); - dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG); - //dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); // No password into log files - dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG); - dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG); - dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG); - dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); - dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); - dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); - dol_syslog("shipToName: $shipToName", LOG_DEBUG); - dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); - dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); - dol_syslog("shipToState: $shipToState", LOG_DEBUG); - dol_syslog("shipToCountryCode: $shipToCountryCode", LOG_DEBUG); - dol_syslog("shipToZip: $shipToZip", LOG_DEBUG); - dol_syslog("shipToStreet2: $shipToStreet2", LOG_DEBUG); - dol_syslog("phoneNum: $phoneNum", LOG_DEBUG); - dol_syslog("email: $email", LOG_DEBUG); - dol_syslog("desc: $desc", LOG_DEBUG); + dol_syslog("Submit Paypal form", LOG_DEBUG); + dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG); + //dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); // No password into log files + dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG); + dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", LOG_DEBUG); + dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG); + dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); + dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG); + dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); + dol_syslog("shipToName: $shipToName", LOG_DEBUG); + dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG); + dol_syslog("shipToCity: $shipToCity", LOG_DEBUG); + dol_syslog("shipToState: $shipToState", LOG_DEBUG); + dol_syslog("shipToCountryCode: $shipToCountryCode", LOG_DEBUG); + dol_syslog("shipToZip: $shipToZip", LOG_DEBUG); + dol_syslog("shipToStreet2: $shipToStreet2", LOG_DEBUG); + dol_syslog("phoneNum: $phoneNum", LOG_DEBUG); + dol_syslog("email: $email", LOG_DEBUG); + dol_syslog("desc: $desc", LOG_DEBUG); - dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO - //$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE; - //$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE; - //$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE; + dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO + //$_SESSION["PaymentType"]=$PAYPAL_PAYMENT_TYPE; + //$_SESSION["currencyCodeType"]=$PAYPAL_API_DEVISE; + //$_SESSION["FinalPaymentAmt"]=$PAYPAL_API_PRICE; - // A redirect is added if API call successfull - print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); + // A redirect is added if API call successfull + print_paypal_redirect($PAYPAL_API_PRICE,$PAYPAL_API_DEVISE,$PAYPAL_PAYMENT_TYPE,$PAYPAL_API_OK,$PAYPAL_API_KO, $FULLTAG); exit; } @@ -506,11 +506,11 @@ llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'online // Check link validity if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) { - $langs->load("errors"); - dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); - llxFooter(); - $db->close(); - exit; + $langs->load("errors"); + dol_print_error_email('BADREFINPAYMENTFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); + llxFooter(); + $db->close(); + exit; } @@ -592,15 +592,15 @@ if ($urllogo) $text=''; if (! empty($conf->global->PAYMENT_NEWFORM_TEXT)) { - $langs->load("members"); - if (preg_match('/^\((.*)\)$/',$conf->global->PAYMENT_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."
\n"; - else $text.=$conf->global->PAYMENT_NEWFORM_TEXT."
\n"; - $text=''."\n"; + $langs->load("members"); + if (preg_match('/^\((.*)\)$/',$conf->global->PAYMENT_NEWFORM_TEXT,$reg)) $text.=$langs->trans($reg[1])."
\n"; + else $text.=$conf->global->PAYMENT_NEWFORM_TEXT."
\n"; + $text=''."\n"; } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text.=''."\n"; + $text.=''."\n"; } print $text; @@ -626,9 +626,9 @@ if (! $source) // Creditor print ''."\n"; + print ''."\n"; // Amount @@ -637,12 +637,12 @@ if (! $source) print ''."\n"; - // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum - // as they don't exists (buyer is unknown, tag is free). + // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum + // as they don't exists (buyer is unknown, tag is free). } @@ -685,12 +685,12 @@ if ($source == 'order') $object = $order; } - if ($action != 'dopayment') // Do not change amount if we just click on first dopayment - { - $amount=$order->total_ttc; - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - } + if ($action != 'dopayment') // Do not change amount if we just click on first dopayment + { + $amount=$order->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + } $fulltag='ORD='.$order->ref.'.CUS='.$order->thirdparty->id; //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," "); @@ -700,9 +700,9 @@ if ($source == 'order') // Creditor print ''."\n"; + print ''."\n"; // Debitor @@ -726,12 +726,12 @@ if ($source == 'order') print ''."\n"; + print ''."\n"; // Debitor @@ -841,12 +841,12 @@ if ($source == 'invoice') print ''."\n"; } - // Shipping address - $shipToName=$invoice->thirdparty->name; - $shipToStreet=$invoice->thirdparty->address; - $shipToCity=$invoice->thirdparty->town; - $shipToState=$invoice->thirdparty->state_code; - $shipToCountryCode=$invoice->thirdparty->country_code; - $shipToZip=$invoice->thirdparty->zip; - $shipToStreet2=''; - $phoneNum=$invoice->thirdparty->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - $labeldesc=$langs->trans("Invoice").' '.$invoice->ref; - if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); - print ''."\n"; + // Shipping address + $shipToName=$invoice->thirdparty->name; + $shipToStreet=$invoice->thirdparty->address; + $shipToCity=$invoice->thirdparty->town; + $shipToState=$invoice->thirdparty->state_code; + $shipToCountryCode=$invoice->thirdparty->country_code; + $shipToZip=$invoice->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$invoice->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + $labeldesc=$langs->trans("Invoice").' '.$invoice->ref; + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } // Payment on contract line @@ -941,40 +941,40 @@ if ($source == 'contractline') } } - if ($action != 'dopayment') // Do not change amount if we just click on first dopayment - { - $amount=$contractline->total_ttc; + if ($action != 'dopayment') // Do not change amount if we just click on first dopayment + { + $amount=$contractline->total_ttc; - if ($contractline->fk_product && ! empty($conf->global->PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES)) - { - $product=new Product($db); - $result=$product->fetch($contractline->fk_product); + if ($contractline->fk_product && ! empty($conf->global->PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES)) + { + $product=new Product($db); + $result=$product->fetch($contractline->fk_product); - // We define price for product (TODO Put this in a method in product class) - if (! empty($conf->global->PRODUIT_MULTIPRICES)) - { - $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; - $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; - $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; - } - else - { - $pu_ht = $product->price; - $pu_ttc = $product->price_ttc; - $price_base_type = $product->price_base_type; - } + // We define price for product (TODO Put this in a method in product class) + if (! empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pu_ht = $product->multiprices[$contract->thirdparty->price_level]; + $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level]; + $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level]; + } + else + { + $pu_ht = $product->price; + $pu_ttc = $product->price_ttc; + $price_base_type = $product->price_base_type; + } - $amount=$pu_ttc; - if (empty($amount)) - { - dol_print_error('','ErrorNoPriceDefinedForThisProduct'); - exit; - } - } + $amount=$pu_ttc; + if (empty($amount)) + { + dol_print_error('','ErrorNoPriceDefinedForThisProduct'); + exit; + } + } - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - } + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + } $fulltag='COL='.$contractline->ref.'.CON='.$contract->ref.'.CUS='.$contract->thirdparty->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); //$fulltag.='.NAM='.strtr($contract->thirdparty->name,"-"," "); @@ -988,7 +988,7 @@ if ($source == 'contractline') print ''."\n"; // Debitor @@ -1054,12 +1054,12 @@ if ($source == 'contractline') print ''."\n"; - // Shipping address - $shipToName=$contract->thirdparty->name; - $shipToStreet=$contract->thirdparty->address; - $shipToCity=$contract->thirdparty->town; - $shipToState=$contract->thirdparty->state_code; - $shipToCountryCode=$contract->thirdparty->country_code; - $shipToZip=$contract->thirdparty->zip; - $shipToStreet2=''; - $phoneNum=$contract->thirdparty->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - $labeldesc=$langs->trans("Contract").' '.$contract->ref; - if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); - print ''."\n"; + // Shipping address + $shipToName=$contract->thirdparty->name; + $shipToStreet=$contract->thirdparty->address; + $shipToCity=$contract->thirdparty->town; + $shipToState=$contract->thirdparty->state_code; + $shipToCountryCode=$contract->thirdparty->country_code; + $shipToZip=$contract->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$contract->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + $labeldesc=$langs->trans("Contract").' '.$contract->ref; + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } // Payment on member subscription @@ -1128,12 +1128,12 @@ if ($source == 'membersubscription') $subscription=new Subscription($db); } - if ($action != 'dopayment') // Do not change amount if we just click on first dopayment - { - $amount=$subscription->total_ttc; - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - } + if ($action != 'dopayment') // Do not change amount if we just click on first dopayment + { + $amount=$subscription->total_ttc; + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + } $fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M'); if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; } @@ -1142,9 +1142,9 @@ if ($source == 'membersubscription') // Creditor print ''."\n"; + print ''."\n"; // Debitor @@ -1195,7 +1195,7 @@ if ($source == 'membersubscription') { $valtoshow=GETPOST("newamount",'int'); // force default subscription amount to value defined into constant... - if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + if (! empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT; } @@ -1203,21 +1203,21 @@ if ($source == 'membersubscription') else { if (! empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - } + } + } } if (empty($amount) || ! is_numeric($amount)) { - //$valtoshow=GETPOST("newamount",'int'); - if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); - print ''; - print ''; + //$valtoshow=GETPOST("newamount",'int'); + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''; + print ''; } else { - $valtoshow=$amount; - if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); - print ''.price($valtoshow).''; - print ''; + $valtoshow=$amount; + if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow); + print ''.price($valtoshow).''; + print ''; print ''; } // Currency @@ -1233,34 +1233,34 @@ if ($source == 'membersubscription') print ''; print ''."\n"; - // Shipping address - $shipToName=$member->getFullName($langs); - $shipToStreet=$member->address; - $shipToCity=$member->town; - $shipToState=$member->state_code; - $shipToCountryCode=$member->country_code; - $shipToZip=$member->zip; - $shipToStreet2=''; - $phoneNum=$member->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - $labeldesc = $langs->trans("PaymentSubscription"); - if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); - print ''."\n"; + // Shipping address + $shipToName=$member->getFullName($langs); + $shipToStreet=$member->address; + $shipToCity=$member->town; + $shipToState=$member->state_code; + $shipToCountryCode=$member->country_code; + $shipToZip=$member->zip; + $shipToStreet2=''; + $phoneNum=$member->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + $labeldesc = $langs->trans("PaymentSubscription"); + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } @@ -1275,44 +1275,44 @@ print "\n"; if ($action != 'dopayment') { - if ($found && ! $error) // We are in a management option and no error - { - // Buttons for all payments registration methods + if ($found && ! $error) // We are in a management option and no error + { + // Buttons for all payments registration methods - if (! empty($conf->paybox->enabled)) - { - // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of paybox - print '
'; - } + if (! empty($conf->paybox->enabled)) + { + // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of paybox + print '
'; + } - if (! empty($conf->stripe->enabled)) - { - // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe - print '
'; - } + if (! empty($conf->stripe->enabled)) + { + // If STRIPE_PICTO_FOR_PAYMENT is 'cb' we show a picto of a crdit card instead of stripe + print '
'; + } - if (! empty($conf->paypal->enabled)) - { - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + if (! empty($conf->paypal->enabled)) + { + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') - { - print '
'; - } - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') - { - print '
'; - } - } - } - else - { - dol_print_error_email('ERRORNEWPAYMENT'); - } + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') + { + print '
'; + } + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') + { + print '
'; + } + } + } + else + { + dol_print_error_email('ERRORNEWPAYMENT'); + } } else { - // Print + // Print } print ''."\n"; @@ -1495,7 +1495,7 @@ if (preg_match('/^dopayment/',$action)) } '; + print ''; } } diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 4853c54fdd9..428f5b96f42 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -33,65 +33,65 @@ require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; */ class CompanyBankAccount extends Account { - var $socid; + var $socid; - var $default_rib; - var $frstrecur; - var $rum; - var $date_rum; + var $default_rib; + var $frstrecur; + var $rum; + var $date_rum; - var $datec; - var $datem; + var $datec; + var $datem; - /** + /** * Constructor * * @param DoliDB $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; + */ + public function __construct(DoliDB $db) + { + $this->db = $db; - $this->socid = 0; - $this->solde = 0; - $this->error_number = 0; - $this->default_rib = 0; - } + $this->socid = 0; + $this->solde = 0; + $this->error_number = 0; + $this->default_rib = 0; + } - /** - * Create bank information record - * - * @param User $user User - * @param int $notrigger 1=Disable triggers - * @return int <0 if KO, >= 0 if OK - */ - function create(User $user = null, $notrigger=0) - { - $now = dol_now(); + /** + * Create bank information record + * + * @param User $user User + * @param int $notrigger 1=Disable triggers + * @return int <0 if KO, >= 0 if OK + */ + function create(User $user = null, $notrigger=0) + { + $now = dol_now(); $error = 0; - // Correct default_rib to be sure to have always one default + // Correct default_rib to be sure to have always one default $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1"; $result = $this->db->query($sql); - if ($result) - { - $numrows=$this->db->num_rows($result); - if ($this->default_rib && $numrows > 0) $this->default_rib = 0; - if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1; - } + if ($result) + { + $numrows=$this->db->num_rows($result); + if ($this->default_rib && $numrows > 0) $this->default_rib = 0; + if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1; + } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec)"; - $sql.= " VALUES (".$this->socid.", '".$this->db->idate($now)."')"; - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->affected_rows($resql)) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec)"; + $sql.= " VALUES (".$this->socid.", '".$this->db->idate($now)."')"; + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->affected_rows($resql)) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); - if (! $notrigger) - { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('COMPANY_RIB_CREATE',$user); if ($result < 0) $error++; @@ -105,64 +105,64 @@ class CompanyBankAccount extends Account { return 0; } - } - else - { - return 1; - } - } - } - else - { - print $this->db->error(); - return 0; - } - } + } + else + { + return 1; + } + } + } + else + { + print $this->db->error(); + return 0; + } + } - /** - * Update bank account - * - * @param User $user Object user - * @param int $notrigger 1=Disable triggers - * @return int <=0 if KO, >0 if OK - */ - function update(User $user = null, $notrigger = 0) - { - global $conf; - $error = 0; + /** + * Update bank account + * + * @param User $user Object user + * @param int $notrigger 1=Disable triggers + * @return int <=0 if KO, >0 if OK + */ + function update(User $user = null, $notrigger = 0) + { + global $conf; + $error = 0; - if (! $this->id) return -1; + if (! $this->id) return -1; - if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); + if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1); if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1); - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET"; - $sql.= " bank = '" .$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",default_rib = ".$this->default_rib; - if ($conf->prelevement->enabled) - { - $sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; - $sql.= ",rum = '".$this->db->escape($this->rum)."'"; - $sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); - } - if (trim($this->label) != '') - $sql.= ",label = '".$this->db->escape($this->label)."'"; - else - $sql.= ",label = NULL"; - $sql.= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET"; + $sql.= " bank = '" .$this->db->escape($this->bank)."'"; + $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql.= ",number='".$this->db->escape($this->number)."'"; + $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql.= ",bic='".$this->db->escape($this->bic)."'"; + $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql.= ",default_rib = ".$this->default_rib; + if ($conf->prelevement->enabled) + { + $sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'"; + $sql.= ",rum = '".$this->db->escape($this->rum)."'"; + $sql.= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null"); + } + if (trim($this->label) != '') + $sql.= ",label = '".$this->db->escape($this->label)."'"; + else + $sql.= ",label = NULL"; + $sql.= " WHERE rowid = ".$this->id; - $result = $this->db->query($sql); - if ($result) - { + $result = $this->db->query($sql); + if ($result) + { if (! $notrigger) @@ -185,118 +185,118 @@ class CompanyBankAccount extends Account return 1; } - } - else - { - dol_print_error($this->db); - return -1; - } - } + } + else + { + dol_print_error($this->db); + return -1; + } + } - /** - * Load record from database - * - * @param int $id Id of record - * @param int $socid Id of company. If this is filled, function will return the default RIB of company - * @return int <0 if KO, >0 if OK - */ - function fetch($id, $socid=0) - { - if (empty($id) && empty($socid)) return -1; + /** + * Load record from database + * + * @param int $id Id of record + * @param int $socid Id of company. If this is filled, function will return the default RIB of company + * @return int <0 if KO, >0 if OK + */ + function fetch($id, $socid=0) + { + if (empty($id) && empty($socid)) return -1; - $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE rowid = ".$id; - if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1"; + $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; + $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql.= " WHERE rowid = ".$id; + if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1"; - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref + $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref - $this->id = $obj->rowid; - $this->socid = $obj->fk_soc; - $this->bank = $obj->bank; - $this->code_banque = $obj->code_banque; - $this->code_guichet = $obj->code_guichet; - $this->number = $obj->number; - $this->cle_rib = $obj->cle_rib; - $this->bic = $obj->bic; - $this->iban = $obj->iban; - $this->domiciliation = $obj->domiciliation; - $this->proprio = $obj->proprio; - $this->owner_address = $obj->owner_address; - $this->label = $obj->label; - $this->default_rib = $obj->default_rib; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->datem); - $this->rum = $obj->rum; - $this->frstrecur = $obj->frstrecur; - } - $this->db->free($resql); + $this->id = $obj->rowid; + $this->socid = $obj->fk_soc; + $this->bank = $obj->bank; + $this->code_banque = $obj->code_banque; + $this->code_guichet = $obj->code_guichet; + $this->number = $obj->number; + $this->cle_rib = $obj->cle_rib; + $this->bic = $obj->bic; + $this->iban = $obj->iban; + $this->domiciliation = $obj->domiciliation; + $this->proprio = $obj->proprio; + $this->owner_address = $obj->owner_address; + $this->label = $obj->label; + $this->default_rib = $obj->default_rib; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); + $this->rum = $obj->rum; + $this->frstrecur = $obj->frstrecur; + } + $this->db->free($resql); - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } - /** - * Delete a rib from database - * - * @param User $user User deleting - * @param int $notrigger 1=Disable triggers - * @return int <0 if KO, >0 if OK - */ - function delete(User $user = null, $notrigger=0) - { - global $conf; + /** + * Delete a rib from database + * + * @param User $user User deleting + * @param int $notrigger 1=Disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete(User $user = null, $notrigger=0) + { + global $conf; - $error = 0; + $error = 0; - dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); + dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); - $this->db->begin(); + $this->db->begin(); - if (! $error && ! $notrigger) - { - // Call trigger - $result=$this->call_trigger('COMPANY_RIB_DELETE',$user); - if ($result < 0) $error++; - // End call triggers - } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('COMPANY_RIB_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } - if (! $error) - { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib"; - $sql .= " WHERE rowid = " . $this->id; + if (! $error) + { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib"; + $sql .= " WHERE rowid = " . $this->id; - if (! $this->db->query($sql)) - { - $error++; - $this->errors[]=$this->db->lasterror(); - } - } + if (! $this->db->query($sql)) + { + $error++; + $this->errors[]=$this->db->lasterror(); + } + } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1*$error; - } - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1*$error; + } + } /** * Return RIB @@ -320,93 +320,93 @@ class CompanyBankAccount extends Account return $rib; } - /** - * Set RIB as Default - * - * @param int $rib RIB id - * @return int 0 if KO, 1 if OK - */ - function setAsDefault($rib=0) - { - $sql1 = "SELECT rowid as id, fk_soc FROM ".MAIN_DB_PREFIX."societe_rib"; - $sql1.= " WHERE rowid = ".($rib?$rib:$this->id); + /** + * Set RIB as Default + * + * @param int $rib RIB id + * @return int 0 if KO, 1 if OK + */ + function setAsDefault($rib=0) + { + $sql1 = "SELECT rowid as id, fk_soc FROM ".MAIN_DB_PREFIX."societe_rib"; + $sql1.= " WHERE rowid = ".($rib?$rib:$this->id); - dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); - $result1 = $this->db->query($sql1); - if ($result1) - { - if ($this->db->num_rows($result1) == 0) - { - return 0; - } - else - { - $obj = $this->db->fetch_object($result1); + dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); + $result1 = $this->db->query($sql1); + if ($result1) + { + if ($this->db->num_rows($result1) == 0) + { + return 0; + } + else + { + $obj = $this->db->fetch_object($result1); - $this->db->begin(); + $this->db->begin(); - $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0 "; - $sql2.= "WHERE fk_soc = ".$obj->fk_soc; - dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); - $result2 = $this->db->query($sql2); + $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0 "; + $sql2.= "WHERE fk_soc = ".$obj->fk_soc; + dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); + $result2 = $this->db->query($sql2); - $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1 "; - $sql3.= "WHERE rowid = ".$obj->id; - dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); - $result3 = $this->db->query($sql3); + $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1 "; + $sql3.= "WHERE rowid = ".$obj->id; + dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); + $result3 = $this->db->query($sql3); - if (!$result2 || !$result3) - { - dol_print_error($this->db); - $this->db->rollback(); - return -1; - } - else - { - $this->db->commit(); - return 1; - } - } - } - else - { - dol_print_error($this->db); - return -1; - } - } + if (!$result2 || !$result3) + { + dol_print_error($this->db); + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return 1; + } + } + } + else + { + dol_print_error($this->db); + return -1; + } + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - function initAsSpecimen() - { - $this->specimen = 1; - $this->ref = 'CBA'; - $this->label = 'CustomerCorp Bank account'; - $this->bank = 'CustomerCorp Bank'; - $this->courant = Account::TYPE_CURRENT; - $this->clos = Account::STATUS_OPEN; - $this->code_banque = '123'; - $this->code_guichet = '456'; - $this->number = 'CUST12345'; - $this->cle_rib = 50; - $this->bic = 'CC12'; - $this->iban = 'FR999999999'; - $this->domiciliation = 'Bank address of customer corp'; - $this->proprio = 'Owner'; - $this->owner_address = 'Owner address'; - $this->country_id = 1; + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + function initAsSpecimen() + { + $this->specimen = 1; + $this->ref = 'CBA'; + $this->label = 'CustomerCorp Bank account'; + $this->bank = 'CustomerCorp Bank'; + $this->courant = Account::TYPE_CURRENT; + $this->clos = Account::STATUS_OPEN; + $this->code_banque = '123'; + $this->code_guichet = '456'; + $this->number = 'CUST12345'; + $this->cle_rib = 50; + $this->bic = 'CC12'; + $this->iban = 'FR999999999'; + $this->domiciliation = 'Bank address of customer corp'; + $this->proprio = 'Owner'; + $this->owner_address = 'Owner address'; + $this->country_id = 1; - $this->rum = 'UMR-CU1212-0007-5-1475405262'; - $this->date_rum =dol_now() - 10000; - $this->frstrecur = 'FRST'; + $this->rum = 'UMR-CU1212-0007-5-1475405262'; + $this->date_rum =dol_now() - 10000; + $this->frstrecur = 'FRST'; - $this->socid = 0; - } + $this->socid = 0; + } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d1d218a0061..ed0cd57ba76 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -40,28 +40,28 @@ require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; */ class Societe extends CommonObject { - public $element='societe'; - public $table_element = 'societe'; + public $element='societe'; + public $table_element = 'societe'; public $fk_element='fk_soc'; - protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object + protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object protected $childtablesoncascade=array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); /** - * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - * @var int - */ - protected $ismultientitymanaged = 1; + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + protected $ismultientitymanaged = 1; - public $entity; + public $entity; - /** - * Thirdparty name - * @var string - * @deprecated Use $name instead - * @see name - */ - public $nom; + /** + * Thirdparty name + * @var string + * @deprecated Use $name instead + * @see name + */ + public $nom; /** * Alias names (commercial, trademark or alias names) @@ -69,46 +69,46 @@ class Societe extends CommonObject */ public $name_alias; - public $particulier; - public $address; - public $zip; - public $town; + public $particulier; + public $address; + public $zip; + public $town; - /** - * Thirdparty status : 0=activity ceased, 1= in activity - * @var int - */ - var $status; + /** + * Thirdparty status : 0=activity ceased, 1= in activity + * @var int + */ + var $status; - /** - * Id of department - * @var int - */ - var $state_id; - var $state_code; - var $state; + /** + * Id of department + * @var int + */ + var $state_id; + var $state_code; + var $state; - /** - * State code - * @var string - * @deprecated Use state_code instead - * @see state_code - */ - var $departement_code; + /** + * State code + * @var string + * @deprecated Use state_code instead + * @see state_code + */ + var $departement_code; - /** - * @var string - * @deprecated Use state instead - * @see state - */ - var $departement; + /** + * @var string + * @deprecated Use state instead + * @see state + */ + var $departement; - /** - * @var string - * @deprecated Use country instead - * @see country - */ - var $pays; + /** + * @var string + * @deprecated Use country instead + * @see country + */ + var $pays; /** * Phone number @@ -137,77 +137,77 @@ class Societe extends CommonObject var $url; //! barcode - /** - * Barcode value - * @var string - */ - var $barcode; + /** + * Barcode value + * @var string + */ + var $barcode; - // 6 professional id (usage depends on country) + // 6 professional id (usage depends on country) - /** - * Professional ID 1 (Ex: Siren in France) - * @var string - */ - var $idprof1; + /** + * Professional ID 1 (Ex: Siren in France) + * @var string + */ + var $idprof1; - /** - * Professional ID 2 (Ex: Siret in France) - * @var string - */ - var $idprof2; + /** + * Professional ID 2 (Ex: Siret in France) + * @var string + */ + var $idprof2; - /** - * Professional ID 3 (Ex: Ape in France) - * @var string - */ - var $idprof3; + /** + * Professional ID 3 (Ex: Ape in France) + * @var string + */ + var $idprof3; - /** - * Professional ID 4 (Ex: RCS in France) - * @var string - */ - var $idprof4; + /** + * Professional ID 4 (Ex: RCS in France) + * @var string + */ + var $idprof4; - /** - * Professional ID 5 - * @var string - */ - var $idprof5; + /** + * Professional ID 5 + * @var string + */ + var $idprof5; - /** - * Professional ID 6 - * @var string - */ - var $idprof6; + /** + * Professional ID 6 + * @var string + */ + var $idprof6; - var $prefix_comm; + var $prefix_comm; - var $tva_assuj; - /** - * Intracommunitary VAT ID - * @var string - */ - var $tva_intra; + var $tva_assuj; + /** + * Intracommunitary VAT ID + * @var string + */ + var $tva_intra; - // Local taxes - var $localtax1_assuj; - var $localtax1_value; - var $localtax2_assuj; - var $localtax2_value; + // Local taxes + var $localtax1_assuj; + var $localtax1_value; + var $localtax2_assuj; + var $localtax2_value; - var $managers; - var $capital; - var $typent_id; - var $typent_code; - var $effectif; - var $effectif_id; - var $forme_juridique_code; - var $forme_juridique; + var $managers; + var $capital; + var $typent_id; + var $typent_code; + var $effectif; + var $effectif_id; + var $forme_juridique_code; + var $forme_juridique; - var $remise_percent; - var $mode_reglement_supplier_id; - var $cond_reglement_supplier_id; + var $remise_percent; + var $mode_reglement_supplier_id; + var $cond_reglement_supplier_id; var $fk_prospectlevel; var $name_bis; @@ -215,149 +215,149 @@ class Societe extends CommonObject /** * Date of last update - * @var string + * @var string */ var $date_modification; /** * User that made last update - * @var string + * @var string */ var $user_modification; /** * Date of creation - * @var string + * @var string */ var $date_creation; /** * User that created the thirdparty - * @var User + * @var User */ var $user_creation; - var $specimen; + var $specimen; - /** - * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect - * @var int - */ - var $client; - /** - * 0=no prospect, 1=prospect - * @var int - */ - var $prospect; - /** - * 0=no supplier, 1=supplier - * @var int - */ - var $fournisseur; + /** + * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect + * @var int + */ + var $client; + /** + * 0=no prospect, 1=prospect + * @var int + */ + var $prospect; + /** + * 0=no supplier, 1=supplier + * @var int + */ + var $fournisseur; - /** - * Client code. E.g: CU2014-003 - * @var string - */ - var $code_client; + /** + * Client code. E.g: CU2014-003 + * @var string + */ + var $code_client; - /** - * Supplier code. E.g: SU2014-003 - * @var string - */ - var $code_fournisseur; + /** + * Supplier code. E.g: SU2014-003 + * @var string + */ + var $code_fournisseur; - /** - * Accounting code for client - * @var string - */ - var $code_compta; + /** + * Accounting code for client + * @var string + */ + var $code_compta; - /** - * Accounting code for suppliers - * @var string - */ - var $code_compta_fournisseur; + /** + * Accounting code for suppliers + * @var string + */ + var $code_compta_fournisseur; - /** - * @var string - * @deprecated Note is split in public and private notes - * @see note_public, note_private - */ - var $note; + /** + * @var string + * @deprecated Note is split in public and private notes + * @see note_public, note_private + */ + var $note; - /** - * Private note - * @var string - */ - var $note_private; + /** + * Private note + * @var string + */ + var $note_private; - /** - * Public note - * @var string - */ - var $note_public; + /** + * Public note + * @var string + */ + var $note_public; - //! code statut prospect - var $stcomm_id; - var $statut_commercial; + //! code statut prospect + var $stcomm_id; + var $statut_commercial; - /** - * Assigned price level - * @var int - */ - var $price_level; - var $outstanding_limit; + /** + * Assigned price level + * @var int + */ + var $price_level; + var $outstanding_limit; - /** - * Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives. - * @var int - */ - var $commercial_id; - /** - * Id of parent thirdparty (if one) - * @var int - */ - var $parent; - /** - * Default language code of thirdparty (en_US, ...) - * @var string - */ - var $default_lang; + /** + * Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives. + * @var int + */ + var $commercial_id; + /** + * Id of parent thirdparty (if one) + * @var int + */ + var $parent; + /** + * Default language code of thirdparty (en_US, ...) + * @var string + */ + var $default_lang; - var $ref; - var $ref_int; - /** - * External user reference. - * This is to allow external systems to store their id and make self-developed synchronizing functions easier to - * build. - * @var string - */ - var $ref_ext; + var $ref; + var $ref_int; + /** + * External user reference. + * This is to allow external systems to store their id and make self-developed synchronizing functions easier to + * build. + * @var string + */ + var $ref_ext; - /** - * Import key. - * Set when the thirdparty has been created through an import process. This is to relate those created thirdparties - * to an import process - * @var string - */ - var $import_key; + /** + * Import key. + * Set when the thirdparty has been created through an import process. This is to relate those created thirdparties + * to an import process + * @var string + */ + var $import_key; - /** - * Supplier WebServices URL - * @var string - */ - var $webservices_url; + /** + * Supplier WebServices URL + * @var string + */ + var $webservices_url; - /** - * Supplier WebServices Key - * @var string - */ - var $webservices_key; + /** + * Supplier WebServices Key + * @var string + */ + var $webservices_key; - var $logo; - var $logo_small; - var $logo_mini; + var $logo; + var $logo_small; + var $logo_mini; - var $array_options; + var $array_options; // Incoterms var $fk_incoterms; @@ -368,53 +368,53 @@ class Societe extends CommonObject var $fk_multicurrency; var $multicurrency_code; - /** - * To contains a clone of this when we need to save old properties of object - * @var Societe - */ - var $oldcopy; + /** + * To contains a clone of this when we need to save old properties of object + * @var Societe + */ + var $oldcopy; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; - $this->client = 0; - $this->prospect = 0; - $this->fournisseur = 0; - $this->typent_id = 0; - $this->effectif_id = 0; - $this->forme_juridique_code = 0; - $this->tva_assuj = 1; - $this->status = 1; - } + $this->client = 0; + $this->prospect = 0; + $this->fournisseur = 0; + $this->typent_id = 0; + $this->effectif_id = 0; + $this->forme_juridique_code = 0; + $this->tva_assuj = 1; + $this->status = 1; + } - /** - * Create third party in database. - * $this->code_client = -1 and $this->code_fournisseur = -1 means automatic assignement. - * - * @param User $user Object of user that ask creation - * @return int >= 0 if OK, < 0 if KO - */ - function create($user) - { - global $langs,$conf,$mysoc; + /** + * Create third party in database. + * $this->code_client = -1 and $this->code_fournisseur = -1 means automatic assignement. + * + * @param User $user Object of user that ask creation + * @return int >= 0 if OK, < 0 if KO + */ + function create($user) + { + global $langs,$conf,$mysoc; $error=0; - // Clean parameters - if (empty($this->status)) $this->status=0; - $this->name=$this->name?trim($this->name):trim($this->nom); - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name); - $this->nom=$this->name; // For backward compatibility - if (empty($this->client)) $this->client=0; - if (empty($this->fournisseur)) $this->fournisseur=0; - $this->import_key = trim($this->import_key); + // Clean parameters + if (empty($this->status)) $this->status=0; + $this->name=$this->name?trim($this->name):trim($this->nom); + if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name); + $this->nom=$this->name; // For backward compatibility + if (empty($this->client)) $this->client=0; + if (empty($this->fournisseur)) $this->fournisseur=0; + $this->import_key = trim($this->import_key); if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) @@ -423,333 +423,333 @@ class Societe extends CommonObject $this->fk_multicurrency = 0; } - dol_syslog(get_class($this)."::create ".$this->name); + dol_syslog(get_class($this)."::create ".$this->name); - $now=dol_now(); + $now=dol_now(); - $this->db->begin(); + $this->db->begin(); - // For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts) - if ($this->code_client == -1) $this->get_codeclient($this,0); - if ($this->code_fournisseur == -1) $this->get_codefournisseur($this,1); + // For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts) + if ($this->code_client == -1) $this->get_codeclient($this,0); + if ($this->code_fournisseur == -1) $this->get_codefournisseur($this,1); - // Check more parameters (including mandatory setup - // If error, this->errors[] is filled - $result = $this->verify(); + // Check more parameters (including mandatory setup + // If error, this->errors[] is filled + $result = $this->verify(); - if ($result >= 0) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; - $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$conf->entity.", '".$this->db->idate($now)."'"; - $sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null"); - $sql.= ", ".(! empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'":"null"); - $sql.= ", ".$this->status; - $sql.= ", ".(! empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", ".(! empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", 0"; + if ($result >= 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; + $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$conf->entity.", '".$this->db->idate($now)."'"; + $sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null"); + $sql.= ", ".(! empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'":"null"); + $sql.= ", ".$this->status; + $sql.= ", ".(! empty($this->ref_int) ? "'".$this->db->escape($this->ref_int)."'":"null"); + $sql.= ", ".(! empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'":"null"); + $sql.= ", 0"; $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null"); - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."')"; + $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null"); + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."')"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result=$this->db->query($sql); - if ($result) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe"); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $result=$this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe"); - $ret = $this->update($this->id,$user,0,1,1,'add'); + $ret = $this->update($this->id,$user,0,1,1,'add'); - // Ajout du commercial affecte - if ($this->commercial_id != '' && $this->commercial_id != -1) - { - $this->add_commercial($user, $this->commercial_id); - } - // si un commercial cree un client il lui est affecte automatiquement - else if (empty($user->rights->societe->client->voir)) - { - $this->add_commercial($user, $user->id); - } + // Ajout du commercial affecte + if ($this->commercial_id != '' && $this->commercial_id != -1) + { + $this->add_commercial($user, $this->commercial_id); + } + // si un commercial cree un client il lui est affecte automatiquement + else if (empty($user->rights->societe->client->voir)) + { + $this->add_commercial($user, $user->id); + } - if ($ret >= 0) - { - // Call trigger - $result=$this->call_trigger('COMPANY_CREATE',$user); - if ($result < 0) $error++; - // End call triggers - } - else $error++; + if ($ret >= 0) + { + // Call trigger + $result=$this->call_trigger('COMPANY_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + } + else $error++; - if (! $error) - { - dol_syslog(get_class($this)."::Create success id=".$this->id); - $this->db->commit(); - return $this->id; - } - else - { - dol_syslog(get_class($this)."::Create echec update ".$this->error." ".join(',',$this->errors), LOG_ERR); - $this->db->rollback(); - return -4; - } - } - else - { - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name); // duplicate on a field (code or profid or ...) - $result=-1; - } - else - { - $this->error=$this->db->lasterror(); - $result=-2; - } - $this->db->rollback(); - return $result; - } + if (! $error) + { + dol_syslog(get_class($this)."::Create success id=".$this->id); + $this->db->commit(); + return $this->id; + } + else + { + dol_syslog(get_class($this)."::Create echec update ".$this->error." ".join(',',$this->errors), LOG_ERR); + $this->db->rollback(); + return -4; + } + } + else + { + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name); // duplicate on a field (code or profid or ...) + $result=-1; + } + else + { + $this->error=$this->db->lasterror(); + $result=-2; + } + $this->db->rollback(); + return $result; + } - } - else - { - $this->db->rollback(); - dol_syslog(get_class($this)."::Create fails verify ".join(',',$this->errors), LOG_WARNING); - return -3; - } - } + } + else + { + $this->db->rollback(); + dol_syslog(get_class($this)."::Create fails verify ".join(',',$this->errors), LOG_WARNING); + return -3; + } + } - /** - * Create a contact/address from thirdparty - * - * @param User $user Object user - * @return int <0 if KO, >0 if OK - */ - function create_individual(User $user) - { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $contact=new Contact($this->db); + /** + * Create a contact/address from thirdparty + * + * @param User $user Object user + * @return int <0 if KO, >0 if OK + */ + function create_individual(User $user) + { + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + $contact=new Contact($this->db); - $contact->name = $this->name_bis; - $contact->firstname = $this->firstname; - $contact->civility_id = $this->civility_id; - $contact->socid = $this->id; // fk_soc - $contact->statut = 1; - $contact->priv = 0; - $contact->country_id = $this->country_id; - $contact->state_id = $this->state_id; - $contact->address = $this->address; - $contact->email = $this->email; - $contact->zip = $this->zip; - $contact->town = $this->town; - $contact->phone_pro = $this->phone; + $contact->name = $this->name_bis; + $contact->firstname = $this->firstname; + $contact->civility_id = $this->civility_id; + $contact->socid = $this->id; // fk_soc + $contact->statut = 1; + $contact->priv = 0; + $contact->country_id = $this->country_id; + $contact->state_id = $this->state_id; + $contact->address = $this->address; + $contact->email = $this->email; + $contact->zip = $this->zip; + $contact->town = $this->town; + $contact->phone_pro = $this->phone; - $result = $contact->create($user); - if ($result < 0) - { - $this->error = $contact->error; - $this->errors = $contact->errors; - dol_syslog(get_class($this)."::create_individual ERROR:" . $this->error, LOG_ERR); - } + $result = $contact->create($user); + if ($result < 0) + { + $this->error = $contact->error; + $this->errors = $contact->errors; + dol_syslog(get_class($this)."::create_individual ERROR:" . $this->error, LOG_ERR); + } - return $result; - } + return $result; + } - /** - * Check properties of third party are ok (like name, third party codes, ...) - * Used before an add or update. - * - * @return int 0 if OK, <0 if KO - */ - function verify() - { - global $conf, $langs, $mysoc; + /** + * Check properties of third party are ok (like name, third party codes, ...) + * Used before an add or update. + * + * @return int 0 if OK, <0 if KO + */ + function verify() + { + global $conf, $langs, $mysoc; - $error = 0; - $this->errors=array(); + $error = 0; + $this->errors=array(); - $result = 0; - $this->name = trim($this->name); - $this->nom=$this->name; // For backward compatibility + $result = 0; + $this->name = trim($this->name); + $this->nom=$this->name; // For backward compatibility - if (! $this->name) - { - $this->errors[] = 'ErrorBadThirdPartyName'; - $result = -2; - } + if (! $this->name) + { + $this->errors[] = 'ErrorBadThirdPartyName'; + $result = -2; + } - if ($this->client) - { - $rescode = $this->check_codeclient(); - if ($rescode <> 0) - { - if ($rescode == -1) - { - $this->errors[] = 'ErrorBadCustomerCodeSyntax'; - } - if ($rescode == -2) - { - $this->errors[] = 'ErrorCustomerCodeRequired'; - } - if ($rescode == -3) - { - $this->errors[] = 'ErrorCustomerCodeAlreadyUsed'; - } - if ($rescode == -4) - { - $this->errors[] = 'ErrorPrefixRequired'; - } - $result = -3; - } - } + if ($this->client) + { + $rescode = $this->check_codeclient(); + if ($rescode <> 0) + { + if ($rescode == -1) + { + $this->errors[] = 'ErrorBadCustomerCodeSyntax'; + } + if ($rescode == -2) + { + $this->errors[] = 'ErrorCustomerCodeRequired'; + } + if ($rescode == -3) + { + $this->errors[] = 'ErrorCustomerCodeAlreadyUsed'; + } + if ($rescode == -4) + { + $this->errors[] = 'ErrorPrefixRequired'; + } + $result = -3; + } + } - if ($this->fournisseur) - { - $rescode = $this->check_codefournisseur(); - if ($rescode <> 0) - { - if ($rescode == -1) - { - $this->errors[] = 'ErrorBadSupplierCodeSyntax'; - } - if ($rescode == -2) - { - $this->errors[] = 'ErrorSupplierCodeRequired'; - } - if ($rescode == -3) - { - $this->errors[] = 'ErrorSupplierCodeAlreadyUsed'; - } - if ($rescode == -5) - { - $this->errors[] = 'ErrorprefixRequired'; - } - $result = -3; - } - } + if ($this->fournisseur) + { + $rescode = $this->check_codefournisseur(); + if ($rescode <> 0) + { + if ($rescode == -1) + { + $this->errors[] = 'ErrorBadSupplierCodeSyntax'; + } + if ($rescode == -2) + { + $this->errors[] = 'ErrorSupplierCodeRequired'; + } + if ($rescode == -3) + { + $this->errors[] = 'ErrorSupplierCodeAlreadyUsed'; + } + if ($rescode == -5) + { + $this->errors[] = 'ErrorprefixRequired'; + } + $result = -3; + } + } - // Check for duplicate or mandatory fields defined into setup - $array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL'); - foreach($array_to_check as $key) - { - $keymin=strtolower($key); - $i=(int) preg_replace('/[^0-9]/','',$key); - $vallabel=$this->$keymin; + // Check for duplicate or mandatory fields defined into setup + $array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL'); + foreach($array_to_check as $key) + { + $keymin=strtolower($key); + $i=(int) preg_replace('/[^0-9]/','',$key); + $vallabel=$this->$keymin; - if ($i > 0) - { - if ($this->isACompany()) - { - // Check for unicity - if ($vallabel && $this->id_prof_verifiable($i)) - { - if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) - { - $langs->load("errors"); - $error++; $this->errors[] = $langs->transcountry('ProfId'.$i, $this->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; - } - } + if ($i > 0) + { + if ($this->isACompany()) + { + // Check for unicity + if ($vallabel && $this->id_prof_verifiable($i)) + { + if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) + { + $langs->load("errors"); + $error++; $this->errors[] = $langs->transcountry('ProfId'.$i, $this->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; + } + } - // Check for mandatory prof id (but only if country is other than ours) - if ($mysoc->country_id > 0 && $this->country_id == $mysoc->country_id) - { - $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) - { - $langs->load("errors"); - $error++; - $this->errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $this->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')'; - } - } - } - } - else - { - //var_dump($conf->global->SOCIETE_EMAIL_MANDATORY); - if ($key == 'EMAIL') - { - // Check for unicity - if ($vallabel) - { - if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) - { - $langs->load("errors"); - $error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; - } - } + // Check for mandatory prof id (but only if country is other than ours) + if ($mysoc->country_id > 0 && $this->country_id == $mysoc->country_id) + { + $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) + { + $langs->load("errors"); + $error++; + $this->errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $this->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')'; + } + } + } + } + else + { + //var_dump($conf->global->SOCIETE_EMAIL_MANDATORY); + if ($key == 'EMAIL') + { + // Check for unicity + if ($vallabel) + { + if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) + { + $langs->load("errors"); + $error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; + } + } - // Check for mandatory - if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY) && ! isValidEMail($this->email)) - { - $langs->load("errors"); - $error++; - $this->errors[] = $langs->trans("ErrorBadEMail", $this->email).' ('.$langs->trans("ForbiddenBySetupRules").')'; - } - } - } - } + // Check for mandatory + if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY) && ! isValidEMail($this->email)) + { + $langs->load("errors"); + $error++; + $this->errors[] = $langs->trans("ErrorBadEMail", $this->email).' ('.$langs->trans("ForbiddenBySetupRules").')'; + } + } + } + } - if ($error) $result = -4; + if ($error) $result = -4; - return $result; - } + return $result; + } - /** - * Update parameters of third party - * - * @param int $id id societe - * @param User $user Utilisateur qui demande la mise a jour - * @param int $call_trigger 0=non, 1=oui - * @param int $allowmodcodeclient Inclut modif code client et code compta - * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur - * @param string $action 'add' or 'update' - * @param int $nosyncmember Do not synchronize info of linked member - * @return int <0 if KO, >=0 if OK - */ - function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) - { - global $langs,$conf,$hookmanager; - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + /** + * Update parameters of third party + * + * @param int $id id societe + * @param User $user Utilisateur qui demande la mise a jour + * @param int $call_trigger 0=non, 1=oui + * @param int $allowmodcodeclient Inclut modif code client et code compta + * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur + * @param string $action 'add' or 'update' + * @param int $nosyncmember Do not synchronize info of linked member + * @return int <0 if KO, >=0 if OK + */ + function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) + { + global $langs,$conf,$hookmanager; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $error=0; - dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); + dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); - $now=dol_now(); + $now=dol_now(); - // Clean parameters - $this->id = $id; - $this->name = $this->name?trim($this->name):trim($this->nom); - $this->nom = $this->name; // For backward compatibility - $this->name_alias = trim($this->name_alias); - $this->ref_ext = trim($this->ref_ext); - $this->address = $this->address?trim($this->address):trim($this->address); - $this->zip = $this->zip?trim($this->zip):trim($this->zip); - $this->town = $this->town?trim($this->town):trim($this->town); - $this->state_id = trim($this->state_id); - $this->country_id = ($this->country_id > 0)?$this->country_id:0; - $this->phone = trim($this->phone); - $this->phone = preg_replace("/\s/","",$this->phone); - $this->phone = preg_replace("/\./","",$this->phone); - $this->fax = trim($this->fax); - $this->fax = preg_replace("/\s/","",$this->fax); - $this->fax = preg_replace("/\./","",$this->fax); - $this->email = trim($this->email); - $this->skype = trim($this->skype); - $this->url = $this->url?clean_url($this->url,0):''; - $this->idprof1 = trim($this->idprof1); - $this->idprof2 = trim($this->idprof2); - $this->idprof3 = trim($this->idprof3); - $this->idprof4 = trim($this->idprof4); - $this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):''); - $this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):''); - $this->prefix_comm = trim($this->prefix_comm); - $this->outstanding_limit = price2num($this->outstanding_limit); + // Clean parameters + $this->id = $id; + $this->name = $this->name?trim($this->name):trim($this->nom); + $this->nom = $this->name; // For backward compatibility + $this->name_alias = trim($this->name_alias); + $this->ref_ext = trim($this->ref_ext); + $this->address = $this->address?trim($this->address):trim($this->address); + $this->zip = $this->zip?trim($this->zip):trim($this->zip); + $this->town = $this->town?trim($this->town):trim($this->town); + $this->state_id = trim($this->state_id); + $this->country_id = ($this->country_id > 0)?$this->country_id:0; + $this->phone = trim($this->phone); + $this->phone = preg_replace("/\s/","",$this->phone); + $this->phone = preg_replace("/\./","",$this->phone); + $this->fax = trim($this->fax); + $this->fax = preg_replace("/\s/","",$this->fax); + $this->fax = preg_replace("/\./","",$this->fax); + $this->email = trim($this->email); + $this->skype = trim($this->skype); + $this->url = $this->url?clean_url($this->url,0):''; + $this->idprof1 = trim($this->idprof1); + $this->idprof2 = trim($this->idprof2); + $this->idprof3 = trim($this->idprof3); + $this->idprof4 = trim($this->idprof4); + $this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):''); + $this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):''); + $this->prefix_comm = trim($this->prefix_comm); + $this->outstanding_limit = price2num($this->outstanding_limit); - $this->tva_assuj = trim($this->tva_assuj); - $this->tva_intra = dol_sanitizeFileName($this->tva_intra,''); - if (empty($this->status)) $this->status = 0; + $this->tva_assuj = trim($this->tva_assuj); + $this->tva_intra = dol_sanitizeFileName($this->tva_intra,''); + if (empty($this->status)) $this->status = 0; if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) @@ -758,490 +758,490 @@ class Societe extends CommonObject $this->fk_multicurrency = 0; } - // Local taxes - $this->localtax1_assuj=trim($this->localtax1_assuj); - $this->localtax2_assuj=trim($this->localtax2_assuj); + // Local taxes + $this->localtax1_assuj=trim($this->localtax1_assuj); + $this->localtax2_assuj=trim($this->localtax2_assuj); - $this->localtax1_value=trim($this->localtax1_value); - $this->localtax2_value=trim($this->localtax2_value); + $this->localtax1_value=trim($this->localtax1_value); + $this->localtax2_value=trim($this->localtax2_value); - if ($this->capital != '') $this->capital=price2num(trim($this->capital)); - if (! is_numeric($this->capital)) $this->capital = ''; // '' = undef + if ($this->capital != '') $this->capital=price2num(trim($this->capital)); + if (! is_numeric($this->capital)) $this->capital = ''; // '' = undef - $this->effectif_id=trim($this->effectif_id); - $this->forme_juridique_code=trim($this->forme_juridique_code); + $this->effectif_id=trim($this->effectif_id); + $this->forme_juridique_code=trim($this->forme_juridique_code); - //Gencod - $this->barcode=trim($this->barcode); + //Gencod + $this->barcode=trim($this->barcode); - // For automatic creation - if ($this->code_client == -1) $this->get_codeclient($this,0); - if ($this->code_fournisseur == -1) $this->get_codefournisseur($this,1); + // For automatic creation + if ($this->code_client == -1) $this->get_codeclient($this,0); + if ($this->code_fournisseur == -1) $this->get_codefournisseur($this,1); - $this->code_compta=trim($this->code_compta); - $this->code_compta_fournisseur=trim($this->code_compta_fournisseur); + $this->code_compta=trim($this->code_compta); + $this->code_compta_fournisseur=trim($this->code_compta_fournisseur); - // Check parameters. More tests are done later in the ->verify() - if (! is_numeric($this->client) && ! is_numeric($this->fournisseur)) - { - $langs->load("errors"); - $this->error = $langs->trans("BadValueForParameterClientOrSupplier"); - return -1; - } + // Check parameters. More tests are done later in the ->verify() + if (! is_numeric($this->client) && ! is_numeric($this->fournisseur)) + { + $langs->load("errors"); + $this->error = $langs->trans("BadValueForParameterClientOrSupplier"); + return -1; + } - $customer=false; - if (! empty($allowmodcodeclient) && ! empty($this->client)) - { - // Attention get_codecompta peut modifier le code suivant le module utilise - if (empty($this->code_compta)) - { - $ret=$this->get_codecompta('customer'); - if ($ret < 0) return -1; - } + $customer=false; + if (! empty($allowmodcodeclient) && ! empty($this->client)) + { + // Attention get_codecompta peut modifier le code suivant le module utilise + if (empty($this->code_compta)) + { + $ret=$this->get_codecompta('customer'); + if ($ret < 0) return -1; + } - $customer=true; - } + $customer=true; + } - $supplier=false; - if (! empty($allowmodcodefournisseur) && ! empty($this->fournisseur)) - { - // Attention get_codecompta peut modifier le code suivant le module utilise - if (empty($this->code_compta_fournisseur)) - { - $ret=$this->get_codecompta('supplier'); - if ($ret < 0) return -1; - } + $supplier=false; + if (! empty($allowmodcodefournisseur) && ! empty($this->fournisseur)) + { + // Attention get_codecompta peut modifier le code suivant le module utilise + if (empty($this->code_compta_fournisseur)) + { + $ret=$this->get_codecompta('supplier'); + if ($ret < 0) return -1; + } - $supplier=true; - } + $supplier=true; + } - //Web services - $this->webservices_url = $this->webservices_url?clean_url($this->webservices_url,0):''; - $this->webservices_key = trim($this->webservices_key); + //Web services + $this->webservices_url = $this->webservices_url?clean_url($this->webservices_url,0):''; + $this->webservices_key = trim($this->webservices_key); - //Incoterms - $this->fk_incoterms = (int) $this->fk_incoterms; + //Incoterms + $this->fk_incoterms = (int) $this->fk_incoterms; $this->location_incoterms = trim($this->location_incoterms); - $this->db->begin(); + $this->db->begin(); - // Check name is required and codes are ok or unique. - // If error, this->errors[] is filled - $result = 0; - if ($action != 'add') $result = $this->verify(); // We don't check when update called during a create because verify was already done + // Check name is required and codes are ok or unique. + // If error, this->errors[] is filled + $result = 0; + if ($action != 'add') $result = $this->verify(); // We don't check when update called during a create because verify was already done - if ($result >= 0) - { - dol_syslog(get_class($this)."::update verify ok or not done"); + if ($result >= 0) + { + dol_syslog(get_class($this)."::update verify ok or not done"); - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required - $sql .= ",name_alias = '" . $this->db->escape($this->name_alias) ."'"; - $sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null"); - $sql .= ",address = '" . $this->db->escape($this->address) ."'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; + $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required + $sql .= ",name_alias = '" . $this->db->escape($this->name_alias) ."'"; + $sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null"); + $sql .= ",address = '" . $this->db->escape($this->address) ."'"; - $sql .= ",zip = ".(! empty($this->zip)?"'".$this->db->escape($this->zip)."'":"null"); - $sql .= ",town = ".(! empty($this->town)?"'".$this->db->escape($this->town)."'":"null"); + $sql .= ",zip = ".(! empty($this->zip)?"'".$this->db->escape($this->zip)."'":"null"); + $sql .= ",town = ".(! empty($this->town)?"'".$this->db->escape($this->town)."'":"null"); - $sql .= ",fk_departement = '" . (! empty($this->state_id)?$this->state_id:'0') ."'"; - $sql .= ",fk_pays = '" . (! empty($this->country_id)?$this->country_id:'0') ."'"; + $sql .= ",fk_departement = '" . (! empty($this->state_id)?$this->state_id:'0') ."'"; + $sql .= ",fk_pays = '" . (! empty($this->country_id)?$this->country_id:'0') ."'"; - $sql .= ",phone = ".(! empty($this->phone)?"'".$this->db->escape($this->phone)."'":"null"); - $sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null"); - $sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null"); - $sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null"); - $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); + $sql .= ",phone = ".(! empty($this->phone)?"'".$this->db->escape($this->phone)."'":"null"); + $sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null"); + $sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null"); + $sql .= ",skype = ".(! empty($this->skype)?"'".$this->db->escape($this->skype)."'":"null"); + $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); - $sql .= ",siren = '". $this->db->escape($this->idprof1) ."'"; - $sql .= ",siret = '". $this->db->escape($this->idprof2) ."'"; - $sql .= ",ape = '". $this->db->escape($this->idprof3) ."'"; - $sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'"; - $sql .= ",idprof5 = '". $this->db->escape($this->idprof5) ."'"; - $sql .= ",idprof6 = '". $this->db->escape($this->idprof6) ."'"; + $sql .= ",siren = '". $this->db->escape($this->idprof1) ."'"; + $sql .= ",siret = '". $this->db->escape($this->idprof2) ."'"; + $sql .= ",ape = '". $this->db->escape($this->idprof3) ."'"; + $sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'"; + $sql .= ",idprof5 = '". $this->db->escape($this->idprof5) ."'"; + $sql .= ",idprof6 = '". $this->db->escape($this->idprof6) ."'"; - $sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->db->escape($this->tva_assuj)."'":"null"); - $sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'"; - $sql .= ",status = " .$this->status; + $sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->db->escape($this->tva_assuj)."'":"null"); + $sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'"; + $sql .= ",status = " .$this->status; - // Local taxes - $sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->db->escape($this->localtax1_assuj)."'":"null"); - $sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->db->escape($this->localtax2_assuj)."'":"null"); - if($this->localtax1_assuj==1) - { - if($this->localtax1_value!='') - { - $sql .=",localtax1_value =".$this->localtax1_value; - } - else $sql .=",localtax1_value =0.000"; + // Local taxes + $sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->db->escape($this->localtax1_assuj)."'":"null"); + $sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->db->escape($this->localtax2_assuj)."'":"null"); + if($this->localtax1_assuj==1) + { + if($this->localtax1_value!='') + { + $sql .=",localtax1_value =".$this->localtax1_value; + } + else $sql .=",localtax1_value =0.000"; - } - else $sql .=",localtax1_value =0.000"; + } + else $sql .=",localtax1_value =0.000"; - if($this->localtax2_assuj==1) - { - if($this->localtax2_value!='') - { - $sql .=",localtax2_value =".$this->localtax2_value; - } - else $sql .=",localtax2_value =0.000"; + if($this->localtax2_assuj==1) + { + if($this->localtax2_value!='') + { + $sql .=",localtax2_value =".$this->localtax2_value; + } + else $sql .=",localtax2_value =0.000"; - } - else $sql .=",localtax2_value =0.000"; + } + else $sql .=",localtax2_value =0.000"; - $sql .= ",capital = ".($this->capital == '' ? "null" : $this->capital); + $sql .= ",capital = ".($this->capital == '' ? "null" : $this->capital); - $sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null"); + $sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null"); - $sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null"); - if (isset($this->stcomm_id)) - { - $sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? $this->stcomm_id : "0"); - } - $sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0"); + $sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null"); + if (isset($this->stcomm_id)) + { + $sql .= ",fk_stcomm=".($this->stcomm_id > 0 ? $this->stcomm_id : "0"); + } + $sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0"); - $sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null"); + $sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null"); - $sql .= ",mode_reglement = ".(! empty($this->mode_reglement_id)?"'".$this->db->escape($this->mode_reglement_id)."'":"null"); - $sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null"); - $sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null"); - $sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null"); - $sql .= ",fk_shipping_method = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null"); + $sql .= ",mode_reglement = ".(! empty($this->mode_reglement_id)?"'".$this->db->escape($this->mode_reglement_id)."'":"null"); + $sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null"); + $sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null"); + $sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null"); + $sql .= ",fk_shipping_method = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null"); - $sql .= ",client = " . (! empty($this->client)?$this->client:0); - $sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0); - $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); - $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null"); - $sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null"); - $sql .= ",outstanding_limit= ".($this->outstanding_limit!=''?$this->outstanding_limit:'null'); - $sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'"; + $sql .= ",client = " . (! empty($this->client)?$this->client:0); + $sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0); + $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); + $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null"); + $sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null"); + $sql .= ",outstanding_limit= ".($this->outstanding_limit!=''?$this->outstanding_limit:'null'); + $sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'"; - $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); - $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); + $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); + $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); //Incoterms $sql.= ", fk_incoterms = ".$this->fk_incoterms; $sql.= ", location_incoterms = ".(! empty($this->location_incoterms)?"'".$this->db->escape($this->location_incoterms)."'":"null"); - if ($customer) - { - $sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null"); - $sql .= ", code_compta = ".(! empty($this->code_compta)?"'".$this->db->escape($this->code_compta)."'":"null"); - } + if ($customer) + { + $sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null"); + $sql .= ", code_compta = ".(! empty($this->code_compta)?"'".$this->db->escape($this->code_compta)."'":"null"); + } - if ($supplier) - { - $sql .= ", code_fournisseur = ".(! empty($this->code_fournisseur)?"'".$this->db->escape($this->code_fournisseur)."'":"null"); - $sql .= ", code_compta_fournisseur = ".(! empty($this->code_compta_fournisseur)?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null"); - } - $sql .= ", fk_user_modif = ".(! empty($user->id)?"'".$user->id."'":"null"); + if ($supplier) + { + $sql .= ", code_fournisseur = ".(! empty($this->code_fournisseur)?"'".$this->db->escape($this->code_fournisseur)."'":"null"); + $sql .= ", code_compta_fournisseur = ".(! empty($this->code_compta_fournisseur)?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null"); + } + $sql .= ", fk_user_modif = ".(! empty($user->id)?"'".$user->id."'":"null"); $sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency; $sql .= ', multicurrency_code = \''.$this->db->escape($this->multicurrency_code)."'"; - $sql .= " WHERE rowid = '" . $id ."'"; + $sql .= " WHERE rowid = '" . $id ."'"; - $resql=$this->db->query($sql); - if ($resql) - { - unset($this->country_code); // We clean this because it may have been changed after an update of country_id - unset($this->country); - unset($this->state_code); - unset($this->state); - - $nbrowsaffected = $this->db->affected_rows($resql); - - if (! $error && $nbrowsaffected) - { - // Update information on linked member if it is an update - if (! $nosyncmember && ! empty($conf->adherent->enabled)) - { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - - dol_syslog(get_class($this)."::update update linked member"); - - $lmember=new Adherent($this->db); - $result=$lmember->fetch(0, 0, $this->id); - - if ($result > 0) - { - $lmember->societe=$this->name; - //$lmember->firstname=$this->firstname?$this->firstname:$lmember->firstname; // We keep firstname and lastname of member unchanged - //$lmember->lastname=$this->lastname?$this->lastname:$lmember->lastname; // We keep firstname and lastname of member unchanged - $lmember->address=$this->address; - $lmember->email=$this->email; - $lmember->skype=$this->skype; - $lmember->phone=$this->phone; - - $result=$lmember->update($user,0,1,1,1); // Use nosync to 1 to avoid cyclic updates - if ($result < 0) - { - $this->error=$lmember->error; - dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); - $error++; - } - } - else if ($result < 0) - { - $this->error=$lmember->error; - $error++; - } - } - } - - $action='update'; - - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('thirdpartydao')); - $parameters=array('socid'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; - - if (! $error && $call_trigger) - { - // Call trigger - $result=$this->call_trigger('COMPANY_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers - } - - if (! $error) - { - dol_syslog(get_class($this)."::Update success"); - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } - else + $resql=$this->db->query($sql); + if ($resql) { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - // Doublon - $this->error = $langs->trans("ErrorDuplicateField"); - $result = -1; - } - else - { - $this->error = $this->db->lasterror(); - $result = -2; - } - $this->db->rollback(); - return $result; - } - } - else - { - $this->db->rollback(); - dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING); - return -3; - } - } + unset($this->country_code); // We clean this because it may have been changed after an update of country_id + unset($this->country); + unset($this->state_code); + unset($this->state); - /** - * Load a third party from database into memory - * - * @param int $rowid Id of third party to load - * @param string $ref Reference of third party, name (Warning, this can return several records) - * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) - * @param string $ref_int Internal reference of third party (not used by dolibarr) - * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records) - * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) - * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) - * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) - * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records) - * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) - * @param string $email Email (Warning, this can return several records) - * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. - */ - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='') - { - global $langs; - global $conf; + $nbrowsaffected = $this->db->affected_rows($resql); - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1; + if (! $error && $nbrowsaffected) + { + // Update information on linked member if it is an update + if (! $nosyncmember && ! empty($conf->adherent->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; - $sql .= ', s.status'; - $sql .= ', s.price_level'; - $sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif'; - $sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; - $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; - $sql .= ', s.capital, s.tva_intra'; - $sql .= ', s.fk_typent as typent_id'; - $sql .= ', s.fk_effectif as effectif_id'; - $sql .= ', s.fk_forme_juridique as forme_juridique_code'; - $sql .= ', s.webservices_url, s.webservices_key'; - $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; - $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; - $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; - $sql .= ', s.fk_shipping_method'; - $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; + dol_syslog(get_class($this)."::update update linked member"); + + $lmember=new Adherent($this->db); + $result=$lmember->fetch(0, 0, $this->id); + + if ($result > 0) + { + $lmember->societe=$this->name; + //$lmember->firstname=$this->firstname?$this->firstname:$lmember->firstname; // We keep firstname and lastname of member unchanged + //$lmember->lastname=$this->lastname?$this->lastname:$lmember->lastname; // We keep firstname and lastname of member unchanged + $lmember->address=$this->address; + $lmember->email=$this->email; + $lmember->skype=$this->skype; + $lmember->phone=$this->phone; + + $result=$lmember->update($user,0,1,1,1); // Use nosync to 1 to avoid cyclic updates + if ($result < 0) + { + $this->error=$lmember->error; + dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); + $error++; + } + } + else if ($result < 0) + { + $this->error=$lmember->error; + $error++; + } + } + } + + $action='update'; + + // Actions on extra fields (by external module or standard code) + // TODO le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('thirdpartydao')); + $parameters=array('socid'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + + if (! $error && $call_trigger) + { + // Call trigger + $result=$this->call_trigger('COMPANY_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + dol_syslog(get_class($this)."::Update success"); + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + else + { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + // Doublon + $this->error = $langs->trans("ErrorDuplicateField"); + $result = -1; + } + else + { + $this->error = $this->db->lasterror(); + $result = -2; + } + $this->db->rollback(); + return $result; + } + } + else + { + $this->db->rollback(); + dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING); + return -3; + } + } + + /** + * Load a third party from database into memory + * + * @param int $rowid Id of third party to load + * @param string $ref Reference of third party, name (Warning, this can return several records) + * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) + * @param string $ref_int Internal reference of third party (not used by dolibarr) + * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records) + * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records) + * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records) + * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) + * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records) + * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) + * @param string $email Email (Warning, this can return several records) + * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. + */ + function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='') + { + global $langs; + global $conf; + + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1; + + $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; + $sql .= ', s.status'; + $sql .= ', s.price_level'; + $sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif'; + $sql .= ', s.phone, s.fax, s.email, s.skype, s.url, s.zip, s.town, s.note_private, s.note_public, s.model_pdf, s.client, s.fournisseur'; + $sql .= ', s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6'; + $sql .= ', s.capital, s.tva_intra'; + $sql .= ', s.fk_typent as typent_id'; + $sql .= ', s.fk_effectif as effectif_id'; + $sql .= ', s.fk_forme_juridique as forme_juridique_code'; + $sql .= ', s.webservices_url, s.webservices_key'; + $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; + $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; + $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; + $sql .= ', s.fk_shipping_method'; + $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; $sql .= ', s.fk_multicurrency, s.multicurrency_code'; - $sql .= ', fj.libelle as forme_juridique'; - $sql .= ', e.libelle as effectif'; - $sql .= ', c.code as country_code, c.label as country'; - $sql .= ', d.code_departement as state_code, d.nom as state'; - $sql .= ', st.libelle as stcomm'; - $sql .= ', te.code as typent_code'; + $sql .= ', fj.libelle as forme_juridique'; + $sql .= ', e.libelle as effectif'; + $sql .= ', c.code as country_code, c.label as country'; + $sql .= ', d.code_departement as state_code, d.nom as state'; + $sql .= ', st.libelle as stcomm'; + $sql .= ', te.code as typent_code'; $sql .= ', i.libelle as libelle_incoterms'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as e ON s.fk_effectif = e.id'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as fj ON s.fk_forme_juridique = fj.code'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as e ON s.fk_effectif = e.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as fj ON s.fk_forme_juridique = fj.code'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; $sql .= ' WHERE s.entity IN ('.getEntity($this->element, 1).')'; - if ($rowid) $sql .= ' AND s.rowid = '.$rowid; - if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; - if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; - if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; - if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; - if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; - if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; - if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; - if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; - if ($email) $sql .= " AND email = '".$this->db->escape($email)."'"; + if ($rowid) $sql .= ' AND s.rowid = '.$rowid; + if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; + if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; + if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; + if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; + if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; + if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; + if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; + if ($email) $sql .= " AND email = '".$this->db->escape($email)."'"; - $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->num_rows($resql); - if ($num > 1) - { - $this->error='Fetch found several records. Rename one of tirdparties to avoid duplicate.'; - dol_syslog($this->error, LOG_ERR); - $result = -2; - } - elseif ($num) // $num = 1 - { - $obj = $this->db->fetch_object($resql); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + if ($num > 1) + { + $this->error='Fetch found several records. Rename one of tirdparties to avoid duplicate.'; + dol_syslog($this->error, LOG_ERR); + $result = -2; + } + elseif ($num) // $num = 1 + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->entity = $obj->entity; - $this->canvas = $obj->canvas; + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->canvas = $obj->canvas; - $this->ref = $obj->rowid; - $this->name = $obj->name; - $this->nom = $obj->name; // deprecated - $this->name_alias = $obj->name_alias; - $this->ref_ext = $obj->ref_ext; - $this->ref_int = $obj->ref_int; + $this->ref = $obj->rowid; + $this->name = $obj->name; + $this->nom = $obj->name; // deprecated + $this->name_alias = $obj->name_alias; + $this->ref_ext = $obj->ref_ext; + $this->ref_int = $obj->ref_int; - $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_modification = $this->db->jdate($obj->date_modification); - $this->user_creation = $obj->fk_user_creat; - $this->user_modification = $obj->fk_user_modif; + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_modification = $this->db->jdate($obj->date_modification); + $this->user_creation = $obj->fk_user_creat; + $this->user_modification = $obj->fk_user_modif; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; - $this->country_id = $obj->country_id; - $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_id?$obj->country_code:''; + $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; - $this->state_id = $obj->fk_departement; - $this->state_code = $obj->state_code; - $this->state = ($obj->state!='-'?$obj->state:''); + $this->state_id = $obj->fk_departement; + $this->state_code = $obj->state_code; + $this->state = ($obj->state!='-'?$obj->state:''); - $transcode=$langs->trans('StatusProspect'.$obj->fk_stcomm); - $libelle=($transcode!='StatusProspect'.$obj->fk_stcomm?$transcode:$obj->stcomm); - $this->stcomm_id = $obj->fk_stcomm; // id statut commercial - $this->statut_commercial = $libelle; // libelle statut commercial + $transcode=$langs->trans('StatusProspect'.$obj->fk_stcomm); + $libelle=($transcode!='StatusProspect'.$obj->fk_stcomm?$transcode:$obj->stcomm); + $this->stcomm_id = $obj->fk_stcomm; // id statut commercial + $this->statut_commercial = $libelle; // libelle statut commercial - $this->email = $obj->email; - $this->skype = $obj->skype; - $this->url = $obj->url; - $this->phone = $obj->phone; - $this->fax = $obj->fax; + $this->email = $obj->email; + $this->skype = $obj->skype; + $this->url = $obj->url; + $this->phone = $obj->phone; + $this->fax = $obj->fax; - $this->parent = $obj->parent; + $this->parent = $obj->parent; - $this->idprof1 = $obj->idprof1; - $this->idprof2 = $obj->idprof2; - $this->idprof3 = $obj->idprof3; - $this->idprof4 = $obj->idprof4; - $this->idprof5 = $obj->idprof5; - $this->idprof6 = $obj->idprof6; + $this->idprof1 = $obj->idprof1; + $this->idprof2 = $obj->idprof2; + $this->idprof3 = $obj->idprof3; + $this->idprof4 = $obj->idprof4; + $this->idprof5 = $obj->idprof5; + $this->idprof6 = $obj->idprof6; - $this->capital = $obj->capital; + $this->capital = $obj->capital; - $this->code_client = $obj->code_client; - $this->code_fournisseur = $obj->code_fournisseur; + $this->code_client = $obj->code_client; + $this->code_fournisseur = $obj->code_fournisseur; - $this->code_compta = $obj->code_compta; - $this->code_compta_fournisseur = $obj->code_compta_fournisseur; + $this->code_compta = $obj->code_compta; + $this->code_compta_fournisseur = $obj->code_compta_fournisseur; - $this->barcode = $obj->barcode; + $this->barcode = $obj->barcode; - $this->tva_assuj = $obj->tva_assuj; - $this->tva_intra = $obj->tva_intra; - $this->status = $obj->status; + $this->tva_assuj = $obj->tva_assuj; + $this->tva_intra = $obj->tva_intra; + $this->status = $obj->status; - // Local Taxes - $this->localtax1_assuj = $obj->localtax1_assuj; - $this->localtax2_assuj = $obj->localtax2_assuj; + // Local Taxes + $this->localtax1_assuj = $obj->localtax1_assuj; + $this->localtax2_assuj = $obj->localtax2_assuj; - $this->localtax1_value = $obj->localtax1_value; - $this->localtax2_value = $obj->localtax2_value; + $this->localtax1_value = $obj->localtax1_value; + $this->localtax2_value = $obj->localtax2_value; - $this->typent_id = $obj->typent_id; - $this->typent_code = $obj->typent_code; + $this->typent_id = $obj->typent_id; + $this->typent_code = $obj->typent_code; - $this->effectif_id = $obj->effectif_id; - $this->effectif = $obj->effectif_id?$obj->effectif:''; + $this->effectif_id = $obj->effectif_id; + $this->effectif = $obj->effectif_id?$obj->effectif:''; - $this->forme_juridique_code= $obj->forme_juridique_code; - $this->forme_juridique = $obj->forme_juridique_code?$obj->forme_juridique:''; + $this->forme_juridique_code= $obj->forme_juridique_code; + $this->forme_juridique = $obj->forme_juridique_code?$obj->forme_juridique:''; - $this->fk_prospectlevel = $obj->fk_prospectlevel; + $this->fk_prospectlevel = $obj->fk_prospectlevel; - $this->prefix_comm = $obj->prefix_comm; + $this->prefix_comm = $obj->prefix_comm; - $this->remise_percent = $obj->remise_client; - $this->mode_reglement_id = $obj->mode_reglement; - $this->cond_reglement_id = $obj->cond_reglement; - $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; - $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; - $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; + $this->remise_percent = $obj->remise_client; + $this->mode_reglement_id = $obj->mode_reglement; + $this->cond_reglement_id = $obj->cond_reglement; + $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; + $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; + $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; $this->fk_account = $obj->fk_account; - $this->client = $obj->client; - $this->fournisseur = $obj->fournisseur; + $this->client = $obj->client; + $this->fournisseur = $obj->fournisseur; - $this->note = $obj->note_private; // TODO Deprecated for backward comtability - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->modelpdf = $obj->model_pdf; - $this->default_lang = $obj->default_lang; - $this->logo = $obj->logo; + $this->note = $obj->note_private; // TODO Deprecated for backward comtability + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->modelpdf = $obj->model_pdf; + $this->default_lang = $obj->default_lang; + $this->logo = $obj->logo; - $this->webservices_url = $obj->webservices_url; - $this->webservices_key = $obj->webservices_key; + $this->webservices_url = $obj->webservices_url; + $this->webservices_key = $obj->webservices_key; - $this->outstanding_limit = $obj->outstanding_limit; + $this->outstanding_limit = $obj->outstanding_limit; - // multiprix - $this->price_level = $obj->price_level; + // multiprix + $this->price_level = $obj->price_level; - $this->import_key = $obj->import_key; + $this->import_key = $obj->import_key; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; @@ -1252,198 +1252,198 @@ class Societe extends CommonObject $this->fk_multicurrency = $obj->fk_multicurrency; $this->multicurrency_code = $obj->multicurrency_code; - $result = 1; + $result = 1; - // Retreive all extrafield for thirdparty - $this->fetch_optionals(); - } - else + // Retreive all extrafield for thirdparty + $this->fetch_optionals(); + } + else { - $result = 0; - } + $result = 0; + } - $this->db->free($resql); - } - else + $this->db->free($resql); + } + else { - $this->error=$this->db->lasterror(); - $result = -3; - } + $this->error=$this->db->lasterror(); + $result = -3; + } - // Use first price level if level not defined for third party - if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->price_level)) $this->price_level=1; + // Use first price level if level not defined for third party + if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->price_level)) $this->price_level=1; - return $result; - } + return $result; + } - /** - * Search and fetch thirparties by name - * - * @param string $name Name - * @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier) - * @param array $filters Array of couple field name/value to filter the companies with the same name - * @param boolean $exact Exact string search (true/false) - * @param boolean $case Case sensitive (true/false) - * @param boolean $similar Add test if string inside name into database, or name into database inside string. Do not use this: Not compatible with other database. - * @param string $clause Clause for filters - * @return array|int <0 if KO, array of thirdparties object if OK - */ - function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND') - { - $thirdparties = array(); + /** + * Search and fetch thirparties by name + * + * @param string $name Name + * @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier) + * @param array $filters Array of couple field name/value to filter the companies with the same name + * @param boolean $exact Exact string search (true/false) + * @param boolean $case Case sensitive (true/false) + * @param boolean $similar Add test if string inside name into database, or name into database inside string. Do not use this: Not compatible with other database. + * @param string $clause Clause for filters + * @return array|int <0 if KO, array of thirdparties object if OK + */ + function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND') + { + $thirdparties = array(); - dol_syslog("searchByName name=".$name." type=".$type." exact=".$exact); + dol_syslog("searchByName name=".$name." type=".$type." exact=".$exact); - // Check parameter - if (empty($name)) - { - $this->errors[]='ErrorBadValueForParameter'; - return -1; - } + // Check parameter + if (empty($name)) + { + $this->errors[]='ErrorBadValueForParameter'; + return -1; + } - // Generation requete recherche - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE entity IN (".getEntity('category').")"; - if (! empty($type)) - { - if ($type == 1 || $type == 2) - $sql.= " AND client = ".$type; - elseif ($type == 3) - $sql.= " AND fournisseur = 1"; - } - if (! empty($name)) - { - if (! $exact) - { - if (preg_match('/^([\*])?[^*]+([\*])?$/', $name, $regs) && count($regs) > 1) - { - $name = str_replace('*', '%', $name); - } - else - { - $name = '%'.$name.'%'; - } - } - $sql.= " AND "; - if (is_array($filters) && ! empty($filters)) - $sql.= "("; - if ($similar) - { - // For test similitude (string inside name into database, or name into database inside string) - // Do not use this. Not compatible with other database. - $sql.= "(LOCATE('".$this->db->escape($name)."', nom) > 0 OR LOCATE(nom, '".$this->db->escape($name)."') > 0)"; - } - else - { - if (! $case) - $sql.= "nom LIKE '".$this->db->escape($name)."'"; - else - $sql.= "nom LIKE BINARY '".$this->db->escape($name)."'"; - } - } - if (is_array($filters) && ! empty($filters)) - { - foreach($filters as $field => $value) - { - if (! $exact) - { - if (preg_match('/^([\*])?[^*]+([\*])?$/', $value, $regs) && count($regs) > 1) - { - $value = str_replace('*', '%', $value); - } - else - { - $value = '%'.$value.'%'; - } - } - if (! $case) - $sql.= " ".$clause." ".$field." LIKE '".$this->db->escape($value)."'"; - else - $sql.= " ".$clause." ".$field." LIKE BINARY '".$this->db->escape($value)."'"; - } - if (! empty($name)) - $sql.= ")"; - } + // Generation requete recherche + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; + $sql.= " WHERE entity IN (".getEntity('category').")"; + if (! empty($type)) + { + if ($type == 1 || $type == 2) + $sql.= " AND client = ".$type; + elseif ($type == 3) + $sql.= " AND fournisseur = 1"; + } + if (! empty($name)) + { + if (! $exact) + { + if (preg_match('/^([\*])?[^*]+([\*])?$/', $name, $regs) && count($regs) > 1) + { + $name = str_replace('*', '%', $name); + } + else + { + $name = '%'.$name.'%'; + } + } + $sql.= " AND "; + if (is_array($filters) && ! empty($filters)) + $sql.= "("; + if ($similar) + { + // For test similitude (string inside name into database, or name into database inside string) + // Do not use this. Not compatible with other database. + $sql.= "(LOCATE('".$this->db->escape($name)."', nom) > 0 OR LOCATE(nom, '".$this->db->escape($name)."') > 0)"; + } + else + { + if (! $case) + $sql.= "nom LIKE '".$this->db->escape($name)."'"; + else + $sql.= "nom LIKE BINARY '".$this->db->escape($name)."'"; + } + } + if (is_array($filters) && ! empty($filters)) + { + foreach($filters as $field => $value) + { + if (! $exact) + { + if (preg_match('/^([\*])?[^*]+([\*])?$/', $value, $regs) && count($regs) > 1) + { + $value = str_replace('*', '%', $value); + } + else + { + $value = '%'.$value.'%'; + } + } + if (! $case) + $sql.= " ".$clause." ".$field." LIKE '".$this->db->escape($value)."'"; + else + $sql.= " ".$clause." ".$field." LIKE BINARY '".$this->db->escape($value)."'"; + } + if (! empty($name)) + $sql.= ")"; + } - $res = $this->db->query($sql); - if ($res) - { - while ($rec = $this->db->fetch_array($res)) - { - $soc = new Societe($this->db); - $soc->fetch($rec['rowid']); - $thirdparties[] = $soc; - } + $res = $this->db->query($sql); + if ($res) + { + while ($rec = $this->db->fetch_array($res)) + { + $soc = new Societe($this->db); + $soc->fetch($rec['rowid']); + $thirdparties[] = $soc; + } - return $thirdparties; - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - } + return $thirdparties; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } - /** - * Delete a third party from database and all its dependencies (contacts, rib...) - * - * @param int $id Id of third party to delete - * @param User $fuser User who ask to delete thirparty - * @param int $call_trigger 0=No, 1=yes - * @return int <0 if KO, 0 if nothing done, >0 if OK - */ - function delete($id, User $fuser=null, $call_trigger=1) - { - global $langs, $conf, $user; + /** + * Delete a third party from database and all its dependencies (contacts, rib...) + * + * @param int $id Id of third party to delete + * @param User $fuser User who ask to delete thirparty + * @param int $call_trigger 0=No, 1=yes + * @return int <0 if KO, 0 if nothing done, >0 if OK + */ + function delete($id, User $fuser=null, $call_trigger=1) + { + global $langs, $conf, $user; - if (empty($fuser)) $fuser=$user; + if (empty($fuser)) $fuser=$user; - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $entity=isset($this->entity)?$this->entity:$conf->entity; + $entity=isset($this->entity)?$this->entity:$conf->entity; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $error = 0; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $error = 0; - // Test if child exists - $objectisused = $this->isObjectUsed($id); + // Test if child exists + $objectisused = $this->isObjectUsed($id); if (empty($objectisused)) { - $this->db->begin(); + $this->db->begin(); - // User is mandatory for trigger call - if (! $error && $call_trigger) - { - // Call trigger - $result=$this->call_trigger('COMPANY_DELETE',$fuser); - if ($result < 0) $error++; - // End call triggers - } + // User is mandatory for trigger call + if (! $error && $call_trigger) + { + // Call trigger + $result=$this->call_trigger('COMPANY_DELETE',$fuser); + if ($result < 0) $error++; + // End call triggers + } if (! $error) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $static_cat = new Categorie($this->db); - $toute_categs = array(); + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $static_cat = new Categorie($this->db); + $toute_categs = array(); - // Fill $toute_categs array with an array of (type => array of ("Categorie" instance)) - if ($this->client || $this->prospect) - { - $toute_categs['societe'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER); - } - if ($this->fournisseur) - { - $toute_categs['fournisseur'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER); - } + // Fill $toute_categs array with an array of (type => array of ("Categorie" instance)) + if ($this->client || $this->prospect) + { + $toute_categs['societe'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER); + } + if ($this->fournisseur) + { + $toute_categs['fournisseur'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER); + } - // Remove each "Categorie" - foreach ($toute_categs as $type => $categs_type) - { - foreach ($categs_type as $cat) - { - $cat->del_type($this, $type); - } - } + // Remove each "Categorie" + foreach ($toute_categs as $type => $categs_type) + { + foreach ($categs_type as $cat) + { + $cat->del_type($this, $type); + } + } } foreach ($this->childtablesoncascade as $tabletodelete) @@ -1460,1619 +1460,1619 @@ class Societe extends CommonObject } } - // Removed extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used - { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); - } - } + // Removed extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); + } + } - // Remove third party - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE rowid = " . $id; - if (! $this->db->query($sql)) - { - $error++; - $this->errors[] = $this->db->lasterror(); - } - } + // Remove third party + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe"; + $sql.= " WHERE rowid = " . $id; + if (! $this->db->query($sql)) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } - if (! $error) - { - $this->db->commit(); + if (! $error) + { + $this->db->commit(); - // Delete directory - if (! empty($conf->societe->multidir_output[$entity])) - { - $docdir = $conf->societe->multidir_output[$entity] . "/" . $id; - if (dol_is_dir($docdir)) - { - dol_delete_dir_recursive($docdir); - } - } + // Delete directory + if (! empty($conf->societe->multidir_output[$entity])) + { + $docdir = $conf->societe->multidir_output[$entity] . "/" . $id; + if (dol_is_dir($docdir)) + { + dol_delete_dir_recursive($docdir); + } + } - return 1; - } - else + return 1; + } + else { dol_syslog($this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } + $this->db->rollback(); + return -1; + } + } else dol_syslog("Can't remove thirdparty with id ".$id.". There is ".$objectisused." childs", LOG_WARNING); - return 0; - } + return 0; + } - /** - * Define third party as a customer - * - * @return int <0 if KO, >0 if OK - */ - function set_as_client() - { - if ($this->id) - { - $newclient=1; - if ($this->client == 2 || $this->client == 3) $newclient=3; //If prospect, we keep prospect tag - $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET client = ".$newclient; - $sql.= " WHERE rowid = " . $this->id; + /** + * Define third party as a customer + * + * @return int <0 if KO, >0 if OK + */ + function set_as_client() + { + if ($this->id) + { + $newclient=1; + if ($this->client == 2 || $this->client == 3) $newclient=3; //If prospect, we keep prospect tag + $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql.= " SET client = ".$newclient; + $sql.= " WHERE rowid = " . $this->id; - $resql=$this->db->query($sql); - if ($resql) - { - $this->client = $newclient; - return 1; - } - else return -1; - } - return 0; - } + $resql=$this->db->query($sql); + if ($resql) + { + $this->client = $newclient; + return 1; + } + else return -1; + } + return 0; + } - /** - * Definit la societe comme un client - * - * @param float $remise Valeur en % de la remise - * @param string $note Note/Motif de modification de la remise - * @param User $user Utilisateur qui definie la remise - * @return int <0 if KO, >0 if OK - */ - function set_remise_client($remise, $note, User $user) - { - global $conf, $langs; + /** + * Definit la societe comme un client + * + * @param float $remise Valeur en % de la remise + * @param string $note Note/Motif de modification de la remise + * @param User $user Utilisateur qui definie la remise + * @return int <0 if KO, >0 if OK + */ + function set_remise_client($remise, $note, User $user) + { + global $conf, $langs; - // Nettoyage parametres - $note=trim($note); - if (! $note) - { - $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason")); - return -2; - } + // Nettoyage parametres + $note=trim($note); + if (! $note) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason")); + return -2; + } - dol_syslog(get_class($this)."::set_remise_client ".$remise.", ".$note.", ".$user->id); + dol_syslog(get_class($this)."::set_remise_client ".$remise.", ".$note.", ".$user->id); - if ($this->id) - { - $this->db->begin(); + if ($this->id) + { + $this->db->begin(); - $now=dol_now(); + $now=dol_now(); - // Positionne remise courante - $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql.= " SET remise_client = '".$this->db->escape($remise)."'"; - $sql.= " WHERE rowid = " . $this->id; - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->error(); - return -1; - } + // Positionne remise courante + $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; + $sql.= " SET remise_client = '".$this->db->escape($remise)."'"; + $sql.= " WHERE rowid = " . $this->id; + $resql=$this->db->query($sql); + if (! $resql) + { + $this->db->rollback(); + $this->error=$this->db->error(); + return -1; + } - // Ecrit trace dans historique des remises - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; - $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; - $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; - $sql.= " '".$this->db->escape($note)."',"; - $sql.= " ".$user->id; - $sql.= ")"; + // Ecrit trace dans historique des remises + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; + $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; + $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; + $sql.= " '".$this->db->escape($note)."',"; + $sql.= " ".$user->id; + $sql.= ")"; - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } + $resql=$this->db->query($sql); + if (! $resql) + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; + } - $this->db->commit(); - return 1; - } - } + $this->db->commit(); + return 1; + } + } - /** - * Add a discount for third party - * - * @param float $remise Amount of discount - * @param User $user User adding discount - * @param string $desc Reason of discount - * @param float $tva_tx VAT rate - * @return int <0 if KO, id of discount record if OK - */ - function set_remise_except($remise, User $user, $desc, $tva_tx=0) - { - global $langs; + /** + * Add a discount for third party + * + * @param float $remise Amount of discount + * @param User $user User adding discount + * @param string $desc Reason of discount + * @param float $tva_tx VAT rate + * @return int <0 if KO, id of discount record if OK + */ + function set_remise_except($remise, User $user, $desc, $tva_tx=0) + { + global $langs; - // Clean parameters - $remise = price2num($remise); - $desc = trim($desc); + // Clean parameters + $remise = price2num($remise); + $desc = trim($desc); - // Check parameters - if (! $remise > 0) - { - $this->error=$langs->trans("ErrorWrongValueForParameter","1"); - return -1; - } - if (! $desc) - { - $this->error=$langs->trans("ErrorWrongValueForParameter","3"); - return -2; - } + // Check parameters + if (! $remise > 0) + { + $this->error=$langs->trans("ErrorWrongValueForParameter","1"); + return -1; + } + if (! $desc) + { + $this->error=$langs->trans("ErrorWrongValueForParameter","3"); + return -2; + } - if ($this->id) - { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + if ($this->id) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discount = new DiscountAbsolute($this->db); - $discount->fk_soc=$this->id; - $discount->amount_ht=price2num($remise,'MT'); - $discount->amount_tva=price2num($remise*$tva_tx/100,'MT'); - $discount->amount_ttc=price2num($discount->amount_ht+$discount->amount_tva,'MT'); - $discount->tva_tx=price2num($tva_tx,'MT'); - $discount->description=$desc; - $result=$discount->create($user); - if ($result > 0) - { - return $result; - } - else - { - $this->error=$discount->error; - return -3; - } - } - else return 0; - } + $discount = new DiscountAbsolute($this->db); + $discount->fk_soc=$this->id; + $discount->amount_ht=price2num($remise,'MT'); + $discount->amount_tva=price2num($remise*$tva_tx/100,'MT'); + $discount->amount_ttc=price2num($discount->amount_ht+$discount->amount_tva,'MT'); + $discount->tva_tx=price2num($tva_tx,'MT'); + $discount->description=$desc; + $result=$discount->create($user); + if ($result > 0) + { + return $result; + } + else + { + $this->error=$discount->error; + return -3; + } + } + else return 0; + } - /** - * Renvoie montant TTC des reductions/avoirs en cours disponibles de la societe - * - * @param User $user Filtre sur un user auteur des remises - * @param string $filter Filtre autre - * @param integer $maxvalue Filter on max value for discount - * @return int <0 if KO, Credit note amount otherwise - */ - function getAvailableDiscounts($user='',$filter='',$maxvalue=0) - { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + /** + * Renvoie montant TTC des reductions/avoirs en cours disponibles de la societe + * + * @param User $user Filtre sur un user auteur des remises + * @param string $filter Filtre autre + * @param integer $maxvalue Filter on max value for discount + * @return int <0 if KO, Credit note amount otherwise + */ + function getAvailableDiscounts($user='',$filter='',$maxvalue=0) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - $discountstatic=new DiscountAbsolute($this->db); - $result=$discountstatic->getAvailableDiscounts($this,$user,$filter,$maxvalue); - if ($result >= 0) - { - return $result; - } - else - { - $this->error=$discountstatic->error; - return -1; - } - } + $discountstatic=new DiscountAbsolute($this->db); + $result=$discountstatic->getAvailableDiscounts($this,$user,$filter,$maxvalue); + if ($result >= 0) + { + return $result; + } + else + { + $this->error=$discountstatic->error; + return -1; + } + } - /** - * Return array of sales representatives - * - * @param User $user Object user - * @return array Array of sales representatives of third party - */ - function getSalesRepresentatives(User $user) - { - global $conf; + /** + * Return array of sales representatives + * + * @param User $user Object user + * @return array Array of sales representatives of third party + */ + function getSalesRepresentatives(User $user) + { + global $conf; - $reparray=array(); + $reparray=array(); - $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE ((ug.fk_user = sc.fk_user"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1)"; - } - else - $sql.= " WHERE entity in (0, ".$conf->entity.")"; + $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ((ug.fk_user = sc.fk_user"; + $sql.= " AND ug.entity = ".$conf->entity.")"; + $sql.= " OR u.admin = 1)"; + } + else + $sql.= " WHERE entity in (0, ".$conf->entity.")"; - $sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; + $sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $reparray[$i]['id']=$obj->rowid; - $reparray[$i]['lastname']=$obj->lastname; - $reparray[$i]['firstname']=$obj->firstname; - $reparray[$i]['email']=$obj->email; - $reparray[$i]['statut']=$obj->statut; - $reparray[$i]['entity']=$obj->entity; - $reparray[$i]['login']=$obj->login; - $reparray[$i]['photo']=$obj->photo; - $i++; - } - return $reparray; - } - else { - dol_print_error($this->db); - return -1; - } - } + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $reparray[$i]['id']=$obj->rowid; + $reparray[$i]['lastname']=$obj->lastname; + $reparray[$i]['firstname']=$obj->firstname; + $reparray[$i]['email']=$obj->email; + $reparray[$i]['statut']=$obj->statut; + $reparray[$i]['entity']=$obj->entity; + $reparray[$i]['login']=$obj->login; + $reparray[$i]['photo']=$obj->photo; + $i++; + } + return $reparray; + } + else { + dol_print_error($this->db); + return -1; + } + } - /** - * Set the price level - * - * @param int $price_level Level of price - * @param User $user Use making change - * @return int <0 if KO, >0 if OK - */ - function set_price_level($price_level, User $user) - { - if ($this->id) - { - $now=dol_now(); + /** + * Set the price level + * + * @param int $price_level Level of price + * @param User $user Use making change + * @return int <0 if KO, >0 if OK + */ + function set_price_level($price_level, User $user) + { + if ($this->id) + { + $now=dol_now(); - $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql .= " SET price_level = '".$this->db->escape($price_level)."'"; - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql .= " SET price_level = '".$this->db->escape($price_level)."'"; + $sql .= " WHERE rowid = " . $this->id; - if (! $this->db->query($sql)) - { - dol_print_error($this->db); - return -1; - } + if (! $this->db->query($sql)) + { + dol_print_error($this->db); + return -1; + } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices"; - $sql .= " (datec, fk_soc, price_level, fk_user_author)"; - $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_prices"; + $sql .= " (datec, fk_soc, price_level, fk_user_author)"; + $sql .= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($price_level)."', ".$user->id.")"; - if (! $this->db->query($sql)) - { - dol_print_error($this->db); - return -1; - } - return 1; - } - return -1; - } + if (! $this->db->query($sql)) + { + dol_print_error($this->db); + return -1; + } + return 1; + } + return -1; + } - /** - * Add link to sales representative - * - * @param User $user Object user - * @param int $commid Id of user - * @return void - */ - function add_commercial(User $user, $commid) - { - if ($this->id > 0 && $commid > 0) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + /** + * Add link to sales representative + * + * @param User $user Object user + * @param int $commid Id of user + * @return void + */ + function add_commercial(User $user, $commid) + { + if ($this->id > 0 && $commid > 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; + $sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; - $this->db->query($sql); + $this->db->query($sql); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux"; - $sql.= " ( fk_soc, fk_user )"; - $sql.= " VALUES (".$this->id.",".$commid.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux"; + $sql.= " ( fk_soc, fk_user )"; + $sql.= " VALUES (".$this->id.",".$commid.")"; - if (! $this->db->query($sql) ) - { - dol_syslog(get_class($this)."::add_commercial Erreur"); - } - } - } + if (! $this->db->query($sql) ) + { + dol_syslog(get_class($this)."::add_commercial Erreur"); + } + } + } - /** - * Add link to sales representative - * - * @param User $user Object user - * @param int $commid Id of user - * @return void - */ - function del_commercial(User $user, $commid) - { - if ($this->id > 0 && $commid > 0) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; - $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; + /** + * Add link to sales representative + * + * @param User $user Object user + * @param int $commid Id of user + * @return void + */ + function del_commercial(User $user, $commid) + { + if ($this->id > 0 && $commid > 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; + $sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; - if (! $this->db->query($sql) ) - { - dol_syslog(get_class($this)."::del_commercial Erreur"); - } - } - } + if (! $this->db->query($sql) ) + { + dol_syslog(get_class($this)."::del_commercial Erreur"); + } + } + } - /** - * Return a link on thirdparty (with picto) - * - * @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) - * @param string $option Target of link ('', 'customer', 'prospect', 'supplier', 'project') - * @param int $maxlen Max length of name - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto=0, $option='', $maxlen=0, $notooltip=0, $save_lastsearch_value=-1) - { - global $conf, $langs, $hookmanager; + /** + * Return a link on thirdparty (with picto) + * + * @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) + * @param string $option Target of link ('', 'customer', 'prospect', 'supplier', 'project') + * @param int $maxlen Max length of name + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $maxlen=0, $notooltip=0, $save_lastsearch_value=-1) + { + global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $name=$this->name?$this->name:$this->nom; + $name=$this->name?$this->name:$this->nom; - if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto))) - { - if (($this->client) && (! empty ( $this->code_client )) - && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 - || $conf->global->SOCIETE_ADD_REF_IN_LIST == 2 - ) - ) - $code = $this->code_client . ' - '; + if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST) && (!empty($withpicto))) + { + if (($this->client) && (! empty ( $this->code_client )) + && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 + || $conf->global->SOCIETE_ADD_REF_IN_LIST == 2 + ) + ) + $code = $this->code_client . ' - '; - if (($this->fournisseur) && (! empty ( $this->code_fournisseur )) - && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 - || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 - ) - ) - $code .= $this->code_fournisseur . ' - '; + if (($this->fournisseur) && (! empty ( $this->code_fournisseur )) + && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 + || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 + ) + ) + $code .= $this->code_fournisseur . ' - '; - if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) - $name =$code.' '.$name; - else - $name =$code; - } + if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) + $name =$code.' '.$name; + else + $name =$code; + } - if (!empty($this->name_alias)) $name .= ' ('.$this->name_alias.')'; + if (!empty($this->name_alias)) $name .= ' ('.$this->name_alias.')'; - $result=''; $label=''; - $linkstart=''; $linkend=''; + $result=''; $label=''; + $linkstart=''; $linkend=''; - if (! empty($this->logo) && class_exists('Form')) - { - $label.= '
'; - $label.= Form::showphoto('societe', $this, 80, 0, 0, 'photowithmargin', 'mini'); - $label.= '
'; - } + if (! empty($this->logo) && class_exists('Form')) + { + $label.= '
'; + $label.= Form::showphoto('societe', $this, 80, 0, 0, 'photowithmargin', 'mini'); + $label.= '
'; + } - $label.= '
'; + $label.= '
'; - if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') - { - $label.= '' . $langs->trans("ShowCustomer") . ''; - $linkstart = ''; - $linkstart = ''; - $linkstart = ''; - $linkstart = ''; - $linkstart = ''; - $linkstart = ''; - $linkstart = ''; - $linkstart = ''; + $linkstart = ''; + $linkstart = ''; + $linkstart = ''; + $linkstart = ''; + $linkstart = ''; + $linkstart = ''; + $linkstart = ''; + $linkstart = ''; - $linkstart = ''; + $linkstart = 'canvas)?'&canvas='.$this->canvas:''); + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $linkstart.='&save_lastsearch_values=1'; + $linkstart.='"'; - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowCompany"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowCompany"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip"'; - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } - $hookmanager->initHooks(array('societedao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - } - $linkstart.=$linkclose.'>'; - $linkend=''; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('societedao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + } + $linkstart.=$linkclose.'>'; + $linkend=''; - global $user; - if (! $user->rights->societe->client->voir && $user->societe_id > 0 && $this->id != $user->societe_id) - { - $linkstart=''; - $linkend=''; - } + global $user; + if (! $user->rights->societe->client->voir && $user->societe_id > 0 && $this->id != $user->societe_id) + { + $linkstart=''; + $linkend=''; + } - if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1).$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$linkstart.($maxlen?dol_trunc($name,$maxlen):$name).$linkend; + if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1).$linkend); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$linkstart.($maxlen?dol_trunc($name,$maxlen):$name).$linkend; - return $result; - } + return $result; + } - /** - * Return label of status (activity, closed) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * @return string Libelle - */ - function getLibStatut($mode=0) - { - return $this->LibStatut($this->status,$mode); - } + /** + * Return label of status (activity, closed) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @return string Libelle + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } - /** - * Renvoi le libelle d'un statut donne - * - * @param int $statut Id statut - * @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 Libelle du statut - */ - function LibStatut($statut,$mode=0) - { - global $langs; - $langs->load('companies'); + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @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 Libelle du statut + */ + function LibStatut($statut,$mode=0) + { + global $langs; + $langs->load('companies'); - if ($mode == 0) - { - if ($statut==0) return $langs->trans("ActivityCeased"); - if ($statut==1) return $langs->trans("InActivity"); - } - if ($mode == 1) - { - if ($statut==0) return $langs->trans("ActivityCeased"); - if ($statut==1) return $langs->trans("InActivity"); - } - if ($mode == 2) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - if ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); - } - if ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); - } - if ($mode == 5) - { - if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); - if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); - } - } + if ($mode == 0) + { + if ($statut==0) return $langs->trans("ActivityCeased"); + if ($statut==1) return $langs->trans("InActivity"); + } + if ($mode == 1) + { + if ($statut==0) return $langs->trans("ActivityCeased"); + if ($statut==1) return $langs->trans("InActivity"); + } + if ($mode == 2) + { + if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + } + if ($mode == 3) + { + if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + } + if ($mode == 4) + { + if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); + if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); + } + if ($mode == 5) + { + if ($statut==0) return $langs->trans("ActivityCeased").' '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); + if ($statut==1) return $langs->trans("InActivity").' '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); + } + } - /** - * Return list of contacts emails existing for third party - * - * @param int $addthirdparty 1=Add also a record for thirdparty email - * @return array Array of contacts emails - */ - function thirdparty_and_contact_email_array($addthirdparty=0) - { - global $langs; + /** + * Return list of contacts emails existing for third party + * + * @param int $addthirdparty 1=Add also a record for thirdparty email + * @return array Array of contacts emails + */ + function thirdparty_and_contact_email_array($addthirdparty=0) + { + global $langs; - $contact_emails = $this->contact_property_array('email',1); - if ($this->email && $addthirdparty) - { - if (empty($this->name)) $this->name=$this->nom; - $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; - } - //var_dump($contact_emails) - return $contact_emails; - } + $contact_emails = $this->contact_property_array('email',1); + if ($this->email && $addthirdparty) + { + if (empty($this->name)) $this->name=$this->nom; + $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; + } + //var_dump($contact_emails) + return $contact_emails; + } - /** - * Return list of contacts mobile phone existing for third party - * - * @return array Array of contacts emails - */ - function thirdparty_and_contact_phone_array() - { - global $langs; + /** + * Return list of contacts mobile phone existing for third party + * + * @return array Array of contacts emails + */ + function thirdparty_and_contact_phone_array() + { + global $langs; - $contact_phone = $this->contact_property_array('mobile'); + $contact_phone = $this->contact_property_array('mobile'); - if (! empty($this->phone)) // If a phone of thirdparty is defined, we add it ot mobile of contacts - { - if (empty($this->name)) $this->name=$this->nom; - // TODO: Tester si tel non deja present dans tableau contact - $contact_phone['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->phone.">"; - } - return $contact_phone; - } + if (! empty($this->phone)) // If a phone of thirdparty is defined, we add it ot mobile of contacts + { + if (empty($this->name)) $this->name=$this->nom; + // TODO: Tester si tel non deja present dans tableau contact + $contact_phone['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->phone.">"; + } + return $contact_phone; + } - /** - * Return list of contacts emails or mobile existing for third party - * - * @param string $mode 'email' or 'mobile' + /** + * Return list of contacts emails or mobile existing for third party + * + * @param string $mode 'email' or 'mobile' * @param int $hidedisabled 1=Hide contact if disabled - * @return array Array of contacts emails or mobile array(id=>'Name ') - */ - function contact_property_array($mode='email', $hidedisabled=0) - { - global $langs; + * @return array Array of contacts emails or mobile array(id=>'Name ') + */ + function contact_property_array($mode='email', $hidedisabled=0) + { + global $langs; - $contact_property = array(); + $contact_property = array(); - $sql = "SELECT rowid, email, statut, phone_mobile, lastname, poste, firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; - $sql.= " WHERE fk_soc = ".$this->id; + $sql = "SELECT rowid, email, statut, phone_mobile, lastname, poste, firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; + $sql.= " WHERE fk_soc = ".$this->id; - $resql=$this->db->query($sql); - if ($resql) - { - $nump = $this->db->num_rows($resql); - if ($nump) - { - $sepa="("; $sepb=")"; - if ($mode == 'email') - { - $sepa="<"; $sepb=">"; - } - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object($resql); - if ($mode == 'email') $property=$obj->email; - else if ($mode == 'mobile') $property=$obj->phone_mobile; - else $property=$obj->$mode; + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + if ($nump) + { + $sepa="("; $sepb=")"; + if ($mode == 'email') + { + $sepa="<"; $sepb=">"; + } + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($resql); + if ($mode == 'email') $property=$obj->email; + else if ($mode == 'mobile') $property=$obj->phone_mobile; + else $property=$obj->$mode; // Show all contact. If hidedisabled is 1, showonly contacts with status = 1 - if ($obj->statut == 1 || empty($hidedisabled)) - { - if (empty($property)) - { - if ($mode == 'email') $property=$langs->trans("NoEMail"); - else if ($mode == 'mobile') $property=$langs->trans("NoMobilePhone"); - } + if ($obj->statut == 1 || empty($hidedisabled)) + { + if (empty($property)) + { + if ($mode == 'email') $property=$langs->trans("NoEMail"); + else if ($mode == 'mobile') $property=$langs->trans("NoMobilePhone"); + } - if (!empty($obj->poste)) - { + if (!empty($obj->poste)) + { $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname)).($obj->poste?" - ".$obj->poste:"").(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); } else { $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname)).(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); } - } - $i++; - } - } - } - else - { - dol_print_error($this->db); - } - return $contact_property; - } + } + $i++; + } + } + } + else + { + dol_print_error($this->db); + } + return $contact_property; + } - /** - * Renvoie la liste des contacts de cette societe - * - * @return array tableau des contacts - */ - function contact_array() - { - $contacts = array(); + /** + * Renvoie la liste des contacts de cette societe + * + * @return array tableau des contacts + */ + function contact_array() + { + $contacts = array(); - $sql = "SELECT rowid, lastname, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; - $resql=$this->db->query($sql); - if ($resql) - { - $nump = $this->db->num_rows($resql); - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object($resql); - $contacts[$obj->rowid] = dolGetFirstLastname($obj->firstname,$obj->lastname); - $i++; - } - } - } - else - { - dol_print_error($this->db); - } - return $contacts; - } + $sql = "SELECT rowid, lastname, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($resql); + $contacts[$obj->rowid] = dolGetFirstLastname($obj->firstname,$obj->lastname); + $i++; + } + } + } + else + { + dol_print_error($this->db); + } + return $contacts; + } - /** - * Renvoie la liste des contacts de cette societe - * - * @return array $contacts tableau des contacts - */ - function contact_array_objects() - { - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - $contacts = array(); + /** + * Renvoie la liste des contacts de cette societe + * + * @return array $contacts tableau des contacts + */ + function contact_array_objects() + { + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + $contacts = array(); - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; - $resql=$this->db->query($sql); - if ($resql) - { - $nump = $this->db->num_rows($resql); - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object($resql); - $contact = new Contact($this->db); - $contact->fetch($obj->rowid); - $contacts[] = $contact; - $i++; - } - } - } - else - { - dol_print_error($this->db); - } - return $contacts; - } + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$this->id; + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + if ($nump) + { + $i = 0; + while ($i < $nump) + { + $obj = $this->db->fetch_object($resql); + $contact = new Contact($this->db); + $contact->fetch($obj->rowid); + $contacts[] = $contact; + $i++; + } + } + } + else + { + dol_print_error($this->db); + } + return $contacts; + } - /** - * Return property of contact from its id - * - * @param int $rowid id of contact - * @param string $mode 'email' or 'mobile' - * @return string Email of contact with format: "Full name " - */ - function contact_get_property($rowid,$mode) - { - $contact_property=''; + /** + * Return property of contact from its id + * + * @param int $rowid id of contact + * @param string $mode 'email' or 'mobile' + * @return string Email of contact with format: "Full name " + */ + function contact_get_property($rowid,$mode) + { + $contact_property=''; - if (empty($rowid)) return ''; + if (empty($rowid)) return ''; - $sql = "SELECT rowid, email, phone_mobile, lastname, firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; - $sql.= " WHERE rowid = '".$rowid."'"; + $sql = "SELECT rowid, email, phone_mobile, lastname, firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; + $sql.= " WHERE rowid = '".$rowid."'"; - $resql=$this->db->query($sql); - if ($resql) - { - $nump = $this->db->num_rows($resql); + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); - if ($nump) - { - $obj = $this->db->fetch_object($resql); + if ($nump) + { + $obj = $this->db->fetch_object($resql); - if ($mode == 'email') $contact_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; - else if ($mode == 'mobile') $contact_property = $obj->phone_mobile; - } - return $contact_property; - } - else - { - dol_print_error($this->db); - } + if ($mode == 'email') $contact_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; + else if ($mode == 'mobile') $contact_property = $obj->phone_mobile; + } + return $contact_property; + } + else + { + dol_print_error($this->db); + } - } + } - /** - * Return bank number property of thirdparty (label or rum) - * - * @param string $mode 'label' or 'rum' or 'format' - * @return string Bank number - */ - function display_rib($mode='label') - { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + /** + * Return bank number property of thirdparty (label or rum) + * + * @param string $mode 'label' or 'rum' or 'format' + * @return string Bank number + */ + function display_rib($mode='label') + { + require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; - $bac = new CompanyBankAccount($this->db); - $bac->fetch(0,$this->id); + $bac = new CompanyBankAccount($this->db); + $bac->fetch(0,$this->id); - if ($mode == 'label') - { - return $bac->getRibLabel(true); - } - elseif ($mode == 'rum') - { - if (empty($bac->rum)) - { - require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php'; - $prelevement = new BonPrelevement($this->db); - $bac->fetch_thirdparty(); - $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); - } - return $bac->rum; - } - elseif ($mode == 'format') - { - return $bac->frstrecur; - } + if ($mode == 'label') + { + return $bac->getRibLabel(true); + } + elseif ($mode == 'rum') + { + if (empty($bac->rum)) + { + require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php'; + $prelevement = new BonPrelevement($this->db); + $bac->fetch_thirdparty(); + $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); + } + return $bac->rum; + } + elseif ($mode == 'format') + { + return $bac->frstrecur; + } - return 'BadParameterToFunctionDisplayRib'; - } + return 'BadParameterToFunctionDisplayRib'; + } - /** - * Return Array of RIB - * - * @return array|int 0 if KO, Array of CompanyBanckAccount if OK - */ - function get_all_rib() - { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc = ".$this->id; - $result = $this->db->query($sql); - if (!$result) { - $this->error++; - $this->errors[] = $this->db->lasterror; - return 0; - } else { - $num_rows = $this->db->num_rows($result); - $rib_array = array(); - if ($num_rows) { - while ($obj = $this->db->fetch_object($result)) { - $rib = new CompanyBankAccount($this->db); - $rib->fetch($obj->rowid); - $rib_array[] = $rib; - } - } - return $rib_array; - } - } + /** + * Return Array of RIB + * + * @return array|int 0 if KO, Array of CompanyBanckAccount if OK + */ + function get_all_rib() + { + require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc = ".$this->id; + $result = $this->db->query($sql); + if (!$result) { + $this->error++; + $this->errors[] = $this->db->lasterror; + return 0; + } else { + $num_rows = $this->db->num_rows($result); + $rib_array = array(); + if ($num_rows) { + while ($obj = $this->db->fetch_object($result)) { + $rib = new CompanyBankAccount($this->db); + $rib->fetch($obj->rowid); + $rib_array[] = $rib; + } + } + return $rib_array; + } + } - /** - * Attribut un code client a partir du module de controle des codes. - * Return value is stored into this->code_client - * - * @param Societe $objsoc Object thirdparty - * @param int $type Should be 0 to say customer - * @return void - */ - function get_codeclient($objsoc=0,$type=0) - { - global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) - { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - $mod = new $module(); - - $this->code_client = $mod->getNextValue($objsoc,$type); - $this->prefixCustomerIsRequired = $mod->prefixIsRequired; - - dol_syslog(get_class($this)."::get_codeclient code_client=".$this->code_client." module=".$module); - } - } - - /** - * Attribut un code fournisseur a partir du module de controle des codes. - * Return value is stored into this->code_fournisseur - * - * @param Societe $objsoc Object thirdparty - * @param int $type Should be 1 to say supplier - * @return void - */ - function get_codefournisseur($objsoc=0,$type=1) - { - global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) - { + /** + * Attribut un code client a partir du module de controle des codes. + * Return value is stored into this->code_client + * + * @param Societe $objsoc Object thirdparty + * @param int $type Should be 0 to say customer + * @return void + */ + function get_codeclient($objsoc=0,$type=0) + { + global $conf; + if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + { $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - $mod = new $module(); - - $this->code_fournisseur = $mod->getNextValue($objsoc,$type); - - dol_syslog(get_class($this)."::get_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module); - } - } - - /** - * Verifie si un code client est modifiable en fonction des parametres - * du module de controle des codes. - * - * @return int 0=No, 1=Yes - */ - function codeclient_modifiable() - { - global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) - { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - - $mod = new $module(); - - dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module); - if ($mod->code_modifiable_null && ! $this->code_client) return 1; - if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) return 1; - if ($mod->code_modifiable) return 1; // A mettre en dernier - return 0; - } - else - { - return 0; - } - } - - - /** - * Verifie si un code fournisseur est modifiable dans configuration du module de controle des codes - * - * @return int 0=No, 1=Yes - */ - function codefournisseur_modifiable() - { - global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) - { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - - $mod = new $module(); - - dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module); - if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1; - if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) return 1; - if ($mod->code_modifiable) return 1; // A mettre en dernier - return 0; - } - else - { - return 0; - } - } - - - /** - * Check customer code - * - * @return int 0 if OK - * -1 ErrorBadCustomerCodeSyntax - * -2 ErrorCustomerCodeRequired - * -3 ErrorCustomerCodeAlreadyUsed - * -4 ErrorPrefixRequired - */ - function check_codeclient() - { - global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) - { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - - $mod = new $module(); - - dol_syslog(get_class($this)."::check_codeclient code_client=".$this->code_client." module=".$module); - $result = $mod->verif($this->db, $this->code_client, $this, 0); - return $result; - } - else - { - return 0; - } - } - - /** - * Check supplier code - * - * @return int 0 if OK - * -1 ErrorBadCustomerCodeSyntax - * -2 ErrorCustomerCodeRequired - * -3 ErrorCustomerCodeAlreadyUsed - * -4 ErrorPrefixRequired - */ - function check_codefournisseur() - { - global $conf; - if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) - { - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - - $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) - { - $res=dol_include_once($dirroot.$module.'.php'); - if ($res) break; - } - - $mod = new $module(); - - dol_syslog(get_class($this)."::check_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module); - $result = $mod->verif($this->db, $this->code_fournisseur, $this, 1); - return $result; - } - else - { - return 0; - } - } - - /** - * Renvoie un code compta, suivant le module de code compta. - * Peut etre identique a celui saisit ou genere automatiquement. - * A ce jour seule la generation automatique est implementee - * - * @param string $type Type of thirdparty ('customer' or 'supplier') - * @return string Code compta si ok, 0 si aucun, <0 si ko - */ - function get_codecompta($type) - { - global $conf; - - if (! empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) - { - $file=''; - $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); - foreach ($dirsociete as $dirroot) - { - if (file_exists(DOL_DOCUMENT_ROOT.'/'.$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php")) - { - $file=$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php"; - break; - } - } - - if (! empty($file)) - { - dol_include_once($file); - - $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON; - $mod = new $classname; - - // Defini code compta dans $mod->code - $result = $mod->get_code($this->db, $this, $type); - - if ($type == 'customer') $this->code_compta = $mod->code; - else if ($type == 'supplier') $this->code_compta_fournisseur = $mod->code; - - return $result; - } - else - { - $this->error = 'ErrorAccountancyCodeNotDefined'; - return -1; - } - } - else - { - if ($type == 'customer') $this->code_compta = ''; - else if ($type == 'supplier') $this->code_compta_fournisseur = ''; - - return 0; - } - } - - /** - * Define parent commany of current company - * - * @param int $id Id of thirdparty to set or '' to remove - * @return int <0 if KO, >0 if OK - */ - function set_parent($id) - { - if ($this->id) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; - $sql.= " SET parent = ".($id > 0 ? $id : "null"); - $sql.= " WHERE rowid = " . $this->id; - dol_syslog(get_class($this).'::set_parent', LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->parent = $id; - return 1; - } - else + $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) { - return -1; - } - } - else return -1; - } + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } + $mod = new $module(); + + $this->code_client = $mod->getNextValue($objsoc,$type); + $this->prefixCustomerIsRequired = $mod->prefixIsRequired; + + dol_syslog(get_class($this)."::get_codeclient code_client=".$this->code_client." module=".$module); + } + } /** - * Returns if a profid sould be verified - * - * @param int $idprof 1,2,3,4,5,6 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm,5=idprof5,6=idprof6) - * @return boolean true , false - */ - function id_prof_verifiable($idprof) - { - global $conf; + * Attribut un code fournisseur a partir du module de controle des codes. + * Return value is stored into this->code_fournisseur + * + * @param Societe $objsoc Object thirdparty + * @param int $type Should be 1 to say supplier + * @return void + */ + function get_codefournisseur($objsoc=0,$type=1) + { + global $conf; + if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + { + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - switch($idprof) - { - case 1: - $ret=(!$conf->global->SOCIETE_IDPROF1_UNIQUE?false:true); - break; - case 2: - $ret=(!$conf->global->SOCIETE_IDPROF2_UNIQUE?false:true); - break; - case 3: - $ret=(!$conf->global->SOCIETE_IDPROF3_UNIQUE?false:true); - break; - case 4: - $ret=(!$conf->global->SOCIETE_IDPROF4_UNIQUE?false:true); - break; - case 5: - $ret=(!$conf->global->SOCIETE_IDPROF5_UNIQUE?false:true); - break; - case 6: - $ret=(!$conf->global->SOCIETE_IDPROF6_UNIQUE?false:true); - break; - default: - $ret=false; - } + $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) + { + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } + $mod = new $module(); - return $ret; - } + $this->code_fournisseur = $mod->getNextValue($objsoc,$type); + + dol_syslog(get_class($this)."::get_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module); + } + } /** - * Verify if a profid exists into database for others thirds - * - * @param string $idprof 'idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','email' (Example: idprof1=siren, idprof2=siret, idprof3=naf, idprof4=rcs/rm) - * @param string $value Value of profid - * @param int $socid Id of thirdparty to exclude (if update) - * @return boolean True if exists, False if not - */ - function id_prof_exists($idprof, $value, $socid=0) - { - $field = $idprof; + * Verifie si un code client est modifiable en fonction des parametres + * du module de controle des codes. + * + * @return int 0=No, 1=Yes + */ + function codeclient_modifiable() + { + global $conf; + if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + { + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - switch($idprof) // For backward compatibility - { - case '1': - case 'idprof1': - $field="siren"; - break; - case '2': - case 'idprof2': - $field="siret"; - break; - case '3': - case 'idprof3': - $field="ape"; - break; - case '4': - case 'idprof4': - $field="idprof4"; - break; - case '5': - $field="idprof5"; - break; - case '6': - $field="idprof6"; - break; - } + $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) + { + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } - //Verify duplicate entries - $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; - if($socid) $sql .= " AND rowid <> ".$socid; - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - $count = $obj->idprof; - } - else - { - $count = 0; - print $this->db->error(); - } - $this->db->free($resql); + $mod = new $module(); + + dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module); + if ($mod->code_modifiable_null && ! $this->code_client) return 1; + if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) return 1; + if ($mod->code_modifiable) return 1; // A mettre en dernier + return 0; + } + else + { + return 0; + } + } + + + /** + * Verifie si un code fournisseur est modifiable dans configuration du module de controle des codes + * + * @return int 0=No, 1=Yes + */ + function codefournisseur_modifiable() + { + global $conf; + if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + { + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + + $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) + { + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } + + $mod = new $module(); + + dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module); + if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1; + if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) return 1; + if ($mod->code_modifiable) return 1; // A mettre en dernier + return 0; + } + else + { + return 0; + } + } + + + /** + * Check customer code + * + * @return int 0 if OK + * -1 ErrorBadCustomerCodeSyntax + * -2 ErrorCustomerCodeRequired + * -3 ErrorCustomerCodeAlreadyUsed + * -4 ErrorPrefixRequired + */ + function check_codeclient() + { + global $conf; + if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + { + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + + $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) + { + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } + + $mod = new $module(); + + dol_syslog(get_class($this)."::check_codeclient code_client=".$this->code_client." module=".$module); + $result = $mod->verif($this->db, $this->code_client, $this, 0); + return $result; + } + else + { + return 0; + } + } + + /** + * Check supplier code + * + * @return int 0 if OK + * -1 ErrorBadCustomerCodeSyntax + * -2 ErrorCustomerCodeRequired + * -3 ErrorCustomerCodeAlreadyUsed + * -4 ErrorPrefixRequired + */ + function check_codefournisseur() + { + global $conf; + if (! empty($conf->global->SOCIETE_CODECLIENT_ADDON)) + { + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + + $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) + { + $res=dol_include_once($dirroot.$module.'.php'); + if ($res) break; + } + + $mod = new $module(); + + dol_syslog(get_class($this)."::check_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module); + $result = $mod->verif($this->db, $this->code_fournisseur, $this, 1); + return $result; + } + else + { + return 0; + } + } + + /** + * Renvoie un code compta, suivant le module de code compta. + * Peut etre identique a celui saisit ou genere automatiquement. + * A ce jour seule la generation automatique est implementee + * + * @param string $type Type of thirdparty ('customer' or 'supplier') + * @return string Code compta si ok, 0 si aucun, <0 si ko + */ + function get_codecompta($type) + { + global $conf; + + if (! empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) + { + $file=''; + $dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); + foreach ($dirsociete as $dirroot) + { + if (file_exists(DOL_DOCUMENT_ROOT.'/'.$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php")) + { + $file=$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php"; + break; + } + } + + if (! empty($file)) + { + dol_include_once($file); + + $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON; + $mod = new $classname; + + // Defini code compta dans $mod->code + $result = $mod->get_code($this->db, $this, $type); + + if ($type == 'customer') $this->code_compta = $mod->code; + else if ($type == 'supplier') $this->code_compta_fournisseur = $mod->code; + + return $result; + } + else + { + $this->error = 'ErrorAccountancyCodeNotDefined'; + return -1; + } + } + else + { + if ($type == 'customer') $this->code_compta = ''; + else if ($type == 'supplier') $this->code_compta_fournisseur = ''; + + return 0; + } + } + + /** + * Define parent commany of current company + * + * @param int $id Id of thirdparty to set or '' to remove + * @return int <0 if KO, >0 if OK + */ + function set_parent($id) + { + if ($this->id) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql.= " SET parent = ".($id > 0 ? $id : "null"); + $sql.= " WHERE rowid = " . $this->id; + dol_syslog(get_class($this).'::set_parent', LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->parent = $id; + return 1; + } + else + { + return -1; + } + } + else return -1; + } + + /** + * Returns if a profid sould be verified + * + * @param int $idprof 1,2,3,4,5,6 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm,5=idprof5,6=idprof6) + * @return boolean true , false + */ + function id_prof_verifiable($idprof) + { + global $conf; + + switch($idprof) + { + case 1: + $ret=(!$conf->global->SOCIETE_IDPROF1_UNIQUE?false:true); + break; + case 2: + $ret=(!$conf->global->SOCIETE_IDPROF2_UNIQUE?false:true); + break; + case 3: + $ret=(!$conf->global->SOCIETE_IDPROF3_UNIQUE?false:true); + break; + case 4: + $ret=(!$conf->global->SOCIETE_IDPROF4_UNIQUE?false:true); + break; + case 5: + $ret=(!$conf->global->SOCIETE_IDPROF5_UNIQUE?false:true); + break; + case 6: + $ret=(!$conf->global->SOCIETE_IDPROF6_UNIQUE?false:true); + break; + default: + $ret=false; + } + + return $ret; + } + + /** + * Verify if a profid exists into database for others thirds + * + * @param string $idprof 'idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','email' (Example: idprof1=siren, idprof2=siret, idprof3=naf, idprof4=rcs/rm) + * @param string $value Value of profid + * @param int $socid Id of thirdparty to exclude (if update) + * @return boolean True if exists, False if not + */ + function id_prof_exists($idprof, $value, $socid=0) + { + $field = $idprof; + + switch($idprof) // For backward compatibility + { + case '1': + case 'idprof1': + $field="siren"; + break; + case '2': + case 'idprof2': + $field="siret"; + break; + case '3': + case 'idprof3': + $field="ape"; + break; + case '4': + case 'idprof4': + $field="idprof4"; + break; + case '5': + $field="idprof5"; + break; + case '6': + $field="idprof6"; + break; + } + + //Verify duplicate entries + $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; + if($socid) $sql .= " AND rowid <> ".$socid; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $count = $obj->idprof; + } + else + { + $count = 0; + print $this->db->error(); + } + $this->db->free($resql); if ($count > 0) return true; else return false; - } + } - /** - * Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...) - * - * @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) - * @param Societe $soc Objet societe - * @return int <=0 if KO, >0 if OK - * TODO better to have this in a lib than into a business class - */ - function id_prof_check($idprof,$soc) - { - global $conf; + /** + * Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...) + * + * @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) + * @param Societe $soc Objet societe + * @return int <=0 if KO, >0 if OK + * TODO better to have this in a lib than into a business class + */ + function id_prof_check($idprof,$soc) + { + global $conf; - $ok=1; + $ok=1; - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; + if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; - // Verifie SIREN si pays FR - if ($idprof == 1 && $soc->country_code == 'FR') - { - $chaine=trim($this->idprof1); - $chaine=preg_replace('/(\s)/','',$chaine); - - if (dol_strlen($chaine) != 9) return -1; - - $sum = 0; - - for ($i = 0 ; $i < 10 ; $i = $i+2) - { - $sum = $sum + substr($this->idprof1, (8 - $i), 1); - } - - for ($i = 1 ; $i < 9 ; $i = $i+2) - { - $ps = 2 * substr($this->idprof1, (8 - $i), 1); - - if ($ps > 9) - { - $ps = substr($ps, 0,1) + substr($ps, 1, 1); - } - $sum = $sum + $ps; - } - - if (substr($sum, -1) != 0) return -1; - } - - // Verifie SIRET si pays FR - if ($idprof == 2 && $soc->country_code == 'FR') - { - $chaine=trim($this->idprof2); - $chaine=preg_replace('/(\s)/','',$chaine); - - if (dol_strlen($chaine) != 14) return -1; - } - - //Verify CIF/NIF/NIE if pays ES - //Returns: 1 if NIF ok, 2 if CIF ok, 3 if NIE ok, -1 if NIF bad, -2 if CIF bad, -3 if NIE bad, 0 if unexpected bad - if ($idprof == 1 && $soc->country_code == 'ES') - { - $string=trim($this->idprof1); - $string=preg_replace('/(\s)/','',$string); - $string = strtoupper($string); - - for ($i = 0; $i < 9; $i ++) - $num[$i] = substr($string, $i, 1); - - //Check format - if (!preg_match('/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $string)) - return 0; - - //Check NIF - if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) - return 1; - else - return -1; - - //algorithm checking type code CIF - $sum = $num[2] + $num[4] + $num[6]; - for ($i = 1; $i < 8; $i += 2) - $sum += substr((2 * $num[$i]),0,1) + substr((2 * $num[$i]),1,1); - $n = 10 - substr($sum, strlen($sum) - 1, 1); - - //Chek special NIF - if (preg_match('/^[KLM]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) - return 1; - else - return -1; - - //Check CIF - if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) - return 2; - else - return -2; - - //Check NIE T - if (preg_match('/^[T]{1}/', $string)) - if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) - return 3; - else - return -3; - - //Check NIE XYZ - if (preg_match('/^[XYZ]{1}/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) - return 3; - else - return -3; - - //Can not be verified - return -4; - } - - return $ok; - } - - /** - * Return an url to check online a professional id or empty string - * - * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm) - * @param Societe $thirdparty Object thirdparty - * @return string Url or empty string if no URL known - * TODO better in a lib than into business class - */ - function id_prof_url($idprof,$thirdparty) - { - global $conf,$langs,$hookmanager; - - $url=''; - $action = ''; - - $hookmanager->initHooks(array('idprofurl')); - $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); - $reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return ''; - - // TODO Move links to validate professional ID into a dictionary table "country" + "link" - if ($idprof == 1 && $thirdparty->country_code == 'FR') $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ - //if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid - if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; - if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; - - if ($url) return ''.$langs->trans("Check").''; - } - else - { - return $hookmanager->resPrint; - } - - return ''; - } - - /** - * Indique si la societe a des projets - * - * @return bool true si la societe a des projets, false sinon - */ - function has_projects() - { - $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = ' . $this->id; - $resql = $this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - $count = $obj->numproj; - } - else - { - $count = 0; - print $this->db->error(); - } - $this->db->free($resql); - return ($count > 0); - } - - - /** - * Load information for tab info - * - * @param int $id Id of thirdparty to load - * @return void - */ - function info($id) - { - $sql = "SELECT s.rowid, s.nom as name, s.datec as date_creation, tms as date_modification,"; - $sql.= " fk_user_creat, fk_user_modif"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid = ".$id; - - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - - if ($obj->fk_user_creat) { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_creat); - $this->user_creation = $cuser; - } - - if ($obj->fk_user_modif) { - $muser = new User($this->db); - $muser->fetch($obj->fk_user_modif); - $this->user_modification = $muser; - } - - $this->ref = $obj->name; - $this->date_creation = $this->db->jdate($obj->date_creation); - $this->date_modification = $this->db->jdate($obj->date_modification); - } - - $this->db->free($result); - - } - else + // Verifie SIREN si pays FR + if ($idprof == 1 && $soc->country_code == 'FR') { - dol_print_error($this->db); - } - } + $chaine=trim($this->idprof1); + $chaine=preg_replace('/(\s)/','',$chaine); - /** - * Return if third party is a company (Business) or an end user (Consumer) - * - * @return boolean true=is a company, false=a and user - */ - function isACompany() - { - global $conf; + if (dol_strlen($chaine) != 9) return -1; - // Define if third party is treated as company (or not) when nature is unknown - $isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default - if (! empty($this->tva_intra)) $isacompany=1; - else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_PRIVATE'))) $isacompany=0; - else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_SMALL','TE_MEDIUM','TE_LARGE','TE_GROUP'))) $isacompany=1; + $sum = 0; - return $isacompany; - } + for ($i = 0 ; $i < 10 ; $i = $i+2) + { + $sum = $sum + substr($this->idprof1, (8 - $i), 1); + } - /** - * Charge la liste des categories fournisseurs - * - * @return int 0 if success, <> 0 if error - */ - function LoadSupplierCateg() - { - $this->SupplierCategories = array(); - $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type = ".Categorie::TYPE_SUPPLIER; + for ($i = 1 ; $i < 9 ; $i = $i+2) + { + $ps = 2 * substr($this->idprof1, (8 - $i), 1); - $resql=$this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql) ) - { - $this->SupplierCategories[$obj->rowid] = $obj->label; - } - return 0; - } - else - { - return -1; - } - } + if ($ps > 9) + { + $ps = substr($ps, 0,1) + substr($ps, 1, 1); + } + $sum = $sum + $ps; + } - /** - * Insert link supplier - category - * - * @param int $categorie_id Id of category - * @return int 0 if success, <> 0 if error - */ - function AddFournisseurInCategory($categorie_id) - { - if ($categorie_id > 0 && $this->id > 0) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_fournisseur (fk_categorie, fk_soc) "; - $sql.= " VALUES (".$categorie_id.", ".$this->id.")"; + if (substr($sum, -1) != 0) return -1; + } - if ($resql=$this->db->query($sql)) return 0; - } - else - { - return 0; - } - return -1; - } + // Verifie SIRET si pays FR + if ($idprof == 2 && $soc->country_code == 'FR') + { + $chaine=trim($this->idprof2); + $chaine=preg_replace('/(\s)/','',$chaine); + + if (dol_strlen($chaine) != 14) return -1; + } + + //Verify CIF/NIF/NIE if pays ES + //Returns: 1 if NIF ok, 2 if CIF ok, 3 if NIE ok, -1 if NIF bad, -2 if CIF bad, -3 if NIE bad, 0 if unexpected bad + if ($idprof == 1 && $soc->country_code == 'ES') + { + $string=trim($this->idprof1); + $string=preg_replace('/(\s)/','',$string); + $string = strtoupper($string); + + for ($i = 0; $i < 9; $i ++) + $num[$i] = substr($string, $i, 1); + + //Check format + if (!preg_match('/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $string)) + return 0; + + //Check NIF + if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) + return 1; + else + return -1; + + //algorithm checking type code CIF + $sum = $num[2] + $num[4] + $num[6]; + for ($i = 1; $i < 8; $i += 2) + $sum += substr((2 * $num[$i]),0,1) + substr((2 * $num[$i]),1,1); + $n = 10 - substr($sum, strlen($sum) - 1, 1); + + //Chek special NIF + if (preg_match('/^[KLM]{1}/', $string)) + if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) + return 1; + else + return -1; + + //Check CIF + if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) + if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) + return 2; + else + return -2; + + //Check NIE T + if (preg_match('/^[T]{1}/', $string)) + if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) + return 3; + else + return -3; + + //Check NIE XYZ + if (preg_match('/^[XYZ]{1}/', $string)) + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) + return 3; + else + return -3; + + //Can not be verified + return -4; + } + + return $ok; + } + + /** + * Return an url to check online a professional id or empty string + * + * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm) + * @param Societe $thirdparty Object thirdparty + * @return string Url or empty string if no URL known + * TODO better in a lib than into business class + */ + function id_prof_url($idprof,$thirdparty) + { + global $conf,$langs,$hookmanager; + + $url=''; + $action = ''; + + $hookmanager->initHooks(array('idprofurl')); + $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); + $reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return ''; + + // TODO Move links to validate professional ID into a dictionary table "country" + "link" + if ($idprof == 1 && $thirdparty->country_code == 'FR') $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ + //if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid + if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; + if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + + if ($url) return ''.$langs->trans("Check").''; + } + else + { + return $hookmanager->resPrint; + } + + return ''; + } + + /** + * Indique si la societe a des projets + * + * @return bool true si la societe a des projets, false sinon + */ + function has_projects() + { + $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = ' . $this->id; + $resql = $this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $count = $obj->numproj; + } + else + { + $count = 0; + print $this->db->error(); + } + $this->db->free($resql); + return ($count > 0); + } - /** - * Create a third party into database from a member object - * - * @param Adherent $member Object member - * @param string $socname Name of third party to force - * @param string $socalias Alias name of third party to force - * @return int <0 if KO, id of created account if OK - */ - function create_from_member(Adherent $member, $socname='', $socalias='') - { - global $user,$langs; + /** + * Load information for tab info + * + * @param int $id Id of thirdparty to load + * @return void + */ + function info($id) + { + $sql = "SELECT s.rowid, s.nom as name, s.datec as date_creation, tms as date_modification,"; + $sql.= " fk_user_creat, fk_user_modif"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.rowid = ".$id; - $name = $socname?$socname:$member->societe; - if (empty($name)) $name=$member->getFullName($langs); + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); - $alias = $socalias?$socalias:''; + $this->id = $obj->rowid; - // Positionne parametres - $this->nom=$name; // TODO deprecated - $this->name=$name; - $this->name_alias=$alias; - $this->address=$member->address; - $this->zip=$member->zip; - $this->town=$member->town; - $this->country_code=$member->country_code; - $this->country_id=$member->country_id; - $this->phone=$member->phone; // Prof phone - $this->email=$member->email; - $this->skype=$member->skype; + if ($obj->fk_user_creat) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_creat); + $this->user_creation = $cuser; + } - $this->client = 1; // A member is a customer by default - $this->code_client = -1; - $this->code_fournisseur = -1; + if ($obj->fk_user_modif) { + $muser = new User($this->db); + $muser->fetch($obj->fk_user_modif); + $this->user_modification = $muser; + } - $this->db->begin(); + $this->ref = $obj->name; + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_modification = $this->db->jdate($obj->date_modification); + } - // Cree et positionne $this->id - $result=$this->create($user); - if ($result >= 0) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET fk_soc=".$this->id; - $sql.= " WHERE rowid=".$member->id; + $this->db->free($result); - dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return $this->id; - } - else - { - $this->error=$this->db->error(); + } + else + { + dol_print_error($this->db); + } + } - $this->db->rollback(); - return -1; - } - } - else - { - // $this->error deja positionne - dol_syslog(get_class($this)."::create_from_member - 2 - ".$this->error." - ".join(',',$this->errors), LOG_ERR); + /** + * Return if third party is a company (Business) or an end user (Consumer) + * + * @return boolean true=is a company, false=a and user + */ + function isACompany() + { + global $conf; - $this->db->rollback(); - return $result; - } - } + // Define if third party is treated as company (or not) when nature is unknown + $isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default + if (! empty($this->tva_intra)) $isacompany=1; + else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_PRIVATE'))) $isacompany=0; + else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_SMALL','TE_MEDIUM','TE_LARGE','TE_GROUP'))) $isacompany=1; - /** - * Set properties with value into $conf - * - * @param Conf $conf Conf object (possibility to use another entity) - * @return void - */ - function setMysoc(Conf $conf) - { - global $langs; + return $isacompany; + } - $this->id=0; - $this->name=empty($conf->global->MAIN_INFO_SOCIETE_NOM)?'':$conf->global->MAIN_INFO_SOCIETE_NOM; - $this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS; - $this->zip=empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP; - $this->town=empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN; + /** + * Charge la liste des categories fournisseurs + * + * @return int 0 if success, <> 0 if error + */ + function LoadSupplierCateg() + { + $this->SupplierCategories = array(); + $sql = "SELECT rowid, label"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE type = ".Categorie::TYPE_SUPPLIER; + + $resql=$this->db->query($sql); + if ($resql) + { + while ($obj = $this->db->fetch_object($resql) ) + { + $this->SupplierCategories[$obj->rowid] = $obj->label; + } + return 0; + } + else + { + return -1; + } + } + + /** + * Insert link supplier - category + * + * @param int $categorie_id Id of category + * @return int 0 if success, <> 0 if error + */ + function AddFournisseurInCategory($categorie_id) + { + if ($categorie_id > 0 && $this->id > 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_fournisseur (fk_categorie, fk_soc) "; + $sql.= " VALUES (".$categorie_id.", ".$this->id.")"; + + if ($resql=$this->db->query($sql)) return 0; + } + else + { + return 0; + } + return -1; + } + + + /** + * Create a third party into database from a member object + * + * @param Adherent $member Object member + * @param string $socname Name of third party to force + * @param string $socalias Alias name of third party to force + * @return int <0 if KO, id of created account if OK + */ + function create_from_member(Adherent $member, $socname='', $socalias='') + { + global $user,$langs; + + $name = $socname?$socname:$member->societe; + if (empty($name)) $name=$member->getFullName($langs); + + $alias = $socalias?$socalias:''; + + // Positionne parametres + $this->nom=$name; // TODO deprecated + $this->name=$name; + $this->name_alias=$alias; + $this->address=$member->address; + $this->zip=$member->zip; + $this->town=$member->town; + $this->country_code=$member->country_code; + $this->country_id=$member->country_id; + $this->phone=$member->phone; // Prof phone + $this->email=$member->email; + $this->skype=$member->skype; + + $this->client = 1; // A member is a customer by default + $this->code_client = -1; + $this->code_fournisseur = -1; + + $this->db->begin(); + + // Cree et positionne $this->id + $result=$this->create($user); + if ($result >= 0) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; + $sql.= " SET fk_soc=".$this->id; + $sql.= " WHERE rowid=".$member->id; + + dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->error=$this->db->error(); + + $this->db->rollback(); + return -1; + } + } + else + { + // $this->error deja positionne + dol_syslog(get_class($this)."::create_from_member - 2 - ".$this->error." - ".join(',',$this->errors), LOG_ERR); + + $this->db->rollback(); + return $result; + } + } + + /** + * Set properties with value into $conf + * + * @param Conf $conf Conf object (possibility to use another entity) + * @return void + */ + function setMysoc(Conf $conf) + { + global $langs; + + $this->id=0; + $this->name=empty($conf->global->MAIN_INFO_SOCIETE_NOM)?'':$conf->global->MAIN_INFO_SOCIETE_NOM; + $this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS; + $this->zip=empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP; + $this->town=empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN; $this->state_id=empty($conf->global->MAIN_INFO_SOCIETE_STATE)?'':$conf->global->MAIN_INFO_SOCIETE_STATE; - /* Disabled: we don't want any SQL request into method setMySoc. This method set object from env only. + /* Disabled: we don't want any SQL request into method setMySoc. This method set object from env only. If we need label, label must be loaded by output that need it from id (label depends on output language) require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php'; if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) { @@ -3081,165 +3081,165 @@ class Societe extends CommonObject } */ - $this->note_private=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; + $this->note_private=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; - $this->nom=$this->name; // deprecated + $this->nom=$this->name; // deprecated - // We define country_id, country_code and country - $country_id=$country_code=$country_label=''; - if (! empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) - { - $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_COUNTRY); - $country_id=$tmp[0]; - if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" - { - $country_code=$tmp[1]; - $country_label=$tmp[2]; - } - else // For backward compatibility - { - dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_ERR); - include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $country_code=getCountry($country_id,2,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore - $country_label=getCountry($country_id,0,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore - } - } - $this->country_id=$country_id; - $this->country_code=$country_code; - $this->country=$country_label; - if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; + // We define country_id, country_code and country + $country_id=$country_code=$country_label=''; + if (! empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) + { + $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_COUNTRY); + $country_id=$tmp[0]; + if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" + { + $country_code=$tmp[1]; + $country_label=$tmp[2]; + } + else // For backward compatibility + { + dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_ERR); + include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + $country_code=getCountry($country_id,2,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore + $country_label=getCountry($country_id,0,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore + } + } + $this->country_id=$country_id; + $this->country_code=$country_code; + $this->country=$country_label; + if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; - $this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; - $this->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; - $this->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB; - // Id prof generiques - $this->idprof1=empty($conf->global->MAIN_INFO_SIREN)?'':$conf->global->MAIN_INFO_SIREN; - $this->idprof2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET; - $this->idprof3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE; - $this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; - $this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; - $this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; - $this->tva_intra=empty($conf->global->MAIN_INFO_TVAINTRA)?'':$conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. - $this->managers=empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS)?'':$conf->global->MAIN_INFO_SOCIETE_MANAGERS; - $this->capital=empty($conf->global->MAIN_INFO_CAPITAL)?'':$conf->global->MAIN_INFO_CAPITAL; - $this->forme_juridique_code=empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)?'':$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; - $this->email=empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?'':$conf->global->MAIN_INFO_SOCIETE_MAIL; - $this->logo=empty($conf->global->MAIN_INFO_SOCIETE_LOGO)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO; - $this->logo_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; - $this->logo_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; + $this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; + $this->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; + $this->url=empty($conf->global->MAIN_INFO_SOCIETE_WEB)?'':$conf->global->MAIN_INFO_SOCIETE_WEB; + // Id prof generiques + $this->idprof1=empty($conf->global->MAIN_INFO_SIREN)?'':$conf->global->MAIN_INFO_SIREN; + $this->idprof2=empty($conf->global->MAIN_INFO_SIRET)?'':$conf->global->MAIN_INFO_SIRET; + $this->idprof3=empty($conf->global->MAIN_INFO_APE)?'':$conf->global->MAIN_INFO_APE; + $this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; + $this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; + $this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; + $this->tva_intra=empty($conf->global->MAIN_INFO_TVAINTRA)?'':$conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. + $this->managers=empty($conf->global->MAIN_INFO_SOCIETE_MANAGERS)?'':$conf->global->MAIN_INFO_SOCIETE_MANAGERS; + $this->capital=empty($conf->global->MAIN_INFO_CAPITAL)?'':$conf->global->MAIN_INFO_CAPITAL; + $this->forme_juridique_code=empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)?'':$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; + $this->email=empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?'':$conf->global->MAIN_INFO_SOCIETE_MAIL; + $this->logo=empty($conf->global->MAIN_INFO_SOCIETE_LOGO)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO; + $this->logo_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; + $this->logo_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; - // Define if company use vat or not - $this->tva_assuj=$conf->global->FACTURE_TVAOPTION; + // Define if company use vat or not + $this->tva_assuj=$conf->global->FACTURE_TVAOPTION; - // Define if company use local taxes - $this->localtax1_assuj=((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on'))?1:0); - $this->localtax2_assuj=((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on'))?1:0); - } + // Define if company use local taxes + $this->localtax1_assuj=((isset($conf->global->FACTURE_LOCAL_TAX1_OPTION) && ($conf->global->FACTURE_LOCAL_TAX1_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on'))?1:0); + $this->localtax2_assuj=((isset($conf->global->FACTURE_LOCAL_TAX2_OPTION) && ($conf->global->FACTURE_LOCAL_TAX2_OPTION=='1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on'))?1:0); + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - function initAsSpecimen() - { - $now=dol_now(); + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + function initAsSpecimen() + { + $now=dol_now(); - // Initialize parameters - $this->id=0; - $this->name = 'THIRDPARTY SPECIMEN '.dol_print_date($now,'dayhourlog'); - $this->nom = $this->name; // For backward compatibility - $this->ref_ext = 'Ref ext'; - $this->specimen=1; - $this->address='21 jump street'; - $this->zip='99999'; - $this->town='MyTown'; - $this->state_id=1; - $this->state_code='AA'; - $this->state='MyState'; - $this->country_id=1; - $this->country_code='FR'; - $this->email='specimen@specimen.com'; - $this->skype='tom.hanson'; - $this->url='http://www.specimen.com'; + // Initialize parameters + $this->id=0; + $this->name = 'THIRDPARTY SPECIMEN '.dol_print_date($now,'dayhourlog'); + $this->nom = $this->name; // For backward compatibility + $this->ref_ext = 'Ref ext'; + $this->specimen=1; + $this->address='21 jump street'; + $this->zip='99999'; + $this->town='MyTown'; + $this->state_id=1; + $this->state_code='AA'; + $this->state='MyState'; + $this->country_id=1; + $this->country_code='FR'; + $this->email='specimen@specimen.com'; + $this->skype='tom.hanson'; + $this->url='http://www.specimen.com'; - $this->phone='0909090901'; - $this->fax='0909090909'; + $this->phone='0909090901'; + $this->fax='0909090909'; - $this->code_client='CC-'.dol_print_date($now,'dayhourlog'); - $this->code_fournisseur='SC-'.dol_print_date($now,'dayhourlog'); - $this->capital=10000; - $this->client=1; - $this->prospect=1; - $this->fournisseur=1; - $this->tva_assuj=1; - $this->tva_intra='EU1234567'; - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; + $this->code_client='CC-'.dol_print_date($now,'dayhourlog'); + $this->code_fournisseur='SC-'.dol_print_date($now,'dayhourlog'); + $this->capital=10000; + $this->client=1; + $this->prospect=1; + $this->fournisseur=1; + $this->tva_assuj=1; + $this->tva_intra='EU1234567'; + $this->note_public='This is a comment (public)'; + $this->note_private='This is a comment (private)'; - $this->idprof1='idprof1'; - $this->idprof2='idprof2'; - $this->idprof3='idprof3'; - $this->idprof4='idprof4'; - $this->idprof5='idprof5'; - $this->idprof6='idprof6'; - } + $this->idprof1='idprof1'; + $this->idprof2='idprof2'; + $this->idprof3='idprof3'; + $this->idprof4='idprof4'; + $this->idprof5='idprof5'; + $this->idprof6='idprof6'; + } - /** - * Check if we must use localtax feature or not according to country (country of $mysoc in most cases). - * - * @param int $localTaxNum To get info for only localtax1 or localtax2 - * @return boolean true or false - */ - function useLocalTax($localTaxNum=0) - { - $sql = "SELECT t.localtax1, t.localtax2"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$this->db->escape($this->country_code)."'"; - $sql .= " AND t.active = 1"; - if (empty($localTaxNum)) $sql .= " AND (t.localtax1_type <> '0' OR t.localtax2_type <> '0')"; - elseif ($localTaxNum == 1) $sql .= " AND t.localtax1_type <> '0'"; - elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'"; + /** + * Check if we must use localtax feature or not according to country (country of $mysoc in most cases). + * + * @param int $localTaxNum To get info for only localtax1 or localtax2 + * @return boolean true or false + */ + function useLocalTax($localTaxNum=0) + { + $sql = "SELECT t.localtax1, t.localtax2"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$this->db->escape($this->country_code)."'"; + $sql .= " AND t.active = 1"; + if (empty($localTaxNum)) $sql .= " AND (t.localtax1_type <> '0' OR t.localtax2_type <> '0')"; + elseif ($localTaxNum == 1) $sql .= " AND t.localtax1_type <> '0'"; + elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'"; - dol_syslog("useLocalTax", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { + dol_syslog("useLocalTax", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { return ($this->db->num_rows($resql) > 0); - } - else return false; - } + } + else return false; + } - /** - * Check if we must use NPR Vat (french stupid rule) or not according to country (country of $mysoc in most cases). - * - * @return boolean true or false - */ - function useNPR() - { - $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$this->db->escape($this->country_code)."'"; - $sql .= " AND t.active = 1 AND t.recuperableonly = 1"; + /** + * Check if we must use NPR Vat (french stupid rule) or not according to country (country of $mysoc in most cases). + * + * @return boolean true or false + */ + function useNPR() + { + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$this->db->escape($this->country_code)."'"; + $sql .= " AND t.active = 1 AND t.recuperableonly = 1"; - dol_syslog("useNPR", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - return ($this->db->num_rows($resql) > 0); - } - else return false; - } + dol_syslog("useNPR", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + return ($this->db->num_rows($resql) > 0); + } + else return false; + } - /** - * Check if we must use revenue stamps feature or not according to country (country of $mysocin most cases). - * - * @return boolean true or false - */ - function useRevenueStamp() - { + /** + * Check if we must use revenue stamps feature or not according to country (country of $mysocin most cases). + * + * @return boolean true or false + */ + function useRevenueStamp() + { $sql = "SELECT COUNT(*) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."c_revenuestamp as r, ".MAIN_DB_PREFIX."c_country as c"; $sql .= " WHERE r.fk_pays = c.rowid AND c.code = '".$this->db->escape($this->country_code)."'"; @@ -3294,11 +3294,11 @@ class Societe extends CommonObject * * @param User $user Utilisateur qui definie la remise * @return int <0 if KO, >0 if OK - * @deprecated Use update function instead + * @deprecated Use update function instead */ function set_prospect_level(User $user) { - return $this->update($this->id, $user); + return $this->update($this->id, $user); } /** @@ -3371,11 +3371,11 @@ class Societe extends CommonObject * * @param User $user User making change * @return int <0 if KO, >0 if OK - * @deprecated Use update function instead + * @deprecated Use update function instead */ function set_OutstandingBill(User $user) { - return $this->update($this->id, $user); + return $this->update($this->id, $user); } /** @@ -3539,39 +3539,39 @@ class Societe extends CommonObject */ function get_OutstandingBill() { - /* Accurate value of remain to pay is to sum remaintopay for each invoice + /* Accurate value of remain to pay is to sum remaintopay for each invoice $paiement = $invoice->getSommePaiement(); $creditnotes=$invoice->getSumCreditNotesUsed(); $deposits=$invoice->getSumDepositsUsed(); $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); */ - $sql = "SELECT rowid, total_ttc FROM ".MAIN_DB_PREFIX."facture as f"; - $sql .= " WHERE fk_soc = ". $this->id; - $sql .= " AND paye = 0"; - $sql .= " AND fk_statut <> 0"; // Not a draft - //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason - $sql .= " AND fk_statut <> 3"; // Not abandonned - $sql .= " AND fk_statut <> 2"; // Not clasified as paid + $sql = "SELECT rowid, total_ttc FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE fk_soc = ". $this->id; + $sql .= " AND paye = 0"; + $sql .= " AND fk_statut <> 0"; // Not a draft + //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason + $sql .= " AND fk_statut <> 3"; // Not abandonned + $sql .= " AND fk_statut <> 2"; // Not clasified as paid - dol_syslog("get_OutstandingBill", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $outstandingAmount = 0; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $tmpobject=new Facture($this->db); - while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); - $outstandingAmount+= $obj->total_ttc - $paiement - $creditnotes - $deposits; - } - return $outstandingAmount; - } - else - return 0; + dol_syslog("get_OutstandingBill", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $outstandingAmount = 0; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $tmpobject=new Facture($this->db); + while($obj=$this->db->fetch_object($resql)) { + $tmpobject->id=$obj->rowid; + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); + $outstandingAmount+= $obj->total_ttc - $paiement - $creditnotes - $deposits; + } + return $outstandingAmount; + } + else + return 0; } /** @@ -3620,33 +3620,33 @@ class Societe extends CommonObject if (! empty($moreparams) && ! empty($moreparams['use_companybankid'])) { - $modelpath = "core/modules/bank/doc/"; + $modelpath = "core/modules/bank/doc/"; - include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; - $companybankaccount = new CompanyBankAccount($this->db); - $result = $companybankaccount->fetch($moreparams['use_companybankid']); - if (! $result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); - $result=$companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; + $companybankaccount = new CompanyBankAccount($this->db); + $result = $companybankaccount->fetch($moreparams['use_companybankid']); + if (! $result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); + $result=$companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } else { - // Positionne le modele sur le nom du modele a utiliser - if (! dol_strlen($modele)) - { - if (! empty($conf->global->COMPANY_ADDON_PDF)) - { - $modele = $conf->global->COMPANY_ADDON_PDF; - } - else - { - print $langs->trans("Error")." ".$langs->trans("Error_COMPANY_ADDON_PDF_NotDefined"); - return 0; - } - } + // Positionne le modele sur le nom du modele a utiliser + if (! dol_strlen($modele)) + { + if (! empty($conf->global->COMPANY_ADDON_PDF)) + { + $modele = $conf->global->COMPANY_ADDON_PDF; + } + else + { + print $langs->trans("Error")." ".$langs->trans("Error_COMPANY_ADDON_PDF_NotDefined"); + return 0; + } + } - $modelpath = "core/modules/societe/doc/"; + $modelpath = "core/modules/societe/doc/"; - $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } return $result; @@ -3667,7 +3667,7 @@ class Societe extends CommonObject { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - // Decode type + // Decode type if ($type == 'customer') { $type_id = Categorie::TYPE_CUSTOMER; $type_text = 'customer'; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index f9e10667ccd..24789902411 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -127,15 +127,15 @@ $fieldstosearchall = array( 's.nom'=>"ThirdPartyName", 's.name_alias'=>"AliasNameShort", 's.code_client'=>"CustomerCode", - 's.code_fournisseur'=>"SupplierCode", + 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"CustomerAccountancyCodeShort", 's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort", 's.email'=>"EMail", 's.url'=>"URL", - 's.tva_intra'=>"VATIntra", - 's.siren'=>"ProfId1", - 's.siret'=>"ProfId2", - 's.ape'=>"ProfId3", + 's.tva_intra'=>"VATIntra", + 's.siren'=>"ProfId1", + 's.siret'=>"ProfId2", + 's.ape'=>"ProfId3", ); if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4'; if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5'; @@ -161,35 +161,35 @@ $checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0); $checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0); $arrayfields=array( 's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)), - 's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1), - 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), - 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), - 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode), - 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), - 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode), - 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), - 's.town'=>array('label'=>"Town", 'checked'=>1), - 's.zip'=>array('label'=>"Zip", 'checked'=>1), - 'state.nom'=>array('label'=>"State", 'checked'=>0), - 'region.nom'=>array('label'=>"Region", 'checked'=>0), + 's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), + 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), + 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode), + 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode), + 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.town'=>array('label'=>"Town", 'checked'=>1), + 's.zip'=>array('label'=>"Zip", 'checked'=>1), + 'state.nom'=>array('label'=>"State", 'checked'=>0), + 'region.nom'=>array('label'=>"Region", 'checked'=>0), 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), - 's.email'=>array('label'=>"Email", 'checked'=>0), - 's.url'=>array('label'=>"Url", 'checked'=>0), - 's.phone'=>array('label'=>"Phone", 'checked'=>1), - 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), - 's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1), - 's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2), - 's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3), - 's.idprof4'=>array('label'=>"ProfId4Short", 'checked'=>$checkedprofid4), - 's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5), - 's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6), + 's.email'=>array('label'=>"Email", 'checked'=>0), + 's.url'=>array('label'=>"Url", 'checked'=>0), + 's.phone'=>array('label'=>"Phone", 'checked'=>1), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), + 's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1), + 's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2), + 's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3), + 's.idprof4'=>array('label'=>"ProfId4Short", 'checked'=>$checkedprofid4), + 's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5), + 's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6), 's.tva_intra'=>array('label'=>"VATIntra", 'checked'=>0), 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1), 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm), - 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - 's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), + 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields @@ -197,7 +197,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } @@ -220,44 +220,44 @@ if (empty($reshook)) // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Did we click on purge search criteria ? - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers - { - $search_id=''; - $search_nom=''; - $search_alias=''; - $search_categ_cus=0; - $search_categ_sup=0; - $search_sale=''; - $search_barcode=""; - $search_customer_code=''; - $search_supplier_code=''; - $search_account_customer_code=''; - $search_account_supplier_code=''; - $search_town=""; - $search_zip=""; - $search_state=""; - $search_country=''; - $search_email=''; - $search_phone=''; - $search_url=''; - $search_idprof1=''; - $search_idprof2=''; - $search_idprof3=''; - $search_idprof4=''; - $search_idprof5=''; - $search_idprof6=''; - $search_vat=''; - $search_type=''; - $search_type_thirdparty=''; - $search_status=-1; - $search_stcomm=''; - $search_level_from=''; - $search_level_to=''; - $search_import_key=''; - $toselect=''; - $search_array_options=array(); - } + // Did we click on purge search criteria ? + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + $search_id=''; + $search_nom=''; + $search_alias=''; + $search_categ_cus=0; + $search_categ_sup=0; + $search_sale=''; + $search_barcode=""; + $search_customer_code=''; + $search_supplier_code=''; + $search_account_customer_code=''; + $search_account_supplier_code=''; + $search_town=""; + $search_zip=""; + $search_state=""; + $search_country=''; + $search_email=''; + $search_phone=''; + $search_url=''; + $search_idprof1=''; + $search_idprof2=''; + $search_idprof3=''; + $search_idprof4=''; + $search_idprof5=''; + $search_idprof6=''; + $search_vat=''; + $search_type=''; + $search_type_thirdparty=''; + $search_status=-1; + $search_stcomm=''; + $search_level_from=''; + $search_level_to=''; + $search_import_key=''; + $toselect=''; + $search_array_options=array(); + } // Mass actions $objectclass='Societe'; @@ -469,16 +469,16 @@ if ($search_import_key) $sql.= natural_search("s.import_key",$search_import_k // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } } // Add where from hooks @@ -501,8 +501,8 @@ $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); if (! $resql) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $num = $db->num_rows($resql); @@ -511,10 +511,10 @@ $arrayofselected=is_array($toselect)?$toselect:array(); if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id); + exit; } $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; @@ -562,20 +562,20 @@ if ($type != '') $param.='&type='.urlencode($type); // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } // Show delete result message if (GETPOST('delsoc')) { - setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs'); + setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs'); } // List of mass actions available $arrayofmassactions = array( - 'presend'=>$langs->trans("SendByMail"), + 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); @@ -618,8 +618,8 @@ if ($massaction == 'presend') if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } // Filter on categories @@ -637,14 +637,14 @@ if (empty($type) || $type == 'c' || $type == 'p') } if (empty($type) || $type == 'f') { - if (! empty($conf->categorie->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('SuppliersCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1); - $moreforfilter.='
'; - } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('SuppliersCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1); + $moreforfilter.='
'; + } } // If the user can view prospects other than his' @@ -661,8 +661,8 @@ if ($moreforfilter) print $moreforfilter; $parameters=array('type'=>$type); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; + print $hookmanager->resPrint; + print '
'; } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; @@ -705,125 +705,125 @@ if (! empty($arrayfields['s.barcode']['checked'])) // Customer code if (! empty($arrayfields['s.code_client']['checked'])) { - print ''; } // Supplier code if (! empty($arrayfields['s.code_fournisseur']['checked'])) { - print ''; } // Account Customer code if (! empty($arrayfields['s.code_compta']['checked'])) { - print ''; } // Account Supplier code if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) { - print ''; } // Town if (! empty($arrayfields['s.town']['checked'])) { - print ''; } // Zip if (! empty($arrayfields['s.zip']['checked'])) { - print ''; } // State if (! empty($arrayfields['state.nom']['checked'])) { - print ''; } // Region if (! empty($arrayfields['region.nom']['checked'])) { - print ''; } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; } // Company type if (! empty($arrayfields['typent.code']['checked'])) { - print ''; } if (! empty($arrayfields['s.email']['checked'])) { - // Email + // Email print ''; } if (! empty($arrayfields['s.phone']['checked'])) { - // Phone + // Phone print ''; } if (! empty($arrayfields['s.url']['checked'])) { - // Url + // Url print ''; } if (! empty($arrayfields['s.siren']['checked'])) { - // IdProf1 + // IdProf1 print ''; } if (! empty($arrayfields['s.siret']['checked'])) { - // IdProf2 + // IdProf2 print ''; } if (! empty($arrayfields['s.ape']['checked'])) { - // IdProf3 + // IdProf3 print ''; } if (! empty($arrayfields['s.idprof4']['checked'])) { - // IdProf4 + // IdProf4 print ''; } if (! empty($arrayfields['s.idprof5']['checked'])) { - // IdProf5 + // IdProf5 print ''; @@ -846,20 +846,20 @@ if (! empty($arrayfields['s.tva_intra']['checked'])) // Type (customer/prospect/supplier) if (! empty($arrayfields['customerorsupplier']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) { - // Prospect level + // Prospect level print ''; + print ''; } if (! empty($arrayfields['s.fk_stcomm']['checked'])) { - // Prospect status - print ''; + print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); + print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -904,12 +904,12 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { if (! empty($arrayfields["ef.".$key]['checked'])) { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; + print ''; } // Date modification if (! empty($arrayfields['s.tms']['checked'])) { - print ''; + print ''; } // Status if (! empty($arrayfields['s.status']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['s.import_key']['checked'])) { @@ -993,16 +993,16 @@ if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_f // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } } // Hook fields $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); @@ -1043,186 +1043,186 @@ while ($i < min($num, $limit)) print '\n"; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.nom']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.name_alias']['checked'])) { - print '\n"; - if (! $i) $totalarray['nbfield']++; + print '\n"; + if (! $i) $totalarray['nbfield']++; } // Barcode - if (! empty($arrayfields['s.barcode']['checked'])) + if (! empty($arrayfields['s.barcode']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } // Customer code - if (! empty($arrayfields['s.code_client']['checked'])) + if (! empty($arrayfields['s.code_client']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } - // Supplier code - if (! empty($arrayfields['s.code_fournisseur']['checked'])) + // Supplier code + if (! empty($arrayfields['s.code_fournisseur']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } // Account customer code - if (! empty($arrayfields['s.code_compta']['checked'])) + if (! empty($arrayfields['s.code_compta']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } - // Account supplier code - if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) + // Account supplier code + if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Zip - if (! empty($arrayfields['s.zip']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // State - if (! empty($arrayfields['state.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Region - if (! empty($arrayfields['region.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Country - if (! empty($arrayfields['country.code_iso']['checked'])) - { - print '\n"; + if (! $i) $totalarray['nbfield']++; + } + // Zip + if (! empty($arrayfields['s.zip']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Region + if (! empty($arrayfields['region.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.email']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.phone']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.url']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.siren']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.siret']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.ape']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.idprof4']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.idprof5']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.idprof6']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.tva_intra']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Type - if (! empty($arrayfields['customerorsupplier']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.email']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.phone']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.url']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.siren']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.siret']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.ape']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.idprof4']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.idprof5']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.idprof6']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.tva_intra']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Type + if (! empty($arrayfields['customerorsupplier']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } - if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) - { + if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) + { // Prospect level print '"; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } - if (! empty($arrayfields['s.fk_stcomm']['checked'])) - { - // Prospect status + if (! empty($arrayfields['s.fk_stcomm']['checked'])) + { + // Prospect status print ''; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -1249,54 +1249,54 @@ while ($i < min($num, $limit)) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } } } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['s.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['s.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - if (! empty($arrayfields['s.status']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['s.import_key']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['s.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['s.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['s.status']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['s.import_key']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; + } + print ''; + if (! $i) $totalarray['nbfield']++; print ''."\n"; $i++; diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 7bfc5a482fe..5b5a10b598b 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -78,255 +78,255 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) - { - $action=''; - if (! empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - } + if ($cancel) + { + $action=''; + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } - if ($action == 'update' && ! $_POST["cancel"]) - { - // Modification - if (! GETPOST('label')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $action='edit'; - $error++; - } - if (! GETPOST('bank')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='edit'; - $error++; - } - if ($account->needIBAN() == 1) - { - if (! GETPOST('iban')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='edit'; - $error++; - } - if (! GETPOST('bic')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='edit'; - $error++; - } - } + if ($action == 'update' && ! $_POST["cancel"]) + { + // Modification + if (! GETPOST('label')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $action='edit'; + $error++; + } + if (! GETPOST('bank')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action='edit'; + $error++; + } + if ($account->needIBAN() == 1) + { + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='edit'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='edit'; + $error++; + } + } - $account->fetch($id); - if (! $error) - { - $account->socid = $object->id; + $account->fetch($id); + if (! $error) + { + $account->socid = $object->id; - $account->bank = GETPOST('bank','alpha'); - $account->label = GETPOST('label','alpha'); - $account->courant = GETPOST('courant','alpha'); - $account->clos = GETPOST('clos','alpha'); - $account->code_banque = GETPOST('code_banque','alpha'); - $account->code_guichet = GETPOST('code_guichet','alpha'); - $account->number = GETPOST('number','alpha'); - $account->cle_rib = GETPOST('cle_rib','alpha'); - $account->bic = GETPOST('bic','alpha'); - $account->iban = GETPOST('iban','alpha'); - $account->domiciliation = GETPOST('domiciliation','alpha'); - $account->proprio = GETPOST('proprio','alpha'); - $account->owner_address = GETPOST('owner_address','alpha'); - $account->frstrecur = GETPOST('frstrecur','alpha'); - $account->rum = GETPOST('rum','alpha'); - if (empty($account->rum)) - { - $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); - $account->date_rum = dol_now(); - } + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); + $account->frstrecur = GETPOST('frstrecur','alpha'); + $account->rum = GETPOST('rum','alpha'); + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } - $result = $account->update($user); - if (! $result) - { - setEventMessages($account->error, $account->errors, 'errors'); - } - else - { - // If this account is the default bank account, we disable others - if ($account->default_rib) - { - $account->setAsDefault($id); // This will make sure there is only one default rib - } + $result = $account->update($user); + if (! $result) + { + setEventMessages($account->error, $account->errors, 'errors'); + } + else + { + // If this account is the default bank account, we disable others + if ($account->default_rib) + { + $account->setAsDefault($id); // This will make sure there is only one default rib + } - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } - } - } + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + } + } - if ($action == 'add' && ! $_POST["cancel"]) - { - $error=0; + if ($action == 'add' && ! $_POST["cancel"]) + { + $error=0; - if (! GETPOST('label')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - $action='create'; - $error++; - } - if (! GETPOST('bank')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - $action='create'; - $error++; - } + if (! GETPOST('label')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('bank')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action='create'; + $error++; + } - if (! $error) - { - // Ajout - $account = new CompanyBankAccount($db); + if (! $error) + { + // Ajout + $account = new CompanyBankAccount($db); - $account->socid = $object->id; + $account->socid = $object->id; - $account->bank = GETPOST('bank','alpha'); - $account->label = GETPOST('label','alpha'); - $account->courant = GETPOST('courant','alpha'); - $account->clos = GETPOST('clos','alpha'); - $account->code_banque = GETPOST('code_banque','alpha'); - $account->code_guichet = GETPOST('code_guichet','alpha'); - $account->number = GETPOST('number','alpha'); - $account->cle_rib = GETPOST('cle_rib','alpha'); - $account->bic = GETPOST('bic','alpha'); - $account->iban = GETPOST('iban','alpha'); - $account->domiciliation = GETPOST('domiciliation','alpha'); - $account->proprio = GETPOST('proprio','alpha'); - $account->owner_address = GETPOST('owner_address','alpha'); - $account->frstrecur = GETPOST('frstrecur'); - $account->rum = GETPOST('rum','alpha'); - $account->datec = dol_now(); + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); + $account->frstrecur = GETPOST('frstrecur'); + $account->rum = GETPOST('rum','alpha'); + $account->datec = dol_now(); - $db->begin(); + $db->begin(); - // This test can be done only once properties were set - if ($account->needIBAN() == 1) - { - if (! GETPOST('iban')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); - $action='create'; - $error++; - } - if (! GETPOST('bic')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); - $action='create'; - $error++; - } - } + // This test can be done only once properties were set + if ($account->needIBAN() == 1) + { + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='create'; + $error++; + } + } - if (! $error) - { - $result = $account->create($user); - if ($result < 0) - { - $error++; - setEventMessages($account->error, $account->errors, 'errors'); - $action='create'; // Force chargement page création - } + if (! $error) + { + $result = $account->create($user); + if ($result < 0) + { + $error++; + setEventMessages($account->error, $account->errors, 'errors'); + $action='create'; // Force chargement page création + } - if (empty($account->rum)) - { - $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); - $account->date_rum = dol_now(); - } - } + if (empty($account->rum)) + { + $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + $account->date_rum = dol_now(); + } + } - if (! $error) - { - $result = $account->update($user); // This will set the UMR number. - if ($result < 0) - { - $error++; - setEventMessages($account->error, $account->errors, 'errors'); - $action='create'; - } - } + if (! $error) + { + $result = $account->update($user); // This will set the UMR number. + if ($result < 0) + { + $error++; + setEventMessages($account->error, $account->errors, 'errors'); + $action='create'; + } + } - if (! $error) - { - $db->commit(); + if (! $error) + { + $db->commit(); - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } - else - { - $db->rollback(); - } - } - } + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + else + { + $db->rollback(); + } + } + } - if ($action == 'setasdefault') - { - $account = new CompanyBankAccount($db); - $res = $account->setAsDefault(GETPOST('ribid','int')); - if ($res) - { - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } - else - { - setEventMessages($db->lasterror, null, 'errors'); - } - } + if ($action == 'setasdefault') + { + $account = new CompanyBankAccount($db); + $res = $account->setAsDefault(GETPOST('ribid','int')); + if ($res) + { + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + else + { + setEventMessages($db->lasterror, null, 'errors'); + } + } - if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') - { - $account = new CompanyBankAccount($db); - if ($account->fetch($ribid?$ribid:$id)) - { - $result = $account->delete($user); - if ($result > 0) - { - $url = $_SERVER['PHP_SELF']."?socid=".$object->id; - header('Location: '.$url); - exit; - } - else - { - setEventMessages($account->error, $account->errors, 'errors'); - } - } - else - { - setEventMessages($account->error, $account->errors, 'errors'); - } - } + if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') + { + $account = new CompanyBankAccount($db); + if ($account->fetch($ribid?$ribid:$id)) + { + $result = $account->delete($user); + if ($result > 0) + { + $url = $_SERVER['PHP_SELF']."?socid=".$object->id; + header('Location: '.$url); + exit; + } + else + { + setEventMessages($account->error, $account->errors, 'errors'); + } + } + else + { + setEventMessages($account->error, $account->errors, 'errors'); + } + } - $savid=$id; + $savid=$id; - // Actions to build doc - if ($action == 'builddocrib') - { - $action = 'builddoc'; - $moreparams = array( - 'use_companybankid'=>GETPOST('companybankid'), - 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) - ); - $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid')); - $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid')); - } - $id = $socid; - $upload_dir = $conf->societe->multidir_output[$object->entity]; - $permissioncreate=$user->rights->societe->creer; - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + // Actions to build doc + if ($action == 'builddocrib') + { + $action = 'builddoc'; + $moreparams = array( + 'use_companybankid'=>GETPOST('companybankid'), + 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) + ); + $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid')); + $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid')); + } + $id = $socid; + $upload_dir = $conf->societe->multidir_output[$object->entity]; + $permissioncreate=$user->rights->societe->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - $id = $savid; + $id = $savid; } @@ -347,22 +347,22 @@ if (! $id) } else { - $account->fetch($id); + $account->fetch($id); } if (empty($account->socid)) $account->socid=$object->id; if ($socid && $action == 'edit' && $user->rights->societe->creer) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } if ($socid && $action == 'create' && $user->rights->societe->creer) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } @@ -372,25 +372,25 @@ if ($socid && $action != 'edit' && $action != "create") dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); // Confirm delete third party - if ($action == 'delete') - { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1); - } + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1); + } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - print load_fiche_titre($langs->trans("DefaultRIB"), '', ''); + print load_fiche_titre($langs->trans("DefaultRIB"), '', ''); - print '
'; - print '
'; + print '
'; + print '
'; - print '
'; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5); - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5); + print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5); - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5); + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - $arrayofstatus = array(); - foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); - $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; + print ''; + $arrayofstatus = array(); + foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); + $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); - print 'getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) { - $crit=$val; + $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; print ''; } - print ''; - print ''; + print ''; - print ''; + print ''; @@ -604,16 +604,16 @@ if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } } // Hook fields $parameters=array('arrayfields'=>$arrayfields); @@ -656,157 +656,157 @@ while ($i < min($num,$limit)) { print '
'; - print $object->getNomUrl(1,'withproject'); - if ($object->hasDelay()) print img_warning("Late"); - print ''; - print $object->label; - print ''; + print $object->getNomUrl(1,'withproject'); + if ($object->hasDelay()) print img_warning("Late"); + print ''; + print $object->label; + print ''; - print dol_print_date($db->jdate($obj->date_start),'day'); - print ''; - print dol_print_date($db->jdate($obj->date_end),'day'); - print ''; - print $projectstatic->getNomUrl(1, 'task'); - if ($projectstatic->hasDelay()) print img_warning("Late"); - print ''; - print dol_trunc($obj->projecttitle,80); - print ''; - if ($obj->socid) - { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - print $socstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - print $projectstatic->getLibStatut(1); - print ''; + print $projectstatic->getNomUrl(1, 'task'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print ''; + print dol_trunc($obj->projecttitle,80); + print ''; + if ($obj->socid) + { + $socstatic->id=$obj->socid; + $socstatic->name=$obj->name; + print $socstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + print $projectstatic->getLibStatut(1); + print ''; - $fullhour=convertSecondToTime($obj->planned_workload,$plannedworkloadoutputformat); - $workingdelay=convertSecondToTime($obj->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks - if ($obj->planned_workload != '') - { - print $fullhour; - // TODO Add delay taking account of working hours per day and working day per week - //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; - } - //else print '--:--'; - print '
'; + // Planned workload + if (! empty($arrayfields['t.planned_workload']['checked'])) + { + print ''; + $fullhour=convertSecondToTime($obj->planned_workload,$plannedworkloadoutputformat); + $workingdelay=convertSecondToTime($obj->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + if ($obj->planned_workload != '') + { + print $fullhour; + // TODO Add delay taking account of working hours per day and working day per week + //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; + } + //else print '--:--'; + print '
'; if ($showlineingray) print ''; else print ''; if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; else print ''; - print ''; - if ($obj->planned_workload || $obj->duration_effective) + if ($obj->planned_workload || $obj->duration_effective) { if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload,2).' %'; else print $form->textwithpicto('',$langs->trans('WorkloadNotDefined'), 1, 'help'); } - print ''; - if ($obj->progress != '') + if ($obj->progress != '') { print $obj->progress.' %'; } - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$projectstatic->getLibStatut(5).''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->id, $arrayofselected)) $selected=1; - print ''; - } - print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->id, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').'

'.$text.'

'.$text.'

'.$langs->trans("WelcomeOnPaymentPage").'
'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'


'.$langs->trans("WelcomeOnPaymentPage").'
'.$langs->trans("ThisScreenAllowsYouToPay",$creditor).'

'.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
'.$creditor.''; + print ''; + print '
'; if (empty($amount) || ! is_numeric($amount)) { - print ''; - print ''; + print ''; + print ''; } else { print ''.price($amount).''; - print ''; + print ''; print ''; } // Currency @@ -658,8 +658,8 @@ if (! $source) print ''; print '
'.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
'.$creditor.''; + print ''; + print '
'; if (empty($amount) || ! is_numeric($amount)) { - print ''; - print ''; + print ''; + print ''; } else { print ''.price($amount).''; - print ''; + print ''; print ''; } // Currency @@ -749,32 +749,32 @@ if ($source == 'order') // Shipping address $shipToName=$order->thirdparty->name; - $shipToStreet=$order->thirdparty->address; - $shipToCity=$order->thirdparty->town; - $shipToState=$order->thirdparty->state_code; - $shipToCountryCode=$order->thirdparty->country_code; - $shipToZip=$order->thirdparty->zip; - $shipToStreet2=''; - $phoneNum=$order->thirdparty->phone; - if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) - { - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - $labeldesc=$langs->trans("Order").' '.$order->ref; - if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); - print ''."\n"; + $shipToStreet=$order->thirdparty->address; + $shipToCity=$order->thirdparty->town; + $shipToState=$order->thirdparty->state_code; + $shipToCountryCode=$order->thirdparty->country_code; + $shipToZip=$order->thirdparty->zip; + $shipToStreet2=''; + $phoneNum=$order->thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) + { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + $labeldesc=$langs->trans("Order").' '.$order->ref; + if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); + print ''."\n"; } @@ -800,12 +800,12 @@ if ($source == 'invoice') $object = $invoice; } - if ($action != 'dopayment') // Do not change amount if we just click on first dopayment - { - $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); - if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); - $amount=price2num($amount); - } + if ($action != 'dopayment') // Do not change amount if we just click on first dopayment + { + $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement()); + if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int'); + $amount=price2num($amount); + } $fulltag='INV='.$invoice->ref.'.CUS='.$invoice->thirdparty->id; //$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," "); @@ -815,9 +815,9 @@ if ($source == 'invoice') // Creditor print '
'.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
'.$creditor.''; + print ''; + print '
'; if (empty($amount) || ! is_numeric($amount)) { - print ''; - print ''; + print ''; + print ''; } else { print ''.price($amount).''; - print ''; + print ''; print ''; } // Currency @@ -870,34 +870,34 @@ if ($source == 'invoice') print '
'.$langs->trans("Creditor"); print ''.$creditor.''; - print ''; + print ''; print '
'; if (empty($amount) || ! is_numeric($amount)) { - print ''; - print ''; + print ''; + print ''; } else { print ''.price($amount).''; - print ''; + print ''; print ''; } // Currency @@ -1075,34 +1075,34 @@ if ($source == 'contractline') print ''; print '
'.$langs->trans("Creditor"); - print ''.$creditor.''; - print ''; - print '
'.$creditor.''; + print ''; + print '
'; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print ''; print ''; + print ''; print $form->select_country($search_country,'search_country','',0,'maxwidth100'); print ''; + print ''; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - if ($type != '') print ''; - print ''; + if ($type != '') print ''; + print ''; $options_from = ''; // Generate in $options_from the list of each option sorted foreach ($tab_level as $tab_level_sortorder => $tab_level_label) @@ -877,25 +877,25 @@ if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) $options_to .= ''; } - // Print these two select + // Print these two select print $langs->trans("From").' '; print ' '; print $langs->trans("to").' '; - print ''; - $arraystcomm=array(); + // Prospect status + print ''; + $arraystcomm=array(); foreach($prospectstatic->cacheprospectstatus as $key => $val) { - $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); + $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); } - print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); - print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) { - $crit=$val; + $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; @@ -932,21 +932,21 @@ print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['s.datec']['checked'])) { - print ''; - print ''; + print ''; - print ''; + print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1); - print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1); + print ''; print $obj->rowid; print "'; print $companystatic->getNomUrl(1,'',100); print "'; - print $companystatic->name_alias; - print "'; + print $companystatic->name_alias; + print "'.$obj->barcode.''.$obj->code_client.''.$obj->code_fournisseur.''.$obj->code_compta.''.$obj->code_compta_fournisseur.'".$obj->town."".$obj->zip."".$obj->state_name."".$obj->region_name."'; + if (! empty($arrayfields['s.town']['checked'])) + { + print "".$obj->town."".$obj->zip."".$obj->state_name."".$obj->region_name."'; $tmparray=getCountry($obj->fk_pays,'all'); print $tmparray['label']; print ''; + if (! empty($arrayfields['typent.code']['checked'])) + { + print ''; if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print '".$obj->email."".$obj->phone."".$obj->url."".$obj->idprof1."".$obj->idprof2."".$obj->idprof3."".$obj->idprof4."".$obj->idprof5."".$obj->idprof6."".$obj->tva_intra."'; - $s=''; - if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - $companystatic->name=$langs->trans("Customer"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'customer'); - } - if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Prospect"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'prospect'); - } - if (! empty($conf->fournisseur->enabled) && $obj->fournisseur) - { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Supplier"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'supplier'); - } - print $s; - print '".$obj->email."".$obj->phone."".$obj->url."".$obj->idprof1."".$obj->idprof2."".$obj->idprof3."".$obj->idprof4."".$obj->idprof5."".$obj->idprof6."".$obj->tva_intra."'; + $s=''; + if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $companystatic->name=$langs->trans("Customer"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'customer'); + } + if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Prospect"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'prospect'); + } + if (! empty($conf->fournisseur->enabled) && $obj->fournisseur) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Supplier"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'supplier'); + } + print $s; + print ''; print $companystatic->getLibProspLevel(); print "
'; print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']); print '
-
'; @@ -1233,8 +1233,8 @@ while ($i < min($num, $limit)) if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; } print '
'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$companystatic->getLibStatut(3).''; - print $obj->import_key; - print "'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$companystatic->getLibStatut(3).''; + print $obj->import_key; + print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; if (in_array($obj->rowid, $arrayofselected)) $selected=1; print ''; - } - print '
'; + print '
'; - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -405,11 +405,11 @@ if ($socid && $action != 'edit' && $action != "create") } elseif ($val == 'BankAccountNumber') { $content = $account->number; if (! empty($account->label) && $account->number) { - if (! checkBanForAccount($account)) { - $content.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); - } else { - $content.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); - } + if (! checkBanForAccount($account)) { + $content.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); + } else { + $content.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); + } } } elseif ($val == 'BankAccountNumberKey') { $content = $account->cle_rib; @@ -451,78 +451,78 @@ if ($socid && $action != 'edit' && $action != "create") print "\n"; print '
'.$langs->trans("LabelRIB").''.$account->label.'
'.$langs->trans("LabelRIB").''.$account->label.'
'.$langs->trans("BankName").''.$account->bank.'
'; - print '
'; + print '
'; print '
'; - /* + /* * List of bank accounts */ - print load_fiche_titre($langs->trans("AllRIB"), '', ''); + print load_fiche_titre($langs->trans("AllRIB"), '', ''); - $rib_list = $object->get_all_rib(); - $var = false; - if (is_array($rib_list)) - { + $rib_list = $object->get_all_rib(); + $var = false; + if (is_array($rib_list)) + { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; + print '
'; - print ''; - print_liste_field_titre("LabelRIB"); - print_liste_field_titre("Bank"); - print_liste_field_titre("RIB"); - print_liste_field_titre("IBAN"); - print_liste_field_titre("BIC"); - if (! empty($conf->prelevement->enabled)) - { + print ''; + print_liste_field_titre("LabelRIB"); + print_liste_field_titre("Bank"); + print_liste_field_titre("RIB"); + print_liste_field_titre("IBAN"); + print_liste_field_titre("BIC"); + if (! empty($conf->prelevement->enabled)) + { print print_liste_field_titre("RUM"); print print_liste_field_titre("WithdrawMode"); - } - print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"'); - print_liste_field_titre('', '', '', '', '', 'align="center"'); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + } + print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"'); + print_liste_field_titre('', '', '', '', '', 'align="center"'); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; - foreach ($rib_list as $rib) - { - print ''; - // Label - print ''; - // Bank name - print ''; - // Account number - print ''; + // Label + print ''; + // Bank name + print ''; + // Account number + print ''; - // IBAN - print ''; + // IBAN + print ''; - // BIC - print ''; + // BIC + print '
'.$rib->label.''.$rib->bank.''; - $string=''; - foreach ($rib->getFieldsToShow() as $val) { + foreach ($rib_list as $rib) + { + print '
'.$rib->label.''.$rib->bank.''; + $string=''; + foreach ($rib->getFieldsToShow() as $val) { - if ($val == 'BankCode') { - $string .= $rib->code_banque.' '; - } elseif ($val == 'BankAccountNumber') { - $string .= $rib->number.' '; - } elseif ($val == 'DeskCode') { - $string .= $rib->code_guichet.' '; - } elseif ($val == 'BankAccountNumberKey') { - $string .= $rib->cle_rib.' '; - /* Already output after + if ($val == 'BankCode') { + $string .= $rib->code_banque.' '; + } elseif ($val == 'BankAccountNumber') { + $string .= $rib->number.' '; + } elseif ($val == 'DeskCode') { + $string .= $rib->code_guichet.' '; + } elseif ($val == 'BankAccountNumberKey') { + $string .= $rib->cle_rib.' '; + /* Already output after }elseif ($val == 'BIC') { $string .= $rib->bic.' '; }elseif ($val == 'IBAN') { $string .= $rib->iban.' ';*/ - } - } - if (! empty($rib->label) && $rib->number) { - if (! checkBanForAccount($rib)) { - $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); - } else { - $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); - } + } + } + if (! empty($rib->label) && $rib->number) { + if (! checkBanForAccount($rib)) { + $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); + } else { + $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); + } } - print $string; - print ''.$rib->iban; + print $string; + print ''.$rib->iban; if (! empty($rib->iban)) { if (! checkIbanForAccount($rib)) { print ' '.img_picto($langs->trans("IbanNotValid"),'warning'); @@ -530,9 +530,9 @@ if ($socid && $action != 'edit' && $action != "create") print ' '.img_picto($langs->trans("IbanValid"),'info'); } } - print ''.$rib->bic; + print ''.$rib->bic; if (! empty($rib->bic)) { if (! checkSwiftForAccount($rib)) { print ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); @@ -723,20 +723,20 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) { dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - print '
'; + print '
'; - print '
'; + print '
'; print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; // Show fields of bank account foreach ($account->getFieldsToShow(1) as $val) { @@ -775,51 +775,51 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print ''; } - print '"; + print '"; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - print '"; + print '"; - print '
'.$langs->trans("LabelRIB").'
'.$langs->trans("LabelRIB").'
'.$langs->trans("BankName").'
'.$langs->trans("BankName").'
'.$langs->trans("BankAccountDomiciliation").''; - print '
'.$langs->trans("BankAccountDomiciliation").''; + print '
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwnerAddress").''; - print '
'.$langs->trans("BankAccountOwnerAddress").''; + print '
'; + print '
'; - if ($conf->prelevement->enabled) - { + if ($conf->prelevement->enabled) + { print '
'; - print ''; + print '
'; - if (empty($account->rum)) $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); + if (empty($account->rum)) $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id); - // RUM - print ''; - print ''; + // RUM + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("RUM").'
'.$langs->trans("RUM").'
'.$langs->trans("WithdrawMode").''; - $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); - print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur')?GETPOST('frstrecur'):$account->frstrecur), 0); - print '
'.$langs->trans("WithdrawMode").''; + $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); + print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur')?GETPOST('frstrecur'):$account->frstrecur), 0); + print '
'; - } + print ''; + } - print '
'; + print ''; - dol_fiche_end(); + dol_fiche_end(); print '
'; print ''; - print '     '; + print '     '; print ''; - print '
'; + print ''; } @@ -828,95 +828,95 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) { dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - print '
'; + print '
'; - print '
'; + print '
'; print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - // Show fields of bank account - foreach ($account->getFieldsToShow(1) as $val) { + // Show fields of bank account + foreach ($account->getFieldsToShow(1) as $val) { - $require=false; - if ($val == 'BankCode') { - $name = 'code_banque'; - $size = 8; - } elseif ($val == 'DeskCode') { - $name = 'code_guichet'; - $size = 8; - } elseif ($val == 'BankAccountNumber') { - $name = 'number'; - $size = 18; - } elseif ($val == 'BankAccountNumberKey') { - $name = 'cle_rib'; - $size = 3; - } elseif ($val == 'IBAN') { - $name = 'iban'; - $size = 30; - if ($account->needIBAN()) $require=true; - } elseif ($val == 'BIC') { - $name = 'bic'; - $size = 12; - if ($account->needIBAN()) $require=true; - } + $require=false; + if ($val == 'BankCode') { + $name = 'code_banque'; + $size = 8; + } elseif ($val == 'DeskCode') { + $name = 'code_guichet'; + $size = 8; + } elseif ($val == 'BankAccountNumber') { + $name = 'number'; + $size = 18; + } elseif ($val == 'BankAccountNumberKey') { + $name = 'cle_rib'; + $size = 3; + } elseif ($val == 'IBAN') { + $name = 'iban'; + $size = 30; + if ($account->needIBAN()) $require=true; + } elseif ($val == 'BIC') { + $name = 'bic'; + $size = 12; + if ($account->needIBAN()) $require=true; + } - print ''.$langs->trans($val).''; - print ''; - print ''; - } + print ''.$langs->trans($val).''; + print ''; + print ''; + } - print '"; + print '"; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - print '"; + print '"; - print '
'.$langs->trans("LabelRIB").'
'.$langs->trans("LabelRIB").'
'.$langs->trans("Bank").'
'.$langs->trans("Bank").'
'.$langs->trans("BankAccountDomiciliation").''; - print '
'.$langs->trans("BankAccountDomiciliation").''; + print '
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwnerAddress").''; - print '
'.$langs->trans("BankAccountOwnerAddress").''; + print '
'; + print ''; - if ($conf->prelevement->enabled) - { - print '
'; + if ($conf->prelevement->enabled) + { + print '
'; - print ''; + print '
'; - // RUM - print ''; - print ''; + // RUM + print ''; + print ''; - print ''; + print ''; - print '
'.$langs->trans("RUM").'
'.$langs->trans("RUMWillBeGenerated").'
'.$langs->trans("RUM").'
'.$langs->trans("RUMWillBeGenerated").'
'.$langs->trans("WithdrawMode").''; - $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); - print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); - print '
'.$langs->trans("WithdrawMode").''; + $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); + print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); + print '
'; - } + print ''; + } - print '
'; + print '
'; dol_fiche_end(); print '
'; print ''; - print '     '; + print '     '; print ''; - print '
'; + print ''; } if ($socid && $action == 'edit' && $user->rights->societe->creer) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 9b345827a8e..85798a8a80f 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -126,39 +126,39 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'p.ref'=>'Ref', - 's.nom'=>'Supplier', - 'pd.description'=>'Description', - 'p.note_public'=>'NotePublic', + 'p.ref'=>'Ref', + 's.nom'=>'Supplier', + 'pd.description'=>'Description', + 'p.note_public'=>'NotePublic', ); if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; $checkedtypetiers=0; $arrayfields=array( - 'sp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 's.nom'=>array('label'=>$langs->trans("Supplier"), 'checked'=>1), - 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), - 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), - 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), - 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), - 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), - 'sp.date_valid'=>array('label'=>$langs->trans("Date"), 'checked'=>1), - 'sp.date_livraison'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1), - 'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), - 'sp.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), - 'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), - 'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10), - 'sp.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'sp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'sp.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'sp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 's.nom'=>array('label'=>$langs->trans("Supplier"), 'checked'=>1), + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), + 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), + 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), + 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), + 'sp.date_valid'=>array('label'=>$langs->trans("Date"), 'checked'=>1), + 'sp.date_livraison'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1), + 'sp.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), + 'sp.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), + 'sp.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), + 'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10), + 'sp.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'sp.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'sp.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } } @@ -180,38 +180,38 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { - $search_categ=''; - $search_user=''; - $search_sale=''; - $search_ref=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_ttc=''; - $search_login=''; - $search_product_category=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_author=''; - $yearvalid=''; - $monthvalid=''; - $year=''; - $month=''; - $search_status=''; - $object_statut=''; + $search_categ=''; + $search_user=''; + $search_sale=''; + $search_ref=''; + $search_societe=''; + $search_montant_ht=''; + $search_montant_vat=''; + $search_montant_ttc=''; + $search_login=''; + $search_product_category=''; + $search_town=''; + $search_zip=""; + $search_state=""; + $search_type=''; + $search_country=''; + $search_type_thirdparty=''; + $search_author=''; + $yearvalid=''; + $monthvalid=''; + $year=''; + $month=''; + $search_status=''; + $object_statut=''; } if (empty($reshook)) { - $objectclass='SupplierProposal'; - $objectlabel='SupplierProposals'; - $permtoread = $user->rights->supplier_proposal->lire; - $permtodelete = $user->rights->supplier_proposal->supprimer; - $uploaddir = $conf->supplier_proposal->dir_output; + $objectclass='SupplierProposal'; + $objectlabel='SupplierProposals'; + $permtoread = $user->rights->supplier_proposal->lire; + $permtodelete = $user->rights->supplier_proposal->supprimer; + $uploaddir = $conf->supplier_proposal->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -263,8 +263,8 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = sp.fk_projet"; if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; + $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; } $sql.= ' WHERE sp.fk_soc = s.rowid'; $sql.= ' AND sp.entity IN ('.getEntity('supplier_proposal').')'; @@ -288,12 +288,12 @@ if ($socid) $sql.= ' AND s.rowid = '.$socid; if ($search_status >= 0 && $search_status != '') $sql.= ' AND sp.fk_statut IN ('.$db->escape($search_status).')'; if ($month > 0) { - if ($year > 0 && empty($day)) - $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; - else if ($year > 0 && ! empty($day)) - $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; - else - $sql.= " AND date_format(sp.date_livraison, '%m') = '".$month."'"; + if ($year > 0 && empty($day)) + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else if ($year > 0 && ! empty($day)) + $sql.= " AND sp.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; + else + $sql.= " AND date_format(sp.date_livraison, '%m') = '".$month."'"; } else if ($year > 0) { @@ -301,12 +301,12 @@ else if ($year > 0) } if ($monthvalid > 0) { - if ($yearvalid > 0 && empty($dayvalid)) - $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,$monthvalid,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,$monthvalid,false))."'"; - else if ($yearvalid > 0 && ! empty($dayvalid)) - $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $monthvalid, $dayvalid, $yearvalid))."' AND '".$db->idate(dol_mktime(23, 59, 59, $monthvalid, $dayvalid, $yearvalid))."'"; - else - $sql.= " AND date_format(sp.date_valid, '%m') = '".$monthvalid."'"; + if ($yearvalid > 0 && empty($dayvalid)) + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_get_first_day($yearvalid,$monthvalid,false))."' AND '".$db->idate(dol_get_last_day($yearvalid,$monthvalid,false))."'"; + else if ($yearvalid > 0 && ! empty($dayvalid)) + $sql.= " AND sp.date_valid BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $monthvalid, $dayvalid, $yearvalid))."' AND '".$db->idate(dol_mktime(23, 59, 59, $monthvalid, $dayvalid, $yearvalid))."'"; + else + $sql.= " AND date_format(sp.date_valid, '%m') = '".$monthvalid."'"; } else if ($yearvalid > 0) { @@ -315,21 +315,21 @@ else if ($yearvalid > 0) if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; if ($search_user > 0) { - $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".$search_user; + $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = sp.rowid AND c.fk_socpeople = ".$search_user; } // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } } // Add where from hooks $parameters=array(); @@ -357,13 +357,13 @@ if ($resql) if ($socid > 0) { - $soc = new Societe($db); - $soc->fetch($socid); - $title = $langs->trans('ListOfSupplierProposals') . ' - '.$soc->name; + $soc = new Societe($db); + $soc->fetch($socid); + $title = $langs->trans('ListOfSupplierProposals') . ' - '.$soc->name; } else { - $title = $langs->trans('ListOfSupplierProposals'); + $title = $langs->trans('ListOfSupplierProposals'); } $num = $db->num_rows($resql); @@ -371,13 +371,13 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($sall) $param.='&sall='.$sall; if ($month) $param.='&month='.$month; if ($year) $param.='&year='.$year; - if ($search_ref) $param.='&search_ref=' .$search_ref; - if ($search_societe) $param.='&search_societe=' .$search_societe; + if ($search_ref) $param.='&search_ref=' .$search_ref; + if ($search_societe) $param.='&search_societe=' .$search_societe; if ($search_user > 0) $param.='&search_user='.$search_user; if ($search_sale > 0) $param.='&search_sale='.$search_sale; if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; @@ -390,15 +390,15 @@ if ($resql) // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } // List of mass actions available $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - 'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + 'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->supplier_proposal->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); @@ -428,8 +428,8 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } $i = 0; @@ -448,20 +448,20 @@ if ($resql) // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='
'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + $moreforfilter.='
'; } // If the user can view products if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='
'; + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter.='
'; } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook @@ -469,18 +469,18 @@ if ($resql) else $moreforfilter = $hookmanager->resPrint; if (! empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - print '
'; - } + { + print '
'; + print $moreforfilter; + print '
'; + } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - print '
'; - print ''."\n"; + print '
'; + print '
'."\n"; print ''; if (! empty($arrayfields['sp.ref']['checked'])) @@ -498,26 +498,26 @@ if ($resql) if (! empty($arrayfields['s.town']['checked'])) print ''; if (! empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) - { - print ''; - } - // Country - if (! empty($arrayfields['country.code_iso']['checked'])) - { - print ''; - } + if (! empty($arrayfields['state.nom']['checked'])) + { + print ''; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + } // Company type - if (! empty($arrayfields['typent.code']['checked'])) - { - print ''; - } + if (! empty($arrayfields['typent.code']['checked'])) + { + print ''; + } // Date if (! empty($arrayfields['sp.date_valid']['checked'])) { @@ -543,54 +543,54 @@ if ($resql) if (! empty($arrayfields['sp.total_ht']['checked'])) { - // Amount - print ''; + // Amount + print ''; } if (! empty($arrayfields['sp.total_vat']['checked'])) { - // Amount - print ''; + // Amount + print ''; } if (! empty($arrayfields['sp.total_ttc']['checked'])) { - // Amount - print ''; + // Amount + print ''; } if (! empty($arrayfields['u.login']['checked'])) { - // Author - print ''; + // Author + print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); @@ -599,14 +599,14 @@ if ($resql) // Date creation if (! empty($arrayfields['sp.datec']['checked'])) { - print ''; + print ''; } // Date modification if (! empty($arrayfields['sp.tms']['checked'])) { - print ''; + print ''; } // Status if (! empty($arrayfields['sp.fk_statut']['checked'])) @@ -643,19 +643,19 @@ if ($resql) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) - { + if (! empty($arrayfields["ef.".$key]['checked'])) + { $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } } } // Hook fields $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (! empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'],$_SERVER["PHP_SELF"],"sp.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['sp.tms']['checked'])) print_liste_field_titre($arrayfields['sp.tms']['label'],$_SERVER["PHP_SELF"],"sp.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['sp.fk_statut']['checked'])) print_liste_field_titre($arrayfields['sp.fk_statut']['label'],$_SERVER["PHP_SELF"],"sp.fk_statut","",$param,'align="right"',$sortfield,$sortorder); @@ -724,164 +724,164 @@ if ($resql) // Thirdparty if (! empty($arrayfields['s.nom']['checked'])) { - print ''; if (! $i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Zip - if (! empty($arrayfields['s.zip']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // State - if (! empty($arrayfields['state.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Country - if (! empty($arrayfields['country.code_iso']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Type ent - if (! empty($arrayfields['typent.code']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } + if (! empty($arrayfields['s.town']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Zip + if (! empty($arrayfields['s.zip']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // State + if (! empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Type ent + if (! empty($arrayfields['typent.code']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Date proposal - if (! empty($arrayfields['sp.date_valid']['checked'])) - { - print '\n"; if (! $i) $totalarray['nbfield']++; - } + } // Date delivery - if (! empty($arrayfields['sp.date_livraison']['checked'])) - { - print '\n"; if (! $i) $totalarray['nbfield']++; - } + } - // Amount HT - if (! empty($arrayfields['sp.total_ht']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; - $totalarray['totalht'] += $obj->total_ht; - } - // Amount VAT - if (! empty($arrayfields['sp.total_vat']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; - $totalarray['totalvat'] += $obj->total_vat; - } - // Amount TTC - if (! empty($arrayfields['sp.total_ttc']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; - $totalarray['totalttc'] += $obj->total_ttc; - } + // Amount HT + if (! empty($arrayfields['sp.total_ht']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield']; + $totalarray['totalht'] += $obj->total_ht; + } + // Amount VAT + if (! empty($arrayfields['sp.total_vat']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield']; + $totalarray['totalvat'] += $obj->total_vat; + } + // Amount TTC + if (! empty($arrayfields['sp.total_ttc']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield']; + $totalarray['totalttc'] += $obj->total_ttc; + } $userstatic->id=$obj->fk_user_author; $userstatic->login=$obj->login; - // Author - if (! empty($arrayfields['u.login']['checked'])) - { + // Author + if (! empty($arrayfields['u.login']['checked'])) + { print '\n"; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['sp.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['sp.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - if (! empty($arrayfields['sp.fk_statut']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['sp.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['sp.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['sp.fk_statut']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; print "\n"; @@ -893,28 +893,28 @@ if ($resql) // Show total line if (isset($totalarray['totalhtfield']) - || isset($totalarray['totalvatfield']) - || isset($totalarray['totalttcfield']) - || isset($totalarray['totalamfield']) - || isset($totalarray['totalrtpfield']) - ) + || isset($totalarray['totalvatfield']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if ($i == 1) - { - if ($num < $limit && empty($offset)) print ''; - else print ''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''; - elseif ($totalarray['totalvatfield'] == $i) print ''; - elseif ($totalarray['totalttcfield'] == $i) print ''; - else print ''; - } - print ''; + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit && empty($offset)) print ''; + else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''; + elseif ($totalarray['totalvatfield'] == $i) print ''; + elseif ($totalarray['totalttcfield'] == $i) print ''; + else print ''; + } + print ''; } $db->free($resql); @@ -924,28 +924,28 @@ if ($resql) print $hookmanager->resPrint; print '
'; - print ''; - print ''; - print $form->select_country($search_country,'search_country','',0,'maxwidth100'); - print ''; + print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); - print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; - print ''; + print ''; - print ''; + print ''; + print ''; print $companystatic->getNomUrl(1,'customer'); print ''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays,'all'); - print $tmparray['label']; - print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); - print $typenArray[$obj->typent_code]; - print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; + if (! empty($arrayfields['sp.date_valid']['checked'])) + { + print ''; print dol_print_date($db->jdate($obj->date_valid), 'day'); print "'; + if (! empty($arrayfields['sp.date_livraison']['checked'])) + { + print ''; print dol_print_date($db->jdate($obj->dp), 'day'); print "'.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_ttc)."'.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_ttc)."'; if ($userstatic->id) print $userstatic->getLoginUrl(1); else print ' '; print "'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$objectstatic->LibStatut($obj->fk_statut,5)."'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$objectstatic->LibStatut($obj->fk_statut,5)."'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalht']).''.price($totalarray['totalvat']).''.price($totalarray['totalttc']).'
'."\n"; - print '
'."\n"; + print ''."\n"; print ''."\n"; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - /* + /* * Show list of available documents */ - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - $filedir=$diroutputmassaction; + $filedir=$diroutputmassaction; - $genallowed=$user->rights->supplier_proposal->lire; - $delallowed=$user->rights->supplier_proposal->lire; + $genallowed=$user->rights->supplier_proposal->lire; + $delallowed=$user->rights->supplier_proposal->lire; - print $formfile->showdocuments('massfilesarea_supplier_proposal','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); + print $formfile->showdocuments('massfilesarea_supplier_proposal','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); } else { - print '
'.$langs->trans("ShowTempMassFilesArea").''; + print '
'.$langs->trans("ShowTempMassFilesArea").''; } } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 15571755944..981704de6ae 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -72,37 +72,37 @@ $form = new Form($db); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'u.login'=>"Login", - 'u.lastname'=>"Lastname", - 'u.firstname'=>"Firstname", + 'u.lastname'=>"Lastname", + 'u.firstname'=>"Firstname", 'u.accountancy_code'=>"AccountancyCode", 'u.email'=>"EMail", - 'u.note'=>"Note" + 'u.note'=>"Note" ); // Definition of fields for list $arrayfields=array( - 'u.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), - 'u.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), - 'u.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), - 'u.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), - 'u.employee'=>array('label'=>$langs->trans("Employee"), 'checked'=>($mode=='employee'?1:0)), - 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), - 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), - 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), - 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), - 'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1), - 'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100), - 'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110), - 'u.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'u.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'u.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), + 'u.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), + 'u.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), + 'u.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), + 'u.employee'=>array('label'=>$langs->trans("Employee"), 'checked'=>($mode=='employee'?1:0)), + 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), + 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), + 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), + 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), + 'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1), + 'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100), + 'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110), + 'u.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'u.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } @@ -141,29 +141,29 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers - { - $search_user=""; - $search_login=""; - $search_lastname=""; - $search_firstname=""; - $search_gender=""; - $search_employee=""; - $search_accountancy_code=""; - $search_email=""; - $search_statut=""; - $search_thirdparty=""; - $search_supervisor=""; - $search_datelastlogin=""; - $search_datepreviouslogin=""; - $search_date_creation=""; - $search_date_update=""; - $search_array_options=array(); - } + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + $search_user=""; + $search_login=""; + $search_lastname=""; + $search_firstname=""; + $search_gender=""; + $search_employee=""; + $search_accountancy_code=""; + $search_email=""; + $search_statut=""; + $search_thirdparty=""; + $search_supervisor=""; + $search_datelastlogin=""; + $search_datepreviouslogin=""; + $search_date_creation=""; + $search_date_update=""; + $search_array_options=array(); + } } @@ -217,16 +217,16 @@ if ($sall) $sql.= natural_search(array_keys($fieldstos // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; - $mode=0; - if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric - if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) - { - $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); - } + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric + if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int + if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0')) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } } // Add where from hooks $parameters=array(); @@ -238,7 +238,7 @@ $nbtotalofrecords=0; $result=$db->query($sql); if ($result) { - $nbtotalofrecords = $db->num_rows($result); + $nbtotalofrecords = $db->num_rows($result); } $sql.= $db->plimit($limit+1, $offset); @@ -246,18 +246,18 @@ $sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); if (! $result) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $num = $db->num_rows($result); if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id); + exit; } llxHeader('',$langs->trans("ListOfUsers")); @@ -281,9 +281,9 @@ if ($mode != '') $param.='&mode='.$mode; // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } $text = $langs->trans("ListOfUsers"); @@ -302,8 +302,8 @@ print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sorto if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } $moreforfilter=''; @@ -319,59 +319,59 @@ print ''; if (! empty($arrayfields['u.login']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.lastname']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.firstname']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.gender']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.employee']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.accountancy_code']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.email']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.fk_soc']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.entity']['checked'])) { - print ''; + print ''; } // Supervisor if (! empty($arrayfields['u.fk_user']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.datelastlogin']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['u.datepreviouslogin']['checked'])) { - print ''; + print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -380,12 +380,12 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab { if (! empty($arrayfields["ef.".$key]['checked'])) { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; + // Date creation + print ''; } if (! empty($arrayfields['u.tms']['checked'])) { - // Date modification - print ''; + // Date modification + print ''; } if (! empty($arrayfields['u.statut']['checked'])) { - // Status - print ''; + // Status + print ''; } // Action column print '"; - if (! empty($arrayfields['u.login']['checked'])) + print ""; + if (! empty($arrayfields['u.login']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + if (! empty($conf->multicompany->enabled) && $obj->admin && ! $obj->entity) + { + print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); + } + else if ($obj->admin) + { + print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); + } + print ''; + if (! $i) $totalarray['nbfield']++; } - if (! empty($arrayfields['u.lastname']['checked'])) + if (! empty($arrayfields['u.lastname']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } - if (! empty($arrayfields['u.firstname']['checked'])) + if (! empty($arrayfields['u.firstname']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } - if (! empty($arrayfields['u.gender']['checked'])) + if (! empty($arrayfields['u.gender']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } - if (! empty($arrayfields['u.employee']['checked'])) + if (! empty($arrayfields['u.employee']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.accountancy_code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } - if (! empty($arrayfields['u.email']['checked'])) + if (! empty($arrayfields['u.email']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.fk_soc']['checked'])) { print "'; - if (! $i) $totalarray['nbfield']++; - } - // Multicompany enabled - if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { - if (! empty($arrayfields['u.entity']['checked'])) + if ($obj->fk_soc) { - print ''; - if (! $i) $totalarray['nbfield']++; + $companystatic->id=$obj->fk_soc; + $companystatic->name=$obj->name; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1); } - } - // Supervisor - if (! empty($arrayfields['u.fk_user']['checked'])) + else if ($obj->ldap_sid) + { + print $langs->trans("DomainUser"); + } + else + { + print $langs->trans("InternalUser"); + } + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Multicompany enabled + if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + if (! empty($arrayfields['u.entity']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + // Supervisor + if (! empty($arrayfields['u.fk_user']['checked'])) { // Resp - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } - // Date last login - if (! empty($arrayfields['u.datelastlogin']['checked'])) + // Date last login + if (! empty($arrayfields['u.datelastlogin']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } - // Date previous login - if (! empty($arrayfields['u.datepreviouslogin']['checked'])) + // Date previous login + if (! empty($arrayfields['u.datepreviouslogin']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } // Extra fields @@ -632,44 +632,44 @@ while ($i < min($num,$limit)) $tmpkey='options_'.$key; print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } } } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['u.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['u.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - if (! empty($arrayfields['u.statut']['checked'])) - { + if (! empty($arrayfields['u.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['u.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['u.statut']['checked'])) + { $userstatic->statut=$obj->statut; - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; - print "\n"; + print "\n"; - $i++; + $i++; } $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); From c1c3725eb6c41f114934b944b9daad2ebab544bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 15:23:24 +0200 Subject: [PATCH 108/128] The website grabber rocks --- htdocs/websites/index.php | 83 ++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 23c915335c5..4438812cc60 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -180,6 +180,8 @@ if ($action == 'addsite') // Add page if ($action == 'add') { + dol_mkdir($pathofwebsite); + $db->begin(); $objectpage->fk_website = $object->id; @@ -240,20 +242,25 @@ if ($action == 'add') } $objectpage->content = $tmp['content']; - $objectpage->content = preg_replace('/^.*]*>/ims', '', $objectpage->content); - $objectpage->content = preg_replace('/<\/body[^>]*>.*$/ims', '', $objectpage->content); + $objectpage->content = preg_replace('/^.*]*)*>/ims', '', $objectpage->content); + $objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content); + $absoluteurlinaction=$urltograbdirwithoutslash; + // TODO Replace 'action="$urltograbdirwithoutslash' into action="/" + // TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..." + // TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/" + // TODO Replace 'a href="$urltograbdirwithoutslash..."' into a href="..." // Now loop to fetch all css files. Include them inline into header of page $objectpage->htmlheader = $tmp['content']; - $objectpage->htmlheader = preg_replace('/^.*]*>/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/<\/head[^>]*>.*$/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/]*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/]*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/]*>\n*/ims', '', $objectpage->htmlheader); - $objectpage->htmlheader = preg_replace('/]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/]*)*>\n*/ims', '', $objectpage->htmlheader); + $objectpage->htmlheader = preg_replace('/]*)*>\n*/ims', '', $objectpage->htmlheader); //$objectpage->htmlheader = preg_replace('/]*>\n*/ims', '', $objectpage->htmlheader); $objectpage->htmlheader = preg_replace('/[^<]*<\/title>\n*/ims', '', $objectpage->htmlheader); @@ -262,12 +269,14 @@ if ($action == 'add') // Now loop to fetch JS $tmp = $objectpage->htmlheader; - preg_match_all('/<script([^\.]+)src="([^>"]+)"([^>]*)><\/script>/i', $objectpage->htmlheader, $regs); + preg_match_all('/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs); foreach ($regs[0] as $key => $val) { - $urltograbbis = $urltograbdirwithoutslash.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + dol_syslog("We will grab the resource ".$regs[2][$key]); $linkwithoutdomain = $regs[2][$key]; + $urltograbbis = $urltograbdirwithoutslash.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { @@ -275,6 +284,15 @@ if ($action == 'add') $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } + + //print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - '; + //print $linkwithoutdomain.' - '.$urltograbbis."<br>\n"; + + // Test if this is an external URL of grabbed web site. If yes, we do not load resource + $domaintograb = getDomainFromURL($urltograbdirwithoutslash); + $domaintograbbis = getDomainFromURL($urltograbbis); + if ($domaintograb != $domaintograbbis) continue; + /* $tmpgeturl = getURLContent($urltograbbis); if ($tmpgeturl['curl_error_no']) @@ -293,9 +311,9 @@ if ($action == 'add') if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); } + */ - $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; - */ + //$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; $tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '', $tmp); } $objectpage->htmlheader = trim($tmp); @@ -304,11 +322,14 @@ if ($action == 'add') // Now loop to fetch CSS $pagecsscontent = "\n".'<style>'."\n"; - preg_match_all('/<link([^\.]+)href="([^>"]+\.css)"([^>]*)>/i', $objectpage->htmlheader, $regs); + preg_match_all('/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs); foreach ($regs[0] as $key => $val) { - $urltograbbis = $urltograbdirwithoutslash.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + dol_syslog("We will grab the resource ".$regs[2][$key]); + $linkwithoutdomain = $regs[2][$key]; + $urltograbbis = $urltograbdirwithoutslash.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { @@ -317,6 +338,14 @@ if ($action == 'add') //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } + //print $domaintograb.' - '.$domaintograbbis.' - '.$urltograbdirwithoutslash.' - '; + //print $linkwithoutdomain.' - '.$urltograbbis."<br>\n"; + + // Test if this is an external URL of grabbed web site. If yes, we do not load resource + $domaintograb = getDomainFromURL($urltograbdirwithoutslash); + $domaintograbbis = getDomainFromURL($urltograbbis); + if ($domaintograb != $domaintograbbis) continue; + $tmpgeturl = getURLContent($urltograbbis); if ($tmpgeturl['curl_error_no']) { @@ -326,13 +355,13 @@ if ($action == 'add') } else { - //dol_mkdir(dirname($filetosave)); + //dol_mkdir(dirname($filetosave)); - //$fp = fopen($filetosave, "w"); - //fputs($fp, $tmpgeturl['content']); - //fclose($fp); - //if (! empty($conf->global->MAIN_UMASK)) - // @chmod($file, octdec($conf->global->MAIN_UMASK)); + //$fp = fopen($filetosave, "w"); + //fputs($fp, $tmpgeturl['content']); + //fclose($fp); + //if (! empty($conf->global->MAIN_UMASK)) + // @chmod($file, octdec($conf->global->MAIN_UMASK)); } // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; @@ -448,6 +477,16 @@ if ($action == 'add') // To generate the CSS, robot and htmlheader file. + // Check symlink to medias and restore it if ko + $pathtomedias=DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite=$pathofwebsite.'/medias'; + if (! is_link(dol_osencode($pathtomediasinwebsite))) + { + dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + $result = symlink($pathtomedias, $pathtomediasinwebsite); + } + if (! dol_is_file($filehtmlheader)) { $htmlheadercontent = "<!-- HTML header content (common for all pages) -->"; From 8b64f979ef1f9620a6d1d3f2699afe8c4bfe0b94 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 15:49:39 +0200 Subject: [PATCH 109/128] Fix multiple upload was broken --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 73198771b93..7559179c87d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -131,7 +131,7 @@ class FormFile $out .= '<input class="flat minwidth400" type="file"'; $out .= ((! empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic')?' name="userfile"':' name="userfile[]" multiple'); $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); - $out .= (!empty($accept)?' accept="'.$accept.'"':'accept=""'); + $out .= (!empty($accept)?' accept="'.$accept.'"':' accept=""'); $out .= '>'; $out .= ' '; $out .= '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"'; From 5f021990b4769739fe61c90a1084a0394e8e655f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 17:44:31 +0200 Subject: [PATCH 110/128] Code comment --- htdocs/user/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index eeb1e898736..4902e0b6de0 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1412,9 +1412,13 @@ else print '</td>'; print "</tr>\n"; + //$childids = $user->getAllChildIds(1); + if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) { + // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). + // However, he can see the valuation of timesheet of its subordinates even without these permissions. $langs->load("salaries"); // THM From 1f2555d7c6e83fed0fb6fd390a0eb2c000b6928d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 19:51:36 +0200 Subject: [PATCH 111/128] Add link other invoices of third party on supplier card to --- htdocs/fourn/facture/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 3c257c9d4e5..6241a80aec1 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2036,6 +2036,7 @@ else $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherBills").'</a>)'; // Project if (! empty($conf->projet->enabled)) { From 5092c41d943f31ab902e479b15ac8903836ecb9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 20:04:11 +0200 Subject: [PATCH 112/128] Look and feel v6 --- htdocs/core/class/html.formactions.class.php | 1 - htdocs/fourn/paiement/card.php | 7 +++---- htdocs/fourn/paiement/info.php | 21 ++++++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index adf5f4c340b..7d5bffb6e54 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -179,7 +179,6 @@ class FormActions if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); - elseif ($typeelement == 'supplier_payment') $title=$langs->trans('ActionsOnSupplierPayment'); elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 4126ef8c134..36749977927 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -367,11 +367,10 @@ if ($result > 0) } print '</div>'; + /* print '<div class="fichecenter"><div class="fichehalfleft">'; - /* - * Documents generes - */ + // Documents generes $ref=dol_sanitizeFileName($object->ref); $filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; @@ -393,7 +392,7 @@ if ($result > 0) print '</div></div></div>'; //print '</td></tr></table>'; - + */ } else { diff --git a/htdocs/fourn/paiement/info.php b/htdocs/fourn/paiement/info.php index 24263106052..eafc4f2decc 100644 --- a/htdocs/fourn/paiement/info.php +++ b/htdocs/fourn/paiement/info.php @@ -32,9 +32,12 @@ $langs->load("bills"); $langs->load("suppliers"); $langs->load("companies"); -$paiement = new PaiementFourn($db); -$paiement->fetch($_GET["id"], $user); -$paiement->info($_GET["id"]); +$id = GETPOST('id','int'); + +$object = new PaiementFourn($db); +$object->fetch($id); +$object->info($id); + /* * View @@ -42,15 +45,17 @@ $paiement->info($_GET["id"]); llxHeader(); -$head = payment_supplier_prepare_head($paiement); +$head = payment_supplier_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("SupplierPayment"), 0, 'payment'); -print '<table width="100%"><tr><td>'; -dol_print_object_info($paiement); -print '</td></tr></table>'; +dol_banner_tab($object, 'id', $linkback, -1, 'rowid', 'ref'); -print '</div>'; +dol_fiche_end(); + +print '<table width="100%"><tr><td>'; +dol_print_object_info($object); +print '</td></tr></table>'; llxFooter(); From c28dec8dc2a63d4a66ca6b4362d6103722d10763 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 21:04:20 +0200 Subject: [PATCH 113/128] Fix balance no more visible --- htdocs/compta/bank/bankentries_list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 271cb03cd6d..4e88ff8bf4a 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -100,10 +100,10 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder='ASC'; -if (! $sortfield) $sortfield='b.datev, b.dateo, b.rowid'; +if (! $sortfield) $sortfield='b.datev,b.dateo,b.rowid'; $mode_balance_ok=false; -//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected +//if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) // TODO Manage balance when account not selected if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) { $sortfield = 'b.datev,b.dateo,b.rowid'; From afd83a4454e92a21027029db8610fbcfbead80cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 21:25:27 +0200 Subject: [PATCH 114/128] Fix navigation on bank receipts --- htdocs/compta/bank/releve.php | 120 ++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 95e73183154..ee30812545a 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -47,10 +47,11 @@ $langs->load("companies"); $langs->load("bills"); $action=GETPOST('action', 'alpha'); -$id=GETPOST('account'); -$ref=GETPOST('ref'); -$dvid=GETPOST('dvid'); -$numref=GETPOST('num'); +$id=GETPOST('account','int'); +$ref=GETPOST('ref','alpha'); +$dvid=GETPOST('dvid','alpha'); +$numref=GETPOST('num','alpha'); +$ve=GETPOST("ve",'alpha'); // Security check $fieldid = (! empty($ref)?$ref:$id); @@ -95,6 +96,62 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage context to save list fields $contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); + +// Define number of receipt to show (current, previous or next one ?) +$found=false; +if ($_GET["rel"] == 'prev') +{ + // Recherche valeur pour num = numero releve precedent + $sql = "SELECT DISTINCT(b.num_releve) as num"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql.= " AND b.fk_account = ".$object->id; + $sql.= " ORDER BY b.num_releve DESC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found=true; + } + } +} +elseif ($_GET["rel"] == 'next') +{ + // Recherche valeur pour num = numero releve precedent + $sql = "SELECT DISTINCT(b.num_releve) as num"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; + $sql.= " AND b.fk_account = ".$object->id; + $sql.= " ORDER BY b.num_releve ASC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found=true; + } + } +} +else { + // On veut le releve num + $found=true; +} + + + + + $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql.= " b.fk_bordereau,"; @@ -104,7 +161,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank as b"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; $sql.= " WHERE b.num_releve='".$db->escape($numref)."'"; -if (!isset($numref)) $sql.= " OR b.num_releve is null"; +if (empty($numref)) $sql.= " OR b.num_releve is null"; $sql.= " AND b.fk_account = ".$object->id; $sql.= " AND b.fk_account = ba.rowid"; $sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day @@ -420,58 +477,6 @@ else /** * Show list of bank statements */ - $ve=$_GET["ve"]; - - // Define number of receipt to show (current, previous or next one ?) - $found=false; - if ($_GET["rel"] == 'prev') - { - // Recherche valeur pour num = numero releve precedent - $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve DESC"; - - dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - if ($numrows > 0) - { - $obj = $db->fetch_object($resql); - $numref = $obj->num; - $found=true; - } - } - } - elseif ($_GET["rel"] == 'next') - { - // Recherche valeur pour num = numero releve precedent - $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve ASC"; - - dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - if ($numrows > 0) - { - $obj = $db->fetch_object($resql); - $numref = $obj->num; - $found=true; - } - } - } - else { - // On veut le releve num - $found=true; - } $mesprevnext=''; $mesprevnext.='<div class="pagination"><ul>'; @@ -713,6 +718,7 @@ else dol_print_error($db); } } + print "</td>"; if ($objp->amount < 0) From 807724e0f0f18a04c789e9bb1d85633c9b89cfc5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 19:51:36 +0200 Subject: [PATCH 115/128] Add link other invoices of third party on supplier card to --- htdocs/fourn/facture/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ca9689292b4..c0e8ce23c4b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2028,6 +2028,7 @@ else $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherBills").'</a>)'; // Project if (! empty($conf->projet->enabled)) { From 5a4480bd1d57940b09166b44ce5d0016d5af4c06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 21:25:27 +0200 Subject: [PATCH 116/128] Fix navigation on bank receipts --- htdocs/compta/bank/releve.php | 120 ++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index ec61c39ee84..efa7c03f89b 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -47,10 +47,11 @@ $langs->load("companies"); $langs->load("bills"); $action=GETPOST('action', 'alpha'); -$id=GETPOST('account'); -$ref=GETPOST('ref'); -$dvid=GETPOST('dvid'); -$numref=GETPOST('num'); +$id=GETPOST('account','int'); +$ref=GETPOST('ref','alpha'); +$dvid=GETPOST('dvid','alpha'); +$numref=GETPOST('num','alpha'); +$ve=GETPOST("ve",'alpha'); // Security check $fieldid = (! empty($ref)?$ref:$id); @@ -95,6 +96,62 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage context to save list fields $contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); + +// Define number of receipt to show (current, previous or next one ?) +$found=false; +if ($_GET["rel"] == 'prev') +{ + // Recherche valeur pour num = numero releve precedent + $sql = "SELECT DISTINCT(b.num_releve) as num"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql.= " AND b.fk_account = ".$object->id; + $sql.= " ORDER BY b.num_releve DESC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found=true; + } + } +} +elseif ($_GET["rel"] == 'next') +{ + // Recherche valeur pour num = numero releve precedent + $sql = "SELECT DISTINCT(b.num_releve) as num"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; + $sql.= " AND b.fk_account = ".$object->id; + $sql.= " ORDER BY b.num_releve ASC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found=true; + } + } +} +else { + // On veut le releve num + $found=true; +} + + + + + $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql.= " b.fk_bordereau,"; @@ -104,7 +161,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank as b"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; $sql.= " WHERE b.num_releve='".$db->escape($numref)."'"; -if (!isset($numref)) $sql.= " OR b.num_releve is null"; +if (empty($numref)) $sql.= " OR b.num_releve is null"; $sql.= " AND b.fk_account = ".$object->id; $sql.= " AND b.fk_account = ba.rowid"; $sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day @@ -420,58 +477,6 @@ else /** * Show list of bank statements */ - $ve=$_GET["ve"]; - - // Define number of receipt to show (current, previous or next one ?) - $found=false; - if ($_GET["rel"] == 'prev') - { - // Recherche valeur pour num = numero releve precedent - $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve DESC"; - - dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - if ($numrows > 0) - { - $obj = $db->fetch_object($resql); - $numref = $obj->num; - $found=true; - } - } - } - elseif ($_GET["rel"] == 'next') - { - // Recherche valeur pour num = numero releve precedent - $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve ASC"; - - dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - if ($numrows > 0) - { - $obj = $db->fetch_object($resql); - $numref = $obj->num; - $found=true; - } - } - } - else { - // On veut le releve num - $found=true; - } $mesprevnext=''; $mesprevnext.='<div class="pagination"><ul>'; @@ -713,6 +718,7 @@ else dol_print_error($db); } } + print "</td>"; if ($objp->amount < 0) From 4b43faf0c186687dabaa2f1bef424526ccf39213 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 21:44:38 +0200 Subject: [PATCH 117/128] Fix lose filter --- htdocs/compta/bank/bankentries_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 4e88ff8bf4a..80463f10899 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -367,7 +367,7 @@ if (!empty($debit)) $param.='&debit='.$debit; if (!empty($credit)) $param.='&credit='.$credit; if (!empty($account)) $param.='&account='.$account; if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); -if ($search_conciliated != '') $param.='&search_conciliated='.urlencode($search_conciliated); +if ($search_conciliated != '' && $search_conciliated != '-1') $param.='&search_conciliated='.urlencode($search_conciliated); if (!empty($bid)) $param.='&bid='.$bid; if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); From ab280feaa56d97650e3a9342dfcf6a96907418b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 22:37:30 +0200 Subject: [PATCH 118/128] Move datepicker vars into lib_heas.js.php --- htdocs/core/class/html.form.class.php | 4 +- htdocs/core/js/datepicker.js.php | 151 -------------------------- htdocs/core/js/lib_head.js.php | 33 ++++++ htdocs/main.inc.php | 6 - 4 files changed, 36 insertions(+), 158 deletions(-) delete mode 100644 htdocs/core/js/datepicker.js.php diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c29c0f9e924..faf26f7c111 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4803,8 +4803,10 @@ class Form { $retstring.="<script type='text/javascript'>"; $retstring.="$(function(){ $('#".$prefix."').datepicker({ - autoclose: true, + dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."', + autoclose: true, todayHighlight: true,"; + // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) { $retstring.=" diff --git a/htdocs/core/js/datepicker.js.php b/htdocs/core/js/datepicker.js.php deleted file mode 100644 index 32b7ca43f5e..00000000000 --- a/htdocs/core/js/datepicker.js.php +++ /dev/null @@ -1,151 +0,0 @@ -<?php -/* Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -/** - * \file htdocs/core/js/datepicker.js.php - * \brief File that include javascript functions for datepickers - */ - -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); -if (! defined('NOLOGIN')) define('NOLOGIN',1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); - -session_cache_limiter(FALSE); - -require_once '../../main.inc.php'; - -// Define javascript type -top_httphead('text/javascript; charset=UTF-8'); -// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); -else header('Cache-Control: no-cache'); - - -// Define tradMonths javascript array (we define this in datepicker AND in parent page to avoid errors with IE8) -$tradMonths=array( - dol_escape_js($langs->transnoentitiesnoconv("January")), - dol_escape_js($langs->transnoentitiesnoconv("February")), - dol_escape_js($langs->transnoentitiesnoconv("March")), - dol_escape_js($langs->transnoentitiesnoconv("April")), - dol_escape_js($langs->transnoentitiesnoconv("May")), - dol_escape_js($langs->transnoentitiesnoconv("June")), - dol_escape_js($langs->transnoentitiesnoconv("July")), - dol_escape_js($langs->transnoentitiesnoconv("August")), - dol_escape_js($langs->transnoentitiesnoconv("September")), - dol_escape_js($langs->transnoentitiesnoconv("October")), - dol_escape_js($langs->transnoentitiesnoconv("November")), - dol_escape_js($langs->transnoentitiesnoconv("December")) -); - -$tradMonthsShort=array( - $langs->trans("JanuaryMin"), - $langs->trans("FebruaryMin"), - $langs->trans("MarchMin"), - $langs->trans("AprilMin"), - $langs->trans("MayMin"), - $langs->trans("JuneMin"), - $langs->trans("JulyMin"), - $langs->trans("AugustMin"), - $langs->trans("SeptemberMin"), - $langs->trans("OctoberMin"), - $langs->trans("NovemberMin"), - $langs->trans("DecemberMin") -); - -$tradDays=array( - $langs->trans("Sunday"), - $langs->trans("Monday"), - $langs->trans("Tuesday"), - $langs->trans("Wednesday"), - $langs->trans("Thursday"), - $langs->trans("Friday"), - $langs->trans("Saturday") -); - -$tradDaysShort=array( - $langs->trans("ShortSunday"), - $langs->trans("ShortMonday"), - $langs->trans("ShortTuesday"), - $langs->trans("ShortWednesday"), - $langs->trans("ShortThursday"), - $langs->trans("ShortFriday"), - $langs->trans("ShortSaturday") -); - -$tradDaysMin=array( - $langs->trans("SundayMin"), - $langs->trans("MondayMin"), - $langs->trans("TuesdayMin"), - $langs->trans("WednesdayMin"), - $langs->trans("ThursdayMin"), - $langs->trans("FridayMin"), - $langs->trans("SaturdayMin") -); -?> - - -// For jQuery date picker -var tradMonths = <?php echo json_encode($tradMonths) ?>; -var tradMonthsShort = <?php echo json_encode($tradMonthsShort) ?>; -var tradDays = <?php echo json_encode($tradDays) ?>; -var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>; -var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>; - - -// For JQuery date picker -$(document).ready(function() { - $.datepicker.setDefaults({ - autoSize: true, - changeMonth: true, - changeYear: true, - altField: '#timestamp', - altFormat: '@' // Gives a timestamp dateformat - }); -}); - -jQuery(function($){ - $.datepicker.regional['<?php echo $langs->defaultlang ?>'] = { - closeText: '<?php echo $langs->trans("Close2") ?>', - prevText: '<?php echo $langs->trans("Previous") ?>', - nextText: '<?php echo $langs->trans("Next") ?>', - currentText: '<?php echo $langs->trans("Now") ?>', - monthNames: tradMonths, - monthNamesShort: tradMonthsShort, - dayNames: tradDays, - dayNamesShort: tradDaysShort, - dayNamesMin: tradDaysMin, - weekHeader: '<?php echo $langs->trans("Week"); ?>', - dateFormat: '<?php echo $langs->trans("FormatDateShortJQuery"); ?>', - firstDay: <?php echo (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'); ?>, - isRTL: <?php echo ($langs->trans("DIRECTION")=='rtl'?'true':'false'); ?>, - showMonthAfterYear: false, /* TODO add specific to country */ - yearSuffix: '' /* TODO add specific to country */ - }; - $.datepicker.setDefaults($.datepicker.regional['<?php echo $langs->defaultlang ?>']); -}); - - -<?php -if (is_object($db)) $db->close(); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index f725e23cad5..188c8dc193a 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -117,6 +117,39 @@ var tradDays = <?php echo json_encode($tradDays) ?>; var tradDaysShort = <?php echo json_encode($tradDaysShort) ?>; var tradDaysMin = <?php echo json_encode($tradDaysMin) ?>; +// For JQuery date picker +$(document).ready(function() { + $.datepicker.setDefaults({ + autoSize: true, + changeMonth: true, + changeYear: true, + altField: '#timestamp', + altFormat: '@' // Gives a timestamp dateformat + }); +}); + +jQuery(function($){ + $.datepicker.regional['<?php echo $langs->defaultlang ?>'] = { + closeText: '<?php echo $langs->trans("Close2") ?>', + prevText: '<?php echo $langs->trans("Previous") ?>', + nextText: '<?php echo $langs->trans("Next") ?>', + currentText: '<?php echo $langs->trans("Now") ?>', + monthNames: tradMonths, + monthNamesShort: tradMonthsShort, + dayNames: tradDays, + dayNamesShort: tradDaysShort, + dayNamesMin: tradDaysMin, + weekHeader: '<?php echo $langs->trans("Week"); ?>', + dateFormat: '<?php echo $langs->trans("FormatDateShortJQuery"); ?>', + firstDay: <?php echo (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'); ?>, + isRTL: <?php echo ($langs->trans("DIRECTION")=='rtl'?'true':'false'); ?>, + showMonthAfterYear: false, /* TODO add specific to country */ + yearSuffix: '' /* TODO add specific to country */ + }; + $.datepicker.setDefaults($.datepicker.regional['<?php echo $langs->defaultlang ?>']); +}); + + /** * Set select2 translations (if module was loaded). diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6321856bfb3..973a7b95567 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1328,12 +1328,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print '<!-- Includes JS of Dolibarr -->'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/lib_head.js.php?lang='.$langs->defaultlang.($ext?'&'.$ext:'').'"></script>'."\n"; - // Add datepicker default options (needed by jquery datepicker!) - /*if (! defined('DISABLE_DATE_PICKER')) - { - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.($ext?'&'.$ext:'').'"></script>'."\n"; - }*/ - // JS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) { From e17c92b11cc7f900ac4e973506d15d1d84f4dba5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 22:40:33 +0200 Subject: [PATCH 119/128] Code comment --- htdocs/core/js/lib_head.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 188c8dc193a..a68995e5eeb 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -140,7 +140,7 @@ jQuery(function($){ dayNamesShort: tradDaysShort, dayNamesMin: tradDaysMin, weekHeader: '<?php echo $langs->trans("Week"); ?>', - dateFormat: '<?php echo $langs->trans("FormatDateShortJQuery"); ?>', + dateFormat: '<?php echo $langs->trans("FormatDateShortJQuery"); ?>', /* Note dd/mm/yy means year on 4 digit in jquery format */ firstDay: <?php echo (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'); ?>, isRTL: <?php echo ($langs->trans("DIRECTION")=='rtl'?'true':'false'); ?>, showMonthAfterYear: false, /* TODO add specific to country */ From c0147864467cfe651d026d4340a6770f9b7108ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 23:07:27 +0200 Subject: [PATCH 120/128] NEW On reconciliation, show balance including all reconciliated fields --- htdocs/compta/bank/bankentries_list.php | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 80463f10899..319f5cb05db 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -963,6 +963,55 @@ if ($resql) else dol_print_error($db); $balancecalculated=true; + + // Output a line with start balance + if ($user->rights->banque->consolidate && $action == 'reconcile') + { + $tmpnbfieldbeforebalance=0; + $tmpnbfieldafterbalance=0; + $balancefieldfound=false; + foreach($arrayfields as $key => $val) + { + if ($key == 'balance') + { + $balancefieldfound=true; + continue; + } + if (! empty($arrayfields[$key]['checked'])) + { + if (! $balancefieldfound) $tmpnbfieldbeforebalance++; + else $tmpnbfieldafterbalance++; + } + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + if (! empty($arrayfields[$key]['checked'])) + { + if (! $balancefieldfound) $tmpnbfieldbeforebalance++; + else $tmpnbfieldafterbalance++; + } + } + } + } + + print '<tr class="oddeven trforbreak">'; + if ($tmpnbfieldbeforebalance) + { + print '<td colspan="'.$tmpnbfieldbeforebalance.'">'; + print '</td>'; + } + print '<td align="right">'; + print price2num($balance, 'MT'); + print '</td>'; + print '<td colspan="'.($tmpnbfieldafterbalance+2).'">'; + print '</td>'; + print '</tr>'; + } } $balance = price2num($balance + ($sign * $objp->amount),'MT'); From 07d16afe3bc2bb685c3f4cd405a6a1fa7cf5d5cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 23:10:40 +0200 Subject: [PATCH 121/128] Save one space --- htdocs/compta/bank/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 27de7b6e863..0fc7657f184 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -669,7 +669,6 @@ else if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) { - print '<br>'; print '<div class="underbanner clearboth"></div>'; From d06f260b9496648e127a03da1b3c2f2d3e9269b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 23:13:26 +0200 Subject: [PATCH 122/128] Fix amount format --- htdocs/compta/bank/bankentries_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 319f5cb05db..326e3ece569 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1006,7 +1006,7 @@ if ($resql) print '</td>'; } print '<td align="right">'; - print price2num($balance, 'MT'); + print price(price2num($balance, 'MT'), 1, $langs); print '</td>'; print '<td colspan="'.($tmpnbfieldafterbalance+2).'">'; print '</td>'; From b90770c30c05c90c2dae2b3f917570f394c199db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 13 Oct 2017 23:38:57 +0200 Subject: [PATCH 123/128] NEW Can rename (so reorder) bank receipts --- htdocs/compta/bank/releve.php | 46 +++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index ee30812545a..fb43f098583 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -52,6 +52,9 @@ $ref=GETPOST('ref','alpha'); $dvid=GETPOST('dvid','alpha'); $numref=GETPOST('num','alpha'); $ve=GETPOST("ve",'alpha'); +$brref=GETPOST('brref','alpha'); +$oldbankreceipt=GETPOST('oldbankreceipt','alpha'); +$newbankreceipt=GETPOST('newbankreceipt','alpha'); // Security check $fieldid = (! empty($ref)?$ref:$id); @@ -149,9 +152,6 @@ else { } - - - $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql.= " b.fk_bordereau,"; @@ -174,6 +174,16 @@ $sqlrequestforbankline = $sql; * Actions */ +if ($action == 'confirm_editbankreceipt' && ! empty($oldbankreceipt) && ! empty($newbankreceipt)) +{ + // TODO Add a test to check newbankreceipt does not exists yet + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'"'; + $result = $db->query($sqlupdate); + if ($result < 0) dol_print_error($db); + + $action='view'; +} + // ZIP creation if ($action=="dl" && $numref > 0) { @@ -404,16 +414,22 @@ if (empty($numref)) } print '</div>'; - print '<br><br>'; print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); + print '<form name="aaa" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="confirm_editbankreceipt">'; + print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; + print '<input type="hidden" name="account" value="'.$object->id.'">'; + print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td>'.$langs->trans("AccountStatement").'</td>'; print '<td align="right">'.$langs->trans("InitialBankBalance").'</td>'; print '<td align="right">'.$langs->trans("EndBankBalance").'</td>'; + print '<td></td>'; print '</tr>'; $balancestart=array(); @@ -429,7 +445,20 @@ if (empty($numref)) } else { - print '<tr class="oddeven"><td><a href="releve.php?num='.$objp->numr.'&account='.$object->id.'">'.$objp->numr.'</a></td>'; + print '<tr class="oddeven">'; + print '<td>'; + if ($action != 'editbankreceipt' || $objp->numr != $brref) + { + print '<a href="releve.php?num='.$objp->numr.'&account='.$object->id.'">'.$objp->numr.'</a>'; + } + else + { + print '<input type="hidden" name="oldbankreceipt" value="'.$objp->numr.'">'; + print '<input type="text" name="newbankreceipt" value="'.$objp->numr.'">'; + print '<input type="submit" class="button" name="actionnewbankreceipt" value="'.$langs->trans("Rename").'">'; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; + } + print '</td>'; // Calculate start amount $sql = "SELECT sum(b.amount) as amount"; @@ -459,11 +488,18 @@ if (empty($numref)) } print '<td align="right">'.price(($balancestart[$objp->numr]+$content[$objp->numr]),'',$langs,1,-1,-1,$conf->currency).'</td>'; + print '<td align="center">'; + if ($user->rights->banque->consolidate && $action != 'editbankreceipt') { + print '<a href="'.$_SERVER["PHP_SELF"].'?account='.$object->id.'&action=editbankreceipt&brref='.$objp->numr.'">'.img_edit().'</a>'; + } + print '</td>'; + print '</tr>'."\n"; } $i++; } print "</table>\n"; + print '</form>'; print "\n</div>\n"; } From 56e27d785adeb7135490fe7e1aadc5a7387f279f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 14 Oct 2017 01:03:59 +0200 Subject: [PATCH 124/128] CSS on report --- htdocs/compta/resultat/clientfourn.php | 16 ++++++++-------- htdocs/compta/resultat/index.php | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index eea830dfbc5..485b9a9b47a 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -338,7 +338,7 @@ else /* * Factures clients */ - print '<tr><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>'; if ($modecompta == 'CREANCES-DETTES') { @@ -500,7 +500,7 @@ else $sql .= " GROUP BY name, socid"; $sql.= $db->order($sortfield, $sortorder); - print '<tr><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>'; $subtotal_ht = 0; $subtotal_ttc = 0; @@ -554,7 +554,7 @@ else * Charges sociales non deductibles */ - print '<tr><td colspan="4">'.$langs->trans("SocialContributionsNondeductibles").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SocialContributionsNondeductibles").'</td></tr>'; if ($modecompta == 'CREANCES-DETTES') { @@ -630,7 +630,7 @@ else * Charges sociales deductibles */ - print '<tr><td colspan="4">'.$langs->trans("SocialContributionsDeductibles").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SocialContributionsDeductibles").'</td></tr>'; if ($modecompta == 'CREANCES-DETTES') { @@ -727,7 +727,7 @@ else if (! empty($conf->salaries->enabled)) { - print '<tr><td colspan="4">'.$langs->trans("Salaries").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Salaries").'</td></tr>'; if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') { @@ -840,7 +840,7 @@ else $sql.= $db->order($newsortfield, $sortorder); } - print '<tr><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>'; dol_syslog("get expense report outcome"); $result=$db->query($sql); @@ -890,7 +890,7 @@ else if (! empty($conf->don->enabled)) { - print '<tr><td colspan="4">'.$langs->trans("Donations").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>'; if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') { @@ -972,7 +972,7 @@ else * VAT */ - print '<tr><td colspan="4">'.$langs->trans("VAT").'</td></tr>'; + print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("VAT").'</td></tr>'; $subtotal_ht = 0; $subtotal_ttc = 0; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index bd1d8effcc7..20333675542 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -893,10 +893,19 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) } print '</tr>'; print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>'; +// Loop on each year to ouput for ($annee = $year_start ; $annee <= $year_end ; $annee++) { - print '<td class="liste_titre" align="center">'.$langs->trans("Outcome").'</td>'; - print '<td class="liste_titre" align="center" class="borderrightlight">'.$langs->trans("Income").'</td>'; + print '<td class="liste_titre" align="center">'; + $htmlhelp=''; + // if ($modecompta == 'RECETTES-DEPENSES') $htmlhelp=$langs->trans("PurchasesPlusVATEarnedAndDue"); + print $form->textwithpicto($langs->trans("Outcome"), $htmlhelp); + print '</td>'; + print '<td class="liste_titre" align="center" class="borderrightlight">'; + $htmlhelp=''; + // if ($modecompta == 'RECETTES-DEPENSES') $htmlhelp=$langs->trans("SalesPlusVATToRetreive"); + print $form->textwithpicto($langs->trans("Income"), $htmlhelp); + print '</td>'; } print '</tr>'; @@ -967,7 +976,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) { $in=(isset($totentrees[$annee])?price2num($totentrees[$annee], 'MT'):0); $out=(isset($totsorties[$annee])?price2num($totsorties[$annee],'MT'):0); - print price($in-$out).'</td>'; + print price(price2num($in-$out, 'MT')).'</td>'; // print '<td> </td>'; } } From f853dbc152dedd90a3227e61bdd0c6ff95929c7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 14 Oct 2017 02:55:07 +0200 Subject: [PATCH 125/128] Add spec for SEPA --- dev/resources/sepa/pain.001.001.03.xsd | 921 +++++++++++++++++++++++++ dev/resources/sepa/pain.008.001.02.xsd | 879 +++++++++++++++++++++++ dev/resources/sepa/text.txt | 2 + 3 files changed, 1802 insertions(+) create mode 100644 dev/resources/sepa/pain.001.001.03.xsd create mode 100644 dev/resources/sepa/pain.008.001.02.xsd create mode 100644 dev/resources/sepa/text.txt diff --git a/dev/resources/sepa/pain.001.001.03.xsd b/dev/resources/sepa/pain.001.001.03.xsd new file mode 100644 index 00000000000..8649779919c --- /dev/null +++ b/dev/resources/sepa/pain.001.001.03.xsd @@ -0,0 +1,921 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!--Generated by SWIFTStandards Workstation (build:R6.1.0.2) on 2009 Jan 08 17:30:53--> +<xs:schema xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"> + <xs:element name="Document" type="Document"/> + <xs:complexType name="AccountIdentification4Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="IBAN" type="IBAN2007Identifier"/> + <xs:element name="Othr" type="GenericAccountIdentification1"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="AccountSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalAccountIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="ActiveOrHistoricCurrencyAndAmount_SimpleType"> + <xs:restriction base="xs:decimal"> + <xs:minInclusive value="0"/> + <xs:fractionDigits value="5"/> + <xs:totalDigits value="18"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="ActiveOrHistoricCurrencyAndAmount"> + <xs:simpleContent> + <xs:extension base="ActiveOrHistoricCurrencyAndAmount_SimpleType"> + <xs:attribute name="Ccy" type="ActiveOrHistoricCurrencyCode" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:simpleType name="ActiveOrHistoricCurrencyCode"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{3,3}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="AddressType2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="ADDR"/> + <xs:enumeration value="PBOX"/> + <xs:enumeration value="HOME"/> + <xs:enumeration value="BIZZ"/> + <xs:enumeration value="MLTO"/> + <xs:enumeration value="DLVY"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="AmountType3Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="InstdAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element name="EqvtAmt" type="EquivalentAmount2"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="AnyBICIdentifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="Authorisation1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="Authorisation1Code"/> + <xs:element name="Prtry" type="Max128Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="Authorisation1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AUTH"/> + <xs:enumeration value="FDET"/> + <xs:enumeration value="FSUM"/> + <xs:enumeration value="ILEV"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="BICIdentifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="BaseOneRate"> + <xs:restriction base="xs:decimal"> + <xs:fractionDigits value="10"/> + <xs:totalDigits value="11"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="BatchBookingIndicator"> + <xs:restriction base="xs:boolean"/> + </xs:simpleType> + <xs:complexType name="BranchAndFinancialInstitutionIdentification4"> + <xs:sequence> + <xs:element name="FinInstnId" type="FinancialInstitutionIdentification7"/> + <xs:element maxOccurs="1" minOccurs="0" name="BrnchId" type="BranchData2"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="BranchData2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstlAdr" type="PostalAddress6"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CashAccount16"> + <xs:sequence> + <xs:element name="Id" type="AccountIdentification4Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="CashAccountType2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ccy" type="ActiveOrHistoricCurrencyCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max70Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CashAccountType2"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="CashAccountType4Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="CashAccountType4Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CASH"/> + <xs:enumeration value="CHAR"/> + <xs:enumeration value="COMM"/> + <xs:enumeration value="TAXE"/> + <xs:enumeration value="CISH"/> + <xs:enumeration value="TRAS"/> + <xs:enumeration value="SACC"/> + <xs:enumeration value="CACC"/> + <xs:enumeration value="SVGS"/> + <xs:enumeration value="ONDP"/> + <xs:enumeration value="MGLD"/> + <xs:enumeration value="NREX"/> + <xs:enumeration value="MOMA"/> + <xs:enumeration value="LOAN"/> + <xs:enumeration value="SLRY"/> + <xs:enumeration value="ODFT"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="CategoryPurpose1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalCategoryPurpose1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="ChargeBearerType1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="DEBT"/> + <xs:enumeration value="CRED"/> + <xs:enumeration value="SHAR"/> + <xs:enumeration value="SLEV"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="Cheque6"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="ChqTp" type="ChequeType2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChqNb" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChqFr" type="NameAndAddress10"/> + <xs:element maxOccurs="1" minOccurs="0" name="DlvryMtd" type="ChequeDeliveryMethod1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="DlvrTo" type="NameAndAddress10"/> + <xs:element maxOccurs="1" minOccurs="0" name="InstrPrty" type="Priority2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChqMtrtyDt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="FrmsCd" type="Max35Text"/> + <xs:element maxOccurs="2" minOccurs="0" name="MemoFld" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RgnlClrZone" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PrtLctn" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="ChequeDelivery1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="MLDB"/> + <xs:enumeration value="MLCD"/> + <xs:enumeration value="MLFA"/> + <xs:enumeration value="CRDB"/> + <xs:enumeration value="CRCD"/> + <xs:enumeration value="CRFA"/> + <xs:enumeration value="PUDB"/> + <xs:enumeration value="PUCD"/> + <xs:enumeration value="PUFA"/> + <xs:enumeration value="RGDB"/> + <xs:enumeration value="RGCD"/> + <xs:enumeration value="RGFA"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="ChequeDeliveryMethod1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ChequeDelivery1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="ChequeType2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CCHQ"/> + <xs:enumeration value="CCCH"/> + <xs:enumeration value="BCHQ"/> + <xs:enumeration value="DRFT"/> + <xs:enumeration value="ELDR"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="ClearingSystemIdentification2Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalClearingSystemIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ClearingSystemMemberIdentification2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="ClrSysId" type="ClearingSystemIdentification2Choice"/> + <xs:element name="MmbId" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ContactDetails2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="NmPrfx" type="NamePrefix1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PhneNb" type="PhoneNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="MobNb" type="PhoneNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="FaxNb" type="PhoneNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="EmailAdr" type="Max2048Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Othr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="CountryCode"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{2,2}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="CreditDebitCode"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CRDT"/> + <xs:enumeration value="DBIT"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="CreditTransferTransactionInformation10"> + <xs:sequence> + <xs:element name="PmtId" type="PaymentIdentification1"/> + <xs:element maxOccurs="1" minOccurs="0" name="PmtTpInf" type="PaymentTypeInformation19"/> + <xs:element name="Amt" type="AmountType3Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="XchgRateInf" type="ExchangeRateInformation1"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgBr" type="ChargeBearerType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChqInstr" type="Cheque6"/> + <xs:element maxOccurs="1" minOccurs="0" name="UltmtDbtr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="IntrmyAgt1" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="IntrmyAgt1Acct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="IntrmyAgt2" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="IntrmyAgt2Acct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="IntrmyAgt3" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="IntrmyAgt3Acct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrAgtAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="Cdtr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="UltmtCdtr" type="PartyIdentification32"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="InstrForCdtrAgt" type="InstructionForCreditorAgent1"/> + <xs:element maxOccurs="1" minOccurs="0" name="InstrForDbtrAgt" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Purp" type="Purpose2Choice"/> + <xs:element maxOccurs="10" minOccurs="0" name="RgltryRptg" type="RegulatoryReporting3"/> + <xs:element maxOccurs="1" minOccurs="0" name="Tax" type="TaxInformation3"/> + <xs:element maxOccurs="10" minOccurs="0" name="RltdRmtInf" type="RemittanceLocation2"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtInf" type="RemittanceInformation5"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CreditorReferenceInformation2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="CreditorReferenceType2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ref" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CreditorReferenceType1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="DocumentType3Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CreditorReferenceType2"> + <xs:sequence> + <xs:element name="CdOrPrtry" type="CreditorReferenceType1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CustomerCreditTransferInitiationV03"> + <xs:sequence> + <xs:element name="GrpHdr" type="GroupHeader32"/> + <xs:element maxOccurs="unbounded" minOccurs="1" name="PmtInf" type="PaymentInstructionInformation3"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="DateAndPlaceOfBirth"> + <xs:sequence> + <xs:element name="BirthDt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="PrvcOfBirth" type="Max35Text"/> + <xs:element name="CityOfBirth" type="Max35Text"/> + <xs:element name="CtryOfBirth" type="CountryCode"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="DatePeriodDetails"> + <xs:sequence> + <xs:element name="FrDt" type="ISODate"/> + <xs:element name="ToDt" type="ISODate"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="DecimalNumber"> + <xs:restriction base="xs:decimal"> + <xs:fractionDigits value="17"/> + <xs:totalDigits value="18"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="Document"> + <xs:sequence> + <xs:element name="CstmrCdtTrfInitn" type="CustomerCreditTransferInitiationV03"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="DocumentAdjustment1"> + <xs:sequence> + <xs:element name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtDbtInd" type="CreditDebitCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="Rsn" type="Max4Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="AddtlInf" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="DocumentType3Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="RADM"/> + <xs:enumeration value="RPIN"/> + <xs:enumeration value="FXDR"/> + <xs:enumeration value="DISP"/> + <xs:enumeration value="PUOR"/> + <xs:enumeration value="SCOR"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="DocumentType5Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="MSIN"/> + <xs:enumeration value="CNFA"/> + <xs:enumeration value="DNFA"/> + <xs:enumeration value="CINV"/> + <xs:enumeration value="CREN"/> + <xs:enumeration value="DEBN"/> + <xs:enumeration value="HIRI"/> + <xs:enumeration value="SBIN"/> + <xs:enumeration value="CMCN"/> + <xs:enumeration value="SOAC"/> + <xs:enumeration value="DISP"/> + <xs:enumeration value="BOLD"/> + <xs:enumeration value="VCHR"/> + <xs:enumeration value="AROI"/> + <xs:enumeration value="TSUT"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="EquivalentAmount2"> + <xs:sequence> + <xs:element name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element name="CcyOfTrf" type="ActiveOrHistoricCurrencyCode"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ExchangeRateInformation1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="XchgRate" type="BaseOneRate"/> + <xs:element maxOccurs="1" minOccurs="0" name="RateTp" type="ExchangeRateType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtrctId" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="ExchangeRateType1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="SPOT"/> + <xs:enumeration value="SALE"/> + <xs:enumeration value="AGRD"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalAccountIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalCategoryPurpose1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalClearingSystemIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="5"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalFinancialInstitutionIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalLocalInstrument1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="35"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalOrganisationIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalPersonIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalPurpose1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalServiceLevel1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="FinancialIdentificationSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalFinancialInstitutionIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="FinancialInstitutionIdentification7"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="BIC" type="BICIdentifier"/> + <xs:element maxOccurs="1" minOccurs="0" name="ClrSysMmbId" type="ClearingSystemMemberIdentification2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstlAdr" type="PostalAddress6"/> + <xs:element maxOccurs="1" minOccurs="0" name="Othr" type="GenericFinancialIdentification1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GenericAccountIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max34Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="AccountSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GenericFinancialIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="FinancialIdentificationSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GenericOrganisationIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="OrganisationIdentificationSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GenericPersonIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="PersonIdentificationSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GroupHeader32"> + <xs:sequence> + <xs:element name="MsgId" type="Max35Text"/> + <xs:element name="CreDtTm" type="ISODateTime"/> + <xs:element maxOccurs="2" minOccurs="0" name="Authstn" type="Authorisation1Choice"/> + <xs:element name="NbOfTxs" type="Max15NumericText"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtrlSum" type="DecimalNumber"/> + <xs:element name="InitgPty" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="FwdgAgt" type="BranchAndFinancialInstitutionIdentification4"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="IBAN2007Identifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ISODate"> + <xs:restriction base="xs:date"/> + </xs:simpleType> + <xs:simpleType name="ISODateTime"> + <xs:restriction base="xs:dateTime"/> + </xs:simpleType> + <xs:simpleType name="Instruction3Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CHQB"/> + <xs:enumeration value="HOLD"/> + <xs:enumeration value="PHOB"/> + <xs:enumeration value="TELB"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="InstructionForCreditorAgent1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Cd" type="Instruction3Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="InstrInf" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="LocalInstrument2Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalLocalInstrument1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="Max10Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="10"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max128Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="128"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max140Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="140"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max15NumericText"> + <xs:restriction base="xs:string"> + <xs:pattern value="[0-9]{1,15}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max16Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="16"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max2048Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="2048"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max34Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="34"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max35Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="35"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max4Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max70Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="70"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="NameAndAddress10"> + <xs:sequence> + <xs:element name="Nm" type="Max140Text"/> + <xs:element name="Adr" type="PostalAddress6"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="NamePrefix1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="DOCT"/> + <xs:enumeration value="MIST"/> + <xs:enumeration value="MISS"/> + <xs:enumeration value="MADM"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Number"> + <xs:restriction base="xs:decimal"> + <xs:fractionDigits value="0"/> + <xs:totalDigits value="18"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="OrganisationIdentification4"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="BICOrBEI" type="AnyBICIdentifier"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Othr" type="GenericOrganisationIdentification1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="OrganisationIdentificationSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalOrganisationIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="Party6Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="OrgId" type="OrganisationIdentification4"/> + <xs:element name="PrvtId" type="PersonIdentification5"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PartyIdentification32"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstlAdr" type="PostalAddress6"/> + <xs:element maxOccurs="1" minOccurs="0" name="Id" type="Party6Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtryOfRes" type="CountryCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtctDtls" type="ContactDetails2"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PaymentIdentification1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="InstrId" type="Max35Text"/> + <xs:element name="EndToEndId" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PaymentInstructionInformation3"> + <xs:sequence> + <xs:element name="PmtInfId" type="Max35Text"/> + <xs:element name="PmtMtd" type="PaymentMethod3Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="BtchBookg" type="BatchBookingIndicator"/> + <xs:element maxOccurs="1" minOccurs="0" name="NbOfTxs" type="Max15NumericText"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtrlSum" type="DecimalNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="PmtTpInf" type="PaymentTypeInformation19"/> + <xs:element name="ReqdExctnDt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="PoolgAdjstmntDt" type="ISODate"/> + <xs:element name="Dbtr" type="PartyIdentification32"/> + <xs:element name="DbtrAcct" type="CashAccount16"/> + <xs:element name="DbtrAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="DbtrAgtAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="UltmtDbtr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgBr" type="ChargeBearerType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgsAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgsAcctAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="unbounded" minOccurs="1" name="CdtTrfTxInf" type="CreditTransferTransactionInformation10"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="PaymentMethod3Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CHK"/> + <xs:enumeration value="TRF"/> + <xs:enumeration value="TRA"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="PaymentTypeInformation19"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="InstrPrty" type="Priority2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="SvcLvl" type="ServiceLevel8Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="LclInstrm" type="LocalInstrument2Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtgyPurp" type="CategoryPurpose1Choice"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="PercentageRate"> + <xs:restriction base="xs:decimal"> + <xs:fractionDigits value="10"/> + <xs:totalDigits value="11"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="PersonIdentification5"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="DtAndPlcOfBirth" type="DateAndPlaceOfBirth"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Othr" type="GenericPersonIdentification1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PersonIdentificationSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalPersonIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="PhoneNumber"> + <xs:restriction base="xs:string"> + <xs:pattern value="\+[0-9]{1,3}-[0-9()+\-]{1,30}"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="PostalAddress6"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="AdrTp" type="AddressType2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dept" type="Max70Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SubDept" type="Max70Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="StrtNm" type="Max70Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="BldgNb" type="Max16Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstCd" type="Max16Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TwnNm" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtrySubDvsn" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctry" type="CountryCode"/> + <xs:element maxOccurs="7" minOccurs="0" name="AdrLine" type="Max70Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="Priority2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="HIGH"/> + <xs:enumeration value="NORM"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="Purpose2Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalPurpose1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ReferredDocumentInformation3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="ReferredDocumentType2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nb" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RltdDt" type="ISODate"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ReferredDocumentType1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="DocumentType5Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ReferredDocumentType2"> + <xs:sequence> + <xs:element name="CdOrPrtry" type="ReferredDocumentType1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RegulatoryAuthority2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctry" type="CountryCode"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RegulatoryReporting3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="DbtCdtRptgInd" type="RegulatoryReportingType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="Authrty" type="RegulatoryAuthority2"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Dtls" type="StructuredRegulatoryReporting3"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="RegulatoryReportingType1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CRED"/> + <xs:enumeration value="DEBT"/> + <xs:enumeration value="BOTH"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="RemittanceAmount1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="DuePyblAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="DscntApldAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtNoteAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="AdjstmntAmtAndRsn" type="DocumentAdjustment1"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtdAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RemittanceInformation5"> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Ustrd" type="Max140Text"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Strd" type="StructuredRemittanceInformation7"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RemittanceLocation2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="RmtId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtLctnMtd" type="RemittanceLocationMethod2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtLctnElctrncAdr" type="Max2048Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtLctnPstlAdr" type="NameAndAddress10"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="RemittanceLocationMethod2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="FAXI"/> + <xs:enumeration value="EDIC"/> + <xs:enumeration value="URID"/> + <xs:enumeration value="EMAL"/> + <xs:enumeration value="POST"/> + <xs:enumeration value="SMSM"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="ServiceLevel8Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalServiceLevel1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="StructuredRegulatoryReporting3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctry" type="CountryCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="Cd" type="Max10Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Inf" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="StructuredRemittanceInformation7"> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="RfrdDocInf" type="ReferredDocumentInformation3"/> + <xs:element maxOccurs="1" minOccurs="0" name="RfrdDocAmt" type="RemittanceAmount1"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrRefInf" type="CreditorReferenceInformation2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Invcr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="Invcee" type="PartyIdentification32"/> + <xs:element maxOccurs="3" minOccurs="0" name="AddtlRmtInf" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxAmount1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Rate" type="PercentageRate"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxblBaseAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="TtlAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Dtls" type="TaxRecordDetails1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxAuthorisation1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Titl" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxInformation3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Cdtr" type="TaxParty1"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dbtr" type="TaxParty2"/> + <xs:element maxOccurs="1" minOccurs="0" name="AdmstnZn" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RefNb" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Mtd" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TtlTaxblBaseAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="TtlTaxAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="SeqNb" type="Number"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Rcrd" type="TaxRecord1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxParty1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="TaxId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RegnId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxTp" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxParty2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="TaxId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RegnId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxTp" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Authstn" type="TaxAuthorisation1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxPeriod1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Yr" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="TaxRecordPeriod1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="FrToDt" type="DatePeriodDetails"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxRecord1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctgy" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtgyDtls" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="DbtrSts" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="CertId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="FrmsCd" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Prd" type="TaxPeriod1"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxAmt" type="TaxAmount1"/> + <xs:element maxOccurs="1" minOccurs="0" name="AddtlInf" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxRecordDetails1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Prd" type="TaxPeriod1"/> + <xs:element name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="TaxRecordPeriod1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="MM01"/> + <xs:enumeration value="MM02"/> + <xs:enumeration value="MM03"/> + <xs:enumeration value="MM04"/> + <xs:enumeration value="MM05"/> + <xs:enumeration value="MM06"/> + <xs:enumeration value="MM07"/> + <xs:enumeration value="MM08"/> + <xs:enumeration value="MM09"/> + <xs:enumeration value="MM10"/> + <xs:enumeration value="MM11"/> + <xs:enumeration value="MM12"/> + <xs:enumeration value="QTR1"/> + <xs:enumeration value="QTR2"/> + <xs:enumeration value="QTR3"/> + <xs:enumeration value="QTR4"/> + <xs:enumeration value="HLF1"/> + <xs:enumeration value="HLF2"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/dev/resources/sepa/pain.008.001.02.xsd b/dev/resources/sepa/pain.008.001.02.xsd new file mode 100644 index 00000000000..63359725617 --- /dev/null +++ b/dev/resources/sepa/pain.008.001.02.xsd @@ -0,0 +1,879 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!--Generated by SWIFTStandards Workstation (build:R6.1.0.2) on 2009 Jan 08 17:30:53--> +<xs:schema xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"> + <xs:element name="Document" type="Document"/> + <xs:complexType name="AccountIdentification4Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="IBAN" type="IBAN2007Identifier"/> + <xs:element name="Othr" type="GenericAccountIdentification1"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="AccountSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalAccountIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="ActiveOrHistoricCurrencyAndAmount_SimpleType"> + <xs:restriction base="xs:decimal"> + <xs:minInclusive value="0"/> + <xs:fractionDigits value="5"/> + <xs:totalDigits value="18"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="ActiveOrHistoricCurrencyAndAmount"> + <xs:simpleContent> + <xs:extension base="ActiveOrHistoricCurrencyAndAmount_SimpleType"> + <xs:attribute name="Ccy" type="ActiveOrHistoricCurrencyCode" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:simpleType name="ActiveOrHistoricCurrencyCode"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{3,3}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="AddressType2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="ADDR"/> + <xs:enumeration value="PBOX"/> + <xs:enumeration value="HOME"/> + <xs:enumeration value="BIZZ"/> + <xs:enumeration value="MLTO"/> + <xs:enumeration value="DLVY"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="AmendmentInformationDetails6"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlMndtId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlCdtrSchmeId" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlCdtrAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlCdtrAgtAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlDbtr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlDbtrAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlDbtrAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlDbtrAgtAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlFnlColltnDt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="OrgnlFrqcy" type="Frequency1Code"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="AnyBICIdentifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="Authorisation1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="Authorisation1Code"/> + <xs:element name="Prtry" type="Max128Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="Authorisation1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AUTH"/> + <xs:enumeration value="FDET"/> + <xs:enumeration value="FSUM"/> + <xs:enumeration value="ILEV"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="BICIdentifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="BatchBookingIndicator"> + <xs:restriction base="xs:boolean"/> + </xs:simpleType> + <xs:complexType name="BranchAndFinancialInstitutionIdentification4"> + <xs:sequence> + <xs:element name="FinInstnId" type="FinancialInstitutionIdentification7"/> + <xs:element maxOccurs="1" minOccurs="0" name="BrnchId" type="BranchData2"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="BranchData2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstlAdr" type="PostalAddress6"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CashAccount16"> + <xs:sequence> + <xs:element name="Id" type="AccountIdentification4Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="CashAccountType2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ccy" type="ActiveOrHistoricCurrencyCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max70Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CashAccountType2"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="CashAccountType4Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="CashAccountType4Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CASH"/> + <xs:enumeration value="CHAR"/> + <xs:enumeration value="COMM"/> + <xs:enumeration value="TAXE"/> + <xs:enumeration value="CISH"/> + <xs:enumeration value="TRAS"/> + <xs:enumeration value="SACC"/> + <xs:enumeration value="CACC"/> + <xs:enumeration value="SVGS"/> + <xs:enumeration value="ONDP"/> + <xs:enumeration value="MGLD"/> + <xs:enumeration value="NREX"/> + <xs:enumeration value="MOMA"/> + <xs:enumeration value="LOAN"/> + <xs:enumeration value="SLRY"/> + <xs:enumeration value="ODFT"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="CategoryPurpose1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalCategoryPurpose1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="ChargeBearerType1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="DEBT"/> + <xs:enumeration value="CRED"/> + <xs:enumeration value="SHAR"/> + <xs:enumeration value="SLEV"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="ClearingSystemIdentification2Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalClearingSystemIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ClearingSystemMemberIdentification2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="ClrSysId" type="ClearingSystemIdentification2Choice"/> + <xs:element name="MmbId" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ContactDetails2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="NmPrfx" type="NamePrefix1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PhneNb" type="PhoneNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="MobNb" type="PhoneNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="FaxNb" type="PhoneNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="EmailAdr" type="Max2048Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Othr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="CountryCode"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{2,2}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="CreditDebitCode"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CRDT"/> + <xs:enumeration value="DBIT"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="CreditorReferenceInformation2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="CreditorReferenceType2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ref" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CreditorReferenceType1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="DocumentType3Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CreditorReferenceType2"> + <xs:sequence> + <xs:element name="CdOrPrtry" type="CreditorReferenceType1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CustomerDirectDebitInitiationV02"> + <xs:sequence> + <xs:element name="GrpHdr" type="GroupHeader39"/> + <xs:element maxOccurs="unbounded" minOccurs="1" name="PmtInf" type="PaymentInstructionInformation4"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="DateAndPlaceOfBirth"> + <xs:sequence> + <xs:element name="BirthDt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="PrvcOfBirth" type="Max35Text"/> + <xs:element name="CityOfBirth" type="Max35Text"/> + <xs:element name="CtryOfBirth" type="CountryCode"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="DatePeriodDetails"> + <xs:sequence> + <xs:element name="FrDt" type="ISODate"/> + <xs:element name="ToDt" type="ISODate"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="DecimalNumber"> + <xs:restriction base="xs:decimal"> + <xs:fractionDigits value="17"/> + <xs:totalDigits value="18"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="DirectDebitTransaction6"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="MndtRltdInf" type="MandateRelatedInformation6"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrSchmeId" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="PreNtfctnId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PreNtfctnDt" type="ISODate"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="DirectDebitTransactionInformation9"> + <xs:sequence> + <xs:element name="PmtId" type="PaymentIdentification1"/> + <xs:element maxOccurs="1" minOccurs="0" name="PmtTpInf" type="PaymentTypeInformation20"/> + <xs:element name="InstdAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgBr" type="ChargeBearerType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="DrctDbtTx" type="DirectDebitTransaction6"/> + <xs:element maxOccurs="1" minOccurs="0" name="UltmtCdtr" type="PartyIdentification32"/> + <xs:element name="DbtrAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="DbtrAgtAcct" type="CashAccount16"/> + <xs:element name="Dbtr" type="PartyIdentification32"/> + <xs:element name="DbtrAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="UltmtDbtr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="InstrForCdtrAgt" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Purp" type="Purpose2Choice"/> + <xs:element maxOccurs="10" minOccurs="0" name="RgltryRptg" type="RegulatoryReporting3"/> + <xs:element maxOccurs="1" minOccurs="0" name="Tax" type="TaxInformation3"/> + <xs:element maxOccurs="10" minOccurs="0" name="RltdRmtInf" type="RemittanceLocation2"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtInf" type="RemittanceInformation5"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="Document"> + <xs:sequence> + <xs:element name="CstmrDrctDbtInitn" type="CustomerDirectDebitInitiationV02"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="DocumentAdjustment1"> + <xs:sequence> + <xs:element name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtDbtInd" type="CreditDebitCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="Rsn" type="Max4Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="AddtlInf" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="DocumentType3Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="RADM"/> + <xs:enumeration value="RPIN"/> + <xs:enumeration value="FXDR"/> + <xs:enumeration value="DISP"/> + <xs:enumeration value="PUOR"/> + <xs:enumeration value="SCOR"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="DocumentType5Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="MSIN"/> + <xs:enumeration value="CNFA"/> + <xs:enumeration value="DNFA"/> + <xs:enumeration value="CINV"/> + <xs:enumeration value="CREN"/> + <xs:enumeration value="DEBN"/> + <xs:enumeration value="HIRI"/> + <xs:enumeration value="SBIN"/> + <xs:enumeration value="CMCN"/> + <xs:enumeration value="SOAC"/> + <xs:enumeration value="DISP"/> + <xs:enumeration value="BOLD"/> + <xs:enumeration value="VCHR"/> + <xs:enumeration value="AROI"/> + <xs:enumeration value="TSUT"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalAccountIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalCategoryPurpose1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalClearingSystemIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="5"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalFinancialInstitutionIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalLocalInstrument1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="35"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalOrganisationIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalPersonIdentification1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalPurpose1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ExternalServiceLevel1Code"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="FinancialIdentificationSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalFinancialInstitutionIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="FinancialInstitutionIdentification7"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="BIC" type="BICIdentifier"/> + <xs:element maxOccurs="1" minOccurs="0" name="ClrSysMmbId" type="ClearingSystemMemberIdentification2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstlAdr" type="PostalAddress6"/> + <xs:element maxOccurs="1" minOccurs="0" name="Othr" type="GenericFinancialIdentification1"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="Frequency1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="YEAR"/> + <xs:enumeration value="MNTH"/> + <xs:enumeration value="QURT"/> + <xs:enumeration value="MIAN"/> + <xs:enumeration value="WEEK"/> + <xs:enumeration value="DAIL"/> + <xs:enumeration value="ADHO"/> + <xs:enumeration value="INDA"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="GenericAccountIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max34Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="AccountSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GenericFinancialIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="FinancialIdentificationSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GenericOrganisationIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="OrganisationIdentificationSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GenericPersonIdentification1"> + <xs:sequence> + <xs:element name="Id" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SchmeNm" type="PersonIdentificationSchemeName1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="GroupHeader39"> + <xs:sequence> + <xs:element name="MsgId" type="Max35Text"/> + <xs:element name="CreDtTm" type="ISODateTime"/> + <xs:element maxOccurs="2" minOccurs="0" name="Authstn" type="Authorisation1Choice"/> + <xs:element name="NbOfTxs" type="Max15NumericText"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtrlSum" type="DecimalNumber"/> + <xs:element name="InitgPty" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="FwdgAgt" type="BranchAndFinancialInstitutionIdentification4"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="IBAN2007Identifier"> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z]{2,2}[0-9]{2,2}[a-zA-Z0-9]{1,30}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="ISODate"> + <xs:restriction base="xs:date"/> + </xs:simpleType> + <xs:simpleType name="ISODateTime"> + <xs:restriction base="xs:dateTime"/> + </xs:simpleType> + <xs:complexType name="LocalInstrument2Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalLocalInstrument1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="MandateRelatedInformation6"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="MndtId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="DtOfSgntr" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="AmdmntInd" type="TrueFalseIndicator"/> + <xs:element maxOccurs="1" minOccurs="0" name="AmdmntInfDtls" type="AmendmentInformationDetails6"/> + <xs:element maxOccurs="1" minOccurs="0" name="ElctrncSgntr" type="Max1025Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="FrstColltnDt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="FnlColltnDt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="Frqcy" type="Frequency1Code"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="Max1025Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="1025"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max10Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="10"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max128Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="128"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max140Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="140"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max15NumericText"> + <xs:restriction base="xs:string"> + <xs:pattern value="[0-9]{1,15}"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max16Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="16"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max2048Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="2048"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max34Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="34"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max35Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="35"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max4Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Max70Text"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + <xs:maxLength value="70"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="NameAndAddress10"> + <xs:sequence> + <xs:element name="Nm" type="Max140Text"/> + <xs:element name="Adr" type="PostalAddress6"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="NamePrefix1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="DOCT"/> + <xs:enumeration value="MIST"/> + <xs:enumeration value="MISS"/> + <xs:enumeration value="MADM"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="Number"> + <xs:restriction base="xs:decimal"> + <xs:fractionDigits value="0"/> + <xs:totalDigits value="18"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="OrganisationIdentification4"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="BICOrBEI" type="AnyBICIdentifier"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Othr" type="GenericOrganisationIdentification1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="OrganisationIdentificationSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalOrganisationIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="Party6Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="OrgId" type="OrganisationIdentification4"/> + <xs:element name="PrvtId" type="PersonIdentification5"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PartyIdentification32"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstlAdr" type="PostalAddress6"/> + <xs:element maxOccurs="1" minOccurs="0" name="Id" type="Party6Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtryOfRes" type="CountryCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtctDtls" type="ContactDetails2"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PaymentIdentification1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="InstrId" type="Max35Text"/> + <xs:element name="EndToEndId" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PaymentInstructionInformation4"> + <xs:sequence> + <xs:element name="PmtInfId" type="Max35Text"/> + <xs:element name="PmtMtd" type="PaymentMethod2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="BtchBookg" type="BatchBookingIndicator"/> + <xs:element maxOccurs="1" minOccurs="0" name="NbOfTxs" type="Max15NumericText"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtrlSum" type="DecimalNumber"/> + <xs:element maxOccurs="1" minOccurs="0" name="PmtTpInf" type="PaymentTypeInformation20"/> + <xs:element name="ReqdColltnDt" type="ISODate"/> + <xs:element name="Cdtr" type="PartyIdentification32"/> + <xs:element name="CdtrAcct" type="CashAccount16"/> + <xs:element name="CdtrAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrAgtAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="UltmtCdtr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgBr" type="ChargeBearerType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgsAcct" type="CashAccount16"/> + <xs:element maxOccurs="1" minOccurs="0" name="ChrgsAcctAgt" type="BranchAndFinancialInstitutionIdentification4"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrSchmeId" type="PartyIdentification32"/> + <xs:element maxOccurs="unbounded" minOccurs="1" name="DrctDbtTxInf" type="DirectDebitTransactionInformation9"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="PaymentMethod2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="DD"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="PaymentTypeInformation20"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="InstrPrty" type="Priority2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="SvcLvl" type="ServiceLevel8Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="LclInstrm" type="LocalInstrument2Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="SeqTp" type="SequenceType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtgyPurp" type="CategoryPurpose1Choice"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="PercentageRate"> + <xs:restriction base="xs:decimal"> + <xs:fractionDigits value="10"/> + <xs:totalDigits value="11"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="PersonIdentification5"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="DtAndPlcOfBirth" type="DateAndPlaceOfBirth"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Othr" type="GenericPersonIdentification1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="PersonIdentificationSchemeName1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalPersonIdentification1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="PhoneNumber"> + <xs:restriction base="xs:string"> + <xs:pattern value="\+[0-9]{1,3}-[0-9()+\-]{1,30}"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="PostalAddress6"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="AdrTp" type="AddressType2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dept" type="Max70Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="SubDept" type="Max70Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="StrtNm" type="Max70Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="BldgNb" type="Max16Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="PstCd" type="Max16Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TwnNm" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtrySubDvsn" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctry" type="CountryCode"/> + <xs:element maxOccurs="7" minOccurs="0" name="AdrLine" type="Max70Text"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="Priority2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="HIGH"/> + <xs:enumeration value="NORM"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="Purpose2Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalPurpose1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ReferredDocumentInformation3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="ReferredDocumentType2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nb" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RltdDt" type="ISODate"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ReferredDocumentType1Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="DocumentType5Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ReferredDocumentType2"> + <xs:sequence> + <xs:element name="CdOrPrtry" type="ReferredDocumentType1Choice"/> + <xs:element maxOccurs="1" minOccurs="0" name="Issr" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RegulatoryAuthority2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctry" type="CountryCode"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RegulatoryReporting3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="DbtCdtRptgInd" type="RegulatoryReportingType1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="Authrty" type="RegulatoryAuthority2"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Dtls" type="StructuredRegulatoryReporting3"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="RegulatoryReportingType1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="CRED"/> + <xs:enumeration value="DEBT"/> + <xs:enumeration value="BOTH"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="RemittanceAmount1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="DuePyblAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="DscntApldAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtNoteAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="AdjstmntAmtAndRsn" type="DocumentAdjustment1"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtdAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RemittanceInformation5"> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Ustrd" type="Max140Text"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Strd" type="StructuredRemittanceInformation7"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="RemittanceLocation2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="RmtId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtLctnMtd" type="RemittanceLocationMethod2Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtLctnElctrncAdr" type="Max2048Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RmtLctnPstlAdr" type="NameAndAddress10"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="RemittanceLocationMethod2Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="FAXI"/> + <xs:enumeration value="EDIC"/> + <xs:enumeration value="URID"/> + <xs:enumeration value="EMAL"/> + <xs:enumeration value="POST"/> + <xs:enumeration value="SMSM"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="SequenceType1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="FRST"/> + <xs:enumeration value="RCUR"/> + <xs:enumeration value="FNAL"/> + <xs:enumeration value="OOFF"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="ServiceLevel8Choice"> + <xs:sequence> + <xs:choice> + <xs:element name="Cd" type="ExternalServiceLevel1Code"/> + <xs:element name="Prtry" type="Max35Text"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + <xs:complexType name="StructuredRegulatoryReporting3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctry" type="CountryCode"/> + <xs:element maxOccurs="1" minOccurs="0" name="Cd" type="Max10Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Inf" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="StructuredRemittanceInformation7"> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="RfrdDocInf" type="ReferredDocumentInformation3"/> + <xs:element maxOccurs="1" minOccurs="0" name="RfrdDocAmt" type="RemittanceAmount1"/> + <xs:element maxOccurs="1" minOccurs="0" name="CdtrRefInf" type="CreditorReferenceInformation2"/> + <xs:element maxOccurs="1" minOccurs="0" name="Invcr" type="PartyIdentification32"/> + <xs:element maxOccurs="1" minOccurs="0" name="Invcee" type="PartyIdentification32"/> + <xs:element maxOccurs="3" minOccurs="0" name="AddtlRmtInf" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxAmount1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Rate" type="PercentageRate"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxblBaseAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="TtlAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Dtls" type="TaxRecordDetails1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxAuthorisation1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Titl" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Nm" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxInformation3"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Cdtr" type="TaxParty1"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dbtr" type="TaxParty2"/> + <xs:element maxOccurs="1" minOccurs="0" name="AdmstnZn" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RefNb" type="Max140Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Mtd" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TtlTaxblBaseAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="TtlTaxAmt" type="ActiveOrHistoricCurrencyAndAmount"/> + <xs:element maxOccurs="1" minOccurs="0" name="Dt" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="SeqNb" type="Number"/> + <xs:element maxOccurs="unbounded" minOccurs="0" name="Rcrd" type="TaxRecord1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxParty1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="TaxId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RegnId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxTp" type="Max35Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxParty2"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="TaxId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="RegnId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxTp" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Authstn" type="TaxAuthorisation1"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxPeriod1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Yr" type="ISODate"/> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="TaxRecordPeriod1Code"/> + <xs:element maxOccurs="1" minOccurs="0" name="FrToDt" type="DatePeriodDetails"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxRecord1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Tp" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Ctgy" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="CtgyDtls" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="DbtrSts" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="CertId" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="FrmsCd" type="Max35Text"/> + <xs:element maxOccurs="1" minOccurs="0" name="Prd" type="TaxPeriod1"/> + <xs:element maxOccurs="1" minOccurs="0" name="TaxAmt" type="TaxAmount1"/> + <xs:element maxOccurs="1" minOccurs="0" name="AddtlInf" type="Max140Text"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TaxRecordDetails1"> + <xs:sequence> + <xs:element maxOccurs="1" minOccurs="0" name="Prd" type="TaxPeriod1"/> + <xs:element name="Amt" type="ActiveOrHistoricCurrencyAndAmount"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="TaxRecordPeriod1Code"> + <xs:restriction base="xs:string"> + <xs:enumeration value="MM01"/> + <xs:enumeration value="MM02"/> + <xs:enumeration value="MM03"/> + <xs:enumeration value="MM04"/> + <xs:enumeration value="MM05"/> + <xs:enumeration value="MM06"/> + <xs:enumeration value="MM07"/> + <xs:enumeration value="MM08"/> + <xs:enumeration value="MM09"/> + <xs:enumeration value="MM10"/> + <xs:enumeration value="MM11"/> + <xs:enumeration value="MM12"/> + <xs:enumeration value="QTR1"/> + <xs:enumeration value="QTR2"/> + <xs:enumeration value="QTR3"/> + <xs:enumeration value="QTR4"/> + <xs:enumeration value="HLF1"/> + <xs:enumeration value="HLF2"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="TrueFalseIndicator"> + <xs:restriction base="xs:boolean"/> + </xs:simpleType> +</xs:schema> diff --git a/dev/resources/sepa/text.txt b/dev/resources/sepa/text.txt new file mode 100644 index 00000000000..0a5336a128e --- /dev/null +++ b/dev/resources/sepa/text.txt @@ -0,0 +1,2 @@ +To test a SEPA file: +http://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa \ No newline at end of file From afdc176f472aa67e667ca481f694c0a5006393ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 16 Oct 2017 08:52:00 +0200 Subject: [PATCH 126/128] Fix scrutinizer --- htdocs/adherents/class/subscription.class.php | 2 +- htdocs/api/class/api_documents.class.php | 12 ++++++----- htdocs/blockedlog/class/blockedlog.class.php | 20 +++++++++---------- .../core/class/emailsenderprofile.class.php | 2 ++ htdocs/core/lib/files.lib.php | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index bdb43dd41d3..397be6ee8da 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -216,7 +216,7 @@ class Subscription extends CommonObject $result=$member->fetch($this->fk_adherent); $result=$member->update_end_date($user); - if (is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) { $result=$accountline->delete($user); // Return false if refused because line is conciliated if ($result > 0) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 397910a6e2f..b47584eea99 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -130,18 +130,20 @@ class Documents extends DolibarrApi } /** - * Return the list of documents of an element + * Return the list of documents of a dedicated element (from its ID or Ref) * - * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) - * @param int $id ID of element + * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) + * @param int $id ID of element * @param string $ref Ref of element - * @return array Array of documents with path + * @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size') + * @param string $sortorder Sort order ('asc' or 'desc') + * @return array Array of documents with path * * @throws RestException * * @url GET list */ - function getDocumentsListByElement($modulepart, $id=0, $ref='') + function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') { global $conf; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 8a1508b7a04..4bce16fb796 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -21,13 +21,15 @@ class BlockedLog { - /** * Id of the log * @var int */ public $id; + public $error = ''; + public $errors = array(); + /** * Unique fingerprint of the log * @var string @@ -78,7 +80,7 @@ class BlockedLog public $object_data = null; - public $error = 0; + /** * Constructor @@ -126,7 +128,7 @@ class BlockedLog /** * try to retrieve user author - */ + */ public function getUser() { global $langs, $cachedUser; @@ -188,8 +190,6 @@ class BlockedLog $this->object_data->amounts = $object->amounts; } - - } /** @@ -231,7 +231,7 @@ class BlockedLog $this->action = $obj->action; $this->element = $obj->element; - $this->fk_object = trim($obj->fk_object); + $this->fk_object = $obj->fk_object; $this->date_object = $this->db->jdate($obj->date_object); $this->ref_object = $obj->ref_object; @@ -432,10 +432,10 @@ class BlockedLog /** * return log object for a element. * - * @param string $element element to search - * @param int $fk_object id of object to search - * @param int $limit max number of element, 0 for all - * @param string $order sort of query + * @param string $element element to search + * @param int $fk_object id of object to search + * @param int $limit max number of element, 0 for all + * @param string $order sort of query * @return array array of object log */ public function getLog($element, $fk_object, $limit = 0, $order = -1) { diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 66e37744cc7..f779e949dc3 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -273,6 +273,8 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; + $label=$this->label; + $url=''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 44a404c6c67..2f59c7e388c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -47,7 +47,7 @@ function dol_basename($pathfile) * @param string $filter Regex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function, * but must not contains the start and end '/'. Filter is checked into basename only. * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked into fullpath. - * @param string $sortcriteria Sort criteria ("","fullname","relativename","name","date","size") + * @param string $sortcriteria Sort criteria ('','fullname','relativename','name','date','size') * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $nohook Disable all hooks From 87814af7b6170f1501dba0a492a1bc8568a01ccf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 16 Oct 2017 09:29:10 +0200 Subject: [PATCH 127/128] Move function colorIsLight into functions.lib.php Fix scrutinizer bugs. --- .../accountancy/class/bookkeeping.class.php | 21 +++++--- htdocs/adherents/class/adherent.class.php | 4 +- .../adherents/class/adherent_type.class.php | 2 +- htdocs/adherents/type.php | 4 +- htdocs/admin/mails_templates.php | 6 +-- htdocs/api/class/api_access.class.php | 4 +- htdocs/api/class/api_documents.class.php | 4 +- htdocs/cashdesk/class/Facturation.class.php | 53 ++++++++++--------- htdocs/categories/class/categorie.class.php | 17 ++---- htdocs/core/db/DoliDB.class.php | 8 +-- htdocs/core/lib/functions.lib.php | 34 ++++++++++++ htdocs/core/lib/functions2.lib.php | 34 ------------ 12 files changed, 99 insertions(+), 92 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 52f7a473bed..2d828298b51 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1079,22 +1079,26 @@ class BookKeeping extends CommonObject * @param string $mode Mode * @return number <0 if KO, >0 if OK */ - public function updateByMvt($piece_num='', $field='', $value='', $mode='') { + public function updateByMvt($piece_num='', $field='', $value='', $mode='') + { + $error=0; + $this->db->begin(); + $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'"); $sql .= ' WHERE ab.piece_num=' . $piece_num ; $resql = $this->db->query($sql); if (! $resql) { - $error ++; + $error++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -1521,11 +1525,16 @@ class BookKeeping extends CommonObject * @param string $piece_num Piece num * @return void */ - public function transformTransaction($direction=0,$piece_num='') { + public function transformTransaction($direction=0,$piece_num='') + { + $error = 0; + $this->db->begin(); - if ($direction==0) { + + if ($direction==0) + { $next_piecenum=$this->getNextNumMvt(); - if ($result < 0) { + if ($next_piecenum < 0) { $error++; } $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,'; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c197d1a2362..33be4abb8e6 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1563,7 +1563,7 @@ class Adherent extends CommonObject * @param int $withpictoimg 0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) * @param int $maxlen length max label * @param string $option Page for link ('card', 'category', 'subscription', ...) - * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref + * @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL @@ -1574,6 +1574,8 @@ class Adherent extends CommonObject if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; + $notooltip=0; + $result=''; $label=''; $link=''; $linkstart=''; $linkend=''; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 99c343a1ff0..f65e363cef9 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -167,7 +167,7 @@ class AdherentType extends CommonObject $sql.= "libelle = '".$this->db->escape($this->label) ."',"; $sql.= "subscription = '".$this->db->escape($this->subscription)."',"; $sql.= "note = '".$this->db->escape($this->note)."',"; - $sql.= "vote = '".$this->db->escape($this->vote)."',"; + $sql.= "vote = ".(integer) $this->db->escape($this->vote).","; $sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; $sql.= " WHERE rowid =".$this->id; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index c9edce35f60..7eaefa6fc33 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -160,7 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 111084388ce..4e25e93084b 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1019,9 +1019,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } print '</td>'; } - elseif ($context == 'add' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; - elseif ($context == 'edit' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; - elseif ($context == 'hide' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; else { $size=''; $class=''; $classtd=''; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index b2dcfefa49f..5848620f735 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -83,10 +83,10 @@ class DolibarrApiAccess implements iAuthenticate // api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx $api_key = ''; - if (isset($_GET['api_key'])) + if (isset($_GET['api_key'])) // For backward compatibility { // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['api_key']; // For backward compatibility + $api_key = $_GET['api_key']; } if (isset($_GET['DOLAPIKEY'])) { diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index b47584eea99..92b48dfd0c6 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -256,9 +256,11 @@ class Documents extends DolibarrApi // Define $uploadir $object = null; - $entity = $user->entity; + $entity = DolibarrApiAccess::$user->entity; if ($ref) { + $tmpreldir=''; + if ($modulepart == 'facture' || $modulepart == 'invoice') { $modulepart='facture'; diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index b55524a874a..8bfd1d3082c 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -117,7 +117,7 @@ class Facturation } // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); + $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; @@ -207,6 +207,9 @@ class Facturation $total_ht=0; $total_ttc=0; + $total_vat = 0; + $total_localtax1 = 0; + $total_localtax2 = 0; $tab=array(); $tab = $_SESSION['poscart']; @@ -309,7 +312,7 @@ class Facturation public function ref($aRef=null) { - if ( !$aRef ) + if (is_null($aRef)) { return $this->ref; } @@ -330,9 +333,9 @@ class Facturation * @param int $aQte Qty * @return int Qty */ - public function qte( $aQte=null ) + public function qte($aQte=null) { - if ( !$aQte ) + if (is_null($aQte)) { return $this->qte; } @@ -357,7 +360,7 @@ class Facturation public function stock($aStock=null) { - if ( !$aStock ) + if (is_null($aStock)) { return $this->stock; } @@ -381,7 +384,7 @@ class Facturation public function remisePercent($aRemisePercent=null) { - if ( !$aRemisePercent ) + if (is_null($aRemisePercent)) { return $this->remise_percent; } @@ -405,7 +408,7 @@ class Facturation public function montantRemise($aMontantRemise=null) { - if ( !$aMontantRemise ) { + if (is_null($aMontantRemise)) { return $this->montant_remise; @@ -427,10 +430,10 @@ class Facturation * @param int $aPrix Price * @return string Stock */ - public function prix ( $aPrix=null ) + public function prix($aPrix=null) { - if ( !$aPrix ) { + if (is_null($aPrix)) { return $this->prix; @@ -454,7 +457,7 @@ class Facturation */ public function tva($aTva=null) { - if ( !$aTva ) { + if (is_null($aTva)) { return $this->tva; @@ -478,7 +481,7 @@ class Facturation */ public function numInvoice($aNumFacture=null) { - if ( !$aNumFacture ) { + if (is_null($aNumFacture)) { return $this->num_facture; @@ -499,10 +502,10 @@ class Facturation * @param int $aModeReglement Payment mode * @return int Payment mode */ - public function getSetPaymentMode( $aModeReglement=null ) + public function getSetPaymentMode($aModeReglement=null) { - if ( !$aModeReglement ) { + if (is_null($aModeReglement)) { return $this->mode_reglement; @@ -524,10 +527,10 @@ class Facturation * @param int $aMontantEncaisse Amount * @return int Amount */ - public function montantEncaisse( $aMontantEncaisse=null ) + public function montantEncaisse($aMontantEncaisse=null) { - if ( !$aMontantEncaisse ) { + if (is_null($aMontantEncaisse)) { return $this->montant_encaisse; @@ -549,10 +552,10 @@ class Facturation * @param int $aMontantRendu Amount * @return int Amount */ - public function montantRendu( $aMontantRendu=null ) + public function montantRendu($aMontantRendu=null) { - if ( !$aMontantRendu ) { + if (is_null($aMontantRendu)) { return $this->montant_rendu; } else if ( $aMontantRendu == 'RESET' ) { @@ -573,9 +576,9 @@ class Facturation * @param date $aPaiementLe Date * @return date Date */ - public function paiementLe( $aPaiementLe=null ) + public function paiementLe($aPaiementLe=null) { - if ( !$aPaiementLe ) { + if (is_null($aPaiementLe)) { return $this->paiement_le; @@ -596,9 +599,9 @@ class Facturation * @param int $aTotalHt Total amount * @return int Total amount */ - public function prixTotalHt( $aTotalHt=null ) + public function prixTotalHt($aTotalHt=null) { - if ( !$aTotalHt ) { + if (is_null($aTotalHt)) { return $this->prix_total_ht; @@ -619,9 +622,9 @@ class Facturation * @param int $aMontantTva Amount vat * @return int Amount vat */ - public function montantTva( $aMontantTva=null ) + public function montantTva($aMontantTva=null) { - if ( !$aMontantTva ) { + if (is_null($aMontantTva)) { return $this->montant_tva; @@ -643,9 +646,9 @@ class Facturation * @param int $aTotalTtc Amount ttc * @return int Amount ttc */ - public function prixTotalTtc( $aTotalTtc=null ) + public function prixTotalTtc($aTotalTtc=null) { - if ( !$aTotalTtc ) + if (is_null($aTotalTtc)) { return $this->prix_total_ttc; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6242691d1f1..7a7a6f06a1f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -163,7 +163,7 @@ class Categorie extends CommonObject */ public $socid; /** - * @var int Category type + * @var string Category type * * @see Categorie::TYPE_PRODUCT * @see Categorie::TYPE_SUPPLIER @@ -1327,6 +1327,7 @@ class Categorie extends CommonObject { $w = array(); $i = 0; + $forced_color=''; foreach ($way as $cat) { $i++; @@ -1340,12 +1341,7 @@ class Categorie extends CommonObject $forced_color='categtextwhite'; if ($cat->color) { - $hex=$cat->color; - $r = hexdec($hex[0].$hex[1]); - $g = hexdec($hex[2].$hex[3]); - $b = hexdec($hex[4].$hex[5]); - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + if (colorIsLight($cat->color)) $forced_color='categtextblack'; } } } @@ -1602,12 +1598,7 @@ class Categorie extends CommonObject $forced_color='categtextwhite'; if ($this->color) { - $hex=$this->color; - $r = hexdec($hex[0].$hex[1]); - $g = hexdec($hex[2].$hex[3]); - $b = hexdec($hex[4].$hex[5]); - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + if (colorIsLight($this->color)) $forced_color='categtextblack'; } $link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color .'">'; diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 9fc1739334c..99b799d5d6e 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -59,7 +59,7 @@ abstract class DoliDB implements Database public $lastqueryerror; /** @var string Last error message */ public $lasterror; - /** @var int Last error number */ + /** @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */ public $lasterrno; /** @var bool Status */ @@ -238,16 +238,16 @@ abstract class DoliDB implements Database else $return.=', '; $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - + $tmpsortorder = trim($orders[$i]); - + // Only ASC and DESC values are valid SQL if (strtoupper($tmpsortorder) === 'ASC') { $return .= ' ASC'; } elseif (strtoupper($tmpsortorder) === 'DESC') { $return .= ' DESC'; } - + $i++; } return $return; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f56cd2f523d..2626e917460 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6791,3 +6791,37 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield=' return ''; } } + +/** + * Return true if the color is light + * + * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') + * @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light + */ +function colorIsLight($stringcolor) +{ + $res = -1; + if (!empty($stringcolor)) + { + $res = 0; + $tmp=explode(',', $stringcolor); + if (count($tmp) > 1) // This is a comma RGB ('255','255','255') + { + $r = $tmp[0]; + $g = $tmp[1]; + $b = $tmp[2]; + } + else + { + $hexr=$stringcolor[0].$stringcolor[1]; + $hexg=$stringcolor[2].$stringcolor[3]; + $hexb=$stringcolor[4].$stringcolor[5]; + $r = hexdec($hexr); + $g = hexdec($hexg); + $b = hexdec($hexb); + } + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright > 0.6) $res = 1; + } + return $res; +} diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 3d2e2bb359b..98d113525c1 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2153,40 +2153,6 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); } -/** - * Return true if the color is light - * - * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') - * @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light - */ -function colorIsLight($stringcolor) -{ - $res = -1; - if (!empty($stringcolor)) - { - $res = 0; - $tmp=explode(',', $stringcolor); - if (count($tmp) > 1) // This is a comma RGB ('255','255','255') - { - $r = $tmp[0]; - $g = $tmp[1]; - $b = $tmp[2]; - } - else - { - $hexr=$stringcolor[0].$stringcolor[1]; - $hexg=$stringcolor[2].$stringcolor[3]; - $hexb=$stringcolor[4].$stringcolor[5]; - $r = hexdec($hexr); - $g = hexdec($hexg); - $b = hexdec($hexb); - } - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright > 0.6) $res = 1; - } - return $res; -} - /** * Applies the Cartesian product algorithm to an array * Source: http://stackoverflow.com/a/15973172 From 82348cc1e9edb703e0d0be293f9f489c8fbb31e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 16 Oct 2017 10:17:57 +0200 Subject: [PATCH 128/128] NEW Can filter on date on the page showing existing bindings --- htdocs/accountancy/customer/lines.php | 31 +++++++++++++++++++- htdocs/accountancy/customer/list.php | 1 + htdocs/accountancy/expensereport/lines.php | 33 +++++++++++++++++++++- htdocs/accountancy/expensereport/list.php | 1 + htdocs/accountancy/supplier/lines.php | 33 +++++++++++++++++++++- htdocs/accountancy/supplier/list.php | 1 + 6 files changed, 97 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 0e3e71c1527..13602160c48 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("bills"); @@ -51,6 +53,9 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -95,6 +100,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; $search_country = ''; $search_tvaintra = ''; } @@ -131,6 +139,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { */ $form = new Form($db); +$formother = new FormOther($db); llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); @@ -197,6 +206,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("fd.tva_tx", $search_vat); } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } @@ -237,6 +259,9 @@ if ($result) { $param .= "&search_account=" . $search_account; if ($search_vat) $param .= "&search_vat=" . $search_vat; + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); if ($search_country) $param .= "&search_country=" . $search_country; if ($search_tvaintra) @@ -267,7 +292,11 @@ if ($result) { print '<tr class="liste_titre_filter">'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; - print '<td class="liste_titre"></td>'; + print '<td class="liste_titre center">'; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; + print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; + $formother->select_year($search_year,'search_year',1, 20, 5); + print '</td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 51f62ecabf6..2d26a2d06d8 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -115,6 +115,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; $search_month = ''; $search_year = ''; } diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 156d80f09e4..750a5bc9f25 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -50,6 +52,9 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); @@ -90,6 +95,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -123,6 +131,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { * View */ +$form = new Form($db); +$formother = new FormOther($db); + llxHeader('', $langs->trans("ExpenseReportsVentilation") . ' - ' . $langs->trans("Dispatched")); print '<script type="text/javascript"> @@ -173,6 +184,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND erd.date BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND erd.date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(erd.date, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND erd.date BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -207,6 +231,9 @@ if ($result) { $param .= "&search_account=" . $search_account; if ($search_vat) $param .= "&search_vat=" . $search_vat; + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); if ($search_country) $param .= "&search_country=" . $search_country; if ($search_tvaintra) @@ -237,7 +264,11 @@ if ($result) { print '<tr class="liste_titre_filter">'; print '<td class="liste_titre"></td>'; print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="' . dol_escape_htmltag($search_expensereport) . '"></td>'; - print '<td class="liste_titre" align="right"></td>'; + print '<td class="liste_titre center">'; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; + print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; + $formother->select_year($search_year,'search_year',1, 20, 5); + print '</td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>'; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index c7ebb5ed5af..b7fe591708e 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -109,6 +109,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; $search_month = ''; $search_year = ''; } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 66e6928da07..78b9320fdb1 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -52,6 +54,9 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -96,6 +101,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; $search_country = ''; $search_tvaintra = ''; } @@ -131,6 +139,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { * View */ +$form = new Form($db); +$formother = new FormOther($db); + llxHeader('', $langs->trans("SuppliersVentilation") . ' - ' . $langs->trans("Dispatched")); print '<script type="text/javascript"> @@ -189,6 +200,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", $search_vat, 1); } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} if (strlen(trim($search_country))) { $sql .= " AND (co.label like'" . $search_country . "%')"; } @@ -231,6 +255,9 @@ if ($result) { $param .= "&search_account=" . $search_account; if ($search_vat) $param .= "&search_vat=" . $search_vat; + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); if ($search_country) $param .= "&search_country=" . $search_country; if ($search_tvaintra) @@ -262,7 +289,11 @@ if ($result) { print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; print '<td class="liste_titre"></td>'; - print '<td class="liste_titre"></td>'; + print '<td class="liste_titre center">'; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">'; + print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">'; + $formother->select_year($search_year,'search_year',1, 20, 5); + print '</td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 0ebf66f1215..f154d0b77d0 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -116,6 +116,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; $search_month = ''; $search_year = ''; }
'; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('search_gender', $arraygender, $search_gender, 1); - print ''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('search_gender', $arraygender, $search_gender, 1); + print ''; - print $form->selectyesno('search_employee', $search_employee, 1, false, 1); - print ''; + print $form->selectyesno('search_employee', $search_employee, 1, false, 1); + print ''; - print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); - print ''; + print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); + print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) { - $crit=$val; + $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; @@ -402,22 +402,22 @@ $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // N print $hookmanager->resPrint; if (! empty($arrayfields['u.datec']['checked'])) { - // Date creation - print ''; - print ''; + print ''; - print ''; + print ''; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''; + print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); + print ''; @@ -444,16 +444,16 @@ if (! empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_t // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); $sortonfield = "ef.".$key; if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } + } + } } // Hook fields $parameters=array('arrayfields'=>$arrayfields); @@ -471,151 +471,151 @@ $i = 0; $totalarray=array(); while ($i < min($num,$limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($result); $userstatic->id=$obj->rowid; $userstatic->ref=$obj->label; $userstatic->login=$obj->login; $userstatic->statut=$obj->statut; - $userstatic->email=$obj->email; - $userstatic->gender=$obj->gender; - $userstatic->societe_id=$obj->fk_soc; - $userstatic->firstname=$obj->firstname; + $userstatic->email=$obj->email; + $userstatic->gender=$obj->gender; + $userstatic->societe_id=$obj->fk_soc; + $userstatic->firstname=$obj->firstname; $userstatic->lastname=$obj->lastname; $userstatic->employee=$obj->employee; $userstatic->photo=$obj->photo; $li=$userstatic->getNomUrl(-1,'',0,0,24,1,'login'); - print "
'; + print ''; print $li; - if (! empty($conf->multicompany->enabled) && $obj->admin && ! $obj->entity) - { - print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); - } - else if ($obj->admin) - { - print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); - } - print ''.$obj->lastname.''.$obj->lastname.''.$obj->firstname.''; if ($obj->gender) print $langs->trans("Gender".$obj->gender); print ''.yn($obj->employee).''.$obj->accountancy_code.''.$obj->email.'"; - if ($obj->fk_soc) - { - $companystatic->id=$obj->fk_soc; - $companystatic->name=$obj->name; - $companystatic->canvas=$obj->canvas; - print $companystatic->getNomUrl(1); - } - else if ($obj->ldap_sid) - { - print $langs->trans("DomainUser"); - } - else - { - print $langs->trans("InternalUser"); - } - print ''; - if (! $obj->entity) - { - print $langs->trans("AllEntities"); - } - else - { - $mc->getInfo($obj->entity); - print $mc->label; - } - print ''; + if (! $obj->entity) + { + print $langs->trans("AllEntities"); + } + else + { + $mc->getInfo($obj->entity); + print $mc->label; + } + print ''; - if ($obj->login2) - { - $user2->id=$obj->id2; - $user2->login=$obj->login2; - $user2->lastname=$obj->lastname2; - $user2->firstname=$obj->firstname2; - $user2->gender=$obj->gender2; - $user2->photo=$obj->photo2; - $user2->admin=$obj->admin2; - $user2->email=$obj->email2; - $user2->socid=$obj->fk_soc2; - print $user2->getNomUrl(-1,'',0,0,24,0,''); - if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2) - { - print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); - } - else if ($obj->admin2) - { - print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); - } - } - print ''; + if ($obj->login2) + { + $user2->id=$obj->id2; + $user2->login=$obj->login2; + $user2->lastname=$obj->lastname2; + $user2->firstname=$obj->firstname2; + $user2->gender=$obj->gender2; + $user2->photo=$obj->photo2; + $user2->admin=$obj->admin2; + $user2->email=$obj->email2; + $user2->socid=$obj->fk_soc2; + print $user2->getNomUrl(-1,'',0,0,24,0,''); + if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2) + { + print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); + } + else if ($obj->admin2) + { + print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); + } + } + print ''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").''.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").''.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$userstatic->getLibStatut(3).''.$userstatic->getLibStatut(3).'