Qual: Make code more generic
This commit is contained in:
parent
b150e03b06
commit
cb52af4f47
@ -107,8 +107,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg
|
|||||||
'%MONTH%'=>$month,
|
'%MONTH%'=>$month,
|
||||||
'%DAY%'=>$day,
|
'%DAY%'=>$day,
|
||||||
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
|
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
|
||||||
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/",
|
'%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||||
'%SOCIETE%'=>$objp->company
|
|
||||||
);
|
);
|
||||||
complete_substitutions_array($substitutionarray, $langs);
|
complete_substitutions_array($substitutionarray, $langs);
|
||||||
|
|
||||||
|
|||||||
@ -122,10 +122,10 @@ class pdf_standard
|
|||||||
* @param Translate $outputlangs Output langs
|
* @param Translate $outputlangs Output langs
|
||||||
* @param string $textright Text right
|
* @param string $textright Text right
|
||||||
* @param int $idmember Id member
|
* @param int $idmember Id member
|
||||||
* @param string $photomember Photo member
|
* @param string $photo Photo member
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photomember='')
|
function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='')
|
||||||
{
|
{
|
||||||
global $mysoc,$conf,$langs;
|
global $mysoc,$conf,$langs;
|
||||||
|
|
||||||
@ -154,9 +154,9 @@ class pdf_standard
|
|||||||
|
|
||||||
// Define photo
|
// Define photo
|
||||||
$dir=$conf->adherent->dir_output;
|
$dir=$conf->adherent->dir_output;
|
||||||
$file=get_exdir($idmember,2).'photos/'.$photomember;
|
$file=get_exdir($idmember,2).'photos/'.$photo;
|
||||||
$photo=$dir.'/'.$file;
|
$photo=$dir.'/'.$file;
|
||||||
if (empty($photomember) || ! is_readable($photo)) $photo='';
|
if (empty($photo) || ! is_readable($photo)) $photo='';
|
||||||
|
|
||||||
// Define background image
|
// Define background image
|
||||||
$backgroundimage='';
|
$backgroundimage='';
|
||||||
@ -408,12 +408,13 @@ class pdf_standard
|
|||||||
/**
|
/**
|
||||||
* Function to build PDF on disk, then output on HTTP strem.
|
* Function to build PDF on disk, then output on HTTP strem.
|
||||||
*
|
*
|
||||||
* @param array $arrayofmembers Array of members informations
|
* @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>)
|
||||||
* @param Translate $outputlangs Lang object for output language
|
* @param Translate $outputlangs Lang object for output language
|
||||||
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
||||||
|
* @param string $mode Tell if doc module is called for 'member, ...
|
||||||
* @return int 1=OK, 0=KO
|
* @return int 1=OK, 0=KO
|
||||||
*/
|
*/
|
||||||
function write_file($arrayofmembers,$outputlangs,$srctemplatepath)
|
function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$mode='member')
|
||||||
{
|
{
|
||||||
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
|
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
|
||||||
|
|
||||||
@ -433,8 +434,19 @@ class pdf_standard
|
|||||||
$outputlangs->load("members");
|
$outputlangs->load("members");
|
||||||
$outputlangs->load("admin");
|
$outputlangs->load("admin");
|
||||||
|
|
||||||
|
if (empty($mode) || $mode == 'member')
|
||||||
|
{
|
||||||
|
$title=$outputlangs->transnoentities('MembersCards');
|
||||||
|
$keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
|
||||||
|
$outputdir=$conf->adherent->dir_temp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error('','Bad value for $mode');
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
|
$dir = $outputdir;
|
||||||
$filename = 'tmp_cards.pdf';
|
$filename = 'tmp_cards.pdf';
|
||||||
$file = $dir."/".$filename;
|
$file = $dir."/".$filename;
|
||||||
|
|
||||||
@ -456,11 +468,11 @@ class pdf_standard
|
|||||||
}
|
}
|
||||||
$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
||||||
|
|
||||||
$pdf->SetTitle($outputlangs->transnoentities('MembersCards'));
|
$pdf->SetTitle($title);
|
||||||
$pdf->SetSubject($outputlangs->transnoentities("MembersCards"));
|
$pdf->SetSubject($title);
|
||||||
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
|
||||||
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
|
||||||
$pdf->SetKeyWords($outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name));
|
$pdf->SetKeyWords($keywords);
|
||||||
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||||
|
|
||||||
$pdf->SetMargins(0,0);
|
$pdf->SetMargins(0,0);
|
||||||
@ -482,7 +494,7 @@ class pdf_standard
|
|||||||
|
|
||||||
|
|
||||||
// Add each record
|
// Add each record
|
||||||
foreach($arrayofmembers as $val)
|
foreach($arrayofrecords as $val)
|
||||||
{
|
{
|
||||||
// imprime le texte specifique sur la carte
|
// imprime le texte specifique sur la carte
|
||||||
$this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']);
|
$this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']);
|
||||||
@ -499,7 +511,6 @@ class pdf_standard
|
|||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Output to http stream
|
// Output to http stream
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user