/**
  *	Function to build pdf onto disk
  *
  *	@param		Object		$object			Object expedition to generate (or id if old method)
  *	@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, $conf, $langs, $hookmanager;
     $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 (!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("propal");
     $outputlangs->load("deliveries");
     $outputlangs->load("sendings");
     if ($conf->expedition->dir_output) {
         // 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 (dol_mkdir($dir) < 0) {
                 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
                 return 0;
             }
         }
         if (file_exists($dir)) {
             $nblignes = count($object->lines);
             $pdf = pdf_getInstance($this->format);
             $default_font_size = pdf_getPDFFontSize($outputlangs);
             $heightforinfotot = 0;
             // 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);
             if (method_exists($pdf, 'AliasNbPages')) {
                 $pdf->AliasNbPages();
             }
             $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
             $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Shipment"));
             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
             // 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 = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10;
             $tab_height = 130;
             $tab_height_newpage = 150;
             if (!empty($object->note_public) || !empty($object->tracking_number) && !empty($object->shipping_method_id)) {
                 $tab_top = 88;
                 $tab_top_alt = $tab_top;
                 // Tracking number
                 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("LinkToTrackYourPackage") . "<br>";
                             $label .= $outputlangs->trans("SendingMethod" . strtoupper($code)) . " :";
                             $pdf->SetFont('', 'B', $default_font_size - 2);
                             $pdf->writeHTMLCell(60, 7, $this->posxdesc - 1, $tab_top - 1, $label . " " . $object->tracking_url, 0, 1, false, true, 'L');
                             $tab_top_alt += 7;
                         }
                     }
                 }
                 // Affiche notes
                 if (!empty($object->note_public)) {
                     $pdf->SetFont('', '', $default_font_size - 1);
                     // Dans boucle pour gerer multi-page
                     $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, 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;
             $num = count($object->lines);
             // Loop on each lines
             for ($i = 0; $i < $num; $i++) {
                 $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 de la ligne produit
                 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxqtyordered - 10, 3, $this->posxdesc, $curY, 0, 1);
                 $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.
                 // We suppose that a too long description is moved completely on next page
                 if ($pageposafter > $pageposbefore) {
                     $pdf->setPage($pageposafter);
                     $curY = $tab_top_newpage;
                 }
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // On repositionne la police par defaut
                 $pdf->SetXY($this->posxqtyordered, $curY);
                 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, 3, $object->lines[$i]->qty_asked, '', 'C');
                 $pdf->SetXY($this->posxqtytoship, $curY);
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxqtytoship, 3, $object->lines[$i]->qty_shipped, '', 'C');
                 // Add line
                 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblignes - 1) {
                     $pdf->setPage($pageposafter);
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(210, 210, 210)));
                     //$pdf->SetDrawColor(190,190,200);
                     $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
                     $pdf->SetLineStyle(array('dash' => 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 (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++;
                 }
             }
             // Show square
             if ($pagenb == 1) {
                 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext - $heightforinfotot, 0, $outputlangs, 0, 0);
                 $bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfreetext - $heightforinfotot + 1;
             } else {
                 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext - $heightforinfotot, 0, $outputlangs, 1, 0);
                 $bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfreetext - $heightforinfotot + 1;
             }
             // Pied de page
             $this->_pagefoot($pdf, $object, $outputlangs);
             if (method_exists($pdf, 'AliasNbPages')) {
                 $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("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     } else {
         $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->transnoentities("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }
Example #2
0
 /**
  *      Create an object to build an HTML area to edit a large string content
  *
  *      @param 	string	$htmlname		        HTML name of WYSIWIG field
  *      @param 	string	$content		        Content of WYSIWIG field
  *      @param	int		$width					Width in pixel of edit area (auto by default)
  *      @param 	int		$height			        Height in pixel of edit area (200px by default)
  *      @param 	string	$toolbarname	        Name of bar set to use ('Full', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_mailings')
  *      @param  string	$toolbarlocation       	Where bar is stored :
  *                       		             	'In' each window has its own toolbar
  *                              		      	'Out:name' share toolbar into the div called 'name'
  *      @param  boolean	$toolbarstartexpanded  	Bar is visible or not at start
  *		@param	int		$uselocalbrowser		Enabled to add links to local object with local browser. If false, only external images can be added in content.
  *      @param  int		$okforextendededitor    True=Allow usage of extended editor tool (like fckeditor)
  *      @param  int		$rows                   Size of rows for textarea tool
  *      @param  int		$cols                   Size of cols for textarea tool
  */
 function DolEditor($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0)
 {
     global $conf, $langs;
     dol_syslog(get_class($this) . "::DolEditor htmlname=" . $htmlname . " toolbarname=" . $toolbarname);
     if (!$rows) {
         $rows = round($height / 20);
     }
     if (!$cols) {
         $cols = $width ? round($width / 6) : 80;
     }
     // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor')
     $defaulteditor = 'ckeditor';
     $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME;
     $this->uselocalbrowser = $uselocalbrowser;
     // Define content and some properties
     if ($this->tool == 'ckeditor') {
         $content = dol_htmlentitiesbr($content);
         // If content is not HTML, we convert to HTML.
     }
     if ($this->tool == 'fckeditor') {
         require_once DOL_DOCUMENT_ROOT . "/includes/fckeditor/fckeditor.php";
         $content = dol_htmlentitiesbr($content);
         // If content is not HTML, we convert to HTML.
         $this->editor = new FCKeditor($htmlname);
         $this->editor->BasePath = DOL_URL_ROOT . '/includes/fckeditor/';
         $this->editor->Value = $content;
         $this->editor->Height = $height;
         if (!empty($width)) {
             $this->editor->Width = $width;
         }
         $this->editor->ToolbarSet = $toolbarname;
         $this->editor->Config['AutoDetectLanguage'] = 'true';
         $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In';
         $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded;
         // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner.
         // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart.
         // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ?
         $modulepart = 'fckeditor';
         $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart=' . $modulepart . '&file=';
         $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT . '/' . $modulepart . '/';
         $this->editor->Config['LinkBrowser'] = $uselocalbrowser ? 'true' : 'false';
         $this->editor->Config['ImageBrowser'] = $uselocalbrowser ? 'true' : 'false';
         if (file_exists(DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/fckeditor/fckconfig.js')) {
             $this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT . '/theme/' . $conf->theme . '/fckeditor/fckconfig.js';
             $this->editor->Config['SkinPath'] = DOL_URL_ROOT . '/theme/' . $conf->theme . '/fckeditor/';
         }
     }
     // Define some properties
     if (in_array($this->tool, array('textarea', 'ckeditor'))) {
         $this->content = $content;
         $this->htmlname = $htmlname;
         $this->toolbarname = $toolbarname;
         $this->toolbarstartexpanded = $toolbarstartexpanded;
         $this->rows = max(ROWS_3, $rows);
         $this->cols = max(40, $cols);
         $this->height = $height;
         $this->width = $width;
     }
 }
 /**
  * Make substitution
  *
  * @param	$object				Adherent Object
  * @return  string      		Value of input text string with substitutions done
  */
 function makeSubstitution($object)
 {
     global $conf, $langs;
     $text = $this->body;
     $birthday = dol_print_date($object->naiss, 'day');
     $msgishtml = 0;
     if (dol_textishtml($text, 1)) {
         $msgishtml = 1;
     }
     $infos = '';
     // Specific for Photo
     $photoName = $object->photo;
     $photoType = $object->_attachments->{$photoName}->content_type;
     $photoBase64 = $object->getFileBase64($object->photo);
     $photo = '<img src="data:' . $PhotoType . ';base64,' . $photoBase64 . '"/>';
     // Substitutions
     $substitutionarray = array('__DOL_MAIN_URL_ROOT__' => DOL_MAIN_URL_ROOT, '__ID__' => $msgishtml ? dol_htmlentitiesbr($object->login) : $object->login, '__CIVILITE__' => $object->getCivilityLabel($msgishtml ? 0 : 1), '__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($object->Firstname) : $object->Firstname, '__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($object->Lastname) : $object->Lastname, '__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($object->getFullName($langs)) : $object->getFullName($langs), '__COMPANY__' => $msgishtml ? dol_htmlentitiesbr($object->societe) : $object->societe, '__ADDRESS__' => $msgishtml ? dol_htmlentitiesbr($object->address) : $object->address, '__ZIP__' => $msgishtml ? dol_htmlentitiesbr($object->zip) : $object->zip, '__TOWN__' => $msgishtml ? dol_htmlentitiesbr($object->town) : $object->town, '__COUNTRY__' => $msgishtml ? dol_htmlentitiesbr($object->country) : $object->country, '__EMAIL__' => $msgishtml ? dol_htmlentitiesbr($object->email) : $object->email, '__NAISS__' => $msgishtml ? dol_htmlentitiesbr($birthday) : $birthday, '__PHOTO__' => $photo, '__LOGIN__' => $msgishtml ? dol_htmlentitiesbr($object->login) : $object->login, '__PASSWORD__' => $msgishtml ? dol_htmlentitiesbr($object->pass) : $object->pass, '__STATUS__' => $object->getLibStatus(), '__INFOS__' => $msgishtml ? dol_htmlentitiesbr($infos) : $infos, '__PRENOM__' => $msgishtml ? dol_htmlentitiesbr($object->Firstname) : $object->Firstname, '__NOM__' => $msgishtml ? dol_htmlentitiesbr($object->Lastname) : $object->Lastname, '__SOCIETE__' => $msgishtml ? dol_htmlentitiesbr($object->societe) : $object->societe, '__ADRESSE__' => $msgishtml ? dol_htmlentitiesbr($object->address) : $object->address, '__CP__' => $msgishtml ? dol_htmlentitiesbr($object->zip) : $object->zip, '__VILLE__' => $msgishtml ? dol_htmlentitiesbr($object->town) : $object->town, '__PAYS__' => $msgishtml ? dol_htmlentitiesbr($object->country) : $object->country);
     complete_substitutions_array($substitutionarray, $langs);
     $this->body = make_substitutions($text, $substitutionarray);
     return 1;
 }
Example #4
0
 /**
  *  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("companies");
     $outputlangs->load("interventions");
     if ($conf->ficheinter->dir_output) {
         $object->fetch_thirdparty();
         // Definition of $dir and $file
         if ($object->specimen) {
             $dir = $conf->ficheinter->dir_output;
             $file = $dir . "/SPECIMEN.pdf";
         } else {
             $objectref = dol_sanitizeFileName($object->ref);
             $dir = $conf->ficheinter->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 (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
             $nblignes = count($object->lines);
             // 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));
             $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("InterventionCard"));
             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
             // New page
             $pdf->AddPage();
             if (!empty($tplidx)) {
                 $pdf->useTemplate($tplidx);
             }
             $pagenb++;
             $this->_pagehead($pdf, $object, 1, $outputlangs);
             $pdf->SetFont('', '', $default_font_size - 1);
             $pdf->SetTextColor(0, 0, 0);
             $tab_top = 90;
             $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10;
             $tab_height = 130;
             $tab_height_newpage = 150;
             // Affiche notes
             $notetoshow = empty($object->note_public) ? '' : $object->note_public;
             if ($notetoshow) {
                 $tab_top = 88;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 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;
             $pdf->SetXY($this->marge_gauche, $tab_top);
             $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Description"), 0, 'L', 0);
             $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
             $pdf->SetFont('', '', $default_font_size - 1);
             $pdf->SetXY($this->marge_gauche, $tab_top + 5);
             $text = $object->description;
             if ($object->duree > 0) {
                 $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
                 $text .= ($text ? ' - ' : '') . $langs->trans("Total") . ": " . $totaltime;
             }
             $desc = dol_htmlentitiesbr($text, 1);
             //print $outputlangs->convToOutputCharset($desc); exit;
             $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
             $nexY = $pdf->GetY();
             $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
             $nblines = count($object->lines);
             // Loop on each lines
             for ($i = 0; $i < $nblines; $i++) {
                 $objectligne = $object->lines[$i];
                 $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
                 if ($valide > 0 || $object->specimen) {
                     $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;
                     // Description of product line
                     $txt = $outputlangs->transnoentities("Date") . " : " . dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true);
                     if ($objectligne->duration > 0) {
                         $txt .= " - " . $outputlangs->transnoentities("Duration") . " : " . convertSecondToTime($objectligne->duration);
                     }
                     $txt = '<strong>' . dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output) . '</strong>';
                     $desc = dol_htmlentitiesbr($objectligne->desc, 1);
                     $pdf->startTransaction();
                     $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt, $desc), 0, 1, 0);
                     $pageposafter = $pdf->getPage();
                     if ($pageposafter > $pageposbefore) {
                         $pdf->rollbackTransaction(true);
                         $pageposafter = $pageposbefore;
                         //print $pageposafter.'-'.$pageposbefore;exit;
                         $pdf->setPageOrientation('', 1, $heightforfooter);
                         // The only function to edit the bottom margin of current page to set it.
                         $pdf->writeHTMLCell(0, 0, $curX, $curY, $txt . '<br>' . $desc, LR, 1, 0);
                         $pageposafter = $pdf->getPage();
                         $posyafter = $pdf->GetY();
                         //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
                         if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) {
                             if ($i == $nblines - 1) {
                                 $pdf->AddPage('', '', true);
                                 if (!empty($tplidx)) {
                                     $pdf->useTemplate($tplidx);
                                 }
                                 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
                                     $this->_pagehead($pdf, $object, 0, $outputlangs);
                                 }
                                 $pdf->setPage($pageposafter + 1);
                             }
                         }
                     } else {
                         $pdf->commitTransaction();
                     }
                     $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.
                     // We suppose that a too long description is moved completely on next page
                     if ($pageposafter > $pageposbefore) {
                         $pdf->setPage($pageposafter);
                         $curY = $tab_top_newpage;
                     }
                     $pdf->SetFont('', '', $default_font_size - 1);
                     // On repositionne la police par defaut
                     // 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;
             }
             $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;
         } 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
 }
Example #5
0
     $var = !$var;
     print "<tr " . $bc[$var] . ">";
     print "<td>";
     $interventionstatic->id = $objp->fichid;
     $interventionstatic->ref = $objp->ref;
     print $interventionstatic->getNomUrl(1);
     print "</td>\n";
     print '<td>';
     $companystatic->name = $objp->name;
     $companystatic->id = $objp->socid;
     $companystatic->client = $objp->client;
     print $companystatic->getNomUrl(1, '', 44);
     print '</td>';
     print '<td>' . dol_htmlentitiesbr(dol_trunc($objp->description, 20)) . '</td>';
     if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
         print '<td>' . dol_htmlentitiesbr(dol_trunc($objp->descriptiondetail, 20)) . '</td>';
         print '<td align="center">' . dol_print_date($db->jdate($objp->dp), 'dayhour') . "</td>\n";
         print '<td align="right">' . convertSecondToTime($objp->duree) . '</td>';
     }
     print '<td align="right">' . $interventionstatic->LibStatut($objp->fk_statut, 5) . '</td>';
     print '<td>&nbsp;</td>';
     print "</tr>\n";
     $total += $objp->duree;
     $i++;
 }
 $rowspan = 3;
 if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
     print '<tr class="liste_total"><td colspan="5" class="liste_total">' . $langs->trans("Total") . '</td>';
     print '<td align="right" class="nowrap liste_total">' . convertSecondToTime($total) . '</td><td>&nbsp;</td><td>&nbsp;</td>';
     print '</tr>';
 }
Example #6
0
 /**
  * Return HTML string to put an output field into a page
  *
  * @param   string	$key            Key of attribute
  * @param   string	$value          Value to show
  * @param	string	$moreparam		To add more parametes on html input tag (only checkbox use html input for output rendering)
  * @return	string					Formated value
  */
 function showOutputField($key, $value, $moreparam = '')
 {
     global $conf, $langs;
     $label = $this->attribute_label[$key];
     $type = $this->attribute_type[$key];
     $size = $this->attribute_size[$key];
     $elementtype = $this->attribute_elementtype[$key];
     $unique = $this->attribute_unique[$key];
     $required = $this->attribute_required[$key];
     $params = $this->attribute_param[$key];
     $perms = $this->attribute_perms[$key];
     $list = $this->attribute_list[$key];
     $showsize = 0;
     if ($type == 'date') {
         $showsize = 10;
         $value = dol_print_date($value, 'day');
     } elseif ($type == 'datetime') {
         $showsize = 19;
         $value = dol_print_date($value, 'dayhour');
     } elseif ($type == 'int') {
         $showsize = 10;
     } elseif ($type == 'double') {
         if (!empty($value)) {
             $value = price($value);
         }
     } elseif ($type == 'boolean') {
         $checked = '';
         if (!empty($value)) {
             $checked = ' checked ';
         }
         $value = '<input type="checkbox" ' . $checked . ' ' . ($moreparam ? $moreparam : '') . ' readonly disabled>';
     } elseif ($type == 'mail') {
         $value = dol_print_email($value);
     } elseif ($type == 'phone') {
         $value = dol_print_phone($value);
     } elseif ($type == 'price') {
         $value = price($value, 0, $langs, 0, 0, -1, $conf->currency);
     } elseif ($type == 'select') {
         $value = $params['options'][$value];
     } elseif ($type == 'sellist') {
         $param_list = array_keys($params['options']);
         $InfoFieldList = explode(":", $param_list[0]);
         $selectkey = "rowid";
         $keyList = 'rowid';
         if (count($InfoFieldList) >= 3) {
             $selectkey = $InfoFieldList[2];
             $keyList = $InfoFieldList[2] . ' as rowid';
         }
         $fields_label = explode('|', $InfoFieldList[1]);
         if (is_array($fields_label)) {
             $keyList .= ', ';
             $keyList .= implode(', ', $fields_label);
         }
         $sql = 'SELECT ' . $keyList;
         $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
         if (strpos($InfoFieldList[4], 'extra') !== false) {
             $sql .= ' as main';
         }
         $sql .= " WHERE " . $selectkey . "='" . $this->db->escape($value) . "'";
         //$sql.= ' AND entity = '.$conf->entity;
         dol_syslog(get_class($this) . ':showOutputField:$type=sellist', LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             $value = '';
             // value was used, so now we reste it to use it to build final output
             $obj = $this->db->fetch_object($resql);
             // Several field into label (eq table:code|libelle:rowid)
             $fields_label = explode('|', $InfoFieldList[1]);
             if (is_array($fields_label) && count($fields_label) > 1) {
                 foreach ($fields_label as $field_toshow) {
                     $translabel = '';
                     if (!empty($obj->{$field_toshow})) {
                         $translabel = $langs->trans($obj->{$field_toshow});
                     }
                     if ($translabel != $field_toshow) {
                         $value .= dol_trunc($translabel, 18) . ' ';
                     } else {
                         $value .= $obj->{$field_toshow} . ' ';
                     }
                 }
             } else {
                 $translabel = '';
                 if (!empty($obj->{$InfoFieldList}[1])) {
                     $translabel = $langs->trans($obj->{$InfoFieldList}[1]);
                 }
                 if ($translabel != $obj->{$InfoFieldList}[1]) {
                     $value = dol_trunc($translabel, 18);
                 } else {
                     $value = $obj->{$InfoFieldList}[1];
                 }
             }
         } else {
             dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
         }
     } elseif ($type == 'radio') {
         $value = $params['options'][$value];
     } elseif ($type == 'checkbox') {
         $value_arr = explode(',', $value);
         $value = '';
         if (is_array($value_arr)) {
             foreach ($value_arr as $keyval => $valueval) {
                 $value .= $params['options'][$valueval] . '<br>';
             }
         }
     } elseif ($type == 'chkbxlst') {
         $value_arr = explode(',', $value);
         $param_list = array_keys($params['options']);
         $InfoFieldList = explode(":", $param_list[0]);
         $selectkey = "rowid";
         $keyList = 'rowid';
         if (count($InfoFieldList) >= 3) {
             $selectkey = $InfoFieldList[2];
             $keyList = $InfoFieldList[2] . ' as rowid';
         }
         $fields_label = explode('|', $InfoFieldList[1]);
         if (is_array($fields_label)) {
             $keyList .= ', ';
             $keyList .= implode(', ', $fields_label);
         }
         $sql = 'SELECT ' . $keyList;
         $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
         if (strpos($InfoFieldList[4], 'extra') !== false) {
             $sql .= ' as main';
         }
         // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
         // $sql.= ' AND entity = '.$conf->entity;
         dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst', LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             $value = '';
             // value was used, so now we reste it to use it to build final output
             while ($obj = $this->db->fetch_object($resql)) {
                 // Several field into label (eq table:code|libelle:rowid)
                 $fields_label = explode('|', $InfoFieldList[1]);
                 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
                     if (is_array($fields_label) && count($fields_label) > 1) {
                         foreach ($fields_label as $field_toshow) {
                             $translabel = '';
                             if (!empty($obj->{$field_toshow})) {
                                 $translabel = $langs->trans($obj->{$field_toshow});
                             }
                             if ($translabel != $field_toshow) {
                                 $value .= dol_trunc($translabel, 18) . '<BR>';
                             } else {
                                 $value .= $obj->{$field_toshow} . '<BR>';
                             }
                         }
                     } else {
                         $translabel = '';
                         if (!empty($obj->{$InfoFieldList}[1])) {
                             $translabel = $langs->trans($obj->{$InfoFieldList}[1]);
                         }
                         if ($translabel != $obj->{$InfoFieldList}[1]) {
                             $value .= dol_trunc($translabel, 18) . '<BR>';
                         } else {
                             $value .= $obj->{$InfoFieldList}[1] . '<BR>';
                         }
                     }
                 }
             }
         } else {
             dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
         }
     } elseif ($type == 'link') {
         $out = '';
         // only if something to display (perf)
         if ($value) {
             $param_list = array_keys($params['options']);
             // 0 : ObjectName
             // 1 : classPath
             $InfoFieldList = explode(":", $param_list[0]);
             dol_include_once($InfoFieldList[1]);
             if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) {
                 $object = new $InfoFieldList[0]($this->db);
                 $object->fetch($value);
                 $value = $object->getNomUrl(3);
             } else {
                 dol_syslog('Error bad setup of extrafield', LOG_WARNING);
                 $out .= 'Error bad setup of extrafield';
             }
         }
     } elseif ($type == 'text') {
         $value = dol_htmlentitiesbr($value);
     } else {
         $showsize = round($size);
         if ($showsize > 48) {
             $showsize = 48;
         }
     }
     //print $type.'-'.$size;
     $out = $value;
     return $out;
 }
