--- /tmp/dsg/dolibarr/htdocs/core/modules/member/doc/github_19.0.3_pdf_standard.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/member/doc/client_pdf_standard.class.php
@@ -36,26 +35,0 @@
-	/**

-	 * Dolibarr version of the loaded document

-	 * @var string

-	 */

-	public $version = 'dolibarr';

-

-

-	/**

-	 *	Constructor

-	 *

-	 *  @param		DoliDB		$db      Database handler

-	 */

-	public function __construct($db)

-	{

-		global $conf, $langs, $mysoc;

-

-		// Translations

-		$langs->loadLangs(array("main", "admin"));

-

-		$this->db = $db;

-		$this->name = "standard";

-		$this->description = $langs->trans('TemplateforBusinessCards');

-		//$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template

-

-		$this->type = 'pdf-various-sizes';

-	}

@@ -66 +40 @@
-	 * @param	TCPDF		$pdf			PDF reference

+	 * @param	PDF			$pdf			PDF reference

@@ -71,2 +45,2 @@
-	public function addSticker(&$pdf, $outputlangs, $param)

-	{

+    public function addSticker(&$pdf, $outputlangs, $param)

+    {

@@ -76 +50 @@
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

@@ -82 +56 @@
-	 * @param	 TCPDF		$pdf			PDF

+	 * @param	 PDF		$pdf			PDF

@@ -94 +68 @@
-		// phpcs:enable

+        // phpcs:enable

@@ -111 +85,2 @@
-		if (!is_readable($logo)) {

+		if (!is_readable($logo))

+		{

@@ -113 +88,2 @@
-			if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {

+			if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))

+			{

@@ -115 +91,3 @@
-			} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {

+			}

+			elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))

+			{

@@ -126 +104,2 @@
-		if (!empty($photo)) {

+		if (!empty($photo))

+		{

@@ -129,3 +108 @@
-			if (!is_readable($photo)) {

-				$photo = '';

-			}

+			if (!is_readable($photo)) $photo = '';

@@ -136,2 +113,3 @@
-		if (getDolGlobalString('ADHERENT_CARD_BACKGROUND') && file_exists($conf->adherent->dir_output.'/' . getDolGlobalString('ADHERENT_CARD_BACKGROUND'))) {

-			$backgroundimage = $conf->adherent->dir_output.'/' . getDolGlobalString('ADHERENT_CARD_BACKGROUND');

+		if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND))

+		{

+			$backgroundimage = $conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND;

@@ -141 +119,2 @@
-		if ($this->code == "CARD") {

+		if ($this->code == "CARD")

+		{

@@ -148 +127,2 @@
-		if ($backgroundimage) {

+		if ($backgroundimage)

+		{

@@ -152,2 +132 @@
-		$xleft = 2;

-		$ytop = 2;

+		$xleft = 2; $ytop = 2;

@@ -156,2 +135,4 @@
-		if ($header != '') {

-			if ($this->code == "CARD") {

+		if ($header != '')

+		{

+			if ($this->code == "CARD")

+			{

@@ -170,2 +151 @@
-		$maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth);

-		$maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight);

+		$maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight);

@@ -173,2 +153 @@
-		$widthtouse = $maxwidthtouse;

-		$heighttouse = 0; // old value for image

+		$widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image

@@ -176 +155,2 @@
-		if (isset($tmp['height'])) {

+		if ($tmp['height'])

+		{

@@ -178,7 +158,2 @@
-			if ($imgratio >= $defaultratio) {

-				$widthtouse = $maxwidthtouse;

-				$heighttouse = round($widthtouse / $imgratio);

-			} else {

-				$heighttouse = $maxheighttouse;

-				$widthtouse = round($heighttouse * $imgratio);

-			}

+			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }

+			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }

@@ -189 +164,2 @@
-		if ($textright == '') {	// Only a left part

+		if ($textright == '')	// Only a left part

+		{

@@ -191,5 +167,4 @@
-			if ($textleft == '__LOGO__' && $logo) {

-				$pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-			} elseif ($textleft == '__PHOTO__' && $photo) {

-				$pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-			} else {

+			if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

+			elseif ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

+			else

+			{

@@ -199,7 +174,7 @@
-		} elseif ($textleft != '' && $textright != '') {	//

-			if ($textleft == '__LOGO__' || $textleft == '__PHOTO__') {

-				if ($textleft == '__LOGO__' && $logo) {

-					$pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-				} elseif ($textleft == '__PHOTO__' && $photo) {

-					$pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-				}

+		}

+		elseif ($textleft != '' && $textright != '')	//

+		{

+			if ($textleft == '__LOGO__' || $textleft == '__PHOTO__')

+			{

+				if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

+				elseif ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

@@ -208,6 +183,5 @@
-			} elseif ($textright == '__LOGO__' || $textright == '__PHOTO__') {

-				if ($textright == '__LOGO__' && $logo) {

-					$pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-				} elseif ($textright == '__PHOTO__' && $photo) {

-					$pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-				}

+			}

+			elseif ($textright == '__LOGO__' || $textright == '__PHOTO__')

+			{

+				if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

+				elseif ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

@@ -216 +190,3 @@
-			} else { // text on halft left and text on half right

+			}

+			else	// text on halft left and text on half right

+			{

@@ -222 +198,3 @@
-		} else { // Only a right part

+		}

+		else	// Only a right part

+		{

@@ -224,5 +202,4 @@
-			if ($textright == '__LOGO__' && $logo) {

-				$pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-			} elseif ($textright == '__PHOTO__' && $photo) {

-				$pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

-			} else {

+			if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

+			elseif ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);

+			else

+			{

@@ -235,2 +212,4 @@
-		if ($footer != '') {

-			if ($this->code == "CARD") {

+		if ($footer != '')

+		{

+			if ($this->code == "CARD")

+			{

@@ -261 +240 @@
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

@@ -270 +248,0 @@
-	 *  @param	string		$filename			Name of output file (without extension)

@@ -273 +251 @@
-	public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0, $filename = 'tmp_cards')

+	public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0)

@@ -275 +253 @@
-		// phpcs:enable

+        // phpcs:enable

@@ -280,62 +258,57 @@
-		if (is_object($object)) {

-			if ($object->country == '-') {

-				$object->country = '';

-			}

-

-			$now = dol_now();

-			$year = dol_print_date($now, '%Y');

-			$month = dol_print_date($now, '%m');

-			$day = dol_print_date($now, '%d');

-

-			// List of values to scan for a replacement

-			$substitutionarray = array(

-				'__ID__' => $object->id,

-				'__REF__' => $object->ref,

-				'__LOGIN__' => empty($object->login) ? '' : $object->login,

-				'__FIRSTNAME__' => empty($object->firstname) ? '' : $object->firstname,

-				'__LASTNAME__' => empty($object->lastname) ? '' : $object->lastname,

-				'__FULLNAME__' => $object->getFullName($langs),

-				'__COMPANY__' => empty($object->company) ? '' : $object->company,

-				'__ADDRESS__' => empty($object->address) ? '' : $object->address,

-				'__ZIP__' => empty($object->zip) ? '' : $object->zip,

-				'__TOWN__' => empty($object->town) ? '' : $object->town,

-				'__COUNTRY__' => empty($object->country) ? '' : $object->country,

-				'__COUNTRY_CODE__' => empty($object->country_code) ? '' : $object->country_code,

-				'__EMAIL__' => empty($object->email) ? '' : $object->email,

-				'__BIRTH__' => dol_print_date($object->birth, 'day'),

-				'__TYPE__' => empty($object->type) ? '' : $object->type,

-				'__YEAR__' => $year,

-				'__MONTH__' => $month,

-				'__DAY__' => $day,

-				'__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT,

-				'__SERVER__' => "https://".$_SERVER["SERVER_NAME"]."/"

-			);

-			complete_substitutions_array($substitutionarray, $langs);

-

-			// For business cards

-			$textleft = make_substitutions(getDolGlobalString("ADHERENT_CARD_TEXT"), $substitutionarray);

-			$textheader = make_substitutions(getDolGlobalString("ADHERENT_CARD_HEADER_TEXT"), $substitutionarray);

-			$textfooter = make_substitutions(getDolGlobalString("ADHERENT_CARD_FOOTER_TEXT"), $substitutionarray);

-			$textright = make_substitutions(getDolGlobalString("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(

-					'textleft'=>$textleft,

-					'textheader'=>$textheader,

-					'textfooter'=>$textfooter,

-					'textright'=>$textright,

-					'id'=>(isset($object->id) ? $object->id : ""),

-					'photo'=>(isset($object->photo) ? $object->photo : "")

-				);

-			}

-

-			$arrayofrecords = $arrayofmembers;

-		} else {

-			// Old usage

-			$arrayofrecords = $object;

-		}

+		if (is_object($object))

+		{

+		    if ($object->country == '-') $object->country = '';

+

+    		// List of values to scan for a replacement

+    		$substitutionarray = array(

+    		    '__ID__' => $object->id,

+    		    '__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);

+

+    		// For business cards

+		    $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);

+		    $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(

+	                'textleft'=>$textleft,

+	                'textheader'=>$textheader,

+	                'textfooter'=>$textfooter,

+	                'textright'=>$textright,

+	                'id'=>$object->rowid,

+	                'photo'=>$object->photo

+	            );

+	        }

+

+    		$arrayofrecords = $arrayofmembers;

+		}

+		else

+		{

+		    $arrayofrecords = $object;

+		}

+

+		//var_dump($arrayofrecords);exit;

@@ -344,5 +317 @@
-		if (empty($this->Tformat)) {

-			dol_print_error('', 'ErrorBadTypeForCard'.$this->code);

-			exit;

-		}

-

+		if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; }

@@ -350,14 +319,10 @@
-		$filename .= '.pdf';

-

-		// standard format or custom

-		if ($this->Tformat['paper-size'] != 'custom') {

-			$this->format = $this->Tformat['paper-size'];

-		} else {

-			//custom

-			$resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);

-			$this->format = $resolution;

-		}

-

-		if (!is_object($outputlangs)) {

-			$outputlangs = $langs;

-		}

+        // standard format or custom

+        if ($this->Tformat['paper-size'] != 'custom') {

+            $this->format = $this->Tformat['paper-size'];

+        } else {

+            //custom

+            $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);

+            $this->format = $resolution;

+        }

+

+		if (!is_object($outputlangs)) $outputlangs = $langs;

@@ -365,3 +330 @@
-		if (getDolGlobalString('MAIN_USE_FPDF')) {

-			$outputlangs->charset_output = 'ISO-8859-1';

-		}

+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';

@@ -372 +335,2 @@
-		if (empty($mode) || $mode == 'member') {

+		if (empty($mode) || $mode == 'member')

+		{

@@ -375 +339,3 @@
-		} else {

+		}

+		else

+		{

@@ -380,9 +346,12 @@
-

-		if (is_object($object)) {

-			$outputdir = $conf->adherent->dir_output;

-			$dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');

-			$file = $dir.'/'.$filename;

-		} else {

-			$outputdir = $conf->adherent->dir_temp;

-			$dir = $outputdir;

-			$file = $dir.'/'.$filename;

+		$filename = 'tmp_cards.pdf';

+		if (is_object($object))

+		{

+		    $outputdir = $conf->adherent->dir_output;

+		    $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');

+		    $file = $dir.'/'.$filename;

+		}

+		else

+		{

+		    $outputdir = $conf->adherent->dir_temp;

+		    $dir = $outputdir;

+		    $file = $dir.'/'.$filename;

@@ -393,2 +362,4 @@
-		if (!file_exists($dir)) {

-			if (dol_mkdir($dir) < 0) {

+		if (!file_exists($dir))

+		{

+			if (dol_mkdir($dir) < 0)

+			{

@@ -402 +373,2 @@
-		if (class_exists('TCPDF')) {

+		if (class_exists('TCPDF'))

+		{

@@ -413,3 +385 @@
-		if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {

-			$pdf->SetCompression(false);

-		}

+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);

@@ -424,10 +394,2 @@
-		if ($posX > 0) {

-			$posX--;

-		} else {

-			$posX = 0;

-		}

-		if ($posY > 0) {

-			$posY--;

-		} else {

-			$posY = 0;

-		}

+		if ($posX > 0) $posX--; else $posX = 0;

+		if ($posY > 0) $posY--; else $posY = 0;

@@ -444 +406,2 @@
-		foreach ($arrayofrecords as $val) {

+		foreach ($arrayofrecords as $val)

+		{

@@ -456 +419,3 @@
-		dolChmod($file);

+		if (!empty($conf->global->MAIN_UMASK))

+			@chmod($file, octdec($conf->global->MAIN_UMASK));

+

@@ -461,24 +426,18 @@
-		if (empty($nooutput)) {

-			clearstatcache();

-

-			$attachment = true;

-			if (getDolGlobalString('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);

+		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);