/**
     *      Show header of document
     *      @param      pdf             Object PDF
     *      @param      object          Object commercial proposal
     *      @param      showaddress     0=no, 1=yes
     *      @param      outputlangs     Object lang for output
     */
	function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
	{
		global $conf,$langs;
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && ! empty($conf->global->PROPALE_DRAFT_WATERMARK))
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
		}

		$posy=42;

		$pdf->SetXY($this->marge_gauche+2,$posy);

		// Sender name
		$pdf->SetTextColor(0,0,00);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

		// Sender properties
		$carac_emetteur='';
	 	// Add internal contact of proposal if defined
		$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
	 	if (sizeof($arrayidcontact) > 0)
	 	{
	 		$object->fetch_user($arrayidcontact[0]);
	 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
	 	}

	 	$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);

		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY($this->marge_gauche+2,$posy+4);
		$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


		$pdf->rect(10, 40, 80, 40);

		$pdf->SetXY(10,5);
		$pdf->SetFont('','B', $default_font_size + 6);
		$pdf->SetTextColor(0,0,200);
		$pdf->MultiCell(200, 20, $outputlangs->transnoentities("CommercialProposal"), '' , 'C');

		// Cadre client destinataire
		$pdf->rect(100, 40, 100, 40);

		$pdf->SetTextColor(200,0,0);
		$pdf->SetFont('','B', $default_font_size + 2);

		$pdf->rect(10, 90, 100, 10);
		$pdf->rect(110, 90, 90, 10);

		$pdf->SetXY(10,90);
		$pdf->MultiCell(110, 10, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), 0, 'L');
		$pdf->SetXY(110,90);
		$pdf->MultiCell(100, 10, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs,true), 0, 'L');

		$posy=15;
		$pdf->SetFont('','', $default_font_size);

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');

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

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');

		if ($object->client->code_client)
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
		}

		$posy=39;

		$pdf->SetTextColor(0,0,0);

		// If CUSTOMER contact defined, we use it
		$usecontact=false;
		$arrayidcontact=$object->getIdContact('external','CUSTOMER');
		if (sizeof($arrayidcontact) > 0)
		{
			$usecontact=true;
			$result=$object->fetch_contact($arrayidcontact[0]);
		}

		// Recipient name
		if (! empty($usecontact))
		{
			// On peut utiliser le nom de la societe du contact
			if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
			else $socname = $object->client->nom;
			$carac_client_name=$outputlangs->convToOutputCharset($socname);
		}
		else
		{
			$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
		}

		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

		// Show recipient
		$pdf->SetXY(102,$posy+3);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

		// Show address
		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY(102,$posy+8);
		$pdf->MultiCell(86,4, $carac_client, 0, 'L');
	}
	/**
	 *   	Show header of document
	 *   	@param      pdf     		Object PDF
	 *   	@param      object			Object commercial proposal
	 *      @param      showaddress     0=no, 1=yes
	 *      @param      outputlangs    	Object lang for output
	 */
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs,$mysoc;
		$default_font_size = pdf_getPDFFontSize($outputlangs);
		$langs->load("orders");

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
		}

		//Prepare la suite
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size + 3);

		$posy=$this->marge_haute;

		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B', $default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

		// Show barcode
		if ($conf->barcode->enabled)
		{
			$posx=105;
		}
		else
		{
			$posx=$this->marge_gauche+3;
		}
		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
		if ($conf->barcode->enabled)
		{
			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
			//$pdf->Image($logo,10, 5, 0, 24);
		}

		$pdf->SetDrawColor(128,128,128);
		if ($conf->barcode->enabled)
		{
			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
			//$pdf->Image($logo,10, 5, 0, 24);
		}


		$posx=100;
		$posy=$this->marge_haute;

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

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

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');

		//Date Expedition
		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_delivery,"%d %b %Y",false,$outputlangs,true), '', 'R');

		if (! empty($object->client->code_client))
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
		}


		$pdf->SetFont('','', $default_font_size + 4);
	    $Yoff=25;

	    // Add list of linked orders
	    // TODO possibility to use with other document (business module,...)
	    //$object->load_object_linked();
	    
	    $origin 	= $object->origin;
		$origin_id 	= $object->origin_id;

	    // TODO move to external function
		if ($conf->$origin->enabled)
		{
			$outputlangs->load('orders');
			
			$classname = ucfirst($origin);
			$linkedobject = new $classname($this->db);
			$result=$linkedobject->fetch($origin_id);
			if ($result >= 0)
			{
				$pdf->SetFont('','', $default_font_size - 2);
				$text=$linkedobject->ref;
				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
				$Yoff = $Yoff+8;
				$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff);
				$pdf->MultiCell(60, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
				$Yoff = $Yoff+4;
				$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff);
				$pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true), 0, 'R');
			}
		}
		
		if ($showaddress)
		{
			// Sender properties
			$carac_emetteur='';
		 	// Add internal contact of proposal if defined
			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
		 	if (sizeof($arrayidcontact) > 0)
		 	{
		 		$object->fetch_user($arrayidcontact[0]);
		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
		 	}

		 	$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);

			// Show sender
			$posx=$this->marge_gauche;
			$posy=42;
			$hautcadre=40;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;

			// Show sender frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
			$pdf->SetXY($posx,$posy);
			$pdf->SetFillColor(230,230,230);
			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);

			// Show sender name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetTextColor(0,0,60);
			$pdf->SetFont('','B',$default_font_size);
			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

			// Show sender information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


			// If CUSTOMER contact defined, we use it
			$usecontact=false;
			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
			if (sizeof($arrayidcontact) > 0)
			{
				$usecontact=true;
				$result=$object->fetch_contact($arrayidcontact[0]);
			}

			// Recipient name
			if (! empty($usecontact))
			{
				// On peut utiliser le nom de la societe du contact
				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
				else $socname = $object->client->nom;
				$carac_client_name=$outputlangs->convToOutputCharset($socname);
			}
			else
			{
				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
			}

			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

			// Show recipient
			$posy=42;
			$posx=100;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

			// Show recipient frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(80, 4, $outputlangs->transnoentities("Recipient").":", 0, 'L');
			$pdf->rect($posx, $posy, 100, $hautcadre);
			$pdf->SetTextColor(0,0,0);

			// Show recipient name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

			// Show recipient information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
		}

	}
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("propal");
     $outputlangs->load("companies");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->FACTURE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $w = 110;
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - $w;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("Invoice");
     if ($object->type == 1) {
         $title = $outputlangs->transnoentities("InvoiceReplacement");
     }
     if ($object->type == 2) {
         $title = $outputlangs->transnoentities("InvoiceAvoir");
     }
     if ($object->type == 3) {
         $title = $outputlangs->transnoentities("InvoiceDeposit");
     }
     if ($object->type == 4) {
         $title = $outputlangs->transnoentities("InvoiceProFormat");
     }
     $pdf->MultiCell($w, 3, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', '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');
     }
     $objectidnext = $object->getIdReplacingInvoice('validated');
     if ($object->type == 0 && $objectidnext) {
         $objectreplacing = new Facture($this->db);
         $objectreplacing->fetch($objectidnext);
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
     }
     if ($object->type == 1) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
     }
     if ($object->type == 2 && !empty($object->fk_facture_source)) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
     }
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice") . " : " . dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
     if ($object->type != 2) {
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateEcheance") . " : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
     }
     if ($object->thirdparty->code_client) {
         $posy += 3;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
     }
     $posy += 1;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
         $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
         // If BILLING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'BILLING');
         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->client;
         }
         $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
         $posy = $pdf->getY();
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 0);
 }
Example #4
0
 /**
  *   	Show footer of page. Need this->emetteur object
  *
  *   	@param	PDF			&$pdf     			PDF
  * 		@param	Object		$object				Object to show
  *      @param	Translate	$outputlangs		Object lang for output
  *      @return	void
  */
 function _pagefoot(&$pdf, $object, $outputlangs)
 {
     global $conf;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     //return pdf_pagefoot($pdf,$outputlangs,'BANK_CHEQUERECEIPT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
     $paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT';
     $marge_basse = $this->marge_basse;
     $marge_gauche = $this->marge_gauche;
     $page_hauteur = $this->page_hauteur;
     // Line of free text
     $line = !empty($conf->global->{$paramfreetext}) ? $outputlangs->convToOutputCharset($conf->global->{$paramfreetext}) : "";
     $pdf->SetFont('', '', $default_font_size - 3);
     $pdf->SetDrawColor(224, 224, 224);
     // On positionne le debut du bas de page selon nbre de lignes de ce bas de page
     $nbofline = dol_nboflines_bis($line, 0, $outputlangs->charset_output);
     //print 'e'.$line.'t'.dol_nboflines($line);exit;
     $posy = $marge_basse + $nbofline * 3;
     if ($line) {
         $pdf->SetXY($marge_gauche, -$posy);
         $pdf->MultiCell(20000, 3, $line, 0, 'L', 0);
         // Use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
         $posy -= $nbofline * 3;
         // 6 of ligne + 3 of MultiCell
     }
     $pdf->SetY(-$posy);
     $pdf->line($marge_gauche, $page_hauteur - $posy, 200, $page_hauteur - $posy);
     $posy--;
     /*if ($line1)
     		{
     			$pdf->SetXY($marge_gauche,-$posy);
     			$pdf->MultiCell(200, 2, $line1, 0, 'C', 0);
     		}
     
     		if ($line2)
     		{
     			$posy-=3;
     			$pdf->SetXY($marge_gauche,-$posy);
     			$pdf->MultiCell(200, 2, $line2, 0, 'C', 0);
     		}*/
     // Show page nb only on iso languages (so default Helvetica font)
     if (pdf_getPDFFont($outputlangs) == 'Helvetica') {
         $pdf->SetXY(-20, -$posy);
         $pdf->MultiCell(11, 2, $pdf->PageNo() . '/' . $pdf->getAliasNbPages(), 0, 'R', 0);
     }
 }
