PEEL Shopping
Open source ecommerce : PEEL Shopping
PickingList.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: PickingList.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 require_once($GLOBALS['dirroot'] . "/lib/class/pdf/tcpdf.php");
18 
28 class PickingList extends TCPDF {
35  function Header()
36  {
37  global $dateAdded1, $dateAdded2;
38  // Police Helvetica gras 15
39  $this->SetFont('Helvetica', 'B', 15);
40  $this->SetDrawColor(0, 80, 180);
41  $this->SetFillColor(230, 230, 0);
42  $this->SetTextColor(220, 50, 50);
43  $this->Cell(0, 10, $GLOBALS["STR_ADMIN_PICKING_LIST"].' - ' . get_delivery_status_name($_GET['statut']) . ' ' . $GLOBALS['strStartingOn'] . ' ' . get_formatted_date($dateAdded1) . ' ' . $GLOBALS['strTillDay'] . ' ' . get_formatted_date($dateAdded2) . '', 1, 0, 'C', 1);
44  // Saut de ligne
45  $this->Ln(20);
46  }
52  function Footer()
53  {
54  // Positionnement à 1,5 cm du bas
55  $this->SetY(-15);
56  // Police Helvetica italique 8
57  $this->SetFont('Helvetica', 'I', 8);
58  // Numéro de page
59  $this->Cell(0, 10, $GLOBALS['STR_PDF_BILL_PAGE'] . ' ' . $this->PageNo() . ' / ' . $this->getAliasNbPages(), 0, 0, 'C');
60  }
61 
67  function AddPage()
68  {
70  $y1 = 7;
71  $this->SetXY(0, $y1);
72  $this->SetFont("Helvetica", "B", 10);
73  foreach(explode("\n", $this->PickingList_title) as $this_title) {
74  $this->Cell(0, 4, $this_title, 0, 0, "C");
75  $y1 = $y1 + 6;
76  $this->SetXY(0, $y1);
77  }
78  $this->SetFont("Helvetica", "", 8);
79  }
80 
89  function FillDocument($dateAdded1, $dateAdded2, $statut)
90  {
91  $this->PickingList_title = sprintf($GLOBALS["STR_ADMIN_PICKING_GENERATED_TITLE"], $GLOBALS['site_parameters']['nom_' . $_SESSION['session_langue']], get_formatted_date(time(), 'short', 'long'), get_formatted_date($dateAdded1), get_formatted_date($dateAdded2));
92  if (is_numeric($statut)) {
93  $this->PickingList_title .= " ".$GLOBALS["STR_ADMIN_PICKING_GENERATED_WITH_DELIVERY_STATUS"].$GLOBALS["STR_BEFORE_TWO_POINTS"].": " . String::strtoupper(get_delivery_status_name($statut));
94  }
95  $sql = "SELECT c.*, sp.technical_code AS statut_paiement
96  FROM peel_commandes c
97  LEFT JOIN peel_statut_paiement sp ON sp.id=c.id_statut_paiement AND " . get_filter_site_cond('statut_paiement', 'sp') . "
98  WHERE c.o_timestamp>='" . nohtml_real_escape_string($dateAdded1) . "' AND c.o_timestamp<='" . nohtml_real_escape_string($dateAdded2) . "' " . (is_numeric($statut)?" AND c.id_statut_livraison = '" . intval($statut) . "'":"") . " AND " . get_filter_site_cond('commandes', 'c') . "
99  ORDER BY c.o_timestamp";
100  $query = query($sql);
101 
102  $this->AliasNbPages('{nb}');
103  $this->AddPage();
104 
105  $k = 1;
106  $x1 = 10;
107  $x_margin = 5;
108  $y_top = 15;
109  $y_max = 270;
110  $y_block_margin = 13;
111 
112  $y1 = $y_top;
113  while ($commande = fetch_assoc($query)) {
114  $id = $commande['id'];
115  $date_commande = get_formatted_date($commande['o_timestamp'], 'short', 'long');
116  $order_infos = get_order_infos_array((object) $commande);
117  $client = $order_infos['client_infos_ship'];
118  $product_infos_array = get_product_infos_array_in_order($id, $commande['devise'], $commande['currency_rate']);
119 
120  $w = 91;
121  $h = 24;
122  $h += count(explode("\n", $client)) * 3;
123  if (!empty($product_infos_array)) {
124  foreach ($product_infos_array as $this_ordered_product) {
125  $h += 1 + (1 + count(explode("\n", $this_ordered_product['product_technical_text']))) * 3;
126  }
127  }
128  if ($y1 + $y_block_margin + $h > $y_max && $y1 > ($y_max - $y_top) / 2) {
129  if ($x1 > 100) {
130  // nouvelle page
131  $x1 = 10;
132  $this->AddPage();
133  } else {
134  // nouvelle colonne
135  $x1 = 109;
136  }
137  $y1 = $y_top;
138  }
139 
140  $y1 = $y1 + $y_block_margin;
141 
142  $this->SetFillColor(210, 210, 255);
143  $this->Rect($x1, $y1, $w, 9, 'DF');
144 
145  $this->SetFillColor(255, 255, 255);
146  // $this->Rect($x1, $y1 + 9, $w, min($h-9, $y_max - ($y1 + 9)), 'DF');
147  $this->SetTextColor(0, 0, 0); #Noir*/
148  $this->SetFont("Helvetica", "B", 10);
149  $this->SetXY($x1 + 2, $y1 + 1.5);
150  $this->Cell($w-2, 6, $GLOBALS["STR_ORDER_NAME"].$GLOBALS["STR_BEFORE_TWO_POINTS"].": ".$commande['order_id']." ".$GLOBALS["STR_DATE"].$GLOBALS["STR_BEFORE_TWO_POINTS"].": ".$date_commande);
151 
152  $y1 = $y1 + 11;
153  $this->SetXY($x1 + 2, $y1);
154 
155  $this->SetFont("Helvetica", "B", 8);
156  $this->Cell($w-2, 4, $GLOBALS["STR_SHIP_ADDRESS"].$GLOBALS["STR_BEFORE_TWO_POINTS"].":");
157 
158  $y1 = $y1 + 5;
159  $this->SetXY($x1 + 2, $y1);
160 
161  $this->SetFont("Helvetica", "", 8);
162  foreach(explode("\n", $client) as $this_line) {
163  $this->Cell(0, 3, $this_line);
164  $y1 = $y1 + 3;
165  $this->SetXY($x1 + 2, $y1);
166  }
167 
168  $y1 = $y1 + 2;
169  $this->SetXY($x1 + 2, $y1);
170 
171  $this->SetFont("Helvetica", "B", 8);
172  $this->Cell($w-2, 4, $GLOBALS['STR_LIST_PRODUCT'] . " :");
173  $y1 = $y1 + 4;
174 
175  $this->SetFont("Helvetica", "", 8);
176  if (!empty($product_infos_array)) {
177  $i = 1;
178  foreach ($product_infos_array as $this_ordered_product) {
179  $y1 = $y1 + 2;
180  $this->SetXY($x1 + $x_margin, $y1);
181  $produit_text = $this_ordered_product['product_technical_text'] . " - " . $GLOBALS['STR_QUANTITY_SHORT'] . " : " . $this_ordered_product['quantite'];
182  $this->MultiCell($w-2 * $x_margin, 4, $produit_text . "\n", 0, 'J', false, 1, $x1 + 12);
183 
184  if (!empty($this_ordered_product["produit_id"])) {
185  $product_object = new Product($this_ordered_product["produit_id"]);
186  $main_image = $product_object->get_product_main_picture();
187  if (!empty($main_image)) {
188  $this->Image($GLOBALS['uploaddir'] . '/' . $main_image, $x1 + 3, $y1, 9, 9, '', '', '', true);
189  }
190  unset($product_object);
191  }
192  $y1 = $this->GetY();
193  if ($y1 + 6 > $y_max) {
194  if ($x1 > 100) {
195  // nouvelle page
196  $x1 = 10;
197  $this->AddPage();
198  } else {
199  // nouvelle colonne
200  $x1 = 110;
201  }
202  $y1 = $y_top + $y_block_margin;
203  // On refait le fond
204  $this->SetFillColor(255, 255, 255);
205  // $this->Rect($x1, $y1, $w, 11 + 6 * (count($product_infos_array) - $i), 'DF');
206  $this->SetXY($x1 + $x_margin, $y1 + 1);
207  $this->Cell(0, 4, '... '.$GLOBALS["STR_ADMIN_PICKING_GENERATED_NEW_PAGE_FOR_ORDER"].' ' . $commande['order_id'] . ' ...');
208  $y1 = $y1 + 4;
209  }
210  $i++;
211  }
212  }
213  $k++;
214  }
215  $this->lastPage();
216  $this->Output();
217  }
218 }
219 
static strtoupper($string)
Returns string with all alphabetic characters converted to uppercase.
Definition: String.php:154
Footer()
Pied de page.
Definition: PickingList.php:52
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()
Definition: order.php:1469
SetDrawColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used for all drawing operations (lines, rectangles and cell borders).
Definition: tcpdf.php:4925
get_delivery_status_name($id)
get_delivery_status_name()
Definition: order.php:1088
Output($name='doc.pdf', $dest='I')
Send the document to a given destination: string, local file or browser.
Definition: tcpdf.php:8958
SetY($y, $resetx=true, $rtloff=false)
Moves the current abscissa back to the left margin and sets the ordinate.
Definition: tcpdf.php:8860
AddPage()
Numéro de page.
Definition: PickingList.php:67
$k
Scale factor (number of points in user unit).
Definition: tcpdf.php:233
$w
Current width of page in user unit.
Definition: tcpdf.php:263
Rect($x, $y, $w, $h, $style='', $border_style=array(), $fill_color=array())
Draws a rectangle.
Definition: tcpdf.php:15510
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 ...
Definition: database.php:400
lastPage($resetmargins=false)
Reset pointer to the last document page.
Definition: tcpdf.php:3953
if(empty($_GET['id'])) if(!empty($GLOBALS['site_parameters']['allow_multiple_product_url_with_category'])) $product_object
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).
Definition: tcpdf.php:4942
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...
Definition: tcpdf.php:5946
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.
Definition: fonctions.php:4643
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.
Definition: database.php:158
SetFont($family, $style='', $size=null, $fontfile='', $subset='default', $out=true)
Sets the font used to print character strings.
Definition: tcpdf.php:5384
SetTextColor($col1=0, $col2=-1, $col3=-1, $col4=-1, $ret=false, $name='')
Defines the color used for text.
Definition: tcpdf.php:4959
$h
Current height of page in user unit.
Definition: tcpdf.php:269
FillDocument($dateAdded1, $dateAdded2, $statut)
PickingList::FillDocument()
Definition: PickingList.php:89
Ln($h='', $cell=false)
Performs a line break.
Definition: tcpdf.php:8752
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.
Definition: tcpdf.php:7915
AddPage($orientation='', $format='', $keepmargins=false, $tocpage=false)
Adds a new page to the document.
Definition: tcpdf.php:4013
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
PageNo()
Returns the current page number.
Definition: tcpdf.php:4591
get_formatted_date($datetime_or_timestamp=null, $mode= 'short', $hour_minute=false)
Afficher une date formatée, en évitant les problèmes liés aux noms de mois sur les serveurs qui ne so...
Definition: format.php:440
AliasNbPages($s='')
This method is DEPRECATED and doesn't have any effect.
Definition: tcpdf.php:18466
GetY()
Returns the ordinate of the current position.
Definition: tcpdf.php:8814
$GLOBALS['page_columns_count']
Header()
En-tête.
Definition: PickingList.php:35
getAliasNbPages()
Returns the string alias used for the total number of pages.
Definition: tcpdf.php:18515
SetXY($x, $y, $rtloff=false)
Defines the abscissa and ordinate of the current position.
Definition: tcpdf.php:8893
get_order_infos_array($order_object)
get_order_infos_array()
Definition: order.php:1320
$id
Definition: articles.php:22
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.
Definition: tcpdf.php:6709
PHP class for generating PDF documents without requiring external extensions.
Definition: tcpdf.php:157
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:30:05 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.