Do not show on the first page

Hi @ all
Is it possible to change this code so that it is only executed from the 2nd page - as an example of offers

		$pdf->SetFont('', 'B', $default_font_size + 3);
		$pdf->SetXY($posx, $posy);
		$pdf->SetTextColor(0, 0, 60);
		$title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
		$pdf->MultiCell($w, 4, $title, '', 'R');

		$pdf->SetFont('', 'B', $default_font_size);

		$posy += 5;
		$pdf->SetXY($posx, $posy);
		$pdf->SetTextColor(0, 0, 60);
		$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
		if ($object->statut == $object::STATUS_DRAFT) {
			$pdf->SetTextColor(128, 0, 0);
			$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
		}
		$pdf->MultiCell($w, 4, $textref, '', 'R');

		$posy += 1;
		$pdf->SetFont('', '', $default_font_size - 2);

		if ($object->ref_client) {
			$posy += 4;
			$pdf->SetXY($posx, $posy);
			$pdf->SetTextColor(0, 0, 60);
			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
		}

		if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
			$object->fetch_projet();
			if (!empty($object->project->ref)) {
				$posy += 3;
				$pdf->SetXY($posx, $posy);
				$pdf->SetTextColor(0, 0, 60);
				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
			}
		}

		if (!empty($conf->global->PDF_SHOW_PROJECT)) {
			$object->fetch_projet();
			if (!empty($object->project->ref)) {
				$outputlangs->load("projects");
				$posy += 3;
				$pdf->SetXY($posx, $posy);
				$pdf->SetTextColor(0, 0, 60);
				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
			}
		}

I mean, what is indicated by the code in the PDF document should be visible from the 2nd page.

Thanks for your help

greetings Aba

I’ve tried it like this

$pdf->page_script ('
if ($PAGE_NUM != 1) {
    $current_page = $PAGE_NUM;

		$pdf->SetFont("", "B", $default_font_size + 3);
		$pdf->SetXY($posx, $posy);
		$pdf->SetTextColor(0, 0, 60);
		$title = $outputlangs->transnoentities("PdfCommercialProposalTitle");
		$pdf->MultiCell($w, 4, $title, "", "R");

		$pdf->SetFont("", "B", $default_font_size);

		$posy += 5;
		$pdf->SetXY($posx, $posy);
		$pdf->SetTextColor(0, 0, 60);
		$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
		if ($object->statut == $object::STATUS_DRAFT) {
			$pdf->SetTextColor(128, 0, 0);
			$textref .= " - ".$outputlangs->transnoentities("NotValidated");
		}
		$pdf->MultiCell($w, 4, $textref, "", "R");

		$posy += 1;
		$pdf->SetFont("", "", $default_font_size - 2);

		if ($object->ref_client) {
			$posy += 4;
			$pdf->SetXY($posx, $posy);
			$pdf->SetTextColor(0, 0, 60);
			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), "", "R");
		}

		if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
			$object->fetch_projet();
			if (!empty($object->project->ref)) {
				$posy += 3;
				$pdf->SetXY($posx, $posy);
				$pdf->SetTextColor(0, 0, 60);
				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? "" : $object->project->title), "", "R");
			}
		}

		if (!empty($conf->global->PDF_SHOW_PROJECT)) {
			$object->fetch_projet();
			if (!empty($object->project->ref)) {
				$outputlangs->load("projects");
				$posy += 3;
				$pdf->SetXY($posx, $posy);
				$pdf->SetTextColor(0, 0, 60);
				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? "" : $object->project->ref), "", "R");
			}
		}

		$posy += 4;
		$pdf->SetXY($posx, $posy);
		$pdf->SetTextColor(0, 0, 60);
		$pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), "", "R");

		$posy += 4;
		$pdf->SetXY($posx, $posy);
		$pdf->SetTextColor(0, 0, 60);

		$title = $outputlangs->transnoentities("DateEndPropal");
		if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
			$title .= " - ".$outputlangsbis->transnoentities("DateEndPropal");
		}
		$pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), "", "R");

		if ($object->thirdparty->code_client) {
			$posy += 4;
			$pdf->SetXY($posx, $posy);
			$pdf->SetTextColor(0, 0, 60);
			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), "", "R");
		}

		//Get contact
		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
		{
			$arrayidcontact = $object->getIdContact("internal", "SALESREPFOLL");
			if (count($arrayidcontact) > 0)
			{
				$usertmp = new User($this->db);
				$usertmp->fetch($arrayidcontact[0]);
				$posy += 4;
				$pdf->SetXY($posx, $posy);
				$pdf->SetTextColor(0, 0, 60);
				$pdf->MultiCell($w, 3, $langs->transnoentities("CreatedBy")." : ".$usertmp->getFullName($langs), "", "R");
			}
		}
	}
');

unfortunately I get an error message that I do not understand.


Fatal error: Uncaught Error: Call to undefined method TCPDI::page_script() in ..\htdocs\doli\htdocs\core\modules\propale\doc\pdf_RausBau.modules.php:1637 Stack trace: #0 ..\doli\htdocs\core\modules\propale\doc\pdf_RausBau.modules.php(382): pdf_RausBau->_pagehead(Object(TCPDI), Object(Propal), 1, Object(Translate), NULL) #1 ..\doli\htdocs\core\class\commonobject.class.php(5198): pdf_RausBau->write_file(Object(Propal), Object(Translate), '', 0, 0, 0, NULL) #2..\doli\htdocs\comm\propal\class\propal.class.php(3714): CommonObject->commonGenerateDocument('core/modules/pr...', 'RausBau', Object(Translate), 0, 0, 0, NULL) #3 ..\doli\htdocs\core\actions_builddoc.inc.php(97): Propal->generateDocument('RausBau', Object(Translate), 0, 0, 0, NULL) #4 ..\doli\htdocs\comm\propal\card.php(1430): include('x:\\xxxxx\\xxxx..') #5 {main} thrown in ..\doli\htdocs\core\modules\propale\doc\pdf_RausBau.modules.php on line 1637

Can someone help me please

Thanks Aba

Why are you trying to use that function? Does it even exist?

the IF part can be used in the template file. Either change the core file or copy the whole code + your change to a custom template in a module.

1 Like