Example #5
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("interventions");
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->FICHINTER_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FICHINTER_DRAFT_WATERMARK);
     }
     //Prepare la suite
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("InterventionCard");
     $pdf->MultiCell(100, 4, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $posy += 1;
     $pdf->SetFont('', '', $default_font_size);
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R');
     if ($object->client->code_client) {
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = '';
         // Add internal contact of proposal if defined
         $arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
         if (count($arrayidcontact) > 0) {
             $object->fetch_user($arrayidcontact[0]);
             $carac_emetteur .= ($carac_emetteur ? "\n" : '') . $outputlangs->transnoentities("Name") . ": " . $outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)) . "\n";
         }
         $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy);
         $pdf->MultiCell(80, 4, $carac_emetteur, 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
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->name;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->name);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, isset($object->contact) ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         $pdf->SetTextColor(0, 0, 0);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
 }
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs,$mysoc;
		$langs->load("orders");
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
		}


		$posy=$this->marge_haute;
		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B', $default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

		$posy = 40;

		$pdf->SetXY($this->marge_gauche,$posy+3);

		// Sender name
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

		// Sender properties
		$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY($this->marge_gauche,$posy+7);
		$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');

		// Client destinataire
		$client = new Societe($this->db);
		$client->fetch($object->socid);
		$object->client = $client;

		// If CUSTOMER contact defined on invoice, we use it
		$usecontact=false;
		$arrayidcontact=$object->getIdContact('external','CUSTOMER');
		if (sizeof($arrayidcontact) > 0)
		{
			$usecontact=true;
			$result=$object->fetch_contact($arrayidcontact[0]);
		}

		// Recipient name
		if (! empty($usecontact))
		{
			// On peut utiliser le nom de la societe du contact
			if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
			else $socname = $object->client->nom;
			$carac_client_name=$outputlangs->convToOutputCharset($socname);
		}
		else
		{
			$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
		}

		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

		// Show customer/recipient
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->SetXY(102,42);
		$pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY(102,$pdf->GetY());
		$pdf->MultiCell(96, 4, $carac_client, 0, 'L');

		$pdf->rect(100, 40, 100, 40);

		$pdf->SetTextColor(200,0,0);
		$pdf->SetFont('','B', $default_font_size + 2);
		$pdf->SetXY(11, 88);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,'day',false,$outputlangs), 0, 'L');
        $pdf->SetXY(11, 94);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref), 0, 'L');
	}
