/** * 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'); } }
/** * Function to build pdf onto disk * @param object Id of object to generate * @param outputlangs Lang output object * @param srctemplatepath Full path of source filename for generator using a template file * @param hidedetails Do not show line details * @param hidedesc Do not show desc * @param hideref Do not show ref * @return int 1=OK, 0=KO */ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $user,$conf,$langs,$mysoc; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("orders"); $default_font_size = pdf_getPDFFontSize($outputlangs); if ($conf->commande->dir_output) { // Definition of $dir and $file if ($object->specimen) { $dir = $conf->commande->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->commande->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) { if (create_exdir($dir) < 0) { $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); return 0; } } if (file_exists($dir)) { $pdf=pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->Open(); $pagenb=0; $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Order")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")); 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); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); $tab_top = 100; $tab_height = 140; $pdf->SetFillColor(220,220,220); $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY (10, $tab_top + 10 ); $iniY = $pdf->GetY(); $curY = $pdf->GetY(); $nexY = $pdf->GetY(); $nblignes = sizeof($object->lines); for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page // Description de la ligne produit pdf_writelinedesc($pdf,$object,$i,$outputlangs,100,3,30,$curY,1,$hidedesc); //$pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); $ref = pdf_getlineref($object, $i, $outputlangs); $pdf->SetXY (10, $curY); $pdf->MultiCell(20, 3, $ref, 0, 'C'); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY (133, $curY); $pdf->MultiCell(12, 3, $vat_rate, 0, 'C'); $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY (145, $curY); $pdf->MultiCell(10, 3, $qty, 0, 'C'); $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY (156, $curY); $pdf->MultiCell(18, 3, $up_excl_tax, 0, 'R', 0); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY (174, $curY); $pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); $nexY+=2; // Passe espace entre les lignes // cherche nombre de lignes a venir pour savoir si place suffisante if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line { //on recupere la description du produit suivant $follow_descproduitservice = $object->lines[$i+1]->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); } else // If it's last line { $nblineFollowDesc = 0; } if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1)) { $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); $nexY = $tab_top + 8; } } $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $bottomlasttab=$tab_top + $tab_height + 1; // Affiche zone infos $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux $tab2_top = 241; $tab2_lh = 4; $pdf->SetFont('','', $default_font_size); $pdf->SetXY (132, $tab2_top + 0); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalHT"), 0, 'R', 0); $pdf->SetXY (132, $tab2_top + $tab2_lh); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalVAT"), 0, 'R', 0); $pdf->SetXY (132, $tab2_top + ($tab2_lh*2)); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalTTC"), 1, 'R', 1); $pdf->SetXY (174, $tab2_top + 0); $pdf->MultiCell(26, $tab2_lh, price($object->total_ht), 0, 'R', 0); $pdf->SetXY (174, $tab2_top + $tab2_lh); $pdf->MultiCell(26, $tab2_lh, price($object->total_tva), 0, 'R', 0); $pdf->SetXY (174, $tab2_top + ($tab2_lh*2)); $pdf->MultiCell(26, $tab2_lh, price($object->total_ttc), 1, 'R', 1); // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file,'F'); if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); return 1; } } else { $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); return 0; } $this->error=$langs->transnoentities("ErrorUnknown"); return 0; // Erreur par defaut }
/** * 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); }
/** * 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); }
/** * 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'); } }
/** * 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, $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); $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'); } // Show barcode if (!empty($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 (!empty($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 (!empty($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 = $this->page_largeur - 100 - $this->marge_droite; $posy = $this->marge_haute; $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("SendingSheet"); $pdf->MultiCell(100, 4, $title, '', 'R'); $posy += 1; $pdf->SetFont('', '', $default_font_size + 1); $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSending") . " : " . $object->ref, '', 'R'); // Date Expedition $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_creation, "daytext", false, $outputlangs, true), '', 'R'); if (!empty($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'); } $pdf->SetFont('', '', $default_font_size + 3); $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 (!empty($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'); } } if ($showaddress) { // Sender properties $carac_emetteur = ''; // Add internal contact of origin element if defined $arrayidcontact = array(); if (!empty($origin) && is_object($object->{$origin})) { $arrayidcontact = $object->{$origin}->getIdContact('internal', 'SALESREPFOLL'); } 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 $posx = $this->marge_gauche; $posy = 42; $hautcadre = 40; if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { $posx = $this->page_largeur - $this->marge_droite - 80; } // 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'); $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 SHIPPING contact defined, 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, !empty($object->contact) ? $object->contact : null, $usecontact, 'targetwithdetails'); // 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, $posy - 5); $pdf->MultiCell($widthrecbox, 4, $outputlangs->transnoentities("Recipient") . ":", 0, 'L'); $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'); } }
/** * Show footer of page for PDF generation * * @param PDF &$pdf The PDF factory * @param Translate $outputlangs Object lang for output * @param string $paramfreetext Constant name of free text * @param Societe $fromcompany Object company * @param int $marge_basse Margin bottom * @param int $marge_gauche Margin left * @param int $page_hauteur Page height * @param Object $object Object shown in PDF * @param int $showdetails Show company details * @return void */ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0) { global $conf, $user; $outputlangs->load("dict"); $line = ''; // Line of free text if (!empty($conf->global->{$paramfreetext})) { // Make substitution $substitutionarray = array('__FROM_NAME__' => $fromcompany->nom, '__FROM_EMAIL__' => $fromcompany->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, '__TOTAL_VAT__' => $object->total_vat); complete_substitutions_array($substitutionarray, $outputlangs, $object); $newfreetext = make_substitutions($conf->global->{$paramfreetext}, $substitutionarray); $line .= $outputlangs->convToOutputCharset($newfreetext); } // First line of company infos if ($showdetails) { $line1 = ""; // Company name if ($fromcompany->name) { $line1 .= ($line1 ? " - " : "") . $outputlangs->transnoentities("RegisteredOffice") . ": " . $fromcompany->name; } // Address if ($fromcompany->address) { $line1 .= ($line1 ? " - " : "") . $fromcompany->address; } // Zip code if ($fromcompany->zip) { $line1 .= ($line1 ? " - " : "") . $fromcompany->zip; } // Town if ($fromcompany->town) { $line1 .= ($line1 ? " " : "") . $fromcompany->town; } // Phone if ($fromcompany->phone) { $line1 .= ($line1 ? " - " : "") . $outputlangs->transnoentities("Phone") . ": " . $fromcompany->phone; } // Fax if ($fromcompany->fax) { $line1 .= ($line1 ? " - " : "") . $outputlangs->transnoentities("Fax") . ": " . $fromcompany->fax; } $line2 = ""; // URL if ($fromcompany->url) { $line2 .= ($line2 ? " - " : "") . $fromcompany->url; } // Email if ($fromcompany->email) { $line2 .= ($line2 ? " - " : "") . $fromcompany->email; } } // Line 3 of company infos $line3 = ""; // Juridical status if ($fromcompany->forme_juridique_code) { $line3 .= ($line3 ? " - " : "") . $outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); } // Capital if ($fromcompany->capital) { $line3 .= ($line3 ? " - " : "") . $outputlangs->transnoentities("CapitalOf", $fromcompany->capital) . " " . $outputlangs->transnoentities("Currency" . $conf->currency); } // Prof Id 1 if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2)) { $field = $outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code); if (preg_match('/\\((.*)\\)/i', $field, $reg)) { $field = $reg[1]; } $line3 .= ($line3 ? " - " : "") . $field . ": " . $outputlangs->convToOutputCharset($fromcompany->idprof1); } // Prof Id 2 if ($fromcompany->idprof2) { $field = $outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code); if (preg_match('/\\((.*)\\)/i', $field, $reg)) { $field = $reg[1]; } $line3 .= ($line3 ? " - " : "") . $field . ": " . $outputlangs->convToOutputCharset($fromcompany->idprof2); } // Line 4 of company infos $line4 = ""; // Prof Id 3 if ($fromcompany->idprof3) { $field = $outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code); if (preg_match('/\\((.*)\\)/i', $field, $reg)) { $field = $reg[1]; } $line4 .= ($line4 ? " - " : "") . $field . ": " . $outputlangs->convToOutputCharset($fromcompany->idprof3); } // Prof Id 4 if ($fromcompany->idprof4) { $field = $outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code); if (preg_match('/\\((.*)\\)/i', $field, $reg)) { $field = $reg[1]; } $line4 .= ($line4 ? " - " : "") . $field . ": " . $outputlangs->convToOutputCharset($fromcompany->idprof4); } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { $line4 .= ($line4 ? " - " : "") . $outputlangs->transnoentities("VATIntraShort") . ": " . $outputlangs->convToOutputCharset($fromcompany->tva_intra); } $pdf->SetFont('', '', 7); $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 'nbofline='.$nbofline; exit; //print 'e'.$line.'t'.dol_nboflines($line);exit; $posy = $marge_basse + $nbofline * 3 + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); if ($line) { $pdf->SetXY($marge_gauche, -$posy); $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 ($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT) { $width = 200; $align = 'C'; } $pdf->MultiCell($width, 3, $line, 0, $align, 0); $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 (!empty($line1)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($marge_gauche, -$posy); $pdf->MultiCell(200, 2, $line1, 0, 'C', 0); $posy -= 3; $pdf->SetFont('', '', 7); } if (!empty($line2)) { $pdf->SetFont('', 'B', 7); $pdf->SetXY($marge_gauche, -$posy); $pdf->MultiCell(200, 2, $line2, 0, 'C', 0); $posy -= 3; $pdf->SetFont('', '', 7); } if (!empty($line3)) { $pdf->SetXY($marge_gauche, -$posy); $pdf->MultiCell(200, 2, $line3, 0, 'C', 0); } if (!empty($line4)) { $posy -= 3; $pdf->SetXY($marge_gauche, -$posy); $pdf->MultiCell(200, 2, $line4, 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); //print 'xxx'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit; } }
/** * 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); }
/** * testDolNbOfLinesBis * * @return boolean */ public function testDolNbOfLinesBis() { // This is not a html string so nb of lines depends on \n $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; $after=dol_nboflines_bis($input,0); $this->assertEquals($after,3); // This is a html string so nb of lines depends on <br> $input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; $after=dol_nboflines_bis($input,0); $this->assertEquals($after,1); // This is a html string so nb of lines depends on <br> $input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; $after=dol_nboflines_bis($input,0); $this->assertEquals($after,3); return true; }
/** * Fonction generant le projet sur le disque * * @param Project $object Object project a generer * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ function write_file($object, $outputlangs) { global $user, $langs, $conf; if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("projects"); if ($conf->projet->dir_output) { $nblignes = count($object->lines); $default_font_size = pdf_getPDFFontsize($outputlangs); $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->projet->dir_output; if (!preg_match('/specimen/i', $objectref)) { $dir .= "/" . $objectref; } $file = $dir . "/" . $objectref . ".pdf"; if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { $pdf = pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Complete object by loading several other informations $task = new Task($this->db); $tasksarray = $task->getTasksArray(0, 0, $object->id); $object->lines = $tasksarray; $nblignes = count($object->lines); $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Project")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Project")); 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); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 50; $tab_height = 200; $tab_top_newpage = 40; $tab_height_newpage = 210; // Affiche notes if (!empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - ($tab_top - 2); // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Boucle sur les lignes for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; // Description of ligne $ref = $object->lines[$i]->ref; $libelleline = $object->lines[$i]->label; $progress = $object->lines[$i]->progress . '%'; $datestart = dol_print_date($object->lines[$i]->date_start, 'day'); $dateend = dol_print_date($object->lines[$i]->date_end, 'day'); $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetXY($this->posxref, $curY); $pdf->MultiCell(60, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); $pdf->SetXY($this->posxlabel, $curY); $pdf->MultiCell(108, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); $pdf->SetXY($this->posxprogress, $curY); $pdf->MultiCell(16, 3, $progress, 0, 'L'); $pdf->SetXY($this->posxdatestart, $curY); $pdf->MultiCell(20, 3, $datestart, 0, 'L'); $pdf->SetXY($this->posxdateend, $curY); $pdf->MultiCell(20, 3, $dateend, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); $nexY += 2; // Passe espace entre les lignes // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < $nblignes - 1 && empty($hidedesc)) { //on recupere la description du produit suivant $follow_descproduitservice = $object->lines[$i + 1]->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice, 52, $outputlangs->charset_output) * 4; } else { $nblineFollowDesc = 0; } if ($nexY + $nblineFollowDesc > $tab_top + $tab_height && $i < $nblignes - 1) { $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = $tab_top_newpage; $tab_height = $tab_height_newpage; $nexY = $tab_top + 7; } } // Show square $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $bottomlasttab = $tab_top + $tab_height + 1; /* * Pied de page */ $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $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->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); return 0; }
/** * Fonction generant le bon de livraison sur le disque * * @param Object $object Object livraison a generer * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ function write_file($object, $outputlangs) { global $user, $conf, $langs; $default_font_size = pdf_getPDFFontSize($outputlangs); if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("deliveries"); $outputlangs->load("sendings"); if ($conf->expedition->dir_output . "/receipt") { $object->fetch_thirdparty(); $nblines = count($object->lines); $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->expedition->dir_output . "/receipt"; if (!preg_match('/specimen/i', $objectref)) { $dir .= "/" . $objectref; } $file = $dir . "/" . $objectref . ".pdf"; if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { $pdf = pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } // Complete object by loading several other informations $expedition = new Expedition($this->db); $result = $expedition->fetch($object->expedition_id); $commande = new Commande($this->db); if ($expedition->origin == 'commande') { $commande->fetch($expedition->origin_id); } $object->commande = $commande; $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("DeliveryOrder")); 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); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 100; $tab_top_newpage = 50; $tab_height = 140; $tab_height_newpage = 190; $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page // Description de la ligne produit //$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); pdf_writelinedesc($pdf, $object, $i, $outputlangs, 100, 3, 30, $curY, 1); //$pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page $nexY = $pdf->GetY(); $pdf->SetXY(10, $curY); $pdf->MultiCell(20, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'C'); // TODO Field not yet saved in database //$pdf->SetXY(133, $curY ); //$pdf->MultiCell(10, 5, $object->lines[$i]->tva_tx, 0, 'C'); $pdf->SetXY(145, $curY); $pdf->MultiCell(10, 3, $object->lines[$i]->qty_shipped, 0, 'C'); // TODO Field not yet saved in database //$pdf->SetXY(156, $curY ); //$pdf->MultiCell(20, 3, price($object->lines[$i]->price), 0, 'R', 0); // TODO Field not yet saved in database //$pdf->SetXY(174, $curY ); //$total = price($object->lines[$i]->price * $object->lines[$i]->qty_shipped); //$pdf->MultiCell(26, 3, $total, 0, 'R', 0); $pdf->line(10, $curY - 1, 200, $curY - 1); $nexY += 2; // Passe espace entre les lignes // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < $nblines - 1 && empty($hidedesc)) { //on recupere la description du produit suivant $follow_descproduitservice = $object->lines[$i + 1]->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice, 52, $outputlangs->charset_output) * 4; } else { $nblineFollowDesc = 0; } // Test if a new page is required if ($pagenb == 1) { $tab_top_in_current_page = $tab_top; $tab_height_in_current_page = $tab_height; } else { $tab_top_in_current_page = $tab_top_newpage; $tab_height_in_current_page = $tab_height_newpage; } if ($nexY + $nblineFollowDesc > $tab_top_in_current_page + $tab_height_in_current_page && $i < $nblines - 1) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); } $this->_pagefoot($pdf, $object, $outputlangs); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $nexY = $tab_top_newpage + 7; } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $bottomlasttab = $tab_top + $tab_height + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $bottomlasttab = $tab_top_newpage + $tab_height_newpage + 1; } /* * Pied de page */ $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file, 'F'); if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; } } else { $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); return 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); }
/** * 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"); $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"); $pdf->MultiCell(100, 3, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); $posy += 6; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref") . " : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); if ($object->ref_supplier) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier") . " : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); } $posy += 2; $pdf->SetFont('', '', $default_font_size - 1); $posy += 5; $pdf->SetXY($posx, $posy); if (!empty($object->date_commande)) { $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate") . " : " . dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); } else { $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)) { $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned") . " : " . dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R'); } $posy += 5; $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 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'); } }
/** * Fonction generant le bon de livraison sur le disque * * @param Object $object Object livraison a generer * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ function write_file($object, $outputlangs) { global $user, $langs, $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("deliveries"); $outputlangs->load("sendings"); if ($conf->expedition->dir_output . "/receipt") { $object->fetch_thirdparty(); $nblines = count($object->lines); $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->expedition->dir_output . "/receipt"; if (!preg_match('/specimen/i', $objectref)) { $dir .= "/" . $objectref; } $file = $dir . "/" . $objectref . ".pdf"; if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { $pdf = pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } // Complete object by loading several other informations $expedition = new Expedition($this->db); $result = $expedition->fetch($object->expedition_id); $commande = new Commande($this->db); if ($expedition->origin == 'commande') { $commande->fetch($expedition->origin_id); } $object->commande = $commande; $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("DeliveryOrder")); 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); /* // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0 ; $i < $nblignes ; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } } */ // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; $tab_top_newpage = 50; $tab_height = 110; $tab_height_newpage = 150; // Affiche notes if (!empty($object->note_public)) { $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Boucle sur les lignes for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page // Description de la ligne produit //$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); pdf_writelinedesc($pdf, $object, $i, $outputlangs, 108, 3, $this->posxdesc - 1, $curY); //$pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); /* // TVA $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell(10, 4, ($object->lines[$i]->tva_tx < 0 ? '*':'').abs($object->lines[$i]->tva_tx), 0, 'R'); // Prix unitaire HT avant remise $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell(20, 4, price($object->lines[$i]->subprice), 0, 'R', 0); */ // Quantity $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'R'); /* // Remise sur ligne $pdf->SetXY($this->posxdiscount, $curY); if ($object->lines[$i]->remise_percent) { $pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R'); } // Total HT ligne $pdf->SetXY($this->postotalht, $curY); $total = price($object->lines[$i]->price * $object->lines[$i]->qty); $pdf->MultiCell(23, 3, $total, 0, 'R', 0); // Collecte des totaux par valeur de tva // dans le tableau tva["taux"]=total_tva $tvaligne=$object->lines[$i]->price * $object->lines[$i]->qty; if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; $this->tva[ (string) $object->lines[$i]->tva_tx ] += $tvaligne; */ $nexY += 2; // Passe espace entre les lignes // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < $nblines - 1 && empty($hidedesc)) { //on recupere la description du produit suivant $follow_descproduitservice = $object->lines[$i + 1]->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice, 52, $outputlangs->charset_output) * 4; } else { $nblineFollowDesc = 0; } // Test if a new page is required if ($pagenb == 1) { $tab_top_in_current_page = $tab_top; $tab_height_in_current_page = $tab_height; } else { $tab_top_in_current_page = $tab_top_newpage; $tab_height_in_current_page = $tab_height_newpage; } if ($nexY + $nblineFollowDesc > $tab_top_in_current_page + $tab_height_in_current_page && $i < $nblines - 1) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); } $this->_pagefoot($pdf, $object, $outputlangs); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $nexY = $tab_top_newpage + 7; } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $bottomlasttab = $tab_top + $tab_height + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $bottomlasttab = $tab_top_newpage + $tab_height_newpage + 1; } /* * Pied de page */ $this->_pagefoot($pdf, $object, $outputlangs); // Check product remaining to be delivered // TODO doit etre modifie //$waitingDelivery = $object->getRemainingDelivered(); $waitingDelivery = ''; if (is_array($waitingDelivery) & !empty($waitingDelivery)) { $pdf->AddPage('P', 'A4'); $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetY(90); $w = array(40, 100, 50); $header = array($outputlangs->transnoentities('Reference'), $outputlangs->transnoentities('Label'), $outputlangs->transnoentities('Qty')); // Header $num = count($header); for ($i = 0; $i < $num; $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C'); } $pdf->Ln(); // Data foreach ($waitingDelivery as $value) { $pdf->Cell($w[0], 6, $value['ref'], 1, 0, 'L'); $pdf->Cell($w[1], 6, $value['label'], 1, 0, 'L'); $pdf->Cell($w[2], 6, $value['qty'], 1, 1, 'R'); if ($pdf->GetY() > 250) { $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AddPage('P', 'A4'); $pdf->SetFont('', '', $default_font_size - 1); $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetY(40); $num = count($header); for ($i = 0; $i < $num; $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C'); } $pdf->Ln(); } } $this->_pagefoot($pdf, $object, $outputlangs); } $pdf->AliasNbPages(); $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->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); return 0; }
/** * \brief Fonction generant le document sur le disque * \param object Objet expedition a generer (ou id si ancienne methode) * \param outputlangs Lang output object * \return int 1=ok, 0=ko */ function write_file(&$object, $outputlangs) { global $user,$conf,$langs,$mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $object->fetch_thirdparty(); if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("propal"); $outputlangs->load("sendings"); $outputlangs->load("deliveries"); //Generation de la fiche $this->expe = $object; //Verification de la configuration if ($conf->expedition->dir_output) { $object->fetch_thirdparty(); $origin = $object->origin; //Creation de l expediteur $this->expediteur = $mysoc; //Creation du destinataire $idcontact = $object->$origin->getIdContact('external','SHIPPING'); $this->destinataire = new Contact($this->db); if ($idcontact[0]) $this->destinataire->fetch($idcontact[0]); //Creation du livreur $idcontact = $object->$origin->getIdContact('internal','LIVREUR'); $this->livreur = new User($this->db); if ($idcontact[0]) $this->livreur->fetch($idcontact[0]); // Definition de $dir et $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; $file = $dir . "/SPECIMEN.pdf"; } else { $expref = dol_sanitizeFileName($object->ref); $dir = $conf->expedition->dir_output . "/sending/" . $expref; $file = $dir . "/" . $expref . ".pdf"; } if (! file_exists($dir)) { if (create_exdir($dir) < 0) { $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir); return 0; } } //Si le dossier existe if (file_exists($dir)) { $pdf=pdf_getInstance($this->format,'mm','l'); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->Open(); $pagenb=0; $pdf->SetDrawColor(128,128,128); //Generation de l entete du fichier $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Sending")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Sending")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); $pdf->SetMargins(10, 10, 10); $pdf->SetAutoPageBreak(1,0); $pdf->SetFont('','', $default_font_size - 3); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $this->expe, $outputlangs); $pdf->SetFont('','', $default_font_size - 3); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); //Initialisation des coordonnees $tab_top = 53; $tab_height = 70; $pdf->SetFillColor(240,240,240); $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY (10, $tab_top + 5 ); $iniY = $pdf->GetY(); $curY = $pdf->GetY(); $nexY = $pdf->GetY(); //Generation du tableau $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $nblignes = sizeof($object->lines); for ($i = 0 ; $i < $nblignes ; $i++) { // Description de la ligne produit //Creation des cases a cocher $pdf->rect(10+3, $curY+1, 3, 3); $pdf->rect(20+3, $curY+1, 3, 3); //Insertion de la reference du produit $pdf->SetXY (30, $curY+1 ); $pdf->SetFont('','B', $default_font_size - 3); $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0); //Insertion du libelle $pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY (50, $curY+1 ); //$libelleproduitservice=pdf_getlinedesc($object->$origin,$i,$outputlangs); $libelleproduitservice = pdf_writelinedesc($pdf,$object->$origin,$i,$outputlangs,90,3,50,$curY+1,1); //$pdf->writeHTMLCell(90, 3, 50, $curY+1, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 'L', 0); //Insertion de la quantite commandee $pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY (140, $curY+1 ); $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0); //Insertion de la quantite a envoyer $pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY (170, $curY+1 ); $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0); //Generation de la page 2 $curY += (dol_nboflines_bis($libelleproduitservice,0,$outputlangs->charset_output)*3+1); $nexY = $curY; if ($nexY > ($tab_top+$tab_height-10) && $i < $nblignes - 1) { $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $curY = $iniY; // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $this->expe, $outputlangs); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 3); } } //Insertion du pied de page $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file,'F'); if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); return 1; } else { $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir); return 0; } } else { $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR"); return 0; } $this->error=$outputlangs->transnoentities("ErrorUnknown"); return 0; // Erreur par defaut }
/** * 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); } }
/** * 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 * @param object $hookmanager Hookmanager object * @return void */ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) { 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); $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) * 0.8; $pdf->Image($logo, $this->marge_gauche + 5, $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("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, 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 - 2); if ($object->ref_client) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 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(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($posx, $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 += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } $posy += 4; $pdf->SetXY($posx, $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 += 3; $pdf->SetXY($posx, $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 += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); } //Añadido para que muestre el CIF del cliente debajo del Código de Cliente if ($object->client->idprof1) { $posy += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ProfId1ES") . " : " . $outputlangs->transnoentities($object->client->idprof1), '', 'R'); } // $posy += 1; // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); 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 + 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 (!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'); } }
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); $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); $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("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, 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 - 2); if ($object->ref_client) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer") . " : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } 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(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($posx, $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 += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice") . ' : ' . $outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } $posy += 4; $pdf->SetXY($posx, $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 += 3; $pdf->SetXY($posx, $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 += 3; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); } $posy += 1; if ($showaddress) { // Show sender $posy = 40; $posx = $this->marge_gauche; if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { $posx = $this->page_largeur - $this->marge_droite - 80; } $hautcadre = 38; // 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(92, $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(90, 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(90, 4, $carac_emetteur, 0, 'L'); // If BILLING contact defined on invoice, we use it $usecontact = false; // 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, !empty($object->thirdparty) ? $object->thirdparty : $object->client, $usecontact ? $object->contact : '', $usecontact, 'target'); // Show recipient $widthrecbox = 92; if ($this->page_largeur < 210) { $widthrecbox = 84; } // To work with US executive format $posy = 40; $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 $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'); }
/** * Function to build pdf onto disk * @param object Id of object to generate * @param outputlangs Lang output object * @param srctemplatepath Full path of source filename for generator using a template file * @param hidedetails Do not show line details * @param hidedesc Do not show desc * @param hideref Do not show ref * @return int 1=OK, 0=KO */ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $user,$langs,$conf; $default_font_size = pdf_getPDFFontSize($outputlangs); if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO $sav_charset_output=$outputlangs->charset_output; if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("propal"); $outputlangs->load("products"); if ($conf->propale->dir_output) { $object->fetch_thirdparty(); $deja_regle = ""; // Definition de $dir et $file if ($object->specimen) { $dir = $conf->propale->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->propale->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) { if (create_exdir($dir) < 0) { $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); return 0; } } if (file_exists($dir)) { $nblignes = sizeof($object->lines); // Create pdf instance $pdf=pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->Open(); $pagenb=0; $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal")); 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); // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0 ; $i < $nblignes ; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } } // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 4, ''); // Set interline to 4 $pdf->SetTextColor(0,0,0); $tab_top = 90; $tab_top_middlepage = 50; $tab_top_newpage = 50; $tab_height = 130; $tab_height_middlepage = 200; $tab_height_endpage = 170; // Affiche notes if (! empty($object->note_public)) { $tab_top = 88; $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetXY ($this->posxdesc-1, $tab_top); $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset($object->note_public), 0, 'L'); $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } else { $height_note=0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Loop on each lines for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page // Description de la ligne produit $curX = $this->posxdesc-1; pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); // TVA if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY ($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 4, $vat_rate, 0, 'R'); } // Prix unitaire HT avant remise $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY ($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 4, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY ($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $qty, 0, 'R'); // Remise sur ligne $pdf->SetXY ($this->posxdiscount, $curY); if ($object->lines[$i]->remise_percent) { $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, $remise_percent, 0, 'R'); } // Total HT ligne $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY ($this->postotalht, $curY); $pdf->MultiCell(26, 4, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $tvaligne=$object->lines[$i]->total_tva; $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; $vatrate=(string) $object->lines[$i]->tva_tx; $localtax1rate=(string) $object->lines[$i]->localtax1_tx; $localtax2rate=(string) $object->lines[$i]->localtax2_tx; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; $this->tva[$vatrate] += $tvaligne; $this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne; $nexY+=2; // Passe espace entre les lignes // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line { //on recupere la description du produit suivant $follow_descproduitservice = $object->lines[$i+1]->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); } else // If it's last line { $nblineFollowDesc = 0; } // Test if a new page is required if ($pagenb == 1) { $tab_top_in_current_page=$tab_top; $tab_height_in_current_page=$tab_height; } else { $tab_top_in_current_page=$tab_top_newpage; $tab_height_in_current_page=$tab_height_middlepage; } if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs); } $this->_pagefoot($pdf,$object,$outputlangs); // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); $nexY = $tab_top_newpage + 7; } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $bottomlasttab=$tab_top + $tab_height + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_endpage, $nexY, $outputlangs); $bottomlasttab=$tab_top_newpage + $tab_height_endpage + 1; } // Affiche zone infos $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle) { $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file,'F'); if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); // Add external file //$pdfConcat = new concat_pdf(); //$pdfConcat->setFiles(array($file, DOL_DOCUMENT_ROOT."/includes/modules/propale/morefile.pdf")); //$pdfConcat->concat(); //$pdf->AliasNbPages(); //$pdfConcat->Output($file,'F'); $outputlangs->charset_output=$sav_charset_output; return 1; // Pas d'erreur } else { $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); return 0; } } else { $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); return 0; } $this->error=$langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
/** * Function to build pdf onto disk * * @param Object $object Object to generate * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $user, $langs, $conf, $mysoc, $db, $hookmanager; if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("trips"); $outputlangs->load("project"); $nblignes = count($object->lines); if ($conf->expensereport->dir_output) { // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expensereport->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->expensereport->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (isset($object->lignes) && !isset($object->lines)) { $object->lines = $object->lignes; } if (file_exists($dir)) { // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $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) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref_number)); $pdf->SetSubject($outputlangs->transnoentities("Trips")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Trips")); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0; $i < $nblignes; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } } // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 95; $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 95 : 10; $tab_height = 110; $tab_height_newpage = 110; // Show notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { $salereparray = $object->thirdparty->getSalesRepresentatives($user); $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); if (!empty($salerepobj->signature)) { $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } } if ($notetoshow) { $tab_top = 95; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Loop on each lines for ($i = 0; $i < $nblignes; $i++) { $piece_comptable = $i + 1; $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); // Description of product line $curX = $this->posxdesc - 1; $showpricebeforepagebreak = 1; // Accountancy piece $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 1, 3, $this->posxpiece - 1, $curY, $piece_comptable, 0, 1); // Comments $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->posxcomment, $curY); $pdf->writeHTMLCell($this->posxdate - $this->posxdesc - 1, 3, $this->posxdesc - 1, $curY, $object->lines[$i]->comments, 0, 1); //nexY $nexY = $pdf->GetY(); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // Date $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->posxdate, $curY); $pdf->MultiCell($this->posxtype - $this->posxdate - 1, 3, dol_print_date($object->lines[$i]->date, "day", false, $outpulangs), 0, 'C'); // Type $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->posxtype, $curY); $pdf->MultiCell($this->posxprojet - $this->posxtype - 1, 3, $outputlangs->transnoentities($object->lines[$i]->type_fees_code), 0, 'C'); // Project $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->posxprojet, $curY); $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 3, $object->lines[$i]->projet_ref, 0, 'C'); // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R'); } // Unit price $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty - $this->posxup - 1, 3, price($object->lines[$i]->value_unit), 0, 'R'); // Quantity $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->postotalttc - $this->posxqty, 3, $object->lines[$i]->qty, 0, 'C'); // Total with all taxes $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->postotalttc - 1, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R'); $nexY += 5; // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < $nblignes - 1) { //on recupere la description du produit suivant $follow_descproduitservice = $object->lines[$i + 1]->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice, 52, $outputlangs->charset_output) * 4; // Et si on affiche dates de validite, on ajoute encore une ligne if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { $nblineFollowDesc += 4; } } else { $nblineFollowDesc = 0; } $nexY += 2; // Passe espace entre les lignes // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Show total area box $posy = $bottomlasttab + 5; //$nexY+95; $pdf->SetXY(100, $posy); $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); $pdf->SetXY(160, $posy); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R'); $pdf->SetFillColor(248, 248, 248); if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $posy += 5; $pdf->SetXY(100, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalVAT"), 1, 'L'); $pdf->SetXY(160, $posy); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_tva), 1, 'R'); } $posy += 5; $pdf->SetXY(100, $posy); $pdf->SetFont('', 'B', 10); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalTTC"), 1, 'L'); $pdf->SetXY(160, $posy); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ttc), 1, 'R'); // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } $pdf->Close(); $pdf->Output($file, 'F'); // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; // Pas d'erreur } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "EXPENSEREPORT_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
/** * \brief Fonction generant la fiche d'intervention sur le disque * \param fichinter Object fichinter * \param outputlangs Lang output object * \return int 1=ok, 0=ko */ function write_file($fichinter,$outputlangs) { global $user,$langs,$conf,$mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("interventions"); if ($conf->ficheinter->dir_output) { // If $fichinter is id instead of object if (! is_object($fichinter)) { $id = $fichinter; $fichinter = new Fichinter($this->db); $result=$fichinter->fetch($id); if ($result < 0) { dol_print_error($this->db,$fichinter->error); } } $fichinter->fetch_thirdparty(); $fichref = dol_sanitizeFileName($fichinter->ref); $dir = $conf->ficheinter->dir_output; if (! preg_match('/specimen/i',$fichref)) $dir.= "/" . $fichref; $file = $dir . "/" . $fichref . ".pdf"; if (! file_exists($dir)) { if (create_exdir($dir) < 0) { $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir); return 0; } } if (file_exists($dir)) { $pdf=pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->Open(); $pagenb=0; $pdf->SetDrawColor(128,128,128); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetAutoPageBreak(1,0); // New page $pdf->AddPage(); $pagenb++; $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 // Pagehead //Affiche le filigrane brouillon - Print Draft Watermark if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) ) { pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK); } $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'); } } // Nom emetteur $posy=40; $hautcadre=40; $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); $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); // 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+2,$posy+9); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); $object=$fichinter; // 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'); // Client destinataire $pdf->SetTextColor(0,0,0); $pdf->SetFont('','B', $default_font_size); $fichinter->fetch_thirdparty(); $pdf->SetXY(102,42); $pdf->MultiCell(86,4, $carac_client_name, 0, 'L'); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY(102,$pdf->GetY()); $pdf->MultiCell(66,4, $carac_client, 0, 'L'); $pdf->rect(100, 40, 100, 40); $pdf->SetTextColor(0,0,100); $pdf->SetFont('','B', $default_font_size + 2); $pdf->SetXY(10,86); $pdf->MultiCell(120, 4, $outputlangs->transnoentities("InterventionCard")." : ".$outputlangs->convToOutputCharset($fichinter->ref), 0, 'L'); $pdf->SetFillColor(220,220,220); $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size); $tab_top = 100; $tab_top_newpage = 50; $tab_height = 110; $tab_height_newpage = 150; // Affiche notes if (! empty($fichinter->note_public)) { $tab_top = 98; $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetXY ($this->posxdesc-1, $tab_top); $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($fichinter->note_public), 0, 'L'); $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } else { $height_note=0; } $pdf->SetXY (10, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->line(10, $tab_top + 8, 200, $tab_top + 8 ); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetXY (10, $tab_top + 8 ); $desc=dol_htmlentitiesbr($fichinter->description,1); //print $outputlangs->convToOutputCharset($desc); exit; $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1); $nexY = $pdf->GetY(); $pdf->line(10, $nexY, 200, $nexY); $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. //dol_syslog("desc=".dol_htmlentitiesbr($fichinter->description)); $nblignes = sizeof($fichinter->lines); $curY = $pdf->GetY(); $nexY = $pdf->GetY(); // Loop on each lines for ($i = 0 ; $i < $nblignes ; $i++) { $fichinterligne = $fichinter->lines[$i]; $valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0; if ($valide>0) { $curY = $nexY+3; $pdf->SetXY (10, $curY); $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY, dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($fichinterligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration),1,$outputlangs->charset_output), 0, 1, 0); $nexY = $pdf->GetY(); $pdf->SetXY (10, $curY + 3); $desc = dol_htmlentitiesbr($fichinterligne->desc,1); $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY + 3, $desc, 0, 1, 0); $nexY+=dol_nboflines_bis($fichinterligne->desc,52,$outputlangs->charset_output)*3; } } //$pdf->line(10, $tab_top+$tab_height+3, 200, $tab_top+$tab_height+3); // Rectangle for title and all lines $pdf->Rect(10, $tab_top, 190, $tab_height+3); $pdf->SetXY (10, $pdf->GetY() + 20); $pdf->MultiCell(60, 5, '', 0, 'J', 0); $pdf->SetXY(20,220); $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); $pdf->SetXY(20,225); $pdf->MultiCell(80,30, '', 1); $pdf->SetXY(110,220); $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); $pdf->SetXY(110,225); $pdf->MultiCell(80,30, '', 1); $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $this->_pagefoot($pdf,$fichinter,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file,'F'); if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); return 1; } else { $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); return 0; } } else { $this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR"); return 0; } $this->error=$langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }