NEW Can use translations into all substitutions (watermark, freetext...)

This commit is contained in:
Laurent Destailleur 2017-04-17 13:02:40 +02:00
parent e97e202deb
commit 0994622bf8
23 changed files with 239 additions and 123 deletions

View File

@ -209,6 +209,23 @@ class Adherent extends CommonObject
// Substitutions
$substitutionarray=array(
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
'__ID__'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id,
'__CIVILITY__'=>$this->getCivilityLabel(),
'__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
'__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
'__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs),
'__COMPANY__'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'__ADDRESS__'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address,
'__ZIP__'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
'__TOWN_'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'__COUNTRY__'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
'__EMAIL__'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
'__BIRTH__'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday,
'__PHOTO__'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'__LOGIN__'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'__PASSWORD__'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass,
// For backward compatibility
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
'%ID%'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id,
'%CIVILITY%'=>$this->getCivilityLabel(),
@ -225,7 +242,6 @@ class Adherent extends CommonObject
'%PHOTO%'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'%LOGIN%'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass,
// For backward compatibility
'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
'%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'%PRENOM%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
@ -234,16 +250,10 @@ class Adherent extends CommonObject
'%VILLE%'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
'%PAYS%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
);
// Add extrafields as substitution key %EXTRA_XXX%
foreach($this->array_options as $key => $val)
{
$keyshort=preg_replace('/^(options|extra)_/','',$key);
$substitutionarray['%EXTRA_'.$keyshort.'%']=$val;
}
complete_substitutions_array($substitutionarray, $langs);
complete_substitutions_array($substitutionarray, $langs, $this);
return make_substitutions($text,$substitutionarray);
return make_substitutions($text, $substitutionarray, $langs);
}

View File

@ -284,7 +284,7 @@ print load_fiche_titre($langs->trans("OrdersSetup"),$linkback,'title_setup');
$head = order_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Orders"), 0, 'order');
dol_fiche_head($head, 'general', $langs->trans("Orders"), -1, 'order');
/*
* Orders Numbering model
@ -593,8 +593,14 @@ print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"set_COMMANDE_DRAFT_WATERMARK\">";
print '<tr class="oddeven"><td>';
print $langs->trans("WatermarkOnDraftOrders").'</td><td>';
print '<input size="50" class="flat" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.$conf->global->COMMANDE_DRAFT_WATERMARK.'">';
$substitutionarray=pdf_getSubstitutionArray($langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext);
print '</td><td>';
print '<input class="flat minwidth200" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.$conf->global->COMMANDE_DRAFT_WATERMARK.'">';
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";

View File

@ -279,7 +279,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup');
$head = invoice_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Invoices"), 0, 'invoice');
dol_fiche_head($head, 'general', $langs->trans("Invoices"), -1, 'invoice');
/*
* Numbering module
@ -760,7 +760,13 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="set_FACTURE_DRAFT_WATERMARK" />';
print '<tr class="oddeven"><td>';
print $langs->trans("WatermarkOnDraftBill").'</td>';
$substitutionarray=pdf_getSubstitutionArray($langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext);
print '</td>';
print '<td><input size="50" class="flat" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.$conf->global->FACTURE_DRAFT_WATERMARK.'" />';
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';

View File

@ -75,7 +75,7 @@ print "<br>\n";
$head = order_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Orders"), 0, 'order');
dol_fiche_head($head, 'attributes', $langs->trans("Orders"), -1, 'order');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -76,7 +76,7 @@ print "<br>\n";
$head = order_admin_prepare_head();
dol_fiche_head($head, 'attributeslines', $langs->trans("OrderLines"), 0, 'order');
dol_fiche_head($head, 'attributeslines', $langs->trans("OrderLines"), -1, 'order');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -248,16 +248,15 @@ else if ($action == 'setmod')
/*
* Affiche page
* View
*/
$form=new Form($db);
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
llxHeader('',$langs->trans("PropalSetup"));
$form=new Form($db);
//if ($mesg) print $mesg;
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@ -265,7 +264,7 @@ print load_fiche_titre($langs->trans("PropalSetup"),$linkback,'title_setup');
$head = propal_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Proposals"), 0, 'propal');
dol_fiche_head($head, 'general', $langs->trans("Proposals"), -1, 'propal');
/*
* Module numerotation
@ -534,11 +533,10 @@ print '<br>';
/*
* Other options
*
*/
print load_fiche_titre($langs->trans("OtherOptions"),'','');
$var=true;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td>".$langs->trans("Parameter")."</td>\n";
@ -572,7 +570,6 @@ print "</td></tr>\n";
print '</form>';
*/
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_PROPOSAL_FREE_TEXT">';
@ -599,8 +596,14 @@ print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"set_PROPALE_DRAFT_WATERMARK\">";
print '<tr class="oddeven"><td>';
print $langs->trans("WatermarkOnDraftProposal").'</td><td>';
print '<input size="50" class="flat" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.$conf->global->PROPALE_DRAFT_WATERMARK.'">';
$substitutionarray=pdf_getSubstitutionArray($langs);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
$htmltext.='</i>';
print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext);
print '</td><td>';
print '<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.$conf->global->PROPALE_DRAFT_WATERMARK.'">';
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";

