Laurent Destailleur 2 years ago
parent
commit
a64ed59e18
58 changed files with 318 additions and 234 deletions
  1. 1 1
      htdocs/admin/agenda.php
  2. 1 1
      htdocs/admin/agenda_extsites.php
  3. 2 2
      htdocs/admin/agenda_other.php
  4. 25 8
      htdocs/admin/agenda_xcal.php
  5. 3 3
      htdocs/admin/const.php
  6. 5 1
      htdocs/admin/dav.php
  7. 2 3
      htdocs/admin/dict.php
  8. 5 3
      htdocs/admin/facture.php
  9. 3 3
      htdocs/admin/mailing.php
  10. 3 3
      htdocs/admin/payment.php
  11. 4 1
      htdocs/admin/ticket_public.php
  12. 20 9
      htdocs/bom/lib/bom.lib.php
  13. 2 2
      htdocs/comm/action/class/actioncomm.class.php
  14. 7 5
      htdocs/comm/mailing/card.php
  15. 1 1
      htdocs/comm/propal/class/propal.class.php
  16. 3 4
      htdocs/comm/propal/list.php
  17. 4 1
      htdocs/compta/prelevement/class/bonprelevement.class.php
  18. 2 2
      htdocs/contrat/card.php
  19. 16 3
      htdocs/core/ajax/fetchKnowledgeRecord.php
  20. 5 0
      htdocs/core/class/commondocgenerator.class.php
  21. 1 1
      htdocs/core/class/dolgraph.class.php
  22. 4 4
      htdocs/core/class/html.formfile.class.php
  23. 30 22
      htdocs/core/class/html.formticket.class.php
  24. 2 2
      htdocs/core/class/ldap.class.php
  25. 8 10
      htdocs/core/lib/functions.lib.php
  26. 2 0
      htdocs/core/lib/pdf.lib.php
  27. 1 1
      htdocs/core/lib/usergroups.lib.php
  28. 6 21
      htdocs/core/modules/facture/mod_facture_mercure.php
  29. 3 3
      htdocs/core/modules/payment/mod_payment_ant.php
  30. 11 8
      htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
  31. 11 8
      htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
  32. 5 3
      htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
  33. 10 7
      htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php
  34. 10 7
      htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
  35. 2 1
      htdocs/core/tpl/objectline_view.tpl.php
  36. 1 1
      htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
  37. 2 2
      htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
  38. 1 1
      htdocs/dav/dav.lib.php
  39. 1 1
      htdocs/includes/tecnickcom/tcpdf/include/barcodes/datamatrix.php
  40. 1 1
      htdocs/langs/en_US/ticket.lang
  41. 1 1
      htdocs/mrp/class/api_mos.class.php
  42. 2 2
      htdocs/product/stock/card.php
  43. 9 3
      htdocs/product/stock/class/entrepot.class.php
  44. 8 3
      htdocs/projet/class/task.class.php
  45. 13 13
      htdocs/projet/tasks.php
  46. 9 7
      htdocs/projet/tasks/time.php
  47. 1 1
      htdocs/public/stripe/ipn.php
  48. 23 3
      htdocs/public/ticket/ajax/ajax.php
  49. 1 3
      htdocs/public/ticket/create_ticket.php
  50. 1 1
      htdocs/public/ticket/index.php
  51. 11 9
      htdocs/societe/paymentmodes.php
  52. 1 1
      htdocs/theme/eldy/global.inc.php
  53. 1 1
      htdocs/theme/md/style.css.php
  54. 2 2
      htdocs/ticket/card.php
  55. 6 5
      htdocs/ticket/class/ticket.class.php
  56. 2 2
      htdocs/ticket/css/styles.css.php
  57. 1 3
      htdocs/variants/card.php
  58. 0 14
      htdocs/variants/tpl/productattributevalueline_create.tpl.php

+ 1 - 1
htdocs/admin/agenda.php

@@ -202,7 +202,7 @@ if (!empty($triggers)) {
 				print '<td>'.$trigger['label'].'</td>';
 				print '<td class="right" width="40">';
 				$key = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
-				$value = $conf->global->$key;
+				$value = getDolGlobalInt($key);
 				print '<input class="oddeven" type="checkbox" name="'.$key.'" value="1"'.((($action == 'selectall' || $value) && $action != "selectnone") ? ' checked' : '').'>';
 				print '</td></tr>'."\n";
 			}

+ 1 - 1
htdocs/admin/agenda_extsites.php

@@ -203,7 +203,7 @@ print '<span class="opacitymedium">'.$langs->trans("AgendaExtSitesDesc")."</span
 print "<br>\n";
 
 
-$selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
+$selectedvalue = getDolGlobalInt('AGENDA_DISABLE_EXT');
 if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
 
 print "<table class=\"noborder\" width=\"100%\">";

+ 2 - 2
htdocs/admin/agenda_other.php

@@ -333,7 +333,7 @@ print '<td>'.$form->textwithpicto($langs->trans("AGENDA_DEFAULT_VIEW"), $htmltex
 print '<td class="center">&nbsp;</td>'."\n";
 print '<td class="right">'."\n";
 $tmplist = array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
-print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
+print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, getDolGlobalString('AGENDA_DEFAULT_VIEW'));
 print '</td></tr>'."\n";
 
 // Manual or automatic
@@ -395,7 +395,7 @@ print '<tr class="oddeven">'."\n";
 print '<td>'.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").'</td>'."\n";
 print '<td class="center">&nbsp;</td>'."\n";
 print '<td class="right">'."\n";
-$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100');
+$formactions->form_select_status_action('agenda', getDolGlobalString('AGENDA_DEFAULT_FILTER_STATUS'), 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100');
 print '</td></tr>'."\n";
 
 print '</table>';

+ 25 - 8
htdocs/admin/agenda_xcal.php

@@ -39,6 +39,23 @@ $langs->loadLangs(array("admin", "other", "agenda"));
 
 $def = array();
 $actionsave = GETPOST('save', 'alpha');
+$MAIN_AGENDA_XCAL_EXPORTKEY = getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY');
+$MAIN_AGENDA_EXPORT_PAST_DELAY = getDolGlobalInt('MAIN_AGENDA_EXPORT_PAST_DELAY');
+$MAIN_AGENDA_EXPORT_CACHE = getDolGlobalInt('MAIN_AGENDA_EXPORT_CACHE');
+$AGENDA_EXPORT_FIX_TZ = getDolGlobalString('AGENDA_EXPORT_FIX_TZ');
+
+if (GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) {
+	$MAIN_AGENDA_XCAL_EXPORTKEY = trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha'));
+}
+if (GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) {
+	$MAIN_AGENDA_EXPORT_PAST_DELAY = intval(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'int'));
+}
+if (GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) {
+	$MAIN_AGENDA_EXPORT_CACHE = intval(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'int'));
+}
+if (GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) {
+	$AGENDA_EXPORT_FIX_TZ = trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha'));
+}
 
 // Sauvegardes parametres
 if ($actionsave) {
@@ -46,10 +63,10 @@ if ($actionsave) {
 
 	$db->begin();
 
-	$i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity);
-	$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity);
-	$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
-	$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
+	$i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', $MAIN_AGENDA_XCAL_EXPORTKEY, 'chaine', 0, '', $conf->entity);
+	$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', $MAIN_AGENDA_EXPORT_PAST_DELAY, 'chaine', 0, '', $conf->entity);
+	$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', $MAIN_AGENDA_EXPORT_CACHE, 'chaine', 0, '', $conf->entity);
+	$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', $AGENDA_EXPORT_FIX_TZ, 'chaine', 0, '', $conf->entity);
 
 	if ($i >= 4) {
 		$db->commit();
@@ -98,7 +115,7 @@ print "</tr>";
 
 print '<tr class="oddeven">';
 print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
-print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
+print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.dol_escape_htmltag($MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
 if (!empty($conf->use_javascript_ajax)) {
 	print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
 }
@@ -108,13 +125,13 @@ print "</tr>";
 
 print '<tr class="oddeven">';
 print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
-print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"".(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha') ?GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha') : $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)."\" size=\"10\"> ".$langs->trans("days")."</td>";
+print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"".$MAIN_AGENDA_EXPORT_PAST_DELAY."\" size=\"10\"> ".$langs->trans("days")."</td>";
 print "<td>&nbsp;</td>";
 print "</tr>";
 
 print '<tr class="oddeven">';
 print "<td>".$langs->trans("UseACacheDelay")."</td>";
-print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"".(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha') ?GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha') : $conf->global->MAIN_AGENDA_EXPORT_CACHE)."\" size=\"10\"></td>";
+print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"".$MAIN_AGENDA_EXPORT_CACHE."\" size=\"10\"></td>";
 print "<td>&nbsp;</td>";
 print "</tr>";
 
@@ -131,7 +148,7 @@ print "</tr>";
 print '<tr class="oddeven">';
 print '<td>'.$langs->trans("FixTZ")."</td>";
 print "<td>";
-print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.$conf->global->AGENDA_EXPORT_FIX_TZ.'">';
+print '<input class="flat" type="text" size="4" name="AGENDA_EXPORT_FIX_TZ" value="'.dol_escape_htmltag($AGENDA_EXPORT_FIX_TZ).'">';
 print ' &nbsp; '.$langs->trans("FillThisOnlyIfRequired");
 print "</td>";
 print "</tr>";

+ 3 - 3
htdocs/admin/const.php