Example #7
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
     if ($mysoc->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     if ($object->date_valid) {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery ? $object->date_delivery : $date->valid, "%d %b %Y", false, $outputlangs, true), '', 'R');
     } else {
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
         $pdf->SetTextColor(0, 0, 60);
     }
     if ($object->client->code_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetTextColor(0, 0, 60);
     // Add origin linked objects
     // TODO extend to other objects
     $object->fetchObjectLinked('', '', $object->id, 'delivery');
     if (!empty($object->linkedObjects)) {
         $outputlangs->load('orders');
         foreach ($object->linkedObjects as $elementtype => $objects) {
             $object->fetchObjectLinked('', '', $objects[0]->id, $objects[0]->element);
             foreach ($object->linkedObjects as $elementtype => $objects) {
                 $num = count($objects);
                 for ($i = 0; $i < $num; $i++) {
                     $order = new Commande($this->db);
                     $result = $order->fetch($objects[$i]->id);
                     if ($result >= 0) {
                         $posy += 5;
                         $pdf->SetXY($posx, $posy);
                         $pdf->SetFont('', '', $default_font_size - 1);
                         $text = $order->ref;
                         if ($order->ref_client) {
                             $text .= ' (' . $order->ref_client . ')';
                         }
                         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
                     }
                 }
             }
         }
     }
     if ($showaddress) {
         // Emetteur
         $posy = 42;
         $hautcadre = 40;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($this->marge_gauche, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":");
         $pdf->SetXY($this->marge_gauche, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetXY($this->marge_gauche + 2, $posy + 3);
         // Nom emetteur
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($this->marge_gauche + 2, $posy + 9);
         $pdf->MultiCell(80, 3, $carac_emetteur, 0, 'L');
         // Client destinataire
         $posy = 42;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY(102, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress") . ":", 0, 'L');
         // Cadre client destinataire
         $pdf->Rect(100, $posy, 100, $hautcadre);
         // If SHIPPING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
         // Show customer/recipient
         $pdf->SetXY(102, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(106, 4, $carac_client_name, 0, 'L');
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY(102, $posy + 8);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
 }
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  CommandeFournisseur		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("orders");
     $outputlangs->load("companies");
     $outputlangs->load("sendings");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     // Do not add the BACKGROUND as this is for suppliers
     //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
     		{
                 pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
     		}*/
     //Print content
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("SupplierOrder") . " " . $outputlangs->convToOutputCharset($object->ref);
     $pdf->MultiCell(100, 3, $title, '', 'R');
     $posy += 1;
     if ($object->ref_supplier) {
         $posy += 4;
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier") . " : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
         $posy += 1;
     }
     $pdf->SetFont('', '', $default_font_size - 1);
     if (!empty($conf->global->PDF_SHOW_PROJECT)) {
         $object->fetch_projet();
         if (!empty($object->project->ref)) {
             $posy += 4;
             $pdf->SetXY($posx, $posy);
             $langs->load("projects");
             $pdf->SetTextColor(0, 0, 60);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project") . " : " . (empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
         }
     }
     if (!empty($object->date_commande)) {
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate") . " : " . dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R');
     } else {
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R');
     }
     $pdf->SetTextColor(0, 0, 60);
     $usehourmin = 'day';
     if (empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) {
         $usehourmin = 'dayhour';
     }
     if (!empty($object->date_livraison)) {
         $posy += 4;
         $pdf->SetXY($posx - 90, $posy);
         $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned") . " : " . dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R');
     }
     if ($object->thirdparty->code_fournisseur) {
         $posy += 4;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode") . " : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
     }
     $posy += 1;
     $pdf->SetTextColor(0, 0, 60);
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // If BILLING contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'BILLING');
         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->client;
         }
         $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         $posy = $pdf->getY();
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
 }
	/**
	 *   	\brief      Show header of page
	 *      \param      pdf             Object PDF
	 *      \param      object          Object invoice
	 *      \param      showaddress     0=no, 1=yes
	 *      \param      outputlangs		Object lang for output
	 */
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs;

		$outputlangs->load("main");
		$outputlangs->load("bills");
		$outputlangs->load("propal");
		$outputlangs->load("companies");

		$default_font_size = pdf_getPDFFontSize($outputlangs);

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

        if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
        {
		      pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
        }

		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size + 3);

		$posy=$this->marge_haute;

		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);	// width=0 (auto), max height=24
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B',$default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

		$pdf->SetFont('','B', $default_font_size + 3);
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$title=$outputlangs->transnoentities("Invoice");
		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat");
		$pdf->MultiCell(100, 4, $title, '' , 'R');

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

		$posy+=6;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');

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

		$objectidnext=$object->getIdReplacingInvoice('validated');
		if ($object->type == 0 && $objectidnext)
		{
			$objectreplacing=new Facture($this->db);
			$objectreplacing->fetch($objectidnext);

			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
		}
		if ($object->type == 1)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
		}
		if ($object->type == 2)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
		}

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

		if ($object->type != 2)
		{
			$posy+=4;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R');
		}

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

		// Add list of linked orders and proposals
		// TODO mutualiser
	    $object->fetchObjectLinked();

	    foreach($object->linkedObjects as $objecttype => $objects)
	    {
	    	if ($objecttype == 'propal')
	    	{
	    		$outputlangs->load('propal');
	    		$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY(100,$posy);
	    			$pdf->SetFont('','', $default_font_size - 1);
	    			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'R');
	    		}
			}
			else if ($objecttype == 'commande')
			{
				$outputlangs->load('orders');
				$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY(100,$posy);
	    			$pdf->SetFont('','', $default_font_size - 1);
	    			$text=$objects[$i]->ref;
	    			if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
	    			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
	    		}
	    	}
		}

		if ($showaddress)
		{
			// Sender properties
			$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

			// Show sender
			$posy=42;
			$posx=$this->marge_gauche;
			$hautcadre=40;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;

			// Show sender frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
			$pdf->SetXY($posx,$posy);
			$pdf->SetFillColor(230,230,230);
			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
			$pdf->SetTextColor(0,0,60);

			// Show sender name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

			// Show sender information
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');



			// If BILLING contact defined on invoice, we use it
			$usecontact=false;
			$arrayidcontact=$object->getIdContact('external','BILLING');
			if (sizeof($arrayidcontact) > 0)
			{
				$usecontact=true;
				$result=$object->fetch_contact($arrayidcontact[0]);
			}

			// Recipient name
			if (! empty($usecontact))
			{
				// On peut utiliser le nom de la societe du contact
				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
				else $socname = $object->client->nom;
				$carac_client_name=$outputlangs->convToOutputCharset($socname);
			}
			else
			{
				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
			}

			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

			// Show recipient
			$posy=42;
			$posx=100;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

			// Show recipient frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx+2,$posy-5);
			$pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":",0,'L');
			$pdf->rect($posx, $posy, 100, $hautcadre);

			// Show recipient name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

			// Show recipient information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
		}
	}
 /**
  * \brief Fonction generant le document sur le disque
  * \param agf		Objet document a generer (ou id si ancienne methode)
  * outputlangs	Lang object for output language
  * file		Name of file to generate
  * \return int 1=ok, 0=ko
  */
 function write_file($loyer, $outputlangs, $file, $socid, $courrier)
 {
     global $user, $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     if (!is_object($loyer)) {
         $id = $loyer;
         $loyer = new Loyer($this->db);
         $ret = $loyer->fetch($id);
     }
     // dol_syslog ( "pdf_quittance::debug loyer=" . var_export ( $loyer, true ) );
     // Definition of $dir and $file
     $dir = $conf->immobilier->dir_output;
     $file = $dir . '/' . $file;
     if (!file_exists($dir)) {
         if (create_exdir($dir) < 0) {
             $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     }
     if (file_exists($dir)) {
         $pdf = pdf_getInstance($this->format, $this->unit, $this->orientation);
         if (class_exists('TCPDF')) {
             $pdf->setPrintHeader(false);
             $pdf->setPrintFooter(false);
         }
         $pdf->Open();
         $pagenb = 0;
         $pdf->SetTitle($outputlangs->convToOutputCharset($loyer->nom));
         $pdf->SetSubject($outputlangs->transnoentities("Quitance"));
         $pdf->SetCreator("Dolibarr " . DOL_VERSION . ' (Immobilier module)');
         $pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
         $pdf->SetKeyWords($outputlangs->convToOutputCharset($loyer->nom) . " " . $outputlangs->transnoentities("Document"));
         if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) {
             $pdf->SetCompression(false);
         }
         $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
         // Left, Top, Right
         $pdf->SetAutoPageBreak(1, 0);
         // On recupere les infos societe
         $locataire = new Locataire($this->db);
         $result = $locataire->fetch($loyer->locataire_id);
         $proprio = new Adherent($this->db);
         $result = $proprio->fetch($loyer->proprietaire_id);
         $local = new Local($this->db);
         $result = $local->fetch($loyer->local_id);
         $paiement = new Paie($this->db);
         $result = $paiement->fetch_by_loyer($loyer->id);
         if (!empty($loyer->id)) {
             // New page
             $pdf->AddPage();
             $pagenb++;
             $this->_pagehead($pdf, $agf, 1, $outputlangs);
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 9);
             $pdf->MultiCell(0, 3, '', 0, 'J');
             $pdf->SetTextColor(0, 0, 0);
             $posY = $this->marge_haute;
             $posX = $this->marge_gauche;
             // Bloc Owner
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 15);
             $pdf->SetXY($posX, $posY + 3);
             $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset('Bailleur'), 1, 'C');
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $this->str = $proprio->getFullName($outputlangs) . "\n";
             $this->str .= $proprio->address . "\n";
             $this->str .= $proprio->zip . ' ' . $proprio->town;
             $this->str .= ' - ' . $proprio->country . "\n\n";
             if ($proprio->phone) {
                 $this->str .= $outputlangs->transnoentities('Téléphone') . ' ' . $proprio->phone . "\n";
             }
             if ($proprio->fax) {
                 $this->str .= $outputlangs->transnoentities('Fax') . ' ' . $proprio->fax . "\n";
             }
             if ($proprio->email) {
                 $this->str .= $outputlangs->transnoentities('EMail') . ' ' . $proprio->email . "\n";
             }
             if ($proprio->url) {
                 $this->str .= $outputlangs->transnoentities('Url') . ' ' . $proprio->url . "\n";
             }
             $pdf->MultiCell(100, 20, $outputlangs->convToOutputCharset($this->str), 1, 'L');
             // Bloc Locataire
             $posX = $this->page_largeur - $this->marge_droite - 100;
             $posY = $pdf->getY() + 10;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 15);
             $pdf->SetXY($posX, $posY);
             $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset('Locataire Destinataire'), 1, 'C');
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $this->str = $locataire->nom . "\n";
             $this->str .= $local->nom . "\n";
             if (!empty($locataire->adresse)) {
                 $this->str .= $locataire->adresse . "\n";
             } else {
                 $this->str .= $local->adresse . "\n";
             }
             $pdf->MultiCell(100, 20, $outputlangs->convToOutputCharset($this->str), 1, 'L');
             // Bloc Quittance de loyer
             $posX = $this->marge_gauche;
             $posY = $pdf->getY() + 10;
             $widthbox = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 15);
             $pdf->SetXY($posX, $posY);
             $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset('Quittance de loyer'), 1, 'C');
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $period = 'Loyer ' . dol_print_date($loyer->periode_du, '%b %Y');
             $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset($period), 1, 'C');
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
             $posY = $pdf->getY();
             $pdf->SetXY($posX, $posY);
             $numquitance = 'Quittance n°:' . 'ILQ' . $loyer->id;
             $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset($numquitance), 1, 'R');
             // Sous Bloc Quittance de loyer Gauche
             $posX = $this->marge_gauche;
             $posY = $pdf->getY();
             $widthbox = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 12);
             $pdf->SetXY($posX, $posY);
             $text = ' Reçu de :' . $locataire->nom . "\n";
             $text .= "\n";
             $montantpay = 0;
             if (!empty($loyer->paiepartiel)) {
                 $montantpay = $loyer->paiepartiel;
             }
             $text .= ' la somme de :' . $montantpay . '€' . "\n";
             $text .= "\n";
             $dtpaiement = $paiement->date_paiement;
             if (empty($dtpaiement)) {
                 $dtpaiement = $loyer->echeance;
             }
             $text .= ' le :' . dol_print_date($dtpaiement, 'daytext') . "\n";
             $text .= "\n";
             $text .= ' pour loyer et accessoires des locaux sis à :' . "\n";
             $text .= $local->adresse . "\n";
             $text .= "\n";
             $text .= 'en paiement du terme du ' . dol_print_date($loyer->periode_du, 'daytext') . "\n";
             $text .= 'au ' . dol_print_date($loyer->periode_au, 'daytext') . "\n";
             $text .= "\n";
             $text .= 'Fait à ' . $proprio->town . "\n";
             $text .= 'le ' . dol_print_date(dol_now(), 'daytext') . "\n";
             $text .= "\n";
             $pdf->MultiCell($widthbox, 0, $outputlangs->convToOutputCharset($text), 1, 'L');
             $newpoy = $pdf->getY();
             // Sous Bloc Quittance de loyer Droite
             $posX = $widthbox + $this->marge_gauche;
             $widthbox = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2;
             $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 12);
             $pdf->SetXY($posX, $posY);
             $text = '<table>';
             $text .= '<tr>';
             $text .= '<td colspan="2">';
             $text .= 'Détail :' . "<BR>";
             $text .= ' - Loyer nu :' . $loyer->loy . '€' . "<BR>";
             $text .= ' - Charges / Provisions de Charges :' . $loyer->charges . '€' . "<BR>";
             $text .= "<BR>";
             $text .= 'Montant total du terme :' . $loyer->montant_tot . '€' . "<BR>";
             $text .= '</td>';
             $text .= '</tr>';
             $sql = "SELECT p.rowid, p.loyer_id, date_paiement as dp, p.montant, p.commentaire as type, il.montant_tot as amount";
             $sql .= " FROM " . MAIN_DB_PREFIX . "immo_paie as p";
             $sql .= ", " . MAIN_DB_PREFIX . "immo_loyer as il ";
             $sql .= " WHERE p.loyer_id = " . $loyer->id;
             $sql .= " AND p.loyer_id = il.rowid";
             $sql .= " ORDER BY dp DESC";
             // print $sql;
             dol_syslog(get_class($this) . ':: Paiement sql=' . $sql, LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $num = $this->db->num_rows($resql);
                 $i = 0;
                 $total = 0;
                 $text .= '<tr>';
                 $text .= '<td align="left">' . $langs->trans("Date") . '</td>';
                 $text .= '<td align="right">' . $langs->trans("Amount") . '</td>';
                 $text .= '</tr><br>';
                 $var = True;
                 while ($i < $num) {
                     $objp = $this->db->fetch_object($resql);
                     $text .= '<tr>';
                     $text .= '<td>' . dol_print_date($this->db->jdate($objp->dp), 'day') . "</td>";
                     $text .= '<td align="right">' . price($objp->montant) . ' ' . $langs->trans("Currency" . $conf->currency) . "</td>";
                     $text .= "</tr>";
                     $totalpaye += $objp->montant;
                     $i++;
                 }
                 if ($loyer->paye == 0) {
                     $text .= "<br><tr><td align=\"left\">" . $langs->trans("AlreadyPaid") . " :</td><td align=\"right\">" . price($totalpaye) . " " . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                     $text .= "<tr><td align=\"left\">" . $langs->trans("AmountExpected") . " :</td><td align=\"right\">" . price($loyer->montant_tot) . " " . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                     $resteapayer = $loyer->montant_tot - $totalpaye;
                     $text .= "<tr><td align=\"left\">" . $langs->trans("RemainderToPay") . " :</td>";
                     $text .= "<td align=\"right\">" . price($resteapayer, 2) . " " . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                 }
                 $this->db->free($resql);
             }
             $text .= "</table>";
             $pdf->writeHTMLCell($widthbox, $newpoy - $posY, $posX, $posY, dol_htmlentitiesbr($text), 1);
             // Tableau Loyer et solde
             $sql = "SELECT il.nom, il.solde";
             $sql .= " FROM " . MAIN_DB_PREFIX . "immo_loyer as il ";
             $sql .= " WHERE il.solde<>0 AND paye=0 AND periode_du<'" . $this->db->idate($loyer->periode_du) . "'";
             $sql .= " AND local_id=" . $loyer->local_id . " AND locataire_id=" . $loyer->locataire_id;
             $sql .= " ORDER BY echeance ASC";
             dol_syslog(get_class($this) . ':: loyerAntierieur sql=' . $sql, LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $num = $this->db->num_rows($resql);
                 if ($num > 0) {
                     // Bloc Solde Anterieur
                     $posX = $this->marge_gauche;
                     $posY = $pdf->getY() + ($newpoy - $posY) + 5;
                     $widthbox = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 15);
                     $pdf->SetXY($posX, $posY);
                     $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset('Solde Anterieur'), 1, 'C');
                     $text = '<table>';
                     // print $sql;
                     dol_syslog(get_class($this) . ':: loyerAntierieur sql=' . $sql, LOG_DEBUG);
                     $resql = $this->db->query($sql);
                     $i = 0;
                     $total = 0;
                     $var = True;
                     while ($i < $num) {
                         $objp = $this->db->fetch_object($resql);
                         $text .= '<tr>';
                         $text .= '<td>' . $objp->nom . "</td>";
                         $text .= "<td align=\"right\">" . $objp->solde . ' ' . $langs->trans("Currency" . $conf->currency) . "</td>";
                         $text .= "</tr>";
                         $i++;
                     }
                     $this->db->free($resql);
                     $text .= "</table>";
                     $posY = $pdf->getY();
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
                     $pdf->writeHTMLCell($widthbox, 0, $posX, $posY, dol_htmlentitiesbr($text), 1, 1);
                 }
             }
             // Bloc total somme due
             // Tableau total somme due
             $sql = "SELECT SUM(il.solde) as total";
             $sql .= " FROM " . MAIN_DB_PREFIX . "immo_loyer as il ";
             $sql .= " WHERE il.solde<>0 AND paye=0 AND periode_du<='" . $this->db->idate($loyer->periode_du) . "'";
             $sql .= " AND local_id=" . $loyer->local_id . " AND locataire_id=" . $loyer->locataire_id;
             $sql .= " GROUP BY local_id,locataire_id";
             // print $sql;
             dol_syslog(get_class($this) . ':: loyerAntierieur sql=' . $sql, LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 $num = $this->db->num_rows($resql);
                 if ($num > 0) {
                     $objp = $this->db->fetch_object($resql);
                     $posX = $this->marge_gauche;
                     $posY = $pdf->getY() + 5;
                     $widthbox = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 15);
                     $pdf->SetXY($posX, $posY);
                     if ($objp->total > 0) {
                         $title = 'Total somme due';
                     } else {
                         $title = 'Total somme à rembouser';
                     }
                     $pdf->MultiCell($widthbox, 3, $outputlangs->convToOutputCharset($title), 1, 'C');
                     $text = '<table>';
                     $i = 0;
                     $total = 0;
                     $text .= '<tr>';
                     $text .= "<td align=\"right\">" . $objp->total . ' ' . $langs->trans("Currency" . $conf->currency) . "</td></tr>";
                     $this->db->free($resql);
                     $text .= "</table>";
                     $posY = $pdf->getY();
                     $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 13);
                     $pdf->writeHTMLCell($widthbox, 0, $posX, $posY, dol_htmlentitiesbr($text), 1);
                 }
             }
         }
         $pdf->Close();
         $pdf->Output($file, 'F');
         if (!empty($conf->global->MAIN_UMASK)) {
             @chmod($file, octdec($conf->global->MAIN_UMASK));
         }
         return 1;
         // Pas d'erreur
     } else {
         $this->error = $langs->trans("ErrorConstantNotDefined", "AGF_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->trans("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }
	function _pagehead(&$pdf, $object, $showadress=0, $outputlangs)
	{
		global $langs,$conf;
		$langs->load("main");
		$langs->load("bills");
		$langs->load("propal");
		$langs->load("companies");

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
		}

		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B',$default_font_size + 3);

		$pdf->SetXY($this->marges['g'],6);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$taille=getimagesize($logo);
				$length=$taille[0]/2.835;
				$pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B', $default_font_size - 2);
				$pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}


		/*
		 * Emetteur
		 */
		$posy=$this->marges['h']+24;
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','', $default_font_size - 2);
		$pdf->SetXY($this->marges['g'],$posy-5);


		$pdf->SetXY($this->marges['g'],$posy);
		$pdf->SetFillColor(255,255,255);
		$pdf->MultiCell(82, 34, "", 0, 'R', 1);


		$pdf->SetXY($this->marges['g'],$posy+4);

		// Sender name
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size);
		$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

		// Sender properties
		$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

		$pdf->SetFont('','', $default_font_size - 1);
		$pdf->SetXY($this->marge_gauche,$posy+9);
		$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


		// Client destinataire
		$posy=45;
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','', $default_font_size - 2);
		$pdf->SetXY($this->marges['g']+100,$posy-5);
		$pdf->SetFont('','B',$default_font_size);

		// If BILLING contact defined on invoice, we use it
		$usecontact=false;
		$arrayidcontact=$object->getIdContact('external','BILLING');
		if (sizeof($arrayidcontact) > 0)
		{
			$usecontact=true;
			$result=$object->fetch_contact($arrayidcontact[0]);
		}

		// Recipient name
		if (! empty($usecontact))
		{
			// On peut utiliser le nom de la societe du contact
			if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
			else $socname = $object->client->nom;
			$carac_client_name=$outputlangs->convToOutputCharset($socname);
		}
		else
		{
			$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
		}

		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

		// Show customer/recipient
		$pdf->SetFont('','B', $default_font_size);
		$pdf->SetXY($this->marges['g']+100,$posy+4);
		$pdf->MultiCell(86,4, $carac_client_name, 0, 'L');

		$pdf->SetFont('','B', $default_font_size - 1);
		$pdf->SetXY($this->marges['g']+100,$posy+8);
		$pdf->MultiCell(86,4, $carac_client, 0, 'L');

		/*
		 * ref facture
		 */
		$posy=70;
		$pdf->SetFont('','B', $default_font_size + 3);
		$pdf->SetXY($this->marges['g'],$posy-5);
		$pdf->SetTextColor(0,0,0);
		$title=$outputlangs->transnoentities("Invoice");
		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma");
		$pdf->MultiCell(100, 10, $title.' '.$outputlangs->transnoentities("Of").' '.dol_print_date($object->date,"day",false,$outputlangs,true), '' , 'L');
		$pdf->SetFont('','B', $default_font_size + 1);
		$pdf->SetXY($this->marges['g'],$posy);
		$pdf->SetTextColor(22,137,210);
		$pdf->MultiCell(100, 10, $outputlangs->transnoentities("RefBill")." : " . $outputlangs->transnoentities($object->ref), '', 'L');
		$pdf->SetTextColor(0,0,0);
		$posy+=4;

		$objectidnext=$object->getIdReplacingInvoice('validated');
		if ($object->type == 0 && $objectidnext)
		{
			$objectreplacing=new Facture($this->db);
			$objectreplacing->fetch($objectidnext);

			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'L');
		}
		if ($object->type == 1)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
		}
		if ($object->type == 2)
		{
			$objectreplaced=new Facture($this->db);
			$objectreplaced->fetch($object->fk_facture_source);

			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
		}

		if ($object->type != 2)
		{
			$posy+=5;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'L');
		}

		if ($object->client->code_client)
		{
			$posy+=4;
			$pdf->SetXY($this->marges['g'],$posy);
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'L');
		}

		// Add list of linked orders and proposals
		// TODO mutualiser
	    $object->fetchObjectLinked();

	    foreach($object->linkedObjects as $objecttype => $objects)
	    {
	    	if ($objecttype == 'propal')
	    	{
	    		$outputlangs->load('propal');
	    		$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY($this->marges['g'],$posy);
	    			$pdf->SetFont('','', $default_font_size - 1);
	    			$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref));
	    		}
			}
			else if ($objecttype == 'commande')
			{
				$num=sizeof($objects);
	    		for ($i=0;$i<$num;$i++)
	    		{
	    			$posy+=4;
	    			$pdf->SetXY($this->marges['g'],$posy);
					$pdf->SetFont('','', $default_font_size - 1);
					$text=$objects[$i]->ref;
					if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
					$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text));
	    		}
			}
		}

		// Amount in (at tab_top - 1)
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('','', $default_font_size);
		$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie));
        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), 90);
        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
	}