Example #7
0
            print !empty($line->description) && $line->description != $line->product_label ? '<br>' . dol_htmlentitiesbr($line->description) : '';
        }
    } else {
        if ($type == 1) {
            $text = img_object($langs->trans('Service'), 'service');
        } else {
            $text = img_object($langs->trans('Product'), 'product');
        }
        if (!empty($line->label)) {
            $text .= ' <strong>' . $line->label . '</strong>';
            echo $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, '', '', $i, 0, !empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '');
        } else {
            if (!empty($line->fk_parent_line)) {
                echo img_picto('', 'rightarrow');
            }
            echo $text . ' ' . dol_htmlentitiesbr($line->description);
        }
        // Show range
        echo get_date_range($line->date_start, $line->date_end, $format);
    }
}
?>
	</td>
	<?php 
if ($object->element == 'supplier_proposal') {
    ?>
		<td class="linecolrefsupplier" align="right"><?php 
    echo $line->ref_fourn;
    ?>
</td>
	<?php 
Example #8
0
     print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
     // Add description in form
     if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
         print !empty($object->lines[$i]->desc) && $object->lines[$i]->desc != $fac->lines[$i]->product_label ? '<br>' . dol_htmlentitiesbr($object->lines[$i]->desc) : '';
     }
     print '</td>';
 } else {
     print '<td>';
     if ($type == 1) {
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     if (!empty($object->lines[$i]->label)) {
         $text .= ' <strong>' . $object->lines[$i]->label . '</strong>';
         print $form->textwithtooltip($text, dol_htmlentitiesbr($object->lines[$i]->desc), 3, '', '', $i);
     } else {
         print $text . ' ' . nl2br($object->lines[$i]->desc);
     }
     // Show range
     print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
     print '</td>';
 }
 print '<td align="right">' . price($object->lines[$i]->price) . '</td>';
 print '<td align="center">' . $object->lines[$i]->remise_percent . ' %</td>';
 print '<td align="center">' . $object->lines[$i]->qty . '</td>';
 if ($conf->global->PRODUCT_USE_UNITS) {
     print "<td align=\"left\">" . $object->lines[$i]->getLabelOfUnit() . "</td>";
 }
 print "</tr>\n";
 $i++;
 /**
  *  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("companies");
     $outputlangs->load("bills");
     $outputlangs->load("products");
     $nblignes = count($object->lines);
     // Loop on each lines to detect if there is at least one image to show
     $realpatharray = array();
     if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) {
         for ($i = 0; $i < $nblignes; $i++) {
             if (empty($object->lines[$i]->fk_product)) {
                 continue;
             }
             $objphoto = new Product($this->db);
             $objphoto->fetch($object->lines[$i]->fk_product);
             $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product . "/photos/";
             $dir = $conf->product->dir_output . '/' . $pdir;
             $realpath = '';
             foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
                 $filename = $obj['photo'];
                 //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
                 $realpath = $dir . $filename;
                 break;
             }
             if ($realpath) {
                 $realpatharray[$i] = $realpath;
             }
         }
     }
     if (count($realpatharray) == 0) {
         $this->posxpicture = $this->posxtva;
     }
     if ($conf->facture->dir_output) {
         $object->fetch_thirdparty();
         $deja_regle = $object->getSommePaiement();
         $amount_credit_notes_included = $object->getSumCreditNotesUsed();
         $amount_deposits_included = $object->getSumDepositsUsed();
         // Definition of $dir and $file
         if ($object->specimen) {
             $dir = $conf->facture->dir_output;
             $file = $dir . "/SPECIMEN.pdf";
         } else {
             $objectref = dol_sanitizeFileName($object->ref);
             $dir = $conf->facture->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 (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
             // Set nblignes with the new facture lines content after hook
             $nblignes = count($object->lines);
             // 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));
             $pdf->SetSubject($outputlangs->transnoentities("Invoice"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Invoice"));
             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++;
                 }
             }
             if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) {
                 $this->posxpicture += $this->postotalht - $this->posxdiscount;
                 $this->posxtva += $this->postotalht - $this->posxdiscount;
                 $this->posxup += $this->postotalht - $this->posxdiscount;
                 $this->posxqty += $this->postotalht - $this->posxdiscount;
                 $this->posxdiscount += $this->postotalht - $this->posxdiscount;
                 //$this->postotalht;
             }
             // Situation invoice handling
             if ($object->situation_cycle_ref) {
                 $this->situationinvoice = True;
                 $progress_width = 14;
                 $this->posxtva -= $progress_width;
                 $this->posxup -= $progress_width;
                 $this->posxqty -= $progress_width;
                 $this->posxdiscount -= $progress_width;
                 $this->posxprogress -= $progress_width;
             }
             // 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 = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10;
             $tab_height = 130;
             $tab_height_newpage = 150;
             // Incoterm
             $height_incoterms = 0;
             if ($conf->incoterm->enabled) {
                 $desc_incoterms = $object->getIncotermsForPDF();
                 if ($desc_incoterms) {
                     $tab_top = 88;
                     $pdf->SetFont('', '', $default_font_size - 1);
                     $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
                     $nexY = $pdf->GetY();
                     $height_incoterms = $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_incoterms + 1);
                     $tab_top = $nexY + 6;
                     $height_incoterms += 4;
                 }
             }
             // Affiche 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 = 88 + $height_incoterms;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 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++) {
                 $curY = $nexY;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // Into loop to work with multipage
                 $pdf->SetTextColor(0, 0, 0);
                 // Define size of image if we need it
                 $imglinesize = array();
                 if (!empty($realpatharray[$i])) {
                     $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
                 }
                 $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();
                 $showpricebeforepagebreak = 1;
                 $posYAfterImage = 0;
                 $posYAfterDescription = 0;
                 // We start with Photo of product line
                 if (isset($imglinesize['width']) && isset($imglinesize['height']) && $curY + $imglinesize['height'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) {
                     $pdf->AddPage('', '', true);
                     if (!empty($tplidx)) {
                         $pdf->useTemplate($tplidx);
                     }
                     if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
                         $this->_pagehead($pdf, $object, 0, $outputlangs);
                     }
                     $pdf->setPage($pageposbefore + 1);
                     $curY = $tab_top_newpage;
                     $showpricebeforepagebreak = 0;
                 }
                 if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
                     $curX = $this->posxpicture - 1;
                     $pdf->Image($realpatharray[$i], $curX + ($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2, $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);
                     // Use 300 dpi
                     // $pdf->Image does not increase value return by getY, so we save it manually
                     $posYAfterImage = $curY + $imglinesize['height'];
                 }
                 // Description of product line
                 $curX = $this->posxdesc - 1;
                 $pdf->startTransaction();
                 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
                 $pageposafter = $pdf->getPage();
                 if ($pageposafter > $pageposbefore) {
                     $pdf->rollbackTransaction(true);
                     $pageposafter = $pageposbefore;
                     //print $pageposafter.'-'.$pageposbefore;exit;
                     $pdf->setPageOrientation('', 1, $heightforfooter);
                     // The only function to edit the bottom margin of current page to set it.
                     pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
                     $pageposafter = $pdf->getPage();
                     $posyafter = $pdf->GetY();
                     //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
                     if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) {
                         if ($i == $nblignes - 1) {
                             $pdf->AddPage('', '', true);
                             if (!empty($tplidx)) {
                                 $pdf->useTemplate($tplidx);
                             }
                             if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
                                 $this->_pagehead($pdf, $object, 0, $outputlangs);
                             }
                             $pdf->setPage($pageposafter + 1);
                         }
                     } else {
                         // We found a page break
                         $showpricebeforepagebreak = 0;
                     }
                 } else {
                     $pdf->commitTransaction();
                 }
                 $posYAfterDescription = $pdf->GetY();
                 $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.
                 // We suppose that a too long description or photo were moved completely on next page
                 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
                     $pdf->setPage($pageposafter);
                     $curY = $tab_top_newpage;
                 }
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // On repositionne la police par defaut
                 // VAT Rate
                 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 - 0.8, 3, $vat_rate, 0, 'R');
                 }
                 // Unit price before discount
                 $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
                 $pdf->SetXY($this->posxup, $curY);
                 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
                 // Quantity
                 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
                 $pdf->SetXY($this->posxqty, $curY);
                 // Enough for 6 chars
                 if ($conf->global->PRODUCT_USE_UNITS) {
                     $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R');
                 } else {
                     $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R');
                 }
                 // Unit
                 if ($conf->global->PRODUCT_USE_UNITS) {
                     $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
                     $pdf->SetXY($this->posxunit, $curY);
                     $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
                 }
                 // Discount on line
                 if ($object->lines[$i]->remise_percent) {
                     $pdf->SetXY($this->posxdiscount - 2, $curY);
                     $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
                     $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
                 }
                 if ($this->situationinvoice) {
                     // Situation progress
                     $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
                     $pdf->SetXY($this->posxprogress, $curY);
                     $pdf->MultiCell($this->postotalht - $this->posxprogress, 3, $progress, 0, 'R');
                 }
                 // Total HT line
                 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
                 $pdf->SetXY($this->postotalht, $curY);
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
                 // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
                 $prev_progress = $object->lines[$i]->get_prev_progress();
                 if ($prev_progress > 0) {
                     if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
                         $tvaligne = $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
                     } else {
                         $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
                     }
                 } else {
                     if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
                         $tvaligne = $object->lines[$i]->multicurrency_total_tva;
                     } else {
                         $tvaligne = $object->lines[$i]->total_tva;
                     }
                 }
                 $localtax1ligne = $object->lines[$i]->total_localtax1;
                 $localtax2ligne = $object->lines[$i]->total_localtax2;
                 $localtax1_rate = $object->lines[$i]->localtax1_tx;
                 $localtax2_rate = $object->lines[$i]->localtax2_tx;
                 $localtax1_type = $object->lines[$i]->localtax1_type;
                 $localtax2_type = $object->lines[$i]->localtax2_type;
                 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;
                 // Retrieve type from database for backward compatibility with old records
                 if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
                     $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
                     $localtax1_type = $localtaxtmp_array[0];
                     $localtax2_type = $localtaxtmp_array[2];
                 }
                 // retrieve global local tax
                 if ($localtax1_type && $localtax1ligne != 0) {
                     $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
                 }
                 if ($localtax2_type && $localtax2ligne != 0) {
                     $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
                 }
                 if (($object->lines[$i]->info_bits & 0x1) == 0x1) {
                     $vatrate .= '*';
                 }
                 if (!isset($this->tva[$vatrate])) {
                     $this->tva[$vatrate] = '';
                 }
                 $this->tva[$vatrate] += $tvaligne;
                 if ($posYAfterImage > $posYAfterDescription) {
                     $nexY = $posYAfterImage;
                 }
                 // Add line
                 if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < $nblignes - 1) {
                     $pdf->setPage($pageposafter);
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
                     //$pdf->SetDrawColor(190,190,200);
                     $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
                     $pdf->SetLineStyle(array('dash' => 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, $object->multicurrency_code);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
                     }
                     $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, $object->multicurrency_code);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
                     }
                     $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, $object->multicurrency_code);
                 $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, $object->multicurrency_code);
                 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 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 || $amount_credit_notes_included || $amount_deposits_included) {
                 $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
             }
             // 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", "FAC_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->trans("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }
Example #10
0
 /**
  * Make substitution
  * @param       text        Text to make substitution to
  * @return      string      Value of input text string with substitutions done
  */
 function makeSubstitution($text)
 {
     global $langs;
     $birthday = dol_print_date($this->naiss, 'day');
     $msgishtml = 0;
     if (dol_textishtml($text, 1)) {
         $msgishtml = 1;
     }
     $infos = '';
     if ($this->civilite_id) {
         $infos .= $langs->transnoentities("UserTitle") . ": " . $this->getCivilityLabel(1) . "\n";
     }
     $infos .= $langs->transnoentities("id") . ": " . $this->id . "\n";
     $infos .= $langs->transnoentities("Lastname") . ": " . $this->nom . "\n";
     $infos .= $langs->transnoentities("Firstname") . ": " . $this->prenom . "\n";
     $infos .= $langs->transnoentities("Company") . ": " . $this->societe . "\n";
     $infos .= $langs->transnoentities("Address") . ": " . $this->adresse . "\n";
     $infos .= $langs->transnoentities("Zip") . ": " . $this->cp . "\n";
     $infos .= $langs->transnoentities("Town") . ": " . $this->ville . "\n";
     $infos .= $langs->transnoentities("Country") . ": " . $this->pays . "\n";
     $infos .= $langs->transnoentities("EMail") . ": " . $this->email . "\n";
     $infos .= $langs->transnoentities("Login") . ": " . $this->login . "\n";
     $infos .= $langs->transnoentities("Password") . ": " . $this->pass . "\n";
     $infos .= $langs->transnoentities("Birthday") . ": " . $birthday . "\n";
     $infos .= $langs->transnoentities("Photo") . ": " . $this->photo . "\n";
     $infos .= $langs->transnoentities("Public") . ": " . yn($this->public);
     // Substitutions
     $substitutionarray = array('%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT, '%ID%' => $msgishtml ? dol_htmlentitiesbr($this->id) : $this->id, '%INFOS%' => $msgishtml ? dol_htmlentitiesbr($infos) : $infos, '%CIVILITE%' => $this->getCivilityLabel($msgishtml ? 0 : 1), '%PRENOM%' => $msgishtml ? dol_htmlentitiesbr($this->prenom) : $this->prenom, '%NOM%' => $msgishtml ? dol_htmlentitiesbr($this->nom) : $this->nom, '%SOCIETE%' => $msgishtml ? dol_htmlentitiesbr($this->societe) : $this->societe, '%ADRESSE%' => $msgishtml ? dol_htmlentitiesbr($this->adresse) : $this->adresse, '%CP%' => $msgishtml ? dol_htmlentitiesbr($this->cp) : $this->cp, '%VILLE%' => $msgishtml ? dol_htmlentitiesbr($this->ville) : $this->ville, '%PAYS%' => $msgishtml ? dol_htmlentitiesbr($this->pays) : $this->pays, '%EMAIL%' => $msgishtml ? dol_htmlentitiesbr($this->email) : $this->email, '%NAISS%' => $msgishtml ? dol_htmlentitiesbr($birthday) : $birthday, '%PHOTO%' => $msgishtml ? dol_htmlentitiesbr($this->photo) : $this->photo, '%LOGIN%' => $msgishtml ? dol_htmlentitiesbr($this->login) : $this->login, '%PASSWORD%' => $msgishtml ? dol_htmlentitiesbr($this->pass) : $this->pass);
     complete_substitutions_array($substitutionarray, $langs);
     return make_substitutions($text, $substitutionarray);
 }
Example #11
0
					$product_static->type=$objp->fk_product_type;
					$product_static->id=$objp->fk_product;
					$product_static->ref=$objp->ref;
					$product_static->libelle=$objp->product_label;
					$text=$product_static->getNomUrl(1);
					$text.= ' - '.$objp->product_label;
					$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
					print $html->textwithtooltip($text,$description,3,'','',$i);

					// Show range
					print_date_range($objp->date_start,$objp->date_end);

					// Add description in form
					if ($conf->global->PRODUIT_DESC_IN_FORM)
					{
						print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
					}
					print '</td>';
				}
				else
				{
					print '<td>';
					print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
					if (($objp->info_bits & 2) == 2)
					{
						print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->socid.'">';
						print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
						print '</a>';
						if ($objp->description)
						{
							if ($objp->description == '(CREDIT_NOTE)')
Example #12
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, $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;
 }
Example #13
0
     if (!$object->email) {
         print $langs->trans("NoEMail");
     } else {
         $adht = new AdherentType($db);
         $adht->fetch($object->typeid);
         $subjecttosend = $object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
         $texttosend = $object->makeSubstitution($adht->getMailOnSubscription());
         $tmp = '<input name="sendmail" type="checkbox"' . (GETPOST('sendmail') ? GETPOST('sendmail') : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')) . '>';
         $helpcontent = '';
         $helpcontent .= '<b>' . $langs->trans("MailFrom") . '</b>: ' . $conf->global->ADHERENT_MAIL_FROM . '<br>' . "\n";
         $helpcontent .= '<b>' . $langs->trans("MailRecipient") . '</b>: ' . $object->email . '<br>' . "\n";
         $helpcontent .= '<b>' . $langs->trans("MailTopic") . '</b>:<br>' . "\n";
         $helpcontent .= $subjecttosend . "\n";
         $helpcontent .= "<br>";
         $helpcontent .= '<b>' . $langs->trans("MailText") . '</b>:<br>';
         $helpcontent .= dol_htmlentitiesbr($texttosend) . "\n";
         print $form->textwithpicto($tmp, $helpcontent, 1, 'help');
     }
     print '</td></tr>';
     print '</tbody>';
     print '</table>';
     dol_fiche_end();
     print '<div class="center">';
     print '<input type="submit" class="button" name="add" value="' . $langs->trans("AddSubscription") . '">';
     print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
     print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
     print '</div>';
     print '</form>';
     print "\n<!-- End form subscription -->\n\n";
 }
 //print '</td></tr>';
/**
 * List sendings and receive receipts
 *
 * @param   string		$origin			Origin ('commande', ...)
 * @param	int			$origin_id		Origin id
 * @param	string		$filter			Filter
 * @return	int							<0 if KO, >0 if OK
 */
function show_list_sending_receive($origin, $origin_id, $filter = '')
{
    global $db, $conf, $langs, $bc;
    global $form;
    $product_static = new Product($db);
    $expedition = new Expedition($db);
    $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end";
    $sql .= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line";
    $sql .= ", e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
    //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
    $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
    $sql .= ' p.description as product_desc';
    $sql .= " FROM " . MAIN_DB_PREFIX . "expeditiondet as ed";
    $sql .= ", " . MAIN_DB_PREFIX . "expedition as e";
    $sql .= ", " . MAIN_DB_PREFIX . $origin . "det as obj";
    //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid  AND obj.rowid = ld.fk_origin_line";
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON obj.fk_product = p.rowid";
    $sql .= " WHERE e.entity = " . $conf->entity;
    $sql .= " AND obj.fk_" . $origin . " = " . $origin_id;
    $sql .= " AND obj.rowid = ed.fk_origin_line";
    $sql .= " AND ed.fk_expedition = e.rowid";
    if ($filter) {
        $sql .= $filter;
    }
    $sql .= " ORDER BY obj.fk_product";
    dol_syslog("show_list_sending_receive sql=" . $sql, LOG_DEBUG);
    $resql = $db->query($sql);
    if ($resql) {
        $num = $db->num_rows($resql);
        $i = 0;
        if ($num) {
            if ($filter) {
                print_titre($langs->trans("OtherSendingsForSameOrder"));
            } else {
                print_titre($langs->trans("SendingsAndReceivingForSameOrder"));
            }
            print '<table class="liste" width="100%">';
            print '<tr class="liste_titre">';
            //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>';
            print '<td align="left">' . $langs->trans("SendingSheet") . '</td>';
            print '<td align="left">' . $langs->trans("Description") . '</td>';
            print '<td align="center">' . $langs->trans("DateCreation") . '</td>';
            print '<td align="center">' . $langs->trans("DateDeliveryPlanned") . '</td>';
            print '<td align="center">' . $langs->trans("QtyShipped") . '</td>';
            if ($conf->livraison_bon->enabled) {
                print '<td>' . $langs->trans("DeliveryOrder") . '</td>';
                //print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
                print '<td align="right">' . $langs->trans("DeliveryDate") . '</td>';
            }
            print "</tr>\n";
            $var = True;
            while ($i < $num) {
                $var = !$var;
                $objp = $db->fetch_object($resql);
                print "<tr " . $bc[$var] . ">";
                // Sending id
                print '<td align="left" class="nowrap"><a href="' . DOL_URL_ROOT . '/expedition/fiche.php?id=' . $objp->expedition_id . '">' . img_object($langs->trans("ShowSending"), 'sending') . ' ' . $objp->exp_ref . '<a></td>';
                // Description
                if ($objp->fk_product > 0) {
                    // Define output language
                    if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
                        $object = new $origin($db);
                        $object->fetch($origin_id);
                        $object->fetch_thirdparty();
                        $prod = new Product($db);
                        $prod->id = $objp->fk_product;
                        $prod->getMultiLangs();
                        $outputlangs = $langs;
                        $newlang = '';
                        if (empty($newlang) && !empty($_REQUEST['lang_id'])) {
                            $newlang = $_REQUEST['lang_id'];
                        }
                        if (empty($newlang)) {
                            $newlang = $object->client->default_lang;
                        }
                        if (!empty($newlang)) {
                            $outputlangs = new Translate("", $conf);
                            $outputlangs->setDefaultLang($newlang);
                        }
                        $label = !empty($prod->multilangs[$outputlangs->defaultlang]["label"]) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
                    } else {
                        $label = !empty($objp->label) ? $objp->label : $objp->product_label;
                    }
                    print '<td>';
                    // Show product and description
                    $product_static->type = $objp->fk_product_type;
                    $product_static->id = $objp->fk_product;
                    $product_static->ref = $objp->ref;
                    $text = $product_static->getNomUrl(1);
                    $text .= ' - ' . $label;
                    $description = !empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description);
                    print $form->textwithtooltip($text, $description, 3, '', '', $i);
                    // Show range
                    print_date_range($objp->date_start, $objp->date_end);
                    // Add description in form
                    if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
                        print !empty($objp->description) && $objp->description != $objp->product ? '<br>' . dol_htmlentitiesbr($objp->description) : '';
                    }
                    print '</td>';
                } else {
                    print "<td>";
                    if ($objp->fk_product_type == 1) {
                        $text = img_object($langs->trans('Service'), 'service');
                    } else {
                        $text = img_object($langs->trans('Product'), 'product');
                    }
                    if (!empty($objp->label)) {
                        $text .= ' <strong>' . $objp->label . '</strong>';
                        print $form->textwithtooltip($text, $objp->description, 3, '', '', $i);
                    } else {
                        print $text . ' ' . nl2br($objp->description);
                    }
                    // Show range
                    print_date_range($objp->date_start, $objp->date_end);
                    print "</td>\n";
                }
                //print '<td align="center">'.$objp->qty_asked.'</td>';
                // Date creation
                print '<td align="center" class="nowrap">' . dol_print_date($db->jdate($objp->date_creation), 'day') . '</td>';
                // Date shipping creation
                print '<td align="center" class="nowrap">' . dol_print_date($db->jdate($objp->date_delivery), 'day') . '</td>';
                // Qty shipped
                print '<td align="center">' . $objp->qty_shipped . '</td>';
                // Informations on receipt
                if (!empty($conf->livraison_bon->enabled)) {
                    include_once DOL_DOCUMENT_ROOT . '/livraison/class/livraison.class.php';
                    $expedition->id = $objp->sendingid;
                    $expedition->fetchObjectLinked($expedition->id, $expedition->element);
                    //var_dump($expedition->linkedObjects);
                    $receiving = !empty($expedition->linkedObjects['delivery'][0]) ? $expedition->linkedObjects['delivery'][0] : '';
                    if (!empty($receiving)) {
                        // $expedition->fk_origin_line = id of det line of order
                        // $receiving->fk_origin_line = id of det line of order
                        // $receiving->origin may be 'shipping'
                        // $receiving->origin_id may be id of shipping
                        // Ref
                        print '<td>';
                        print $receiving->getNomUrl($db);
                        //print '<a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>';
                        print '</td>';
                        // Qty received
                        //print '<td align="center">';
                        // TODO No solution for the moment to link a line det of receipt with a line det of shipping,
                        // so no way to know the qty received for this line of shipping.
                        //print $langs->trans("FeatureNotYetAvailable");
                        //print '</td>';
                        // Date shipping real
                        print '<td align="right">';
                        print dol_print_date($receiving->date_delivery, 'day');
                        print '</td>';
                    } else {
                        //print '<td>&nbsp;</td>';
                        print '<td>&nbsp;</td>';
                        print '<td>&nbsp;</td>';
                    }
                }
                print '</tr>';
                $i++;
            }
            print '</table>';
        }
        $db->free($resql);
    } else {
        dol_print_error($db);
    }
    return 1;
}
Example #15
0
     print '<td>';
     // Affiche ligne produit
     $text = '<a href="' . DOL_URL_ROOT . '/product/card.php?id=' . $object->lines[$i]->fk_product . '">';
     if ($object->lines[$i]->fk_product_type == 1) {
         $text .= img_object($langs->trans('ShowService'), 'service');
     } else {
         $text .= img_object($langs->trans('ShowProduct'), 'product');
     }
     $text .= ' ' . $object->lines[$i]->product_ref . '</a>';
     $text .= ' - ' . $label;
     $description = !empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($object->lines[$i]->description);
     //print $description;
     print $form->textwithtooltip($text, $description, 3, '', '', $i);
     print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
     if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
         print !empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label ? '<br>' . dol_htmlentitiesbr($object->lines[$i]->description) : '';
     }
 } else {
     print "<td>";
     if ($object->lines[$i]->fk_product_type == 1) {
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     if (!empty($object->lines[$i]->label)) {
         $text .= ' <strong>' . $object->lines[$i]->label . '</strong>';
         print $form->textwithtooltip($text, $object->lines[$i]->description, 3, '', '', $i);
     } else {
         print $text . ' ' . nl2br($object->lines[$i]->description);
     }
     print_date_range($objp->date_start, $objp->date_end);
Example #16
0
$toutsujet = explode(",", $object->sujet);
$listofanswers = array();
foreach ($toutsujet as $value) {
    $tmp = explode('@', $value);
    $listofanswers[] = array('label' => $tmp[0], 'format' => $tmp[1] ? $tmp[1] : 'checkbox');
}
$toutsujet = str_replace("°", "'", $toutsujet);
print '<div class="survey_invitation">' . $langs->trans("YouAreInivitedToVote") . '</div>';
print $langs->trans("OpenSurveyHowTo") . '<br><br>';
print '<div class="corps"> ' . "\n";
//affichage du titre du sondage
$titre = str_replace("\\", "", $object->titre);
print '<strong>' . dol_htmlentities($titre) . '</strong><br><br>' . "\n";
//affichage des commentaires du sondage
if ($object->commentaires) {
    print dol_htmlentitiesbr($object->commentaires);
    print '<br>' . "\n";
}
print '</div>' . "\n";
//The survey has expired, users can't vote or do any action
if (!$canbemodified) {
    print '<div style="text-align: center"><p>' . $langs->trans('SurveyExpiredInfo') . '</p></div>';
    llxFooterSurvey();
    $db->close();
    die;
}
print '<form name="formulaire" action="studs.php?sondage=' . $numsondage . '"' . '#bas" method="POST">' . "\n";
print '<input type="hidden" name="sondage" value="' . $numsondage . '"/>';
print '<div class="cadre"> ' . "\n";
print '<br><br>' . "\n";
// Start to show survey result
 /**
  *	Function to build pdf onto disk
  *
  *	@param		Object		&$object			Object expedition to generate (or id if old method)
  *	@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, $conf, $langs, $mysoc, $hookmanager;
     $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 (!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("propal");
     $outputlangs->load("deliveries");
     $outputlangs->load("sendings");
     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 (!empty($idcontact[0])) {
             $this->destinataire->fetch($idcontact[0]);
         }
         //Creation du livreur
         $idcontact = $object->{$origin}->getIdContact('internal', 'LIVREUR');
         $this->livreur = new User($this->db);
         if (!empty($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 (dol_mkdir($dir) < 0) {
                 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
                 return 0;
             }
         }
         if (file_exists($dir)) {
             $nblignes = count($object->lines);
             $pdf = pdf_getInstance($this->format, 'mm', 'l');
             $default_font_size = pdf_getPDFFontSize($outputlangs);
             $heightforinfotot = 0;
             // 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->AliasNbPages();
             $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 (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
                 $pdf->SetCompression(false);
             }
             $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
             // Left, Top, Right
             // New page
             $pdf->AddPage();
             $pagenb++;
             $this->_pagehead($pdf, $object, 1, $outputlangs);
             $pdf->SetFont('', '', $default_font_size - 3);
             $pdf->MultiCell(0, 3, '');
             // Set interline to 3
             $pdf->SetTextColor(0, 0, 0);
             $tab_top = 52;
             $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10;
             $tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
             $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
             // Affiche notes
             if (!empty($object->note_public)) {
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $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;
             }
             $pdf->SetFillColor(240, 240, 240);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetXY(10, $tab_top + 5);
             $iniY = $tab_top + 7;
             $curY = $tab_top + 7;
             $nexY = $tab_top + 7;
             $num = count($object->lines);
             // Loop on each lines
             for ($i = 0; $i < $num; $i++) {
                 $curY = $nexY;
                 $pdf->SetFont('', '', $default_font_size - 3);
                 $pdf->SetTextColor(0, 0, 0);
                 $pdf->setTopMargin($tab_top_newpage);
                 $pdf->setPageOrientation('', 1, $heightforfooter);
                 // The only function to edit the bottom margin of current page to set it.
                 $pageposbefore = $pdf->getPage();
                 // Description de la ligne produit
                 $libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1);
                 $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.
                 // We suppose that a too long description is moved completely on next page
                 if ($pageposafter > $pageposbefore) {
                     $pdf->setPage($pageposafter);
                     $curY = $tab_top_newpage;
                 }
                 $pdf->SetFont('', '', $default_font_size - 3);
                 //Creation des cases a cocher
                 $pdf->Rect(10 + 3, $curY, 3, 3);
                 $pdf->Rect(20 + 3, $curY, 3, 3);
                 //Insertion de la reference du produit
                 $pdf->SetXY(30, $curY);
                 $pdf->SetFont('', 'B', $default_font_size - 3);
                 $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
                 $pdf->SetXY(140, $curY);
                 $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0);
                 $pdf->SetXY(170, $curY);
                 $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
                 // Add line
                 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblignes - 1) {
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(210, 210, 210)));
                     //$pdf->SetDrawColor(190,190,200);
                     $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
                     $pdf->SetLineStyle(array('dash' => 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 - 1, $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 (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 - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
                     }
                     $this->_pagefoot($pdf, $object, $outputlangs, 1);
                     // New page
                     $pdf->AddPage();
                     $pagenb++;
                 }
             }
             // 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 - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
                 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 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 = $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
 }
Example #18
0
     }
     print '</td></tr>';
 }
 // Priority
 print '<tr><td class="nowrap" width="30%">' . $langs->trans("Priority") . '</td><td colspan="3">';
 print $object->priority ? $object->priority : '';
 print '</td></tr>';
 // Object linked
 if (!empty($object->fk_element) && !empty($object->elementtype)) {
     include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     print '<tr><td>' . $langs->trans("LinkedObject") . '</td>';
     print '<td colspan="3">' . dolGetElementUrl($object->fk_element, $object->elementtype, 1) . '</td></tr>';
 }
 // Description
 print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td colspan="3">';
 print dol_htmlentitiesbr($object->note);
 print '</td></tr>';
 // Other attributes
 $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3', 'id' => $object->id);
 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
 // Note that $action and $object may have been modified by hook
 print '</table>';
 //Extra field
 if (empty($reshook) && !empty($extrafields->attribute_label)) {
     print '<br><br><table class="border" width="100%">';
     foreach ($extrafields->attribute_label as $key => $label) {
         if (isset($_POST["options_" . $key])) {
             if (is_array($_POST["options_" . $key])) {
                 // $_POST["options"] is an array but following code expects a comma separated string
                 $value = implode(",", $_POST["options_" . $key]);
             } else {
Example #19
0
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Creditor");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $creditor . '</b>';
 print '<input type="hidden" name="creditor" value="' . $creditor . '">';
 print '</td></tr>' . "\n";
 // Debitor
 $var = !$var;
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("ThirdParty");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $contract->thirdparty->name . '</b>';
 // Object
 $var = !$var;
 $text = '<b>' . $langs->trans("PaymentRenewContractId", $contract->ref, $contractline->ref) . '</b>';
 if ($contractline->fk_product) {
     $text .= '<br>' . $product->ref . ($product->libelle ? ' - ' . $product->libelle : '');
 }
 if ($contractline->description) {
     $text .= '<br>' . dol_htmlentitiesbr($contractline->description);
 }
 //if ($contractline->date_fin_validite) {
 //	$text.='<br>'.$langs->trans("DateEndPlanned").': ';
 //	$text.=dol_print_date($contractline->date_fin_validite);
 //}
 if ($contractline->date_fin_validite) {
     $text .= '<br>' . $langs->trans("ExpiredSince") . ': ' . dol_print_date($contractline->date_fin_validite);
 }
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Designation");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . $text;
 print '<input type="hidden" name="source" value="' . GETPOST("source", 'alpha') . '">';
 print '<input type="hidden" name="ref" value="' . $contractline->ref . '">';
 print '</td></tr>' . "\n";
 // Quantity
 $var = !$var;
Example #20
0
    print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;type=' . $type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete');
}
print '<table border="0" width="100%" class="border">';
// Path of category
print '<tr><td width="20%" class="notopnoleft">';
$ways = $object->print_all_ways();
print $langs->trans("Ref") . '</td><td>';
print '<a href="' . DOL_URL_ROOT . '/categories/index.php?leftmenu=cat&type=' . $type . '">' . $langs->trans("Root") . '</a> >> ';
foreach ($ways as $way) {
    print $way . "<br>\n";
}
print '</td></tr>';
// Description
print '<tr><td class="notopnoleft">';
print $langs->trans("Description") . '</td><td>';
print dol_htmlentitiesbr($object->description);
print '</td></tr>';
// Color
print '<tr><td class="notopnoleft">';
print $langs->trans("Color") . '</td><td>';
print $formother->showColor($object->color);
print '</td></tr>';
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
// Note that $action and $object may have been modified by hook
if (empty($reshook) && !empty($extrafields->attribute_label)) {
    print $object->showOptionals($extrafields);
}
print '</table>';
dol_fiche_end();
/*
 * Boutons actions
Example #21
0
 /**
  *	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 $conf, $hookmanager, $langs, $user;
     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);  // This is set later with array of tasks
         $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)) {
             // 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
             $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));
             // Complete object by loading several other informations
             $task = new Task($this->db);
             $tasksarray = $task->getTasksArray(0, 0, $object->id);
             if (!$object->id > 0) {
                 $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
             }
             $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 (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
                 $pdf->SetCompression(false);
             }
             $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
             // Left, Top, Right
             // 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');
                 $planned_workload = convertSecondToTime($object->lines[$i]->planned_workload, 'allhourmin');
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // Dans boucle pour gerer multi-page
                 $pdf->SetXY($this->posxref, $curY);
                 $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
                 $pdf->SetXY($this->posxlabel, $curY);
                 $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
                 $pdf->SetXY($this->posxworkload, $curY);
                 $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload, 0, 'R');
                 $pdf->SetXY($this->posxprogress, $curY);
                 $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R');
                 $pdf->SetXY($this->posxdatestart, $curY);
                 $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
                 $pdf->SetXY($this->posxdateend, $curY);
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
                 $pageposafter = $pdf->getPage();
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // On repositionne la police par defaut
                 $nexY = $pdf->GetY();
                 // Add line
                 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblignes - 1) {
                     $pdf->setPage($pageposafter);
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80)));
                     //$pdf->SetDrawColor(190,190,200);
                     $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
                     $pdf->SetLineStyle(array('dash' => 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 (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++;
                 }
             }
             // 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;
             }
             /*
              * Pied de page
              */
             $this->_pagefoot($pdf, $object, $outputlangs);
             if (method_exists($pdf, 'AliasNbPages')) {
                 $pdf->AliasNbPages();
             }
             $pdf->Close();
             $pdf->Output($file, 'F');
             // 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('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->transnoentities("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     }
     $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR");
     return 0;
 }
     // Message
     print '<tr><td width="25%" valign="top">' . $langs->trans("MailMessage") . '<br>';
     print '<br><i>' . $langs->trans("CommonSubstitutions") . ':<br>';
     foreach ($object->substitutionarray as $key => $val) {
         print $key . ' = ' . $langs->trans($val) . '<br>';
     }
     print '</i></td>';
     print '<td colspan="3" bgcolor="' . ($object->bgcolor ? (preg_match('/^#/', $object->bgcolor) ? '' : '#') . $object->bgcolor : 'white') . '">';
     if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') {
         $readonly = 1;
         // Editeur wysiwyg
         require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
         $doleditor = new DolEditor('body', $object->body, '', 320, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, 120, $readonly);
         $doleditor->Create();
     } else {
         print dol_htmlentitiesbr($object->body);
     }
     print '</td>';
     print '</tr>';
     print '</table>';
     print "<br>";
 } else {
     /*
      * Mailing en mode edition
      */
     dol_htmloutput_mesg($mesg);
     print '<table class="border" width="100%">';
     // Ref
     print '<tr><td width="25%">' . $langs->trans("Ref") . '</td><td colspan="3">' . $object->id . '</td></tr>';
     // Topic
     print '<tr><td width="25%">' . $langs->trans("MailTitle") . '</td><td colspan="3">' . $object->titre . '</td></tr>';
 /**
  *  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
 }
Example #24
0
/**
 *	Return line ref_supplier
 *
 *	@param	Object		$object				Object
 *	@param	int			$i					Current line number
 *  @param  Translate	$outputlangs		Object langs for output
 *  @param	int			$hidedetails		Hide details (0=no, 1=yes, 2=just special lines)
 * 	@return	string
 */
function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0)
{
    global $hookmanager;
    $reshook = 0;
    $result = '';
    //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
    if (is_object($hookmanager)) {
        $special_code = $object->lines[$i]->special_code;
        if (!empty($object->lines[$i]->fk_parent_line)) {
            $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
        }
        $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code);
        $action = '';
        $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier', $parameters, $object, $action);
        // Note that $action and $object may have been modified by some hooks
        $result .= $hookmanager->resPrint;
    }
    if (empty($reshook)) {
        $result .= dol_htmlentitiesbr($object->lines[$i]->ref_supplier);
    }
    return $result;
}
Example #25
0
 // Ref
 print '<tr><td width="25%" valign="top">' . $langs->trans("Ref") . '</td>';
 print '<td colspan="2">';
 print $form->showrefnav($fgroup, 'id', '', $user->rights->user->user->lire || $user->admin);
 print '</td>';
 print '</tr>';
 // Nom
 print '<tr><td width="25%" valign="top">' . $langs->trans("Name") . '</td>';
 print '<td colspan="2">' . $fgroup->name . '';
 if (!$fgroup->entity) {
     print img_picto($langs->trans("GlobalGroup"), 'redstar');
 }
 print "</td></tr>\n";
 // Note
 print '<tr><td width="25%" valign="top">' . $langs->trans("Note") . '</td>';
 print '<td class="valeur">' . dol_htmlentitiesbr($fgroup->note) . '</td>';
 print "</tr>\n";
 print '</table><br>';
 if ($user->admin) {
     print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"));
 }
 print '<table width="100%" class="noborder">';
 print '<tr class="liste_titre">';
 print '<td>' . $langs->trans("Module") . '</td>';
 if ($caneditperms) {
     print '<td width="24">&nbsp</td>';
 }
 print '<td align="center" width="24">&nbsp;</td>';
 print '<td>' . $langs->trans("Permissions") . '</td>';
 print '</tr>';
 $sql = "SELECT r.id, r.libelle, r.module";
