@return int 1=OK, 0=KO
*/
public function write_file(&$object, $outputlangs, $srctemplatepath = ‚‘, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
//********* Code für Extrafeld *********
$extrafields = new extraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_llx_product_extrafields);
$object->fetch($rowid);
$object->fetch_optionals($rowid,$extralabels);
print $object->array_options [‚options_artgr‘];
//********* Code Ende *********
// phpcs:enable
global $user, $conf, $langs, $mysoc, $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‘;
}
// Load traductions files required by page
$outputlangs->loadLangs(array(„main“, „bills“, „products“, „dict“, „companies“, „propal“, „deliveries“, „sendings“, „productbatch“));
if ($conf->expedition->dir_output) {
$object->fetch_thirdparty();
$origin = $object->origin;
//Create sender
$this->expediteur = $mysoc;
// Definition of $dir and $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)) {
// 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
$nblines = 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
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
$heightforfooter += 56;
}
$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_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 (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
$pdf->SetCompression(false);
}
// 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 = 2;
$tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 1 : 10);
$pdf->SetFillColor(240, 240, 240);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetXY(2, 2);
$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 of product line
//$libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 5, $curY, 0, 1);
//$pdf->MultiCell(30, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
$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;
}
//Inserting the product reference
//$pdf->SetXY(10, $curY + 48);
//$pdf->SetFont('', '', $default_font_size - 6);
//$pdf->MultiCell(50, 5, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'R', 0);
//$pdf->SetXY(2, $curY - 28);
//$pdf->SetFont('', '', $default_font_size - 5);
//$pdf->MultiCell($this->page_largeur - 4, 0, $outputlangs->transnoentities("Art.-Nr.").': '.$outputlangs->convToOutputCharset($object->lines[$i]->ref), 1, 'R', 0);
$pdf->SetXY(2, 17);
$pdf->SetFont('', 'B', $default_font_size + 5);
$pdf->MultiCell(58, 3, $outputlangs->transnoentities("DIN 933"), 0, 'R', 0);
$pdf->SetFont('', 'B', $default_font_size + 5);
$pdf->SetXY(2, 25);
$pdf->MultiCell(40, 3, $outputlangs->transnoentities("M8x60"), 0, 'L', 0);
$pdf->SetXY(2, 28);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->MultiCell(58, 3, $object->lines[$i]->qty_asked.' '.$outputlangs->transnoentities("Stück "), 0, 'R', 0);
$pdf->SetXY(2, 32);
$pdf->SetFont('', '', $default_font_size - 5);
$pdf->MultiCell(58, 3, $outputlangs->transnoentities("Art.-Nr.").': '.$outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'R', 0);
$pdf->SetFont('', ' ', $default_font_size - 2);
$pdf->SetXY(2, 35);
$pdf->MultiCell(40, 3, $outputlangs->transnoentities("Sechskantschraube"), 0, 'L', 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY(2, 40);
$pdf->MultiCell(40, 3, $outputlangs->transnoentities("verzinkt blau 8.8"), 0, 'L', 0);
$pdf->SetXY(2, 45);
$pdf->SetFont('', '', $default_font_size - 6);
$pdf->MultiCell($this->page_largeur - 4, 3, $outputlangs->transnoentities("Lot Nr.").': '.$outputlangs->convToOutputCharset($object->ref), '', 'L');
$pdf->MultiCell (0,$this->page_hauteur - 4, $outputlangs->transnoentities("Art-Gr.").': '.$outputlangs->convToOutputCharset($object->array_options ['artgr']),0,'L');
//$pdf->MultiCell($this->page_largeur - 4, 3, $outputlangs->convToOutputCharset($object->artgr), '', 'L');
//$pdf->writeHTMLCell (190,3, $pdf->getX(), $curY + 10, $andereVariable,0,1); // NEUE ZEILE
//$pdf->MultiCell($this->page_largeur - 4, $this->page_hauteur, $outputlangs->convToOutputCharset($object->lines[$i]->array_options['options_artgr']),0,'L');
// 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++;
}
}
// Pagefoot
$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 ($reshook < 0) {
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
dolChmod($file);
$this->result = array('fullpath'=>$file);
return 1;
} else {
$this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
} else {
$this->error = $outputlangs->transnoentities(„ErrorConstantNotDefined“, „EXP_OUTPUTDIR“);
return 0;
}
}