Example #12
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $outputlangs->load("companies");
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     if ($conf->global->MAIN_INFO_SOCIETE_NOM) {
         $pdf->SetTextColor(0, 0, 200);
         $pdf->SetFont('', 'B', $default_font_size + 2);
         $pdf->MultiCell(76, 4, $outputlangs->convToOutputCharset(MAIN_INFO_SOCIETE_NOM), 0, 'L');
     }
     // Sender properties
     $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
     $pdf->SetFont('', '', $default_font_size - 1);
     $pdf->SetXY($this->marge_gauche, $posy + 4);
     $pdf->MultiCell(80, 3, $carac_emetteur, 0, 'L');
     /*
      * Adresse Client
      */
     // If SHIPPING contact defined on invoice, we use it
     $usecontact = false;
     $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
     if (count($arrayidcontact) > 0) {
         $usecontact = true;
         $result = $object->fetch_contact($arrayidcontact[0]);
     }
     // Recipient name
     if (!empty($usecontact)) {
         // On peut utiliser le nom de la societe du contact
         if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
             $socname = $object->contact->socname;
         } else {
             $socname = $object->client->nom;
         }
         $carac_client_name = $outputlangs->convToOutputCharset($socname);
     } else {
         $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
     }
     $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', 'B', $default_font_size + 1);
     $pdf->SetXY(102, 42);
     $pdf->MultiCell(96, 5, $carac_client_name, 0, 'L');
     $pdf->SetFont('', 'B', $default_font_size);
     $pdf->SetXY(102, 47);
     $pdf->MultiCell(96, 5, $carac_client, 0, 'L');
     $pdf->Rect(100, 40, 100, 40);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 1);
     $pdf->SetXY($posx, 86);
     $pdf->MultiCell(100, 2, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery ? $object->date_delivery : $date->valid, "day", false, $outputlangs, true), 0, 'R');
     $pdf->SetXY($posx, 92);
     $pdf->MultiCell(100, 2, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), 0, 'R');
     if ($object->client->code_client) {
         $posy += 7;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetFont('', 'B', $default_font_size - 1);
     // Add origin linked objects
     // TODO extend to other objects
     $object->fetchObjectLinked('', '', $object->id, 'delivery');
     if (!empty($object->linkedObjects)) {
         $outputlangs->load('orders');
         foreach ($object->linkedObjects as $elementtype => $objects) {
             $object->fetchObjectLinked('', '', $objects[0]->id, $objects[0]->element);
             foreach ($object->linkedObjects as $elementtype => $objects) {
                 $num = count($objects);
                 for ($i = 0; $i < $num; $i++) {
                     $order = new Commande($this->db);
                     $result = $order->fetch($objects[$i]->id);
                     if ($result >= 0) {
                         $posy += 5;
                         $pdf->SetXY($posx, $posy);
                         $pdf->SetFont('', '', $default_font_size - 1);
                         $text = $order->ref;
                         if ($order->ref_client) {
                             $text .= ' (' . $order->ref_client . ')';
                         }
                         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
                     }
                 }
             }
         }
     }
 }
Example #13
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @param	object		$hookmanager	Hookmanager object
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
 {
     global $conf, $langs, $mysoc;
     $langs->load("orders");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     if ($showaddress) {
         $posy = 40;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         $pdf->SetXY($posx, $posy + 3);
         // Sender name
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx, $posy + 7);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // Client destinataire
         $client = new Societe($this->db);
         $client->fetch($object->socid);
         $object->client = $client;
         // If CUSTOMER contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
         // Show recipient
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - 100;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, 100, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
     $curY = 80;
     $posy = $curY;
     // Date - order
     $pdf->SetTextColor(200, 0, 0);
     $pdf->SetFont('', 'B', $default_font_size + 1);
     $pdf->SetXY(11, $posy);
     $posy += 6;
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date, 'day', false, $outputlangs), 0, 'L');
     $pdf->SetXY(11, $posy);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order") . " " . $outputlangs->convToOutputCharset($object->ref), 0, 'L');
     $posy += 1;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
 }
Example #14
0
 /**
  *	Show area for the customer to sign
  *
  *	@param	PDF			$pdf            Object PDF
  *	@param  Facture		$object         Object invoice
  *	@param	int			$posy			Position depart
  *	@param	Translate	$outputlangs	Objet langs
  *	@return int							Position pour suite
  */
 function _signature_area(&$pdf, $object, $posy, $outputlangs)
 {
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $tab_top = $posy + 4;
     $tab_hl = 4;
     $pdf->SetFont('', '', $default_font_size - 1);
     $posx = 120;
     $largcol = $this->page_largeur - $this->marge_droite - $posx;
     $useborder = 0;
     $index = 0;
     // Total HT
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetXY($posx, $tab_top + 0);
     $pdf->SetFont('', '', $default_font_size - 2);
     $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1);
     $pdf->SetXY($posx, $tab_top + $tab_hl);
     $pdf->MultiCell($largcol, $tab_hl * 6, '', 1, 'R');
     return $tab_hl * 7;
 }
Example #15
0
 /**
  *   	Show footer of page. Need this->emetteur object
  *
  *   	@param	PDF			$pdf     			PDF
  * 		@param	Object		$object				Object to show
  *      @param	Translate	$outputlangs		Object lang for output
  *      @param	int			$hidefreetext		1=Hide free text
  *      @return	void
  */
 function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
 {
     global $conf;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     //$showdetails=0;
     return pdf_pagefoot($pdf, $outputlangs, 'BANK_CHEQUERECEIPT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
     $paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT';
     $marge_basse = $this->marge_basse;
     $marge_gauche = $this->marge_gauche;
     $page_hauteur = $this->page_hauteur;
     // Line of free text
     $line = !empty($conf->global->{$paramfreetext}) ? $outputlangs->convToOutputCharset($conf->global->{$paramfreetext}) : "";
     $pdf->SetFont('', '', $default_font_size - 3);
     $pdf->SetDrawColor(224, 224, 224);
     // The start of the bottom of this page footer is positioned according to # of lines
     $freetextheight = 0;
     if ($line) {
         //$line="eee<br>\nfd<strong>sf</strong>sdf<br>\nghfghg<br>";
         if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
             $width = 20000;
             $align = 'L';
             // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
             if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
                 $width = 200;
                 $align = 'C';
             }
             $freetextheight = $pdf->getStringHeight($width, $line);
         } else {
             $freetextheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($line, 1, 'UTF-8', 0));
             // New method (works for HTML content)
             //print '<br>'.$freetextheight;exit;
         }
     }
     $marginwithfooter = $marge_basse + $freetextheight;
     $posy = $marginwithfooter + 0;
     if ($line) {
         $pdf->SetXY($dims['lm'], -$posy);
         if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
             $pdf->MultiCell(0, 3, $line, 0, $align, 0);
         } else {
             $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0));
         }
         $posy -= $freetextheight;
     }
     // On positionne le debut du bas de page selon nbre de lignes de ce bas de page
     /*
     		$nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output);
     		//print 'e'.$line.'t'.dol_nboflines($line);exit;
     		$posy=$marge_basse + ($nbofline*3);
     
     		if ($line)	// Free text
     		{
     			$pdf->SetXY($marge_gauche,-$posy);
     			$pdf->MultiCell(20000, 3, $line, 0, 'L', 0);	// Use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
     			$posy-=($nbofline*3);	// 6 of ligne + 3 of MultiCell
     		}*/
     $pdf->SetY(-$posy);
     $pdf->line($marge_gauche, $page_hauteur - $posy, 200, $page_hauteur - $posy);
     $posy--;
     /*if ($line1)
     		{
     			$pdf->SetXY($marge_gauche,-$posy);
     			$pdf->MultiCell(200, 2, $line1, 0, 'C', 0);
     		}
     
     		if ($line2)
     		{
     			$posy-=3;
     			$pdf->SetXY($marge_gauche,-$posy);
     			$pdf->MultiCell(200, 2, $line2, 0, 'C', 0);
     		}*/
     // Show page nb only on iso languages (so default Helvetica font)
     if (pdf_getPDFFont($outputlangs) == 'Helvetica') {
         $pdf->SetXY(-20, -$posy);
         $pdf->MultiCell(11, 2, $pdf->PageNo() . '/' . $pdf->getAliasNbPages(), 0, 'R', 0);
     }
 }
 /**
  *   	Show footer of page. Need this->emetteur object
  *
  *   	@param	PDF			&$pdf     			PDF
  * 		@param	Object		$object				Object to show
  *      @param	Translate	$outputlangs		Object lang for output
  *      @param	int			$hidefreetext		1=Hide free text
  *      @return	void
  */
 function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
 {
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $pdf->SetFont('', '', $default_font_size - 2);
     $pdf->SetY(-23);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
     $pdf->SetY(-13);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
     $pdf->SetXY(120, -23);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
     // Show page nb only on iso languages (so default Helvetica font)
     //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
     //{
     //    $pdf->SetXY(-10,-10);
     //    $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
     //}
 }