@@ -64,9 +64,9 @@ if ($action == 'add' && GETPOST('update')) {	// Click on button update must be u
 if ($action == 'add' && GETPOST('delete')) {	// Click on button update must be used in priority before param $action
 	$action = 'delete';
 }
-if ($action == 'update' && GETPOST('add')) {	// Click on button add must be used in priority before param $action
+/*if ($action == 'update' && GETPOST('add')) {	// 'add' button is always clicked as it is the first in form.
 	$action = 'add';
-}
+}*/
 if ($action == 'delete' && GETPOST('add')) {	// Click on button add must be used in priority before param $action
 	$action = 'add';
 }
@@ -234,7 +234,7 @@ if (isModEnabled('multicompany') && !$user->entity) {
 	print '<td class="center">';
 	print '<input type="hidden" name="entity" value="' . $conf->entity . '">';
 }
-print '<input type="submit" class="button button-add small" name="add" value="'.$langs->trans("Add").'">';
+print '<input type="submit" class="button button-add small" id="add" name="add" value="'.$langs->trans("Add").'">';
 print "</td>\n";
 print '</tr>';
 

+ 5 - 1
htdocs/admin/dav.php

@@ -43,7 +43,7 @@ $arrayofparameters = array(
 	'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1),
 	'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2),
 	'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1),
-	'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled)
+	'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>isModEnabled('ecm'))
 );
 
 // To fix when dire does not exists
@@ -124,6 +124,10 @@ if ($action == 'edit') {
 	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
 	foreach ($arrayofparameters as $key => $val) {
+		if (isset($val['enabled']) && empty($val['enabled'])) {
+			continue;
+		}
+
 		print '<tr class="oddeven"><td>';
 		$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
 		$label = $langs->trans($key);

+ 2 - 3
htdocs/admin/dict.php

@@ -513,7 +513,7 @@ $tabcond[25] = isModEnabled('website');
 $tabcond[27] = isModEnabled("societe");
 $tabcond[28] = isModEnabled('holiday');
 $tabcond[29] = isModEnabled('project');
-$tabcond[30] = isModEnabled('label');
+$tabcond[30] = (isModEnabled('label') || isModEnabled('barcode') || isModEnabled('adherent'));	// stickers format dictionary
 //$tabcond[31]= isModEnabled('accounting');
 $tabcond[32] = (isModEnabled('holiday') || isModEnabled('hrm'));
 $tabcond[33] = isModEnabled('hrm');
@@ -1571,7 +1571,6 @@ if ($id > 0) {
 			unset($fieldlist[2]); // Remove field ??? if dictionary Regions
 		}
 
-
 		if (empty($reshook)) {
 			fieldList($fieldlist, $obj, $tabname[$id], 'add');
 		}
@@ -2531,7 +2530,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
 				$classtd = 'right'; $class = 'maxwidth50 right';
 			}
 			if (in_array($fieldlist[$field], array('pos', 'position'))) {
-				$classtd = 'center'; $class = 'maxwidth50 center';
+				$classtd = 'right'; $class = 'maxwidth50 right';
 			}
 			if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'use_default', 'affect', 'delay', 'public', 'sortorder', 'sens', 'category_type', 'fk_parent'))) {
 				$class = 'maxwidth50 center';

+ 5 - 3
htdocs/admin/facture.php

@@ -364,7 +364,7 @@ foreach ($dirmodels as $reldir) {
 							if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) {
 								print img_picto($langs->trans("Activated"), 'switch_on');
 							} else {
-								print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+								print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
 							}
 							print '</td>';
 
@@ -702,12 +702,14 @@ if (isModEnabled('banque')) {
 }
 print "</td></tr>";
 
+$FACTURE_CHQ_NUMBER = getDolGlobalInt('FACTURE_CHQ_NUMBER');
+
 print '<tr class="oddeven">';
 print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
 print "<td>";
 print '<select class="flat" name="chq" id="chq">';
 print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
-print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
+print '<option value="-1"'.($FACTURE_CHQ_NUMBER == -1 ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
 
 $sql = "SELECT rowid, label";
 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
@@ -723,7 +725,7 @@ if ($resql) {
 		$row = $db->fetch_row($resql);
 
 		print '<option value="'.$row[0].'"';
-		print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
+		print $FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
 		print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
 
 		$i++;

+ 3 - 3
htdocs/admin/mailing.php

@@ -150,8 +150,8 @@ print '</tr>';
 
 print '<tr class="oddeven"><td>';
 print $langs->trans("MailingEMailError").'</td><td>';
-print '<input class="minwidth100" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'">';
-if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && !isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) {
+print '<input class="minwidth100" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.getDolGlobalString('MAILING_EMAIL_ERRORSTO').'">';
+if (getDolGlobalString('MAILING_EMAIL_ERRORSTO') && !isValidEmail(getDolGlobalString('MAILING_EMAIL_ERRORSTO'))) {
 	print ' '.img_warning($langs->trans("BadEMail"));
 }
 print '</td>';
@@ -160,7 +160,7 @@ print '</tr>';
 
 print '<tr class="oddeven"><td>';
 print $form->textwithpicto($langs->trans("MailingDelay"), $langs->trans("IfDefinedUseAValueBeetween", '0.001', '10')).'</td><td>';
-print '<input class="width75" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
+print '<input class="width75" type="text" name="MAILING_DELAY" value="'.getDolGlobalString('MAILING_DELAY').'">';
 print '</td>';
 print '<td class="hideonsmartphone"></td>';
 print '</tr>';

+ 3 - 3
htdocs/admin/payment.php

@@ -190,7 +190,7 @@ foreach ($dirmodels as $reldir) {
 							if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) {
 								print img_picto($langs->trans("Activated"), 'switch_on');
 							} else {
-								print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+								print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
 							}
 							print '</td>';
 
@@ -257,7 +257,7 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>';
 print $langs->trans("PaymentOnDifferentThirdBills");
 print '</td><td width="60" align="center">';
-print $form->selectyesno("FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", $conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS, 1);
+print $form->selectyesno("FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS", getDolGlobalInt('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS'), 1);
 print '</td><td class="right">';
 print "</td></tr>\n";
 
@@ -265,7 +265,7 @@ print "</td></tr>\n";
 print '<tr class="oddeven"><td>';
 print $langs->trans("GroupPaymentsByModOnReports");
 print '</td><td width="60" align="center">';
-print $form->selectyesno("PAYMENTS_REPORT_GROUP_BY_MOD", $conf->global->PAYMENTS_REPORT_GROUP_BY_MOD, 1);
+print $form->selectyesno("PAYMENTS_REPORT_GROUP_BY_MOD", getDolGlobalInt('PAYMENTS_REPORT_GROUP_BY_MOD'), 1);
 print '</td><td class="right">';
 print "</td></tr>\n";
 

+ 4 - 1
htdocs/admin/ticket_public.php

@@ -329,7 +329,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
 	print '</td>';
 	print '</tr>';
 
-	// Create third-party with contact if email not linked to a contact
+	// Auto fill the contact found from email
+	// This option is a serious security hole. it allowe to any non looged perso, to get the database of contacts
+	/*
 	print '<tr class="oddeven"><td>'.$langs->trans("TicketCreateThirdPartyWithContactIfNotExist").'</td>';
 	print '<td class="left">';
 	if (empty(getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST'))) {
@@ -342,6 +344,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
 	print $form->textwithpicto('', $langs->trans("TicketCreateThirdPartyWithContactIfNotExistHelp"), 1, 'help');
 	print '</td>';
 	print '</tr>';
+	*/
 
 	/*if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
 	{

+ 20 - 9
htdocs/bom/lib/bom.lib.php

@@ -156,20 +156,31 @@ function mrpCollapseBomManagement()
 	<script type="text/javascript" language="javascript">
 
 		$(document).ready(function () {
-			// When clicking on collapse
-			$(".collapse_bom").click(function() {
-				console.log("We click on collapse");
-				var id_bom_line = $(this).attr('id').replace('collapse-', '');
-				console.log($(this).html().indexOf('folder-open'));
-				if($(this).html().indexOf('folder-open') <= 0) {
+			function folderManage(element, onClose = 0) {
+				let id_bom_line = element.attr('id').replace('collapse-', '');
+				let TSubLines = $('[parentid="'+ id_bom_line +'"]');
+
+				if(element.html().indexOf('folder-open') <= 0 && onClose < 1) {
 					$('[parentid="'+ id_bom_line +'"]').show();
-					$(this).html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
+					element.html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
 				}
 				else {
-					$('[parentid="'+ id_bom_line +'"]').hide();
-					$(this).html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
+					for (let i = 0; i < TSubLines.length; i++) {
+						let subBomFolder = $(TSubLines[i]).children('.linecoldescription').children('.collapse_bom');
+
+						if (subBomFolder.length > 0) {
+							onClose = 1
+							folderManage(subBomFolder, onClose);
+						}
+					}
+					TSubLines.hide();
+					element.html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
 				}
+			}
 
+			// When clicking on collapse
+			$(".collapse_bom").click(function() {
+				folderManage($(this));
 				return false;
 			});
 

+ 2 - 2
htdocs/comm/action/class/actioncomm.class.php

@@ -2551,7 +2551,7 @@ class ActionComm extends CommonObject
 						}
 
 						// Sender
-						$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
+						$from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
 						if (empty($from)) {
 							$errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
 							$error++;
@@ -2559,7 +2559,7 @@ class ActionComm extends CommonObject
 
 						if (!$error) {
 							// Errors Recipient
-							$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
+							$errors_to = getDolGlobalString('MAIN_MAIL_ERRORS_TO');
 
 							// Mail Creation
 							$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', '', '', '', '');

+ 7 - 5
htdocs/comm/mailing/card.php

@@ -43,19 +43,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
 $langs->load("mails");
 
 $id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int'));
+
 $action = GETPOST('action', 'aZ09');
-$cancel = GETPOST('cancel');
 $confirm = GETPOST('confirm', 'alpha');
+$cancel = GETPOST('cancel', 'aZ09');
 $urlfrom = GETPOST('urlfrom');
 
+// Initialize technical objects
 $object = new Mailing($db);
+$extrafields = new ExtraFields($db);
+
 if ($id > 0) {
 	$result = $object->fetch($id);
 }
 
-$extrafields = new ExtraFields($db);
-
-// fetch optionals attributes and labels
+// Fetch optionals attributes and labels
 $extrafields->fetch_name_optionals_label($object->table_element);
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@@ -773,7 +775,7 @@ if ($action == 'create') {
 
 	print '<tr><td class="fieldrequired">'.$langs->trans("MailFrom").'</td><td><input class="flat minwidth200" name="from" value="'.getDolGlobalString('MAILING_EMAIL_FROM').'"></td></tr>';
 
-	print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td><input class="flat minwidth200" name="errorsto" value="'.(getDolGlobalString('MAILING_EMAIL_ERRORSTO', getDolGlobalString('MAIN_MAIL_ERRORS_TO'))).'"></td></tr>';
+	print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td><input class="flat minwidth200" name="errorsto" value="'.getDolGlobalString('MAILING_EMAIL_ERRORSTO', getDolGlobalString('MAIN_MAIL_ERRORS_TO')).'"></td></tr>';
 
 	// Other attributes
 	$parameters = array();

+ 1 - 1
htdocs/comm/propal/class/propal.class.php

@@ -1469,7 +1469,7 @@ class Propal extends CommonObject
 		if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) {
 			$object->ref_client = '';
 		}
-		if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) {
+		if (getDolGlobalInt('MAIN_DONT_KEEP_NOTE_ON_CLONING') == 1) {
 			$object->note_private = '';
 			$object->note_public = '';
 		}

+ 3 - 4
htdocs/comm/propal/list.php

@@ -557,10 +557,6 @@ $formcompany = new FormCompany($db);
 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
 
-$title = $langs->trans('ListOfProposals');
-$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
-llxHeader('', $title, $help_url);
-
 $sql = 'SELECT';
 if ($sall || $search_user > 0) {
 	$sql = 'SELECT DISTINCT';
@@ -868,6 +864,9 @@ if ($resql) {
 		exit;
 	}
 
+	$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos';
+	llxHeader('', $title, $help_url);
+
 	$param = '&search_status='.urlencode($search_status);
 	if (!empty($mode)) {
 		$param .= '&mode='.urlencode($mode);

+ 4 - 1
htdocs/compta/prelevement/class/bonprelevement.class.php

@@ -1717,8 +1717,11 @@ class BonPrelevement extends CommonObject
 	public static function buildRumNumber($row_code_client, $row_datec, $row_drum)
 	{
 		global $langs;
+
 		$pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation)
-		return $pre.($row_code_client ? '-'.$row_code_client : '').'-'.$row_drum.'-'.date('U', $row_datec);
+
+		// 3 char + '-' + 12 + '-' + id + '-' + code 		Must be lower than 32.
+		return $pre.'-'.dol_print_date($row_datec, 'dayhourlogsmall').'-'.dol_trunc($row_drum.($row_code_client ? '-'.$row_code_client : ''), 13, 'right', 'UTF-8', 1);
 	}
 
 

+ 2 - 2
htdocs/contrat/card.php

@@ -1650,9 +1650,9 @@ if ($action == 'create') {
 					if ($objp->subprice >= 0) {
 						$colspan = 6;
 
-						if ($conf->margin->enabled && getDolGlobalString('PRODUCT_USE_UNITS')) {
+						if (isModEnabled('margin') && getDolGlobalString('PRODUCT_USE_UNITS')) {
 							$colspan = 8;
-						} elseif ($conf->margin->enabled || getDolGlobalString('PRODUCT_USE_UNITS')) {
+						} elseif (isModEnabled('margin') || getDolGlobalString('PRODUCT_USE_UNITS')) {
 							$colspan = 7;
 						}
 

+ 16 - 3
htdocs/core/ajax/fetchKnowledgeRecord.php

@@ -36,8 +36,10 @@ if (!defined('NOREQUIREMENU')) {
 	define('NOREQUIREMENU', '1');
 }
 // If there is no need to load and show top and left menu
-if (!defined("NOLOGIN")) {
-	define("NOLOGIN", '1');
+if (!empty($_GET['public'])) {
+	if (!defined("NOLOGIN")) {
+		define("NOLOGIN", '1');
+	}
 }
 if (!defined('NOIPCHECK')) {
 	define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
@@ -52,6 +54,12 @@ $idticketgroup = GETPOST('idticketgroup', 'aZ09');
 $idticketgroup = GETPOST('idticketgroup', 'aZ09');
 $lang = GETPOST('lang', 'aZ09');
 
+/*if (defined("NOLOGIN") && !getDolGlobalString('TICKET_ENABLE_PUBLIC_INTERFACE')) {
+	// If we ask public content (so without login), we block if option TICKET_ENABLE_PUBLIC_INTERFACE is not enabled
+	httponly_accessforbidden('');
+}*/
+
+
 /*
  * Actions
  */
@@ -71,8 +79,13 @@ if ($action == "getKnowledgeRecord") {
 	$sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as kr ";
 	$sql .= " JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctc ON ctc.rowid = kr.fk_c_ticket_category";
 	$sql .= " WHERE ctc.code = '".$db->escape($idticketgroup)."'";
-	$sql .= " AND ctc.active = 1 AND ctc.public = 1 AND (kr.lang = '".$db->escape($lang)."' OR kr.lang = 0 OR kr.lang IS NULL)";
+	$sql .= " AND ctc.active = 1";
+	if (defined("NOLOGIN")) {
+		$sql .= " AND ctc.public = 1";
+	}
+	$sql .= " AND (kr.lang = '".$db->escape($lang)."' OR kr.lang = 0 OR kr.lang IS NULL)";
 	$sql .= " AND kr.status = 1 AND (kr.answer IS NOT NULL AND kr.answer <> '')";
+
 	$resql = $db->query($sql);
 	if ($resql) {
 		$num = $db->num_rows($resql);

+ 5 - 0
htdocs/core/class/commondocgenerator.class.php

@@ -35,6 +35,11 @@
  */
 abstract class CommonDocGenerator
 {
+	/**
+	 * @var string Model name
+	 */
+	public $name = '';
+
 	/**
 	 * @var string Error code (or message)
 	 */

+ 1 - 1
htdocs/core/class/dolgraph.class.php

@@ -1418,7 +1418,7 @@ class DolGraph
 
 					//var_dump($iinstack);
 					if ($iinstack) {
-						// Change color with offset of $$iinstack
+						// Change color with offset of $iinstack
 						//var_dump($newcolor);
 						if ($iinstack % 2) {	// We increase agressiveness of reference color for color 2, 4, 6, ...
 							$ratio = min(95, 10 + 10 * $iinstack); // step of 20

+ 4 - 4
htdocs/core/class/html.formfile.class.php

@@ -458,6 +458,10 @@ class FormFile
 			$submodulepart = $tmp[1];
 		}
 
+		$addcolumforpicto = ($delallowed || $printer || $morepicto);
+		$colspan = (4 + ($addcolumforpicto ? 1 : 0));
+		$colspanmore = 0;
+
 		// Show table
 		if ($genallowed) {
 			$modellist = array();
@@ -700,10 +704,6 @@ class FormFile
 
 			$out .= '<tr class="liste_titre">';
 
-			$addcolumforpicto = ($delallowed || $printer || $morepicto);
-			$colspan = (4 + ($addcolumforpicto ? 1 : 0));
-			$colspanmore = 0;
-
 			$out .= '<th colspan="'.$colspan.'" class="formdoc liste_titre maxwidthonsmartphone center">';
 
 			// Model

+ 30 - 22
htdocs/core/class/html.formticket.class.php

@@ -154,7 +154,7 @@ class FormTicket
 	 * @param  	int	 			$withdolfichehead		With dol_get_fiche_head() and dol_get_fiche_end()
 	 * @param	string			$mode					Mode ('create' or 'edit')
 	 * @param	int				$public					1=If we show the form for the public interface
-	 * @param	Contact|null	$with_contact			[=NULL] Contact to link to this ticket if exists
+	 * @param	Contact|null	$with_contact			[=NULL] Contact to link to this ticket if it exists
 	 * @param	string			$action					[=''] Action in card
 	 * @return 	void
 	 */
@@ -188,6 +188,7 @@ class FormTicket
 		print '<form method="POST" '.($withdolfichehead ? '' : 'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.(!empty($this->param["returnurl"]) ? $this->param["returnurl"] : $_SERVER['PHP_SELF']).'">';
 		print '<input type="hidden" name="token" value="'.newToken().'">';
 		print '<input type="hidden" name="action" value="'.$this->action.'">';
+		print '<input type="hidden" name="trackid" value="'.$this->trackid.'">';
 		foreach ($this->param as $key => $value) {
 			print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
 		}
@@ -348,26 +349,9 @@ class FormTicket
 		$this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1);
 		print '</td></tr>';
 
-		// Subject
-		if ($this->withtitletopic) {
-			print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>';
-			// Answer to a ticket : display of the thread title in readonly
-			if ($this->withtopicreadonly) {
-				print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title;
-			} else {
-				if (isset($this->withreadid) && $this->withreadid > 0) {
-					$subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title;
-				} else {
-					$subject = GETPOST('subject', 'alpha');
-				}
-				print '<input class="text minwidth500" id="subject" name="subject" value="'.$subject.'" autofocus />';
-			}
-			print '</td></tr>';
-		}
-
 		if (!empty($conf->knowledgemanagement->enabled)) {
 			// KM Articles
-			print '<tr id="KWwithajax"></tr>';
+			print '<tr id="KWwithajax" class="hidden"><td></td></tr>';
 			print '<!-- Script to manage change of ticket group -->
 			<script nonce="'.getNonce().'">
 			jQuery(document).ready(function() {
@@ -380,12 +364,17 @@ class FormTicket
 
 					if (idgroupticket != "") {
 						$.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/fetchKnowledgeRecord.php\',
-							 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\'},
+							 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\', public:'.($public).' },
 							 type: \'GET\',
 							 success: function(response) {
 								var urllist = \'\';
 								console.log("We received response "+response);
-								response = JSON.parse(response)
+								if (typeof response == "object") {
+									console.log("response is already type object, no need to parse it");
+								} else {
+									console.log("response is type "+(typeof response));
+									response = JSON.parse(response);
+								}
 								for (key in response) {
 									answer = response[key].answer;
 									urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
@@ -422,6 +411,23 @@ class FormTicket
 			</script>'."\n";
 		}
 
+		// Subject
+		if ($this->withtitletopic) {
+			print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>';
+			// Answer to a ticket : display of the thread title in readonly
+			if ($this->withtopicreadonly) {
+				print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title;
+			} else {
+				if (isset($this->withreadid) && $this->withreadid > 0) {
+					$subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title.'';
+				} else {
+					$subject = GETPOST('subject', 'alpha');
+				}
+				print '<input class="text minwidth500" id="subject" name="subject" value="'.$subject.'"'.(empty($this->withemail)?' autofocus':'').' />';
+			}
+			print '</td></tr>';
+		}
+
 		// MESSAGE
 		$msg = GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : '';
 		print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span></label></td><td>';
@@ -459,7 +465,7 @@ class FormTicket
 			if (count($cate_arbo)) {
 				// Categories
 				print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
-				print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
+				print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
 				print "</td></tr>";
 			}
 		}
@@ -854,6 +860,8 @@ class FormTicket
 						print ' selected="selected"';
 					} elseif ($arraycategories['use_default'] == "1" && !$selected && !$empty) {
 						print ' selected="selected"';
+					} elseif (count($ticketstat->cache_category_tickets) == 1) {
+						print ' selected="selected"';
 					}
 
 					print '>';

+ 2 - 2
htdocs/core/class/ldap.class.php

@@ -339,7 +339,7 @@ class Ldap
 	 * This method seems a duplicate/alias of unbind().
 	 *
 	 * @return	boolean			true or false
-	 * @deprecated ldap_close is an alias of ldap_unbind
+	 * @deprecated ldap_close is an alias of ldap_unbind, so use unbind() instead.
 	 * @see unbind()
 	 */
 	public function close()
@@ -401,7 +401,7 @@ class Ldap
 	public function unbind()
 	{
 		$this->result = true;
-		if ($this->connection) {
+		if (is_resource($this->connection) || is_object($this->connection)) {
 			$this->result = @ldap_unbind($this->connection);
 		}
 		if ($this->result) {

+ 8 - 10
htdocs/core/lib/functions.lib.php

@@ -2324,14 +2324,12 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
 		}
 		$tmptxt = $object->getLibStatut(5);
 		$morehtmlstatus .= $tmptxt; // No status on task
-	} else { // Generic case
-		if (isset($object->status)) {
-			$tmptxt = $object->getLibStatut(6);
-			if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
-				$tmptxt = $object->getLibStatut(5);
-			}
-			$morehtmlstatus .= $tmptxt;
+	} elseif (method_exists($object, 'getLibStatut')) { // Generic case
+		$tmptxt = $object->getLibStatut(6);
+		if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
+			$tmptxt = $object->getLibStatut(5);
 		}
+		$morehtmlstatus .= $tmptxt;
 	}
 
 	// Add if object was dispatched "into accountancy"
@@ -2648,7 +2646,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
 		$format = '%Y%m%d%H%M%S';
 	} elseif ($format == 'dayhourlogsmall') {
 		// Format not sensitive to language
-		$format = '%Y%m%d%H%M';
+		$format = '%y%m%d%H%M';
 	} elseif ($format == 'dayhourldap') {
 		$format = '%Y%m%d%H%M%SZ';
 	} elseif ($format == 'dayhourxcard') {
@@ -2731,8 +2729,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
 			$dtts->setTimestamp($timetouse);
 			$dtts->setTimezone($tzo);
 			$newformat = str_replace(
-				array('%Y', '%y', '%m', '%d', '%H', '%I', '%M', '%S', '%p', 'T', 'Z', '__a__', '__A__', '__b__', '__B__'),
-				array('Y', 'y', 'm', 'd', 'H', 'h', 'i', 's', 'A', '__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
+				array('%Y', '%y', '%m', '%d', '%H', '%I', '%M', '%S', '%p', '%w', 'T', 'Z', '__a__', '__A__', '__b__', '__B__'),
+				array('Y', 'y', 'm', 'd', 'H', 'h', 'i', 's', 'A', 'w', '__£__', '__$__', '__{__', '__}__', '__[__', '__]__'),
 				$format);
 			$ret = $dtts->format($newformat);
 			$ret = str_replace(

+ 2 - 0
htdocs/core/lib/pdf.lib.php

@@ -2471,10 +2471,12 @@ function pdf_getLinkedObjects(&$object, $outputlangs)
 					$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending");
 					if (!empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] .= ' / ';
 					$linkedobjects[$objecttype]['ref_value'] .= $outputlangs->transnoentities($elementobject->ref);
+					$linkedobjects[$objecttype]['date_value'] = dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping, 'day', '', $outputlangs);
 				} else {
 					$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending");
 					if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '');
 					$linkedobjects[$objecttype]['ref_value'] .= ' / '.$outputlangs->transnoentities($elementobject->ref);
+					$linkedobjects[$objecttype]['date_value'] = dol_print_date(empty($elementobject->date_shipping) ? $elementobject->date_delivery : $elementobject->date_shipping, 'day', '', $outputlangs);
 				}
 			}
 		}

+ 1 - 1
htdocs/core/lib/usergroups.lib.php

@@ -366,7 +366,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
 		print '<tr>';
 		print '<td>'.$langs->trans("DefaultSkin").'</td>';
 		print '<td>'.$conf->global->MAIN_THEME.'</td>';
-		print '<td class="nowrap left"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit ? '' : ' disabled').' type="checkbox" '.($selected_theme ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>';
+		print '<td class="nowrap left"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit ? '' : ' disabled').' type="checkbox" '.($selected_theme ? " checked" : "").'> <label for="check_MAIN_THEME">'.$langs->trans("UsePersonalValue").'</label></td>';
 		print '<td>&nbsp;</td>';
 		print '</tr>';
 	} else {

+ 6 - 21
htdocs/core/modules/facture/mod_facture_mercure.php

@@ -53,7 +53,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
 	 */
 	public function info()
 	{
-		global $db, $conf, $langs;
+		global $db, $langs;
 
 		$langs->load("bills");
 
@@ -137,35 +137,20 @@ class mod_facture_mercure extends ModeleNumRefFactures
 	 */
 	public function getNextValue($objsoc, $invoice, $mode = 'next')
 	{
-		global $db, $conf;
+		global $db;
 
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 
 		// Get Mask value
 		$mask = '';
 		if (is_object($invoice) && $invoice->type == 1) {
-			if (isset($conf->global->FACTURE_MERCURE_MASK_REPLACEMENT)) {
-				$mask = $conf->global->FACTURE_MERCURE_MASK_REPLACEMENT;
-			}
-			if (!$mask) {
-				if (isset($conf->global->FACTURE_MERCURE_MASK_INVOICE)) {
-					$mask = $conf->global->FACTURE_MERCURE_MASK_INVOICE;
-				}
-			}
+			$mask = getDolGlobalString('FACTURE_MERCURE_MASK_REPLACEMENT', getDolGlobalString('FACTURE_MERCURE_MASK_INVOICE'));
 		} elseif (is_object($invoice) && $invoice->type == 2) {
-			if (isset($conf->global->FACTURE_MERCURE_MASK_CREDIT)) {
-				$mask = $conf->global->FACTURE_MERCURE_MASK_CREDIT;
-			}
+			$mask = getDolGlobalString('FACTURE_MERCURE_MASK_CREDIT');
 		} elseif (is_object($invoice) && $invoice->type == 3) {
-			if (isset($conf->global->FACTURE_MERCURE_MASK_DEPOSIT)) {
-				$mask = $conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
-			}
+			$mask = getDolGlobalString('FACTURE_MERCURE_MASK_DEPOSIT');
 		} else {
-			if (isset($conf->global->FACTURE_MERCURE_MASK_INVOICE)) {
-				$mask = $conf->global->FACTURE_MERCURE_MASK_INVOICE;
-			} else {
-				$mask = '';
-			}
+			$mask = getDolGlobalString('FACTURE_MERCURE_MASK_INVOICE');
 		}
 		if (!$mask) {
 			$this->error = 'NotConfigured';

+ 3 - 3
htdocs/core/modules/payment/mod_payment_ant.php

@@ -61,7 +61,7 @@ class mod_payment_ant extends ModeleNumRefPayments
 	 */
 	public function info()
 	{
-		global $db, $conf, $langs;
+		global $db, $langs;
 
 		$langs->load("bills");
 
@@ -82,7 +82,7 @@ class mod_payment_ant extends ModeleNumRefPayments
 
 		// Parametrage du prefix
 		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
-		$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskpayment" value="'.$conf->global->PAYMENT_ANT_MASK.'">', $tooltip, 1, 1).'</td>';
+		$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskpayment" value="'.getDolGlobalString('PAYMENT_ANT_MASK').'">', $tooltip, 1, 1).'</td>';
 
 		$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
 
@@ -128,7 +128,7 @@ class mod_payment_ant extends ModeleNumRefPayments
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 
 		// We get cursor rule
-		$mask = $conf->global->PAYMENT_ANT_MASK;
+		$mask = getDolGlobalString('PAYMENT_ANT_MASK');
 
 		if (!$mask) {
 			$this->error = 'NotConfigured';

+ 11 - 8
htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php

@@ -117,13 +117,16 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 
 		$form = new Form($this->db);
 
+		$odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0;
+		$odtPath = trim(getDolGlobalString('PROPALE_ADDON_PDF_ODT_PATH'));
+
 		$texte = $this->description.".<br>\n";
 		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
 		$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
 		$texte .= '<input type="hidden" name="page_y" value="">';
 		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
 		$texte .= '<input type="hidden" name="param1" value="PROPALE_ADDON_PDF_ODT_PATH">';
-		if (getDolGlobalInt("MAIN_PROPAL_CHOOSE_ODT_DOCUMENT") > 0) {
+		if ($odtChosen) {
 			$texte .= '<input type="hidden" name="param2" value="PROPALE_ADDON_PDF_ODT_DEFAULT">';
 			$texte .= '<input type="hidden" name="param3" value="PROPALE_ADDON_PDF_ODT_TOBILL">';
 			$texte .= '<input type="hidden" name="param4" value="PROPALE_ADDON_PDF_ODT_CLOSED">';
@@ -133,7 +136,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 		// List of directories area
 		$texte .= '<tr><td>';
 		$texttitle = $langs->trans("ListOfDirectories");
-		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH)));
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
 		$listoffiles = array();
 		foreach ($listofdir as $key => $tmpdir) {
 			$tmpdir = trim($tmpdir);
@@ -159,7 +162,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
 		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
 		$texte .= '<textarea class="flat" cols="60" name="value1">';
-		$texte .= $conf->global->PROPALE_ADDON_PDF_ODT_PATH;
+		$texte .= $odtPath;
 		$texte .= '</textarea>';
 		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
 		$texte .= '<input type="submit" class="button small reposition" name="modify" value="'.$langs->trans("Modify").'">';
@@ -167,7 +170,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 
 		// Scan directories
 		$nbofiles = count($listoffiles);
-		if (!empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH)) {
+		if (!empty($odtPath)) {
 			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
 			$texte .= count($listoffiles);
@@ -187,26 +190,26 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 			$texte .= '</div>';
 
 			// Set default template for different status of proposal
-			if (getDolGlobalInt("MAIN_PROPAL_CHOOSE_ODT_DOCUMENT") > 0) {
+			if ($odtChosen) {
 				// Model for creation
 				$list = ModelePDFPropales::liste_modeles($this->db);
 				$texte .= '<table width="50%">';
 				$texte .= '<tr>';
 				$texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalCreate").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value2', $list, $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT);
+				$texte .= $form->selectarray('value2', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_DEFAULT'));
 				$texte .= "</td></tr>";
 
 				$texte .= '<tr>';
 				$texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalToBill").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value3', $list, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL);
+				$texte .= $form->selectarray('value3', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_TOBILL'));
 				$texte .= "</td></tr>";
 				$texte .= '<tr>';
 
 				$texte .= '<td width="60%">'.$langs->trans("DefaultModelPropalClosed").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value4', $list, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED);
+				$texte .= $form->selectarray('value4', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_CLOSED'));
 				$texte .= "</td></tr>";
 				$texte .= '</table>';
 			}

+ 11 - 8
htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php

@@ -117,13 +117,16 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
 
 		$form = new Form($this->db);
 
+		$odtChosen = getDolGlobalInt('MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT') > 0;
+		$odtPath = trim(getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'));
+
 		$texte = $this->description.".<br>\n";
 		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 		$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
 		$texte .= '<input type="hidden" name="page_y" value="">';
 		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
 		$texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
-		if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) {
+		if ($odtChosen) {
 			$texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
 			$texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
 			$texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
@@ -133,7 +136,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
 		// List of directories area
 		$texte .= '<tr><td>';
 		$texttitle = $langs->trans("ListOfDirectories");
-		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
 		$listoffiles = array();
 		foreach ($listofdir as $key => $tmpdir) {
 			$tmpdir = trim($tmpdir);
@@ -159,7 +162,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
 		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
 		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
 		$texte .= '<textarea class="flat" cols="60" name="value1">';
-		$texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
+		$texte .= $odtPath;
 		$texte .= '</textarea>';
 		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
 		$texte .= '<input type="submit" class="button small reposition" name="modify" value="'.$langs->trans("Modify").'">';
@@ -167,7 +170,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
 
 		// Scan directories
 		$nbofiles = count($listoffiles);
-		if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)) {
+		if (!empty($odtPath)) {
 			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
 			$texte .= count($listoffiles);
@@ -185,26 +188,26 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
 			}
 			$texte .= '</div>';
 
-			if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) {
+			if ($odtChosen) {
 				// Model for creation
 				$list = ModelePDFSupplierProposal::liste_modeles($this->db);
 				$texte .= '<table width="50%;">';
 				$texte .= '<tr>';
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value2', $list, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
+				$texte .= $form->selectarray('value2', $list, getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT'));
 				$texte .= "</td></tr>";
 
 				$texte .= '<tr>';
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value3', $list, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
+				$texte .= $form->selectarray('value3', $list, getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL'));
 				$texte .= "</td></tr>";
 				$texte .= '<tr>';
 
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value4', $list, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
+				$texte .= $form->selectarray('value4', $list, getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED'));
 				$texte .= "</td></tr>";
 				$texte .= '</table>';
 			}

+ 5 - 3
htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php

@@ -64,7 +64,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
 	 */
 	public function info()
 	{
-		global $conf, $langs, $db;
+		global $langs, $db;
 
 		$langs->load("bills");
 
@@ -83,9 +83,11 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
 		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("CommRequest"), $langs->transnoentities("CommRequest"));
 		$tooltip .= $langs->trans("GenericMaskCodes5");
 
+		$mask = dolGetGlobalString('SUPPLIER_PROPOSAL_SAPHIR_MASK');
+
 		// Parametrage du prefix
 		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
-		$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="masksupplier_proposal" value="'.$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
+		$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="masksupplier_proposal" value="'.$mask.'">', $tooltip, 1, 1).'</td>';
 
 		$texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit" name="Button"value="'.$langs->trans("Modify").'"></td>';
 
@@ -131,7 +133,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 
 		// On defini critere recherche compteur
-		$mask = $conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
+		$mask = empty($conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK) ? '' : $conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
 
 		if (!$mask) {
 			$this->error = 'NotConfigured';

+ 10 - 7
htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php

@@ -114,13 +114,16 @@ class doc_generic_user_odt extends ModelePDFUser
 
 		$form = new Form($this->db);
 
+		$odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0;
+		$odtPath = trim(getDolGlobalString('USER_ADDON_PDF_ODT_PATH'));
+
 		$texte = $this->description.".<br>\n";
 		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
 		$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
 		$texte .= '<input type="hidden" name="page_y" value="">';
 		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
 		$texte .= '<input type="hidden" name="param1" value="USER_ADDON_PDF_ODT_PATH">';
-		if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) {
+		if ($odtChosen) {
 			$texte .= '<input type="hidden" name="param2" value="USER_ADDON_PDF_ODT_DEFAULT">';
 			$texte .= '<input type="hidden" name="param3" value="USER_ADDON_PDF_ODT_TOBILL">';
 			$texte .= '<input type="hidden" name="param4" value="USER_ADDON_PDF_ODT_CLOSED">';
@@ -130,7 +133,7 @@ class doc_generic_user_odt extends ModelePDFUser
 		// List of directories area
 		$texte .= '<tr><td>';
 		$texttitle = $langs->trans("ListOfDirectories");
-		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USER_ADDON_PDF_ODT_PATH)));
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
 		$listoffiles = array();
 		foreach ($listofdir as $key => $tmpdir) {
 			$tmpdir = trim($tmpdir);
@@ -156,7 +159,7 @@ class doc_generic_user_odt extends ModelePDFUser
 		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
 		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
 		$texte .= '<textarea class="flat" cols="60" name="value1">';
-		$texte .= $conf->global->USER_ADDON_PDF_ODT_PATH;
+		$texte .= $odtPath;
 		$texte .= '</textarea>';
 		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
 		$texte .= '<input type="submit" class="button small reposition" name="modify" value="'.$langs->trans("Modify").'">';
@@ -166,26 +169,26 @@ class doc_generic_user_odt extends ModelePDFUser
 		if (count($listofdir)) {
 			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
 
-			if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) {
+			if ($odtChosen) {
 				// Model for creation
 				$list = ModelePDFUser::liste_modeles($this->db);
 				$texte .= '<table width="50%;">';
 				$texte .= '<tr>';
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value2', $list, $conf->global->USER_ADDON_PDF_ODT_DEFAULT);
+				$texte .= $form->selectarray('value2', $list, getDolGlobalString('USER_ADDON_PDF_ODT_DEFAULT'));
 				$texte .= "</td></tr>";
 
 				$texte .= '<tr>';
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value3', $list, $conf->global->USER_ADDON_PDF_ODT_TOBILL);
+				$texte .= $form->selectarray('value3', $list, getDolGlobalString('USER_ADDON_PDF_ODT_TOBILL'));
 				$texte .= "</td></tr>";
 				$texte .= '<tr>';
 
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value4', $list, $conf->global->USER_ADDON_PDF_ODT_CLOSED);
+				$texte .= $form->selectarray('value4', $list, getDolGlobalString('USER_ADDON_PDF_ODT_CLOSED'));
 				$texte .= "</td></tr>";
 				$texte .= '</table>';
 			}

+ 10 - 7
htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php

@@ -117,13 +117,16 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
 
 		$form = new Form($this->db);
 
+		$odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0;
+		$odtPath = trim(getDolGlobalString('USERGROUP_ADDON_PDF_ODT_PATH'));
+
 		$texte = $this->description.".<br>\n";
 		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 		$texte .= '<input type="hidden" name="token" value="'.newToken().'">';
 		$texte .= '<input type="hidden" name="page_y" value="">';
 		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
 		$texte .= '<input type="hidden" name="param1" value="USERGROUP_ADDON_PDF_ODT_PATH">';
-		if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) {
+		if ($odtChosen) {
 			$texte .= '<input type="hidden" name="param2" value="USERGROUP_ADDON_PDF_ODT_DEFAULT">';
 			$texte .= '<input type="hidden" name="param3" value="USERGROUP_ADDON_PDF_ODT_TOBILL">';
 			$texte .= '<input type="hidden" name="param4" value="USERGROUP_ADDON_PDF_ODT_CLOSED">';
@@ -133,7 +136,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
 		// List of directories area
 		$texte .= '<tr><td>';
 		$texttitle = $langs->trans("ListOfDirectories");
-		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USERGROUP_ADDON_PDF_ODT_PATH)));
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
 		$listoffiles = array();
 		foreach ($listofdir as $key => $tmpdir) {
 			$tmpdir = trim($tmpdir);
@@ -159,7 +162,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
 		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
 		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
 		$texte .= '<textarea class="flat" cols="60" name="value1">';
-		$texte .= $conf->global->USERGROUP_ADDON_PDF_ODT_PATH;
+		$texte .= $odtPath;
 		$texte .= '</textarea>';
 		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
 		$texte .= '<input type="submit" class="button small reposition" name="modify" value="'.$langs->trans("Modify").'">';
@@ -169,26 +172,26 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
 		if (count($listofdir)) {
 			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
 
-			if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) {
+			if ($odtChosen) {
 				// Model for creation
 				$list = ModelePDFUserGroup::liste_modeles($this->db);
 				$texte .= '<table width="50%;">';
 				$texte .= '<tr>';
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value2', $list, $conf->global->USERGROUP_ADDON_PDF_ODT_DEFAULT);
+				$texte .= $form->selectarray('value2', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_DEFAULT'));
 				$texte .= "</td></tr>";
 
 				$texte .= '<tr>';
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value3', $list, $conf->global->USERGROUP_ADDON_PDF_ODT_TOBILL);
+				$texte .= $form->selectarray('value3', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_TOBILL'));
 				$texte .= "</td></tr>";
 				$texte .= '<tr>';
 
 				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
 				$texte .= '<td colspan="">';
-				$texte .= $form->selectarray('value4', $list, $conf->global->USERGROUP_ADDON_PDF_ODT_CLOSED);
+				$texte .= $form->selectarray('value4', $list, getDolGlobalString('USERGROUP_ADDON_PDF_ODT_CLOSED'));
 				$texte .= "</td></tr>";
 				$texte .= '</table>';
 			}

+ 2 - 1
htdocs/core/tpl/objectline_view.tpl.php

@@ -187,10 +187,11 @@ if (($line->info_bits & 2) == 2) {
 		if ($line->date_start || $line->date_end) {
 			print '<div class="clearboth nowraponall opacitymedium daterangeofline">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
 		}
+
 		if (!$line->date_start || !$line->date_end) {
 			// show warning under line
 			// we need to fetch product associated to line for some test
-			if ($object->element == 'propal'  || $object->element == 'order' || $object->element == 'propal_supplier' || $object->element == 'supplier_proposal' || $object->element == 'commande') {
+			if ($object->element == 'propal' || $object->element == 'order' || $object->element == 'facture' || $object->element == 'propal_supplier' || $object->element == 'supplier_proposal' || $object->element == 'commande') {
 				$res = $line->fetch_product();
 				if ($res  > 0  ) {
 					if ($line->product->isService() && $line->product->isMandatoryPeriod()) {

+ 1 - 1
htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php

@@ -1112,7 +1112,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		$ret = $actioncomm->create($user); // User creating action
 
 		if ($ret > 0 && !empty($conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO)) {
-			if (is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) {
+			if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && array_key_exists('paths', $object->attachedfiles) && count($object->attachedfiles['paths']) > 0) {
 				foreach ($object->attachedfiles['paths'] as $key => $filespath) {
 					$srcfile = $filespath;
 					$destdir = $conf->agenda->dir_output.'/'.$ret;

+ 2 - 2
htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php

@@ -274,7 +274,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
 		$message_admin = $langs->transnoentities($body, $object->track_id).'<br>';
 		$message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
 		$message_admin .= '<li>'.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
-		$message_admin .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
+		$message_admin .= '<li>'.$langs->trans('TicketCategory').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
 		$message_admin .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
 		$message_admin .= '<li>'.$langs->trans('From').' : '.($object->email_from ? $object->email_from : ($object->fk_user_create > 0 ? $langs->trans('Internal') : '')).'</li>';
 		// Extrafields
@@ -343,7 +343,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
 		$message_customer = $langs->transnoentities($body, $object->track_id).'<br>';
 		$message_customer .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
 		$message_customer .= '<li>'.$langs->trans('Type').' : '.$langs->getLabelFromKey($this->db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code).'</li>';
-		$message_customer .= '<li>'.$langs->trans('Category').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
+		$message_customer .= '<li>'.$langs->trans('TicketCategory').' : '.$langs->getLabelFromKey($this->db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code).'</li>';
 		$message_customer .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
 
 		// Extrafields

+ 1 - 1
htdocs/dav/dav.lib.php

@@ -54,7 +54,7 @@ function dav_admin_prepare_head()
 	$h = 0;
 	$head = array();
 
-	$head[$h][0] = DOL_URL_ROOT.'/admin/dav.php?id='.$object->id;
+	$head[$h][0] = DOL_URL_ROOT.'/admin/dav.php';
 	$head[$h][1] = $langs->trans("WebDAV");
 	$head[$h][2] = 'webdav';
 	$h++;

+ 1 - 1
htdocs/includes/tecnickcom/tcpdf/include/barcodes/datamatrix.php

@@ -629,7 +629,7 @@ class Datamatrix {
 					if ($numch[ENC_C40] == $numch[ENC_X12]) {
 						$k = ($pos + $charscount + 1);
 						while ($k < $data_length) {
-							$tmpchr = ord($data{$k});
+							$tmpchr = ord($data[$k]);
 							if ($this->isCharMode($tmpchr, ENC_X12)) {
 								return ENC_X12;
 							} elseif (!($this->isCharMode($tmpchr, ENC_X12) OR $this->isCharMode($tmpchr, ENC_C40))) {

+ 1 - 1
htdocs/langs/en_US/ticket.lang

@@ -186,7 +186,7 @@ CreatedBy=Created by
 NewTicket=New Ticket
 SubjectAnswerToTicket=Ticket answer
 TicketTypeRequest=Request type
-TicketCategory=Ticket categorization
+TicketCategory=Ticket group
 SeeTicket=See ticket
 TicketMarkedAsRead=Ticket has been marked as read
 TicketReadOn=Read on

+ 1 - 1
htdocs/mrp/class/api_mos.class.php

@@ -366,7 +366,7 @@ class Mos extends DolibarrApi
 			$pos = 0;
 			$arrayofarrayname = array("arraytoconsume","arraytoproduce");
 			foreach ($arrayofarrayname as $arrayname) {
-				foreach ($$arrayname as $value) {
+				foreach ($arrayname as $value) {
 					$tmpproduct = new Product($this->db);
 					if (empty($value["objectid"])) {
 						throw new RestException(500, "Field objectid required in ".$arrayname);

+ 2 - 2
htdocs/product/stock/card.php

@@ -364,7 +364,7 @@ if ($action == 'create') {
 
 	// Status
 	print '<tr><td>'.$langs->trans("Status").'</td><td>';
-	print '<select id="warehousestatus" name="statut" class="flat">';
+	print '<select id="warehousestatus" name="statut" class="flat minwidth100">';
 	foreach ($object->statuts as $key => $value) {
 		if ($key == 1) {
 			print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
@@ -839,7 +839,7 @@ if ($action == 'create') {
 
 
 		/*
-		 * Edition fiche
+		 * Edit
 		 */
 		if ($action == 'edit' || $action == 're-edit') {
 			$langs->trans("WarehouseEdit");

+ 9 - 3
htdocs/product/stock/class/entrepot.class.php

@@ -141,7 +141,7 @@ class Entrepot extends CommonObject
 		'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>301),
 		//'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000),
 		//'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>1010),
-		'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>500),
+		'statut' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>500, 'css'=>'minwidth50'),
 	);
 
 	/**
@@ -150,15 +150,21 @@ class Entrepot extends CommonObject
 	const STATUS_CLOSED = 0;
 
 	/**
-	 * Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corrections allowed.
+	 * Warehouse open and any operations are allowed (customer shipping, supplier dispatch, internal stock transfers/corrections).
 	 */
 	const STATUS_OPEN_ALL = 1;
 
 	/**
-	 * Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and supplier dispatch).
+	 * Warehouse open and only operations for stock transfers/corrections allowed (not for customer shipping and supplier dispatch).
 	 */
 	const STATUS_OPEN_INTERNAL = 2;
 
+	/**
+	 * Warehouse open and any operations are allowed, but warehouse is not included into calculation of stock.
+	 */
+	const STATUS_OPENEXT_ALL = 3;	// TODO Implement this
+
+
 
 	/**
 	 *  Constructor

+ 8 - 3
htdocs/projet/class/task.class.php

@@ -842,9 +842,11 @@ class Task extends CommonObjectLine
 	 * @param   array   $search_array_options Array of search
 	 * @param   int     $loadextras         Fetch all Extrafields on each task
 	 * @param	int		$loadRoleMode		1= will test Roles on task;  0 used in delete project action
+	 * @param	string	$sortfield			Sort field
+	 * @param	string	$sortorder			Sort order
 	 * @return 	array|string				Array of tasks
 	 */
-	public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1)
+	public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '')
 	{
 		global $conf, $hookmanager;
 
@@ -984,8 +986,11 @@ class Task extends CommonObjectLine
 			}
 		}
 
-
-		$sql .= " ORDER BY p.ref, t.rang, t.dateo";
+		if ($sortfield && $sortorder) {
+			$sql .= $this->db->order($sortfield, $sortorder);
+		} else {
+			$sql .= " ORDER BY p.ref, t.rang, t.dateo";
+		}
 
 		//print $sql;exit;
 		dol_syslog(get_class($this)."::getTasksArray", LOG_DEBUG);

+ 13 - 13
htdocs/projet/tasks.php

@@ -124,12 +124,12 @@ $search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_el
 
 
 // Default sort order (if not yet defined by previous GETPOST)
-if (!$sortfield) {
+/* if (!$sortfield) {
 	reset($object->fields); $sortfield="t.".key($object->fields);
 }   // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
 if (!$sortorder) {
 	$sortorder = "ASC";
-}
+} */
 
 
 // Security check
@@ -880,7 +880,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
 	// Get list of tasks in tasksarray and taskarrayfiltered
 	// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
 	$filteronthirdpartyid = $socid;
-	$tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options);
+	$tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options, 0, 1, $sortfield, $sortorder);
 
 	// We load also tasks limited to a particular user
 	$tmpuser = new User($db);
@@ -1037,41 +1037,41 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
 	print '<tr class="liste_titre nodrag nodrop">';
 	// print '<td>'.$langs->trans("Project").'</td>';
 	if (!empty($arrayfields['t.ref']['checked'])) {
-		print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '');
+		print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], 't.ref', '', $param, '', $sortfield, $sortorder, '');
 	}
 	if (!empty($arrayfields['t.label']['checked'])) {
-		print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
+		print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", '', $param, '', $sortfield, $sortorder, '');
 	}
 	if (!empty($arrayfields['t.description']['checked'])) {
 		print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
 	}
 	if (!empty($arrayfields['t.dateo']['checked'])) {
-		print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
+		print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", '', $param, '', $sortfield, $sortorder, 'center ');
 	}
 	if (!empty($arrayfields['t.datee']['checked'])) {
-		print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
+		print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", '', $param, '', $sortfield, $sortorder, 'center ');
 	}
 	if (!empty($arrayfields['t.planned_workload']['checked'])) {
-		print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
+		print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
 	}
 	if (!empty($arrayfields['t.duration_effective']['checked'])) {
-		print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
+		print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
 	}
 	if (!empty($arrayfields['t.progress_calculated']['checked'])) {
 		print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
 	}
 	if (!empty($arrayfields['t.progress']['checked'])) {
-		print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
+		print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
 	}
 	if (!empty($arrayfields['t.progress_summary']['checked'])) {
 		print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1);
 	}
 	if ($object->usage_bill_time) {
 		if (!empty($arrayfields['t.tobill']['checked'])) {
-			print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
+			print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "t.tobill", '', $param, '', $sortfield, $sortorder, 'right ');
 		}
 		if (!empty($arrayfields['t.billed']['checked'])) {
-			print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
+			print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "t.billed", '', $param, '', $sortfield, $sortorder, 'right ');
 		}
 	}
 	// Contacts of task, disabled because available by default jsut after
@@ -1082,7 +1082,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
 	*/
 
 	if (!empty($arrayfields['t.budget_amount']['checked'])) {
-		print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
+		print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "t.budget_amount", "", $param, '', $sortfield, $sortorder, 'center ');
 	}
 
 	if (!empty($arrayfields['c.assigned']['checked'])) {

+ 9 - 7
htdocs/projet/tasks/time.php

@@ -1120,23 +1120,27 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
 	}
 	$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
 
+	// Task
+
 	// Show section with information of task. If id of task is not defined and project id defined, then $projectidforalltimes is not empty.
 	if (empty($projectidforalltimes) && empty($allprojectforuser)) {
 		$head = task_prepare_head($object);
 		print dol_get_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition');
 
 		if ($action == 'deleteline') {
-			print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid", 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
+			$urlafterconfirm = $_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid", 'int').($withproject ? '&withproject=1' : '');
+			print $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
 		}
 
 		$param = ($withproject ? '&withproject=1' : '');
+		$param .= ($param ? '&' : '').'id='.$object->id;		// ID of task
 		$linkback = $withproject ? '<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>' : '';
 
 		if (!GETPOST('withproject') || empty($projectstatic->id)) {
 			$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
 			$object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")";
 		} else {
-			$object->next_prev_filter = " fk_projet = ".$projectstatic->id;
+			$object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id);
 		}
 
 		$morehtmlref = '';
@@ -1233,17 +1237,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
 
 
 	if ($projectstatic->id > 0 || $allprojectforuser > 0) {
-		if ($action == 'deleteline' && !empty($projectidforalltimes)) {
-			print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
-		}
-
 		// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
 		$hookmanager->initHooks(array('tasktimelist'));
 
 		$formconfirm = '';
 
 		if ($action == 'deleteline' && !empty($projectidforalltimes)) {
-			$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
+			// We must use projectidprojectid if on list of timespent of project and id=taskid if on list of timespent of a task
+			$urlafterconfirm = $_SERVER["PHP_SELF"]."?".($projectstatic->id > 0 ? 'projectid='.$projectstatic->id : ($object->id > 0 ? "id=".$object->id : '')).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : '')."&contextpage=".urlencode($contextpage);
+			$formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1);
 		}
 
 		// Call Hook formConfirm

+ 1 - 1
htdocs/public/stripe/ipn.php

@@ -73,7 +73,7 @@ if (isset($_GET['connect'])) {
 	}
 }
 
-if (empty($conf->stripe->enabled)) {
+if (!isModEnabled('stripe')) {
 	httponly_accessforbidden('Module Stripe not enabled');
 }
 

+ 23 - 3
htdocs/public/ticket/ajax/ajax.php

@@ -19,6 +19,9 @@
 /**
  *	\file       htdocs/public/ticket/ajax/ajax.php
  *	\brief      Ajax component for Ticket.
+ *
+ *  This ajax component is called only by the create ticket public page. And only if TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST is set.
+ *  This option TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST has been removed because it is a security hole.
  */
 
 if (!defined('NOTOKENRENEWAL')) {
@@ -54,6 +57,14 @@ $action = GETPOST('action', 'aZ09');
 $id = GETPOST('id', 'int');
 $email = GETPOST('email', 'alphanohtml');
 
+if (!isModEnabled('ticket')) {
+	httponly_accessforbidden('Module Ticket not enabled');
+}
+
+if (empty($conf->global->TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST)) {
+	httponly_accessforbidden('Option TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST of module ticket is not enabled');
+}
+
 
 /*
  * View
@@ -71,9 +82,18 @@ if ($action == 'getContacts') {
 		require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
 
 		$ticket = new Ticket($db);
-		$contacts = $ticket->searchContactByEmail($email);
-		if (is_array($contacts)) {
-			$return['contacts'] = $contacts;
+		$arrayofcontacts = $ticket->searchContactByEmail($email);
+		if (is_array($arrayofcontacts)) {
+			$arrayofminimalcontacts = array();
+			foreach ($arrayofcontacts as $tmpval) {
+				$tmpresult = new stdClass();
+				$tmpresult->id = $tmpval->id;
+				$tmpresult->firstname = $tmpval->firstname;
+				$tmpresult->lastname = $tmpval->lastname;
+				$arrayofminimalcontacts[] = $tmpresult;
+			}
+
+			$return['contacts'] = $arrayofminimalcontacts;
 		} else {
 			$return['error'] = $ticket->errorsToString();
 		}

+ 1 - 3
htdocs/public/ticket/create_ticket.php

@@ -1,6 +1,7 @@
 <?php
 /* Copyright (C) 2013-2016    Jean-François FERRY <hello@librethic.io>
  * Copyright (C) 2016         Christophe Battarel <christophe@altairis.fr>
+ * Copyright (C) 2023         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
@@ -26,9 +27,6 @@
 if (!defined('NOREQUIREUSER')) {
 	define('NOREQUIREUSER', '1');
 }*/
-if (!defined('NOTOKENRENEWAL')) {
-	define('NOTOKENRENEWAL', '1');
-}
 if (!defined('NOREQUIREMENU')) {
 	define('NOREQUIREMENU', '1');
 }

+ 1 - 1
htdocs/public/ticket/index.php

@@ -86,7 +86,7 @@ print '<p style="text-align: center">'.(getDolGlobalString("TICKET_PUBLIC_TEXT_H
 print '<br>';
 
 print '<div class="ticketform">';
-print '<a href="create_ticket.php?action=create'.(!empty($entity) && isModEnabled('multicompany')?'&entity='.$entity:'').'" rel="nofollow noopener" class="butAction marginbottomonly"><div class="index_create bigrounded"><span class="fa fa-15 fa-plus-circle valignmiddle btnTitle-icon"></span><br>'.dol_escape_htmltag($langs->trans("CreateTicket")).'</div></a>';
+print '<a href="'.DOL_URL_ROOT.'/public/ticket/create_ticket.php?action=create'.(!empty($entity) && isModEnabled('multicompany')?'&entity='.$entity:'').'" rel="nofollow noopener" class="butAction marginbottomonly"><div class="index_create bigrounded"><span class="fa fa-15 fa-plus-circle valignmiddle btnTitle-icon"></span><br>'.dol_escape_htmltag($langs->trans("CreateTicket")).'</div></a>';
 print '<a href="list.php'.(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'').'" rel="nofollow noopener" class="butAction marginbottomonly"><div class="index_display bigrounded"><span class="fa fa-15 fa-list-alt valignmiddle btnTitle-icon"></span><br>'.dol_escape_htmltag($langs->trans("ViewMyTicketList")).'</div></a>';
 print '<a href="view.php'.(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'').'" rel="nofollow noopener" class="butAction marginbottomonly"><div class="index_display bigrounded">'.img_picto('', 'ticket', 'class="fa-15"').'<br>'.dol_escape_htmltag($langs->trans("ShowTicketWithTrackId")).'</div></a>';
 print '<div class="clearboth"></div>';

+ 11 - 9
htdocs/societe/paymentmodes.php

@@ -1144,14 +1144,14 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 								}
 								print '<a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe').' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account, 'globe').'</a> ';
 							}
-							print $companypaymentmodetemp->stripe_card_ref;
+							print dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref);
 							print '</td>';
 							// Type
 							print '<td>';
 							print img_credit_card($companypaymentmodetemp->type);
 							print '</td>';
 							// Information (Owner, ...)
-							print '<td>';
+							print '<td class="minwidth100">';
 							if ($companypaymentmodetemp->proprio) {
 								print '<span class="opacitymedium">'.$companypaymentmodetemp->proprio.'</span><br>';
 							}
@@ -1161,7 +1161,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 							if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) {
 								print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year;
 							}
-							print '</td><td>';
+							print '</td>';
+							// Country
+							print '<td class="tdoverflowmax100">';
 							if ($companypaymentmodetemp->country_code) {
 								$img = picto_from_langcode($companypaymentmodetemp->country_code);
 								print $img ? $img.' ' : '';
@@ -1180,12 +1182,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 								print img_picto($langs->trans("Default"), 'on');
 							}
 							print '</td>';
-							print '<td>';
 							if (empty($companypaymentmodetemp->stripe_card_ref)) {
-								print $langs->trans("Local");
+								$s = $langs->trans("Local");
 							} else {
-								print $langs->trans("LocalAndRemote");
+								$s = $langs->trans("LocalAndRemote");
 							}
+							print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).'">';
+							print $s;
 							print '</td>';
 							print '<td>';
 							print dol_print_date($companypaymentmodetemp->tms, 'dayhour');
@@ -1195,7 +1198,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 							$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
 							print $hookmanager->resPrint;
 							// Action column
-							print '<td class="right nowraponall">';
+							print '<td class="right minwidth50 nowraponall">';
 							if ($permissiontoaddupdatepaymentinformation) {
 								if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) {
 									print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="paddingrightonly marginrightonly">'.$langs->trans("CreateCardOnStripe").'</a>';
@@ -1480,7 +1483,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 			// Bank name
 			print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($rib->bank).'">'.dol_escape_htmltag($rib->bank).'</td>';
 			// Account number
-			print '<td>';
 			$string = '';
 			foreach ($rib->getFieldsToShow() as $val) {
 				if ($val == 'BankCode') {
@@ -1506,7 +1508,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 					$string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info');
 				}
 			}
-
+			print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($string).'">';
 			print $string;
 			print '</td>';
 			// IBAN

+ 1 - 1
htdocs/theme/eldy/global.inc.php

@@ -5246,7 +5246,7 @@ div.visible {
 	display: block;
 }
 
-div.hidden, header.hidden, td.hidden, img.hidden, span.hidden, div.showifmore {
+div.hidden, header.hidden, tr.hidden, td.hidden, img.hidden, span.hidden, div.showifmore {
 	display: none;
 }
 .unvisible {

+ 1 - 1
htdocs/theme/md/style.css.php

@@ -5243,7 +5243,7 @@ div.visible {
 	display: block;
 }
 
-div.hidden, header.hidden, td.hidden, img.hidden, span.hidden, div.showifmore {
+div.hidden, header.hidden, tr.hidden, td.hidden, img.hidden, span.hidden, div.showifmore {
 	display: none;
 }
 

+ 2 - 2
htdocs/ticket/card.php

@@ -276,7 +276,7 @@ if (empty($reshook)) {
 
 			if (!$error) {
 				// File transfer
-				$object->copyFilesForTicket();
+				$object->copyFilesForTicket('');		// trackid is forced to '' because files were uploaded when no id for ticket exists yet and trackid was ''
 			}
 
 			if (!$error) {
@@ -726,6 +726,7 @@ if ($action == 'create' || $action == 'presend') {
 
 	print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
 
+	$formticket->trackid = '';		// TODO Use a unique key 'tic' to avoid conflict in upload file feature
 	$formticket->withfromsocid = $socid ? $socid : $user->socid;
 	$formticket->withfromcontactid = $contactid ? $contactid : '';
 	$formticket->withtitletopic = 1;
@@ -736,7 +737,6 @@ if ($action == 'create' || $action == 'presend') {
 	$formticket->withfile = 2;
 	$formticket->withextrafields = 1;
 	$formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid'));
-	$formticket->trackid = 'tic'.$object->id;
 
 	$formticket->withcancel = 1;
 

+ 6 - 5
htdocs/ticket/class/ticket.class.php

@@ -1940,10 +1940,10 @@ class Ticket extends CommonObject
 
 		$res = $this->db->query($sql);
 		if ($res) {
-			while ($rec = $this->db->fetch_array($res)) {
+			while ($rec = $this->db->fetch_object($res)) {
 				include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 				$contactstatic = new Contact($this->db);
-				$contactstatic->fetch($rec['rowid']);
+				$contactstatic->fetch($rec->rowid);
 				$contacts[] = $contactstatic;
 			}
 
@@ -2316,9 +2316,10 @@ class Ticket extends CommonObject
 	 * Used for files linked into messages.
 	 * Files may be renamed during copy to avoid overwriting existing files.
 	 *
-	 * @return	array		Array with final path/name/mime of files.
+	 * @param	string	$forcetrackid	Force trackid
+	 * @return	array					Array with final path/name/mime of files.
 	 */
-	public function copyFilesForTicket()
+	public function copyFilesForTicket($forcetrackid = null)
 	{
 		global $conf;
 
@@ -2333,7 +2334,7 @@ class Ticket extends CommonObject
 		$maxheightmini = 72;
 
 		$formmail = new FormMail($this->db);
-		$formmail->trackid = 'tic'.$this->id;
+		$formmail->trackid = (is_null($forcetrackid) ? 'tic'.$this->id : '');
 		$attachedfiles = $formmail->get_attached_files();
 
 		$filepath = $attachedfiles['paths'];

+ 2 - 2
htdocs/ticket/css/styles.css.php

@@ -82,15 +82,15 @@ div.ticketform {
 	box-shadow: 2px 2px 2px rgb(245, 245, 245);
 	border-radius: 10px 10px 10px 10px;
 	margin: 1.5em;
-*/
 	background : #ffffff;
+*/
 	text-align: center;
 }
 
 div.ticketform .index_create, div.ticketform .index_display {
 	display: inline-block;
 	width: 200px;
-	height: 45px;
+	height: 60px;
 	text-align: center;
 	vertical-align: middle;
 	margin: 20px;

+ 1 - 3
htdocs/variants/card.php

@@ -330,9 +330,7 @@ if ($action == 'create') {
 			print '<table id="tablelines" class="noborder centpercent">';
 		}
 
-		if (!empty($object->lines)) {
-			$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/variants/tpl', ($permissiontoedit ? 1 : 0));
-		}
+		$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/variants/tpl', ($permissiontoedit ? 1 : 0));
 
 		if (!empty($object->lines) || ($permissiontoedit && $action != 'selectlines' && $action != 'editline')) {
 			print '</table>';

+ 0 - 14
htdocs/variants/tpl/productattributevalueline_create.tpl.php

@@ -40,20 +40,6 @@ $objectline = null;
 
 print "<!-- BEGIN PHP TEMPLATE productattributevalueline_create.tpl.php -->\n";
 $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
-if ($nolinesbefore) {
-	?>
-	<tr class="liste_titre<?php echo ($nolinesbefore ? '' : ' liste_titre_add_') ?> nodrag nodrop">
-		<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
-			<td class="linecolnum center"></td>
-		<?php } ?>
-		<td class="linecolref">
-			<div id="add"></div><span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine'); ?></span>
-		</td>
-		<td class="linecolvalue"><span id="title_vat"><?php echo $langs->trans('Value'); ?></span></td>
-		<td class="linecoledit" colspan="<?php echo $colspan; ?>">&nbsp;</td>
-	</tr>
-	<?php
-}
 ?>
 <tr class="pair nodrag nodrop nohoverpair<?php echo $nolinesbefore ? '' : ' liste_titre_create'; ?>">
 	<?php