View File

@ -69,7 +69,7 @@ print load_fiche_titre($langs->trans("PropalSetup"),$linkback,'title_setup');
$head = propal_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Proposals"), 0, 'propal');
dol_fiche_head($head, 'attributes', $langs->trans("Proposals"), -1, 'propal');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -76,7 +76,7 @@ print load_fiche_titre($langs->trans("PropalSetup"),$linkback,'title_setup');
$head = propal_admin_prepare_head();
dol_fiche_head($head, 'attributeslines', $langs->trans("Proposals"), 0, 'propal');
dol_fiche_head($head, 'attributeslines', $langs->trans("Proposals"), -1, 'propal');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -57,6 +57,7 @@ $hookmanager->initHooks(array('mailingcard','globalcard'));
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$object->substitutionarray=FormMail::getAvailableSubstitKey('emailing');
$object->substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
$object->substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord',
@ -72,7 +73,7 @@ $object->substitutionarrayfortest=array(
'__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''),
'__CHECK_READ__' => 'TagCheckMail',
'__UNSUBSCRIBE__' => 'TagUnsubscribe'
//,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet
//,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet
);
// List of sending methods
@ -237,7 +238,7 @@ if (empty($reshook))
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
$substitutionisok=true;
//$substitutionisok=true;
complete_substitutions_array($substitutionarray, $langs);
$newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray);
@ -266,11 +267,11 @@ if (empty($reshook))
{
$res=0;
}
if (! $substitutionisok)
/*if (! $substitutionisok)
{
$mail->error='Some substitution failed';
$res=0;
}
}*/
// Send mail
if ($res)
@ -754,8 +755,6 @@ else
$head = emailing_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("Mailing"), 0, 'email');
// Confirmation back to draft
if ($action == 'settodraft')
{
@ -780,6 +779,8 @@ else
if ($action != 'edit')
{
dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email');
/*
* Mailing en mode visu
*/
@ -842,7 +843,8 @@ else
if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -903,8 +905,10 @@ else
print '</table>';
print "</div>";
dol_fiche_end();
// Clone confirmation
if ($action == 'clone')
{
@ -1106,7 +1110,9 @@ else
/*
* Mailing en mode edition
*/
dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email');
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlright='';
@ -1114,6 +1120,7 @@ else
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -1132,9 +1139,6 @@ else
// To
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($object->email_errorsto,0,0,0,0,1).'</td></tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
// Nb of distinct emails
print '<tr><td>';
print $langs->trans("TotalNbOfDistinctRecipients");
@ -1160,6 +1164,7 @@ else
}
print '</table>';
print '</div>';
dol_fiche_end();

View File

@ -177,7 +177,7 @@ if ($object->fetch($id) >= 0)
{
$head = emailing_prepare_head($object);
dol_fiche_head($head, 'targets', $langs->trans("Mailing"), 0, 'email');
dol_fiche_head($head, 'targets', $langs->trans("Mailing"), -1, 'email');
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
@ -186,16 +186,11 @@ if ($object->fetch($id) >= 0)
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
/*
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">';
print $form->showrefnav($object,'id', $linkback);
print '</td></tr>';
*/
print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>';
print '<tr><td>'.$langs->trans("MailFrom").'</td><td colspan="3">'.dol_print_email($object->email_from,0,0,0,0,1).'</td></tr>';
@ -204,11 +199,6 @@ if ($object->fetch($id) >= 0)
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td colspan="3">'.dol_print_email($object->email_errorsto,0,0,0,0,1);
print '</td></tr>';
// Status
/* print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4);
if ($object->statut == 2) print ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.')';
print '</td></tr>';
*/
// Nb of distinct emails
print '<tr><td>';
print $langs->trans("TotalNbOfDistinctRecipients");
@ -229,6 +219,7 @@ if ($object->fetch($id) >= 0)
print "</div>";
dol_fiche_end();
$allowaddtarget=($object->statut == 0);
@ -256,8 +247,8 @@ if ($object->fetch($id) >= 0)
clearstatcache();
$var=true;
$var = true;
foreach ($modulesdir as $dir)
{
$modulenames=array();
@ -316,7 +307,7 @@ if ($object->fetch($id) >= 0)
if ($allowaddtarget)
{
print '<form '.$bctag[$var].' name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
print '<form aa '.$bctag[$var].' name="'.$modulename.'" action="'.$_SERVER['PHP_SELF'].'?action=add&id='.$object->id.'&module='.$modulename.'" method="POST" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
}
else
@ -514,7 +505,6 @@ if ($object->fetch($id) >= 0)
print '</td>';
print '</tr>';
$var = true;
$i = 0;
if ($num)
@ -523,8 +513,6 @@ if ($object->fetch($id) >= 0)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.$obj->email.'</td>';
print '<td>'.$obj->lastname.'</td>';
@ -599,7 +587,7 @@ if ($object->fetch($id) >= 0)
{
if ($object->statut < 2)
{
print '<tr '.$bc[false].'><td colspan="8" class="opacitymedium">';
print '<tr><td colspan="8" class="opacitymedium">';
print $langs->trans("NoTargetYet");
print '</td></tr>';
}

View File

@ -27,6 +27,8 @@ require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
$id=GETPOST('id');
$langs->load("mails");
// Security check
@ -45,11 +47,11 @@ $form = new Form($db);
$object = new Mailing($db);
if ($object->fetch($_REQUEST["id"]) >= 0)
if ($object->fetch($id) >= 0)
{
$head = emailing_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Mailing"), 0, 'email');
dol_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email');
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';

View File

@ -359,7 +359,6 @@ class Facture extends CommonInvoice
'__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'),
);
$substitutionisok=true;
complete_substitutions_array($substitutionarray, $outputlangs);
$this->note_public=make_substitutions($this->note_public,$substitutionarray);

View File

@ -938,7 +938,8 @@ if ($action == 'create')
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date,'%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'),'%Y').')'
);
$substitutionarray['__(TRANSKEY)__']=$langs->trans("TransKey");
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)
{
@ -1241,7 +1242,8 @@ else
'__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')',
'__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')'
);
$substitutionarray['__(TRANSKEY)__']=$langs->trans("TransKey");
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)
{

View File

@ -1025,11 +1025,15 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if ($object->element == 'member') $modulepart='memberphoto';
if ($object->element == 'user') $modulepart='userphoto';
if ($object->element == 'product') $modulepart='product';
if ($object->element == 'propal') $modulepart='propal';
if ($object->element == 'commande') $modulepart='commande';
if ($object->element == 'facture') $modulepart='facture';
if ($object->element == 'fichinter') $modulepart='ficheinter';
if (class_exists("Imagick"))
{
if ($object->element == 'propal') $modulepart='propal';
if ($object->element == 'commande') $modulepart='commande';
if ($object->element == 'facture') $modulepart='facture';
if ($object->element == 'fichinter') $modulepart='ficheinter';
if ($object->element == 'contrat') $modulepart='contract';
}
if ($object->element == 'product')
{
$width=80; $cssclass='photoref';
@ -1051,14 +1055,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
}
else
{
if ($showimage)
if ($showimage)
{
if ($modulepart != 'unknown')
if ($modulepart != 'unknown')
{
$phototoshow='';
// Check if a preview file is available
if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter')) && class_exists("Imagick"))
if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract')) && class_exists("Imagick"))
{
$objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->$modulepart->dir_output . "/";
@ -1083,7 +1087,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$ret = dol_convert_file($file, 'png', $fileimage);
if ($ret < 0) $error++;
}
// Si fichier png PDF d'1 page trouve
if (file_exists($fileimage))
{
@ -4865,45 +4869,77 @@ function dol_concatdesc($text1,$text2,$forxml=false)
/**
* Make substition into a string replacing key with vals from $substitutionarray (oldval=>newval)
*
* @param string $chaine Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute
* @return string Output string after subsitutions
* @param string $text Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute
* @param Translate $outputlangs Output language
* @return string Output string after substitutions
* @see complete_substitutions_array
*/
function make_substitutions($chaine,$substitutionarray)
function make_substitutions($text, $substitutionarray, $outputlangs=null)
{
global $conf;
global $conf, $langs;
if (! is_array($substitutionarray)) return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
// Make substitition
if (empty($outputlangs)) $outputlangs=$langs;
// Make substitution for language keys
if (is_object($outputlangs))
{
while (preg_match('/__\((.*)\)__/', $text, $reg))
{
$msgishtml = 0;
if (dol_textishtml($text,1)) $msgishtml = 1;
$text = preg_replace('/__\('.preg_quote($reg[1]).'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text);
}
}
// Make substitition for array $substitutionarray
foreach ($substitutionarray as $key => $value)
{
if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value='';
$chaine=str_replace("$key","$value",$chaine); // We must keep the " to work when value is 123.5 for example
$text=str_replace("$key","$value",$text); // We must keep the " to work when value is 123.5 for example
}
return $chaine;
return $text;
}
/**
* Complete the $substitutionarray with more entries
*
* @param array $substitutionarray Array substitution old value => new value value
* @param Translate $outputlangs If we want substitution from special constants, we provide a language
* @param object $object If we want substitution from special constants, we provide data in a source object
* @param Mixed $parameters Add more parameters (useful to pass product lines)
* @param Translate $outputlangs Output language
* @param Object $object Source object
* @param mixed $parameters Add more parameters (useful to pass product lines)
* @param string $callfunc What is the name of the custom function that will be called? (default: completesubstitutionarray)
* @return void
* @see make_substitutions
*/
function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='',$parameters=null,$callfunc="completesubstitutionarray")
function complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
{
global $conf,$user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Check if there is external substitution to do asked by plugins
// Add a substitution key for each object property
if (is_object($object))
{
// TODO
}
// Add a substitution key for each extrafields, using key __EXTRA_XXX__
if (is_object($object) && is_array($object->array_options))
{
foreach($object->array_options as $key => $val)
{
$keyshort=preg_replace('/^(options|extra)_/','',$key);
$substitutionarray['__EXTRA_'.$keyshort.'__']=$val;
// For backward compatibiliy
$substitutionarray['%EXTRA_'.$keyshort.'%']=$val;
}
}
// Check if there is external substitution to do, requested by plugins
$dirsubstitutions=array_merge(array(),(array) $conf->modules_parts['substitutions']);
foreach($dirsubstitutions as $reldir)

View File

@ -586,6 +586,29 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
}
}
/**
* Return array of possible substitutions
*
* @param Translate $outputlangs Output language
* @return array Array of substitutions
*/
function pdf_getSubstitutionArray($outputlangs)
{
global $conf, $mysoc, $user;
$substitutionarray=array(
'__MYCOMPANY_NAME__' => $mysoc->name,
'__MYCOMPANY_EMAIL__' => $mysoc->email,
'__USER_ID__' => $user->id,
'__USER_LOGIN__' => $user->login,
'__USER_LASTNAME__' => $user->lastname,
'__USER_FIRSTNAME__' => $user->firstname,
'__USER_FULLNAME__' => $user->getFullName($outputlangs)
);
return $substitutionarray;
}
/**
* Add a draft watermark on PDF files
*
@ -599,12 +622,20 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
*/
function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
{
global $langs, $mysoc, $user;
// Print Draft Watermark
if ($unit=='pt') $k=1;
elseif ($unit=='mm') $k=72/25.4;
elseif ($unit=='cm') $k=72/2.54;
elseif ($unit=='in') $k=72;
// Make substitution
$substitutionarray=pdf_getSubstitutionArray($outputlangs);
complete_substitutions_array($substitutionarray,$outputlangs,$object);
$text=make_substitutions($text,$substitutionarray,$outputlangs);
$text=$outputlangs->convToOutputCharset($text);
$savx=$pdf->getX(); $savy=$pdf->getY();
$watermark_angle=atan($h/$w)/2;
@ -819,7 +850,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
*/
function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object,$showdetails=0,$hidefreetext=0)
{
global $conf,$user;
global $conf,$user,$mysoc;
$outputlangs->load("dict");
$line='';
@ -829,16 +860,15 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
// Line of free text
if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext))
{
// Make substitution
$substitutionarray=array(
'__FROM_NAME__' => $fromcompany->name,
'__FROM_EMAIL__' => $fromcompany->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
$substitutionarray=pdf_getSubstitutionArray($outputlangs);
// More substitution keys
$substitutionarray['__FROM_NAME__']=$fromcompany->name;
$substitutionarray['__FROM_EMAIL__']=$fromcompany->email;
$substitutionarray['__TOTAL_TTC__']=$object->total_ttc;
$substitutionarray['__TOTAL_HT__']=$object->total_ht;
$substitutionarray['__TOTAL_VAT__']=$object->total_vat;
complete_substitutions_array($substitutionarray,$outputlangs,$object);
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray,$outputlangs);
$line.=$outputlangs->convToOutputCharset($newfreetext);
}

View File

@ -1499,7 +1499,7 @@ class pdf_crabe extends ModelePDFFactures
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
// Show Draft Watermark
if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
if($object->statut==Facture::STATUS_DRAFT && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
{
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
}
@ -1553,7 +1553,13 @@ class pdf_crabe extends ModelePDFFactures
$posy+=5;
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
$textref=$outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref);
if ($object->statut == Facture::STATUS_DRAFT)
{
$pdf->SetTextColor(128,0,0);
$textref.=' - '.$outputlangs->trans("NotValidated");
}
$pdf->MultiCell($w, 4, $textref, '', 'R');
$posy+=1;
$pdf->SetFont('','', $default_font_size - 2);

View File

@ -98,6 +98,13 @@ class modCommande extends DolibarrModules
$this->const[$r][3] = "";
$this->const[$r][4] = 0;
/*$r++;
$this->const[$r][0] = "COMMANDE_DRAFT_WATERMARK";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "__(Draft)__";
$this->const[$r][3] = 'Watermark to show on draft orders';
$this->const[$r][4] = 0;*/
// Boxes
$this->boxes = array(
0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),

View File

@ -100,6 +100,13 @@ class modFacture extends DolibarrModules
$this->const[$r][4] = 0;
$r++;
/*$this->const[$r][0] = "FACTURE_DRAFT_WATERMARK";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "__(Draft)__";
$this->const[$r][3] = 'Watermark to show on draft invoices';
$this->const[$r][4] = 0;
$r++;*/
// Boxes
//$this->boxes = array(0=>array(1=>'box_factures_imp.php'),1=>array(1=>'box_factures.php'));

View File

@ -100,7 +100,14 @@ class modPropale extends DolibarrModules
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/proposals";
$this->const[$r][3] = "";
$this->const[$r][4] = 0;
$r++;
/*$this->const[$r][0] = "PROPALE_DRAFT_WATERMARK";
$this->const[$r][2] = "__(Draft)__";
$this->const[$r][3] = 'Watermark to show on draft proposals';
$this->const[$r][4] = 0;
$r++;*/
// Boxes
$this->boxes = array(
0=>array('file'=>'box_graph_propales_permonth.php','enabledbydefaulton'=>'Home'),

View File

@ -153,6 +153,7 @@ Edit=Edit
Validate=Validate
ValidateAndApprove=Validate and Approve
ToValidate=To validate
NotValidated=Not validated
Save=Save
SaveAs=Save As
TestConnection=Test connection

View File

@ -849,7 +849,7 @@ if (! defined('NOREQUIRETRAN'))
$bc=array(0=>'class="impair"',1=>'class="pair"');
$bcdd=array(0=>'class="drag drop oddeven"',1=>'class="drag drop oddeven"');
$bcnd=array(0=>'class="nodrag nodrop nohover"',1=>'class="nodrag nodrop nohoverpair"'); // Used for tr to add new lines
$bctag=array(0=>'class="tagtr"',1=>'class="pair tagtr"');
$bctag=array(0=>'class="impair tagtr"',1=>'class="pair tagtr"');
// Define messages variables
$mesg=''; $warning=''; $error=0;

View File

@ -2501,21 +2501,20 @@ div.pagination li.paginationafterarrows {
/* Set the color for hover lines */
.oddeven:hover, .odd:hover, .impair:hover, .even:hover, .pair:hover, .even:hover, .pair:hover,
table.dataTable tr.even:hover, table.dataTable tr.odd:hover
.oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover
{
<?php if ($colorbacklinepairhover) { ?>
background: rgb(<?php echo $colorbacklinepairhover; ?>) !important; /* Must be background to be stronger than background of odd or even */
<?php } ?>
}
.oddeven, .odd, .impair, .nohover .odd:hover, .nohover .impair:hover, tr.odd td.nohover, tr.impair td.nohover
.oddeven, .evenodd, .impair, .nohover .impair:hover, tr.impair td.nohover
{
font-family: <?php print $fontlist ?>;
margin-bottom: 1px;
color: #202020;
}
.odd, .impair, .nohover .odd:hover, .nohover .impair:hover, tr.odd td.nohover, tr.impair td.nohover
.impair, .nohover .impair:hover, tr.impair td.nohover
{
background: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?>;
}
@ -2523,16 +2522,16 @@ table.dataTable tr.even:hover, table.dataTable tr.odd:hover
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?>;
}
.oddeven, .even, .pair, .nohover .even:hover, .nohover .pair:hover, tr.even td.nohover, tr.pair td.nohover {
.oddeven, .evenodd, .pair, .nohover .pair:hover, tr.pair td.nohover {
font-family: <?php print $fontlist ?>;
margin-bottom: 1px;
color: #202020;
}
.even, .pair, .nohover .even:hover, .nohover .pair:hover, tr.even td.nohover, tr.pair td.nohover {
.pair, .nohover .pair:hover, tr.pair td.nohover {
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?>;
}
table.dataTable tr.odd, table.dataTable tr.oddeven {
table.dataTable tr.oddeven {
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?> !important;
}
@ -2541,7 +2540,7 @@ td.oddeven, table.nohover tr.impair, table.nohover tr.pair, table.nohover tr.imp
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?> !important;
background: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?> !important;
}
tr.nohoverpair td {
td.evenodd, tr.nohoverpair td {
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?> !important;
background: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?> !important;
}
@ -2550,17 +2549,17 @@ tr.nohoverpair td {
table.dataTable td {
padding: 5px 2px 5px 3px !important;
}
tr.even td, tr.pair td, tr.odd td, tr.impair td, form.odd div.tagtd, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd {
tr.pair td, tr.impair td, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd {
padding: 7px 2px 7px 3px;
border-bottom: 1px solid #ddd;
}
form.pair, form.impair {
font-weight: normal;
}
form.tagtr:last-of-type div.tagtd, tr.even:last-of-type td, tr.pair:last-of-type td, tr.odd:last-of-type td, tr.impair:last-of-type td {
form.tagtr:last-of-type div.tagtd, tr.pair:last-of-type td, tr.impair:last-of-type td {
border-bottom: 0px !important;
}
tr.even td .nobordernopadding tr td, tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td, tr.odd td .nobordernopadding tr td {
tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td {
border-bottom: 0px !important;
}
td.nobottom, td.nobottom {
@ -2620,6 +2619,7 @@ tr.liste_titre th, th.liste_titre, tr.liste_titre td, td.liste_titre, form.liste
font-family: <?php print $fontlist ?>;
font-weight: <?php echo $useboldtitle?'bold':'normal'; ?>;
vertical-align: middle;
height: 24px;
}
tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, form.liste_titre div a, div.liste_titre a {
text-shadow: none !important;

View File

@ -2596,21 +2596,21 @@ div.pagination li.paginationafterarrows {
*/
/* Set the color for hover lines */
.oddeven:hover, .odd:hover, .impair:hover, .even:hover, .pair:hover, .even:hover, .pair:hover, table.dataTable tr.even:hover, table.dataTable tr.odd:hover
.oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover
{
<?php if ($colorbacklinepairhover) { ?>
background: rgb(<?php echo $colorbacklinepairhover; ?>) !important;
<?php } ?>
}
.oddeven, .odd, .impair, .nohover .odd:hover, .nohover .impair:hover, tr.odd td.nohover, tr.impair td.nohover
.oddeven, .evenodd, .impair, .nohover .impair:hover, tr.impair td.nohover
{
font-family: <?php print $fontlist ?>;
border: 0px;
margin-bottom: 1px;
color: #202020;
}
.odd, .impair, .nohover .odd:hover, .nohover .impair:hover, tr.odd td.nohover, tr.impair td.nohover
.impair, .nohover .impair:hover, tr.impair td.nohover
{
background: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?>;
}
@ -2618,15 +2618,15 @@ div.pagination li.paginationafterarrows {
background: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?>;
}
.oddeven, .even, .pair, .nohover .even:hover, .nohover .pair:hover, tr.even td.nohover, tr.pair td.nohover {
.oddeven, .evenodd, .pair, .nohover .pair:hover, tr.pair td.nohover {
font-family: <?php print $fontlist ?>;
margin-bottom: 1px;
color: #202020;
}
.even, .pair, .nohover .even:hover, .nohover .pair:hover, tr.even td.nohover, tr.pair td.nohover {
.pair, .nohover .pair:hover, tr.pair td.nohover {
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?>;
}
table.dataTable tr.odd, table.dataTable tr.oddeven {
table.dataTable tr.oddeven {
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?> !important;
}
@ -2635,7 +2635,7 @@ td.oddeven, table.nohover tr.impair, table.nohover tr.pair, table.nohover tr.imp
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?> !important;
background: #<?php echo colorArrayToHex(colorStringToArray($colorbacklineimpair1)); ?> !important;
}
tr.nohoverpair td {
td.evenodd, tr.nohoverpair td {
background-color: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?> !important;
background: #<?php echo colorArrayToHex(colorStringToArray($colorbacklinepair1)); ?> !important;
}
@ -2643,17 +2643,17 @@ tr.nohoverpair td {
table.dataTable td {
padding: 5px 2px 5px 3px !important;
}
tr.even td, tr.pair td, tr.odd td, tr.impair td, form.odd div.tagtd, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd {
tr.pair td, tr.impair td, form.impair div.tagtd, form.pair div.tagtd, div.impair div.tagtd, div.pair div.tagtd, div.liste_titre div.tagtd {
padding: 5px 2px 5px 3px;
border-bottom: 1px solid #eee;
}
form.pair, form.impair {
font-weight: normal;
}
tr.even:last-of-type td, tr.pair:last-of-type td, tr.odd:last-of-type td, tr.impair:last-of-type td {
tr.pair:last-of-type td, tr.impair:last-of-type td {
border-bottom: 0px !important;
}
tr.even td .nobordernopadding tr td, tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td, tr.odd td .nobordernopadding tr td {
tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td {
border-bottom: 0px !important;
}
td.nobottom, td.nobottom {
@ -2726,6 +2726,7 @@ tr.liste_titre th, th.liste_titre, tr.liste_titre td, td.liste_titre, form.liste
font-family: <?php print $fontlist ?>;
font-weight: <?php echo $useboldtitle?'bold':'normal'; ?>;
vertical-align: middle;
height: 24px;
}
tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, form.liste_titre div a, div.liste_titre a {
text-shadow: none !important;