Example #17
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("orders");
     $outputlangs->load("companies");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     // Do not add the BACKGROUND as this is for suppliers
     //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     /*
     		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
     		if ($mysoc->logo)
     		{
     			if (is_readable($logo))
     			{
     			    $height=pdf_getHeightForLogo($logo);
     			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
     			}
     			else
     			{
     				$pdf->SetTextColor(200,0,0);
     				$pdf->SetFont('','B', $default_font_size - 2);
     				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
     				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
     			}
     		}
     		else
     		{*/
     $text = $this->emetteur->name;
     $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     //}
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SupplierInvoice") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     if ($object->ref_supplier) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier") . " : " . $object->ref_supplier, '', 'R');
     }
     $posy += 6;
     $pdf->SetXY($posx, $posy);
     if ($object->date) {
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
     } else {
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
     }
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Show sender information
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($this->emetteur->name, 44) * 4);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // If BILLING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('internal', 'BILLING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $mysoc->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($mysoc->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, $object->contact, $usecontact, 'target');
         // Show recipient
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - 100;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, 100, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
 }
Example #18
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("propal");
     $outputlangs->load("companies");
     $outputlangs->load("orders");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("InvoiceProForma");
     $pdf->MultiCell(100, 3, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $posy += 1;
     $pdf->SetFont('', '', $default_font_size - 1);
     if ($object->ref_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
     }
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
     $posy += 2;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // If CUSTOMER contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->name;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->name);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 0);
 }
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
     if ($mysoc->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 6;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart") . " : " . dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
     $posy += 6;
     $pdf->SetXY($posx, $posy);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd") . " : " . dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
     $pdf->SetTextColor(0, 0, 60);
 }
 function _showLCR($pdf, $object, $outputlangs, &$TtoGenerate)
 {
     global $db, $conf;
     //Gestion LCR /////////////////////////////////////////////////////////////////////
     $pdf->AddPage();
     $posy = 50;
     $pdf->SetDrawColor(0, 0, 0);
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $nb_facture = count($TtoGenerate);
     foreach ($TtoGenerate as $ii => $ref_piece) {
         $f = new Facture($db);
         $f->fetch('', $ref_piece);
         $f->fetch_thirdparty();
         $object =& $f;
         if (!empty($conf->global->LCR_USE_REST_TO_PAY)) {
             $deja_regle = $object->getSommePaiement();
             $creditnoteamount = $object->getSumCreditNotesUsed();
             $depositsamount = $object->getSumDepositsUsed();
             $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
         } else {
             $resteapayer = price2num($object->total_ttc);
         }
         // ENTETE
         if (!empty($conf->global->LCR_GENERATE_ONE_PER_PAGE_WiTH_ADDRESS)) {
             $this->_pagehead($pdf, $object, 1, $outputlangs);
             $curx = $this->marge_gauche;
             $heightforinfotot = 50;
             // Height reserved to output the info and total part
             $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5;
             // Height reserved to output the free text on last page
             $heightforfooter = $this->marge_basse + 8;
             // Height reserved to output the footer (value include bottom margin)
             $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 10;
             $cury = $bottomlasttab;
             $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(200, 200, 200)));
             $pdf->Line($curx, $cury - 11, $this->page_largeur - $this->marge_droite, $cury - 11);
             $pdf->SetLineStyle(array('dash' => 0, 'color' => array(0, 0, 0)));
         } else {
             $curx = $this->marge_gauche;
             $cury = $posy - 30;
         }
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->writeHTMLCell(53, 20, 10, $cury - 8, $outputlangs->convToOutputCharset('MERCI DE NOUS RETOURNER LA PRESENTE TRAITE SOUS 8 JOURS.'), 0, 1, false, true, 'J', true);
         $pdf->SetFont('', '', $default_font_size - 3);
         $pdf->writeHTMLCell(40, 20, 70, $cury - 8, $outputlangs->convToOutputCharset('Contre cette LETTRE DE CHANGE STIPULEE SANS FRAIS'), 0, 1, false, true, 'J', true);
         $pdf->writeHTMLCell(40, 20, 70, $cury - 3, $outputlangs->convToOutputCharset('Veuillez payer la somme indiquée ci_dessous à l\'ordre de'), 0, 1, false, true, 'J', true);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->writeHTMLCell(20, 20, 115, $cury - 8, $outputlangs->convToOutputCharset($conf->global->MAIN_INFO_SOCIETE_NOM), 0, 1, false, true, 'J', true);
         $pdf->writeHTMLCell(40, 20, 115, $cury - 5, $outputlangs->convToOutputCharset($conf->global->MAIN_INFO_SOCIETE_ADDRESS), 0, 1, false, true, 'J', true);
         $pdf->writeHTMLCell(40, 20, 115, $cury + 1, $outputlangs->convToOutputCharset($conf->global->MAIN_INFO_SOCIETE_ZIP . ' ' . $conf->global->MAIN_INFO_SOCIETE_TOWN), 0, 1, false, true, 'J', true);
         //Affichage code monnaie
         $pdf->SetXY(180, $cury + 1);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
         $pdf->Cell(18, 0, "Code Monnaie", 0, 1, C);
         $pdf->SetXY(180, $cury + 5);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 14);
         $pdf->Cell(18, 0, $outputlangs->trans($conf->currency), 0, 0, C);
         //Affichage lieu / date
         //$town = !empty($this->emetteur->town) ? $this->emetteur->town : $this->emetteur->ville;
         $town = $conf->global->MAIN_INFO_SOCIETE_TOWN;
         $cury += 5;
         $pdf->SetXY(30, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $pdf->Cell(15, 0, "A " . $outputlangs->convToOutputCharset($town) . ", le", 0, 1, 'R');
         // jolie fleche ...
         $curx = 43;
         $cury += 2;
         $largeur_cadre = 5;
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre + 5, $cury);
         $pdf->Line($curx + $largeur_cadre + 5, $cury, $curx + $largeur_cadre + 5, $cury + 2);
         $pdf->Line($curx + $largeur_cadre + 4, $cury + 2, $curx + $largeur_cadre + 6, $cury + 2);
         $pdf->Line($curx + $largeur_cadre + 4, $cury + 2, $curx + $largeur_cadre + 5, $cury + 3);
         $pdf->Line($curx + $largeur_cadre + 6, $cury + 2, $curx + $largeur_cadre + 5, $cury + 3);
         // fin jolie fleche
         //Affichage toute la ligne qui commence par "montant pour controle" ...
         $curx = $this->marge_gauche;
         $cury += 5;
         $hauteur_cadre = 8;
         $largeur_cadre = 27;
         $pdf->SetXY($curx, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
         $pdf->Cell($largeur_cadre, 0, "Montant pour contrôle", 0, 0, C);
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->SetXY($curx, $cury + 4);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $pdf->Cell($largeur_cadre, 0, price($resteapayer), 0, 0, C);
         $curx = $curx + $largeur_cadre + 5;
         $hauteur_cadre = 8;
         $largeur_cadre = 25;
         $pdf->SetXY($curx, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
         $pdf->Cell($largeur_cadre, 0, "Date de création", 0, 0, C);
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->SetXY($curx, $cury + 4);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $pdf->Cell($largeur_cadre, 0, dol_print_date($object->date, "day", false, $outpulangs), 0, 0, C);
         $curx = $curx + $largeur_cadre + 5;
         $hauteur_cadre = 8;
         $largeur_cadre = 25;
         $pdf->SetXY($curx, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
         $pdf->Cell($largeur_cadre, 0, "Echéance", 0, 0, C);
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->SetXY($curx, $cury + 4);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $pdf->Cell($largeur_cadre, 0, dol_print_date($object->date_lim_reglement, "day"), 0, 0, C);
         $curx = $curx + $largeur_cadre + 5;
         $hauteur_cadre = 8;
         $largeur_cadre = 75;
         $pdf->SetXY($curx, $cury - 1);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
         $pdf->Cell($largeur_cadre, 0, "LCR Seulement", 0, 0, C);
         $largeurportioncadre = 30;
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeurportioncadre, $cury + $hauteur_cadre);
         $curx += $largeurportioncadre;
         $pdf->Line($curx, $cury + 2, $curx, $cury + $hauteur_cadre);
         $curx += 10;
         $largeurportioncadre = 6;
         $pdf->Line($curx, $cury + 2, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeurportioncadre, $cury + $hauteur_cadre);
         $curx += $largeurportioncadre;
         $pdf->Line($curx, $cury + 2, $curx, $cury + $hauteur_cadre);
         $curx += 3;
         $largeurportioncadre = 6;
         $pdf->Line($curx, $cury + 2, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeurportioncadre, $cury + $hauteur_cadre);
         $curx += $largeurportioncadre;
         $pdf->Line($curx, $cury + 2, $curx, $cury + $hauteur_cadre);
         $curx += 3;
         $largeurportioncadre = 12;
         $pdf->Line($curx, $cury + 2, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeurportioncadre, $cury + $hauteur_cadre);
         $curx += $largeurportioncadre;
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $curx += 3;
         $hauteur_cadre = 8;
         $largeur_cadre = 30;
         $pdf->SetXY($curx, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
         $pdf->Cell($largeur_cadre, 0, "Montant", 0, 0, C);
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->SetXY($curx, $cury + 4);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $pdf->Cell($largeur_cadre, 0, price($resteapayer), 0, 0, C);
         $cury = $cury + $hauteur_cadre + 3;
         $curx = 20;
         $hauteur_cadre = 6;
         $largeur_cadre = 70;
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury, $curx + $largeur_cadre / 5, $cury);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre / 5, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre * 4 / 5, $cury);
         $pdf->Line($curx + $largeur_cadre, $cury + $hauteur_cadre, $curx + $largeur_cadre * 4 / 5, $cury + $hauteur_cadre);
         $pdf->SetXY($curx, $cury + 1.5);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $pdf->Cell($largeur_cadre, 1, $outputlangs->convToOutputCharset($object->ref), 0, 0, C);
         $curx = $curx + $largeur_cadre + 15;
         $largeur_cadre = 50;
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury, $curx + $largeur_cadre / 5, $cury);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre / 5, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre * 4 / 5, $cury);
         $pdf->Line($curx + $largeur_cadre, $cury + $hauteur_cadre, $curx + $largeur_cadre * 4 / 5, $cury + $hauteur_cadre);
         $pdf->SetXY($curx, $cury + 2);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         // MB leave blank
         //$pdf->Cell($largeur_cadre, 0, "Réf ",0,0,C);
         $curx = $curx + $largeur_cadre + 10;
         $largeur_cadre = 30;
         $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
         $pdf->Line($curx, $cury, $curx + $largeur_cadre / 5, $cury);
         $pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre / 5, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre * 4 / 5, $cury);
         $pdf->Line($curx + $largeur_cadre, $cury + $hauteur_cadre, $curx + $largeur_cadre * 4 / 5, $cury + $hauteur_cadre);
         $pdf->SetXY($curx, $cury + 2);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         // MB leave blank
         //$pdf->Cell($largeur_cadre, 0, "R�f ",0,0,C);
         // RIB client
         $cury = $cury + $hauteur_cadre + 3;
         $largeur_cadre = 70;
         $hauteur_cadre = 6;
         $sql = "SELECT rib.fk_soc, rib.domiciliation, rib.code_banque, rib.code_guichet, rib.number, rib.cle_rib";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe_rib as rib";
         $sql .= " WHERE rib.fk_soc = " . $object->client->id;
         $sql .= ' ORDER BY default_rib DESC LIMIT 1';
         // On veux en priorité le RIB par défaut si jamais on tombe sur le cas de +sieurs RIB mais pas de default alors on en prend qu'un
         $resql = $this->db->query($sql);
         if ($resql) {
             $num = $this->db->num_rows($resql);
             $i = 0;
             while ($i <= $num) {
                 $cpt = $this->db->fetch_object($resql);
                 $curx = $this->marge_gauche;
                 $pdf->Line($curx, $cury, $curx + $largeur_cadre, $cury);
                 $pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
                 $pdf->Line($curx + 22, $cury, $curx + 22, $cury + $hauteur_cadre - 2);
                 $pdf->Line($curx + 35, $cury, $curx + 35, $cury + $hauteur_cadre - 2);
                 $pdf->Line($curx + 60, $cury, $curx + 60, $cury + $hauteur_cadre - 2);
                 $pdf->Line($curx + 70, $cury, $curx + 70, $cury + $hauteur_cadre);
                 $pdf->SetXY($curx + 5, $cury + $hauteur_cadre - 4);
                 $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
                 if ($cpt->code_banque && $cpt->code_guichet && $cpt->number && $cpt->cle_rib) {
                     $pdf->Cell($largeur_cadre, 1, $cpt->code_banque . "             " . $cpt->code_guichet . "         " . $cpt->number . "        " . $cpt->cle_rib, 0, 0, L);
                 }
                 $pdf->SetXY($curx, $cury + $hauteur_cadre - 1);
                 $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 6);
                 $pdf->Cell($largeur_cadre, 1, "Code établissement    Code guichet           N° de compte            Cl RIB", 0, 0, L);
                 $curx = 150;
                 $largeur_cadre = 55;
                 $pdf->SetXY($curx, $cury - 1);
                 $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 6);
                 $pdf->Cell($largeur_cadre, 1, "Domiciliation bancaire", 0, 0, C);
                 $pdf->SetXY($curx, $cury + 2);
                 $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
                 if ($cpt->domiciliation) {
                     $pdf->Cell($largeur_cadre, 5, $outputlangs->convToOutputCharset($cpt->domiciliation), 1, 0, C);
                 }
                 $i++;
             }
         }
         //
         $cury = $cury + $hauteur_cadre + 3;
         $curx = $this->marge_gauche;
         $largeur_cadre = 20;
         $pdf->SetXY($curx, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 6);
         $pdf->Cell($largeur_cadre, 1, "Acceptation ou aval", 0, 0, L);
         // jolie fl�che ...
         $cury += 2;
         $pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre + 5, $cury);
         $pdf->Line($curx + $largeur_cadre + 5, $cury, $curx + $largeur_cadre + 5, $cury + 2);
         $pdf->Line($curx + $largeur_cadre + 4, $cury + 2, $curx + $largeur_cadre + 6, $cury + 2);
         $pdf->Line($curx + $largeur_cadre + 4, $cury + 2, $curx + $largeur_cadre + 5, $cury + 3);
         $pdf->Line($curx + $largeur_cadre + 6, $cury + 2, $curx + $largeur_cadre + 5, $cury + 3);
         // fin jolie fl�che
         //Coordonn�es du tir�
         $curx += 50;
         $largeur_cadre = 20;
         $hauteur_cadre = 6;
         $pdf->SetXY($curx, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 6);
         $pdf->MultiCell($largeur_cadre, $hauteur_cadre, "Nom\n et Adresse\n du tiré", 0, R);
         $pdf->SetXY($curx + $largeur_cadre + 2, $cury - 0.5);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $arrayidcontact = $object->getIdContact('external', 'BILLING');
         $carac_client = $outputlangs->convToOutputCharset($object->client->nom);
         $carac_client .= "\n" . $outputlangs->convToOutputCharset(!empty($object->client->address) ? $object->client->address : $object->client->adresse);
         $carac_client .= "\n" . $outputlangs->convToOutputCharset(!empty($object->client->zip) ? $object->client->zip : $object->client->cp) . " " . $outputlangs->convToOutputCharset(!empty($object->client->town) ? $object->client->town : $object->client->ville) . "\n";
         $pdf->MultiCell($largeur_cadre * 2.5, $hauteur_cadre, $carac_client, 1, C);
         //N� Siren
         $pdf->SetXY($curx, $cury + 16);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 6);
         $pdf->MultiCell($largeur_cadre, 4, "N° SIREN du tiré", 0, R);
         $pdf->SetXY($curx + $largeur_cadre + 2, $cury + 15.5);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
         $pdf->MultiCell($largeur_cadre * 2.5, 4, $outputlangs->convToOutputCharset(empty($object->client->siren) ? $object->client->idprof1 : $object->client->siren), 1, C);
         //signature du tireur
         $pdf->SetXY($curx + $largeur_cadre * 5, $cury);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 6);
         $pdf->MultiCell($largeur_cadre * 2, 4, "Signature du tireur", 0, C);
         $pdf->Line(0, $cury + 40, $this->page_largeur, $cury + 40);
         $pdf->SetXY($curx + 100, $cury + 36);
         $pdf->SetFont(pdf_getPDFFont($outputlangs), '', 6);
         $pdf->MultiCell(50, 4, "Ne rien inscrire au dessous de cette ligne", 0, R);
         if (!empty($conf->global->LCR_GENERATE_ONE_PER_PAGE_WiTH_ADDRESS)) {
             // New page
             if ($ii < $nb_facture - 1) {
                 $pdf->AddPage();
             }
         } else {
             $posy += 96;
             $ii++;
             $res_modulo = $ii % 3;
             if ($res_modulo == 0) {
                 $pdf->AddPage();
                 $posy = 50;
             }
         }
     }
     //fin mb ///////////
 }
