Fix: uniformize substitution tags

This commit is contained in:
Regis Houssin 2017-10-09 16:33:22 +02:00
parent 86c301f197
commit e2206d9bf2
5 changed files with 84 additions and 84 deletions

View File

@ -240,9 +240,9 @@ $constantes=array(
print load_fiche_titre($langs->trans("MembersCards"),'','');
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, ';
$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, ';
$helptext.='%YEAR%, %MONTH%, %DAY%';
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext.='__YEAR__, __MONTH__, __DAY__';
form_constantes($constantes, 0, $helptext);
@ -257,9 +257,9 @@ $constantes=array('ADHERENT_ETIQUETTE_TYPE','ADHERENT_ETIQUETTE_TEXT');
print load_fiche_titre($langs->trans("MembersTickets"),'','');
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, ';
$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, ';
$helptext.='%YEAR%, %MONTH%, %DAY%';
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext.='__YEAR__, __MONTH__, __DAY__';
form_constantes($constantes, 0, $helptext);

View File

@ -171,14 +171,14 @@ $constantes=array(
);
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, ';
$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, ';
$helptext.='%YEAR%, %MONTH%, %DAY%';
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
$helptext.='__YEAR__, __MONTH__, __DAY__';
$helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
$helptext.='%DOL_MAIN_URL_ROOT%, %ID%, %FIRSTNAME%, %LASTNAME%, %FULLNAME%, %LOGIN%, %PASSWORD%, ';
$helptext.='%COMPANY%, %ADDRESS%, %ZIP%, %TOWN%, %COUNTRY%, %EMAIL%, %BIRTH%, %PHOTO%, %TYPE%, ';
//$helptext.='%YEAR%, %MONTH%, %DAY%'; // Not supported
$helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
$helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
//$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported
form_constantes($constantes, 0, $helptext);

View File

@ -116,25 +116,25 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
// List of values to scan for a replacement
$substitutionarray = array (
'%ID%'=>$objp->rowid,
'%LOGIN%'=>$objp->login,
'%FIRSTNAME%'=>$objp->firstname,
'%LASTNAME%'=>$objp->lastname,
'%FULLNAME%'=>$adherentstatic->getFullName($langs),
'%COMPANY%'=>$objp->company,
'%ADDRESS%'=>$objp->address,
'%ZIP%'=>$objp->zip,
'%TOWN%'=>$objp->town,
'%COUNTRY%'=>$objp->country,
'%COUNTRY_CODE%'=>$objp->country_code,
'%EMAIL%'=>$objp->email,
'%BIRTH%'=>dol_print_date($objp->birth,'day'),
'%TYPE%'=>$objp->type,
'%YEAR%'=>$year,
'%MONTH%'=>$month,
'%DAY%'=>$day,
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
'__ID__'=>$objp->rowid,
'__LOGIN__'=>$objp->login,
'__FIRSTNAME__'=>$objp->firstname,
'__LASTNAME__'=>$objp->lastname,
'__FULLNAME__'=>$adherentstatic->getFullName($langs),
'__COMPANY__'=>$objp->company,
'__ADDRESS__'=>$objp->address,
'__ZIP__'=>$objp->zip,
'__TOWN__'=>$objp->town,
'__COUNTRY__'=>$objp->country,
'__COUNTRY_CODE__'=>$objp->country_code,
'__EMAIL__'=>$objp->email,
'__BIRTH__'=>dol_print_date($objp->birth,'day'),
'__TYPE__'=>$objp->type,
'__YEAR__'=>$year,
'__MONTH__'=>$month,
'__DAY__'=>$day,
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
'__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
);
complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
@ -179,7 +179,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
// For labels
if ($mode == 'label')
{
if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="%FULLNAME%\n%ADDRESS%\n%ZIP% %TOWN%\n%COUNTRY%";
if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
$textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
$textheader='';
$textfooter='';

View File

@ -48,8 +48,8 @@ class pdf_standard extends CommonStickerGenerator
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
* - %LOGO% is replace with company logo
* - %PHOTO% is replace with photo provided as parameter
* - __LOGO__ is replace with company logo
* - __PHOTO__ is replace with photo provided as parameter
*
* @param PDF $pdf PDF
* @param string $textleft Text left
@ -58,7 +58,7 @@ class pdf_standard extends CommonStickerGenerator
* @param Translate $outputlangs Output langs
* @param string $textright Text right
* @param int $idmember Id member
* @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
* @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text)
* @return void
*/
function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='')
@ -95,7 +95,7 @@ class pdf_standard extends CommonStickerGenerator
$member=new Adherent($db);
$member->id = $idmember;
$member->ref = $idmember;
// Define photo
$dir=$conf->adherent->dir_output;
if (! empty($photo))
@ -161,8 +161,8 @@ class pdf_standard extends CommonStickerGenerator
if ($textright=='') // Only a left part
{
// Output left area
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else
{
$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
@ -171,17 +171,17 @@ class pdf_standard extends CommonStickerGenerator
}
else if ($textleft!='' && $textright!='') //
{
if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
if ($textleft == '__LOGO__' || $textleft == '__PHOTO__')
{
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
}
else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
else if ($textright == '__LOGO__' || $textright == '__PHOTO__')
{
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
}
@ -196,8 +196,8 @@ class pdf_standard extends CommonStickerGenerator
else // Only a right part
{
// Output right area
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
else
{
$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
@ -247,34 +247,34 @@ class pdf_standard extends CommonStickerGenerator
function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0)
{
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
$this->code=$srctemplatepath;
if (is_object($object))
{
if ($object->country == '-') $object->country='';
// List of values to scan for a replacement
$substitutionarray = array (
'%ID%'=>$object->rowid,
'%LOGIN%'=>$object->login,
'%FIRSTNAME%'=>$object->firstname,
'%LASTNAME%'=>$object->lastname,
'%FULLNAME%'=>$object->getFullName($langs),
'%COMPANY%'=>$object->company,
'%ADDRESS%'=>$object->address,
'%ZIP%'=>$object->zip,
'%TOWN%'=>$object->town,
'%COUNTRY%'=>$object->country,
'%COUNTRY_CODE%'=>$object->country_code,
'%EMAIL%'=>$object->email,
'%BIRTH%'=>dol_print_date($object->birth,'day'),
'%TYPE%'=>$object->type,
'%YEAR%'=>$year,
'%MONTH%'=>$month,
'%DAY%'=>$day,
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
'__ID__'=>$object->rowid,
'__LOGIN__'=>$object->login,
'__FIRSTNAME__'=>$object->firstname,
'__LASTNAME__'=>$object->lastname,
'__FULLNAME__'=>$object->getFullName($langs),
'__COMPANY__'=>$object->company,
'__ADDRESS__'=>$object->address,
'__ZIP__'=>$object->zip,
'__TOWN__'=>$object->town,
'__COUNTRY__'=>$object->country,
'__COUNTRY_CODE__'=>$object->country_code,
'__EMAIL__'=>$object->email,
'__BIRTH__'=>dol_print_date($object->birth,'day'),
'__TYPE__'=>$object->type,
'__YEAR__'=>$year,
'__MONTH__'=>$month,
'__DAY__'=>$day,
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
'__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
);
complete_substitutions_array($substitutionarray, $langs);
@ -283,10 +283,10 @@ class pdf_standard extends CommonStickerGenerator
$textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
$textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
$textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
$nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY'];
if ($nb <= 0) $nb=1; // Protection to avoid empty page
for($j=0;$j<$nb;$j++)
{
$arrayofmembers[]=array(
@ -298,7 +298,7 @@ class pdf_standard extends CommonStickerGenerator
'photo'=>$object->photo
);
}
$arrayofrecords = $arrayofmembers;
}
else
@ -348,7 +348,7 @@ class pdf_standard extends CommonStickerGenerator
$dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');
$file = $dir.'/'.$filename;
}
else
else
{
$outputdir = $conf->adherent->dir_temp;
$dir = $outputdir;
@ -419,28 +419,28 @@ class pdf_standard extends CommonStickerGenerator
$this->result = array('fullpath'=>$file);
// Output to http stream
if (empty($nooutput))
{
clearstatcache();
$attachment=true;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
$type=dol_mimetype($filename);
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
readfile($file);
}
return 1;
}

View File

@ -93,7 +93,7 @@ class modAdherent extends DolibarrModules
$this->const[$r][0] = "ADHERENT_MAIL_VALID";
$this->const[$r][1] = "texte";
$this->const[$r][2] = "Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n%INFOS%\r\n\r\n";
$this->const[$r][2] = "Votre adhésion vient d'être validée. \r\nVoici le rappel de vos coordonnées (toute information erronée entrainera la non validation de votre inscription) :\r\n\r\n__INFOS__\r\n\r\n";
$this->const[$r][3] = "Mail de validation";
$this->const[$r][4] = 0;
$r++;
@ -121,7 +121,7 @@ class modAdherent extends DolibarrModules
$this->const[$r][0] = "ADHERENT_MAIL_COTIS";
$this->const[$r][1] = "texte";
$this->const[$r][2] = "Bonjour %FIRSTNAME%,\r\nCet email confirme que votre cotisation a été reçue\r\net enregistrée";
$this->const[$r][2] = "Bonjour __FIRSTNAME__,\r\nCet email confirme que votre cotisation a été reçue\r\net enregistrée";
$this->const[$r][3] = "Mail de validation de cotisation";
$this->const[$r][4] = 0;
$r++;
@ -135,21 +135,21 @@ class modAdherent extends DolibarrModules
$this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "%YEAR%";
$this->const[$r][2] = "__YEAR__";
$this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent";
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "%COMPANY%";
$this->const[$r][2] = "__COMPANY__";
$this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent";
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ADHERENT_CARD_TEXT";
$this->const[$r][1] = "texte";
$this->const[$r][2] = "%FULLNAME%\r\nID: %ID%\r\n%EMAIL%\r\n%ADDRESS%\r\n%ZIP% %TOWN%\r\n%COUNTRY%";
$this->const[$r][2] = "__FULLNAME__\r\nID: __ID__\r\n__EMAIL__\r\n__ADDRESS__\r\n__ZIP__ __TOWN__\r\n__COUNTRY__";
$this->const[$r][3] = "Text to print on member cards";
$this->const[$r][4] = 0;
$r++;
@ -184,7 +184,7 @@ class modAdherent extends DolibarrModules
$this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT";
$this->const[$r][1] = "texte";
$this->const[$r][2] = "%FULLNAME%\n%ADDRESS%\n%ZIP% %TOWN%\n%COUNTRY%";
$this->const[$r][2] = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY%";
$this->const[$r][3] = "Text to print on member address sheets";
$this->const[$r][4] = 0;
$r++;
@ -324,7 +324,7 @@ class modAdherent extends DolibarrModules
// End add extra fields
$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_regex_array[$r]=array('a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)','a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
$this->import_examplevalues_array[$r]=array('a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m-%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
$this->import_examplevalues_array[$r]=array('a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1','a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1','a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d'));
}