14 if (!defined(
'IN_PEEL')) {
17 require_once(
$GLOBALS[
'dirroot'] .
"/lib/class/pdf/tcpdf.php");
19 define(
'EURO', chr(128));
20 define(
'EURO_VAL', 6.55957);
21 define(
'FPDF_FONTPATH',
$GLOBALS[
'dirroot'] .
'/lib/class/pdf/font/');
63 elseif ($style ==
'FD' or $style ==
'DF')
67 $MyArc = 4 / 3 * (sqrt(2) - 1);
68 $this->
_out(sprintf(
'%.2f %.2f m', (
$x + $r) *
$k, ($hp -
$y) * $k));
71 $this->
_out(sprintf(
'%.2f %.2f l', $xc * $k, ($hp -
$y) * $k));
73 $this->
_Arc($xc + $r * $MyArc, $yc - $r, $xc + $r, $yc - $r * $MyArc, $xc + $r, $yc);
76 $this->
_out(sprintf(
'%.2f %.2f l', (
$x +
$w) * $k, ($hp - $yc) * $k));
77 $this->
_Arc($xc + $r, $yc + $r * $MyArc, $xc + $r * $MyArc, $yc + $r, $xc, $yc + $r);
80 $this->
_out(sprintf(
'%.2f %.2f l', $xc * $k, ($hp - (
$y +
$h)) * $k));
81 $this->
_Arc($xc - $r * $MyArc, $yc + $r, $xc - $r, $yc + $r * $MyArc, $xc - $r, $yc);
84 $this->
_out(sprintf(
'%.2f %.2f l', (
$x) * $k, ($hp - $yc) * $k));
85 $this->
_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r);
100 function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
103 $this->
_out(sprintf(
'%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1 * $this->k, (
$h - $y1) * $this->k,
104 $x2 * $this->k, (
$h - $y2) * $this->k, $x3 * $this->k, (
$h - $y3) * $this->k));
121 if ($this->angle != 0)
125 $angle *= M_PI / 180;
129 $cy = ($this->h -
$y) * $this->k;
130 $this->
_out(sprintf(
'q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm', $c, $s, - $s, $c, $cx, $cy, - $cx, - $cy));
141 if ($this->angle != 0) {
170 $res = 1 + floor($length / $largeur) ;
172 $res = 1 + floor($length);
189 if ($bill_mode ==
'user_custom_products_list') {
198 $this->
Image($logo, $x1 + 50, $y1, 35);
200 if ($bill_mode !=
'user_custom_products_list') {
201 $this->
SetXY($x1, $y1);
205 $this->
SetFont(
'Helvetica',
'', 10);
208 $lignes = $this->
sizeOfText($adresse, $length) ;
222 function fact_dev($libelle, $num, $change_background_color_by_type =
false, $bill_mode = null)
224 if ($bill_mode ==
'user_custom_products_list') {
226 $r1 = $this->w - 100;
231 $r1 = $this->w - 100;
235 $mid = ($r1 + $r2) / 2;
237 $texte = $libelle .
" N° : " . $num;
242 $this->
SetFont(
"Helvetica",
"B", $szfont);
244 if (($r1 + $sz) > $r2)
251 if($change_background_color_by_type) {
253 if($_GET[
'mode'] ==
'proforma') {
255 }
elseif ($_GET[
'mode'] ==
'devis') {
257 }
elseif ($_GET[
'mode'] ==
'bdc') {
259 }
elseif ($_GET[
'mode'] ==
'facture') {
264 $this->
SetXY($r1 + 1, $y1 + 2);
265 $this->
Cell($r2 - $r1 -1, 5, $texte, 0, 0,
"C");
276 $string = sprintf(
"FA%04d", $numfact);
289 if ($bill_mode ==
'user_custom_products_list') {
290 $r1 = $this->w - 100;
293 $r1 = $this->w - 100;
301 $this->
Rect($r1, $y1, $width, $height,
'D');
302 $this->
Rect($r1, $y1, $width, $header_height,
'DF');
304 $this->
SetFont(
"Helvetica",
"B", 10);
305 $this->
SetXY($r1, $y1 + 0.5);
306 $this->
Cell(90, 4,
$GLOBALS[
'STR_PDF_BILL_DATE'], 0, 0,
"C");
308 $this->
SetFont(
"Helvetica",
"", 10);
309 $this->
SetXY($r1, $y1 + $this->cMargin + $header_height);
312 $date .=
" - " .
$GLOBALS[
'STR_PDF_DATE_PAID'] .
" " . $date_a;
314 $this->
Cell(90, 4, $date, 0, 0,
"C");
327 $r1 = $this->w / 2 - 15;
330 $text1 = (
$mode !=
'devis'?
$GLOBALS[
'STR_INVOICE_BOTTOM_TEXT']:
$GLOBALS[
'STR_INVOICE_BOTTOM_TEXT1']);
331 $this->
SetXY($r1, $y1);
332 $this->
SetFont(
"Helvetica",
"", 8);
333 $this->
Cell(30, 4, $text1 ,0, 0,
"C");
334 if (floatval($tva)==0) {
342 $text2 =
$GLOBALS[
'STR_INVOICE_BOTTOM_TEXT2'];
343 $this->
SetXY($r1, $y1+4);
344 $this->
Cell(30, 4, $text2, 0, 0,
"C");
357 $r1 = $this->w / 2 - 15;
360 $this->
SetXY($r1, $y1);
361 $this->
SetFont(
"Helvetica",
"", 8);
374 if ($bill_mode ==
'user_custom_products_list') {
375 $r1 = $this->w - 200;
378 $r1 = $this->w - 200;
386 $this->
Rect($r1, $y1, $width, $height,
'D');
387 $this->
Rect($r1, $y1, $width, $header_height,
'DF');
389 $this->
SetFont(
"Helvetica",
"B", 10);
390 $this->
SetXY($r1, $y1 + 0.5);
395 $this->
Cell(90, 4,
$GLOBALS[
'STR_PDF_FACTURATION'], 0, 0,
"C");
397 $this->
SetFont(
"Helvetica",
"", 10);
398 $this->
SetXY($r1, $y1 + $this->cMargin + $header_height);
399 $this->
MultiCell(90, 4, $pdf_facturation .
"\n");
410 $r1 = $this->w - 100;
417 $this->
Rect($r1, $y1, $width, $height,
'D');
418 $this->
Rect($r1, $y1, $width, $header_height,
'DF');
420 $this->
SetFont(
"Helvetica",
"B", 10);
421 $this->
SetXY($r1, $y1 + 0.5);
422 $this->
Cell(90, 4,
$GLOBALS[
'STR_PDF_LIVRAISON'], 0, 0,
"C");
424 $this->
SetFont(
"Helvetica",
"", 10);
425 $this->
SetXY($r1, $y1 + $this->cMargin + $header_height);
426 $this->
MultiCell(90, 4, $pdf_facturation2 .
"\n");
437 $r1 = $this->w - 100;
444 $this->
Rect($r1, $y1, $width, $height,
'D');
445 $this->
Rect($r1, $y1, $width, $header_height,
'DF');
447 $this->
SetFont(
"Helvetica",
"B", 10);
448 $this->
SetXY($r1, $y1 + 0.5);
449 $this->
Cell(90, 4,
$GLOBALS[
'STR_PDF_PAIEMENT'], 0, 0,
"C");
451 $this->
SetFont(
"Helvetica",
"", 10);
452 $this->
SetXY($r1, $y1 + $this->cMargin + $header_height);
468 $mid = $y1 + (($y2 - $y1) / 2);
470 $this->
Line($r1, $mid, $r2, $mid);
471 $this->
SetXY($r1 + ($r2 - $r1) / 2 - 5 , $y1 + 1);
472 $this->
SetFont(
"Helvetica",
"B", 10);
473 $this->
Cell(10, 4,
$GLOBALS[
'STR_PDF_DUE_DATE'], 0, 0,
"C");
474 $this->
SetXY($r1 + ($r2 - $r1) / 2 - 5 , $y1 + 5);
475 $this->
SetFont(
"Helvetica",
"", 10);
476 $this->
Cell(10, 5, $date, 0, 0,
"C");
487 $this->
SetFont(
"Helvetica",
"", 10);
493 $this->
SetXY($r1 , $y1);
503 function addCols($y_max_allowed, $bill_mode=null)
507 $r2 = $this->w - ($r1 * 2) ;
508 if($bill_mode ==
'user_custom_products_list') {
515 $y2 = $y_max_allowed - 10 - $y1;
516 $this->
SetXY($r1, $y1);
517 $this->
Rect($r1, $y1, $r2, $y2,
"D");
520 $this->
Rect($r1, $y1, $r2, $height,
"DF");
523 $this->
SetFont(
"Helvetica",
"B", 8);
524 if(!empty($this->colonnes)) {
525 foreach($this->colonnes as $lib => $pos) {
526 $this->
SetXY($colX, $y1 + 1);
527 if($bill_mode !=
'user_custom_products_list') {
528 $this->
Cell($pos, 1, $lib, 0, 0,
"C");
530 $this->
MultiCell($pos, $height-1, $lib, 0, 0,
"C");
533 if($bill_mode !=
'user_custom_products_list') {
535 $this->
Line($colX, $y1, $colX, $y1 + $y2);
549 if(!empty($this->colonnes)) {
550 foreach($this->colonnes as $lib => $pos) {
551 if (isset($tab[
"$lib"])) {
552 $this->format[$lib] = $tab[
"$lib"];
567 if(!empty($this->colonnes)) {
568 foreach($this->colonnes as $lib => $pos) {
569 $texte = $tab[ $lib ];
572 if ($size > $max_y_reached) {
573 $max_y_reached = $size;
577 return $max_y_reached;
587 function addLine($ligne, $tab, $bill_mode = null)
590 $max_y_reached = $ligne;
591 if($bill_mode ==
'user_custom_products_list') {
592 $this->
SetFont(
"Helvetica",
"", 7);
594 $this->
SetFont(
"Helvetica",
"", 8);
597 if($bill_mode ==
'user_custom_products_list') {
600 if(!empty($this->colonnes)) {
601 foreach($this->colonnes as $lib => $pos) {
603 $texte = $tab[ $lib ];
605 $tailleTexte = $this->
sizeOfText($texte, $length);
606 $formText = $this->format[ $lib ];
608 $this->
MultiCell($longCell, $line_height, $texte, 0, $formText);
609 if ($max_y_reached < ($this->
GetY())) {
610 $max_y_reached = $this->
GetY() ;
614 if($bill_mode ==
'user_custom_products_list') {
620 return ($max_y_reached - $ligne);
635 $mid = $y1 + ($y2 / 2);
636 $this->
SetXY($r1 + ($r2 - $r1) / 2 - 5, $y1 + 3);
637 $this->
SetFont(
"Helvetica",
"B", 10);
638 $this->
Cell(10, 5,
$GLOBALS[
'STR_PDF_TOTAL_HT'], 0, 0,
"C");
639 $this->
SetXY($r1 + ($r2 - $r1) / 2 - 5, $y1 + 9);
640 $this->
SetFont(
"Helvetica",
"", 10);
652 $this->
SetFont(
"Helvetica",
"", 8);
654 $r2 = $this->w - ($r1 * 2) ;
655 $y1 = $this->h - 62 - $this->remarque_lignes * 4 - 5;
656 $y2 = $this->remarque_lignes * 4;
657 $this->
SetXY($r1 , $y1);
658 if (!empty(
$GLOBALS[
'site_parameters'][
'bill_pdf_add_color_behind_comments'])) {
661 $this->
Rect($r1, $y1-1, $r2, $y2+1,
"DF");
664 $this->
MultiCell($this->w - $r1 * 2, 4, $remarque .
"\n");
674 $this->
SetFont(
"Helvetica",
"B", 8);
679 $this->
Line($r1, $y1 + 4, $r2, $y1 + 4);
680 $this->
Line($r1 + 5, $y1 + 4, $r1 + 5, $y2);
681 $this->
Line($r1 + 27, $y1, $r1 + 27, $y2);
682 $this->
Line($r1 + 63, $y1, $r1 + 63, $y2);
683 $this->
Line($r1 + 75, $y1, $r1 + 75, $y2);
684 $this->
Line($r1 + 91, $y1, $r1 + 91, $y2);
685 $this->
SetXY($r1 + 9, $y1);
687 $this->
SetX($r1 + 63);
689 $this->
SetX($r1 + 78);
691 $this->
SetX($r1 + 100);
693 $this->
SetFont(
"Helvetica",
"B", 6);
694 $this->
SetXY($r1 + 93, $y2 - 13);
696 $this->
SetXY($r1 + 93, $y2 - 8);
698 $this->
SetXY($r1 + 93, $y2 - 3);
709 $this->
SetFont(
"Helvetica",
"B", 10);
715 $this->
Line($r1, $y1 + 6, $r2, $y1 + 6);
716 $this->
SetXY($r1, $y1 + 1);
718 $this->
SetFont(
"Helvetica",
"B", 7);
719 $this->
SetXY($r1, $y2 - 21);
721 $this->
SetXY($r1, $y2 - 16);
723 $this->
SetXY($r1, $y2 - 11);
734 $this->
SetFont(
"Helvetica",
"B", 10);
740 $this->
Line($r1, $y1 + 6, $r2, $y1 + 6);
741 $this->
SetXY($r1, $y1 + 1);
742 $this->
Cell(60, 4,
$GLOBALS[
'STR_TRANSFER'], 0, 0,
"C");
744 $sql=
"SELECT code_banque, code_guichet, numero_compte, cle_rib, iban, swift
751 $this->
SetXY($r1, $y1+6);
752 $this->
SetFont(
'Helvetica',
'', 10);
753 $rib =
$GLOBALS[
'STR_BANK_ACCOUNT_CODE'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':' .
$result[
'code_banque'] .
"\r\n" .
$GLOBALS[
'STR_BANK_ACCOUNT_COUNTER'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':' .
$result[
'code_guichet'] .
"\r\n" .
$GLOBALS[
'STR_BANK_ACCOUNT_NUMBER'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':'.$result[
'numero_compte'] .
"\r\n" .
$GLOBALS[
'STR_BANK_ACCOUNT_RIB_KEY'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':'.$result[
'cle_rib'] .
"\r\n" .
$GLOBALS[
'STR_IBAN'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':'.$result[
'iban'] .
"\r\n" .
$GLOBALS[
'STR_SWIFT'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':'.$result[
'swift'];
779 $r1 = $this->w - 130;
796 $this->
SetFont(
"Helvetica",
"B", 7);
802 $this->
SetXY($re + 30, $y1 +
$k);
803 $this->
Cell(25, 4, $params1[
'tarif_paiement'],
'',
'',
'R');
810 $this->
SetXY($re + 30, $y1 +
$k);
811 $this->
Cell(25, 4, $params1[
"total_ecotaxe_ht"],
'',
'',
'R');
814 if (!empty(
$GLOBALS[
'site_parameters'][
'mode_transport'])) {
816 $this->
Cell(25, 4,
$GLOBALS[
'STR_PDF_COUT_TRANSPORT_HT'] .
$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':');
817 $this->
SetXY($re + 30, $y1 +
$k);
818 $this->
Cell(25, 4, $params1[
"cout_transport_ht"],
'',
'',
'R');
824 $this->
Cell(25, 4,
$GLOBALS[
'STR_SMALL_ORDER_OVERCOST_TEXT'] .
$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':');
825 $this->
SetXY($re + 30, $y1 +
$k);
826 $this->
Cell(25, 4, $params1[
"small_order_overcost_amount"],
'',
'',
'R');
832 $this->
SetXY($re + 30, $y1 +
$k);
833 $this->
Cell(25, 4, $params1[
"montant_ht"],
'',
'',
'R');
835 addNETs_part_micro($this, $re, $y1 +
$k, $params1[
"totalttc"]);
841 $this->
SetXY($re + 30, $y1 +
$k);
842 $this->
Cell(25, 4, $params1[
"avoir"],
'',
'',
'R');
848 $this->
SetFont(
"Helvetica",
"B", 8);
851 $this->
SetXY($re + 30, $y1 +
$k);
852 $this->
Cell(25, 4, $params1[
"montant"],
'',
'',
'R');
863 $re = $this->w - 130;
865 $this->
SetFont(
"Helvetica",
"B", 7);
869 addTVAs_part_micro($this, $re, $y1 +
$k);
871 if (!empty($params2[
"distinct_total_vat"])) {
872 foreach($params2[
"distinct_total_vat"] as $vat_percent => $value) {
874 $this->
Cell(25, 4,
$GLOBALS[
'STR_PDF_TVA'] .
' ' . (
String::substr($vat_percent, 0, strlen(
'transport')) ==
'transport'? str_replace(
'transport',
$GLOBALS[
'STR_PDF_SHIPMENT'], $vat_percent) : $vat_percent) .
'%' .
$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
':' .
" ");
875 $this->
SetXY($re + 30, $y1 +
$k);
876 $this->
Cell(25, 4, $value,
'',
'',
'R');
882 $this->
SetXY($re + 30, $y1 +
$k);
883 $this->
Cell(25, 4, $params2[
'total_tva'],
'',
'',
'R');
899 $this->
SetFont(
'Helvetica',
'B', 50);
901 $this->
Rotate(45, 55, 190);
902 $this->
Text((!empty($coordx)?$coordx:55), (!empty($coordy)?$coordy:190), $texte);
923 function FillDocument($code_facture = null, $date_debut = null, $date_fin = null, $id_debut = null, $id_fin = null, $user_id = null, $id_statut_paiement_filter = null, $bill_mode =
'standard', $folder =
false, $order_object=null, $product_infos_array = null, $order_array = null, $document_title = null, $ids_array=null)
931 if ($bill_mode!=
'user_custom_products_list') {
932 $this->colonnes = array(
$GLOBALS[
'STR_PDF_REFERENCE'] => 22,
940 $column_formats = array(
$GLOBALS[
'STR_PDF_REFERENCE'] =>
"L",
943 $GLOBALS[
'STR_PDF_PRIX_TTC'] =>
"R",
949 $this->colonnes = array(
$GLOBALS[
'STR_PHOTO'] => 25,
954 $GLOBALS[
'STR_QUANTITY_SHORT'] => 7,
957 $column_formats = array(
$GLOBALS[
'STR_PHOTO'] =>
"C",
962 $GLOBALS[
'STR_QUANTITY_SHORT'] =>
"R",
963 $GLOBALS[
'STR_PDF_PRIX_TTC'] =>
"R",
970 if ($bill_mode !=
"user_custom_products_list") {
971 if (!empty($product_infos_array) || !empty($order_object)) {
975 if (!empty($code_facture)) {
979 if (!empty($date_debut)) {
982 if (!empty($date_fin)) {
985 if (!empty($id_fin)) {
986 $sql_cond_array[] =
"c.id BETWEEN '" . intval($id_debut) .
"' AND '" . intval($id_fin) .
"'";
987 }
elseif (!empty($id_debut)) {
988 $sql_cond_array[] =
"c.id>='" . intval($id_debut) .
"'";
990 if (!empty($user_id)) {
991 $sql_cond_array[] =
"c.id_utilisateur = '" . intval($user_id) .
"'";
993 if (is_numeric($id_statut_paiement_filter)) {
994 $sql_cond_array[] =
"c.id_statut_paiement = '" . intval($id_statut_paiement_filter) .
"'";
996 if ($bill_mode ==
'standard' || $bill_mode ==
'facture') {
998 $sql_cond_array[] =
"c.numero != ''";
1000 if (is_array($ids_array)) {
1001 $sql_cond_array[] =
"c.id IN (" . implode(
',', $ids_array) .
")";
1003 if (empty($sql_cond_array)) {
1006 $sql_bills =
"SELECT c.*, sp.technical_code AS statut_paiement
1007 FROM peel_commandes c
1008 LEFT JOIN peel_statut_paiement sp ON sp.id=c.id_statut_paiement AND " .
get_filter_site_cond(
'statut_paiement',
'sp') .
"
1009 WHERE " . implode(
' AND ', $sql_cond_array) .
' AND ' .
get_filter_site_cond(
'commandes',
'c') .
"
1010 ORDER BY c.o_timestamp ASC";
1015 if(empty($file_name)) {
1017 if(!empty($commande->f_datetime) && substr($commande->f_datetime, 0, 10) !=
'0000-00-00') {
1020 $file_name .=
'.pdf';
1023 $file_name =
'F-' . md5($sql_bills) .
'.pdf';
1029 $this->
generatePdfOrderContent($column_formats, $bill_mode, 0, $order_object, $product_infos_array, $document_title);
1030 $file_name =
$GLOBALS[
'STR_LIST_PRODUCT'] .
' ' .
vb($order_object->nom_ship) .
'.pdf';
1036 if ($folder ===
false) {
1037 $this->
Output($file_name);
1039 $this->
Output($folder . $file_name,
"F");
1053 if (!empty($order_object->id)) {
1054 $_SESSION[
'session_last_bill_viewed'] =
vn($order_object->id);
1068 $next_product_max_size_forecasted = 30;
1069 if (empty($product_infos_array)) {
1071 $product_infos_array[] =
false;
1073 $comments = array();
1074 if(!empty($order_infos[
'delivery_infos'])) {
1075 $comments[] =
$GLOBALS[
"STR_SHIPPING_TYPE"] .
$GLOBALS[
"STR_BEFORE_TWO_POINTS"].
': ' . $order_infos[
'delivery_infos'];
1077 if(!empty($order_object->commentaires)) {
1078 $comments[] = $order_object->commentaires;
1080 $this->remarque_lignes = $this->
sizeOfText(implode(
"\n", $comments), $this->w - 10 * 2);
1081 if(!empty(
$GLOBALS[
'site_parameters'][
'billing_as_transaction_receipt'])) {
1082 $sql_transaction =
"SELECT t.reference
1083 FROM peel_transactions t
1084 LEFT JOIN peel_commandes c ON c.id = t.orders_id
1085 WHERE t.orders_id='".intval($order_object->id).
"'
1089 $this->document_name =
'';
1092 $this->document_id =
$result[
'reference'];
1094 if ($bill_mode ==
"user_custom_products_list") {
1095 $this->document_id = 0;
1096 }
elseif ($bill_mode ==
"bdc") {
1098 $this->document_id = intval($order_object->order_id);
1099 }
elseif ($bill_mode ==
"proforma") {
1101 $this->document_id = intval($order_object->order_id);
1102 }
elseif ($bill_mode ==
"devis") {
1104 $this->document_id = intval($order_object->order_id);
1106 if(!empty($order_object->numero)) {
1108 $this->document_id = $order_object->numero;
1111 $this->document_id = intval($order_object->order_id);
1115 if(!empty($document_title)) {
1119 $product_infos_array[] = null;
1120 foreach($product_infos_array as $this_ordered_product) {
1121 if ($bill_mode ==
"user_custom_products_list") {
1123 $y_max_allowed = $this->h + 5;
1124 if (empty($this_ordered_product)) {
1126 $y_max_allowed += -13 - 4 *
vn($this->remarque_lignes) - 5;
1129 $y_max_allowed = $this->h - 10;
1130 if (empty($this_ordered_product)) {
1132 $y_max_allowed += -45 - 4 *
vn($this->remarque_lignes) - 5;
1135 if (empty(
$y) ||
$y + $next_product_max_size_forecasted > $y_max_allowed -5) {
1136 if(!empty(
$y) && ($bill_mode !=
'user_custom_products_list' || ($bill_mode ==
'user_custom_products_list' && !empty($this_ordered_product)))) {
1139 $this->
addCols($this->h - 10, $bill_mode);
1141 if ($bill_mode !=
'user_custom_products_list' || ($bill_mode==
'user_custom_products_list' && !empty($this_ordered_product))) {
1143 $next_product_max_size_forecasted = (30 + $next_product_max_size_forecasted) / 2;
1146 $this->
addSociete($societeInfoText, $societeLogoPath, $bill_mode);
1147 if ($bill_mode ==
"bdc") {
1149 }
elseif ($bill_mode ==
"proforma") {
1151 }
elseif ($bill_mode ==
"devis") {
1154 if (!empty(
$GLOBALS[
'site_parameters'][
'show_invoice_filigrane'])) {
1159 $this->
fact_dev($this->document_name, $this->document_id,
false, $bill_mode);
1160 if ($bill_mode !=
"user_custom_products_list") {
1161 if(in_array($order_object->statut_paiement, array(
'cancelled',
'refunded'))) {
1165 if(empty($order_object->o_timestamp) || substr($order_object->o_timestamp, 0, 10) ==
'0000-00-00') {
1167 $order_object->o_timestamp = date(
'Y-m-d H:i:s');
1169 if($bill_mode ==
"bdc" || $bill_mode ==
"devis" || $bill_mode ==
"user_custom_products_list") {
1170 $displayed_date =
get_formatted_date($order_object->o_timestamp,
'short',
vb(
$GLOBALS[
'site_parameters'][
'order_hour_display_mode'],
'long'));
1173 if(!empty($order_object->f_datetime) &&
String::substr($order_object->f_datetime, 0, 10) !=
'0000-00-00') {
1181 $this->
addDate($displayed_date, $order_infos[
'displayed_paiement_date'], $bill_mode);
1182 if ($bill_mode !=
"user_custom_products_list") {
1186 if ($bill_mode !=
"user_custom_products_list" && !empty(
$GLOBALS[
'site_parameters'][
'mode_transport']) && !empty($order_infos[
'client_infos_ship'])) {
1193 if ($bill_mode ==
"user_custom_products_list") {
1200 if (!empty($this_ordered_product)) {
1201 $prix =
fprix($this_ordered_product[
"prix"], ($bill_mode !=
"user_custom_products_list"), $order_object->devise,
true, $order_object->currency_rate);
1202 $prix_ht =
fprix($this_ordered_product[
"prix_ht"],
true, $order_object->devise,
true, $order_object->currency_rate);
1203 $total_prix_ht =
fprix($this_ordered_product[
"total_prix_ht"],
true, $order_object->devise,
true, $order_object->currency_rate);
1204 $total_prix =
fprix($this_ordered_product[
"total_prix"],
true, $order_object->devise,
true, $order_object->currency_rate);
1205 $product_text =
filtre_pdf($this_ordered_product[
"product_text"]);
1206 if ($bill_mode !=
"user_custom_products_list") {
1208 $line = array(
$GLOBALS[
'STR_PDF_REFERENCE'] => $this_ordered_product[
"reference"],
1209 $GLOBALS[
'STR_DESIGNATION'] => $product_text,
1210 $GLOBALS[
'STR_PDF_PRIX_HT'] => $prix_ht,
1212 $GLOBALS[
'STR_QUANTITY'] => $this_ordered_product[
"quantite"],
1213 $GLOBALS[
'STR_PDFTOTALHT'] => $total_prix_ht,
1214 $GLOBALS[
'STR_PDFTOTALTTC'] => $total_prix,
1215 $GLOBALS[
'STR_TAXE'] =>
"" . number_format($this_ordered_product[
'tva_percent'], 1) .
"%");
1217 $line = array(
$GLOBALS[
'STR_PDF_REFERENCE'] => $this_ordered_product[
"reference"],
1218 $GLOBALS[
'STR_DESIGNATION'] => $product_text,
1220 $GLOBALS[
'STR_QUANTITY'] => $this_ordered_product[
"quantite"],
1221 $GLOBALS[
'STR_PDFTOTALTTC'] => $total_prix);
1224 if (!empty($this_ordered_product[
"photo"]) && file_exists(
$GLOBALS[
'uploaddir'].
'/thumbs/'.
thumbs($this_ordered_product[
"photo"],50, 35))) {
1226 $this->
Image(
$GLOBALS[
'uploaddir'].
'/thumbs/'.
thumbs($this_ordered_product[
"photo"], 50, 35), 15,
$y-4);
1228 if (!empty($this_ordered_product[
"barcode_image_src"])) {
1230 $this->
Image($this_ordered_product[
'barcode_image_src'], 73,
$y-6, 58, 12);
1232 $line = array(
$GLOBALS[
'STR_PHOTO'] =>
"",
1233 $GLOBALS[
'STR_DESIGNATION'] => $this_ordered_product[
"reference"].
"\r\n".$product_text,
1234 $GLOBALS[
'STR_EAN_CODE'] =>
"\r\n\r\n\r\n".$this_ordered_product[
"ean_code"],
1235 $GLOBALS[
'STR_BRAND'] => $this_ordered_product[
"brand"],
1236 $GLOBALS[
'STR_CATEGORY'] => $this_ordered_product[
"category"],
1238 $GLOBALS[
'STR_QUANTITY_SHORT'] => $this_ordered_product[
"quantite"],
1239 $GLOBALS[
'STR_START_PRICE'].
' '.
$GLOBALS[
'STR_TTC'] => $this_ordered_product[
"minimal_price"]);
1241 $size = $this->
addLine(
$y, $line, $bill_mode);
1242 $next_product_max_size_forecasted = max($next_product_max_size_forecasted, min(60, $size));
1246 if(
$y > ($bill_mode !=
"user_custom_products_list" ?100: 70)) {
1248 $this->
addCols($y_max_allowed, $bill_mode);
1250 if (!empty($order_infos[
'code_promo_text'])) {
1251 foreach($line as $this_key => $this_item) {
1252 $line[$this_key] =
'';
1254 $line[
$GLOBALS[
'STR_DESIGNATION']] = $order_infos[
'code_promo_text'];
1258 if(!empty($comments)) {
1261 if (empty(
$GLOBALS[
'site_parameters'][
'pdf_invoice_display_rib_on_invoice_bottom'])) {
1262 if ($bill_mode ==
"bdc") {
1268 if ($bill_mode !=
"user_custom_products_list") {
1270 $this->
addNETs($order_infos[
'net_infos_array']);
1272 $this->
addTVAs($order_infos[
'tva_infos_array']);
1273 $this->
addInfoTVA($order_object->total_tva, $bill_mode, $order_object->id_utilisateur);
1276 if (!empty(
$GLOBALS[
'site_parameters'][
'add_copyright_on_pdf_file'])) {
1277 $qid =
query(
"SELECT *
1282 $text =
'<a href="' .get_url(
'/') .
'">' . get_url(
'/') .
'</a> Copyright ' .
$GLOBALS[
'site'] .
' ' . date(
'Y').
' / '.
$GLOBALS[
'STR_TEL'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'].
': '.$ligne[
'tel'].
' / '.
$GLOBALS[
'STR_FAX'].$GLOBALS[
'STR_BEFORE_TWO_POINTS'].
': '.$ligne[
'fax'].
' / '.$ligne[
'email'] ;
1283 $this->
writeHTMLCell(
"", 4, 10, $y1, $text, 0, 1,
false,
true,
"C");
1284 $this->
SetFont(
"Helvetica",
"", 6);
1286 $this->
writeHTMLCell(
"", 4, 10, $y1+4, $text, 0, 1,
false,
true,
"C");
1298 $qid =
query(
"SELECT *
1303 $pdf_societe =
filtre_pdf($ligne->societe) .
"\n" ;
1304 $pdf_adresse =
filtre_pdf($ligne->adresse) .
"\n" ;
1305 $pdf_codepostal =
filtre_pdf($ligne->code_postal);
1307 $pdf_pays =
filtre_pdf($ligne->pays) .
"\n" ;
1308 if (!empty($ligne->tel)) {
1313 $pdf_fax = $ligne->fax ;
1314 if (!empty($ligne->siren)) {
1319 if (!empty($ligne->tvaintra)) {
1320 $pdf_tvaintra_company =
$GLOBALS[
'STR_VAT_INTRACOM'] .
$GLOBALS[
'STR_BEFORE_TWO_POINTS'] .
': ' .
filtre_pdf($ligne->tvaintra) .
"\n";
1322 $pdf_tvaintra_company =
"" ;
1325 if (file_exists(
$GLOBALS[
'dirroot'] .
'/factures/logo.jpg')) {
1326 $pdf_logo =
$GLOBALS[
'dirroot'] .
'/factures/logo.jpg';
1328 $pdf_logo = $ligne->logo ;
1330 return $pdf_societe . $pdf_adresse . $pdf_codepostal .
" " . $pdf_ville .
" - " . $pdf_pays . $pdf_siret . $pdf_tvaintra_company . $pdf_tel . $pdf_siteweb .
"\n";
1344 if (!empty(
$lang)) {
1345 if (!empty(
$GLOBALS[
'site_parameters'][
'logo_bill_'.
$lang])) {
1346 $pdf_logo =
$GLOBALS[
'site_parameters'][
'logo_bill_'.$lang];
1348 $pdf_logo =
$GLOBALS[
'site_parameters'][
'logo_'.$lang];
1351 if(empty($pdf_logo) && file_exists(
$GLOBALS[
'dirroot'] .
'/factures/logo.jpg')) {
1352 $pdf_logo =
$GLOBALS[
'dirroot'] .
'/factures/logo.jpg';
1354 if(!empty($pdf_logo) && strpos($pdf_logo,
$GLOBALS[
'dirroot']) ===
false) {
1358 if (!empty($pdf_logo) && file_exists(
$GLOBALS[
'dirroot'] .
'/' . $pdf_logo)) {
1360 $pdf_logo =
$GLOBALS[
'dirroot'] .
'/' . $pdf_logo;
1361 }
elseif (!empty($pdf_logo) && file_exists(
$GLOBALS[
'dirroot'] .
'/images/' . $pdf_logo)) {
1363 $pdf_logo =
$GLOBALS[
'dirroot'] .
'/images/' . $pdf_logo;
1368 if(!empty($handle)) {
SetLineWidth($width)
Defines the line width.
static strtoupper($string)
Returns string with all alphabetic characters converted to uppercase.
addEcheance($date)
Affiche un cadre avec la date d'echeance (en haut, au centre)
FillDocument($code_facture=null, $date_debut=null, $date_fin=null, $id_debut=null, $id_fin=null, $user_id=null, $id_statut_paiement_filter=null, $bill_mode= 'standard', $folder=false, $order_object=null, $product_infos_array=null, $order_array=null, $document_title=null, $ids_array=null)
Cette fonction génère :
get_payment_status_name($id)
get_payment_status_name()
getGroupPageNo()
Return the current page in the group.
getPageGroupAlias()
Return the alias for the total number of pages in the current page group.
addRemarque($remarque)
Ajoute une remarque (en bas, a gauche)
addCadreTva()
Invoice::addCadreTva()
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
addClientAdresseExpedition($pdf_facturation2)
Invoice::addClientAdresseExpedition()
get_product_infos_array_in_order($order_id, $devise=null, $currency_rate=null, $order_by=null, $add_total_prix_attribut=false)
get_product_infos_array_in_order()
static rawurldecode($string, $avoid_slash=false)
Returns rawurldecode.
is_user_tva_intracom_for_no_vat($user_id=null)
is_user_tva_intracom_for_no_vat()
addNETs($params1)
Invoice::addNETs()
Output($name='doc.pdf', $dest='I')
Send the document to a given destination: string, local file or browser.
static fopen_utf8($filename, $mode, $force_filename_in_iso_8859=false, $try_filename_in_iso_8859_if_file_not_found=true)
Ouvre un fichier.
addClientAdresseFacturation($pdf_facturation, $id_utilisateur, $bill_mode)
Affiche l'adresse du client (en haut, a droite)
sizeOfText($texte, $largeur)
Invoice::sizeOfText()
$k
Scale factor (number of points in user unit).
$w
Current width of page in user unit.
addLineFormat($tab)
Mémorise le format (gauche, centre, droite) d'une colonne.
Rect($x, $y, $w, $h, $style='', $border_style=array(), $fill_color=array())
Draws a rectangle.
SetX($x, $rtloff=false)
Defines the abscissa of the current position.
addReference($ref)
Affiche une ligne avec des references (en haut, a gauche)
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
lastPage($resetmargins=false)
Reset pointer to the last document page.
addSociete($adresse, $logo, $bill_mode)
Cette fonction affiche en haut à gauche le nom de la societe dans la police Helvetica-12-Bold les coo...
if(!defined('IN_PEEL')) thumbs($source_filename, $width, $height, $method= 'fit', $source_folder=null, $thumb_folder=null, $thumb_rename=true, $return_absolute_path=false)
Charge l'image dont le nom est $source_filename dans le répertoire d'upload, et crée une vignette pou...
SetFillColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used for all filling operations (filled rectangles and cell backgrounds).
$y
Current vertical position in user unit for cell positioning.
getSocieteInfoText()
getSocieteInfoText()
addCols($y_max_allowed, $bill_mode=null)
Trace le cadre des colonnes du devis/facture.
Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
Prints a cell (rectangular area) with optional borders, background color and character string...
Text($x, $y, $txt, $fstroke=false, $fclip=false, $ffill=true, $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M', $rtloff=false)
Prints a text cell at the specified position.
addLine($ligne, $tab, $bill_mode=null)
Invoice::addLine()
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
SetFont($family, $style='', $size=null, $fontfile='', $subset='default', $out=true)
Sets the font used to print character strings.
SetTextColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used for text.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
addDate($date, $date_a, $bill_mode)
Affiche un cadre avec la date de la facture / devis (en haut, a droite)
addCadreSignature()
Invoice::addCadreSignature()
Open()
This method begins the generation of the PDF document.
backgoundBigWatermark($texte, $coordx=null, $coordy=null)
Permet de rajouter un commentaire (Devis temporaire, REGLE, DUPLICATA, ...) en sous-impression ATTENT...
startPageGroup($page= '')
Create a new page group.
$h
Current height of page in user unit.
fetch_object($query_result)
fetch_object()
Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false, $alt=false, $altimgs=array())
Puts an image in the page.
AddPage($orientation='', $format='', $keepmargins=false, $tocpage=false)
Adds a new page to the document.
addCadreNet()
trace le cadre des totaux
fetch_assoc($query_result)
fetch_assoc()
InvoiceRoundedRect($x, $y, $w, $h, $r, $style= '')
PRIVATE FUNCTION : Invoice::InvoiceRoundedRect()
call_module_hook($hook, $params, $mode= 'boolean')
Appelle la fonction correspondant au $hook pour chaque module installé La fonction doit s'appeler : [...
SetAutoPageBreak($auto, $margin=0)
Enables or disables the automatic page breaking mode.
addCadreTVAs()
Trace le cadre des TVAs.
writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true)
Prints a cell (rectangular area) with optional borders, background color and html text string...
_out($s)
Output a string to the document.
AliasNbPages($s='')
This method is DEPRECATED and doesn't have any effect.
GetY()
Returns the ordinate of the current position.
$GLOBALS['page_columns_count']
GetStringWidth($s, $fontname='', $fontstyle='', $fontsize=0, $getarray=false)
Returns the length of a string in user unit.
_endpage()
PRIVATE FUNCTION : Invoice::_endpage()
Rotate($angle, $x=-1, $y=-1)
PRIVATE FUNCTION : Invoice::Rotate()
fact_dev($libelle, $num, $change_background_color_by_type=false, $bill_mode=null)
Affiche en haut, a droite le libelle (FACTURE, $GLOBALS['STR_DEVIS'], Bon de commande, etc...) et son numero La taille de la fonte est auto-adaptee au cadre.
addTVAs($params2)
Invoice::addTVAs()
$x
Current horizontal position in user unit for cell positioning.
lineVert($tab)
Invoice::lineVert()
addReglement($mode)
Affiche un cadre avec le règlement (chèque, etc...) (en haut, a gauche)
Line($x1, $y1, $x2, $y2, $style=array())
Draws a line between two points.
SetXY($x, $y, $rtloff=false)
Defines the abscissa and ordinate of the current position.
addFacture($numfact)
Génère automatiquement un numéro de facture.
addInfoTVA($tva, $mode=null, $id_utilisateur=null)
Affiche un cadre avec les informations sur la TVA (en bas au milieu)
get_order_infos_array($order_object)
get_order_infos_array()
fprix($price, $display_currency=false, $currency_code_or_default=null, $convertion_needed_into_currency=true, $currency_rate=null, $display_iso_currency_code=false, $format=true, $force_format_separator=null, $add_rdfa_properties=false, $round_even_if_no_format=false)
fprix formatte le prix donné en le convertissant si nécessaire au préalable et en ajoutant éventuelle...
addTotalHt($total_ht)
Invoice::addTotalHt()
MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0, $valign='T', $fitcell=false)
This method allows printing text with line breaks.
_Arc($x1, $y1, $x2, $y2, $x3, $y3)
PRIVATE FUNCTION : Invoice::_Arc()
get_payment_name($id_or_code)
get_payment_name()
$page
Current page number.
PHP class for generating PDF documents without requiring external extensions.
static convert_accents($string, $convert_umlaut=false, $strip_umlaut=true)
convert_accents()
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
check_if_module_active($module_name, $specific_file_name=null)
Renvoie si un module est présent et activé ou non - Peut être appelé avant ou après le chargement d'u...
generatePdfOrderContent($column_formats, $bill_mode, $i, &$order_object, &$product_infos_array, $document_title=null)
generatePdfOrderContent()
static str_shorten($string, $length_limit, $middle_separator= '', $ending_if_no_middle_separator= '...', $ideal_length_with_clean_cut_if_possible=null)
Raccourcit une chaine de caractère en insérant au milieu ou à la fin un séparateur.
addPageNumber($page)
Affiche un cadre avec un numéro de page (en haut, a droite)
addCadreRib()
Invoice::addCadreRib()
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']
getSocieteLogoPath($lang=null)
getSocieteLogoPath()