How to make shipment model like invoice? SOLVED

Hi,
Please i would like to know how can i make shipment model like invoice.
See the secreenshot in attachement
Thank you.

https://wiki.dolibarr.org/index.php/Create_a_PDF_document_template

Copy invoice template and change what you want.

(I’ve just seen that you posted a similar question in the French forum: https://www.dolibarr.fr/forum/12-howto–aide/63543-comment-avoir-model-expedition-comme-facture#105887)

First of all thank you for your quick reply,
I did this before :
copy and paste mod_expedition_safor.php rename it to mod_expedition_bl.php locate in : /htdocs/core/modules/expedition then i renamed class name to class mod_expedition_bl

=============code 1 ==================
class mod_expedition_bl extends ModelNumRefExpedition
{
var $version=‘dolibarr’;
var $error = ‘’;
var $nom = ‘bl’;
}

The same thing for pdf_merou.modules.php in /htdocs/core/modules/expedition/doc

==============code2 =================
class pdf_bl extends ModelePdfExpedition
{
}
function __construct($db=0)
{
$this->name = “bl”;
}

I know this is path of invoice template : /htdocs/core/modules/facture/doc/pdf_crabe.modules.php
But when i copy source code from invoice template to /htdocs/core/modules/expedition/doc/pdf_bl.modules.php i got many problems like :
Fatal error: Class ‘Facture’ not found in C:\wamp64\www\dolibarr\htdocs\core\modules\expedition\doc\pdf_bl.modules.php on line 1548
Lot of function not undefined in pdf_bl.modules.php

Hi again,
I found the right solution for that: i added the code from order.
Thank you

Great!

Pls. mark these posts both as solved by editing the respective starting posts and mark them accordingly.

Hi again Mr Peter A. Gebhardt,
Yes i will do, but my solution works only in version 8.04 but in version 3.9.1 i can’t get total HT and Total TTC i got just total VAT, please how can i fix it?

=================Total HT===============================
// Total HT
$pdf->SetFillColor(200,200,200);
$pdf->SetXY($col1x + 80, $tab2_top + 265);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities(“TotalHT”), 0, ‘L’, 1);

	$total_ht = (($conf-\>multicurrency-\>enabled && isset($object-\>multicurrency_tx) && $object-\>multicurrency_tx != 1) ? $object-\>multicurrency_total_ht : $object-\>total_ht);
	$pdf-\>SetXY($col2x \+ 50, $tab2_top \+ 265);
	$pdf-\>MultiCell($largcol2, $tab2_hl, price($total_ht \+ (! empty($object-\>remise)?$object-\>remise:0), 0, $outputlangs), 0, 'R', 1);
	//$pdf-\>MultiCell($largcol2, $tab2_hl, price($object-\>total_ht \+ (! empty($object-\>remise)?$object-\>remise:0), 0, $outputlangs), 0, 'R', 1);

===================Total TTC=============================
// Total TTC
$index++;
$pdf->SetXY($col1x + 80, $tab2_top + 275 + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(200,200,200);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities(“TotalTTC”), $useborder, ‘L’, 1);

			$pdf-\>SetXY($col2x +50, $tab2_top \+ 275 \+ $tab2_hl \* $index);
			$pdf-\>MultiCell($largcol2, $tab2_hl , price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);

