diff --git a/admin/subtotal_about.php b/admin/subtotal_about.php
index 412f14ff..c1ea3272 100644
--- a/admin/subtotal_about.php
+++ b/admin/subtotal_about.php
@@ -73,4 +73,4 @@
llxFooter();
-$db->close();
\ No newline at end of file
+$db->close();
diff --git a/admin/subtotal_setup.php b/admin/subtotal_setup.php
index 242a6e6b..c490e5a4 100644
--- a/admin/subtotal_setup.php
+++ b/admin/subtotal_setup.php
@@ -45,28 +45,20 @@
// Parameters
$action = GETPOST('action', 'alpha');
-if($action=='save') {
-
- foreach($_REQUEST['TDivers'] as $name=>$param) {
-
- dolibarr_set_const($db, $name, $param);
-
- }
-
+if ($action=='save') {
+ foreach ($_REQUEST['TDivers'] as $name=>$param) {
+ dolibarr_set_const($db, $name, $param);
+ }
}
-if (preg_match('/set_(.*)/',$action,$reg))
-{
- $code=$reg[1];
- if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0)
- {
- header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- dol_print_error($db);
- }
+if (preg_match('/set_(.*)/', $action, $reg)) {
+ $code=$reg[1];
+ if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) {
+ header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ } else {
+ dol_print_error($db);
+ }
}
@@ -78,10 +70,10 @@
-llxHeader('','Gestion de sous-total, à propos','');
+llxHeader('', 'Gestion de sous-total, à propos', '');
$linkback=''.$langs->trans("BackToModuleList").'';
-print_fiche_titre('Gestion de subtotal',$linkback,'setup');
+print_fiche_titre('Gestion de subtotal', $linkback, 'setup');
// Configuration header
$head = subtotalAdminPrepareHead();
@@ -95,13 +87,14 @@
showParameters();
-function showParameters() {
- global $db,$conf,$langs;
+function showParameters()
+{
+ global $db,$conf,$langs;
- $html=new Form($db);
+ $html=new Form($db);
- ?>
@@ -168,20 +162,23 @@ function showParameters() {
- clilacevenements->enabled) { ?>
+ clilacevenements->enabled) {
+ ?>
Afficher la quantité sur les lignes de sous-total (uniquement dans le cas d'un produit virtuel ajouté) |
|
@@ -193,16 +190,20 @@ function showParameters() {
-
+
load('subtotal@subtotal');
+ $langs->load('subtotal@subtotal');
- $contexts = explode(':',$parameters['context']);
+ $contexts = explode(':', $parameters['context']);
- if(in_array('ordercard',$contexts) || in_array('propalcard',$contexts) || in_array('invoicecard',$contexts)) {
-
- if ($object->statut == 0 && $user->rights->{$object->element}->creer) {
-
-
- if($object->element=='facture')$idvar = 'facid';
- else $idvar='id';
+ if (in_array('ordercard', $contexts) || in_array('propalcard', $contexts) || in_array('invoicecard', $contexts)) {
+ if ($object->statut == 0 && $user->rights->{$object->element}->creer) {
+ if ($object->element=='facture') {
+ $idvar = 'facid';
+ } else {
+ $idvar='id';
+ }
- if($action=='add_title_line' || $action=='add_total_line' || $action=='add_subtitle_line' || $action=='add_subtotal_line') {
+ if ($action=='add_title_line' || $action=='add_total_line' || $action=='add_subtitle_line' || $action=='add_subtotal_line') {
+ $level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
- $level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
-
- if($action=='add_title_line') {
- $title = GETPOST('title');
- if(empty($title)) $title = $langs->trans('title');
- $qty = $level ? $level : 1;
- }
- else if($action=='add_subtitle_line') {
- $title = GETPOST('title');
- if(empty($title)) $title = $langs->trans('subtitle');
- $qty = 2;
+ if ($action=='add_title_line') {
+ $title = GETPOST('title');
+ if (empty($title)) {
+ $title = $langs->trans('title');
+ }
+ $qty = $level ? $level : 1;
+ } elseif ($action=='add_subtitle_line') {
+ $title = GETPOST('title');
+ if (empty($title)) {
+ $title = $langs->trans('subtitle');
+ }
+ $qty = 2;
+ } elseif ($action=='add_subtotal_line') {
+ $title = $langs->trans('SubSubTotal');
+ $qty = 98;
+ } else {
+ $title = $langs->trans('SubTotal');
+ $qty = $level ? 100-$level : 99;
}
- else if($action=='add_subtotal_line') {
- $title = $langs->trans('SubSubTotal');
- $qty = 98;
- }
- else {
- $title = $langs->trans('SubTotal');
- $qty = $level ? 100-$level : 99;
- }
- dol_include_once('/subtotal/class/subtotal.class.php');
- TSubtotal::addSubTotalLine($object, $title, $qty);
- }
- else if($action==='ask_deleteallline') {
- $form=new Form($db);
+ dol_include_once('/subtotal/class/subtotal.class.php');
+ TSubtotal::addSubTotalLine($object, $title, $qty);
+ } elseif ($action==='ask_deleteallline') {
+ $form=new Form($db);
- $lineid = GETPOST('lineid','integer');
- $TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
+ $lineid = GETPOST('lineid', 'integer');
+ $TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
- $nbLines = count($TIdForGroup);
+ $nbLines = count($TIdForGroup);
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
- print $formconfirm;
- }
+ $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
+ print $formconfirm;
+ }
// New format is for 3.8
- if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
- {
- $this->printNewFormat($object, $conf, $langs, $idvar);
- }
- else
- {
- $this->printOldFormat($object, $conf, $langs, $idvar);
+ if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
+ $this->printNewFormat($object, $conf, $langs, $idvar);
+ } else {
+ $this->printOldFormat($object, $conf, $langs, $idvar);
}
-
- }
- }
+ }
+ }
- return 0;
- }
+ return 0;
+ }
- function printNewFormat(&$object, &$conf, &$langs, $idvar)
- {
- ?>
+ public function printNewFormat(&$object, &$conf, &$langs, $idvar)
+ {
+ ?>
+ public function printOldFormat(&$object, &$conf, &$langs, $idvar)
+ {
+ ?>
+ $out.= '
-
+
|
';
- $var = -$var;
+ $var = -$var;
- $out.= '
+ $out.= '
-
+
|
';
- $var = -$var;
+ $var = -$var;
- $this->resprints = $out;
- }
+ $this->resprints = $out;
+ }
return 1;
- }
+ }
- function formEditProductOptions($parameters, &$object, &$action, $hookmanager)
+ public function formEditProductOptions($parameters, &$object, &$action, $hookmanager)
{
-
- if (in_array('invoicecard',explode(':',$parameters['context'])))
- {
-
+ if (in_array('invoicecard', explode(':', $parameters['context']))) {
}
return 0;
}
- function ODTSubstitutionLine($parameters, &$object, $action, $hookmanager) {
- global $conf;
+ public function ODTSubstitutionLine($parameters, &$object, $action, $hookmanager)
+ {
+ global $conf;
- if($action === 'builddoc') {
-
- $line = &$parameters['line'];
- $object = &$parameters['object'];
- $substitutionarray = &$parameters['substitutionarray'];
+ if ($action === 'builddoc') {
+ $line = &$parameters['line'];
+ $object = &$parameters['object'];
+ $substitutionarray = &$parameters['substitutionarray'];
- if($line->product_type == 9 && $line->special_code == $this->module_number) {
- $substitutionarray['line_modsubtotal'] = true;
+ if ($line->product_type == 9 && $line->special_code == $this->module_number) {
+ $substitutionarray['line_modsubtotal'] = true;
- $substitutionarray['line_price_ht']
- = $substitutionarray['line_price_vat']
+ $substitutionarray['line_price_ht']
+ = $substitutionarray['line_price_vat']
= $substitutionarray['line_price_ttc']
= $substitutionarray['line_vatrate']
- = $substitutionarray['line_qty']
+ = $substitutionarray['line_qty']
= '';
- if($line->qty>90) {
- $substitutionarray['line_modsubtotal_total'] = true;
+ if ($line->qty>90) {
+ $substitutionarray['line_modsubtotal_total'] = true;
- $substitutionarray['line_price_ht'] = $substitutionarray['line_price_ttc'] = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
- } else {
- $substitutionarray['line_modsubtotal_title'] = true;
- }
-
-
- }
- else{
- $substitutionarray['line_not_modsubtotal'] = true;
- $substitutionarray['line_modsubtotal'] = false;
- }
-
- }
-
- }
-
- function createFrom($parameters, &$object, $action, $hookmanager) {
+ $substitutionarray['line_price_ht'] = $substitutionarray['line_price_ttc'] = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
+ } else {
+ $substitutionarray['line_modsubtotal_title'] = true;
+ }
+ } else {
+ $substitutionarray['line_not_modsubtotal'] = true;
+ $substitutionarray['line_modsubtotal'] = false;
+ }
+ }
+ }
- if (
- in_array('invoicecard',explode(':',$parameters['context']))
- || in_array('propalcard',explode(':',$parameters['context']))
- || in_array('ordercard',explode(':',$parameters['context']))
+ public function createFrom($parameters, &$object, $action, $hookmanager)
+ {
+ if (
+ in_array('invoicecard', explode(':', $parameters['context']))
+ || in_array('propalcard', explode(':', $parameters['context']))
+ || in_array('ordercard', explode(':', $parameters['context']))
) {
+ global $db;
- global $db;
-
- $objFrom = $parameters['objFrom'];
+ $objFrom = $parameters['objFrom'];
- foreach($objFrom->lines as $k=> &$lineOld) {
-
- if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
-
- $line = & $object->lines[$k];
+ foreach ($objFrom->lines as $k=> &$lineOld) {
+ if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
+ $line = & $object->lines[$k];
- $idLine = (int) ($line->id ? $line->id : $line->rowid);
+ $idLine = (int) ($line->id ? $line->id : $line->rowid);
- $db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
+ $db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
SET info_bits=".(int)$lineOld->info_bits."
WHERE rowid = ".$idLine."
");
-
- }
-
-
- }
-
-
- }
-
- }
+ }
+ }
+ }
+ }
- function doActions($parameters, &$object, $action, $hookmanager) {
- global $conf;
+ public function doActions($parameters, &$object, $action, $hookmanager)
+ {
+ global $conf;
- if($action === 'builddoc') {
-
- if (
- in_array('invoicecard',explode(':',$parameters['context']))
- || in_array('propalcard',explode(':',$parameters['context']))
- || in_array('ordercard',explode(':',$parameters['context']))
- )
- {
- if(in_array('invoicecard',explode(':',$parameters['context']))) {
- $sessname = 'subtotal_hideInnerLines_facture';
- $sessname2 = 'subtotal_hidedetails_facture';
- }
- elseif(in_array('propalcard',explode(':',$parameters['context']))) {
- $sessname = 'subtotal_hideInnerLines_propal';
- $sessname2 = 'subtotal_hidedetails_propal';
- }
- elseif(in_array('ordercard',explode(':',$parameters['context']))) {
- $sessname = 'subtotal_hideInnerLines_commande';
- $sessname2 = 'subtotal_hidedetails_commande';
- }
- else {
- $sessname = 'subtotal_hideInnerLines_unknown';
- $sessname2 = 'subtotal_hidedetails_unknown';
- }
+ if ($action === 'builddoc') {
+ if (
+ in_array('invoicecard', explode(':', $parameters['context']))
+ || in_array('propalcard', explode(':', $parameters['context']))
+ || in_array('ordercard', explode(':', $parameters['context']))
+ ) {
+ if (in_array('invoicecard', explode(':', $parameters['context']))) {
+ $sessname = 'subtotal_hideInnerLines_facture';
+ $sessname2 = 'subtotal_hidedetails_facture';
+ } elseif (in_array('propalcard', explode(':', $parameters['context']))) {
+ $sessname = 'subtotal_hideInnerLines_propal';
+ $sessname2 = 'subtotal_hidedetails_propal';
+ } elseif (in_array('ordercard', explode(':', $parameters['context']))) {
+ $sessname = 'subtotal_hideInnerLines_commande';
+ $sessname2 = 'subtotal_hidedetails_commande';
+ } else {
+ $sessname = 'subtotal_hideInnerLines_unknown';
+ $sessname2 = 'subtotal_hidedetails_unknown';
+ }
- $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
- $_SESSION[$sessname] = $hideInnerLines;
+ $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
+ $_SESSION[$sessname] = $hideInnerLines;
- $hidedetails= (int)isset($_REQUEST['hidedetails']);
- $_SESSION[$sessname2] = $hidedetails;
+ $hidedetails= (int)isset($_REQUEST['hidedetails']);
+ $_SESSION[$sessname2] = $hidedetails;
- foreach($object->lines as &$line) {
- if ($line->product_type == 9 && $line->special_code == $this->module_number) {
-
- if($line->qty>90) {
+ foreach ($object->lines as &$line) {
+ if ($line->product_type == 9 && $line->special_code == $this->module_number) {
+ if ($line->qty>90) {
$line->modsubtotal_total = 1;
- }
- else{
+ } else {
$line->modsubtotal_title = 1;
}
- $line->total_ht = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
- }
- }
- }
-
- }
- else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
+ $line->total_ht = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
+ }
+ }
+ }
+ } elseif ($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
+ $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
- $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
-
- foreach($Tab as $idLine) {
- /**
+ foreach ($Tab as $idLine) {
+ /**
* @var $object Facture
*/
- if($object->element=='facture') $object->deleteline($idLine);
+ if ($object->element=='facture') {
+ $object->deleteline($idLine);
+ }
/**
* @var $object Propal
*/
- else if($object->element=='propal') $object->deleteline($idLine);
+ elseif ($object->element=='propal') {
+ $object->deleteline($idLine);
+ }
/**
* @var $object Commande
*/
- else if($object->element=='commande') $object->deleteline($idLine);
- }
-
- header('location:?id='.$object->id);
- exit;
+ elseif ($object->element=='commande') {
+ $object->deleteline($idLine);
+ }
+ }
- }
+ header('location:?id='.$object->id);
+ exit;
+ }
- return 0;
- }
+ return 0;
+ }
- function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
- return 0;
- }
+ public function formAddObjectLine($parameters, &$object, &$action, $hookmanager)
+ {
+ return 0;
+ }
- function getArrayOfLineForAGroup(&$object, $lineid) {
- $rang = $line->rang;
- $qty_line = $line->qty;
+ public function getArrayOfLineForAGroup(&$object, $lineid)
+ {
+ $rang = $line->rang;
+ $qty_line = $line->qty;
- $total = 0;
+ $total = 0;
- $found = false;
+ $found = false;
- $Tab= array();
+ $Tab= array();
- foreach($object->lines as $l) {
-
- if($l->rowid == $lineid) {
- $found = true;
- $qty_line = $l->qty;
- }
+ foreach ($object->lines as $l) {
+ if ($l->rowid == $lineid) {
+ $found = true;
+ $qty_line = $l->qty;
+ }
- if($found) {
+ if ($found) {
+ $Tab[] = $l->rowid;
- $Tab[] = $l->rowid;
-
- if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2)) ) {
- break; // end of story
- }
- }
-
-
- }
-
+ if ($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))) {
+ break; // end of story
+ }
+ }
+ }
- return $Tab;
- }
+ return $Tab;
+ }
- function getTotalLineFromObject(&$object, &$line, $use_level=false) {
-
- $rang = $line->rang;
- $qty_line = $line->qty;
+ public function getTotalLineFromObject(&$object, &$line, $use_level=false)
+ {
+ $rang = $line->rang;
+ $qty_line = $line->qty;
- $total = 0;
+ $total = 0;
- foreach($object->lines as $l) {
- //print $l->rang.'>='.$rang.' '.$total.'
';
- if($l->rang>=$rang) {
- //echo 'return!
';
+ foreach ($object->lines as $l) {
+ //print $l->rang.'>='.$rang.' '.$total.'
';
+ if ($l->rang>=$rang) {
+ //echo 'return!
';
return $total;
- }
- else if($l->special_code==$this->module_number && $l->qty == 100 - $qty_line)
- {
- $total = 0;
- }
- elseif($l->product_type!=9) {
- $total += $l->total_ht;
+ } elseif ($l->special_code==$this->module_number && $l->qty == 100 - $qty_line) {
+ $total = 0;
+ } elseif ($l->product_type!=9) {
+ $total += $l->total_ht;
}
-
- }
+ }
- return $total;
- }
+ return $total;
+ }
/**
* @param $pdf TCPDF PDF object
@@ -523,42 +499,44 @@ function getTotalLineFromObject(&$object, &$line, $use_level=false) {
* @param $w float width
* @param $h float height
*/
- function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
- global $conf;
+ public function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h)
+ {
+ global $conf;
- $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
+ $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
- $hidePriceOnSubtotalLines = (int) isset($_REQUEST['hide_price_on_subtotal_lines']);
+ $hidePriceOnSubtotalLines = (int) isset($_REQUEST['hide_price_on_subtotal_lines']);
- if($line->qty==99)
- $pdf->SetFillColor(220,220,220);
- elseif ($line->qty==98)
- $pdf->SetFillColor(230,230,230);
- else
- $pdf->SetFillColor(240,240,240);
+ if ($line->qty==99) {
+ $pdf->SetFillColor(220, 220, 220);
+ } elseif ($line->qty==98) {
+ $pdf->SetFillColor(230, 230, 230);
+ } else {
+ $pdf->SetFillColor(240, 240, 240);
+ }
- $pdf->SetFont('', 'B', 9);
+ $pdf->SetFont('', 'B', 9);
- $y1 = $pdf->GetY();
- //Print label
- $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
- $y2 = $pdf->GetY();
+ $y1 = $pdf->GetY();
+ //Print label
+ $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
+ $y2 = $pdf->GetY();
//Print background
$pdf->SetXY($posx, $posy);
- $pdf->MultiCell(200-$posx, $y2-$y1-2, '', 0, '', 1);
+ $pdf->MultiCell(200-$posx, $y2-$y1-2, '', 0, '', 1);
- if (!$hidePriceOnSubtotalLines) {
- if($line->total == 0) {
- $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
+ if (!$hidePriceOnSubtotalLines) {
+ if ($line->total == 0) {
+ $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
- $line->total_ht = $total;
- $line->total = $total;
- }
+ $line->total_ht = $total;
+ $line->total = $total;
+ }
- $pdf->SetXY($pdf->postotalht, $posy);
- $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, price($line->total), 0, 'R', 0);
- }
+ $pdf->SetXY($pdf->postotalht, $posy);
+ $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, price($line->total), 0, 'R', 0);
+ }
}
/**
@@ -572,217 +550,208 @@ function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy
* @param $w float width
* @param $h float height
*/
- function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
-
- global $db,$conf;
+ public function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h)
+ {
+ global $db,$conf;
- $pdf->SetXY ($posx, $posy);
+ $pdf->SetXY($posx, $posy);
- $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
- if($hideInnerLines) {
-
- if($line->qty==1)$pdf->SetFont('', 'BU', 9);
- else $pdf->SetFont('', $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES, 9);
-
- }
- else {
-
- if($line->qty==1)$pdf->SetFont('', 'BU', 9);
- else $pdf->SetFont('', 'BUI', 9);
-
- }
+ $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
+ if ($hideInnerLines) {
+ if ($line->qty==1) {
+ $pdf->SetFont('', 'BU', 9);
+ } else {
+ $pdf->SetFont('', $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES, 9);
+ }
+ } else {
+ if ($line->qty==1) {
+ $pdf->SetFont('', 'BU', 9);
+ } else {
+ $pdf->SetFont('', 'BUI', 9);
+ }
+ }
- $pdf->MultiCell($w, $h, $label, 0, 'L');
+ $pdf->MultiCell($w, $h, $label, 0, 'L');
- if($description && !$hidedesc) {
- $posy = $pdf->GetY();
+ if ($description && !$hidedesc) {
+ $posy = $pdf->GetY();
- $pdf->SetFont('', '', 8);
+ $pdf->SetFont('', '', 8);
- $pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
-
- }
+ $pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
+ }
}
- function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
- // ultimate PDF hook O_o
-
- return $this->pdf_writelinedesc($parameters,$object,$action);
+ public function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='')
+ {
+ // ultimate PDF hook O_o
- }
+ return $this->pdf_writelinedesc($parameters, $object, $action);
+ }
- function isModSubtotalLine(&$parameters, &$object) {
-
- $i = & $parameters['i'];
-
- if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
- return true;
- }
+ public function isModSubtotalLine(&$parameters, &$object)
+ {
+ $i = & $parameters['i'];
- return false;
+ if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
+ return true;
+ }
- }
+ return false;
+ }
- function pdf_getlineqty($parameters=array(), &$object, &$action='') {
-
- if($this->isModSubtotalLine($parameters,$object) ){
-
- $this->resprints = ' ';
-
- return 1;
+ public function pdf_getlineqty($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
- }
-
- }
+ return 1;
+ }
+ }
- function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
-
- if($this->isModSubtotalLine($parameters,$object) ){
-
- $this->resprints = ' ';
-
- return 1;
+ public function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
- }
- }
+ return 1;
+ }
+ }
- function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
- if($this->isModSubtotalLine($parameters,$object) ){
-
- $this->resprints = ' ';
+ public function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
- return 1;
- }
- }
+ return 1;
+ }
+ }
- function pdf_getlineunit($parameters=array(), &$object, &$action='') {
- if($this->isModSubtotalLine($parameters,$object) ){
- $this->resprints = ' ';
+ public function pdf_getlineunit($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
- return 1;
- }
- }
+ return 1;
+ }
+ }
- function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
- if($this->isModSubtotalLine($parameters,$object) ){
- $this->resprints = ' ';
+ public function pdf_getlineupexcltax($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
- return 1;
- }
- }
+ return 1;
+ }
+ }
- function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
- if($this->isModSubtotalLine($parameters,$object) ){
- $this->resprints = ' ';
- return 1;
- }
- }
+ public function pdf_getlineupwithtax($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
+ return 1;
+ }
+ }
- function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
- if($this->isModSubtotalLine($parameters,$object) ){
- $this->resprints = ' ';
- return 1;
- }
- }
+ public function pdf_getlinevatrate($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
+ return 1;
+ }
+ }
- function pdf_getlineprogress($parameters=array(), &$object, &$action='') {
- if($this->isModSubtotalLine($parameters,$object) ){
- $this->resprints = ' ';
- return 1;
- }
- }
+ public function pdf_getlineprogress($parameters=array(), &$object, &$action='')
+ {
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ $this->resprints = ' ';
+ return 1;
+ }
+ }
- function pdf_writelinedesc($parameters=array(), &$object, &$action='')
- {
- /**
+ public function pdf_writelinedesc($parameters=array(), &$object, &$action='')
+ {
+ /**
* @var $pdf TCPDF
*/
global $pdf,$conf;
- foreach($parameters as $key=>$value) {
- ${$key} = $value;
- }
-
- $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
- $hidedetails = (int)isset($_REQUEST['hidedetails']);
+ foreach ($parameters as $key=>$value) {
+ ${$key} = $value;
+ }
- if($this->isModSubtotalLine($parameters,$object) ){
+ $hideInnerLines = (int)isset($_REQUEST['hideInnerLines']);
+ $hidedetails = (int)isset($_REQUEST['hidedetails']);
- if ($hideInnerLines) { // si c une ligne de titre
+ if ($this->isModSubtotalLine($parameters, $object)) {
+ if ($hideInnerLines) { // si c une ligne de titre
$fk_parent_line=0;
- $TLines =array();
+ $TLines =array();
- foreach($object->lines as $k=>&$line)
- {
- if($line->product_type==9 && $line->rowid>0)
- {
- $fk_parent_line = $line->rowid;
+ foreach ($object->lines as $k=>&$line) {
+ if ($line->product_type==9 && $line->rowid>0) {
+ $fk_parent_line = $line->rowid;
- if($line->qty>90 && $line->total==0)
- {
- $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
+ if ($line->qty>90 && $line->total==0) {
+ $total = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
- $line->total_ht = $total;
- $line->total = $total;
- }
-
- }
+ $line->total_ht = $total;
+ $line->total = $total;
+ }
+ }
- if ($hideInnerLines)
- {
- if($line->product_type==9 && $line->rowid>0)
- {
- $TLines[] = $line; //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
- }
- }
- elseif ($hidedetails)
- {
- $TLines[] = $line; //Cas où je cache uniquement les prix des produits
- }
+ if ($hideInnerLines) {
+ if ($line->product_type==9 && $line->rowid>0) {
+ $TLines[] = $line; //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
+ }
+ } elseif ($hidedetails) {
+ $TLines[] = $line; //Cas où je cache uniquement les prix des produits
+ }
- if ($line->product_type != 9) { // jusqu'au prochain titre ou total
+ if ($line->product_type != 9) { // jusqu'au prochain titre ou total
//$line->fk_parent_line = $fk_parent_line;
-
- }
+ }
/*if($hideTotal) {
$line->total = 0;
$line->subprice= 0;
}*/
- }
+ }
- $object->lines = $TLines;
+ $object->lines = $TLines;
- if($i>count($object->lines)) return 1;
- }
+ if ($i>count($object->lines)) {
+ return 1;
+ }
+ }
- $line = &$object->lines[$i];
+ $line = &$object->lines[$i];
- if($line->info_bits>0) { // PAGE BREAK
+ if ($line->info_bits>0) { // PAGE BREAK
$pdf->addPage();
- $posy = $pdf->GetY();
- }
+ $posy = $pdf->GetY();
+ }
- if($line->label=='') {
- $label = $outputlangs->convToOutputCharset($line->desc);
- $description='';
- }
- else {
- $label = $outputlangs->convToOutputCharset($line->label);
- $description=$outputlangs->convToOutputCharset(dol_htmlentitiesbr($line->desc));
- }
+ if ($line->label=='') {
+ $label = $outputlangs->convToOutputCharset($line->desc);
+ $description='';
+ } else {
+ $label = $outputlangs->convToOutputCharset($line->label);
+ $description=$outputlangs->convToOutputCharset(dol_htmlentitiesbr($line->desc));
+ }
- if($line->qty>90) {
+ if ($line->qty>90) {
+ if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
+ $label .= ' '.$this->getTitle($object, $line);
+ }
- if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line);
-
- $pageBefore = $pdf->getPage();
- $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
- $pageAfter = $pdf->getPage();
+ $pageBefore = $pdf->getPage();
+ $this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
+ $pageAfter = $pdf->getPage();
/*
if($pageAfter>$pageBefore) {
print "ST $pageAfter>$pageBefore
";
@@ -793,15 +762,13 @@ function pdf_writelinedesc($parameters=array(), &$object, &$action='')
$posy = $pdf->GetY();
print 'add ST'.$pdf->getPage().'
';
}
- */
+ */
$posy = $pdf->GetY();
-
- }
- else{
- $pageBefore = $pdf->getPage();
+ } else {
+ $pageBefore = $pdf->getPage();
- $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
- $pageAfter = $pdf->getPage();
+ $this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
+ $pageAfter = $pdf->getPage();
/*if($pageAfter>$pageBefore) {
print "T $pageAfter>$pageBefore
";
@@ -815,11 +782,11 @@ function pdf_writelinedesc($parameters=array(), &$object, &$action='')
}
*/
$posy = $pdf->GetY();
- }
+ }
// if($line->rowid==47) exit;
return 1;
- }
+ }
/* TODO je desactive parce que je comprends pas PH Style, mais à test
else {
@@ -832,33 +799,30 @@ function pdf_writelinedesc($parameters=array(), &$object, &$action='')
}
}*/
-
-
-
- }
+ }
/**
* Permet de récupérer le titre lié au sous-total
*
* @return string
*/
- function getTitle(&$object, &$currentLine)
+ public function getTitle(&$object, &$currentLine)
{
- $res = '';
+ $res = '';
- foreach ($object->lines as $line)
- {
- if ($line->id == $currentLine->id) break;
+ foreach ($object->lines as $line) {
+ if ($line->id == $currentLine->id) {
+ break;
+ }
- $qty_search = 100 - $currentLine->qty;
+ $qty_search = 100 - $currentLine->qty;
- if ($line->product_type == 9 && $line->special_code == $this->module_number && $line->qty == $qty_search)
- {
- $res = ($line->label) ? $line->label : (($line->description) ? $line->description : $line->desc);
- }
- }
+ if ($line->product_type == 9 && $line->special_code == $this->module_number && $line->qty == $qty_search) {
+ $res = ($line->label) ? $line->label : (($line->description) ? $line->description : $line->desc);
+ }
+ }
- return $res;
+ return $res;
}
/**
@@ -868,46 +832,49 @@ function getTitle(&$object, &$currentLine)
* @param $hookmanager HookManager
* @return int
*/
- function printObjectLine ($parameters, &$object, &$action, $hookmanager){
-
- global $conf,$langs,$user;
+ public function printObjectLine($parameters, &$object, &$action, $hookmanager)
+ {
+ global $conf,$langs,$user;
- $num = &$parameters['num'];
- $line = &$parameters['line'];
- $i = &$parameters['i'];
+ $num = &$parameters['num'];
+ $line = &$parameters['line'];
+ $i = &$parameters['i'];
- $contexts = explode(':',$parameters['context']);
+ $contexts = explode(':', $parameters['context']);
- if($line->special_code!=$this->module_number || $line->product_type!=9) {
- null;
- }
- else if (in_array('invoicecard',$contexts) || in_array('propalcard',$contexts) || in_array('ordercard',$contexts))
- {
-
- if($object->element=='facture')$idvar = 'facid';
- else $idvar='id';
+ if ($line->special_code!=$this->module_number || $line->product_type!=9) {
+ null;
+ } elseif (in_array('invoicecard', $contexts) || in_array('propalcard', $contexts) || in_array('ordercard', $contexts)) {
+ if ($object->element=='facture') {
+ $idvar = 'facid';
+ } else {
+ $idvar='id';
+ }
- if($action=='savelinetitle' && $_POST['lineid']===$line->id) {
-
- $description = ($line->qty>90) ? '' : GETPOST('linedescription');
- $pagebreak = (int)GETPOST('pagebreak');
+ if ($action=='savelinetitle' && $_POST['lineid']===$line->id) {
+ $description = ($line->qty>90) ? '' : GETPOST('linedescription');
+ $pagebreak = (int)GETPOST('pagebreak');
/**
* @var $object Facture
*/
- if($object->element=='facture') $object->updateline($line->id,$description, 0,$line->qty,0,'','',0,0,0,'HT',$pagebreak,9,0,0,null,0,$_POST['linetitle'], $this->module_number);
+ if ($object->element=='facture') {
+ $object->updateline($line->id, $description, 0, $line->qty, 0, '', '', 0, 0, 0, 'HT', $pagebreak, 9, 0, 0, null, 0, $_POST['linetitle'], $this->module_number);
+ }
/**
* @var $object Propal
*/
- else if($object->element=='propal') $object->updateline($line->id, 0,$line->qty,0,0,0,0, $description ,'HT',$pagebreak,$this->module_number,0,0,0,0,$_POST['linetitle'],9);
+ elseif ($object->element=='propal') {
+ $object->updateline($line->id, 0, $line->qty, 0, 0, 0, 0, $description, 'HT', $pagebreak, $this->module_number, 0, 0, 0, 0, $_POST['linetitle'], 9);
+ }
/**
* @var $object Commande
*/
- else if($object->element=='commande') $object->updateline($line->id,$description, 0,$line->qty,0,0,0,0,'HT',$pagebreak,'','',9,0,0,null,0,$_POST['linetitle'], $this->module_number);
-
- }
- else if($action=='editlinetitle') {
- ?>
+ elseif ($object->element=='commande') {
+ $object->updateline($line->id, $description, 0, $line->qty, 0, 0, 0, 0, 'HT', $pagebreak, '', '', 9, 0, 0, null, 0, $_POST['linetitle'], $this->module_number);
+ }
+ } elseif ($action=='editlinetitle') {
+ ?>
+
+ } else {
+ if ((float)DOL_VERSION <= 3.4) {
+ ?>
description)) $line->description = $line->desc;
- $colspan = 5;
- if($conf->margin->enabled) $colspan++;
- if($conf->global->DISPLAY_MARGIN_RATES) $colspan++;
- if($conf->global->DISPLAY_MARK_RATES) $colspan++;
- if($object->element == 'facture' && $conf->global->INVOICE_USE_SITUATION && $object->type == Facture::TYPE_SITUATION) $colspan++;
- if($conf->global->PRODUCT_USE_UNITS) $colspan++;
+ if (empty($line->description)) {
+ $line->description = $line->desc;
+ }
+ $colspan = 5;
+ if ($conf->margin->enabled) {
+ $colspan++;
+ }
+ if ($conf->global->DISPLAY_MARGIN_RATES) {
+ $colspan++;
+ }
+ if ($conf->global->DISPLAY_MARK_RATES) {
+ $colspan++;
+ }
+ if ($object->element == 'facture' && $conf->global->INVOICE_USE_SITUATION && $object->type == Facture::TYPE_SITUATION) {
+ $colspan++;
+ }
+ if ($conf->global->PRODUCT_USE_UNITS) {
+ $colspan++;
+ }
/* Titre */
//var_dump($line);
?>
- id ) {
-
- if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
- {
- $qty_displayed = ($line->qty >=1 && $line->qty <= 9) ? $line->qty : 100 - $line->qty;
- print img_picto('', 'subsubtotal@subtotal').''.$qty_displayed.' ';
- }
- else
- {
- if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
- else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' ';
- }
+ ?>;">
+ | id) {
+ if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
+ $qty_displayed = ($line->qty >=1 && $line->qty <= 9) ? $line->qty : 100 - $line->qty;
+ print img_picto('', 'subsubtotal@subtotal').''.$qty_displayed.' ';
+ } else {
+ if ($line->qty<=1) {
+ print img_picto('', 'subtotal@subtotal');
+ } elseif ($line->qty==2) {
+ print img_picto('', 'subsubtotal@subtotal').' ';
+ }
+ }
- if($line->label=='') {
- $line->label = $line->description;
- $line->description='';
- }
+ if ($line->label=='') {
+ $line->label = $line->description;
+ $line->description='';
+ }
- ?>
+ ?>
|
+ ?>
qty>90) {
- /* Total */
+ if ($line->qty>90) {
+ /* Total */
$total_line = $this->getTotalLineFromObject($object, $line, $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL);
- ?>
+ ?>
|
+
+ } else {
+ ?>
|
+
+ }
+ ?>
id ) {
- ?>
+ if ($action=='editlinetitle' && $_REQUEST['lineid']==$line->id) {
+ ?>
statut == 0 && $user->rights->{$object->element}->creer) {
-
- ?>
+
+ } else {
+ if ($object->statut == 0 && $user->rights->{$object->element}->creer) {
+ ?>
+ ?>
|
id ) {
- ?>
+ if ($action=='editlinetitle' && $_REQUEST['lineid']===$line->id) {
+ ?>
statut == 0 && $user->rights->{$object->element}->creer) {
-
- ?>
+
+ } else {
+ if ($object->statut == 0 && $user->rights->{$object->element}->creer) {
+ ?>
- qty<10) {
-
- ?>
+ if ($line->qty<10) {
+ ?>
trans('deleteWithAllLines'), 'delete_all@subtotal') ?>
-
+ ?>
|
- 1 && empty($conf->browser->phone)) { ?>
+ 1 && empty($conf->browser->phone)) {
+ ?>
|
-
- browser->phone) && ($object->statut == 0 && $user->rights->{$object->element}->creer))?' class="tdlineupdown"':''); ?>> |
-
+
+ browser->phone) && ($object->statut == 0 && $user->rights->{$object->element}->creer))?' class="tdlineupdown"':'');
+ ?>> |
+
element=='facture') $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
+ if ($object->element=='facture') {
+ $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number);
+ }
/**
* @var $object Propal
*/
- else if($object->element=='propal') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
+ elseif ($object->element=='propal') {
+ $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, -1, TSubtotal::$module_number);
+ }
/**
* @var $object Commande
*/
- else if($object->element=='commande') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
-
- }
- else {
- /**
+ elseif ($object->element=='commande') {
+ $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, -1, TSubtotal::$module_number);
+ }
+ } else {
+ /**
* @var $object Facture
*/
- if($object->element=='facture') $res = $object->addline($label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
+ if ($object->element=='facture') {
+ $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number);
+ }
/**
* @var $object Propal
*/
- else if($object->element=='propal') $res = $object->addline($label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
+ elseif ($object->element=='propal') {
+ $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, -1, TSubtotal::$module_number);
+ }
/**
* @var $object Commande
*/
- else if($object->element=='commande') $res = $object->addline($label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
- }
-
- }
-
+ elseif ($object->element=='commande') {
+ $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, -1, TSubtotal::$module_number);
+ }
+ }
+ }
}
diff --git a/config.php b/config.php
index b4197128..41b2fd25 100644
--- a/config.php
+++ b/config.php
@@ -1,8 +1,12 @@
load("main");
- $langs->load("bills");
+ $langs->load("main");
+ $langs->load("bills");
- $this->db = $db;
- $this->name = "einstein_subtotal";
- $this->description = 'Modèle de commande incluant des spécificités du module sous-total.';
+ $this->db = $db;
+ $this->name = "einstein_subtotal";
+ $this->description = 'Modèle de commande incluant des spécificités du module sous-total.';
// Dimension page pour format A4
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
- $this->page_largeur = $formatarray['width'];
- $this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
-
- $this->option_logo = 1; // Affiche logo
+ $formatarray=pdf_getFormat();
+ $this->page_largeur = $formatarray['width'];
+ $this->page_hauteur = $formatarray['height'];
+ $this->format = array($this->page_largeur,$this->page_hauteur);
+ $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
+ $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
+ $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
+ $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+
+ $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode reglement
$this->option_condreg = 1; // Affiche conditions reglement
@@ -99,32 +99,37 @@ function __construct($db)
// Get source company
$this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
+ if (empty($this->emetteur->country_code)) {
+ $this->emetteur->country_code=substr($langs->defaultlang, -2);
+ } // By default, if was not defined
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
- $this->posxtva=112;
- $this->posxup=126;
- $this->posxqty=145;
- $this->posxdiscount=162;
- $this->postotalht=174;
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
- $this->posxpicture=$this->posxtva - (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->posxtva=112;
+ $this->posxup=126;
+ $this->posxqty=145;
+ $this->posxdiscount=162;
+ $this->postotalht=174;
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $this->posxtva=$this->posxup;
+ }
+ $this->posxpicture=$this->posxtva - (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->posxpicture-=20;
- $this->posxtva-=20;
- $this->posxup-=20;
- $this->posxqty-=20;
- $this->posxdiscount-=20;
- $this->postotalht-=20;
+ $this->posxtva-=20;
+ $this->posxup-=20;
+ $this->posxqty-=20;
+ $this->posxdiscount-=20;
+ $this->postotalht-=20;
}
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva=array();
+ $this->localtax1=array();
+ $this->localtax2=array();
+ $this->atleastoneratenotnull=0;
+ $this->atleastonediscount=0;
}
/**
@@ -138,194 +143,185 @@ function __construct($db)
* @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)
+ public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
{
- global $user,$langs,$conf,$mysoc,$db,$hookmanager;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ 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';
+ 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("orders");
- $outputlangs->load("deliveries");
+ $outputlangs->load("main");
+ $outputlangs->load("dict");
+ $outputlangs->load("companies");
+ $outputlangs->load("bills");
+ $outputlangs->load("products");
+ $outputlangs->load("orders");
+ $outputlangs->load("deliveries");
- $nblignes = count($object->lines);
+ $nblignes = count($object->lines);
- if ($conf->commande->dir_output)
- {
- $object->fetch_thirdparty();
+ if ($conf->commande->dir_output) {
+ $object->fetch_thirdparty();
- $deja_regle = "";
+ $deja_regle = "";
// Definition of $dir and $file
- if ($object->specimen)
- {
- $dir = $conf->commande->dir_output;
- $file = $dir . "/SPECIMEN.pdf";
- }
- else
- {
- $objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->commande->dir_output . "/" . $objectref;
- $file = $dir . "/" . $objectref . ".pdf";
+ if ($object->specimen) {
+ $dir = $conf->commande->dir_output;
+ $file = $dir . "/SPECIMEN.pdf";
+ } else {
+ $objectref = dol_sanitizeFileName($object->ref);
+ $dir = $conf->commande->dir_output . "/" . $objectref;
+ $file = $dir . "/" . $objectref . ".pdf";
}
- if (! file_exists($dir))
- {
- if (dol_mkdir($dir) < 0)
- {
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
- return 0;
- }
- }
+ 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);
+ 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
+ $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
+ $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);
+ $pdf->SetAutoPageBreak(1, 0);
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ 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))
- {
+ 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("Order"));
- $pdf->SetCreator("Dolibarr ".DOL_VERSION);
- $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
- $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order"));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ $pdf->Open();
+ $pagenb=0;
+ $pdf->SetDrawColor(128, 128, 128);
+
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("Order"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order"));
+ if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
+ $pdf->SetCompression(false);
+ }
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $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++;
- }
+ for ($i = 0 ; $i < $nblignes ; $i++) {
+ if ($object->lines[$i]->remise_percent) {
+ $this->atleastonediscount++;
+ }
}
- if (empty($this->atleastonediscount))
- {
- $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);
+ if (empty($this->atleastonediscount)) {
+ $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;
- }
+ }
// 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);
+ 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;
+ $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 (! 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 (! 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;
+ }
+ 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;
+ $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);
+ $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;
- }
+ $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;
+ $iniY = $tab_top + 7;
+ $curY = $tab_top + 7;
+ $nexY = $tab_top + 7;
- $inPackage = false;
- $TPackageInfos = array();
- $TChilds = array();
- $package_qty = 0;
- $TStack = array();
+ $inPackage = false;
+ $TPackageInfos = array();
+ $TChilds = array();
+ $package_qty = 0;
+ $TStack = array();
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
- {
- $package_qty = $TStack[count($TStack) - 1]['package_qty'];
- $inPackage = count($TStack) > 0;
+ for ($i = 0 ; $i < $nblignes ; $i++) {
+ $package_qty = $TStack[count($TStack) - 1]['package_qty'];
+ $inPackage = count($TStack) > 0;
// Ligne de titre
if ($object->lines[$i]->product_type == 9 && $object->lines[$i]->qty < 97 && $object->lines[$i]->fk_product > 0) {
- $inPackage = true;
+ $inPackage = true;
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- if (!empty($object->lines[$i]->fk_product)) {
- $product = new Product($db);
- $product->fetch($object->lines[$i]->fk_product);
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ if (!empty($object->lines[$i]->fk_product)) {
+ $product = new Product($db);
+ $product->fetch($object->lines[$i]->fk_product);
- $TChilds = $product->getChildsArbo($product->id);
+ $TChilds = $product->getChildsArbo($product->id);
- $TStack[count($TStack)] = array(
+ $TStack[count($TStack)] = array(
'childs' => $TChilds,
'package' => array(),
'package_qty' => 0
@@ -334,126 +330,131 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Si on se trouvait déjà dans un package, on rajoute ce produit à la liste des produits
// du précédent package
if (count($TStack) > 1) {
- $TStack[count($TStack) - 2]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
+ $TStack[count($TStack) - 2]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
}
- }
- }
+ }
+ }
}
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- if ($inPackage && $object->lines[$i]->product_type != 9 && $object->lines[$i]->fk_product > 0) {
- $TStack[count($TStack) - 1]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
- }
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ if ($inPackage && $object->lines[$i]->product_type != 9 && $object->lines[$i]->fk_product > 0) {
+ $TStack[count($TStack) - 1]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
+ }
+ }
// Ligne de sous-total
if ($inPackage && $object->lines[$i]->product_type == 9 && $object->lines[$i]->qty >= 97) {
- if (count($TStack) <= 1) {
- $inPackage = false;
- }
+ if (count($TStack) <= 1) {
+ $inPackage = false;
+ }
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- // Comparaison pour déterminer la quantité de package
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ // Comparaison pour déterminer la quantité de package
$TProducts = array_keys($TStack[count($TStack) - 1]['package']);
- $TProductsChilds = array_keys($TStack[count($TStack) - 1]['childs']);
+ $TProductsChilds = array_keys($TStack[count($TStack) - 1]['childs']);
- if ($TProductsChilds == $TProducts) {
- // Il s'agit d'un package
+ if ($TProductsChilds == $TProducts) {
+ // Il s'agit d'un package
// On récupére la quantité
$first_child_id = $TProducts[0];
- $document_qty = $TStack[count($TStack) - 1]['package'][$first_child_id];
- $base_qty = $TStack[count($TStack) - 1]['childs'][$first_child_id][1];
+ $document_qty = $TStack[count($TStack) - 1]['package'][$first_child_id];
+ $base_qty = $TStack[count($TStack) - 1]['childs'][$first_child_id][1];
- $TStack[count($TStack) - 1]['package_qty'] = $document_qty / $base_qty;
- $package_qty = $TStack[count($TStack) - 1]['package_qty'];
- }
+ $TStack[count($TStack) - 1]['package_qty'] = $document_qty / $base_qty;
+ $package_qty = $TStack[count($TStack) - 1]['package_qty'];
+ }
- array_pop($TStack);
- }
+ array_pop($TStack);
+ }
}
- $curY = $nexY;
- $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
- $pdf->SetTextColor(0,0,0);
+ $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.
+ $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;
+ $showpricebeforepagebreak=1;
+
+ $pdf->startTransaction();
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva-$curX, 3, $curX, $curY, $hideref, $hidedesc);
+ $pageposafter=$pdf->getPage();
+ if ($pageposafter > $pageposbefore) {
+ // There is a pagebreak
- $pdf->startTransaction();
- pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
- $pageposafter=$pdf->getPage();
- if ($pageposafter > $pageposbefore) // There is a pagebreak
- {
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $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);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
- 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
- {
- $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);
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva-$curX, 4, $curX, $curY, $hideref, $hidedesc);
+ $pageposafter=$pdf->getPage();
+ $posyafter=$pdf->GetY();
+ 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
+
+ $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
+ } else {
+ // We found a page break
$showpricebeforepagebreak=0;
- }
- }
- else // No pagebreak
- {
+ }
+ } else {
+ // No pagebreak
+
$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.
+ $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->setPage($pageposafter);
+ $curY = $tab_top_newpage;
}
- $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- // Si on ne doit masquer que les sous-produits
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ // Si on ne doit masquer que les sous-produits
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, 0);
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, 0);
} else {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+ $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');
+ $pdf->SetXY($this->posxtva, $curY);
+ $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
}
// Unit price before discount
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, 0);
+ $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, 0);
} else {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
+ $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);
+ $pdf->SetXY($this->posxup, $curY);
+ $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
// Booléen pour déterminer s'il s'agit d'une ligne de titre ou non
$isTitle = false;
@@ -461,182 +462,186 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Quantity
// Récupération de la quantité à afficher
if ($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY) {
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
- $qty = $package_qty;
- } else {
- $qty = pdf_getlineqty($object, $i, $outputlangs, 0);
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
+ $qty = $package_qty;
+ } else {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, 0);
+ }
} else {
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
- $qty = $package_qty;
- } else {
- $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
+ $qty = $package_qty;
+ } else {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ }
}
- $pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
+ $pdf->SetXY($this->posxqty, $curY);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 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);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
+ if ($object->lines[$i]->remise_percent) {
+ $pdf->SetXY($this->posxdiscount-2, $curY);
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
}
// Total HT line
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, 0);
+ $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, 0);
} else {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+ $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);
+ $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;
+ $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=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
- {
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
- $localtax1_type = $localtaxtmp_array[0];
- $localtax2_type = $localtaxtmp_array[2];
+ && (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
+ // and there is local tax
+
+ $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 & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
- $this->tva[$vatrate] += $tvaligne;
+ 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 & 0x01) == 0x01) {
+ $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->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
+ 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));
+ $pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $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);
+ 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);
}
- $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);
+ 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);
- }
+ 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;
+ 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);
- if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
- // Affiche zone totaux
+ if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
+ // Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
- }
+ }
// Affiche zone versements
- if ($deja_regle)
- {
- $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
+ if ($deja_regle) {
+ $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
}
// Pied de page
- $this->_pagefoot($pdf,$object,$outputlangs);
- if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) {
+ $pdf->AliasNbPages();
+ }
- $pdf->Close();
+ $pdf->Close();
- $pdf->Output($file,'F');
+ $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
+ $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));
+ 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","COMMANDE_OUTPUTDIR");
- return 0;
- }
- $this->error=$langs->trans("ErrorUnknown");
- return 0; // Erreur par defaut
+ return 1; // Pas d'erreur
+ } else {
+ $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ } else {
+ $this->error=$langs->trans("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
+ return 0;
+ }
+ $this->error=$langs->trans("ErrorUnknown");
+ return 0; // Erreur par defaut
}
/**
@@ -648,9 +653,8 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
* @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK
*/
- function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
+ public function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{
-
}
@@ -663,40 +667,38 @@ function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
* @param Translate $outputlangs Langs object
* @return void
*/
- function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ public function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
- global $conf;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ global $conf;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+ if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
- $posy=$pdf->GetY()+4;
+ $posy=$pdf->GetY()+4;
}
- $posxval=52;
+ $posxval=52;
// Show payments conditions
- if ($object->cond_reglement_code || $object->cond_reglement)
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentConditions").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
-
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
- $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
- $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
-
- $posy=$pdf->GetY()+3;
+ if ($object->cond_reglement_code || $object->cond_reglement) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentConditions").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement);
+ $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
+
+ $posy=$pdf->GetY()+3;
}
// Check a payment mode is defined
@@ -727,115 +729,105 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
}*/
// Show planed date of delivery
- if (! empty($object->date_livraison))
- {
+ if (! empty($object->date_livraison)) {
$outputlangs->load("sendings");
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
- $pdf->MultiCell(80, 4, $dlp, 0, 'L');
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
+ $pdf->MultiCell(80, 4, $dlp, 0, 'L');
$posy=$pdf->GetY()+1;
- }
- elseif ($object->availability_code || $object->availability) // Show availability conditions
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
- $lib_availability=str_replace('\n',"\n",$lib_availability);
- $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
-
- $posy=$pdf->GetY()+1;
- }
+ } elseif ($object->availability_code || $object->availability) {
+ // Show availability conditions
+
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
+ $lib_availability=str_replace('\n', "\n", $lib_availability);
+ $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
+
+ $posy=$pdf->GetY()+1;
+ }
// Show payment mode
if ($object->mode_reglement_code
&& $object->mode_reglement_code != 'CHQ'
- && $object->mode_reglement_code != 'VIR')
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentMode").':';
- $pdf->MultiCell(80, 5, $titre, 0, 'L');
+ && $object->mode_reglement_code != 'VIR') {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentMode").':';
+ $pdf->MultiCell(80, 5, $titre, 0, 'L');
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
- $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
- $posy=$pdf->GetY()+2;
- }
+ $posy=$pdf->GetY()+2;
+ }
// Show payment mode CHQ
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
- {
- // Si mode reglement non force ou si force a CHQ
- if (! empty($conf->global->FACTURE_CHQ_NUMBER))
- {
- if ($conf->global->FACTURE_CHQ_NUMBER > 0)
- {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
+ // Si mode reglement non force ou si force a CHQ
+ if (! empty($conf->global->FACTURE_CHQ_NUMBER)) {
+ 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->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->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
+ $pdf->SetFont('', 'B', $default_font_size - 3);
+ $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->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
}
- if ($conf->global->FACTURE_CHQ_NUMBER == -1)
- {
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
$pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetFont('','B', $default_font_size - 3);
- $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->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
+ $pdf->SetFont('', 'B', $default_font_size - 3);
+ $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->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
}
}
- }
+ }
// 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($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($bankid);
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
+ 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($bankid);
- $curx=$this->marge_gauche;
- $cury=$posy;
+ $curx=$this->marge_gauche;
+ $cury=$posy;
- $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
+ $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
- $posy+=2;
- }
+ $posy+=2;
+ }
}
- return $posy;
+ return $posy;
}
@@ -849,251 +841,248 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
- function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ public function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
global $conf,$mysoc;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- $tab2_top = $posy;
- $tab2_hl = 4;
- $pdf->SetFont('','', $default_font_size - 1);
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('', '', $default_font_size - 1);
// Tableau total
- $col1x = 120; $col2x = 170;
- if ($this->page_largeur < 210) // To work with US executive format
- {
+ $col1x = 120;
+ $col2x = 170;
+ if ($this->page_largeur < 210) {
+ // To work with US executive format
+
$col2x-=20;
- }
- $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
- $useborder=0;
- $index = 0;
+ $useborder=0;
+ $index = 0;
// Total HT
- $pdf->SetFillColor(255,255,255);
- $pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
- $pdf->SetFillColor(248,248,248);
-
- $this->atleastoneratenotnull=0;
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
- {
- // Nothing to do
- }
- else
- {
- //Local tax 1 before VAT
+ $pdf->SetFillColor(248, 248, 248);
+
+ $this->atleastoneratenotnull=0;
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
+ // Nothing to do
+ } else {
+ //Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach( $this->localtax1 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey!=0) // On affiche pas taux 0
- {
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('1','3','5'))) {
+ continue;
+ }
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey!=0) {
+ // On affiche pas taux 0
+
//$this->atleastoneratenotnull++;
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach( $this->localtax2 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey!=0) // On affiche pas taux 0
- {
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('1','3','5'))) {
+ continue;
+ }
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey!=0) {
+ // On affiche pas taux 0
+
//$this->atleastoneratenotnull++;
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-
- }
- }
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
// VAT
- foreach($this->tva as $tvakey => $tvaval)
- {
- if ($tvakey > 0) // On affiche pas taux 0
- {
- $this->atleastoneratenotnull++;
-
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ foreach ($this->tva as $tvakey => $tvaval) {
+ if ($tvakey > 0) {
+ // On affiche pas taux 0
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $this->atleastoneratenotnull++;
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
+ $totalvat.=vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
}
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach( $this->localtax1 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey != 0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2','4','6'))) {
+ continue;
+ }
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) {
+ // On affiche pas taux 0
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
+ //$this->atleastoneratenotnull++;
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach( $this->localtax2 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey != 0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2','4','6'))) {
+ continue;
+ }
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) {
+ // On affiche pas taux 0
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ //$this->atleastoneratenotnull++;
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
// Total TTC
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
- }
- }
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
+ }
+ }
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetTextColor(0, 0, 0);
- $creditnoteamount=0;
- $depositsamount=0;
+ $creditnoteamount=0;
+ $depositsamount=0;
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
- if (! empty($object->paye)) $resteapayer=0;
+ if (! empty($object->paye)) {
+ $resteapayer=0;
+ }
- if ($deja_regle > 0)
- {
- // Already paid + Deposits
+ if ($deja_regle > 0) {
+ // Already paid + Deposits
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
- $index++;
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $index++;
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetTextColor(0,0,0);
- }
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetTextColor(0, 0, 0);
+ }
- $index++;
- return ($tab2_top + ($tab2_hl * $index));
+ $index++;
+ return ($tab2_top + ($tab2_hl * $index));
}
/**
@@ -1108,87 +1097,81 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
* @param int $hidebottom Hide bottom bar of array
* @return void
*/
- function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
+ public function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{
- global $conf;
+ global $conf;
// Force to disable hidetop and hidebottom
$hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ if ($hidetop) {
+ $hidetop=-1;
+ }
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
// Amount in (at tab_top - 1)
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
- if (empty($hidetop))
- {
- $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
- $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+ if (empty($hidetop)) {
+ $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $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, 5, '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);
- $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetDrawColor(128, 128, 128);
+ $pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
- if (empty($hidetop))
- {
- $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
+ if (empty($hidetop)) {
+ $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');
- }
-
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxtva-3, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
- }
+ $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
}
- $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
- }
-
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
- }
-
- $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- if ($this->atleastonediscount)
- {
- $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
- }
- }
-
- if ($this->atleastonediscount)
- {
- $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
- }
- if (empty($hidetop))
- {
- $pdf->SetXY($this->postotalht-1, $tab_top+1);
- $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
- }
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxtva-3, $tab_top+1);
+ $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+ }
+ }
+
+ $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxup-1, $tab_top+1);
+ $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
+ }
+
+ $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxqty-1, $tab_top+1);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+ }
+
+ $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ if ($this->atleastonediscount) {
+ $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+ }
+ }
+
+ if ($this->atleastonediscount) {
+ $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+ }
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->postotalht-1, $tab_top+1);
+ $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
+ }
}
/**
@@ -1200,174 +1183,170 @@ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0,
* @param Translate $outputlangs Object lang for output
* @return void
*/
- function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ public function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
- global $conf,$langs,$hookmanager;
+ global $conf,$langs,$hookmanager;
- $outputlangs->load("main");
- $outputlangs->load("bills");
- $outputlangs->load("propal");
- $outputlangs->load("companies");
- $outputlangs->load("orders");
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $outputlangs->load("main");
+ $outputlangs->load("bills");
+ $outputlangs->load("propal");
+ $outputlangs->load("companies");
+ $outputlangs->load("orders");
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
+ pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
- {
- pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
+ if ($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
}
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFont('','B', $default_font_size + 3);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy=$this->marge_haute;
+ $posx=$this->page_largeur-$this->marge_droite-100;
- $pdf->SetXY($this->marge_gauche,$posy);
+ $pdf->SetXY($this->marge_gauche, $posy);
// Logo
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
- if ($this->emetteur->logo)
- {
- if (is_readable($logo))
- {
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- }
- else
- {
- $pdf->SetTextColor(200,0,0);
- $pdf->SetFont('','B', $default_font_size -2);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
- }
- }
- else
- {
- $text=$this->emetteur->name;
- $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
- }
+ if ($this->emetteur->logo) {
+ if (is_readable($logo)) {
+ $height=pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ } else {
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size -2);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
+ } else {
+ $text=$this->emetteur->name;
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
+ }
- $pdf->SetFont('','B', $default_font_size + 3);
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $title=$outputlangs->transnoentities("Order");
- $pdf->MultiCell(100, 3, $title, '', 'R');
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $title=$outputlangs->transnoentities("Order");
+ $pdf->MultiCell(100, 3, $title, '', 'R');
- $pdf->SetFont('','B',$default_font_size);
+ $pdf->SetFont('', 'B', $default_font_size);
- $posy+=5;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
+ $posy+=5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
- $posy+=1;
- $pdf->SetFont('','', $default_font_size - 1);
+ $posy+=1;
+ $pdf->SetFont('', '', $default_font_size - 1);
- if ($object->ref_client)
- {
- $posy+=5;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
- }
+ if ($object->ref_client) {
+ $posy+=5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ }
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
- $posy+=2;
+ $posy+=2;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
- if ($showaddress)
- {
- // Sender properties
+ if ($showaddress) {
+ // Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
// Show sender
$posy=42;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posx=$this->marge_gauche;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx=$this->page_largeur-$this->marge_droite-80;
+ }
+ $hautcadre=40;
// Show sender frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx,$posy-5);
- $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
- $pdf->SetXY($posx,$posy);
- $pdf->SetFillColor(230,230,230);
- $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
- $pdf->SetTextColor(0,0,60);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy-5);
+ $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy=$pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2,$posy);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
+ $pdf->SetXY($posx+2, $posy);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If CUSTOMER contact defined on order, we use it
$usecontact=false;
- $arrayidcontact=$object->getIdContact('external','CUSTOMER');
- if (count($arrayidcontact) > 0)
- {
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
- }
+ $arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
+ if (count($arrayidcontact) > 0) {
+ $usecontact=true;
+ $result=$object->fetch_contact($arrayidcontact[0]);
+ }
// Recipient name
- if (! empty($usecontact))
- {
- // On peut utiliser le nom de la societe du contact
- if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
- else $socname = $object->client->name;
- $carac_client_name=$outputlangs->convToOutputCharset($socname);
- }
- else
- {
- $carac_client_name=$outputlangs->convToOutputCharset($object->client->name);
+ if (! empty($usecontact)) {
+ // On peut utiliser le nom de la societe du contact
+ if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
+ $socname = $object->contact->socname;
+ } else {
+ $socname = $object->client->name;
+ }
+ $carac_client_name=$outputlangs->convToOutputCharset($socname);
+ } else {
+ $carac_client_name=$outputlangs->convToOutputCharset($object->client->name);
}
- $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');
+ $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, ($usecontact?$object->contact:''), $usecontact, 'target');
// Show recipient
$widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
+ if ($this->page_largeur < 210) {
+ $widthrecbox=84;
+ } // To work with US executive format
$posy=42;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx=$this->marge_gauche;
+ }
// Show recipient frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx+2,$posy-5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx+2, $posy-5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
+ $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
// Show recipient information
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
- $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
- }
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetXY($posx+2, $posy+4+(dol_nboflines_bis($carac_client_name, 50)*4));
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
+ }
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetTextColor(0, 0, 0);
}
/**
@@ -1379,11 +1358,9 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
*/
- function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
+ public function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
{
- $showdetails=0;
- return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
+ $showdetails=0;
+ return pdf_pagefoot($pdf, $outputlangs, 'COMMANDE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
-
}
-
diff --git a/core/modules/facture/doc/pdf_crabe_subtotal.modules.php b/core/modules/facture/doc/pdf_crabe_subtotal.modules.php
index 6771286c..c7a48410 100755
--- a/core/modules/facture/doc/pdf_crabe_subtotal.modules.php
+++ b/core/modules/facture/doc/pdf_crabe_subtotal.modules.php
@@ -38,23 +38,23 @@
*/
class pdf_crabe_subtotal extends ModelePDFFactures
{
- var $db;
- var $name;
- var $description;
- var $type;
+ public $db;
+ public $name;
+ public $description;
+ public $type;
- var $phpmin = array(4,3,0); // Minimum version of PHP required by module
- var $version = 'dolibarr';
+ public $phpmin = array(4,3,0); // Minimum version of PHP required by module
+ public $version = 'dolibarr';
- var $page_largeur;
- var $page_hauteur;
- var $format;
- var $marge_gauche;
- var $marge_droite;
- var $marge_haute;
- var $marge_basse;
+ public $page_largeur;
+ public $page_hauteur;
+ public $format;
+ public $marge_gauche;
+ public $marge_droite;
+ public $marge_haute;
+ public $marge_basse;
- var $emetteur; // Objet societe qui emet
+ public $emetteur; // Objet societe qui emet
/**
@@ -62,29 +62,29 @@ class pdf_crabe_subtotal extends ModelePDFFactures
*
* @param DoliDB $db Database handler
*/
- function __construct($db)
+ public function __construct($db)
{
- global $conf,$langs,$mysoc;
+ global $conf,$langs,$mysoc;
- $langs->load("main");
- $langs->load("bills");
+ $langs->load("main");
+ $langs->load("bills");
- $this->db = $db;
- $this->name = "crabe_subtotal";
- $this->description = 'Modèle de facture incluant des spécificités pour le module sous-total.';
+ $this->db = $db;
+ $this->name = "crabe_subtotal";
+ $this->description = 'Modèle de facture incluant des spécificités pour le module sous-total.';
// Dimension page pour format A4
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
- $this->page_largeur = $formatarray['width'];
- $this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
-
- $this->option_logo = 1; // Affiche logo
+ $formatarray=pdf_getFormat();
+ $this->page_largeur = $formatarray['width'];
+ $this->page_hauteur = $formatarray['height'];
+ $this->format = array($this->page_largeur,$this->page_hauteur);
+ $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
+ $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
+ $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
+ $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+
+ $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode reglement
$this->option_condreg = 1; // Affiche conditions reglement
@@ -99,32 +99,37 @@ function __construct($db)
// Get source company
$this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
+ if (empty($this->emetteur->country_code)) {
+ $this->emetteur->country_code=substr($langs->defaultlang, -2);
+ } // By default, if was not defined
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
- $this->posxtva=112;
- $this->posxup=126;
- $this->posxqty=145;
- $this->posxdiscount=162;
- $this->postotalht=174;
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
- $this->posxpicture=$this->posxtva - (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->posxtva=112;
+ $this->posxup=126;
+ $this->posxqty=145;
+ $this->posxdiscount=162;
+ $this->postotalht=174;
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $this->posxtva=$this->posxup;
+ }
+ $this->posxpicture=$this->posxtva - (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->posxpicture-=20;
- $this->posxtva-=20;
- $this->posxup-=20;
- $this->posxqty-=20;
- $this->posxdiscount-=20;
- $this->postotalht-=20;
+ $this->posxtva-=20;
+ $this->posxup-=20;
+ $this->posxqty-=20;
+ $this->posxdiscount-=20;
+ $this->postotalht-=20;
}
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva=array();
+ $this->localtax1=array();
+ $this->localtax2=array();
+ $this->atleastoneratenotnull=0;
+ $this->atleastonediscount=0;
}
@@ -139,222 +144,216 @@ function __construct($db)
* @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)
+ public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
{
- global $user,$langs,$conf,$mysoc,$db,$hookmanager;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ 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';
+ 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("main");
+ $outputlangs->load("dict");
+ $outputlangs->load("companies");
+ $outputlangs->load("bills");
+ $outputlangs->load("products");
- $nblignes = count($object->lines);
+ $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 (! 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;
- }
+ break;
+ }
- if ($realpath) $realpatharray[$i]=$realpath;
- }
- }
- if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
+ if ($realpath) {
+ $realpatharray[$i]=$realpath;
+ }
+ }
+ }
+ if (count($realpatharray) == 0) {
+ $this->posxpicture=$this->posxtva;
+ }
- if ($conf->facture->dir_output)
- {
- $object->fetch_thirdparty();
+ if ($conf->facture->dir_output) {
+ $object->fetch_thirdparty();
- $deja_regle = $object->getSommePaiement();
- $amount_credit_notes_included = $object->getSumCreditNotesUsed();
- $amount_deposits_included = $object->getSumDepositsUsed();
+ $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 ($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))
- {
- // Add pdfgeneration hook
- if (! is_object($hookmanager))
- {
- include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ 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
+ $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
+ $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);
+ $pdf->SetAutoPageBreak(1, 0);
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ 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);
+ 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->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->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
+ $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++;
- }
+ for ($i = 0 ; $i < $nblignes ; $i++) {
+ if ($object->lines[$i]->remise_percent) {
+ $this->atleastonediscount++;
+ }
}
- if (empty($this->atleastonediscount))
- {
- $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);
+ if (empty($this->atleastonediscount)) {
+ $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;
- }
+ }
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
- $pagenb++;
+ 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);
+ $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;
+ $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 (! 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 (! 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;
+ }
+ 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;
+ $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;
-
- $inPackage = false;
- $TPackageInfos = array();
- $TChilds = array();
- $package_qty = 0;
- $TStack = array();
+ $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;
+
+ $inPackage = false;
+ $TPackageInfos = array();
+ $TChilds = array();
+ $package_qty = 0;
+ $TStack = array();
// Loop on each lines
- for ($i = 0; $i < $nblignes; $i++)
- {
- $package_qty = $TStack[count($TStack) - 1]['package_qty'];
- $inPackage = count($TStack) > 0;
+ for ($i = 0; $i < $nblignes; $i++) {
+ $package_qty = $TStack[count($TStack) - 1]['package_qty'];
+ $inPackage = count($TStack) > 0;
// Ligne de titre
if ($object->lines[$i]->product_type == 9 && $object->lines[$i]->qty < 97) {
- $inPackage = true;
+ $inPackage = true;
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- if (!empty($object->lines[$i]->fk_product)) {
- $product = new Product($db);
- $product->fetch($object->lines[$i]->fk_product);
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ if (!empty($object->lines[$i]->fk_product)) {
+ $product = new Product($db);
+ $product->fetch($object->lines[$i]->fk_product);
- $TChilds = $product->getChildsArbo($product->id);
+ $TChilds = $product->getChildsArbo($product->id);
- $TStack[count($TStack)] = array(
+ $TStack[count($TStack)] = array(
'childs' => $TChilds,
'package' => array(),
'package_qty' => 0
@@ -363,336 +362,353 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Si on se trouvait déjà dans un package, on rajoute ce produit à la liste des produits
// du précédent package
if (count($TStack) > 1) {
- $TStack[count($TStack) - 2]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
+ $TStack[count($TStack) - 2]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
}
- }
- }
+ }
+ }
}
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- if ($inPackage && $object->lines[$i]->product_type != 9 && $object->lines[$i]->fk_product > 0) {
- $TStack[count($TStack) - 1]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
- }
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ if ($inPackage && $object->lines[$i]->product_type != 9 && $object->lines[$i]->fk_product > 0) {
+ $TStack[count($TStack) - 1]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
+ }
+ }
- if ($inPackage && $object->lines[$i]->product_type == 9 && $object->lines[$i]->qty >= 97) {
- if (count($TStack) <= 1) {
- $inPackage = false;
- }
+ if ($inPackage && $object->lines[$i]->product_type == 9 && $object->lines[$i]->qty >= 97) {
+ if (count($TStack) <= 1) {
+ $inPackage = false;
+ }
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- // Comparaison pour déterminer la quantité de package
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ // Comparaison pour déterminer la quantité de package
$TProducts = array_keys($TStack[count($TStack) - 1]['package']);
- $TProductsChilds = array_keys($TStack[count($TStack) - 1]['childs']);
+ $TProductsChilds = array_keys($TStack[count($TStack) - 1]['childs']);
- if ($TProductsChilds == $TProducts) {
- // Il s'agit d'un package
+ if ($TProductsChilds == $TProducts) {
+ // Il s'agit d'un package
// On récupére la quantité
$first_child_id = $TProducts[0];
- $document_qty = $TStack[count($TStack) - 1]['package'][$first_child_id];
- $base_qty = $TStack[count($TStack) - 1]['childs'][$first_child_id][1];
+ $document_qty = $TStack[count($TStack) - 1]['package'][$first_child_id];
+ $base_qty = $TStack[count($TStack) - 1]['childs'][$first_child_id][1];
- $TStack[count($TStack) - 1]['package_qty'] = $document_qty / $base_qty;
- $package_qty = $TStack[count($TStack) - 1]['package_qty'];
- }
+ $TStack[count($TStack) - 1]['package_qty'] = $document_qty / $base_qty;
+ $package_qty = $TStack[count($TStack) - 1]['package_qty'];
+ }
- array_pop($TStack);
- }
- }
+ array_pop($TStack);
+ }
+ }
- $curY = $nexY;
- $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
- $pdf->SetTextColor(0,0,0);
+ $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]);
+ 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.
+ $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;
+ $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']) && ($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
+ 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) // There is a pagebreak
- {
+ $pdf->startTransaction();
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc);
+ $pageposafter=$pdf->getPage();
+ if ($pageposafter > $pageposbefore) {
+ // There is a pagebreak
+
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $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();
+ 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))) // 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
- {
- $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);
+ 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
+
+ $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
+ } else {
+ // We found a page break
$showpricebeforepagebreak=0;
}
- }
- else // No pagebreak
- {
+ } else {
+ // No pagebreak
+
$pdf->commitTransaction();
- }
- $posYAfterDescription=$pdf->GetY();
+ }
+ $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.
+ $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->setPage($pageposafter);
+ $curY = $tab_top_newpage;
}
- $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- // Si on ne doit masquer que les sous-produits
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ // Si on ne doit masquer que les sous-produits
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, 0);
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, 0);
} else {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+ $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');
+ $pdf->SetXY($this->posxtva, $curY);
+ $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
}
// Unit price before discount
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, 0);
+ $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, 0);
} else {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
+ $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);
+ $pdf->SetXY($this->posxup, $curY);
+ $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
// Quantity
// Affichage de la quantité sur les lignes de total si la conf l'indique
// Récupération de la quantité à afficher
if ($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY && $hidedetails) {
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
- $qty = $package_qty;
- } else {
- $qty = pdf_getlineqty($object, $i, $outputlangs, 0);
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
+ $qty = $package_qty;
+ } else {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, 0);
+ }
} else {
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
- $qty = $package_qty;
- } else {
- $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
+ $qty = $package_qty;
+ } else {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ }
}
- $pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
+ $pdf->SetXY($this->posxqty, $curY);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
// Discount on line
- if ($object->lines[$i]->remise_percent)
- {
- $pdf->SetXY($this->posxdiscount-2, $curY);
+ if ($object->lines[$i]->remise_percent) {
+ $pdf->SetXY($this->posxdiscount-2, $curY);
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
}
// Total HT line
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, 0);
+ $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, 0);
} else {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+ $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);
+ $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;
+ $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=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
- {
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc);
- $localtax1_type = $localtaxtmp_array[0];
- $localtax2_type = $localtaxtmp_array[2];
+ && (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
+ // and there is local tax
+
+ $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 & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
- $this->tva[$vatrate] += $tvaligne;
-
- if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
+ 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 & 0x01) == 0x01) {
+ $vatrate.='*';
+ }
+ 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))
- {
- $pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
+ 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));
+ $pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $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);
+ 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);
}
- 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);
+ 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);
- }
+ 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;
+ 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);
- if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
- // Affiche zone totaux
+ if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
+ // 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);
+ 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();
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) {
+ $pdf->AliasNbPages();
+ }
- $pdf->Close();
+ $pdf->Close();
- $pdf->Output($file,'F');
+ $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
+ $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));
+ 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
+ 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
}
@@ -705,130 +721,131 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
* @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK
*/
- function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
+ public function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{
- global $conf;
+ global $conf;
+
+ $sign=1;
+ if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign=-1;
+ }
- $sign=1;
- if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
+ $tab3_posx = 120;
+ $tab3_top = $posy + 8;
+ $tab3_width = 80;
+ $tab3_height = 4;
+ if ($this->page_largeur < 210) {
+ // To work with US executive format
- $tab3_posx = 120;
- $tab3_top = $posy + 8;
- $tab3_width = 80;
- $tab3_height = 4;
- if ($this->page_largeur < 210) // To work with US executive format
- {
$tab3_posx -= 20;
- }
+ }
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- $title=$outputlangs->transnoentities("PaymentsAlreadyDone");
- if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
+ $title=$outputlangs->transnoentities("PaymentsAlreadyDone");
+ if ($object->type == 2) {
+ $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
+ }
- $pdf->SetFont('','', $default_font_size - 3);
- $pdf->SetXY($tab3_posx, $tab3_top - 4);
- $pdf->MultiCell(60, 3, $title, 0, 'L', 0);
+ $pdf->SetFont('', '', $default_font_size - 3);
+ $pdf->SetXY($tab3_posx, $tab3_top - 4);
+ $pdf->MultiCell(60, 3, $title, 0, 'L', 0);
- $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
+ $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
- $pdf->SetFont('','', $default_font_size - 4);
- $pdf->SetXY($tab3_posx, $tab3_top);
- $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+21, $tab3_top);
- $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+40, $tab3_top);
- $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+58, $tab3_top);
- $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
+ $pdf->SetFont('', '', $default_font_size - 4);
+ $pdf->SetXY($tab3_posx, $tab3_top);
+ $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+21, $tab3_top);
+ $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+40, $tab3_top);
+ $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+58, $tab3_top);
+ $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
- $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
+ $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
- $y=0;
+ $y=0;
- $pdf->SetFont('','', $default_font_size - 4);
+ $pdf->SetFont('', '', $default_font_size - 4);
// Loop on each deposits and credit notes included
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
- $sql.= " re.description, re.fk_facture_source,";
- $sql.= " f.type, f.datef";
- $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
- $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i=0;
- $invoice=new Facture($this->db);
- while ($i < $num)
- {
- $y+=3;
- $obj = $this->db->fetch_object($resql);
-
- if ($obj->type == 2) $text=$outputlangs->trans("CreditNote");
- elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit");
- else $text=$outputlangs->trans("UnknownType");
-
- $invoice->fetch($obj->fk_facture_source);
-
- $pdf->SetXY($tab3_posx, $tab3_top+$y);
- $pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
- $pdf->MultiCell(20, 3, $text, 0, 'L', 0);
- $pdf->SetXY($tab3_posx+58, $tab3_top+$y);
- $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
-
- $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
-
- $i++;
- }
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
+ $sql.= " re.description, re.fk_facture_source,";
+ $sql.= " f.type, f.datef";
+ $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
+ $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
+ $resql=$this->db->query($sql);
+ if ($resql) {
+ $num = $this->db->num_rows($resql);
+ $i=0;
+ $invoice=new Facture($this->db);
+ while ($i < $num) {
+ $y+=3;
+ $obj = $this->db->fetch_object($resql);
+
+ if ($obj->type == 2) {
+ $text=$outputlangs->trans("CreditNote");
+ } elseif ($obj->type == 3) {
+ $text=$outputlangs->trans("Deposit");
+ } else {
+ $text=$outputlangs->trans("UnknownType");
+ }
+
+ $invoice->fetch($obj->fk_facture_source);
+
+ $pdf->SetXY($tab3_posx, $tab3_top+$y);
+ $pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
+ $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
+ $pdf->MultiCell(20, 3, $text, 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+58, $tab3_top+$y);
+ $pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
+
+ $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
+
+ $i++;
+ }
+ } else {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
// Loop on each payment
$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,";
- $sql.= " cp.code";
- $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
- $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
- $sql.= " ORDER BY p.datep";
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i=0;
- while ($i < $num) {
- $y+=3;
- $row = $this->db->fetch_object($resql);
-
- $pdf->SetXY($tab3_posx, $tab3_top+$y);
- $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
- $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
-
- $pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
- $pdf->SetXY($tab3_posx+58, $tab3_top+$y);
- $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
-
- $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
-
- $i++;
- }
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
-
+ $sql.= " cp.code";
+ $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
+ $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
+ $sql.= " ORDER BY p.datep";
+ $resql=$this->db->query($sql);
+ if ($resql) {
+ $num = $this->db->num_rows($resql);
+ $i=0;
+ while ($i < $num) {
+ $y+=3;
+ $row = $this->db->fetch_object($resql);
+
+ $pdf->SetXY($tab3_posx, $tab3_top+$y);
+ $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
+ $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
+ $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
+
+ $pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
+ $pdf->SetXY($tab3_posx+58, $tab3_top+$y);
+ $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
+
+ $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
+
+ $i++;
+ }
+ } else {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
}
@@ -841,150 +858,136 @@ function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
* @param Translate $outputlangs Langs object
* @return void
*/
- function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ public function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
- global $conf;
+ global $conf;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+ if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
- $posy=$pdf->GetY()+4;
+ $posy=$pdf->GetY()+4;
}
- $posxval=52;
+ $posxval=52;
// Show payments conditions
- if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentConditions").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
-
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
- $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
- $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
-
- $posy=$pdf->GetY()+3;
+ if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentConditions").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement);
+ $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
+
+ $posy=$pdf->GetY()+3;
}
- if ($object->type != 2)
- {
- // Check a payment mode is defined
+ if ($object->type != 2) {
+ // Check a payment mode is defined
if (empty($object->mode_reglement_code)
&& empty($conf->global->FACTURE_CHQ_NUMBER)
- && empty($conf->global->FACTURE_RIB_NUMBER))
- {
- $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
+ && empty($conf->global->FACTURE_RIB_NUMBER)) {
+ $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
}
// Avoid having any valid PDF with setup that is not complete
elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER))
- || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER)))
- {
- $outputlangs->load("errors");
-
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetTextColor(200,0,0);
- $pdf->SetFont('','B', $default_font_size - 2);
- $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup",$object->mode_reglement_code);
- $pdf->MultiCell(80, 3, $this->error,0,'L',0);
- $pdf->SetTextColor(0,0,0);
-
- $posy=$pdf->GetY()+1;
+ || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER))) {
+ $outputlangs->load("errors");
+
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
+ $pdf->MultiCell(80, 3, $this->error, 0, 'L', 0);
+ $pdf->SetTextColor(0, 0, 0);
+
+ $posy=$pdf->GetY()+1;
}
// Show payment mode
if ($object->mode_reglement_code
&& $object->mode_reglement_code != 'CHQ'
- && $object->mode_reglement_code != 'VIR')
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentMode").':';
- $pdf->MultiCell(80, 5, $titre, 0, 'L');
-
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
- $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
-
- $posy=$pdf->GetY()+2;
+ && $object->mode_reglement_code != 'VIR') {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentMode").':';
+ $pdf->MultiCell(80, 5, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
+
+ $posy=$pdf->GetY()+2;
}
// Show payment mode CHQ
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
- {
- // 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 - $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 - $diffsizetitle);
- $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
- }
- if ($conf->global->FACTURE_CHQ_NUMBER == -1)
- {
- $pdf->SetXY($this->marge_gauche, $posy);
- $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 - $diffsizetitle);
- $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
- }
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
+ // 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 - $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 - $diffsizetitle);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
+ }
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $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 - $diffsizetitle);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
+ }
}
}
// 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($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($bankid);
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
+ 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($bankid);
- $curx=$this->marge_gauche;
- $cury=$posy;
+ $curx=$this->marge_gauche;
+ $cury=$posy;
- $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
+ $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
- $posy+=2;
- }
+ $posy+=2;
+ }
}
- }
+ }
- return $posy;
+ return $posy;
}
@@ -998,288 +1001,284 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
- function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ public function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
- global $conf,$mysoc;
+ global $conf,$mysoc;
- $sign=1;
- if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
+ $sign=1;
+ if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign=-1;
+ }
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- $tab2_top = $posy;
- $tab2_hl = 4;
- $pdf->SetFont('','', $default_font_size - 1);
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('', '', $default_font_size - 1);
// Tableau total
- $col1x = 120; $col2x = 170;
- if ($this->page_largeur < 210) // To work with US executive format
- {
+ $col1x = 120;
+ $col2x = 170;
+ if ($this->page_largeur < 210) {
+ // To work with US executive format
+
$col2x-=20;
- }
- $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
- $useborder=0;
- $index = 0;
+ $useborder=0;
+ $index = 0;
// Total HT
- $pdf->SetFillColor(255,255,255);
- $pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
- $pdf->SetFillColor(248,248,248);
-
- $this->atleastoneratenotnull=0;
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
- {
- // Nothing to do
- }
- else
- {
- //Local tax 1 before VAT
+ $pdf->SetFillColor(248, 248, 248);
+
+ $this->atleastoneratenotnull=0;
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
+ // Nothing to do
+ } else {
+ //Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach( $this->localtax1 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey!=0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
-
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('1','3','5'))) {
+ continue;
+ }
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey!=0) {
+ // On affiche pas taux 0
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ //$this->atleastoneratenotnull++;
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach( $this->localtax2 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey!=0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
-
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('1','3','5'))) {
+ continue;
+ }
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey!=0) {
+ // On affiche pas taux 0
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ //$this->atleastoneratenotnull++;
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
// VAT
- foreach($this->tva as $tvakey => $tvaval)
- {
- if ($tvakey > 0) // On affiche pas taux 0
- {
- $this->atleastoneratenotnull++;
+ foreach ($this->tva as $tvakey => $tvaval) {
+ if ($tvakey > 0) {
+ // On affiche pas taux 0
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $this->atleastoneratenotnull++;
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
+ $totalvat.=vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
}
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach( $this->localtax1 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey != 0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2','4','6'))) {
+ continue;
+ }
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) {
+ // On affiche pas taux 0
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
+ //$this->atleastoneratenotnull++;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach( $this->localtax2 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- // retrieve global local tax
- if ($tvakey != 0) // On affiche pas taux 0
- {
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2','4','6'))) {
+ continue;
+ }
+
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ // retrieve global local tax
+ if ($tvakey != 0) {
+ // On affiche pas taux 0
+
//$this->atleastoneratenotnull++;
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
- }
+ }
//}
- }
+ }
// Revenue stamp
- if (price2num($object->revenuestamp) != 0)
- {
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
-
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
+ if (price2num($object->revenuestamp) != 0) {
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
}
// Total TTC
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
- }
- }
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
+ }
+ }
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetTextColor(0, 0, 0);
- $creditnoteamount=$object->getSumCreditNotesUsed();
- $depositsamount=$object->getSumDepositsUsed();
+ $creditnoteamount=$object->getSumCreditNotesUsed();
+ $depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
- if ($object->paye) $resteapayer=0;
+ if ($object->paye) {
+ $resteapayer=0;
+ }
- if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0)
- {
- // Already paid + Deposits
+ if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) {
+ // Already paid + Deposits
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
// Credit note
- if ($creditnoteamount)
- {
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
+ if ($creditnoteamount) {
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
}
// Escompte
- if ($object->close_code == 'discount_vat')
- {
- $index++;
- $pdf->SetFillColor(255,255,255);
+ if ($object->close_code == 'discount_vat') {
+ $index++;
+ $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
- $resteapayer=0;
+ $resteapayer=0;
}
- $index++;
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
-
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetTextColor(0,0,0);
- }
+ $index++;
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetTextColor(0, 0, 0);
+ }
- $index++;
- return ($tab2_top + ($tab2_hl * $index));
+ $index++;
+ return ($tab2_top + ($tab2_hl * $index));
}
/**
@@ -1294,96 +1293,88 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
* @param int $hidebottom Hide bottom bar of array
* @return void
*/
- function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
+ public function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{
- global $conf;
+ global $conf;
// Force to disable hidetop and hidebottom
$hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ if ($hidetop) {
+ $hidetop=-1;
+ }
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
// Amount in (at tab_top - 1)
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
- if (empty($hidetop))
- {
- $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
- $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+ if (empty($hidetop)) {
+ $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $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, 5, '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);
- $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetDrawColor(128, 128, 128);
+ $pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
- if (empty($hidetop))
- {
- $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
+ if (empty($hidetop)) {
+ $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');
+ $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);
+ 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);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxtva-3, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
- }
- }
-
- $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
- }
-
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
- }
-
- $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- if ($this->atleastonediscount)
- {
- $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
- }
- }
- if ($this->atleastonediscount)
- {
- $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
- }
- if (empty($hidetop))
- {
- $pdf->SetXY($this->postotalht-1, $tab_top+1);
- $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
- }
+ }
+ }
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxtva-3, $tab_top+1);
+ $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+ }
+ }
+
+ $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxup-1, $tab_top+1);
+ $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
+ }
+
+ $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxqty-1, $tab_top+1);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+ }
+
+ $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ if ($this->atleastonediscount) {
+ $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+ }
+ }
+ if ($this->atleastonediscount) {
+ $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+ }
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->postotalht-1, $tab_top+1);
+ $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
+ }
}
/**
@@ -1395,226 +1386,225 @@ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0,
* @param Translate $outputlangs Object lang for output
* @return void
*/
- function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ public function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
- global $conf,$langs;
+ global $conf,$langs;
- $outputlangs->load("main");
- $outputlangs->load("bills");
- $outputlangs->load("propal");
- $outputlangs->load("companies");
+ $outputlangs->load("main");
+ $outputlangs->load("bills");
+ $outputlangs->load("propal");
+ $outputlangs->load("companies");
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
+ pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
- {
- pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
- }
+ if ($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK))) {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
+ }
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFont('','B', $default_font_size + 3);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy=$this->marge_haute;
+ $posx=$this->page_largeur-$this->marge_droite-100;
- $pdf->SetXY($this->marge_gauche,$posy);
+ $pdf->SetXY($this->marge_gauche, $posy);
// Logo
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
- if ($this->emetteur->logo)
- {
- if (is_readable($logo))
- {
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- }
- else
- {
- $pdf->SetTextColor(200,0,0);
- $pdf->SetFont('','B',$default_font_size - 2);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
- }
- }
- else
- {
- $text=$this->emetteur->name;
- $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
- }
-
- $pdf->SetFont('','B', $default_font_size + 3);
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $title=$outputlangs->transnoentities("Invoice");
- if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
- if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
- if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
- if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProFormat");
- $pdf->MultiCell(100, 3, $title, '', 'R');
-
- $pdf->SetFont('','B',$default_font_size);
-
- $posy+=5;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
-
- $posy+=1;
- $pdf->SetFont('','', $default_font_size - 2);
-
- if ($object->ref_client)
- {
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
- }
-
- $objectidnext=$object->getIdReplacingInvoice('validated');
- if ($object->type == 0 && $objectidnext)
- {
- $objectreplacing=new Facture($this->db);
- $objectreplacing->fetch($objectidnext);
-
- $posy+=3;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
- }
- if ($object->type == 1)
- {
- $objectreplaced=new Facture($this->db);
- $objectreplaced->fetch($object->fk_facture_source);
-
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
- }
- if ($object->type == 2)
- {
- $objectreplaced=new Facture($this->db);
- $objectreplaced->fetch($object->fk_facture_source);
-
- $posy+=3;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
- }
-
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date,"day",false,$outputlangs), '', 'R');
-
- if ($object->type != 2)
- {
- $posy+=3;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R');
- }
-
- if ($object->client->code_client)
- {
- $posy+=3;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
- }
-
- $posy+=1;
+ if ($this->emetteur->logo) {
+ if (is_readable($logo)) {
+ $height=pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ } else {
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
+ } else {
+ $text=$this->emetteur->name;
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
+ }
+
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $title=$outputlangs->transnoentities("Invoice");
+ if ($object->type == 1) {
+ $title=$outputlangs->transnoentities("InvoiceReplacement");
+ }
+ if ($object->type == 2) {
+ $title=$outputlangs->transnoentities("InvoiceAvoir");
+ }
+ if ($object->type == 3) {
+ $title=$outputlangs->transnoentities("InvoiceDeposit");
+ }
+ if ($object->type == 4) {
+ $title=$outputlangs->transnoentities("InvoiceProFormat");
+ }
+ $pdf->MultiCell(100, 3, $title, '', 'R');
+
+ $pdf->SetFont('', 'B', $default_font_size);
+
+ $posy+=5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
+
+ $posy+=1;
+ $pdf->SetFont('', '', $default_font_size - 2);
+
+ if ($object->ref_client) {
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ }
+
+ $objectidnext=$object->getIdReplacingInvoice('validated');
+ if ($object->type == 0 && $objectidnext) {
+ $objectreplacing=new Facture($this->db);
+ $objectreplacing->fetch($objectidnext);
+
+ $posy+=3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
+ }
+ if ($object->type == 1) {
+ $objectreplaced=new Facture($this->db);
+ $objectreplaced->fetch($object->fk_facture_source);
+
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
+ }
+ if ($object->type == 2) {
+ $objectreplaced=new Facture($this->db);
+ $objectreplaced->fetch($object->fk_facture_source);
+
+ $posy+=3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
+ }
+
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
+
+ if ($object->type != 2) {
+ $posy+=3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
+ }
+
+ if ($object->client->code_client) {
+ $posy+=3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
+ }
+
+ $posy+=1;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
- if ($showaddress)
- {
- // Sender properties
+ if ($showaddress) {
+ // Sender properties
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client);
// Show sender
$posy=42;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posx=$this->marge_gauche;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx=$this->page_largeur-$this->marge_droite-80;
+ }
+ $hautcadre=40;
// Show sender frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx,$posy-5);
- $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
- $pdf->SetXY($posx,$posy);
- $pdf->SetFillColor(230,230,230);
- $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
- $pdf->SetTextColor(0,0,60);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy-5);
+ $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy=$pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2,$posy);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
+ $pdf->SetXY($posx+2, $posy);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If BILLING contact defined on invoice, we use it
$usecontact=false;
- $arrayidcontact=$object->getIdContact('external','BILLING');
- if (count($arrayidcontact) > 0)
- {
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
- }
+ $arrayidcontact=$object->getIdContact('external', 'BILLING');
+ if (count($arrayidcontact) > 0) {
+ $usecontact=true;
+ $result=$object->fetch_contact($arrayidcontact[0]);
+ }
// Recipient name
- if (! empty($usecontact))
- {
- // On peut utiliser le nom de la societe du contact
- if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
- else $socname = $object->client->name;
- $carac_client_name=$outputlangs->convToOutputCharset($socname);
- }
- else
- {
- $carac_client_name=$outputlangs->convToOutputCharset($object->client->name);
+ if (! empty($usecontact)) {
+ // On peut utiliser le nom de la societe du contact
+ if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
+ $socname = $object->contact->socname;
+ } else {
+ $socname = $object->client->name;
+ }
+ $carac_client_name=$outputlangs->convToOutputCharset($socname);
+ } else {
+ $carac_client_name=$outputlangs->convToOutputCharset($object->client->name);
}
- $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');
+ $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, ($usecontact?$object->contact:''), $usecontact, 'target');
// Show recipient
$widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
+ if ($this->page_largeur < 210) {
+ $widthrecbox=84;
+ } // To work with US executive format
$posy=42;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx=$this->marge_gauche;
+ }
// Show recipient frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx+2,$posy-5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx+2, $posy-5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
+ $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
// Show recipient information
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
- $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
- }
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetXY($posx+2, $posy+4+(dol_nboflines_bis($carac_client_name, 50)*4));
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
+ }
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetTextColor(0, 0, 0);
}
/**
@@ -1626,11 +1616,9 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
*/
- function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
+ public function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
{
- $showdetails=0;
- return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
+ $showdetails=0;
+ return pdf_pagefoot($pdf, $outputlangs, 'FACTURE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
-
}
-
diff --git a/core/modules/modSubtotal.class.php b/core/modules/modSubtotal.class.php
index d98c1d0c..ef3c4cf7 100644
--- a/core/modules/modSubtotal.class.php
+++ b/core/modules/modSubtotal.class.php
@@ -112,7 +112,7 @@ public function __construct($db)
// List of modules id that must be enabled if this module is enabled
$this->depends = array();
- $this->conflictwith=array('modMilestone');
+ $this->conflictwith=array('modMilestone');
// List of modules id to disable if this one is disabled
$this->requiredby = array();
// Minimum version of PHP required by module
@@ -432,7 +432,7 @@ public function __construct($db)
*/
public function init($options = '')
{
- global $conf;
+ global $conf;
/* if($conf->milestone->enabled) {
@@ -443,7 +443,7 @@ public function init($options = '')
$result = $this->loadTables();
- dolibarr_set_const($this->db, 'SUBTOTAL_MANAGE_SUBSUBTOTAL', isset($conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL) ? $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL : 0 ,'integer',1,'Gère ou pas les sous-sous-totaux',0);
+ dolibarr_set_const($this->db, 'SUBTOTAL_MANAGE_SUBSUBTOTAL', isset($conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL) ? $conf->global->SUBTOTAL_MANAGE_SUBSUBTOTAL : 0, 'integer', 1, 'Gère ou pas les sous-sous-totaux', 0);
return $this->_init($sql, $options);
}
diff --git a/core/modules/propale/doc/pdf_azur_subtotal.modules.php b/core/modules/propale/doc/pdf_azur_subtotal.modules.php
index 3c54e160..11e67e58 100644
--- a/core/modules/propale/doc/pdf_azur_subtotal.modules.php
+++ b/core/modules/propale/doc/pdf_azur_subtotal.modules.php
@@ -37,23 +37,23 @@
*/
class pdf_azur_subtotal extends ModelePDFPropales
{
- var $db;
- var $name;
- var $description;
- var $type;
+ public $db;
+ public $name;
+ public $description;
+ public $type;
- var $phpmin = array(4,3,0); // Minimum version of PHP required by module
- var $version = 'dolibarr';
+ public $phpmin = array(4,3,0); // Minimum version of PHP required by module
+ public $version = 'dolibarr';
- var $page_largeur;
- var $page_hauteur;
- var $format;
- var $marge_gauche;
- var $marge_droite;
- var $marge_haute;
- var $marge_basse;
+ public $page_largeur;
+ public $page_hauteur;
+ public $format;
+ public $marge_gauche;
+ public $marge_droite;
+ public $marge_haute;
+ public $marge_basse;
- var $emetteur; // Objet societe qui emet
+ public $emetteur; // Objet societe qui emet
/**
@@ -61,29 +61,29 @@ class pdf_azur_subtotal extends ModelePDFPropales
*
* @param DoliDB $db Database handler
*/
- function __construct($db)
+ public function __construct($db)
{
- global $conf,$langs,$mysoc;
+ global $conf,$langs,$mysoc;
- $langs->load("main");
- $langs->load("bills");
+ $langs->load("main");
+ $langs->load("bills");
- $this->db = $db;
- $this->name = "azur_subtotal";
- $this->description = 'Modèle de proposition commerciale incluant des spécificités du module sous-total';
+ $this->db = $db;
+ $this->name = "azur_subtotal";
+ $this->description = 'Modèle de proposition commerciale incluant des spécificités du module sous-total';
// Dimension page pour format A4
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
- $this->page_largeur = $formatarray['width'];
- $this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
-
- $this->option_logo = 1; // Affiche logo
+ $formatarray=pdf_getFormat();
+ $this->page_largeur = $formatarray['width'];
+ $this->page_hauteur = $formatarray['height'];
+ $this->format = array($this->page_largeur,$this->page_hauteur);
+ $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
+ $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
+ $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
+ $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+
+ $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode reglement
$this->option_condreg = 1; // Affiche conditions reglement
@@ -98,32 +98,37 @@ function __construct($db)
// Get source company
$this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
+ if (empty($this->emetteur->country_code)) {
+ $this->emetteur->country_code=substr($langs->defaultlang, -2);
+ } // By default, if was not defined
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
- $this->posxtva=112;
- $this->posxup=126;
- $this->posxqty=145;
- $this->posxdiscount=162;
- $this->postotalht=174;
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
- $this->posxpicture=$this->posxtva - (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->posxtva=112;
+ $this->posxup=126;
+ $this->posxqty=145;
+ $this->posxdiscount=162;
+ $this->postotalht=174;
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $this->posxtva=$this->posxup;
+ }
+ $this->posxpicture=$this->posxtva - (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->posxpicture-=20;
- $this->posxtva-=20;
- $this->posxup-=20;
- $this->posxqty-=20;
- $this->posxdiscount-=20;
- $this->postotalht-=20;
+ $this->posxtva-=20;
+ $this->posxup-=20;
+ $this->posxqty-=20;
+ $this->posxdiscount-=20;
+ $this->postotalht-=20;
}
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva=array();
+ $this->localtax1=array();
+ $this->localtax2=array();
+ $this->atleastoneratenotnull=0;
+ $this->atleastonediscount=0;
}
/**
@@ -137,252 +142,237 @@ function __construct($db)
* @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)
+ public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
{
- global $user,$langs,$conf,$mysoc,$db,$hookmanager;
+ global $user,$langs,$conf,$mysoc,$db,$hookmanager;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ 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';
+ 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("propal");
- $outputlangs->load("products");
+ $outputlangs->load("main");
+ $outputlangs->load("dict");
+ $outputlangs->load("companies");
+ $outputlangs->load("bills");
+ $outputlangs->load("propal");
+ $outputlangs->load("products");
- $nblignes = count($object->lines);
+ $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_PROPOSALS_WITH_PICTURE))
- {
- $objphoto = new Product($this->db);
-
- for ($i = 0 ; $i < $nblignes ; $i++)
- {
- if (empty($object->lines[$i]->fk_product)) continue;
-
- $objphoto->fetch($object->lines[$i]->fk_product);
-
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
- {
- $pdir[0] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/";
- $pdir[1] = dol_sanitizeFileName($objphoto->ref).'/';
- }
- else
- {
- $pdir[0] = dol_sanitizeFileName($objphoto->ref).'/';
- $pdir[1] = get_exdir($objphoto->id,2) . $objphoto->id ."/photos/";
- }
-
- $arephoto = false;
- foreach ($pdir as $midir)
- {
- if (! $arephoto)
- {
- $dir = $conf->product->dir_output.'/'.$midir;
-
- foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
- {
- if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
- {
- if ($obj['photo_vignette'])
- {
- $filename= $obj['photo_vignette'];
+ if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) {
+ $objphoto = new Product($this->db);
+
+ for ($i = 0 ; $i < $nblignes ; $i++) {
+ if (empty($object->lines[$i]->fk_product)) {
+ continue;
+ }
+
+ $objphoto->fetch($object->lines[$i]->fk_product);
+
+ if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
+ $pdir[0] = get_exdir($objphoto->id, 2) . $objphoto->id ."/photos/";
+ $pdir[1] = dol_sanitizeFileName($objphoto->ref).'/';
+ } else {
+ $pdir[0] = dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir[1] = get_exdir($objphoto->id, 2) . $objphoto->id ."/photos/";
+ }
+
+ $arephoto = false;
+ foreach ($pdir as $midir) {
+ if (! $arephoto) {
+ $dir = $conf->product->dir_output.'/'.$midir;
+
+ foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+ if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
+ // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+
+ if ($obj['photo_vignette']) {
+ $filename= $obj['photo_vignette'];
+ } else {
+ $filename=$obj['photo'];
}
- else
- {
- $filename=$obj['photo'];
- }
- }
- else
- {
- $filename=$obj['photo'];
- }
+ } else {
+ $filename=$obj['photo'];
+ }
- $realpath = $dir.$filename;
- $arephoto = true;
- }
- }
- }
+ $realpath = $dir.$filename;
+ $arephoto = true;
+ }
+ }
+ }
- if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
- }
- }
+ if ($realpath && $arephoto) {
+ $realpatharray[$i]=$realpath;
+ }
+ }
+ }
- if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
+ if (count($realpatharray) == 0) {
+ $this->posxpicture=$this->posxtva;
+ }
- if ($conf->propal->dir_output)
- {
- $object->fetch_thirdparty();
+ if ($conf->propal->dir_output) {
+ $object->fetch_thirdparty();
// $deja_regle = 0;
// Definition of $dir and $file
- if ($object->specimen)
- {
- $dir = $conf->propal->dir_output;
- $file = $dir . "/SPECIMEN.pdf";
- }
- else
- {
- $objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->propal->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 ($object->specimen) {
+ $dir = $conf->propal->dir_output;
+ $file = $dir . "/SPECIMEN.pdf";
+ } else {
+ $objectref = dol_sanitizeFileName($object->ref);
+ $dir = $conf->propal->dir_output . "/" . $objectref;
+ $file = $dir . "/" . $objectref . ".pdf";
}
- 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);
+ 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
+ $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
+ $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);
+ $pdf->SetAutoPageBreak(1, 0);
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ 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))
- {
+ 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->Open();
+ $pagenb=0;
+ $pdf->SetDrawColor(128, 128, 128);
- $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
- $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal"));
- $pdf->SetCreator("Dolibarr ".DOL_VERSION);
- $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
- $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal"));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal"));
+ if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
+ $pdf->SetCompression(false);
+ }
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $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++;
- }
+ for ($i = 0 ; $i < $nblignes ; $i++) {
+ if ($object->lines[$i]->remise_percent) {
+ $this->atleastonediscount++;
+ }
}
- if (empty($this->atleastonediscount))
- {
- $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);
+ if (empty($this->atleastonediscount)) {
+ $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;
- }
+ }
// 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($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;
// 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 (! 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;
+ }
+ 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;
+ $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;
-
- $inPackage = false;
- $TPackageInfos = array();
- $TChilds = array();
- $package_qty = 0;
- $TStack = array();
+ $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;
+
+ $inPackage = false;
+ $TPackageInfos = array();
+ $TChilds = array();
+ $package_qty = 0;
+ $TStack = array();
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
- {
- $package_qty = $TStack[count($TStack) - 1]['package_qty'];
- $inPackage = count($TStack) > 0;
+ for ($i = 0 ; $i < $nblignes ; $i++) {
+ $package_qty = $TStack[count($TStack) - 1]['package_qty'];
+ $inPackage = count($TStack) > 0;
// Ligne de titre
if ($object->lines[$i]->product_type == 9 && $object->lines[$i]->qty < 97 && $object->lines[$i]->fk_product > 0) {
- $inPackage = true;
+ $inPackage = true;
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- if (!empty($object->lines[$i]->fk_product)) {
- $product = new Product($db);
- $product->fetch($object->lines[$i]->fk_product);
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ if (!empty($object->lines[$i]->fk_product)) {
+ $product = new Product($db);
+ $product->fetch($object->lines[$i]->fk_product);
- $TChilds = $product->getChildsArbo($product->id);
+ $TChilds = $product->getChildsArbo($product->id);
- $TStack[count($TStack)] = array(
+ $TStack[count($TStack)] = array(
'childs' => $TChilds,
'package' => array(),
'package_qty' => 0
@@ -391,157 +381,168 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Si on se trouvait déjà dans un package, on rajoute ce produit à la liste des produits
// du précédent package
if (count($TStack) > 1) {
- $TStack[count($TStack) - 2]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
+ $TStack[count($TStack) - 2]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
}
- }
- }
+ }
+ }
}
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- if ($inPackage && $object->lines[$i]->product_type != 9 && $object->lines[$i]->fk_product > 0) {
- $TStack[count($TStack) - 1]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
- }
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ if ($inPackage && $object->lines[$i]->product_type != 9 && $object->lines[$i]->fk_product > 0) {
+ $TStack[count($TStack) - 1]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty;
+ }
+ }
// Ligne de sous-total
if ($inPackage && $object->lines[$i]->product_type == 9 && $object->lines[$i]->qty >= 97) {
- if (count($TStack) <= 1) {
- $inPackage = false;
- }
+ if (count($TStack) <= 1) {
+ $inPackage = false;
+ }
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
- // Comparaison pour déterminer la quantité de package
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) {
+ // Comparaison pour déterminer la quantité de package
$TProducts = array_keys($TStack[count($TStack) - 1]['package']);
- $TProductsChilds = array_keys($TStack[count($TStack) - 1]['childs']);
+ $TProductsChilds = array_keys($TStack[count($TStack) - 1]['childs']);
- if ($TProductsChilds == $TProducts) {
- // Il s'agit d'un package
+ if ($TProductsChilds == $TProducts) {
+ // Il s'agit d'un package
// On récupére la quantité
$first_child_id = $TProducts[0];
- $document_qty = $TStack[count($TStack) - 1]['package'][$first_child_id];
- $base_qty = $TStack[count($TStack) - 1]['childs'][$first_child_id][1];
+ $document_qty = $TStack[count($TStack) - 1]['package'][$first_child_id];
+ $base_qty = $TStack[count($TStack) - 1]['childs'][$first_child_id][1];
- $TStack[count($TStack) - 1]['package_qty'] = $document_qty / $base_qty;
- $package_qty = $TStack[count($TStack) - 1]['package_qty'];
- }
+ $TStack[count($TStack) - 1]['package_qty'] = $document_qty / $base_qty;
+ $package_qty = $TStack[count($TStack) - 1]['package_qty'];
+ }
- array_pop($TStack);
- }
+ array_pop($TStack);
+ }
}
- $curY = $nexY;
- $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
- $pdf->SetTextColor(0,0,0);
+ $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]);
+ 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.
+ $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;
+ $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']) && ($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
+ 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);
+ $pdf->startTransaction();
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc);
+
+ $pageposafter=$pdf->getPage();
+ if ($pageposafter > $pageposbefore) {
+ // There is a pagebreak
- $pageposafter=$pdf->getPage();
- if ($pageposafter > $pageposbefore) // There is a pagebreak
- {
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $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);
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
+ $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
- {
- $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);
+ 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
+
+ $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
+ } else {
+ // We found a page break
$showpricebeforepagebreak=0;
}
- }
- else // No pagebreak
- {
+ } else {
+ // No pagebreak
+
$pdf->commitTransaction();
- }
- $posYAfterDescription=$pdf->GetY();
+ }
+ $posYAfterDescription=$pdf->GetY();
- $nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $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.
+ $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->setPage($pageposafter);
+ $curY = $tab_top_newpage;
}
- $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- // Si on ne doit masquer que les sous-produits
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ // Si on ne doit masquer que les sous-produits
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, 0);
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, 0);
} else {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+ $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');
+ $pdf->SetXY($this->posxtva, $curY);
+ $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
}
// Unit price before discount
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, 0);
+ $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, 0);
} else {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
+ $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);
+ $pdf->SetXY($this->posxup, $curY);
+ $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
// Booléen pour déterminer s'il s'agit d'une ligne de titre ou non
$isTitle = false;
@@ -551,144 +552,152 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
// Récupération de la quantité à afficher
if ($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY) {
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
- $qty = $package_qty;
- } else {
- $qty = pdf_getlineqty($object, $i, $outputlangs, 0);
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
+ $qty = $package_qty;
+ } else {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, 0);
+ }
} else {
- if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
- $qty = $package_qty;
- } else {
- $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
- }
+ if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) {
+ $qty = $package_qty;
+ } else {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ }
}
- $pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars
+ $pdf->SetXY($this->posxqty, $curY);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 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);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
+ if ($object->lines[$i]->remise_percent) {
+ $pdf->SetXY($this->posxdiscount-2, $curY);
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
}
// Total HT line
if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, 0);
+ $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, 0);
} else {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+ $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);
+ $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;
+ $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=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
- {
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
- $localtax1_type = $localtaxtmp_array[0];
- $localtax2_type = $localtaxtmp_array[2];
+ && (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
+ // and there is local tax
+
+ $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 & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
- $this->tva[$vatrate] += $tvaligne;
-
- if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
+ 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 & 0x01) == 0x01) {
+ $vatrate.='*';
+ }
+ 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))
- {
- $pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
+ 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));
+ $pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Passe espace entre les lignes
+ $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);
+ 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);
}
- 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);
+ 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);
- }
+ 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;
+ 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);
- if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
- // Affiche zone totaux
+ if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) {
+ // Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
- }
+ }
// Affiche zone versements
/*
@@ -699,38 +708,37 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
*/
// Pied de page
- $this->_pagefoot($pdf,$object,$outputlangs);
- if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) {
+ $pdf->AliasNbPages();
+ }
- $pdf->Close();
+ $pdf->Close();
- $pdf->Output($file,'F');
+ $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));
+ $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
- return 1; // Pas d'erreur
- }
- else
- {
- $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
- return 0;
- }
- }
- else
- {
- $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR");
- return 0;
- }
+ if (! empty($conf->global->MAIN_UMASK)) {
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+ }
- $this->error=$langs->trans("ErrorUnknown");
- return 0; // Erreur par defaut
+ return 1; // Pas d'erreur
+ } else {
+ $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ } else {
+ $this->error=$langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
+ return 0;
+ }
+
+ $this->error=$langs->trans("ErrorUnknown");
+ return 0; // Erreur par defaut
}
/**
@@ -742,9 +750,8 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
* @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK
*/
- function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
+ public function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{
-
}
@@ -757,76 +764,72 @@ function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
* @param Translate $outputlangs Langs object
* @return void
*/
- function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ public function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
- global $conf;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ global $conf;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+ if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
- $posy=$pdf->GetY()+4;
+ $posy=$pdf->GetY()+4;
}
- $posxval=52;
+ $posxval=52;
// Show shipping date
- if (! empty($object->date_livraison))
- {
+ if (! empty($object->date_livraison)) {
$outputlangs->load("sendings");
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
- $pdf->MultiCell(80, 4, $dlp, 0, 'L');
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
+ $pdf->MultiCell(80, 4, $dlp, 0, 'L');
$posy=$pdf->GetY()+1;
- }
- elseif ($object->availability_code || $object->availability) // Show availability conditions
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
- $lib_availability=str_replace('\n',"\n",$lib_availability);
- $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
-
- $posy=$pdf->GetY()+1;
- }
+ } elseif ($object->availability_code || $object->availability) {
+ // Show availability conditions
+
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
+ $lib_availability=str_replace('\n', "\n", $lib_availability);
+ $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
+
+ $posy=$pdf->GetY()+1;
+ }
// Show payments conditions
- if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentConditions").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
-
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
- $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
- $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
-
- $posy=$pdf->GetY()+3;
+ if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentConditions").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement);
+ $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
+
+ $posy=$pdf->GetY()+3;
}
- if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND))
- {
- // Check a payment mode is defined
+ if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND)) {
+ // Check a payment mode is defined
/* Not required on a proposal
if (empty($object->mode_reglement_code)
&& ! $conf->global->FACTURE_CHQ_NUMBER
@@ -845,84 +848,75 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
// Show payment mode
if ($object->mode_reglement_code
&& $object->mode_reglement_code != 'CHQ'
- && $object->mode_reglement_code != 'VIR')
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentMode").':';
- $pdf->MultiCell(80, 5, $titre, 0, 'L');
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
- $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
-
- $posy=$pdf->GetY()+2;
+ && $object->mode_reglement_code != 'VIR') {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentMode").':';
+ $pdf->MultiCell(80, 5, $titre, 0, 'L');
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
+
+ $posy=$pdf->GetY()+2;
}
// Show payment mode CHQ
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
- {
- // 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 - $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 - $diffsizetitle);
- $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
- }
- if ($conf->global->FACTURE_CHQ_NUMBER == -1)
- {
- $pdf->SetXY($this->marge_gauche, $posy);
- $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 - $diffsizetitle);
- $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
- }
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
+ // 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 - $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 - $diffsizetitle);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
+ }
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $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 - $diffsizetitle);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
+ }
}
}
// 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($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($bankid);
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
+ 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($bankid);
- $curx=$this->marge_gauche;
- $cury=$posy;
+ $curx=$this->marge_gauche;
+ $cury=$posy;
- $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
+ $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
- $posy+=2;
- }
+ $posy+=2;
+ }
}
- }
+ }
- return $posy;
+ return $posy;
}
@@ -936,234 +930,229 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
- function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ public function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
- global $conf,$mysoc;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ global $conf,$mysoc;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- $tab2_top = $posy;
- $tab2_hl = 4;
- $pdf->SetFont('','', $default_font_size - 1);
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('', '', $default_font_size - 1);
// Tableau total
- $col1x = 120; $col2x = 170;
- if ($this->page_largeur < 210) // To work with US executive format
- {
+ $col1x = 120;
+ $col2x = 170;
+ if ($this->page_largeur < 210) {
+ // To work with US executive format
+
$col2x-=20;
- }
- $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
- $useborder=0;
- $index = 0;
+ $useborder=0;
+ $index = 0;
// Total HT
- $pdf->SetFillColor(255,255,255);
- $pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
- $pdf->SetFillColor(248,248,248);
-
- $this->atleastoneratenotnull=0;
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
- {
- // Nothing to do
- }
- else
- {
- //Local tax 1 before VAT
+ $pdf->SetFillColor(248, 248, 248);
+
+ $this->atleastoneratenotnull=0;
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) {
+ // Nothing to do
+ } else {
+ //Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach( $this->localtax1 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey!=0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('1','3','5'))) {
+ continue;
+ }
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey!=0) {
+ // On affiche pas taux 0
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ //$this->atleastoneratenotnull++;
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach( $this->localtax2 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey!=0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
-
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('1','3','5'))) {
+ continue;
+ }
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey!=0) {
+ // On affiche pas taux 0
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ //$this->atleastoneratenotnull++;
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
// VAT
- foreach($this->tva as $tvakey => $tvaval)
- {
- if ($tvakey > 0) // On affiche pas taux 0
- {
- $this->atleastoneratenotnull++;
-
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ foreach ($this->tva as $tvakey => $tvaval) {
+ if ($tvakey > 0) {
+ // On affiche pas taux 0
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $this->atleastoneratenotnull++;
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
+ $totalvat.=vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
}
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach( $this->localtax1 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey != 0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2','4','6'))) {
+ continue;
+ }
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ if ($tvakey != 0) {
+ // On affiche pas taux 0
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
+ //$this->atleastoneratenotnull++;
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
- }
- }
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ }
+ }
}
//}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach( $this->localtax2 as $localtax_type => $localtax_rate )
- {
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
-
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- // retrieve global local tax
- if ($tvakey != 0) // On affiche pas taux 0
- {
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
+ if (in_array((string) $localtax_type, array('2','4','6'))) {
+ continue;
+ }
+
+ foreach ($localtax_rate as $tvakey => $tvaval) {
+ // retrieve global local tax
+ if ($tvakey != 0) {
+ // On affiche pas taux 0
+
//$this->atleastoneratenotnull++;
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
+ $tvacompl='';
+ if (preg_match('/\*/', $tvakey)) {
+ $tvakey=str_replace('*', '', $tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
- }
+ }
}
//}
// Total TTC
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
- }
- }
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
+ }
+ }
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetTextColor(0, 0, 0);
/*
$resteapayer = $object->total_ttc - $deja_regle;
if (! empty($object->paye)) $resteapayer=0;
*/
- if ($deja_regle > 0)
- {
- $index++;
+ if ($deja_regle > 0) {
+ $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
/*
if ($object->close_code == 'discount_vat')
@@ -1182,20 +1171,20 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
*/
$index++;
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFillColor(224, 224, 224);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetTextColor(0, 0, 0);
}
- $index++;
- return ($tab2_top + ($tab2_hl * $index));
+ $index++;
+ return ($tab2_top + ($tab2_hl * $index));
}
/**
@@ -1210,96 +1199,88 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
* @param int $hidebottom Hide bottom bar of array
* @return void
*/
- function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
+ public function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{
- global $conf;
+ global $conf;
// Force to disable hidetop and hidebottom
$hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ if ($hidetop) {
+ $hidetop=-1;
+ }
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
// Amount in (at tab_top - 1)
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','',$default_font_size - 2);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
- if (empty($hidetop))
- {
- $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
- $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+ if (empty($hidetop)) {
+ $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $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, 5, '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);
- $pdf->SetFont('','',$default_font_size - 1);
+ $pdf->SetDrawColor(128, 128, 128);
+ $pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
- if (empty($hidetop))
- {
- $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
+ if (empty($hidetop)) {
+ $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');
+ $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
}
- if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_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);
+ if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_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);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxtva-3, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
- }
- }
-
- $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
- }
-
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
- }
-
- $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- if ($this->atleastonediscount)
- {
- $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
- }
- }
- if ($this->atleastonediscount)
- {
- $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
- }
- if (empty($hidetop))
- {
- $pdf->SetXY($this->postotalht-1, $tab_top+1);
- $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
- }
+ }
+ }
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+ $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxtva-3, $tab_top+1);
+ $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+ }
+ }
+
+ $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxup-1, $tab_top+1);
+ $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
+ }
+
+ $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxqty-1, $tab_top+1);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+ }
+
+ $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ if ($this->atleastonediscount) {
+ $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+ }
+ }
+ if ($this->atleastonediscount) {
+ $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+ }
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->postotalht-1, $tab_top+1);
+ $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
+ }
}
/**
@@ -1311,195 +1292,189 @@ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0,
* @param Translate $outputlangs Object lang for output
* @return void
*/
- function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ public function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
- global $conf,$langs;
+ global $conf,$langs;
- $outputlangs->load("main");
- $outputlangs->load("bills");
- $outputlangs->load("propal");
- $outputlangs->load("companies");
+ $outputlangs->load("main");
+ $outputlangs->load("bills");
+ $outputlangs->load("propal");
+ $outputlangs->load("companies");
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
- pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
+ pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) )
- {
- pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->PROPALE_DRAFT_WATERMARK);
+ if ($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK))) {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
}
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFont('','B', $default_font_size + 3);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy=$this->marge_haute;
+ $posx=$this->page_largeur-$this->marge_droite-100;
- $pdf->SetXY($this->marge_gauche,$posy);
+ $pdf->SetXY($this->marge_gauche, $posy);
// Logo
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
- if ($this->emetteur->logo)
- {
- if (is_readable($logo))
- {
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- }
- else
- {
- $pdf->SetTextColor(200,0,0);
- $pdf->SetFont('','B',$default_font_size - 2);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
- }
- }
- else
- {
- $text=$this->emetteur->name;
- $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
- }
-
- $pdf->SetFont('','B',$default_font_size + 3);
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $title=$outputlangs->transnoentities("CommercialProposal");
- $pdf->MultiCell(100, 4, $title, '', 'R');
-
- $pdf->SetFont('','B',$default_font_size);
-
- $posy+=5;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
-
- $posy+=1;
- $pdf->SetFont('','', $default_font_size - 2);
-
- if ($object->ref_client)
- {
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
- }
-
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
-
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite,"day",false,$outputlangs,true), '', 'R');
-
- if ($object->client->code_client)
- {
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
- }
-
- $posy+=2;
+ if ($this->emetteur->logo) {
+ if (is_readable($logo)) {
+ $height=pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ } else {
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
+ } else {
+ $text=$this->emetteur->name;
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
+ }
+
+ $pdf->SetFont('', 'B', $default_font_size + 3);
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $title=$outputlangs->transnoentities("CommercialProposal");
+ $pdf->MultiCell(100, 4, $title, '', 'R');
+
+ $pdf->SetFont('', 'B', $default_font_size);
+
+ $posy+=5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
+
+ $posy+=1;
+ $pdf->SetFont('', '', $default_font_size - 2);
+
+ if ($object->ref_client) {
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ }
+
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
+
+ if ($object->client->code_client) {
+ $posy+=4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
+ }
+
+ $posy+=2;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
- if ($showaddress)
- {
- // Sender properties
+ if ($showaddress) {
+ // Sender properties
$carac_emetteur='';
// Add internal contact of proposal if defined
- $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
- if (count($arrayidcontact) > 0)
- {
- $object->fetch_user($arrayidcontact[0]);
- $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
- }
+ $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0) {
+ $object->fetch_user($arrayidcontact[0]);
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ }
- $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
+ $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client);
// Show sender
$posy=42;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posx=$this->marge_gauche;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx=$this->page_largeur-$this->marge_droite-80;
+ }
+ $hautcadre=40;
// Show sender frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx,$posy-5);
- $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
- $pdf->SetXY($posx,$posy);
- $pdf->SetFillColor(230,230,230);
- $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
- $pdf->SetTextColor(0,0,60);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy-5);
+ $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy=$pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2,$posy);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
+ $pdf->SetXY($posx+2, $posy);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If CUSTOMER contact defined, we use it
$usecontact=false;
- $arrayidcontact=$object->getIdContact('external','CUSTOMER');
- if (count($arrayidcontact) > 0)
- {
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
- }
+ $arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
+ if (count($arrayidcontact) > 0) {
+ $usecontact=true;
+ $result=$object->fetch_contact($arrayidcontact[0]);
+ }
// Recipient name
- if (! empty($usecontact))
- {
- // On peut utiliser le nom de la societe du contact
- if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
- else $socname = $object->client->name;
- $carac_client_name=$outputlangs->convToOutputCharset($socname);
- }
- else
- {
- $carac_client_name=$outputlangs->convToOutputCharset($object->client->name);
+ if (! empty($usecontact)) {
+ // On peut utiliser le nom de la societe du contact
+ if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
+ $socname = $object->contact->socname;
+ } else {
+ $socname = $object->client->name;
+ }
+ $carac_client_name=$outputlangs->convToOutputCharset($socname);
+ } else {
+ $carac_client_name=$outputlangs->convToOutputCharset($object->client->name);
}
- $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');
+ $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, ($usecontact?$object->contact:''), $usecontact, 'target');
// Show recipient
$widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
+ if ($this->page_largeur < 210) {
+ $widthrecbox=84;
+ } // To work with US executive format
$posy=42;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
+ $posx=$this->marge_gauche;
+ }
// Show recipient frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx+2,$posy-5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx+2, $posy-5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
+ $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
// Show recipient information
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
- $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
- }
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetXY($posx+2, $posy+4+(dol_nboflines_bis($carac_client_name, 50)*4));
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
+ }
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetTextColor(0, 0, 0);
}
/**
@@ -1511,11 +1486,9 @@ function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
*/
- function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
+ public function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
{
- $showdetails=0;
- return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
+ $showdetails=0;
+ return pdf_pagefoot($pdf, $outputlangs, 'PROPALE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
-
}
-
diff --git a/core/triggers/interface_99_modSubtotal_subtotaltrigger.class.php b/core/triggers/interface_99_modSubtotal_subtotaltrigger.class.php
index 42290772..b3a980d2 100644
--- a/core/triggers/interface_99_modSubtotal_subtotaltrigger.class.php
+++ b/core/triggers/interface_99_modSubtotal_subtotaltrigger.class.php
@@ -89,12 +89,13 @@ public function getVersion()
if ($this->version == 'development') {
return $langs->trans("Development");
- } elseif ($this->version == 'experimental')
-
- return $langs->trans("Experimental");
- elseif ($this->version == 'dolibarr') return DOL_VERSION;
- elseif ($this->version) return $this->version;
- else {
+ } elseif ($this->version == 'experimental') {
+ return $langs->trans("Experimental");
+ } elseif ($this->version == 'dolibarr') {
+ return DOL_VERSION;
+ } elseif ($this->version) {
+ return $this->version;
+ } else {
return $langs->trans("Unknown");
}
}
@@ -390,8 +391,7 @@ public function run_trigger($action, $object, $user, $langs, $conf)
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEBILL_INSERT') {
-
- dol_syslog(
+ dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEBILL_DELETE') {
@@ -569,4 +569,4 @@ public function run_trigger($action, $object, $user, $langs, $conf)
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/htdocs_38/core/lib/pdf.lib.php b/htdocs_38/core/lib/pdf.lib.php
index 945146fa..0e48dad3 100644
--- a/htdocs_38/core/lib/pdf.lib.php
+++ b/htdocs_38/core/lib/pdf.lib.php
@@ -41,31 +41,31 @@
*/
function pdf_getFormat($outputlangs='')
{
- global $conf,$db;
+ global $conf,$db;
// Default value if setup was not done and/or entry into c_paper_format not defined
- $width=210; $height=297; $unit='mm';
-
- if (empty($conf->global->MAIN_PDF_FORMAT))
- {
- include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- $pdfformat=dol_getDefaultFormat($outputlangs);
- }
- else $pdfformat=$conf->global->MAIN_PDF_FORMAT;
-
- $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
- $sql.=" WHERE code = '".$pdfformat."'";
- $resql=$db->query($sql);
- if ($resql)
- {
- $obj=$db->fetch_object($resql);
- if ($obj)
- {
- $width=(int) $obj->width;
- $height=(int) $obj->height;
- $unit=$obj->unit;
- }
- }
+ $width=210;
+ $height=297;
+ $unit='mm';
+
+ if (empty($conf->global->MAIN_PDF_FORMAT)) {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ $pdfformat=dol_getDefaultFormat($outputlangs);
+ } else {
+ $pdfformat=$conf->global->MAIN_PDF_FORMAT;
+ }
+
+ $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
+ $sql.=" WHERE code = '".$pdfformat."'";
+ $resql=$db->query($sql);
+ if ($resql) {
+ $obj=$db->fetch_object($resql);
+ if ($obj) {
+ $width=(int) $obj->width;
+ $height=(int) $obj->height;
+ $unit=$obj->unit;
+ }
+ }
//print "pdfformat=".$pdfformat." width=".$width." height=".$height." unit=".$unit;
return array('width'=>$width,'height'=>$height,'unit'=>$unit);
@@ -79,65 +79,70 @@ function pdf_getFormat($outputlangs='')
* @param string $pagetype 'P' or 'l'
* @return TPDF PDF object
*/
-function pdf_getInstance($format='',$metric='mm',$pagetype='P')
+function pdf_getInstance($format='', $metric='mm', $pagetype='P')
{
- global $conf;
+ global $conf;
// Define constant for TCPDF
- if (! defined('K_TCPDF_EXTERNAL_CONFIG'))
- {
- define('K_TCPDF_EXTERNAL_CONFIG',1); // this avoid using tcpdf_config file
+ if (! defined('K_TCPDF_EXTERNAL_CONFIG')) {
+ define('K_TCPDF_EXTERNAL_CONFIG', 1); // this avoid using tcpdf_config file
define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/');
- define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
- dol_mkdir(K_PATH_CACHE);
- define('K_BLANK_IMAGE', '_blank.png');
- define('PDF_PAGE_FORMAT', 'A4');
- define('PDF_PAGE_ORIENTATION', 'P');
- define('PDF_CREATOR', 'TCPDF');
- define('PDF_AUTHOR', 'TCPDF');
- define('PDF_HEADER_TITLE', 'TCPDF Example');
- define('PDF_HEADER_STRING', "by Dolibarr ERP CRM");
- define('PDF_UNIT', 'mm');
- define('PDF_MARGIN_HEADER', 5);
- define('PDF_MARGIN_FOOTER', 10);
- define('PDF_MARGIN_TOP', 27);
- define('PDF_MARGIN_BOTTOM', 25);
- define('PDF_MARGIN_LEFT', 15);
- define('PDF_MARGIN_RIGHT', 15);
- define('PDF_FONT_NAME_MAIN', 'helvetica');
- define('PDF_FONT_SIZE_MAIN', 10);
- define('PDF_FONT_NAME_DATA', 'helvetica');
- define('PDF_FONT_SIZE_DATA', 8);
- define('PDF_FONT_MONOSPACED', 'courier');
- define('PDF_IMAGE_SCALE_RATIO', 1.25);
- define('HEAD_MAGNIFICATION', 1.1);
- define('K_CELL_HEIGHT_RATIO', 1.25);
- define('K_TITLE_MAGNIFICATION', 1.3);
- define('K_SMALL_RATIO', 2/3);
- define('K_THAI_TOPCHARS', true);
- define('K_TCPDF_CALLS_IN_HTML', true);
- define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
- }
-
- if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI))
- return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
+ define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
+ dol_mkdir(K_PATH_CACHE);
+ define('K_BLANK_IMAGE', '_blank.png');
+ define('PDF_PAGE_FORMAT', 'A4');
+ define('PDF_PAGE_ORIENTATION', 'P');
+ define('PDF_CREATOR', 'TCPDF');
+ define('PDF_AUTHOR', 'TCPDF');
+ define('PDF_HEADER_TITLE', 'TCPDF Example');
+ define('PDF_HEADER_STRING', "by Dolibarr ERP CRM");
+ define('PDF_UNIT', 'mm');
+ define('PDF_MARGIN_HEADER', 5);
+ define('PDF_MARGIN_FOOTER', 10);
+ define('PDF_MARGIN_TOP', 27);
+ define('PDF_MARGIN_BOTTOM', 25);
+ define('PDF_MARGIN_LEFT', 15);
+ define('PDF_MARGIN_RIGHT', 15);
+ define('PDF_FONT_NAME_MAIN', 'helvetica');
+ define('PDF_FONT_SIZE_MAIN', 10);
+ define('PDF_FONT_NAME_DATA', 'helvetica');
+ define('PDF_FONT_SIZE_DATA', 8);
+ define('PDF_FONT_MONOSPACED', 'courier');
+ define('PDF_IMAGE_SCALE_RATIO', 1.25);
+ define('HEAD_MAGNIFICATION', 1.1);
+ define('K_CELL_HEIGHT_RATIO', 1.25);
+ define('K_TITLE_MAGNIFICATION', 1.3);
+ define('K_SMALL_RATIO', 2/3);
+ define('K_THAI_TOPCHARS', true);
+ define('K_TCPDF_CALLS_IN_HTML', true);
+ define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
+ }
+
+ if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI)) {
+ return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
+ }
// We use by default TCPDF else FPDF
- if (empty($conf->global->MAIN_USE_FPDF)) require_once TCPDF_PATH.'tcpdf.php';
- else require_once FPDF_PATH.'fpdf.php';
+ if (empty($conf->global->MAIN_USE_FPDF)) {
+ require_once TCPDF_PATH.'tcpdf.php';
+ } else {
+ require_once FPDF_PATH.'fpdf.php';
+ }
// We need to instantiate tcpdi or fpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features).
- if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php';
- else if (empty($conf->global->MAIN_DISABLE_FPDI)) require_once FPDI_PATH.'fpdi.php';
+ if (empty($conf->global->MAIN_DISABLE_TCPDI)) {
+ require_once TCPDI_PATH.'tcpdi.php';
+ } elseif (empty($conf->global->MAIN_DISABLE_FPDI)) {
+ require_once FPDI_PATH.'fpdi.php';
+ }
//$arrayformat=pdf_getFormat();
//$format=array($arrayformat['width'],$arrayformat['height']);
//$metric=$arrayformat['unit'];
// Protection and encryption of pdf
- if (empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->PDF_SECURITY_ENCRYPTION))
- {
- /* Permission supported by TCPDF
+ if (empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->PDF_SECURITY_ENCRYPTION)) {
+ /* Permission supported by TCPDF
- print : Print the document;
- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
- copy : Copy or otherwise extract text and graphics from the document;
@@ -148,33 +153,38 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
*/
- if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
- else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format);
- else $pdf = new TCPDF($pagetype,$metric,$format);
+ if (class_exists('TCPDI')) {
+ $pdf = new TCPDI($pagetype, $metric, $format);
+ } elseif (class_exists('FPDI')) {
+ $pdf = new FPDI($pagetype, $metric, $format);
+ } else {
+ $pdf = new TCPDF($pagetype, $metric, $format);
+ }
// For TCPDF, we specify permission we want to block
$pdfrights = array('modify','copy');
- $pdfuserpass = ''; // Password for the end user
- $pdfownerpass = NULL; // Password of the owner, created randomly if not defined
- $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
- }
- else
- {
- if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
- else if (class_exists('FPDI')) $pdf = new FPDI($pagetype,$metric,$format);
- else $pdf = new TCPDF($pagetype,$metric,$format);
+ $pdfuserpass = ''; // Password for the end user
+ $pdfownerpass = null; // Password of the owner, created randomly if not defined
+ $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass);
+ } else {
+ if (class_exists('TCPDI')) {
+ $pdf = new TCPDI($pagetype, $metric, $format);
+ } elseif (class_exists('FPDI')) {
+ $pdf = new FPDI($pagetype, $metric, $format);
+ } else {
+ $pdf = new TCPDF($pagetype, $metric, $format);
+ }
}
// If we use FPDF class, we may need to add method writeHTMLCell
- if (! empty($conf->global->MAIN_USE_FPDF) && ! method_exists($pdf, 'writeHTMLCell'))
- {
- // Declare here a class to overwrite FPDI to add method writeHTMLCell
+ if (! empty($conf->global->MAIN_USE_FPDF) && ! method_exists($pdf, 'writeHTMLCell')) {
+ // Declare here a class to overwrite FPDI to add method writeHTMLCell
/**
* This class is an enhanced FPDI class that support method writeHTMLCell
*/
class FPDI_DolExtended extends FPDI
{
- /**
+ /**
* __call
*
* @param string $method Method
@@ -183,10 +193,10 @@ class FPDI_DolExtended extends FPDI
*/
public function __call($method, $args)
{
- if (isset($this->$method)) {
- $func = $this->$method;
- $func($args);
- }
+ if (isset($this->$method)) {
+ $func = $this->$method;
+ $func($args);
+ }
}
/**
@@ -207,20 +217,20 @@ public function __call($method, $args)
*/
public function writeHTMLCell($w, $h, $x, $y, $html = '', $border = 0, $ln = 0, $fill = false, $reseth = true, $align = '', $autopadding = true)
{
- $this->SetXY($x,$y);
- $val=str_replace('
',"\n",$html);
+ $this->SetXY($x, $y);
+ $val=str_replace('
', "\n", $html);
//$val=dol_string_nohtmltag($val,false,'ISO-8859-1');
- $val=dol_string_nohtmltag($val,false,'UTF-8');
- $this->MultiCell($w,$h,$val,$border,$align,$fill);
+ $val=dol_string_nohtmltag($val, false, 'UTF-8');
+ $this->MultiCell($w, $h, $val, $border, $align, $fill);
}
}
- $pdf2=new FPDI_DolExtended($pagetype,$metric,$format);
- unset($pdf);
- $pdf=$pdf2;
+ $pdf2=new FPDI_DolExtended($pagetype, $metric, $format);
+ unset($pdf);
+ $pdf=$pdf2;
}
- return $pdf;
+ return $pdf;
}
@@ -232,19 +242,21 @@ public function writeHTMLCell($w, $h, $x, $y, $html = '', $border = 0, $ln = 0,
*/
function pdf_getPDFFont($outputlangs)
{
- global $conf;
+ global $conf;
- if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT;
+ if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) {
+ return $conf->global->MAIN_PDF_FORCE_FONT;
+ }
- $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF
- if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
- {
- if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF')
- {
- $font=$outputlangs->trans('FONTFORPDF');
+ $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF
+ if (class_exists('TCPDF')) {
+ // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
+
+ if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') {
+ $font=$outputlangs->trans('FONTFORPDF');
}
}
- return $font;
+ return $font;
}
/**
@@ -255,15 +267,15 @@ function pdf_getPDFFont($outputlangs)
*/
function pdf_getPDFFontSize($outputlangs)
{
- $size=10; // By default, for FPDI or ISO language on TCPDF
- if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
- {
- if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF')
- {
- $size = (int) $outputlangs->trans('FONTSIZEFORPDF');
+ $size=10; // By default, for FPDI or ISO language on TCPDF
+ if (class_exists('TCPDF')) {
+ // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower)
+
+ if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF') {
+ $size = (int) $outputlangs->trans('FONTSIZEFORPDF');
}
}
- return $size;
+ return $size;
}
@@ -276,16 +288,17 @@ function pdf_getPDFFontSize($outputlangs)
*/
function pdf_getHeightForLogo($logo, $url = false)
{
- global $conf;
- $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT);
- $maxwidth=130;
- include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
- $tmp=dol_getImageSize($logo, $url);
- if ($tmp['height'])
- {
- $width=round($height*$tmp['width']/$tmp['height']);
- if ($width > $maxwidth) $height=$height*$maxwidth/$width;
- }
+ global $conf;
+ $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT);
+ $maxwidth=130;
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
+ $tmp=dol_getImageSize($logo, $url);
+ if ($tmp['height']) {
+ $width=round($height*$tmp['width']/$tmp['height']);
+ if ($width > $maxwidth) {
+ $height=$height*$maxwidth/$width;
+ }
+ }
//print $tmp['width'].' '.$tmp['height'].' '.$width; exit;
return $height;
}
@@ -299,23 +312,23 @@ function pdf_getHeightForLogo($logo, $url = false)
*/
function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs)
{
- //Recipient name
+ //Recipient name
$socname = '';
// On peut utiliser le nom de la societe du contact
if ($thirdparty instanceof Societe) {
- if (!empty($thirdparty->name_alias)) {
- $socname = $thirdparty->name_alias."\n";
- }
+ if (!empty($thirdparty->name_alias)) {
+ $socname = $thirdparty->name_alias."\n";
+ }
- $socname .= $thirdparty->name;
+ $socname .= $thirdparty->name;
} elseif ($thirdparty instanceof Contact) {
- $socname = $thirdparty->socname;
+ $socname = $thirdparty->socname;
} else {
- throw new InvalidArgumentException();
+ throw new InvalidArgumentException();
}
- return $outputlangs->convToOutputCharset($socname);
+ return $outputlangs->convToOutputCharset($socname);
}
/**
@@ -329,130 +342,178 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs)
* @param int $mode Address type ('source', 'target', 'targetwithdetails')
* @return string String with full address
*/
-function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$targetcontact='',$usecontact=0,$mode='source')
+function pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source')
{
- global $conf;
-
- $stringaddress = '';
-
- if ($mode == 'source' && ! is_object($sourcecompany)) return -1;
- if ($mode == 'target' && ! is_object($targetcompany)) return -1;
- if ($mode == 'delivery' && ! is_object($deliverycompany)) return -1;
-
- if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO: Deprecated
- if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id);
- if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id);
-
- if ($mode == 'source')
- {
- $withCountry = 0;
- if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1;
-
- $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n";
-
- if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS))
- {
- // Phone
- if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
+ global $conf;
+
+ $stringaddress = '';
+
+ if ($mode == 'source' && ! is_object($sourcecompany)) {
+ return -1;
+ }
+ if ($mode == 'target' && ! is_object($targetcompany)) {
+ return -1;
+ }
+ if ($mode == 'delivery' && ! is_object($deliverycompany)) {
+ return -1;
+ }
+
+ if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) {
+ $sourcecompany->departement=getState($sourcecompany->state_id);
+ } //TODO: Deprecated
+ if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
+ $sourcecompany->state=getState($sourcecompany->state_id);
+ }
+ if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) {
+ $targetcompany->departement=getState($targetcompany->state_id);
+ }
+
+ if ($mode == 'source') {
+ $withCountry = 0;
+ if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
+ $withCountry = 1;
+ }
+
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n";
+
+ if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) {
+ // Phone
+ if ($sourcecompany->phone) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone);
+ }
// Fax
- if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
+ if ($sourcecompany->fax) {
+ $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax);
+ }
// EMail
- if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
+ if ($sourcecompany->email) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email);
+ }
// Web
- if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
- }
- }
-
- if ($mode == 'target' || $mode == 'targetwithdetails')
- {
- if ($usecontact)
- {
- $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1));
-
- if (!empty($targetcontact->address)) {
- $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n";
- }else {
- $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
+ if ($sourcecompany->url) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url);
}
+ }
+ }
+
+ if ($mode == 'target' || $mode == 'targetwithdetails') {
+ if ($usecontact) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
+
+ if (!empty($targetcontact->address)) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n";
+ } else {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
+ }
// Country
if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
- $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n";
- }
- else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
- $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
+ $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code))."\n";
+ } elseif (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) {
+ $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
}
- if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
- {
- // Phone
- if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
- if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
- if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / ";
- if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
+ if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') {
+ // Phone
+ if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
+ }
+ if (! empty($targetcontact->phone_pro)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
+ }
+ if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) {
+ $stringaddress .= " / ";
+ }
+ if (! empty($targetcontact->phone_mobile)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
+ }
// Fax
- if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
+ if ($targetcontact->fax) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax);
+ }
// EMail
- if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
+ if ($targetcontact->email) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email);
+ }
// Web
- if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
- }
- }
- else
- {
- $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
+ if ($targetcontact->url) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url);
+ }
+ }
+ } else {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n";
// Country
- if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
+ if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
+ $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n";
+ }
- if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails')
- {
- // Phone
- if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ";
- if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
- if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / ";
- if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
+ if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') {
+ // Phone
+ if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Phone").": ";
+ }
+ if (! empty($targetcompany->phone)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
+ }
+ if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) {
+ $stringaddress .= " / ";
+ }
+ if (! empty($targetcompany->phone_mobile)) {
+ $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
+ }
// Fax
- if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
+ if ($targetcompany->fax) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax);
+ }
// EMail
- if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
+ if ($targetcompany->email) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email);
+ }
// Web
- if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
- }
- }
+ if ($targetcompany->url) {
+ $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url);
+ }
+ }
+ }
// Intra VAT
- if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS))
- {
- if ($targetcompany->tva_intra) $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
+ if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) {
+ if ($targetcompany->tva_intra) {
+ $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
+ }
}
// Professionnal Ids
- if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1))
- {
- $tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code);
- if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
- $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
- }
- if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2))
- {
- $tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code);
- if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
- $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
- }
- if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3))
- {
- $tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code);
- if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
- $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
- }
- if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4))
- {
- $tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code);
- if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1];
- $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
- }
- }
-
- return $stringaddress;
+ if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) {
+ $tmp=$outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code);
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp=$reg[1];
+ }
+ $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1);
+ }
+ if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) {
+ $tmp=$outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code);
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp=$reg[1];
+ }
+ $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2);
+ }
+ if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) {
+ $tmp=$outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code);
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp=$reg[1];
+ }
+ $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3);
+ }
+ if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) {
+ $tmp=$outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code);
+ if (preg_match('/\((.+)\)/', $tmp, $reg)) {
+ $tmp=$reg[1];
+ }
+ $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4);
+ }
+ }
+
+ return $stringaddress;
}
@@ -464,16 +525,17 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target
* @param int $page_height Height of page
* @return void
*/
-function pdf_pagehead(&$pdf,$outputlangs,$page_height)
+function pdf_pagehead(&$pdf, $outputlangs, $page_height)
{
- global $conf;
+ global $conf;
// Add a background image on document
- if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
- {
- $pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image
+ if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) {
+ // Warning, this option make TCPDF generation beeing crazy and some content disappeared behin the image
+
+ $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image
$pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height);
- $pdf->SetAutoPageBreak(1,0); // Restore pagebreak
+ $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak
}
}
@@ -490,30 +552,36 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
*/
function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
{
- // Print Draft Watermark
- if ($unit=='pt') $k=1;
- elseif ($unit=='mm') $k=72/25.4;
- elseif ($unit=='cm') $k=72/2.54;
- elseif ($unit=='in') $k=72;
-
- $savx=$pdf->getX(); $savy=$pdf->getY();
-
- $watermark_angle=atan($h/$w)/2;
- $watermark_x_pos=0;
- $watermark_y_pos=$h/3;
- $watermark_x=$w/2;
- $watermark_y=$h/3;
- $pdf->SetFont('','B',40);
- $pdf->SetTextColor(255,192,203);
+ // Print Draft Watermark
+ if ($unit=='pt') {
+ $k=1;
+ } elseif ($unit=='mm') {
+ $k=72/25.4;
+ } elseif ($unit=='cm') {
+ $k=72/2.54;
+ } elseif ($unit=='in') {
+ $k=72;
+ }
+
+ $savx=$pdf->getX();
+ $savy=$pdf->getY();
+
+ $watermark_angle=atan($h/$w)/2;
+ $watermark_x_pos=0;
+ $watermark_y_pos=$h/3;
+ $watermark_x=$w/2;
+ $watermark_y=$h/3;
+ $pdf->SetFont('', 'B', 40);
+ $pdf->SetTextColor(255, 192, 203);
//rotate
- $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$k,($h-$watermark_y)*$k,-$watermark_x*$k,-($h-$watermark_y)*$k));
+ $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x*$k, ($h-$watermark_y)*$k, -$watermark_x*$k, -($h-$watermark_y)*$k));
//print watermark
- $pdf->SetXY($watermark_x_pos,$watermark_y_pos);
- $pdf->Cell($w-20,25,$outputlangs->convToOutputCharset($text),"",2,"C",0);
+ $pdf->SetXY($watermark_x_pos, $watermark_y_pos);
+ $pdf->Cell($w-20, 25, $outputlangs->convToOutputCharset($text), "", 2, "C", 0);
//antirotate
$pdf->_out('Q');
- $pdf->SetXY($savx,$savy);
+ $pdf->SetXY($savx, $savy);
}
@@ -529,42 +597,41 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
* @param int $default_font_size Default font size
* @return float The Y PDF position
*/
-function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10)
+function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
{
- global $mysoc, $conf;
+ global $mysoc, $conf;
- $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
- $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT);
- $pdf->SetXY($curx, $cury);
+ $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
+ $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT);
+ $pdf->SetXY($curx, $cury);
- if (empty($onlynumber))
- {
- $pdf->SetFont('','B',$default_font_size - $diffsizetitle);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
- $cury+=4;
- }
+ if (empty($onlynumber)) {
+ $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
+ $cury+=4;
+ }
- $outputlangs->load("banks");
+ $outputlangs->load("banks");
// Use correct name of bank id according to country
$bickey="BICNumber";
- if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
+ if ($account->getCountryCode() == 'IN') {
+ $bickey="SWIFT";
+ }
// Get format of bank account according to its country
$usedetailedbban=$account->useDetailedBBAN();
//$onlynumber=0; $usedetailedbban=1; // For tests
- if ($usedetailedbban)
- {
- $savcurx=$curx;
+ if ($usedetailedbban) {
+ $savcurx=$curx;
- if (empty($onlynumber))
- {
- $pdf->SetFont('','',$default_font_size - $diffsizecontent);
- $pdf->SetXY($curx, $cury);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
- $cury+=3;
- }
+ if (empty($onlynumber)) {
+ $pdf->SetFont('', '', $default_font_size - $diffsizecontent);
+ $pdf->SetXY($curx, $cury);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
+ $cury+=3;
+ }
/*
if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+8);
@@ -631,75 +698,74 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
$curx=$savcurx;
$cury+=9;
*/
- }
- else
- {
- $pdf->SetFont('','B',$default_font_size - $diffsizecontent);
- $pdf->SetXY($curx, $cury);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
- $cury+=3;
-
- $pdf->SetFont('','B',$default_font_size - $diffsizecontent);
- $pdf->SetXY($curx, $cury);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
- $cury+=3;
-
- if ($diffsizecontent <= 2) $cury+=1;
+ } else {
+ $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);
+ $pdf->SetXY($curx, $cury);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Bank").': ' . $outputlangs->convToOutputCharset($account->bank), 0, 'L', 0);
+ $cury+=3;
+
+ $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent);
+ $pdf->SetXY($curx, $cury);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
+ $cury+=3;
+
+ if ($diffsizecontent <= 2) {
+ $cury+=1;
+ }
}
- $pdf->SetFont('','',$default_font_size - $diffsizecontent);
+ $pdf->SetFont('', '', $default_font_size - $diffsizecontent);
- if (empty($onlynumber) && ! empty($account->domiciliation))
- {
- $pdf->SetXY($curx, $cury);
- $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation);
- $pdf->MultiCell(100, 3, $val, 0, 'L', 0);
+ if (empty($onlynumber) && ! empty($account->domiciliation)) {
+ $pdf->SetXY($curx, $cury);
+ $val=$outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation);
+ $pdf->MultiCell(100, 3, $val, 0, 'L', 0);
//$nboflines=dol_nboflines_bis($val,120);
//$cury+=($nboflines*3)+2;
$tmpy=$pdf->getStringHeight(100, $val);
- $cury+=$tmpy;
- }
-
- if (! empty($account->proprio))
- {
- $pdf->SetXY($curx, $cury);
- $val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio);
- $pdf->MultiCell(100, 3, $val, 0, 'L', 0);
- $tmpy=$pdf->getStringHeight(100, $val);
- $cury+=$tmpy;
- }
-
- else if (! $usedetailedbban) $cury+=1;
+ $cury+=$tmpy;
+ }
+
+ if (! empty($account->proprio)) {
+ $pdf->SetXY($curx, $cury);
+ $val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio);
+ $pdf->MultiCell(100, 3, $val, 0, 'L', 0);
+ $tmpy=$pdf->getStringHeight(100, $val);
+ $cury+=$tmpy;
+ } elseif (! $usedetailedbban) {
+ $cury+=1;
+ }
// Use correct name of bank id according to country
$ibankey="IBANNumber";
- if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
- if (! empty($account->iban))
- {
- //Remove whitespaces to ensure we are dealing with the format we expect
+ if ($account->getCountryCode() == 'IN') {
+ $ibankey="IFSC";
+ }
+ if (! empty($account->iban)) {
+ //Remove whitespaces to ensure we are dealing with the format we expect
$ibanDisplay_temp = str_replace(' ', '', $outputlangs->convToOutputCharset($account->iban));
- $ibanDisplay = "";
-
- for($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++)
- {
- $ibanDisplay .= $ibanDisplay_temp[$i];
- if($i%4 == 3 && $i > 0) $ibanDisplay .= " ";
- }
-
- $pdf->SetFont('','B',$default_font_size - 3);
- $pdf->SetXY($curx, $cury);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0);
- $cury+=3;
- }
-
- if (! empty($account->bic))
- {
- $pdf->SetFont('','B',$default_font_size - 3);
- $pdf->SetXY($curx, $cury);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0);
- }
-
- return $pdf->getY();
+ $ibanDisplay = "";
+
+ for ($i = 0; $i < dol_strlen($ibanDisplay_temp); $i++) {
+ $ibanDisplay .= $ibanDisplay_temp[$i];
+ if ($i%4 == 3 && $i > 0) {
+ $ibanDisplay .= " ";
+ }
+ }
+
+ $pdf->SetFont('', 'B', $default_font_size - 3);
+ $pdf->SetXY($curx, $cury);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities($ibankey).': ' . $ibanDisplay, 0, 'L', 0);
+ $cury+=3;
+ }
+
+ if (! empty($account->bic)) {
+ $pdf->SetFont('', 'B', $default_font_size - 3);
+ $pdf->SetXY($curx, $cury);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0);
+ }
+
+ return $pdf->getY();
}
/**
@@ -717,19 +783,18 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
* @param int $hidefreetext 1=Hide free text, 0=Show free text
* @return int Return height of bottom margin including footer text
*/
-function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object,$showdetails=0,$hidefreetext=0)
+function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
{
- global $conf,$user;
+ global $conf,$user;
- $outputlangs->load("dict");
- $line='';
+ $outputlangs->load("dict");
+ $line='';
- $dims=$pdf->getPageDimensions();
+ $dims=$pdf->getPageDimensions();
// Line of free text
- if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext))
- {
- // Make substitution
+ if (empty($hidefreetext) && ! empty($conf->global->$paramfreetext)) {
+ // Make substitution
$substitutionarray=array(
'__FROM_NAME__' => $fromcompany->name,
'__FROM_EMAIL__' => $fromcompany->email,
@@ -737,185 +802,183 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
- complete_substitutions_array($substitutionarray,$outputlangs,$object);
- $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
- $line.=$outputlangs->convToOutputCharset($newfreetext);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+ $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray);
+ $line.=$outputlangs->convToOutputCharset($newfreetext);
}
// First line of company infos
- $line1=""; $line2=""; $line3=""; $line4="";
+ $line1="";
+ $line2="";
+ $line3="";
+ $line4="";
- if ($showdetails)
- {
- // Company name
- if ($fromcompany->name)
- {
- $line1.=($line1?" - ":"").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name;
+ if ($showdetails) {
+ // Company name
+ if ($fromcompany->name) {
+ $line1.=($line1?" - ":"").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name;
}
// Address
- if ($fromcompany->address)
- {
- $line1.=($line1?" - ":"").$fromcompany->address;
+ if ($fromcompany->address) {
+ $line1.=($line1?" - ":"").$fromcompany->address;
}
// Zip code
- if ($fromcompany->zip)
- {
- $line1.=($line1?" - ":"").$fromcompany->zip;
+ if ($fromcompany->zip) {
+ $line1.=($line1?" - ":"").$fromcompany->zip;
}
// Town
- if ($fromcompany->town)
- {
- $line1.=($line1?" ":"").$fromcompany->town;
+ if ($fromcompany->town) {
+ $line1.=($line1?" ":"").$fromcompany->town;
}
// Phone
- if ($fromcompany->phone)
- {
- $line1.=($line1?" - ":"").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone;
+ if ($fromcompany->phone) {
+ $line1.=($line1?" - ":"").$outputlangs->transnoentities("Phone").": ".$fromcompany->phone;
}
// Fax
- if ($fromcompany->fax)
- {
- $line1.=($line1?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax;
+ if ($fromcompany->fax) {
+ $line1.=($line1?" - ":"").$outputlangs->transnoentities("Fax").": ".$fromcompany->fax;
}
// URL
- if ($fromcompany->url)
- {
- $line2.=($line2?" - ":"").$fromcompany->url;
+ if ($fromcompany->url) {
+ $line2.=($line2?" - ":"").$fromcompany->url;
}
// Email
- if ($fromcompany->email)
- {
- $line2.=($line2?" - ":"").$fromcompany->email;
+ if ($fromcompany->email) {
+ $line2.=($line2?" - ":"").$fromcompany->email;
}
- }
- if ($showdetails || ($fromcompany->country_code == 'DE'))
- {
- // Managers
- if ($fromcompany->managers)
- {
- $line2.=($line2?" - ":"").$fromcompany->managers;
+ }
+ if ($showdetails || ($fromcompany->country_code == 'DE')) {
+ // Managers
+ if ($fromcompany->managers) {
+ $line2.=($line2?" - ":"").$fromcompany->managers;
}
- }
+ }
// Line 3 of company infos
// Juridical status
- if ($fromcompany->forme_juridique_code)
- {
- $line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
+ if ($fromcompany->forme_juridique_code) {
+ $line3.=($line3?" - ":"").$outputlangs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code));
}
// Capital
- if ($fromcompany->capital)
- {
- $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string
- if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
- else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs);
+ if ($fromcompany->capital) {
+ $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string
+ if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
+ $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
+ } else {
+ $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs);
+ }
}
// Prof Id 1
- if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2))
- {
- $field=$outputlangs->transcountrynoentities("ProfId1",$fromcompany->country_code);
- if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
- $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
+ if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) {
+ $field=$outputlangs->transcountrynoentities("ProfId1", $fromcompany->country_code);
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field=$reg[1];
+ }
+ $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1);
}
// Prof Id 2
- if ($fromcompany->idprof2)
- {
- $field=$outputlangs->transcountrynoentities("ProfId2",$fromcompany->country_code);
- if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
- $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
+ if ($fromcompany->idprof2) {
+ $field=$outputlangs->transcountrynoentities("ProfId2", $fromcompany->country_code);
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field=$reg[1];
+ }
+ $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2);
}
// Line 4 of company infos
// Prof Id 3
- if ($fromcompany->idprof3)
- {
- $field=$outputlangs->transcountrynoentities("ProfId3",$fromcompany->country_code);
- if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
- $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
+ if ($fromcompany->idprof3) {
+ $field=$outputlangs->transcountrynoentities("ProfId3", $fromcompany->country_code);
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field=$reg[1];
+ }
+ $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3);
}
// Prof Id 4
- if ($fromcompany->idprof4)
- {
- $field=$outputlangs->transcountrynoentities("ProfId4",$fromcompany->country_code);
- if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
- $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
+ if ($fromcompany->idprof4) {
+ $field=$outputlangs->transcountrynoentities("ProfId4", $fromcompany->country_code);
+ if (preg_match('/\((.*)\)/i', $field, $reg)) {
+ $field=$reg[1];
+ }
+ $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4);
}
// IntraCommunautary VAT
- if ($fromcompany->tva_intra != '')
- {
- $line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
+ if ($fromcompany->tva_intra != '') {
+ $line4.=($line4?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$outputlangs->convToOutputCharset($fromcompany->tva_intra);
}
- $pdf->SetFont('','',7);
- $pdf->SetDrawColor(224,224,224);
+ $pdf->SetFont('', '', 7);
+ $pdf->SetDrawColor(224, 224, 224);
// The start of the bottom of this page footer is positioned according to # of lines
$freetextheight=0;
- if ($line) // Free text
- {
- $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
- if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
- $width=200; $align='C';
- }
- $freetextheight=$pdf->getStringHeight($width,$line);
- }
-
- $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0);
- $posy=$marginwithfooter+0;
-
- if ($line) // Free text
- {
- $pdf->SetXY($dims['lm'],-$posy);
- $pdf->MultiCell(0, 3, $line, 0, $align, 0);
- $posy-=$freetextheight;
- }
-
- $pdf->SetY(-$posy);
- $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy);
- $posy--;
-
- if (! empty($line1))
- {
- $pdf->SetFont('','B',7);
- $pdf->SetXY($dims['lm'],-$posy);
- $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line1, 0, 'C', 0);
- $posy-=3;
- $pdf->SetFont('','',7);
- }
-
- if (! empty($line2))
- {
- $pdf->SetFont('','B',7);
- $pdf->SetXY($dims['lm'],-$posy);
- $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line2, 0, 'C', 0);
- $posy-=3;
- $pdf->SetFont('','',7);
- }
-
- if (! empty($line3))
- {
- $pdf->SetXY($dims['lm'],-$posy);
- $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line3, 0, 'C', 0);
- }
+ if ($line) {
+ // Free text
- if (! empty($line4))
- {
- $posy-=3;
- $pdf->SetXY($dims['lm'],-$posy);
- $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line4, 0, 'C', 0);
- }
+ $width=20000;
+ $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
+ if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) {
+ $width=200;
+ $align='C';
+ }
+ $freetextheight=$pdf->getStringHeight($width, $line);
+ }
+
+ $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0);
+ $posy=$marginwithfooter+0;
+
+ if ($line) {
+ // Free text
+
+ $pdf->SetXY($dims['lm'], -$posy);
+ $pdf->MultiCell(0, 3, $line, 0, $align, 0);
+ $posy-=$freetextheight;
+ }
+
+ $pdf->SetY(-$posy);
+ $pdf->line($dims['lm'], $dims['hk']-$posy, $dims['wk']-$dims['rm'], $dims['hk']-$posy);
+ $posy--;
+
+ if (! empty($line1)) {
+ $pdf->SetFont('', 'B', 7);
+ $pdf->SetXY($dims['lm'], -$posy);
+ $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line1, 0, 'C', 0);
+ $posy-=3;
+ $pdf->SetFont('', '', 7);
+ }
+
+ if (! empty($line2)) {
+ $pdf->SetFont('', 'B', 7);
+ $pdf->SetXY($dims['lm'], -$posy);
+ $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line2, 0, 'C', 0);
+ $posy-=3;
+ $pdf->SetFont('', '', 7);
+ }
+
+ if (! empty($line3)) {
+ $pdf->SetXY($dims['lm'], -$posy);
+ $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line3, 0, 'C', 0);
+ }
+
+ if (! empty($line4)) {
+ $posy-=3;
+ $pdf->SetXY($dims['lm'], -$posy);
+ $pdf->MultiCell($dims['wk']-$dims['rm'], 2, $line4, 0, 'C', 0);
+ }
// Show page nb only on iso languages (so default Helvetica font)
- if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica')
- {
- $pdf->SetXY(-20,-$posy);
+ if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') {
+ $pdf->SetXY(-20, -$posy);
//print 'xxx'.$pdf->PageNo().'-'.$pdf->getAliasNbPages().'-'.$pdf->getAliasNumPage();exit;
- if (empty($conf->global->MAIN_USE_FPDF)) $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
- else $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
+ if (empty($conf->global->MAIN_USE_FPDF)) {
+ $pdf->MultiCell(13, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
+ } else {
+ $pdf->MultiCell(13, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
+ }
}
- return $marginwithfooter;
+ return $marginwithfooter;
}
/**
@@ -932,28 +995,25 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
* @param string $default_font_size Font size
* @return float The Y PDF position
*/
-function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size)
+function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
{
- $linkedobjects = pdf_getLinkedObjects($object,$outputlangs);
- if (! empty($linkedobjects))
- {
- foreach($linkedobjects as $linkedobject)
- {
- $posy+=3;
- $pdf->SetXY($posx,$posy);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->MultiCell($w, $h, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', $align);
-
- if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"]))
- {
- $posy+=3;
- $pdf->SetXY($posx,$posy);
- $pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align);
- }
- }
- }
-
- return $pdf->getY();
+ $linkedobjects = pdf_getLinkedObjects($object, $outputlangs);
+ if (! empty($linkedobjects)) {
+ foreach ($linkedobjects as $linkedobject) {
+ $posy+=3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->MultiCell($w, $h, $linkedobject["ref_title"].' : '.$linkedobject["ref_value"], '', $align);
+
+ if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"])) {
+ $posy+=3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align);
+ }
+ }
+ }
+
+ return $pdf->getY();
}
/**
@@ -972,26 +1032,26 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al
* @param int $issupplierline Is it a line for a supplier object ?
* @return string|null
*/
-function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0)
+function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
{
- global $db, $conf, $langs, $hookmanager;
-
- $reshook=0;
- 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) ) )
- {
- $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('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code);
- $action='';
- $reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
- }
- if (empty($reshook))
- {
- $labelproductservice=pdf_getlinedesc($object,$i,$outputlangs,$hideref,$hidedesc,$issupplierline);
+ global $db, $conf, $langs, $hookmanager;
+
+ $reshook=0;
+ 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))) {
+ $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('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code);
+ $action='';
+ $reshook=$hookmanager->executeHooks('pdf_writelinedesc', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ }
+ if (empty($reshook)) {
+ $labelproductservice=pdf_getlinedesc($object, $i, $outputlangs, $hideref, $hidedesc, $issupplierline);
// Description
- $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J',true);
- return $labelproductservice;
- }
+ $pdf->writeHTMLCell($w, $h, $posx, $posy, $outputlangs->convToOutputCharset($labelproductservice), 0, 1, false, true, 'J', true);
+ return $labelproductservice;
+ }
}
/**
@@ -1005,27 +1065,28 @@ function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hide
* @param int $issupplierline Is it a line for a supplier object ?
* @return string String with line
*/
-function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0)
+function pdf_getlinedesc($object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
{
- global $db, $conf, $langs;
+ global $db, $conf, $langs;
- $idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false);
- $label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:''));
- $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:''));
- $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders
+ $idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false);
+ $label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:''));
+ $desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:''));
+ $ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders
$note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:'');
- $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false);
+ $dbatch=(! empty($object->lines[$i]->detail_batch)?$object->lines[$i]->detail_batch:false);
- if ($issupplierline) $prodser = new ProductFournisseur($db);
- else $prodser = new Product($db);
+ if ($issupplierline) {
+ $prodser = new ProductFournisseur($db);
+ } else {
+ $prodser = new Product($db);
+ }
- if ($idprod)
- {
- $prodser->fetch($idprod);
+ if ($idprod) {
+ $prodser->fetch($idprod);
// If a predefined product and multilang and on other lang, we renamed label with label translated
- if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang))
- {
- $translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it)
+ if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) {
+ $translatealsoifmodified=(! empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it)
// TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
// ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion).
@@ -1034,151 +1095,154 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
// If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation.
//var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit;
$textwasmodified=($label == $prodser->label);
- if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
+ if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) {
+ $label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
+ }
// Set desc
// Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no
$textwasmodified=false;
- if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) {
- $textwasmodified=(strpos(dol_html_entity_decode($desc,ENT_QUOTES | ENT_HTML401),dol_html_entity_decode($prodser->description,ENT_QUOTES | ENT_HTML401))!==false);
- } else {
- $textwasmodified=($desc == $prodser->description);
- }
- if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
+ if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) {
+ $textwasmodified=(strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401))!==false);
+ } else {
+ $textwasmodified=($desc == $prodser->description);
+ }
+ if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) {
+ $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"];
+ }
// Set note
$textwasmodified=($note == $prodser->note);
- if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
+ if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) {
+ $note=$prodser->multilangs[$outputlangs->defaultlang]["note"];
+ }
}
- }
+ }
// Description short of product line
$libelleproduitservice=$label;
// Description long of product line
- if (! empty($desc) && ($desc != $label))
- {
- if ($libelleproduitservice && empty($hidedesc))
- {
- $libelleproduitservice.='__N__';
- }
-
- if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except)
- {
- $discount=new DiscountAbsolute($db);
- $discount->fetch($object->lines[$i]->fk_remise_except);
- $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source);
- }
- elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except)
- {
- $discount=new DiscountAbsolute($db);
- $discount->fetch($object->lines[$i]->fk_remise_except);
- $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$discount->ref_facture_source);
+ if (! empty($desc) && ($desc != $label)) {
+ if ($libelleproduitservice && empty($hidedesc)) {
+ $libelleproduitservice.='__N__';
+ }
+
+ if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) {
+ $discount=new DiscountAbsolute($db);
+ $discount->fetch($object->lines[$i]->fk_remise_except);
+ $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source);
+ } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
+ $discount=new DiscountAbsolute($db);
+ $discount->fetch($object->lines[$i]->fk_remise_except);
+ $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source);
// Add date of deposit
- if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')';
- }
- else
- {
- if ($idprod)
- {
- if (empty($hidedesc)) $libelleproduitservice.=$desc;
- }
- else
- {
- $libelleproduitservice.=$desc;
+ if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
+ echo ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
}
- }
+ } else {
+ if ($idprod) {
+ if (empty($hidedesc)) {
+ $libelleproduitservice.=$desc;
+ }
+ } else {
+ $libelleproduitservice.=$desc;
+ }
+ }
}
// If line linked to a product
- if ($idprod)
- {
- // We add ref
- if ($prodser->ref)
- {
- $prefix_prodserv = "";
- $ref_prodserv = "";
- if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this
- {
- if ($prodser->isservice())
- {
- $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
+ if ($idprod) {
+ // We add ref
+ if ($prodser->ref) {
+ $prefix_prodserv = "";
+ $ref_prodserv = "";
+ if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
+ // In standard mode, we do not show this
+
+ if ($prodser->isservice()) {
+ $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." ";
+ } else {
+ $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
}
- else
- {
- $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." ";
+ }
+
+ if (empty($hideref)) {
+ if ($issupplierline) {
+ $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : '');
+ } // Show local ref and supplier ref
+ else {
+ $ref_prodserv = $prodser->ref;
+ } // Show local ref only
+
+ if (! empty($libelleproduitservice)) {
+ $ref_prodserv .= " - ";
}
- }
-
- if (empty($hideref))
- {
- if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref
- else $ref_prodserv = $prodser->ref; // Show local ref only
-
- if (! empty($libelleproduitservice)) $ref_prodserv .= " - ";
- }
+ }
- $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;
+ $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice;
}
}
// Add an additional description for the category products
- if (! empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && ! empty($conf->categorie->enabled))
- {
- include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
- $categstatic=new Categorie($db);
+ if (! empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && ! empty($conf->categorie->enabled)) {
+ include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ $categstatic=new Categorie($db);
// recovering the list of all the categories linked to product
$tblcateg=$categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
- foreach ($tblcateg as $cate)
- {
- // Adding the descriptions if they are filled
+ foreach ($tblcateg as $cate) {
+ // Adding the descriptions if they are filled
$desccateg=$cate->add_description;
- if ($desccateg)
- $libelleproduitservice.='__N__'.$desccateg;
- }
+ if ($desccateg) {
+ $libelleproduitservice.='__N__'.$desccateg;
+ }
+ }
}
- if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end))
- {
- $format='day';
+ if (! empty($object->lines[$i]->date_start) || ! empty($object->lines[$i]->date_end)) {
+ $format='day';
// Show duration if exists
- if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
- {
- $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs),dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
- }
- if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end)
- {
- $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')';
- }
- if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end)
- {
- $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
- }
+ if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
+ $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
+ }
+ if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end) {
+ $period='('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')';
+ }
+ if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end) {
+ $period='('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
+ }
//print '>'.$outputlangs->charset_output.','.$period;
$libelleproduitservice.="__N__".$period;
//print $libelleproduitservice;
- }
-
- if ($dbatch)
- {
- $format='day';
- foreach ($dbatch as $detail)
- {
- $dte=array();
- if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs));
- if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs));
- if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch);
- $dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->dluo_qty);
- $libelleproduitservice.= "__N__ ".implode($dte,"-");
- }
- }
+ }
+
+ if ($dbatch) {
+ $format='day';
+ foreach ($dbatch as $detail) {
+ $dte=array();
+ if ($detail->eatby) {
+ $dte[]=$outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs));
+ }
+ if ($detail->sellby) {
+ $dte[]=$outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs));
+ }
+ if ($detail->batch) {
+ $dte[]=$outputlangs->transnoentitiesnoconv('printBatch', $detail->batch);
+ }
+ $dte[]=$outputlangs->transnoentitiesnoconv('printQty', $detail->dluo_qty);
+ $libelleproduitservice.= "__N__ ".implode($dte, "-");
+ }
+ }
// Now we convert \n into br
- if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','
',$libelleproduitservice);
- else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice);
- $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1);
+ if (dol_textishtml($libelleproduitservice)) {
+ $libelleproduitservice=preg_replace('/__N__/', '
', $libelleproduitservice);
+ } else {
+ $libelleproduitservice=preg_replace('/__N__/', "\n", $libelleproduitservice);
+ }
+ $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice, 1);
- return $libelleproduitservice;
+ return $libelleproduitservice;
}
/**
@@ -1190,20 +1254,19 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return null|string
*/
-function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlinenum($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
+ global $hookmanager;
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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);
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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);
+ }
// TODO add hook function
- }
- else
- {
- return dol_htmlentitiesbr($object->lines[$i]->num);
- }
+ } else {
+ return dol_htmlentitiesbr($object->lines[$i]->num);
+ }
}
@@ -1216,20 +1279,19 @@ function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return null|string
*/
-function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineref($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
+ global $hookmanager;
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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);
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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);
+ }
// TODO add hook function
- }
- else
- {
- return dol_htmlentitiesbr($object->lines[$i]->product_ref);
- }
+ } else {
+ return dol_htmlentitiesbr($object->lines[$i]->product_ref);
+ }
}
/**
@@ -1241,20 +1303,19 @@ function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return null|string
*/
-function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
+ global $hookmanager;
- if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
- {
- $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);
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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);
+ }
// TODO add hook function
- }
- else
- {
- return dol_htmlentitiesbr($object->lines[$i]->ref_supplier);
- }
+ } else {
+ return dol_htmlentitiesbr($object->lines[$i]->ref_supplier);
+ }
}
/**
@@ -1266,25 +1327,29 @@ function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string
*/
-function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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_getlinevatrate',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $hookmanager;
+
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlinevatrate', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits,1);
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1);
+ }
+ }
}
/**
@@ -1296,28 +1361,34 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string
*/
-function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
{
- global $conf, $hookmanager;
-
- $sign=1;
- if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
-
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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_getlineupexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $conf, $hookmanager;
+
+ $sign=1;
+ if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign=-1;
+ }
+
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineupexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return price($sign * $object->lines[$i]->subprice, 0, $outputlangs);
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return price($sign * $object->lines[$i]->subprice, 0, $outputlangs);
+ }
+ }
}
/**
@@ -1329,23 +1400,25 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide value (0 = no, 1 = yes, 2 = just special lines)
* @return void
*/
-function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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);
- foreach($object->hooks as $modules)
- {
- if (method_exists($modules[$special_code],'pdf_getlineupwithtax')) return $modules[$special_code]->pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails);
- }
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
- }
+ global $hookmanager;
+
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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);
+ }
+ foreach ($object->hooks as $modules) {
+ if (method_exists($modules[$special_code], 'pdf_getlineupwithtax')) {
+ return $modules[$special_code]->pdf_getlineupwithtax($object, $i, $outputlangs, $hidedetails);
+ }
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return price(($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
+ }
+ }
}
/**
@@ -1357,29 +1430,31 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string
*/
-function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- if ($object->lines[$i]->special_code != 3)
- {
- if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
- {
- $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_getlineqty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
-
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
+ global $hookmanager;
+
+ if ($object->lines[$i]->special_code != 3) {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineqty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty;
- }
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return $object->lines[$i]->qty;
+ }
+ }
+ }
}
/**
@@ -1391,28 +1466,31 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string
*/
-function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineqty_asked($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- if ($object->lines[$i]->special_code != 3)
- {
- if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
- {
- $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_getlineqty_asked',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $hookmanager;
+
+ if ($object->lines[$i]->special_code != 3) {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineqty_asked', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty_asked;
- }
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return $object->lines[$i]->qty_asked;
+ }
+ }
+ }
}
/**
@@ -1424,28 +1502,31 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string
*/
-function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- if ($object->lines[$i]->special_code != 3)
- {
- if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
- {
- $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_getlineqty_shipped',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $hookmanager;
+
+ if ($object->lines[$i]->special_code != 3) {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineqty_shipped', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->qty_shipped;
- }
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return $object->lines[$i]->qty_shipped;
+ }
+ }
+ }
}
/**
@@ -1457,28 +1538,31 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return void
*/
-function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- if ($object->lines[$i]->special_code != 3)
- {
- if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
- {
- $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_getlineqty_keeptoship',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $hookmanager;
+
+ if ($object->lines[$i]->special_code != 3) {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineqty_keeptoship', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
- }
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return ($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped);
+ }
+ }
+ }
}
/**
@@ -1493,32 +1577,34 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0)
*/
function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = false)
{
- global $langs;
- if ($object->lines[$i]->special_code != 3) {
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
- $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(
+ global $langs;
+ if ($object->lines[$i]->special_code != 3) {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineunit', $parameters, $object,
+ $action = '';
+ $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object,
$action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
-
- } else {
- if (empty($hidedetails) || $hidedetails > 1) {
- return $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
}
- }
- }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
+ }
+ }
+ }
}
@@ -1531,30 +1617,33 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string
*/
-function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-
- if ($object->lines[$i]->special_code != 3)
- {
- if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
- {
- $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_getlineremisepercent',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $hookmanager;
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+
+ if ($object->lines[$i]->special_code != 3) {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineremisepercent', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs);
- }
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return dol_print_reduction($object->lines[$i]->remise_percent, $outputlangs);
+ }
+ }
+ }
}
/**
@@ -1569,22 +1658,29 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
*/
function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null)
{
- global $hookmanager;
+ global $hookmanager;
- if ($object->lines[$i]->special_code != 3) {
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
- $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_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ if ($object->lines[$i]->special_code != 3) {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- } else {
- if (empty($hidedetails) || $hidedetails > 1) return $object->lines[$i]->situation_percent . '%';
- }
- }
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return $object->lines[$i]->situation_percent . '%';
+ }
+ }
+ }
}
/**
@@ -1596,36 +1692,39 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string Return total of line excl tax
*/
-function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
{
- global $conf, $hookmanager;
-
- $sign=1;
- if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
-
- if ($object->lines[$i]->special_code == 3)
- {
- return $outputlangs->transnoentities("Option");
- }
- else
- {
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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_getlinetotalexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $conf, $hookmanager;
+
+ $sign=1;
+ if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
+ $sign=-1;
+ }
+
+ if ($object->lines[$i]->special_code == 3) {
+ return $outputlangs->transnoentities("Option");
+ } else {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlinetotalexcltax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return price($sign * $object->lines[$i]->total_ht, 0, $outputlangs);
- }
- }
- return '';
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return price($sign * $object->lines[$i]->total_ht, 0, $outputlangs);
+ }
+ }
+ }
+ return '';
}
/**
@@ -1637,33 +1736,34 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0)
* @param int $hidedetails Hide value (0 = no, 1 = yes, 2 = just special lines)
* @return string Return total of line incl tax
*/
-function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
+function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
{
- global $hookmanager;
-
- if ($object->lines[$i]->special_code == 3)
- {
- return $outputlangs->transnoentities("Option");
- }
- else
- {
- if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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_getlinetotalwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+ global $hookmanager;
+
+ if ($object->lines[$i]->special_code == 3) {
+ return $outputlangs->transnoentities("Option");
+ } else {
+ if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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_getlinetotalwithtax', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint;
- else return $reshook;
- }
- else
- {
- if (empty($hidedetails) || $hidedetails > 1) return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
- }
- }
- return '';
+ if (!empty($hookmanager->resPrint)) {
+ return $hookmanager->resPrint;
+ } else {
+ return $reshook;
+ }
+ } else {
+ if (empty($hidedetails) || $hidedetails > 1) {
+ return price(($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs);
+ }
+ }
+ }
+ return '';
}
/**
@@ -1674,40 +1774,33 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0)
* @param Translate $outputlangs Object langs for output
* @return integer
*/
-function pdf_getTotalQty($object,$type,$outputlangs)
+function pdf_getTotalQty($object, $type, $outputlangs)
{
- global $hookmanager;
+ global $hookmanager;
- $total=0;
- $nblignes=count($object->lines);
+ $total=0;
+ $nblignes=count($object->lines);
// Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
- {
- if ($object->lines[$i]->special_code != 3)
- {
- if ($type=='all')
- {
- $total += $object->lines[$i]->qty;
- }
- else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line)))
- {
- $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);
+ for ($i = 0 ; $i < $nblignes ; $i++) {
+ if ($object->lines[$i]->special_code != 3) {
+ if ($type=='all') {
+ $total += $object->lines[$i]->qty;
+ } elseif ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) {
+ $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);
+ }
// TODO add hook function
- }
- else if ($type==0 && $object->lines[$i]->product_type == 0)
- {
- $total += $object->lines[$i]->qty;
- }
- else if ($type==1 && $object->lines[$i]->product_type == 1)
- {
- $total += $object->lines[$i]->qty;
- }
- }
+ } elseif ($type==0 && $object->lines[$i]->product_type == 0) {
+ $total += $object->lines[$i]->qty;
+ } elseif ($type==1 && $object->lines[$i]->product_type == 1) {
+ $total += $object->lines[$i]->qty;
+ }
+ }
}
- return $total;
+ return $total;
}
/**
@@ -1717,89 +1810,79 @@ function pdf_getTotalQty($object,$type,$outputlangs)
* @param Translate $outputlangs Object lang for output
* @return array Linked objects
*/
-function pdf_getLinkedObjects($object,$outputlangs)
+function pdf_getLinkedObjects($object, $outputlangs)
{
- global $hookmanager;
+ global $hookmanager;
- $linkedobjects=array();
+ $linkedobjects=array();
- $object->fetchObjectLinked();
+ $object->fetchObjectLinked();
- foreach($object->linkedObjects as $objecttype => $objects)
- {
- if ($objecttype == 'propal')
- {
- $outputlangs->load('propal');
+ foreach ($object->linkedObjects as $objecttype => $objects) {
+ if ($objecttype == 'propal') {
+ $outputlangs->load('propal');
- foreach($objects as $elementobject)
- {
- $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
- $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
- $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
- $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs);
- }
- }
- else if ($objecttype == 'commande')
- {
- $outputlangs->load('orders');
- foreach($objects as $elementobject)
- {
- $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
- $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '');
- $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
- $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs);
- }
- }
- else if ($objecttype == 'contrat')
- {
- $outputlangs->load('contracts');
- foreach($objects as $elementobject)
- {
- $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
- $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
- $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
- $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat,'day','',$outputlangs);
- }
- }
- else if ($objecttype == 'shipping')
- {
- $outputlangs->load('orders');
- $outputlangs->load('sendings');
- foreach($objects as $elementobject)
- {
- $elementobject->fetchObjectLinked();
- $order = $elementobject->linkedObjects['commande'][0];
+ foreach ($objects as $elementobject) {
+ $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefProposal");
+ $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
+ $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal");
+ $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
+ }
+ } elseif ($objecttype == 'commande') {
+ $outputlangs->load('orders');
+ foreach ($objects as $elementobject) {
+ $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder");
+ $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref) . ($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '');
+ $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate");
+ $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date, 'day', '', $outputlangs);
+ }
+ } elseif ($objecttype == 'contrat') {
+ $outputlangs->load('contracts');
+ foreach ($objects as $elementobject) {
+ $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract");
+ $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
+ $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract");
+ $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs);
+ }
+ } elseif ($objecttype == 'shipping') {
+ $outputlangs->load('orders');
+ $outputlangs->load('sendings');
+ foreach ($objects as $elementobject) {
+ $elementobject->fetchObjectLinked();
+ $order = $elementobject->linkedObjects['commande'][0];
+
+ if (! empty($object->linkedObjects['commande'])) {
+ // There is already a link to order so we show only info of shipment
- if (! empty($object->linkedObjects['commande'])) // There is already a link to order so we show only info of shipment
- {
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending");
- $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref);
- $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateSending");
- $linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs);
- }
- else // We show both info of order and shipment
- {
+ $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref);
+ $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateSending");
+ $linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery, 'day', '', $outputlangs);
+ } else {
+ // We show both info of order and shipment
+
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending");
- $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : '');
- $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref);
- $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ' / ' . $outputlangs->transnoentities("DateSending");
- $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs);
- $linkedobjects[$objecttype]['date_value'].= ' / ' . dol_print_date($elementobject->date_delivery,'day','',$outputlangs);
- }
- }
- }
- }
+ $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : '');
+ $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref);
+ $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ' / ' . $outputlangs->transnoentities("DateSending");
+ $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date, 'day', '', $outputlangs);
+ $linkedobjects[$objecttype]['date_value'].= ' / ' . dol_print_date($elementobject->date_delivery, 'day', '', $outputlangs);
+ }
+ }
+ }
+ }
// For add external linked objects
- if (is_object($hookmanager))
- {
- $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
- $action='';
- $hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
- if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray;
+ if (is_object($hookmanager)) {
+ $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs);
+ $action='';
+ $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ if (! empty($hookmanager->resArray)) {
+ $linkedobjects = $hookmanager->resArray;
+ }
}
- return $linkedobjects;
+ return $linkedobjects;
}
/**
@@ -1811,25 +1894,24 @@ function pdf_getLinkedObjects($object,$outputlangs)
*/
function pdf_getSizeForImage($realpath)
{
- global $conf;
-
- $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
- $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
- $tmp=dol_getImageSize($realpath);
- if ($tmp['height'])
- {
- $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight
- if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth
- {
+ global $conf;
+
+ $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
+ $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
+ $tmp=dol_getImageSize($realpath);
+ if ($tmp['height']) {
+ $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight
+ if ($width > $maxwidth) {
+ // Pb with maxheight, so i use maxwidth
+
$width=$maxwidth;
- $height=(int) round($maxwidth*$tmp['height']/$tmp['width']);
- }
- else // No pb with maxheight
- {
+ $height=(int) round($maxwidth*$tmp['height']/$tmp['width']);
+ } else {
+ // No pb with maxheight
+
$height=$maxheight;
}
- }
- return array('width'=>$width,'height'=>$height);
+ }
+ return array('width'=>$width,'height'=>$height);
}
-
diff --git a/lib/subtotal.lib.php b/lib/subtotal.lib.php
index ee1a8ff4..c2f87a5c 100644
--- a/lib/subtotal.lib.php
+++ b/lib/subtotal.lib.php
@@ -45,4 +45,3 @@ function subtotalAdminPrepareHead()
return $head;
}
-
diff --git a/script/import-from-milestone.php b/script/import-from-milestone.php
index a9feba75..0876c4ce 100644
--- a/script/import-from-milestone.php
+++ b/script/import-from-milestone.php
@@ -44,4 +44,3 @@
WHERE 1";
print $sql.";
";
-