Example #26
0
     if ($objp->label) {
         $text .= ' - ';
         $productstatic->ref = $objp->label;
         $text .= $productstatic->getNomUrl(0, '', 16);
     }
     $description = $objp->description;
     // Add description in form
     if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
         $text .= !empty($objp->description) && $objp->description != $objp->product_label ? '<br>' . dol_htmlentitiesbr($objp->description) : '';
         $description = '';
         // Already added into main visible desc
     }
     echo $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, !empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '');
     print '</td>';
 } else {
     print '<td>' . dol_htmlentitiesbr($objp->description) . "</td>\n";
 }
 // TVA
 print '<td align="center">' . vatrate($objp->tva_tx, '%', $objp->info_bits) . '</td>';
 // Prix
 print '<td align="right">' . ($objp->subprice != '' ? price($objp->subprice) : '') . "</td>\n";
 // Quantite
 print '<td align="center">' . $objp->qty . '</td>';
 // Unit
 if ($conf->global->PRODUCT_USE_UNITS) {
     print '<td align="left">' . $langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()) . '</td>';
 }
 // Remise
 if ($objp->remise_percent > 0) {
     print '<td align="right" ' . $bc[$var] . '>' . $objp->remise_percent . "%</td>\n";
 } else {
 llxHeader("", $texte, $help_url);
 /*
  * Show tab only if we ask a particular warehouse
  */
 if ($id) {
     $head = stock_prepare_head($entrepot);
     dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), 0, 'stock');
     print '<table class="border" width="100%">';
     $linkback = '<a href="' . DOL_URL_ROOT . '/adherents/liste.php">' . $langs->trans("BackToList") . '</a>';
     // Ref
     print '<tr><td width="25%">' . $langs->trans("Ref") . '</td><td colspan="3">';
     print $form->showrefnav($entrepot, 'id', $linkback, 1, 'rowid', 'libelle');
     print '</td>';
     print '<tr><td>' . $langs->trans("LocationSummary") . '</td><td colspan="3">' . $entrepot->lieu . '</td></tr>';
     // Description
     print '<tr><td valign="top">' . $langs->trans("Description") . '</td><td colspan="3">' . dol_htmlentitiesbr($entrepot->description) . '</td></tr>';
     // Address
     print '<tr><td>' . $langs->trans('Address') . '</td><td colspan="3">';
     print $entrepot->address;
     print '</td></tr>';
     // Town
     print '<tr><td width="25%">' . $langs->trans('Zip') . '</td><td width="25%">' . $entrepot->zip . '</td>';
     print '<td width="25%">' . $langs->trans('Town') . '</td><td width="25%">' . $entrepot->town . '</td></tr>';
     // Country
     print '<tr><td>' . $langs->trans('Country') . '</td><td colspan="3">';
     if (!empty($entrepot->country_code)) {
         $img = picto_from_langcode($entrepot->country_code);
         print $img ? $img . ' ' : '';
         print $entrepot->country;
     }
     print '</td></tr>';
