Skip to content

Commit

Permalink
NEW Add total weight and volume on PDF
Browse files Browse the repository at this point in the history
NEW Can hide column qty ordered.
  • Loading branch information
eldy committed Feb 25, 2016
1 parent a95240e commit b3c3d3a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 30 deletions.
78 changes: 49 additions & 29 deletions htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
Expand Up @@ -69,18 +69,25 @@ function __construct($db=0)

// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
$this->posxweightvol=$this->page_largeur - $this->marge_droite - 80;
$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 60;
$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 30;
$this->posxweightvol=$this->page_largeur - $this->marge_droite - 76;
$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images

if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxweightvol-=20;
$this->posxpicture-=20;
$this->posxqtyordered-=20;
$this->posxqtytoship-=20;
}

if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
$this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
$this->posxqtyordered = $this->posxqtytoship;
}
}

/**
Expand Down Expand Up @@ -203,7 +210,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 30; // Height reserved to output the info and total part
$heightforinfotot = 8; // 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);
Expand Down Expand Up @@ -446,12 +453,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
{
$voltxt=$object->lines[$i]->volume*$object->lines[$i]->qty_shipped.' '.measuring_units_string($object->lines[$i]->volume_units,"volume");
}

$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?', ':'').$voltxt,'','C');

$pdf->SetXY($this->posxqtyordered, $curY);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');

if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$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');

Expand Down Expand Up @@ -571,16 +581,17 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)

$tab2_top = $posy;
$tab2_hl = 4;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetFont('','B', $default_font_size - 1);

// Tableau total
$col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
/*if ($this->page_largeur < 210) // To work with US executive format
{
$col2x-=20;
}*/
$largcol2 = ($this->posxqtyordered - $this->posxweightvol);

if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);

$useborder=0;
$index = 0;

Expand All @@ -591,6 +602,8 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
$tmparray=$object->getTotalWeightVolume();
$totalWeight=$tmparray['weight'];
$totalVolume=$tmparray['volume'];
$totalOrdered=$tmparray['ordered'];
$totalToShip=$tmparray['toship'];
// Set trueVolume and volume_units not currently stored into database
if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
{
Expand All @@ -603,31 +616,35 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);

$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);

if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
}

$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->largeur_page - $this->marge_droite - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);

// Total Weight
if ($totalWeighttoshow)
{
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Weigth"), 0, 'L', 1);

$pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2+20, $tab2_hl, $totalWeighttoshow, 0, 'R', 1);

$index++;
}

if ($totalVolumetoshow)
{
// Total Volume
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Volume"), 0, 'L', 1);

$pdf->SetXY($col2x-20, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2+20, $tab2_hl, $totalVolumetoshow, 0, 'R', 1);

$index++;
}
if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;

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

Expand Down Expand Up @@ -681,13 +698,16 @@ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0,
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
}

$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
}

if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
}
}

$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
if (empty($hidetop))
{
Expand Down
7 changes: 6 additions & 1 deletion htdocs/expedition/class/expedition.class.php
Expand Up @@ -1754,8 +1754,13 @@ function getTotalWeightVolume()
$volumeUnit=0;
$totalWeight = '';
$totalVolume = '';
$totalOrdered = '';
$totalToShip = '';
foreach ($this->lines as $line)
{
$totalOrdered+=$line->qty_asked;
$totalToShip+=$line->qty_shipped;

$weightUnit=0;
$volumeUnit=0;
if (! empty($line->weight_units)) $weightUnit = $line->weight_units;
Expand Down Expand Up @@ -1784,7 +1789,7 @@ function getTotalWeightVolume()
}
}

return array('weight'=>$totalWeight, 'volume'=>$totalVolume);
return array('weight'=>$totalWeight, 'volume'=>$totalVolume, 'ordered'=>$totalOrdered, 'toship'=>$totalToShip);
}


Expand Down

0 comments on commit b3c3d3a

Please sign in to comment.