Example #21
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Project		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
     if ($mysoc->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 6;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart") . " : " . dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
     $posy += 6;
     $pdf->SetXY($posx, $posy);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd") . " : " . dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
     $pdf->SetTextColor(0, 0, 60);
     // Add list of linked objects
     /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
     		$object->fetchObjectLinked();
     
     	    foreach($object->linkedObjects as $objecttype => $objects)
     	    {
     	        var_dump($objects);exit;
     	    	if ($objecttype == 'commande')
     	    	{
     	    		$outputlangs->load('orders');
     	    		$num=count($objects);
     	    		for ($i=0;$i<$num;$i++)
     	    		{
     	    			$posy+=4;
     	    			$pdf->SetXY($posx,$posy);
     	    			$pdf->SetFont('','', $default_font_size - 1);
     	    			$text=$objects[$i]->ref;
     	    			if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
     	    			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
     	    		}
     	    	}
     	    }
             */
 }
 function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 {
     global $conf, $mysoc;
     $sign = 1;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $tab2_top = $posy;
     $tab2_hl = 4;
     $pdf->SetFont('', '', $default_font_size - 1);
     // Tableau total
     $col1x = 120;
     $col2x = 170;
     if ($this->page_largeur < 210) {
         $col2x -= 20;
     }
     $largcol2 = $this->page_largeur - $this->marge_droite - $col2x;
     $useborder = 0;
     $index = 0;
     // Total HT
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetXY($col1x, $tab2_top + 0);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFillColor(224, 224, 224);
     $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
     $pdf->SetXY($col2x, $tab2_top + 0);
     $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
 }
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager, $user;
     $outputlangs->load("main");
     $outputlangs->load("bills");
     $outputlangs->load("propal");
     $outputlangs->load("companies");
     $outputlangs->load("orders");
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $title = $outputlangs->transnoentities("Order");
     $pdf->MultiCell(100, 3, $title, '', 'R');
     $pdf->SetFont('', 'B', $default_font_size);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $posy += 1;
     $pdf->SetFont('', '', $default_font_size - 1);
     if ($object->ref_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
     }
     $posy += 4;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate") . " : " . dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
     $posy += 2;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         //$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         //$pdf->MultiCell(80, 4, $user->id, 0, 'L');
         // if($object->fk_cash == '1' || $object->fk_cash == '2')
         // 	$pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura <br>Aguascalientes, Ags.<br>01(449) 917 3017", 0, 'L');
         // if($object->fk_cash == '3')
         // 	$pdf->MultiCell(80, 4, "Salida a Zacatecas Km. 4.5 <br>Aguascalientes,Ags. <br>01(449) 973 1314", 0, 'L');
         // if($object->fk_cash == '4')
         // 	$pdf->MultiCell(80, 4, "Salida a San Luis Km. 1.9 Fracc. Asturias <br>Aguascalientes, Ags. <br>01(449) 1458210", 0, 'L');
         // if($object->fk_cash == '5' || $object->fk_cash == '6' || $object->fk_cash == '7')
         // 	$pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 <br>San Juan de Los Lagos, Jal.", 0, 'L');
         // if($object->fk_cash == '8')
         // 	$pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 <br>San Juan de Los Lagos, Jal.", 0, 'L');
         // if($object->fk_cash == '9' || $object->fk_cash == '10')
         // 	$pdf->MultiCell(80, 4, "Moreno Valley #199 <br>San Juan de los Lagos, Jal.<br>01(395) 785 3005", 0, 'L');
         if ($user->id == 1) {
             $pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura Aguascalientes, Ags. 01(449) 917 3017", 0, 'L');
         }
         if ($user->id == 2) {
             $pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura Aguascalientes, Ags. 01(449) 917 3017", 0, 'L');
         }
         if ($user->id == 16) {
             $pdf->MultiCell(80, 4, "Quinta Avenida #1001-B Fracc. La Agricultura Aguascalientes, Ags. 01(449) 917 3017", 0, 'L');
         }
         if ($user->id == 5) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 7) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 10) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 11) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 15) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 17) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 21) {
             $pdf->MultiCell(80, 4, "Carr. San Juan –Lagos Km 5.9 San Juan de Los Lagos, Jal.", 0, 'L');
         }
         if ($user->id == 8) {
             $pdf->MultiCell(80, 4, "Moreno Valley #199 San Juan de los Lagos, Jal. 01(395) 785 3005", 0, 'L');
         }
         if ($user->id == 14) {
             $pdf->MultiCell(80, 4, "Moreno Valley #199 San Juan de los Lagos, Jal. 01(395) 785 3005", 0, 'L');
         }
         if ($user->id == 13) {
             $pdf->MultiCell(80, 4, "Salida a Zacatecas Km. 4.5 Aguascalientes,Ags. 01(449) 973 1314", 0, 'L');
         }
         if ($user->id == 23) {
             $pdf->MultiCell(80, 4, "Salida a Zacatecas Km. 4.5 Aguascalientes,Ags. 01(449) 973 1314", 0, 'L');
         }
         if ($user->id == 12) {
             $pdf->MultiCell(80, 4, "Salida a San Luis Km. 1.9 Fracc. Asturias Aguascalientes, Ags. 01(449) 1458210", 0, 'L');
         }
         if ($user->id == 22) {
             $pdf->MultiCell(80, 4, "Salida a San Luis Km. 1.9 Fracc. Asturias Aguascalientes, Ags. 01(449) 1458210", 0, 'L');
         }
         // If CUSTOMER contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 0);
 }
 /**
  *	Output body
  *
  *	@param	PDF			$pdf			PDF object
  *	@param	string		$page			Page
  *	@param	array		$lines			Array of lines
  *	@param	Translate	$outputlangs	Object langs
  *	@return	void
  */
 function Body(&$pdf, $page, $lines, $outputlangs)
 {
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $pdf->SetFont('', '', $default_font_size - 1);
     $oldprowid = 0;
     $pdf->SetFillColor(220, 220, 220);
     $yp = 0;
     $numlines = count($lines);
     for ($j = 0; $j < $numlines; $j++) {
         $i = $j;
         if ($oldprowid != $lines[$j][7]) {
             if ($yp > 200) {
                 $page++;
                 $pdf->AddPage();
                 $this->_pagehead($pdf, $page, 0, $outputlangs);
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $yp = 0;
             }
             $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
             $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
             $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
             $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2] . ' ' . $lines[$j][3], 0, 'L', 1);
             $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
             $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
             $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
             $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
             $yp = $yp + 5;
         }
         // Invoice number
         $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
         $pdf->MultiCell($this->posxinvoiceamount - $this->posxdate, $this->line_height, $lines[$j][0], 0, 'L', 0);
         // Invoice amount
         $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
         $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
         // Payment amount
         $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
         $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
         $yp = $yp + 5;
         if ($oldprowid != $lines[$j][7]) {
             $oldprowid = $lines[$j][7];
         }
     }
 }
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->SENDING_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
     }
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $Xoff = 90;
     $Yoff = 0;
     $tab4_top = 60;
     $tab4_hl = 6;
     $tab4_sl = 4;
     $line = 2;
     //*********************LOGO****************************
     $pdf->SetXY(11, 7);
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, 10, 5, 0, $height * 0.7);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     //*********************Entete****************************
     //Nom du Document
     $pdf->SetXY($Xoff, 7);
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L');
     // Bordereau expedition
     //Num Expedition
     $Yoff = $Yoff + 7;
     $Xoff = 142;
     //$pdf->Rect($Xoff, $Yoff, 85, 8);
     $pdf->SetXY($Xoff, $Yoff);
     $pdf->SetFont('', '', $default_font_size - 2);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending") . ': ' . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
     // Add list of linked elements
     // TODO possibility to use with other elements (business module,...)
     //$object->load_object_linked();
     $origin = $object->origin;
     $origin_id = $object->origin_id;
     // TODO move to external function
     if ($conf->{$origin}->enabled) {
         $outputlangs->load('orders');
         $classname = ucfirst($origin);
         $linkedobject = new $classname($this->db);
         $result = $linkedobject->fetch($origin_id);
         if ($result >= 0) {
             $Yoff = $Yoff + 4;
             $pdf->SetXY($Xoff, $Yoff);
             $pdf->SetFont('', '', $default_font_size - 2);
             $text = $linkedobject->ref;
             if ($linkedobject->ref_client) {
                 $text .= ' (' . $linkedobject->ref_client . ')';
             }
             $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
         }
     }
     //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
     //Definition Emplacement du bloc Societe
     $Xoff = 110;
     $blSocX = 90;
     $blSocY = 24;
     $blSocW = 50;
     $blSocX2 = $blSocW + $blSocX;
     // Sender name
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', 'B', $default_font_size - 3);
     $pdf->SetXY($blSocX, $blSocY + 1);
     $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
     $pdf->SetTextColor(0, 0, 0);
     // Sender properties
     $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
     $pdf->SetFont('', '', $default_font_size - 3);
     $pdf->SetXY($blSocX, $blSocY + 4);
     $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
     if ($object->client->code_client) {
         $Yoff += 7;
         $posy = $Yoff;
         $pdf->SetXY(100, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     //Date Expedition
     $Yoff = $Yoff + 7;
     $pdf->SetXY($blSocX - 80, $blSocY + 20);
     $pdf->SetFont('', 'B', $default_font_size - 2);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
     // Deliverer
     /*$pdf->SetXY($blSocX-80,$blSocY+23);
     		$pdf->SetFont('','', $default_font_size - 2);
     		$pdf->SetTextColor(0,0,0);
     
     		if (! empty($object->tracking_number))
     		{
     			$object->GetUrlTrackingStatus($object->tracking_number);
     			if (! empty($object->tracking_url))
     			{
     				if ($object->shipping_method_id > 0)
     				{
     					// Get code using getLabelFromKey
     					$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
     					$label=$outputlangs->trans("SendingMethod".strtoupper($code))." :";
     				}
     				else
     				{
     					$label=$outputlangs->transnoentities("Deliverer");
     				}
     
     				$pdf->writeHTMLCell(50, 8, '', '', $label." ".$object->tracking_url, '', 'L');
     			}
     		}
     		else
     		{
     			$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
     		}*/
     /**********************************/
     //Emplacement Informations Expediteur (My Company)
     /**********************************/
     $Yoff = $blSocY;
     $blExpX = $Xoff - 20;
     $blW = 52;
     $Ydef = $Yoff;
     $pdf->Rect($blExpX, $Yoff, $blW, 26);
     $object->fetch_thirdparty();
     // If SHIPPING contact defined on order, we use it
     $usecontact = false;
     $arrayidcontact = $object->{$origin}->getIdContact('external', 'SHIPPING');
     if (count($arrayidcontact) > 0) {
         $usecontact = true;
         $result = $object->fetch_contact($arrayidcontact[0]);
     }
     // Recipient name
     if (!empty($usecontact)) {
         // On peut utiliser le nom de la societe du contact
         if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
             $socname = $object->contact->socname;
         } else {
             $socname = $object->client->nom;
         }
         $carac_client_name = $outputlangs->convToOutputCharset($socname);
     } else {
         $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
     }
     $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
     $blDestX = $blExpX + 55;
     $blW = 50;
     $Yoff = $Ydef + 1;
     // Show recipient frame
     $pdf->SetFont('', 'B', $default_font_size - 3);
     $pdf->SetXY($blDestX, $Yoff - 4);
     $pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
     $pdf->Rect($blDestX, $Yoff - 1, $blW, 26);
     // Show recipient name
     $pdf->SetFont('', 'B', $default_font_size - 3);
     $pdf->SetXY($blDestX, $Yoff);
     $pdf->MultiCell($blW, 3, $carac_client_name, 0, 'L');
     // Show recipient information
     $pdf->SetFont('', '', $default_font_size - 3);
     $pdf->SetXY($blDestX, $Yoff + dol_nboflines_bis($carac_client_name, 50) * 4);
     $pdf->MultiCell($blW, 2, $carac_client, 0, 'L');
 }
	/**
	 *   	Show header of document
	 *   	@param      pdf     		Object PDF
	 *   	@param      object			Object commercial proposal
	 *      @param      showaddress     0=no, 1=yes
	 *      @param      outputlangs    	Object lang for output
	 */
	function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
	{
		global $conf,$langs;
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		$outputlangs->load("main");
		$outputlangs->load("bills");
		$outputlangs->load("propal");
		$outputlangs->load("companies");

		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		//Affiche le filigrane brouillon - Print Draft Watermark
		if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
		{
            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
		}

		//Prepare la suite
		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size + 3);

		$posy=$this->marge_haute;

		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
		if ($this->emetteur->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B',$default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
			}
		}
		else
		{
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		}

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

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

		$posy+=6;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');

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

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

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

		$posy+=5;
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');

		if ($object->client->code_client)
		{
			$posy+=5;
			$pdf->SetXY(100,$posy);
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
		}

		if ($showaddress)
		{
			// Sender properties
			$carac_emetteur='';
		 	// Add internal contact of proposal if defined
			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
		 	if (sizeof($arrayidcontact) > 0)
		 	{
		 		$object->fetch_user($arrayidcontact[0]);
		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
		 	}

		 	$carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);

			// Show sender
			$posx=$this->marge_gauche;
			$posy=42;
			$hautcadre=40;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;

			// Show sender frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
			$pdf->SetXY($posx,$posy);
			$pdf->SetFillColor(230,230,230);
			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);

			// Show sender name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetTextColor(0,0,60);
			$pdf->SetFont('','B',$default_font_size);
			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

			// Show sender information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');


			// If CUSTOMER contact defined, we use it
			$usecontact=false;
			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
			if (sizeof($arrayidcontact) > 0)
			{
				$usecontact=true;
				$result=$object->fetch_contact($arrayidcontact[0]);
			}

			// Recipient name
			if (! empty($usecontact))
			{
				// On peut utiliser le nom de la societe du contact
				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
				else $socname = $object->client->nom;
				$carac_client_name=$outputlangs->convToOutputCharset($socname);
			}
			else
			{
				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
			}

			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

			// Show recipient
			$posy=42;
			$posx=100;
			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;

			// Show recipient frame
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($posx,$posy-5);
			$pdf->MultiCell(80, 4, $outputlangs->transnoentities("BillTo").":", 0, 'L');
			$pdf->rect($posx, $posy, 100, $hautcadre);
			$pdf->SetTextColor(0,0,0);

			// Show recipient name
			$pdf->SetXY($posx+2,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

			// Show recipient information
			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($posx+2,$posy+8);
			$pdf->MultiCell(86,4, $carac_client, 0, 'L');
		}
	}
 /**
  *   Affiche la grille des lignes de factures
  *
  *   @param     PDF			$pdf     		Object PDF
  *   @param		int			$tab_top		Tab top
  *   @param		int			$tab_height		Tab height
  *   @param		int			$nexY			next y
  *   @param		Translate	$outputlangs	Output langs
  *   @return	void
  */
 function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
 {
     global $conf;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     // Amount in (at tab_top - 1)
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', '', $default_font_size - 2);
     $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency));
     $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
     $pdf->MultiCell($pdf->GetStringWidth($titre) + 3, 2, $titre);
     $pdf->SetDrawColor(128, 128, 128);
     // Rect prend une longueur en 3eme param
     $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
     // line prend une position y en 3eme param
     $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
     $pdf->SetFont('', '', 8);
     // Accountancy piece
     $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxdesc - $this->posxpiece - 1, 1, '', '', 'R');
     // Comments
     $pdf->line($this->posxdesc - 1, $tab_top, $this->posxdesc - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxdate - $this->posxdesc - 1, 1, $outputlangs->transnoentities("Description"), '', 'L');
     // Date
     $pdf->line($this->posxdate - 1, $tab_top, $this->posxdate - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxdate - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxtype - $this->posxdate - 1, 2, $outputlangs->transnoentities("Date"), '', 'C');
     // Type
     $pdf->line($this->posxtype - 1, $tab_top, $this->posxtype - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxtype - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxprojet - $this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C');
     // Project
     $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxprojet - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C');
     // VAT
     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
         $pdf->SetXY($this->posxtva - 1, $tab_top + 1);
         $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C');
     }
     // Unit price
     $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxup - 1, $tab_top + 1);
     $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C');
     // Quantity
     $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
     $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
     $pdf->MultiCell($this->postotalttc - $this->posxqty, 2, $outputlangs->transnoentities("Qty"), '', 'R');
     // Total with all taxes
     $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
     $pdf->SetXY($this->postotalttc - 1, $tab_top + 1);
     $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R');
     $pdf->SetTextColor(0, 0, 0);
 }
Example #28
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     if ($object->date_valid) {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R');
     } else {
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
         $pdf->SetTextColor(0, 0, 60);
     }
     if ($object->client->code_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetTextColor(0, 0, 60);
     $posy += 2;
     // Add list of linked orders on shipment
     // Currently not supported by pdf_writeLinkedObjects, link for delivery to order is done through shipment)
     if ($object->origin == 'expedition' || $object->origin == 'shipping') {
         $Yoff = $posy - 5;
         include_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
         $shipment = new Expedition($this->db);
         $shipment->fetch($object->origin_id);
         $origin = $shipment->origin;
         $origin_id = $shipment->origin_id;
         if ($conf->{$origin}->enabled) {
             $outputlangs->load('orders');
             $classname = ucfirst($origin);
             $linkedobject = new $classname($this->db);
             $result = $linkedobject->fetch($origin_id);
             if ($result >= 0) {
                 $pdf->SetFont('', '', $default_font_size - 2);
                 $text = $linkedobject->ref;
                 if ($linkedobject->ref_client) {
                     $text .= ' (' . $linkedobject->ref_client . ')';
                 }
                 $Yoff = $Yoff + 8;
                 $pdf->SetXY($this->page_largeur - $this->marge_droite - 100, $Yoff);
                 $pdf->MultiCell(100, 2, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), 0, 'R');
                 $Yoff = $Yoff + 3;
                 $pdf->SetXY($this->page_largeur - $this->marge_droite - 60, $Yoff);
                 $pdf->MultiCell(60, 2, $outputlangs->transnoentities("OrderDate") . " : " . dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
             }
         }
         $posy = $Yoff;
     }
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // Client destinataire
         $posy = 42;
         $posx = 102;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress") . ":", 0, 'L');
         // If SHIPPING contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->name;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->name);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 60);
 }
	/**
	 *   	\brief      Show header of page
	 *    	\param      pdf     		Object PDF
	 *      \param      object          Object invoice
	 *      \param      showadress      0=no, 1=yes
	 *      \param      outputlangs		Object lang for output
	 */
	function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
	{
		global $langs,$conf,$mysoc;

		$outputlangs->load("main");
		$outputlangs->load("bills");
		$outputlangs->load("orders");
		$outputlangs->load("companies");

		$default_font_size = pdf_getPDFFontSize($outputlangs);

		// Do not add the BACKGROUND as this is for suppliers
		//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);

		$pdf->SetTextColor(0,0,60);
		$pdf->SetFont('','B', $default_font_size + 3);

		$posy=$this->marge_haute;

		$pdf->SetXY($this->marge_gauche,$posy);

		// Logo
		/*
		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
		if ($mysoc->logo)
		{
			if (is_readable($logo))
			{
				$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
			}
			else
			{
				$pdf->SetTextColor(200,0,0);
				$pdf->SetFont('','B', $default_font_size - 2);
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
			}
		}
		else
		{*/
			$text=$this->emetteur->name;
			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
		//}

		$pdf->SetFont('','B', $default_font_size + 3);
		$pdf->SetXY(100,$posy);
		$pdf->SetTextColor(0,0,60);
		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '' , 'R');
		$pdf->SetFont('','', $default_font_size + 2);

		$posy+=6;
		$pdf->SetXY(100,$posy);
		if ($object->date)
		{
			$pdf->SetTextColor(0,0,60);
			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
		}
		else
		{
			$pdf->SetTextColor(255,0,0);
			$pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
		}

		if ($showadress)
		{
			// Receive email
			$posy=42;
			$hautcadre=40;
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY($this->marge_gauche,$posy-5);
			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillTo").":",0,"L");


			$pdf->SetXY($this->marge_gauche,$posy);
			$pdf->SetFillColor(230,230,230);
			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);



			// Nom emetteur
			$carac_emetteur_name=$outputlangs->convToOutputCharset($mysoc->name);
			$pdf->SetTextColor(0,0,60);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->SetXY($this->marge_gauche+2,$posy+3);
			$pdf->MultiCell(80, 4, $carac_emetteur_name, 0, 'L');

			// Sender properties
			$carac_emetteur = pdf_build_address($outputlangs,$mysoc);

			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY($this->marge_gauche+2,$posy+8);
			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');

			// Client destinataire
			$posy=42;
			$pdf->SetTextColor(0,0,0);
			$pdf->SetFont('','', $default_font_size - 2);
			$pdf->SetXY(100,$posy-5);
			$pdf->MultiCell(96, 4, $outputlangs->transnoentities("Supplier").":");
			//
			$client = new Societe($this->db);
			$client->fetch($object->socid);
			$object->client = $client;
			//

			// Cadre client destinataire
			$pdf->rect(100, $posy, 100, $hautcadre);

			// Recipient name
			if (! empty($usecontact))
			{
				// On peut utiliser le nom de la societe du contact
				if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
				else $socname = $object->client->nom;
				$carac_client_name=$outputlangs->convToOutputCharset($socname);
			}
			else
			{
				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
			}

			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

			// Show customer/recipient
			$pdf->SetXY(102,$posy+3);
			$pdf->SetFont('','B', $default_font_size);
			$pdf->MultiCell(96,4, $carac_client_name, 0, 'L');

			$pdf->SetFont('','', $default_font_size - 1);
			$pdf->SetXY(102,$posy+8);
			$pdf->MultiCell(96,4, $carac_client, 0, 'L');
		}
	}