Example #28
0
         $label = !empty($prod->multilangs[$outputlangs->defaultlang]["label"]) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label;
     } else {
         $label = !empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label;
     }
     print '<td>';
     // Show product and description
     $product_static->type = $lines[$i]->fk_product_type;
     $product_static->id = $lines[$i]->fk_product;
     $product_static->ref = $lines[$i]->ref;
     $text = $product_static->getNomUrl(1);
     $text .= ' - ' . $label;
     $description = !empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->description);
     print $form->textwithtooltip($text, $description, 3, '', '', $i);
     print_date_range($lines[$i]->date_start, $lines[$i]->date_end);
     if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
         print !empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product ? '<br>' . dol_htmlentitiesbr($lines[$i]->description) : '';
     }
     print "</td>\n";
 } else {
     print "<td>";
     if ($lines[$i]->fk_product_type == 1) {
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     if (!empty($lines[$i]->label)) {
         $text .= ' <strong>' . $lines[$i]->label . '</strong>';
         print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i);
     } else {
         print $text . ' ' . nl2br($lines[$i]->description);
     }
Example #29
0
					print '<td>';

					// Affiche ligne produit
					$text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$delivery->lines[$i]->fk_product.'">';
					if ($delivery->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
					else $text.= img_object($langs->trans('ShowProduct'),'product');
					$text.= ' '.$delivery->lines[$i]->ref.'</a>';
					$text.= ' - '.$delivery->lines[$i]->label;
					$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($delivery->lines[$i]->description));
					//print $description;
					print $html->textwithtooltip($text,$description,3,'','',$i);
					print_date_range($delivery->lines[$i]->date_start,$delivery->lines[$i]->date_end);
					if ($conf->global->PRODUIT_DESC_IN_FORM)
					{
						print ($delivery->lines[$i]->description && $delivery->lines[$i]->description!=$delivery->lines[$i]->label)?'<br>'.dol_htmlentitiesbr($delivery->lines[$i]->description):'';
					}
				}
				else
				{
					print "<td>";
					if ($delivery->lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
					else $text = img_object($langs->trans('Product'),'product');
					print $text.' '.nl2br($delivery->lines[$i]->description);
					print_date_range($objp->date_start,$objp->date_end);
					print "</td>\n";
				}

				print '<td align="center">'.$delivery->lines[$i]->qty_asked.'</td>';
				print '<td align="center">'.$delivery->lines[$i]->qty_shipped.'</td>';
 /**
  *  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
  *  @param		object		$hookmanager		Hookmanager object
  *  @return     int         	    			1=OK, 0=KO
  */
 function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $hookmanager = false)
 {
     global $user, $langs, $conf, $mysoc, $db;
     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");
     if ($conf->facture->dir_output) {
         $object->fetch_thirdparty();
         $deja_regle = $object->getSommePaiement();
         $amount_credit_notes_included = $object->getSumCreditNotesUsed();
         $amount_deposits_included = $object->getSumDepositsUsed();
         // Definition of $dir and $file
         if ($object->specimen) {
             $dir = $conf->facture->dir_output;
             $file = $dir . "/SPECIMEN.pdf";
         } else {
             $objectref = dol_sanitizeFileName($object->ref);
             $dir = $conf->facture->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 (file_exists($dir)) {
             $nblignes = count($object->lines);
             $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));
             $pdf->SetSubject($outputlangs->transnoentities("Invoice"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Invoice"));
             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, $hookmanager);
             $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 = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10;
             $tab_height = 130;
             $tab_height_newpage = 150;
             // Affiche notes
             if (!empty($object->note_public)) {
                 $tab_top = 88;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $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;
             // Loop on each lines
             for ($i = 0; $i < $nblignes; $i++) {
                 $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;
                 $pdf->startTransaction();
                 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc, 0, $hookmanager);
                 $pageposafter = $pdf->getPage();
                 if ($pageposafter > $pageposbefore) {
                     $pdf->rollbackTransaction(true);
                     $pageposafter = $pageposbefore;
                     //print $pageposafter.'-'.$pageposbefore;exit;
                     $pdf->setPageOrientation('', 1, $heightforfooter);
                     // The only function to edit the bottom margin of current page to set it.
                     pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc, 0, $hookmanager);
                     $pageposafter = $pdf->getPage();
                     $posyafter = $pdf->GetY();
                     //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
                     if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) {
                         if ($i == $nblignes - 1) {
                             $pdf->AddPage('', '', true);
                             if (!empty($tplidx)) {
                                 $pdf->useTemplate($tplidx);
                             }
                             if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
                                 $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
                             }
                             $pdf->setPage($pagenb + 1);
                         }
                     } else {
                         // We found a page break
                         $showpricebeforepagebreak = 0;
                     }
                 } else {
                     $pdf->commitTransaction();
                 }
                 $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.
                 // We suppose that a too long description is moved completely on next page
                 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
                     $pdf->setPage($pageposafter);
                     $curY = $tab_top_newpage;
                 }
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // On repositionne la police par defaut
                 // VAT Rate
                 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
                     $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
                     $pdf->SetXY($this->posxtva, $curY);
                     $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
                 }
                 // Unit price before discount
                 $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
                 $pdf->SetXY($this->posxup, $curY);
                 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 3, $up_excl_tax, 0, 'R', 0);
                 // Quantity
                 $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
                 $pdf->SetXY($this->posxqty, $curY);
                 $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 3, $qty, 0, 'R');
                 // Enough for 6 chars
                 // Discount on line
                 if ($object->lines[$i]->remise_percent) {
                     $pdf->SetXY($this->posxdiscount - 2, $curY);
                     $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
                     $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
                 }
                 // Total HT line
                 $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
                 $pdf->SetXY($this->postotalht, $curY);
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $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;
                 $localtax1_rate = $object->lines[$i]->localtax1_tx;
                 $localtax2_rate = $object->lines[$i]->localtax2_tx;
                 $localtax1_type = $object->lines[$i]->localtax1_type;
                 $localtax2_type = $object->lines[$i]->localtax2_type;
                 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;
                 // TODO : store local taxes types into object lines and remove this
                 $localtax1_array = getLocalTaxesFromRate($vatrate, 1, $mysoc);
                 $localtax2_array = getLocalTaxesFromRate($vatrate, 2, $mysoc);
                 if (!isset($localtax1_type)) {
                     $localtax1_type = $localtax1_array[0];
                 }
                 if (!isset($localtax2_type)) {
                     $localtax2_type = $localtax2_array[0];
                 }
                 //end TODO
                 // retrieve global local tax
                 if ($localtax1_type == '7') {
                     $localtax1_rate = $localtax1_array[1];
                 }
                 if ($localtax2_type == '7') {
                     $localtax2_rate = $localtax2_array[1];
                 }
                 if ($localtax1_type && ($localtax1ligne != 0 || $localtax1_type == '7')) {
                     $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
                 }
                 if ($localtax2_type && ($localtax2ligne != 0 || $localtax2_type == '7')) {
                     $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
                 }
                 if (($object->lines[$i]->info_bits & 0x1) == 0x1) {
                     $vatrate .= '*';
                 }
                 if (!isset($this->tva[$vatrate])) {
                     $this->tva[$vatrate] = '';
                 }
                 $this->tva[$vatrate] += $tvaligne;
                 // Add line
                 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblignes - 1) {
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(210, 210, 210)));
                     //$pdf->SetDrawColor(190,190,200);
                     $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
                     $pdf->SetLineStyle(array('dash' => 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, $hookmanager);
                     }
                 }
                 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, $hookmanager);
                     }
                 }
             }
             // 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;
             }
             // 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 || $amount_credit_notes_included || $amount_deposits_included) {
                 $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
             }
             // Pied de page
             $this->_pagefoot($pdf, $object, $outputlangs);
             //$pdf->AliasNbPages();
             $pdf->Close();
             $pdf->Output($file, 'F');
             // 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('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", "FAC_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->trans("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }