Bon du coup je pense que je vais utiliser le code « SHIPPING » du dictionnaire n’ayant pas trouver une autre solution et ne comprenant pas les extrafields.
Je vois que le template pdf azur fait déjà appel au code « SALESREPFOLL » pour le nom du commercial.
J’ai modifier le code à partir de la condition if ($showaddress) que voici :
if ($showaddress)
{
// Add shipping var
$arrayidship=$object->getIdContact('external','SHIPPING');
$arraysocnship=$object->getSocName('external','SHIPPING');
$arraysocaship=$object->getSocAdd('external','SHIPPING');
// Sender properties
$carac_emetteur='';
// Add internal contact of proposal if defined
$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
$object->fetch_user($arrayidcontact[0]);
$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Width box sender and shipping & Left Margin text box
if (! empty($arrayidship)){
$widthrecbox = 62;
$margbox = 1
}
Else {
$widthrecbox = 82;
$margbox = 2;
}
// Show sender
$posy=42+$top_shift;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->(marge_droite-$widthrecbox);
$hautcadre=40;
// Show sender frame
$pdf->SetTextColor(128,128,128);
$pdf->SetFillColor(230,230,230);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($margbox,$posy-5);
$pdf->MultiCell($widthrecbox,5, $outputlangs->transnoentities("BillFrom")." :", 0, 'L');
$pdf->SetXY($posx,$posy);
//$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R');
$pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, 2, '1234', 'F');
// Show sender name
$pdf->SetXY($margbox,$posy+3);
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('','B', $default_font_size + 2);
$pdf->MultiCell($widthrecbox, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
$posy=$pdf->getY();
// Show sender information
$pdf->SetXY($margbox,$posy);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0, 'L');
// Add shipping
if (! empty($arrayidship))
{
// Show shipping
$posy=42+$top_shift;
$posx=$this->marge_gauche+$widthrecbox+2;
$hautcadre=40;
// Show shipping frame
$pdf->SetTextColor(255,255,0);
$pdf->SetFillColor(255,255,0);
$pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY($margbox,$posy-5);
$pdf->MultiCell($widthrecbox,5, "Adresse de livraison :", 0, 'L');
$pdf->SetXY($posx,$posy);
//$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R');
$pdf->RoundedRect($posx, $posy, $widthrecboxrecipient, $hautcadre, 2, '1234');
// Show shipping name
$pdf->SetXY($margbox,$posy+3);
$pdf->SetFont('','B', $default_font_size);
$pdf->MultiCell($widthrecbox, 4, $arraysocnship, 0, 'L');
$posy=$pdf->getY();
// Show shipping information
$pdf->SetXY($margbox,$posy);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell($widthrecbox, 4, $arraysocaship, 0, 'L');
}
// If CUSTOMER contact defined, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external','CUSTOMER');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
//Recipient name
// On peut utiliser le nom de la societe du contact
if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
}
$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
// Show recipient
if (! empty($arrayidship)){ $widthrecboxrecipient=62;
} else { $widthrecboxrecipient=100; }
$posy=42+$top_shift;
$posx=$this->page_largeur-$this->marge_droite-$widthrecboxrecipient;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0,255,0);
$pdf->SetFillColor(0,255,0);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($margbox,$posy-5);
$pdf->MultiCell($widthrecboxrecipient, 5, $outputlangs->transnoentities("BillTo")." :", 0, 'L');
$pdf->RoundedRect($posx, $posy, $widthrecboxrecipient, $hautcadre, 2, '1234');
// Show recipient name
$pdf->SetXY($margbox,$posy+3);
$pdf->SetFont('','B', $default_font_size + 2);
$pdf->MultiCell($widthrecboxrecipient, 4, $carac_client_name, 0, 'L');
$posy = $pdf->getY();
// Show recipient information
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($margbox,$posy);
$pdf->MultiCell($widthrecboxrecipient, 4, $carac_client, 0, 'L');
}
$pdf->SetTextColor(0,0,0);
return $top_shift;
}
Mais cela ne fonctionne pas… Le PDF ne se génère pas.
J’ai du faire une erreur sur l’ajout des variables suivantes :
// Add shipping var
$arrayidship=$object->getIdContact('external','SHIPPING');
$arraysocnship=$object->getSocName('external','SHIPPING');
$arraysocaship=$object->getSocAdd('external','SHIPPING');