Example #30
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @param	object		$hookmanager	Hookmanager object
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
 {
     global $langs, $conf;
     $langs->load("main");
     $langs->load("bills");
     $langs->load("propal");
     $langs->load("companies");
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     //Affiche le filigrane brouillon - Print Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->FACTURE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $pdf->SetXY($this->marges['g'], 6);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $text = $this->emetteur->name;
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
     }
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         // Show sender
         $posy = 30;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // Show sender frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         //$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Show sender information
         $pdf->SetXY($posx + 2, $posy + 8);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // If BILLING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->getIdContact('external', 'BILLING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
         // Show recipient
         $posy = 30;
         $posx = $this->page_largeur - $this->marge_droite - 100;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillTo") . ":", 0, 'L');
         $pdf->Rect($posx, $posy, 100, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(96, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
     /*
      * ref facture
      */
     $posy = 78;
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($this->marges['g'], $posy - 5);
     $pdf->SetTextColor(0, 0, 0);
     $title = $outputlangs->transnoentities("Invoice");
     if ($object->type == 1) {
         $title = $outputlangs->transnoentities("InvoiceReplacement");
     }
     if ($object->type == 2) {
         $title = $outputlangs->transnoentities("InvoiceAvoir");
     }
     if ($object->type == 3) {
         $title = $outputlangs->transnoentities("InvoiceDeposit");
     }
     if ($object->type == 4) {
         $title = $outputlangs->transnoentities("InvoiceProForma");
     }
     $pdf->MultiCell(100, 10, $title . ' ' . $outputlangs->transnoentities("Of") . ' ' . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'L');
     $pdf->SetFont('', 'B', $default_font_size);
     $pdf->SetXY($this->marges['g'], $posy);
     $pdf->SetTextColor(22, 137, 210);
     $pdf->MultiCell(100, 10, $outputlangs->transnoentities("RefBill") . " : " . $outputlangs->transnoentities($object->ref), '', 'L');
     $pdf->SetTextColor(0, 0, 0);
     $objectidnext = $object->getIdReplacingInvoice('validated');
     if ($object->type == 0 && $objectidnext) {
         $objectreplacing = new Facture($this->db);
         $objectreplacing->fetch($objectidnext);
         $posy += 4;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplacing->ref), '', 'L');
     }
     if ($object->type == 1) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 4;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
     }
     if ($object->type == 2) {
         $objectreplaced = new Facture($this->db);
         $objectreplaced->fetch($object->fk_facture_source);
         $posy += 4;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'L');
     }
     $posy += 1;
     if ($object->type != 2) {
         $posy += 3;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance") . " : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'L');
     }
     if ($object->client->code_client) {
         $posy += 3;
         $pdf->SetXY($this->marges['g'], $posy);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'L');
     }
     $posy += 1;
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager);
     // Amount in (at tab_top - 1)
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', '', $default_font_size - 1);
     $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency));
     $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), 90);
     $pdf->MultiCell($pdf->GetStringWidth($titre) + 3, 2, $titre);
 }