From c70beaa56b3afce61c4e0f1def585eeffe566487 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Jun 2017 01:53:55 +0200 Subject: [PATCH] Complete work for mutualizing generic substitution system. --- htdocs/admin/commande.php | 14 +-- htdocs/admin/contract.php | 2 +- htdocs/admin/defaultvalues.php | 44 ++++----- htdocs/admin/expedition.php | 2 +- htdocs/admin/expensereport.php | 12 +-- htdocs/admin/facture.php | 2 +- htdocs/admin/fichinter.php | 4 +- htdocs/admin/ihm.php | 88 +++++++++++------- htdocs/admin/livraison.php | 4 +- htdocs/admin/mails_templates.php | 68 +++++++------- htdocs/admin/propal.php | 6 +- htdocs/admin/supplier_invoice.php | 6 +- htdocs/admin/supplier_order.php | 10 +-- htdocs/admin/supplier_proposal.php | 6 +- htdocs/core/class/html.formmail.class.php | 75 ++++++++-------- htdocs/core/lib/functions.lib.php | 103 +++++++++++++++++++++- htdocs/core/lib/pdf.lib.php | 50 ++++------- htdocs/core/lib/security2.lib.php | 16 ++-- htdocs/index.php | 31 +++---- 19 files changed, 315 insertions(+), 228 deletions(-) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index d60144a3492..6d92ad21999 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -182,7 +182,7 @@ else if ($action == 'setdoc') else if ($action == 'setmod') { - // TODO Check if numbering module chosen can be activated + // TODO Check if numbering module chosen can be activated // by calling method canBeActivated dolibarr_set_const($db, "COMMANDE_ADDON",$value,'chaine',0,'',$conf->entity); @@ -331,7 +331,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print ''.$module->nom."\n"; print $module->info(); print ''; @@ -609,7 +609,7 @@ print "\n"; print ''; // Shippable Icon in List -/* Kept as hidden feature for the moment, result seems bugged. +/* Kept as hidden feature for the moment, result seems bugged. Whet is definition of "shippable" according to all different STOCK_CALCULATE_... options ? print ''; @@ -631,7 +631,7 @@ print ''; // Ask for payment bank during order if ($conf->banque->enabled) { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").' '; if (! empty($conf->use_javascript_ajax)) @@ -653,7 +653,7 @@ if ($conf->banque->enabled) } else { - + print ''; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").' '.$langs->trans('NotAvailable').''; } @@ -661,7 +661,7 @@ else // Ask for warehouse during order if ($conf->stock->enabled) { - + print ''; print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '; if (! empty($conf->use_javascript_ajax)) @@ -683,7 +683,7 @@ if ($conf->stock->enabled) } else { - + print ''; print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '.$langs->trans('NotAvailable').''; } diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 4c0a9572761..47e53a05048 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -265,7 +265,7 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - + print ''.$module->nom."\n"; print $module->info(); print ''; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 40e63de8aea..10d9ec5c282 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -120,11 +120,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac $error++; } } - + if (! $error) { $db->begin(); - + if ($action == 'add' || (GETPOST('add') && $action != 'update')) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; @@ -134,7 +134,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; $sql.= " WHERE rowid = ".$id; } - + $result = $db->query($sql); if ($result > 0) { @@ -223,7 +223,7 @@ print ''; print ''; $head=defaultvalues_prepare_head(); - + dol_fiche_head($head, $mode, '', -1, ''); if ($mode == 'sortorder') @@ -249,11 +249,11 @@ $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); // Field $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); -if ($mode != 'sortorder') +if ($mode != 'sortorder') { $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); } -else +else { $texthelp='field or alias.field'; $textkey=$form->textwithpicto($langs->trans("Field"), $texthelp); @@ -264,22 +264,14 @@ if ($mode != 'focus') { if ($mode != 'sortorder') { + $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST + $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'
'; - // See list into GETPOST - $texthelp.='__USERID__
'; - $texthelp.='__SUPERVISORID__
'; - $texthelp.='__MYCOUNTRYID__
'; - $texthelp.='__DAY__
'; - $texthelp.='__MONTH__
'; - $texthelp.='__YEAR__
'; - $texthelp.='__PREVIOUS_DAY__
'; - $texthelp.='__PREVIOUS_MONTH__
'; - $texthelp.='__PREVIOUS_YEAR__
'; - $texthelp.='__NEXT_DAY__
'; - $texthelp.='__NEXT_MONTH__
'; - $texthelp.='__NEXT_YEAR__
'; - if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__
'; - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); + foreach($substitutionarray as $key => $val) + { + $texthelp.=$key.'
'; + } + $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click } else { @@ -351,18 +343,18 @@ if ($result) while ($i < $num) { $obj = $db->fetch_object($result); - + print "\n"; print ''; - + // Page print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->page; else print ''; print ''."\n"; - + // Field print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; @@ -382,7 +374,7 @@ if ($result) else print ''; print ''; } - + // Actions print ''; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) @@ -400,7 +392,7 @@ if ($result) print ''; } print ''; - + print "\n"; print "\n"; $i++; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 3c89960ede6..e9a9aaedb18 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -82,7 +82,7 @@ else if ($action == 'set_param') $error++; setEventMessages($langs->trans("Error"), null, 'errors'); } - + $draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha'); $res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); if ($res <= 0) diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index eefe5747abd..92ba9375927 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -77,7 +77,7 @@ else if ($action == 'specimen') // For fiche inter $inter->initAsSpecimen(); $inter->status = 0; // Force statut draft to show watermark $inter->fk_statut = 0; // Force statut draft to show watermark - + // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); @@ -193,13 +193,13 @@ else if ($action == 'setmod') else if ($action == 'setoptions') { $db->begin(); - + $freetext= GETPOST('EXPENSEREPORT_FREE_TEXT'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); - + $draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK','alpha'); $res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); - + if (! $res1 > 0 || ! $res2 > 0) $error++; if (! $error) @@ -276,7 +276,7 @@ foreach ($dirmodels as $reldir) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + print ''.$module->nom."\n"; print $module->info(); print ''; @@ -399,7 +399,7 @@ foreach ($dirmodels as $reldir) if (file_exists($dir.'/'.$file)) { - + $name = substr($file, 4, dol_strlen($file) -16); $classname = substr($file, 0, dol_strlen($file) -12); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 77230dc3f68..64ae1abdde6 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -693,7 +693,7 @@ if ($resql) $i = 0; while ($i < $num) { - + $row = $db->fetch_row($resql); print '