New: Add option MAIN_GENERATE_INVOICES_WITH_PICTURE to show picture onto
PDF like MAIN_GENERATE_PROPOSALS_WITH_PICTURE dir for proposals.
This commit is contained in:
parent
6eb3fe1ae4
commit
d976a5575b
@ -53,6 +53,8 @@ For users:
|
||||
- New: Optimize size of image static resources.
|
||||
- New: Add hourly and daily amount on user card. Add weekly working hours and salary on user card.
|
||||
- New: Content of predefined email come firstly from table llx_c_email_template, then translation key.
|
||||
- New: Add option MAIN_GENERATE_INVOICES_WITH_PICTURE to show picture
|
||||
onto PDF like MAIN_GENERATE_PROPOSALS_WITH_PICTURE dir for proposals.
|
||||
- Upgrade phpexcel lib to 1.7.8
|
||||
- Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action
|
||||
- Fix: [ bug #1470, #1472, #1473] User trigger problem
|
||||
|
||||
@ -153,6 +153,36 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$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) . $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();
|
||||
@ -195,9 +225,8 @@ class pdf_crabe extends ModelePDFFactures
|
||||
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);
|
||||
|
||||
$pdf=pdf_getInstance($this->format);
|
||||
// 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
|
||||
@ -309,17 +338,43 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$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))) // If photo too high, we moved completely on new page
|
||||
{
|
||||
$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;
|
||||
|
||||
$showpricebeforepagebreak=1;
|
||||
|
||||
$pdf->startTransaction();
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
|
||||
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
|
||||
$pageposafter=$pdf->getPage();
|
||||
if ($pageposafter > $pageposbefore) // There is a pagebreak
|
||||
{
|
||||
@ -327,7 +382,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$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);
|
||||
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;
|
||||
@ -351,14 +406,15 @@ class pdf_crabe extends ModelePDFFactures
|
||||
{
|
||||
$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 is moved completely on next page
|
||||
// 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;
|
||||
}
|
||||
@ -430,6 +486,8 @@ class pdf_crabe extends ModelePDFFactures
|
||||
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
|
||||
$this->tva[$vatrate] += $tvaligne;
|
||||
|
||||
if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
|
||||
|
||||
// Add line
|
||||
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
|
||||
{
|
||||
@ -512,11 +570,6 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$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;
|
||||
@ -894,7 +947,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
//{
|
||||
foreach( $this->localtax1 as $localtax_type => $localtax_rate )
|
||||
{
|
||||
if (in_array((string) $localtax_type, array('1','3','5','7'))) continue;
|
||||
if (in_array((string) $localtax_type, array('1','3','5'))) continue;
|
||||
|
||||
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||
{
|
||||
@ -927,7 +980,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
//{
|
||||
foreach( $this->localtax2 as $localtax_type => $localtax_rate )
|
||||
{
|
||||
if (in_array((string) $localtax_type, array('1','3','5','7'))) continue;
|
||||
if (in_array((string) $localtax_type, array('1','3','5'))) continue;
|
||||
|
||||
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||
{
|
||||
@ -1121,7 +1174,6 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
|
||||
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
|
||||
|
||||
// Fin
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
}
|
||||
@ -1180,6 +1232,16 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
|
||||
{
|
||||
$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
//$pdf->SetXY($this->posxpicture-1, $tab_top+1);
|
||||
//$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
|
||||
{
|
||||
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
|
||||
|
||||
@ -205,7 +205,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
{
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -383,6 +383,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
|
||||
$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))) // There is no space left for total+free text
|
||||
{
|
||||
if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
|
||||
@ -551,12 +552,11 @@ class pdf_azur extends ModelePDFPropales
|
||||
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone totaux
|
||||
//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
|
||||
$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
|
||||
|
||||
// Affiche zone versements
|
||||
/*
|
||||
if ($deja_regle)
|
||||
if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
|
||||
{
|
||||
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
|
||||
}
|
||||
@ -729,20 +729,22 @@ class pdf_azur extends ModelePDFPropales
|
||||
// Si mode reglement non force ou si force a CHQ
|
||||
if (! empty($conf->global->FACTURE_CHQ_NUMBER))
|
||||
{
|
||||
$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
|
||||
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
|
||||
{
|
||||
$account = new Account($this->db);
|
||||
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
|
||||
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('','B', $default_font_size - 3);
|
||||
$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
|
||||
$posy=$pdf->GetY()+1;
|
||||
|
||||
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('','', $default_font_size - 3);
|
||||
$pdf->SetFont('','', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
|
||||
$posy=$pdf->GetY()+2;
|
||||
}
|
||||
@ -750,14 +752,14 @@ class pdf_azur extends ModelePDFPropales
|
||||
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('','B', $default_font_size - 3);
|
||||
$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
|
||||
$posy=$pdf->GetY()+1;
|
||||
|
||||
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
|
||||
{
|
||||
$pdf->SetXY($this->marge_gauche, $posy);
|
||||
$pdf->SetFont('','', $default_font_size - 3);
|
||||
$pdf->SetFont('','', $default_font_size - $diffsizetitle);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
|
||||
$posy=$pdf->GetY()+2;
|
||||
}
|
||||
@ -768,10 +770,11 @@ class pdf_azur extends ModelePDFPropales
|
||||
// If payment mode not forced or forced to VIR, show payment with BAN
|
||||
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
|
||||
{
|
||||
if (! empty($conf->global->FACTURE_RIB_NUMBER))
|
||||
if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
|
||||
{
|
||||
$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
|
||||
$account = new Account($this->db);
|
||||
$account->fetch($conf->global->FACTURE_RIB_NUMBER);
|
||||
$account->fetch($bankid);
|
||||
|
||||
$curx=$this->marge_gauche;
|
||||
$cury=$posy;
|
||||
@ -971,6 +974,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
|
||||
foreach( $localtax_rate as $tvakey => $tvaval )
|
||||
{
|
||||
// retrieve global local tax
|
||||
if ($tvakey != 0) // On affiche pas taux 0
|
||||
{
|
||||
//$this->atleastoneratenotnull++;
|
||||
@ -1091,7 +1095,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
|
||||
|
||||
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
|
||||
if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 6, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
|
||||
if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
|
||||
}
|
||||
|
||||
$pdf->SetDrawColor(128,128,128);
|
||||
@ -1102,7 +1106,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); // line prend une position y en 2eme param et 4eme param
|
||||
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
|
||||
|
||||
$pdf->SetXY($this->posxdesc-1, $tab_top+1);
|
||||
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
|
||||
@ -1235,11 +1239,11 @@ class pdf_azur extends ModelePDFPropales
|
||||
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
|
||||
|
||||
$posy+=1;
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetFont('','', $default_font_size - 2);
|
||||
|
||||
if ($object->ref_client)
|
||||
{
|
||||
$posy+=5;
|
||||
$posy+=4;
|
||||
$pdf->SetXY($posx,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user