======================VAT============================
// Show VAT by rates and total
$pdf->SetFillColor(255,255,255);

	$total_ttc = ($conf-\>multicurrency-\>enabled && $object-\>multicurrency_tx != 1) ? $object-\>multicurrency_total_ttc : $object-\>total_ttc;

	$this-\>atleastoneratenotnull=0;
	if (empty($conf-\>global-\>MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
	{
		$tvaisnull=((! empty($this-\>tva) && count($this-\>tva) == 1 && isset($this-\>tva['0.000']) && is_float($this-\>tva['0.000'])) ? true : false);
		if (! empty($conf-\>global-\>MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
		{
			// Nothing to do
		}
		else
		{
			//Local tax 1 before VAT
			//if (! empty($conf-\>global-\>FACTURE_LOCAL_TAX1_OPTION) && $conf-\>global-\>FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
			//{
				foreach( $this-\>localtax1 as $localtax_type =\> $localtax_rate )
				{
					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
					foreach( $localtax_rate as $tvakey =\> $tvaval )
					{
						if ($tvakey!=0)    // On affiche pas taux 0
						{
							//$this-\>atleastoneratenotnull++;

							$index++;
							$pdf-\>SetXY($col1x +80, $tab2_top \+ 270 \+ $tab2_hl \* $index);

							$tvacompl='';
							if (preg_match('/\*/',$tvakey))
							{
								$tvakey=str_replace('*','',$tvakey);
								$tvacompl = " (".$outputlangs-\>transnoentities("NonPercuRecuperable").")";
							}
							$totalvat = $outputlangs-\>transcountrynoentities("TotalLT1",$mysoc-\>country_code).' ';
							$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
							$pdf-\>MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

							$pdf-\>SetXY($col2x +50, $tab2_top \+ 270 \+ $tab2_hl \* $index);
							$pdf-\>MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
						}
					}
				}
      		//}
			//Local tax 2 before VAT
			//if (! empty($conf-\>global-\>FACTURE_LOCAL_TAX2_OPTION) && $conf-\>global-\>FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
			//{
				foreach( $this-\>localtax2 as $localtax_type =\> $localtax_rate )
				{
					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
					foreach( $localtax_rate as $tvakey =\> $tvaval )
					{
						if ($tvakey!=0)    // On affiche pas taux 0
						{
							//$this-\>atleastoneratenotnull++;



							$index++;
							$pdf-\>SetXY($col1x +80, $tab2_top \+ 270 \+ $tab2_hl \* $index);

							$tvacompl='';
							if (preg_match('/\*/',$tvakey))
							{
								$tvakey=str_replace('*','',$tvakey);
								$tvacompl = " (".$outputlangs-\>transnoentities("NonPercuRecuperable").")";
							}
							$totalvat = $outputlangs-\>transcountrynoentities("TotalLT2",$mysoc-\>country_code).' ';
							$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
							$pdf-\>MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

							$pdf-\>SetXY($col2x +50, $tab2_top \+ 270 \+ $tab2_hl \* $index);
							$pdf-\>MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);

						}
					}
				}
			//}
			// VAT
			foreach($this-\>tva as $tvakey =\> $tvaval)
			{
				if ($tvakey != 0)    // On affiche pas taux 0
				{
					$this-\>atleastoneratenotnull++;

					$index++;
					$pdf-\>SetXY($col1x \+ 80, $tab2_top \+ 270 \+ $tab2_hl \* $index);

					$tvacompl='';
					if (preg_match('/\*/',$tvakey))
					{
						$tvakey=str_replace('*','',$tvakey);
						$tvacompl = " (".$outputlangs-\>transnoentities("NonPercuRecuperable").")";
					}
					$totalvat =$outputlangs-\>transcountrynoentities("TotalVAT",$mysoc-\>country_code).' ';
					$totalvat.=vatrate($tvakey,1).$tvacompl;
					$pdf-\>MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

					$pdf-\>SetXY($col2x +50, $tab2_top \+ 270 \+ $tab2_hl \* $index);
					$pdf-\>MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
				}
			}

			//Local tax 1 after VAT
			//if (! empty($conf-\>global-\>FACTURE_LOCAL_TAX1_OPTION) && $conf-\>global-\>FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
			//{
				foreach( $this-\>localtax1 as $localtax_type =\> $localtax_rate )
				{
					if (in_array((string) $localtax_type, array('2','4','6'))) continue;

					foreach( $localtax_rate as $tvakey =\> $tvaval )
					{
						if ($tvakey != 0)    // On affiche pas taux 0
						{
							//$this-\>atleastoneratenotnull++;

							$index++;
							$pdf-\>SetXY($col1x \+ 80, $tab2_top \+ 270 \+ $tab2_hl \* $index);

							$tvacompl='';
							if (preg_match('/\*/',$tvakey))
							{
								$tvakey=str_replace('*','',$tvakey);
								$tvacompl = " (".$outputlangs-\>transnoentities("NonPercuRecuperable").")";
							}
							$totalvat = $outputlangs-\>transcountrynoentities("TotalLT1",$mysoc-\>country_code).' ';

							$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
							$pdf-\>MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
							$pdf-\>SetXY($col2x \+ 50, $tab2_top \+ 270 \+ $tab2_hl \* $index);
							$pdf-\>MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
						}
					}
				}
      		//}
			//Local tax 2 after VAT
			//if (! empty($conf-\>global-\>FACTURE_LOCAL_TAX2_OPTION) && $conf-\>global-\>FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
			//{
				foreach( $this-\>localtax2 as $localtax_type =\> $localtax_rate )
				{
					if (in_array((string) $localtax_type, array('2','4','6'))) continue;

					foreach( $localtax_rate as $tvakey =\> $tvaval )
					{
						if ($tvakey != 0)    // On affiche pas taux 0
						{
							//$this-\>atleastoneratenotnull++;

							$index++;
							$pdf-\>SetXY($col1x \+ 80, $tab2_top \+ 270 \+ $tab2_hl \* $index);

							$tvacompl='';
							if (preg_match('/\*/',$tvakey))
							{
								$tvakey=str_replace('*','',$tvakey);
								$tvacompl = " (".$outputlangs-\>transnoentities("NonPercuRecuperable").")";
							}
							$totalvat = $outputlangs-\>transcountrynoentities("TotalLT2",$mysoc-\>country_code).' ';

							$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
							$pdf-\>MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);

							$pdf-\>SetXY($col2x +50, $tab2_top \+ 270 \+ $tab2_hl \* $index);
							$pdf-\>MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
						}
					}
				}

=====================================================

I fixed this problem on old version 3.9.1 i changed the place of code, i put it in the function _pagefoot
Now i need just how to add also services to expedition, i used this variable : STOCK_SUPPORTS_SERVICES= 1
But i got error Message :
=====================Error Message ==============================

===============================================================

I fixed it
Thank you

Hello

i have the same issue i wanna add the price in shipment model, caan i have your model to work on it please ?