PEEL Shopping
Open source ecommerce : PEEL Shopping
fonctions.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: fonctions.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 
25  // On ajoute au prix les attributs à options uniques, puisque ces attributs ne seront pas sélectionnables par ailleurs (car rien à sélectionner)
26  $price_calculation = affiche_attributs_form_part($params['this'], 'price_calculation', null, null, null, null, null, check_if_module_active('reseller') && is_reseller(), false, false, true);
27  $params['this']->prix_ht += vn($GLOBALS['last_calculation_additional_price_ht']);
28 }
29 
37  if ($params['this']->configuration_attributs_list !== $params['attributs_list']) {
38  // Initialisation
39  $params['this']->configuration_attributs_list = $params['attributs_list'];
40  $params['this']->configuration_total_original_price_attributs_ht = 0;
41  $params['this']->configuration_attributs_description = "";
42  // Traitement des attributs
43  if (!empty($params['attributs_list'])) {
44  $params['this']->configuration_attributs_description = affiche_attributs_form_part($params['this'], 'selected_text', null, null, null, null, null, $params['reseller_mode']);
45  $params['this']->configuration_total_original_price_attributs_ht = vn($GLOBALS['last_calculation_additional_price_ht']);
46  }
47  }
48 }
49 
57  return get_product_options($params['id_or_technical_code'], $params['lang'], $params['return_mode']);
58 }
59 
70 function get_possible_attributs($product_id = null, $return_mode = 'rough', $get_attributes_with_multiple_options_only = true, $get_attributes_with_single_options_only = false, $attributs_list = null)
71 {
72  static $possible_attributs;
73  $attributs_array = array();
74  // $attributs_list permet de sélectionner uniquement certains attributs et leurs options
75  // Ceci évite notamment dans certains cas de récupérer des informations inutiles
76  if(!empty($attributs_list)) {
77  $attributs_list_array = explode('§', $attributs_list);
78  foreach($attributs_list_array as $this_attributs_list) {
79  $this_attributs_list_array = explode("|", $this_attributs_list);
80  if(isset($this_attributs_list_array[1])) {
81  // On récupère l'id de l'option sélectionnée si format est attribut_id|option_id, ou le texte si le format est attribut_id|0|texte
82  $attribut_and_options_filter_array[$this_attributs_list_array[0]][$this_attributs_list_array[1]] = end($this_attributs_list_array);
83  if(empty($this_attributs_list_array[1])) {
84  $sql_cond_array[] = 'na.id="'.intval($this_attributs_list_array[0]).'"';
85  } else {
86  $sql_cond_array[] = '(na.id="'.intval($this_attributs_list_array[0]).'" AND a.id="'.intval($this_attributs_list_array[1]).'")';
87  }
88  }
89  }
90  }
91  if(empty($sql_cond_array) && ($attributs_list === '' || !empty($attributs_list))) {
92  // On veut les attributs possibles correspondant à une liste vide
93  $sql_cond_array[] = '0';
94  }
95  if (!isset($possible_attributs[$product_id . '-' . $_SESSION['session_langue'] . '-' . $attributs_list])) {
96  $possible_attributs[$product_id . '-' . $_SESSION['session_langue'] . '-' . $attributs_list] = array();
97  // Les attributs possibles d'un produit (ex : parfum) sont énumérés dans la table peel_nom_attributs
98  // Pour chacun des attributs, il y a diverses options possibles qui sont stockées dans peel_attributs
99  // Dans le cas d'attributs upload ou texte_libre, aucune option n'est associée => LEFT JOIN peel_attributs et non pas INNER JOIN
100  if(!empty($product_id)) {
101  // Pour un produit donné, on peut associer les attributs que l'on veut, et également spécifier les options acceptables de ces attributs pour ce produit en particulier
102  // Il ne faut donc pas faire de jointure entre peel_attributs et peel_nom_attributs, mais passer par peel_produits_attributs pour faire les deux jointures indépendemment. Il faut dans ce cas prendre l'id de l'attribut dans peel_produits_attributs et pas dans peel_attributs par cohérence, et résoud un problème dans le cas d'attribut fictif (paramètre attribut_fictive_options_functions_by_technical_codes_array)
103  $sql_select = 'pa.attribut_id';
104  $sql_from_and_where = "FROM peel_produits_attributs pa
105  LEFT JOIN peel_attributs a ON a.id = pa.attribut_id AND " . get_filter_site_cond('attributs', 'a') . "
106  INNER JOIN peel_nom_attributs na ON na.id = pa.nom_attribut_id AND na.etat = '1' AND " . get_filter_site_cond('nom_attributs', 'na') . "
107  WHERE pa.produit_id = '" . intval($product_id) . "'";
108  } else {
109  $sql_select = 'a.id AS attribut_id';
110  $sql_from_and_where = "FROM peel_nom_attributs na
111  LEFT JOIN peel_attributs a ON a.id_nom_attribut=na.id AND " . get_filter_site_cond('attributs', 'a') . "
112  WHERE na.etat = '1' AND " . get_filter_site_cond('nom_attributs', 'na');
113  }
114  if(!empty($sql_cond_array)) {
115  $sql_from_and_where .= " AND (".implode(' OR ', $sql_cond_array).")";
116  }
117  $sql = "SELECT ".$sql_select." , na.id AS nom_attribut_id, na.nom_" . $_SESSION['session_langue'] . " AS nom, na.technical_code, na.type_affichage_attribut, na.mandatory, na.texte_libre, na.upload, na.show_description, a.descriptif_" . $_SESSION['session_langue'] . " AS descriptif, a.prix, a.prix_revendeur
118  ".$sql_from_and_where."
119  ORDER BY IF(a.position IS NULL,9999999,a.position) ASC, a.descriptif_" . $_SESSION['session_langue'] . " ASC, na.nom_" . $_SESSION['session_langue'] . " ASC";
120  $query = query($sql);
121  while ($result = fetch_assoc($query)) {
122  if ($result['type_affichage_attribut'] == 3) {
123  // On prend la valeur générale du site
124  $result['type_affichage_attribut'] = $GLOBALS['site_parameters']['type_affichage_attribut'];
125  }
126  $result['descriptif'] = String::str_shorten_words($result['descriptif'], 50, " [...] ", false, false);
127  $possible_attributs[$product_id . '-' . $_SESSION['session_langue'] . '-' . $attributs_list][] = $result;
128  }
129  }
130 
131  if (!empty($possible_attributs)) {
132  foreach($possible_attributs[$product_id . '-' . $_SESSION['session_langue'] . '-' . $attributs_list] as $result) {
133  // Si l'attribut n'a pas d'option, $result['attribut_id'] vaut NULL => on applique vn() pour obtenir 0
134  $attributs_array[intval($result['nom_attribut_id'])][intval(vn($result['attribut_id']))] = $result;
135  }
136  foreach ($attributs_array as $this_nom_attribut_id => $this_attribut_values_array) {
137  if (!empty($this_attribut_values_array[0]) && count($this_attribut_values_array)==1) {
138  if (!empty($GLOBALS['site_parameters']['attribut_fictive_options_functions_by_technical_codes_array']) && !empty($GLOBALS['site_parameters']['attribut_fictive_options_functions_by_technical_codes_array'][$this_attribut_values_array[0]['technical_code']]) && function_exists($GLOBALS['site_parameters']['attribut_fictive_options_functions_by_technical_codes_array'][$this_attribut_values_array[0]['technical_code']])) {
139  // DEBUT de gestion d'attributs avec options fictives, n'utilisant pas peel_attributs pour les options mais d'autres sources d'information
140  $this_function = $GLOBALS['site_parameters']['attribut_fictive_options_functions_by_technical_codes_array'][$this_attribut_values_array[0]['technical_code']];
141  // La fonction doit avoir un seul argument, qui est la liste des options filtrées
142  if(!empty($attribut_and_options_filter_array[$this_nom_attribut_id])) {
143  // Valeur sélectionnée => format du type texte_libre
144  $fictive_options_array = $this_function($attribut_and_options_filter_array[$this_nom_attribut_id]);
145  } else {
146  // Pas de valeur sélectionnée => format du type liste d'options
147  $fictive_options_array = $this_function();
148  }
149  // Les options fictives peuvent être du texte_libre ou non :
150  // Si c'est texte_libre, c'est une notion de stockage par la suite du texte choisi, sous forme d'id 0
151  // Mais dans le tableau des options on fait apparaitre l'id de l'option fictive dans tous les cas
152  // On remplit le contenu de l'attribut pour la liste des options
153 
154  foreach($fictive_options_array as $this_id => $this_fictive_options) {
155  if (empty($product_id) || (!empty($attributs_array[$this_nom_attribut_id][$this_id]['descriptif']) && $attributs_array[$this_nom_attribut_id][$this_id]['descriptif'] == $this_fictive_options )) {
156  // Si empty($product_id) on veux tous les attributs possibles pour le produit, sinon on prend ce qui est associé au produit.
157  $attributs_array[$this_nom_attribut_id][$this_id] = $attributs_array[$this_nom_attribut_id][0];
158  $attributs_array[$this_nom_attribut_id][$this_id]['descriptif'] = $this_fictive_options;
159  // L'id de l'attribut dans ce cas est l'id qui est généré par la fonction de attribut_fictive_options_functions_by_technical_codes_array.
160  $attributs_array[$this_nom_attribut_id][$this_id]['attribut_id'] = $this_id;
161  }
162  }
163  if ($this_attribut_values_array[0]['type_affichage_attribut'] == 1) {
164  unset($attributs_array[$this_nom_attribut_id][0]);
165  }
166  foreach ($attributs_array[$this_nom_attribut_id] as $this_attribut_id => $this_attribut_values) {
167  // Ici on supprime les attributs qui ont un ID à NULL, qu'il faut supprimer de la liste. Les ids NULL sont créées par la requête SQL de sélection d'attribut
168  if($this_attribut_values['attribut_id'] === NULL) {
169  unset($attributs_array[$this_nom_attribut_id][$this_attribut_id]);
170  }
171  }
172  // FIN de gestion d'attributs avec options fictives
173  }
174  if(!empty($attribut_and_options_filter_array) && !empty($attribut_and_options_filter_array[$this_nom_attribut_id]) && !empty($attribut_and_options_filter_array[$this_nom_attribut_id][key($this_attribut_values_array)])) {
175  $attributs_array[$this_nom_attribut_id][key($this_attribut_values_array)]['descriptif'] = $attribut_and_options_filter_array[$this_nom_attribut_id][key($this_attribut_values_array)];
176  if(String::strpos($attributs_array[$this_nom_attribut_id][key($this_attribut_values_array)]['technical_code'], 'date') === 0) {
177  $attributs_array[$this_nom_attribut_id][key($this_attribut_values_array)]['descriptif'] = get_formatted_date($attributs_array[$this_nom_attribut_id][key($this_attribut_values_array)]['descriptif']);
178  }
179  }
180  }
181  }
182  if($get_attributes_with_multiple_options_only || $get_attributes_with_single_options_only) {
183  // On retire les attributs qui ne respectent pas les conditions : unique ou multiple
184  foreach($attributs_array as $this_attribute => $this_options_array) {
185  if($get_attributes_with_multiple_options_only && (count($this_options_array)<=1 && $this_options_array[key($this_options_array)]['type_affichage_attribut']!=2)) {
186  // Cet attribut n'est pas une checkbox et a strictement moins de 2 valeurs
187  if(empty($attributs_list) && key($this_options_array) && empty($this_options_array[key($this_options_array)]['texte_libre']) && empty($this_options_array[key($this_options_array)]['upload'])) {
188  // attribut_id est différent de 0 et ce n'est pas un attribut avec options fictives
189  // => il s'agit bien d'une option qu'on peut afficher dans la description produit
190  unset($attributs_array[$this_attribute]);
191  }
192  } elseif($get_attributes_with_single_options_only && (count($this_options_array)>1 || $this_options_array[key($this_options_array)]['type_affichage_attribut']==2)) {
193  unset($attributs_array[$this_attribute]);
194  }
195  }
196  }
197  if ($return_mode == 'option_name' || $return_mode == 'full_name') {
198  // On renvoie les noms et non pas les informations plus complètes
199  foreach ($attributs_array as $this_nom_attribut_id => $this_attribut_values_array) {
200  foreach ($this_attribut_values_array as $this_attribut_id => $this_attribut_infos) {
201  $this_name_parts = array();
202  if($return_mode == 'full_name') {
203  $this_name_parts[] = $this_attribut_infos['name'];
204  }
205  if(!empty($this_attribut_infos['description'])) {
206  $this_name_parts[] = $this_attribut_infos['description'];
207  }
208  $attributs_array[$this_nom_attribut_id][$this_attribut_id] = implode(' - ', $this_name_parts);
209  }
210  }
211  }
212  }
213  return $attributs_array;
214 }
215 
232 function affiche_attributs_form_part(&$product_object, $display_mode = 'table', $save_cart_id = null, $save_suffix_id = null, $form_id = null, $technical_code_array = null, $excluded_technical_code_array = null, $force_reseller_mode = null, $get_attributes_with_multiple_options_only = true, $filter_using_show_description = false, $get_attributes_with_single_options_only = false, $update_last_calculation_additional_price_ht = true)
233 {
234  $output = '';
235  $GLOBALS['last_calculation_additional_price_ht'] = 0;
236  // On récupère éventuellement les attributs sauvegardés qui devront être présélectionnés
237  $attributs_list_array = explode('§', vb($product_object->configuration_attributs_list));
238  foreach($attributs_list_array as $this_attributs_list) {
239  $this_attributs_list_array = explode("|", $this_attributs_list);
240  // On récupère l'id de l'option sélectionnée si format est attribut_id|option_id, ou le texte si le format est attribut_id|0|texte
241  $attribut_preselect_infos[intval($this_attributs_list_array[0])] = end($this_attributs_list_array);
242  }
243  if (empty($technical_code_array) && $display_mode != 'selected_text' && !empty($GLOBALS['site_parameters']['affiche_attributs_form_part_function_by_product_technical_codes_array']) && !empty($GLOBALS['site_parameters']['affiche_attributs_form_part_function_by_product_technical_codes_array'][$product_object->technical_code]) && function_exists($GLOBALS['site_parameters']['affiche_attributs_form_part_function_by_product_technical_codes_array'][$product_object->technical_code])) {
244  // Cas spécifique des formulaires d'attributs générés par des fonctions spécifiques (développements spécifiques pour un site précis)
245  $this_function = $GLOBALS['site_parameters']['affiche_attributs_form_part_function_by_product_technical_codes_array'][$product_object->technical_code];
246  $output .= $this_function($product_object, $save_cart_id, $save_suffix_id, $form_id);
247  return $output;
248  }
249  // On récupère la liste des attributs qui n'offrent pas juste un choix (auquel cas, ils sont gérés par Product, et ils doivent apparaitre comme partie intégrante de la description d'un produit)
250  // L'ajout à la description est par ailleurs gérée dans la classe Product
251  $attributs_array = $product_object->get_possible_attributs('rough', ($display_mode == 'selected_text'), 0, true, false, false, false, $get_attributes_with_multiple_options_only, $get_attributes_with_single_options_only);
252 
253  if (!empty($attributs_array)) {
254  // On affiche la liste des attributs
255  foreach ($attributs_array as $this_nom_attribut_id => $this_attribut_values_array) {
256  $j = 0;
257  $attribut_text = '';
258  $input_id = '';
259  $input_value = '';
260  $input_type = '';
261  $input_name = '';
262  $input_class = '';
263  $input_on_change = '';
264  $options = array();
265  $max_label_length=0;
266  $preselected_value = vb($attribut_preselect_infos[$this_nom_attribut_id]);
267  unset($type_affichage_attribut);
268  $attribut_additional_price_ttc = 0;
269  foreach ($this_attribut_values_array as $this_attribut_id => $this_attribut_infos) {
270  if (!empty($technical_code_array) && !in_array($this_attribut_infos['technical_code'], $technical_code_array)) {
271  break;
272  }
273  if (!empty($excluded_technical_code_array) && in_array($this_attribut_infos['technical_code'], $excluded_technical_code_array)) {
274  break;
275  }
276  if($force_reseller_mode!==null) {
277  $reseller_mode = $force_reseller_mode;
278  } else {
279  $reseller_mode = (check_if_module_active('reseller') && is_reseller());
280  }
281  $show_additionnal_price = true;
282  if(!empty($GLOBALS['site_parameters']['attribut_decreasing_prices_per_technical_code']) && !empty($GLOBALS['site_parameters']['attribut_decreasing_prices_per_technical_code'][$this_attribut_infos['technical_code']])) {
283  $prices_list_by_elements_count = explode(',',$GLOBALS['site_parameters']['attribut_decreasing_prices_per_technical_code'][$this_attribut_infos['technical_code']]);
284  $additional_price_ttc = (isset($prices_list_by_elements_count[$j])?$prices_list_by_elements_count[$j]:$prices_list_by_elements_count[0]) - $attribut_additional_price_ttc;
285  $show_additionnal_price = false;
286  } elseif ($reseller_mode && $this_attribut_infos['prix_revendeur'] != 0) {
287  $additional_price_ttc = vn($this_attribut_infos['prix_revendeur']);
288  } else {
289  $additional_price_ttc = vn($this_attribut_infos['prix']);
290  }
291  if ($reseller_mode && isset($GLOBALS['site_parameters']['attribut_prix_revendeur'][$this_nom_attribut_id])) {
292  $additional_price_ttc += $GLOBALS['site_parameters']['attribut_prix_revendeur'][$this_nom_attribut_id];
293  } elseif(isset($GLOBALS['site_parameters']['attribut_prix'][$this_nom_attribut_id])) {
294  $additional_price_ttc += $GLOBALS['site_parameters']['attribut_prix'][$this_nom_attribut_id];
295  }
296  $attribut_additional_price_ttc += $additional_price_ttc;
297  $additional_price_ht = $additional_price_ttc / (1 + $product_object->tva / 100);
298  // On garde en mémoire le calcul pour utilisation potentielle après exécution de cette fonction
299  if (!empty($update_last_calculation_additional_price_ht)) {
300  $GLOBALS['last_calculation_additional_price_ht'] += $additional_price_ht;
301  }
302  if ($additional_price_ttc != 0 && $show_additionnal_price) {
303  $final_additional_price_ht = $additional_price_ht * (1 - $product_object->get_all_promotions_percentage($reseller_mode, get_current_user_promotion_percentage(), false) / 100);
304  $price_text = $GLOBALS['STR_BEFORE_TWO_POINTS'] . ': ' . ($additional_price_ttc > 0?'+':'') . $product_object->format_prices($final_additional_price_ht, display_prices_with_taxes_active(), false, true, true);
305  } else {
306  $price_text = '';
307  }
308  if($filter_using_show_description && empty($this_attribut_infos['show_description'])) {
309  // L'attribut ne doit pas avoir son texte affiché dans la description récapitulative
310  $j++;
311  continue;
312  }
313  if ($this_attribut_infos['type_affichage_attribut'] == 3) {
314  // L'administrateur choisit la configuration générale du site pour l'affichage de ce paramètre.
315  $type_affichage_attribut = $GLOBALS['site_parameters']['type_affichage_attribut'];
316  } else {
317  $type_affichage_attribut = $this_attribut_infos['type_affichage_attribut'];
318  }
319  if (!empty($this_attribut_infos['upload']) && empty($this_attribut_id)) {
320  // cas des attributs d'upload d'image
321  if($display_mode == 'selected_text') {
322  $input_value = $preselected_value;
323  } else {
324  $type_affichage_attribut = 'upload';
325  $input_name = 'attribut' . $this_nom_attribut_id . '_upload';
326  $input_id = $form_id . '_custom_attribut' . $this_nom_attribut_id;
327  if (empty($_SESSION["session_display_popup"][$input_name]) && preg_match('`' . $GLOBALS['site_parameters']['uploaded_images_name_pattern'] . '`' , $preselected_value)) {
328  // Si pas déjà image téléchargée en cours et qu'on a passé une image dans attributs_list, on vérifie qu'elle semble avec nom cohérent, et on la prend
329  $_SESSION["session_display_popup"][$input_name] = $preselected_value;
330  }
331  if (!empty($_SESSION["session_display_popup"][$input_name])) {
332  // si l'image existe déjà, alors on l'affiche tout simplement (avec la possibilité de la supprimer)
333  $attribut_text .= display_option_image($_SESSION["session_display_popup"][$input_name]);
334  } else {
335  // On ne passe pas de nom d'image dans le formulaire par sécurité
336  $input_type = 'file';
337  }
338  }
339  } elseif (!empty($this_attribut_infos['texte_libre']) && empty($this_attribut_id)) {
340  // Le test sur empty($this_attribut_id) permet de savoir qu'on est dans un texte_libre "normal", sans options fictives qui tirent N valeurs de la base de données
341  $type_affichage_attribut = 'texte_libre';
342  $input_id = $form_id . '_custom_attribut' . $this_nom_attribut_id;
343  $input_name = 'attribut' . $this_nom_attribut_id . '_texte_libre';
344  $input_type = 'text';
345  $input_value = $preselected_value;
346  if(String::strpos($this_attribut_infos['technical_code'], 'date') === 0) {
347  $input_class = 'datepicker';
348  }
349  } else {
350  if(!empty($this_attribut_infos['texte_libre'])) {
351  // Cas d'options fictives
352  $this_value = String::html_entity_decode_if_needed($this_attribut_infos['descriptif']);
353  $input_name = 'attribut' . $this_nom_attribut_id . '_texte_libre';
354  } else {
355  $this_value = $this_nom_attribut_id . '|' . $this_attribut_id;
356  }
357  if ($type_affichage_attribut == 0) {
358  // Affichage sous forme de select
359  if(empty($input_name)) {
360  $input_name = 'attribut' . $this_nom_attribut_id;
361  }
362  $input_id = $form_id . '_custom_attribut' . $this_nom_attribut_id;
363  $input_type = 'select';
364  $options[] = array(
365  'value' => $this_value,
366  'text' => String::html_entity_decode_if_needed($this_attribut_infos['descriptif']) . $price_text,
367  'issel' => in_array($this_value, $attributs_list_array)
368  );
369  } elseif ($type_affichage_attribut == 1) {
370  // Affichage sous forme de boutons radio
371  if(empty($input_name)) {
372  $input_name = 'attribut' . $this_nom_attribut_id;
373  }
374  $input_type = 'radio';
375  $options[] = array(
376  'value' => $this_value,
377  'name' => $input_name,
378  'id' => $form_id . '_custom_attribut' . $this_nom_attribut_id . '-' . $j,
379  'issel' => !empty($attributs_list_array) && in_array($this_value, $attributs_list_array),
380  'text' => String::html_entity_decode_if_needed($this_attribut_infos['descriptif']) . $price_text,
381  'onclick' => $input_on_change.' update_product_price' . $save_suffix_id . '();'
382  );
383  } elseif ($type_affichage_attribut == 2) {
384  // Affichage sous forme de checkbox
385  $input_type = 'checkbox';
386  $options[] = array(
387  'value' => $this_value,
388  'name' => 'attribut' . $this_nom_attribut_id . '-' . $j,
389  'id' => $form_id . '_custom_attribut' . $this_nom_attribut_id . '-' . $j,
390  'issel' => !empty($attributs_list_array) && in_array($this_value, $attributs_list_array),
391  'text' => String::html_entity_decode_if_needed($this_attribut_infos['descriptif']) . $price_text,
392  'onclick' => $input_on_change.' update_product_price' . $save_suffix_id . '();'
393  );
394  } elseif ($type_affichage_attribut == 4) {
395  // Affichage sous forme de lien
396  $input_type = 'link';
397  $options[] = array(
398  'value' => $this_attribut_id,
399  'name' => 'custom_attribut[' . $this_nom_attribut_id . ']',
400  'text' => String::html_entity_decode_if_needed($this_attribut_infos['descriptif'])
401  );
402  }
403  $max_label_length = max($max_label_length, String::strlen(String::html_entity_decode_if_needed(vb($this_attribut_infos['descriptif']))));
404  }
405  $j++;
406  }
407  if(isset($type_affichage_attribut)) {
408  $attributes_text_array[] = array(
409  'text' => $attribut_text,
410  'technical_code' => $this_attribut_infos['technical_code'],
411  'name' => String::html_entity_decode_if_needed($this_attribut_infos['nom']).(!empty($this_attribut_infos['mandatory']) && $display_mode != 'selected_text'?' *':''),
412  'type_affichage_attribut' => $type_affichage_attribut,
413  'input_id' => $input_id,
414  'input_name' => $input_name,
415  'input_value' => $input_value,
416  'input_type' => $input_type,
417  'input_class' => $input_class,
418  'options' => $options,
419  'max_label_length' => $max_label_length,
420  'onchange' => $input_on_change . ' update_product_price' . $save_suffix_id . '();'
421  );
422  }
423  }
424  }
425  if(!empty($attributes_text_array)) {
426  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/attributs_form_part.tpl');
427  $tpl->assign('STR_MODULE_ATTRIBUTS_OPTIONS_ATTRIBUTS', $GLOBALS['STR_MODULE_ATTRIBUTS_OPTIONS_ATTRIBUTS']);
428  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
429  $tpl->assign('attributes_text_array', $attributes_text_array);
430  $tpl->assign('display_mode', $display_mode);
431  $tpl->assign('input_name', $input_name);
432  $tpl->assign('input_id', $input_id);
433  $tpl->assign('input_type', $input_type);
434  $tpl->assign('input_on_change', $input_on_change);
435  $tpl->assign('technical_code', $product_object->technical_code);
436  // Dans le cas où on veut le résultat en mode texte, il faut retirer les sauts de ligne et tabulations => on applique trim()
437  $output .= trim(str_replace(array("\r\n", "\r", "\n", "\t"), ' ', $tpl->fetch()));
438  }
439  return $output;
440 }
441 
449 function display_option_image($str_image, $set = false)
450 {
451  $output = '';
452  if ($set) {
453  // si $str_image est un texte contenant éventuellement des images
454  $inital_text = $str_image;
455  $option_tab = explode("{{", $str_image);
456  if (count($option_tab) > 1) {
457  // s'il ya au moins une image
458  foreach ($option_tab as $str_img) {
459  if (($end_str = String::strpos($str_img, "}}")) !== false) {
460  $str_img = String::substr($str_img, 0, $end_str);
461  if (get_file_type($str_img) == 'pdf') {
462  $small_option_image = get_url('/images/logoPDF_small.png');
463  $is_pdf = true;
464  } else {
465  $small_option_image = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($str_img, 0, 25, 'fit');
466  $is_pdf = false;
467  }
468  $str_img_new = $GLOBALS['tplEngine']->createTemplate('modules/attributs_option_image.tpl', array(
469  'set' => true,
470  'href' => $GLOBALS['repertoire_upload'] . '/' . $str_img,
471  'src' => $small_option_image,
472  'is_pdf' => $is_pdf
473  ))->fetch();
474  $str_image = str_replace('{{' . $str_img . '}}', $str_img_new, $str_image);
475  }
476  }
477  }
478  $output .= $str_image;
479  } else {
480  $small_option_image = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($str_image, 0, 25, 'fit');
481  $output .= $GLOBALS['tplEngine']->createTemplate('modules/attributs_option_image.tpl', array(
482  'set' => false,
483  'href' => $GLOBALS['repertoire_upload'] . '/' . $str_image,
484  'src' => $small_option_image
485  ))->fetch();
486  }
487  return $output;
488 }
489 
498 function get_all_option_combinations(&$attributs_infos_array, $option_values_array = array(''), $get_agregated_attributs_values = true)
499 {
500  $option_values_array_tmp = $option_values_array;
501  if(!empty($attributs_infos_array)) {
502  $this_nom_attribut_id = key($attributs_infos_array);
503  if($get_agregated_attributs_values) {
504  // On veut la liste de toutes les combinaisons possibles attribut_id|attribut_option_id§attribut2_id|attribut_option_id§... sous forme de tableau complet
505  // Le nombre de résultats augmente de manière exponentielle avec le nombre d'attributs => Attention !
506  $option_values_array_tmp = array();
507  foreach ($option_values_array as $option_value) {
508  foreach ($attributs_infos_array[$this_nom_attribut_id] as $this_attribut_id => $this_attribut_infos) {
509  $option_values_array_tmp[] = (!empty($option_value)? $option_value . '§':'') . $this_nom_attribut_id . '|' . $this_attribut_id;
510  }
511  }
512  } else {
513  // On veut juste la liste de toutes les combinaisons simples attribut_id|attribut_option_id sous forme de tableau complet
514  // Le nombre de résultats augmente de manière linéaire avec le nombre d'attributs => pas de problème
515  foreach ($attributs_infos_array[$this_nom_attribut_id] as $this_attribut_id => $this_attribut_infos) {
516  $option_values_array_tmp[] = $this_nom_attribut_id . '|' . $this_attribut_id;
517  }
518  }
519  $next_attributs_infos_array = $attributs_infos_array;
520  unset($next_attributs_infos_array[$this_nom_attribut_id]);
521  }
522  if(!empty($next_attributs_infos_array)) {
523  // On appelle récursivement pour construire la liste
524  return get_all_option_combinations($attributs_infos_array, $option_values_array_tmp, $attributs_infos_array_keys);
525  } else {
526  return array_unique($option_values_array_tmp);
527  }
528 }
529 
537 function get_option_combination_name_from_value($attributs_infos_array, $combinaison_option_value)
538 {
539  $combinaison_option_name_parts = array();
540  $option_value_array_tmp = explode('§', $combinaison_option_value);
541  foreach ($option_value_array_tmp as $option_value) {
542  $value_array = explode('|', $option_value);
543  $combinaison_option_name_parts[] = $attributs_infos_array[$value_array[0]][$value_array[1]]['descriptif'];
544  }
545  return implode(' - ', $combinaison_option_name_parts);
546 }
547 
556 function build_attr_var_js($attr_var_name, $attributs_infos_array, $form_id)
557 {
558  $attributs_infos_array_count = count($attributs_infos_array);
559  $output = '' . $attr_var_name . '="";
560 ';
561  foreach($attributs_infos_array as $this_nom_attribut_id => $this_attributs_array_infos) {
562  $this_attributs_infos = current($this_attributs_array_infos);
563  if(empty($this_attributs_infos['attribut_id'])) {
564  // Champ texte libre ou upload, sans options à choisir
565  continue;
566  }
567  // type_affichage_attribut vaut 0, 1 ou 2 et jamais 3. En effet 3 est une configuration par produit pour dire : prendre la valeur générale du site, et est déjà remplacé par la vraie valeur retenue qui est <=2.
568  if ($this_attributs_infos['type_affichage_attribut'] == 0) {
569  // Affichage sous forme de select
570  $output .= '
571  ' . $attr_var_name . '+= "§"+document.getElementById("' . $form_id . '_custom_attribut' . $this_nom_attribut_id . '").options[document.getElementById("' . $form_id . '_custom_attribut' . $this_nom_attribut_id . '").selectedIndex].value;';
572  } elseif ($this_attributs_infos['type_affichage_attribut'] == 1) {
573  // Affichage sous forme de boutons radio
574  $output .= '
575  radio = document.getElementById("' . $form_id . '").attribut' . $this_nom_attribut_id . ';
576  for (var i=0; radio && i<radio.length;i++) {
577  if (radio[i].checked) {
578  ' . $attr_var_name . '+= "§"+radio[i].value;
579  break;
580  }
581  }';
582  } elseif ($this_attributs_infos['type_affichage_attribut'] == 2) {
583  // Affichage sous forme de checkbox
584  $output .= '
585  for (var i=0; document.getElementById("' . $form_id . '_custom_attribut' . $this_nom_attribut_id . '-"+i);i++) {
586  checkbox = document.getElementById("' . $form_id . '_custom_attribut' . $this_nom_attribut_id . '-"+i);
587  if (checkbox.checked) {
588  ' . $attr_var_name . '+= "§"+checkbox.value;
589  }
590  }
591 ';
592  }
593  }
594  return $output;
595 }
596 
606 function get_attribut_list_from_post_data(&$product_object, &$frm, $keep_free_attributs_only = false, $keep_costly_attributs_only = false)
607 {
608  $reseller_mode = check_if_module_active('reseller') && is_reseller();
609  $combinaisons_array = array();
610  foreach(array_keys($_FILES) as $this_key) {
611  if(!isset($frm[$this_key]) && String::strpos($this_key, 'attribut') === 0) {
612  $frm[$this_key] = upload($this_key, false, 'image', $GLOBALS['site_parameters']['image_max_width'], $GLOBALS['site_parameters']['image_max_height'], null, null, vb($frm[$this_key]));
613  if(!empty($_FILES[$this_key]['name']) && $frm[$this_key] === false) {
614  // on signale que l'image n'a pas été chargée correctement
615  $_SESSION["session_display_popup"][$this_key] = false;
616  // Préparation d'un message d'erreur
617  $tpl = $GLOBALS['tplEngine']->createTemplate('image_upload_error_option.tpl');
618  $tpl->assign('STR_PICTURE', $GLOBALS['STR_PICTURE']);
619  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
620  $tpl->assign('STR_NO_UPLOADED', $GLOBALS['STR_NO_UPLOADED']);
621  $tpl->assign('picture_size_extention_error_txt', sprintf($GLOBALS['STR_PICTURE_SIZE_EXTENTION_ERROR'], implode(",", $GLOBALS['site_parameters']['extensions_valides_image']), $GLOBALS['site_parameters']['uploaded_file_max_size'] / 1024));
622  $tpl_labels = array();
623  foreach ($_SESSION["session_display_popup"] as $label => $error) {
624  if ($error === false) {
625  $tpl_labels[] = $label;
626  }
627  }
628  $tpl->assign('labels', $tpl_labels);
629  $_SESSION["session_display_popup"]["upload_error_text"] = $tpl->fetch();
630  } elseif(!empty($frm[$this_key])) {
631  // Nom de l'image mise en doubles accolades pour être facilement détecté dans l'administration
632  $frm[$this_key] = '{{' . $frm[$this_key] . '}}';
633  }
634  }
635  }
636  if(!empty($frm) && is_object($product_object)) {
637  // On charge les informations de base de données relative aux attributs choisis par l'utilisateur
638  // On va ainsi pouvoir vérifier que ces attributs sont bien possibles, et par ailleurs que ceux obligatoires sont bien remplis
639  $attributs_array = $product_object->get_possible_attributs('rough', false, 0, true, false, false, false, false, false, null);
640  if (!empty($attributs_array)) {
641  // On affiche la liste des attributs
642  foreach ($attributs_array as $this_nom_attribut_id => $this_attribut_values_array) {
643  foreach ($this_attribut_values_array as $this_attribut_id => $this_attribut_infos) {
644  $attributs_infos = $attributs_array[$this_nom_attribut_id][$this_attribut_id];
645  if (intval($attributs_infos['mandatory']) == 1) {
646  // Attributs obligatoires : on prépare une liste, et on va retirer tout ce qui est valide ensuite
647  // Pour les checkbox et les boutons radio, il n'y aura rien d'envoyé dans le formulaire si pas de sélection utilisateur
648  // Il est donc nécessaire de faire la liste exhaustive des attributs obligatoires, indépendamment du formulaire
649  $GLOBALS['error_attribut_mandatory'][$this_nom_attribut_id] = $attributs_infos['nom'];
650  }
651  }
652  }
653  }
654  if(!empty($frm['attributs_list'])){
655  $attributs_list_array = explode('§', $frm['attributs_list']);
656  foreach($attributs_list_array as $this_attributs_list) {
657  $this_attributs_list_array = explode("|", $this_attributs_list);
658  $this_nom_attribut_id = $this_attributs_list_array[0];
659  $this_attribut_id = $this_attributs_list_array[1];
660  if(isset($attributs_array[$this_nom_attribut_id][$this_attribut_id])) {
661  unset($GLOBALS['error_attribut_mandatory'][$this_nom_attribut_id]);
662  $attributs_infos = $attributs_array[$this_nom_attribut_id][$this_attribut_id];
663  if(!empty($GLOBALS['site_parameters']['attribut_decreasing_prices_per_technical_code']) && !empty($GLOBALS['site_parameters']['attribut_decreasing_prices_per_technical_code'][$attributs_infos['technical_code']])) {
664  $costly = true;
665  } elseif (($reseller_mode && floatval($attributs_infos["prix_revendeur"]) > 0) || floatval($attributs_infos["prix"]) > 0) {
666  $costly = true;
667  } else {
668  $costly = false;
669  }
670  if(($keep_free_attributs_only && $costly) || ($keep_costly_attributs_only && !$costly)) {
671  continue;
672  }
673  }
674  //if(isset($attributs_array[$this_nom_attribut_id][$this_attribut_id]) || (!empty($attributs_array[$this_nom_attribut_id]) && empty($this_attribut_id))) {
675  $combinaisons_array[] = $this_attributs_list;
676  //}
677  }
678  }
679  foreach($frm as $this_key => $this_value) {
680  if (String::strpos($this_key, 'attribut') === 0) {
681  // On a un attribut
682  $temp = explode('_', $this_key);
683  $this_nom_attribut_id = intval(String::substr($temp[0], String::strlen('attribut')));
684  if(empty($attributs_array[$this_nom_attribut_id])){
685  // Attribut invalide pour ce produit (erreur technique, ou bidouille utilisateur de ses données POST)
686  continue;
687  }
688  $attributs_infos = current($attributs_array[$this_nom_attribut_id]);
689  // Exclusion des attributs gratuits ou payant suivant les paramètres
690  if(!empty($GLOBALS['site_parameters']['attribut_decreasing_prices_per_technical_code']) && !empty($GLOBALS['site_parameters']['attribut_decreasing_prices_per_technical_code'][$attributs_infos['technical_code']])) {
691  $costly = true;
692  } elseif (($reseller_mode && floatval($attributs_infos["prix_revendeur"]) > 0) || floatval($attributs_infos["prix"]) > 0) {
693  $costly = true;
694  } else {
695  $costly = false;
696  }
697  if(($keep_free_attributs_only && $costly) || ($keep_costly_attributs_only && !$costly)) {
698  continue;
699  }
700  if (String::strpos($this_key, '_texte_libre') !== false) {
701  // attribut au texte libre
702  if (!empty($this_value)) {
703  // Si cet attribut est obligatoire : c'est OK, pas de problème
704  unset($GLOBALS['error_attribut_mandatory'][$this_nom_attribut_id]);
705  }
706  if(!empty($this_value) && String::strpos($attributs_infos['technical_code'], 'date') === 0) {
707  $this_value = get_mysql_date_from_user_input($this_value);
708  }
709  $combinaisons_array[] = $this_nom_attribut_id . '|0|' . $this_value;
710  } elseif (String::strpos($this_key, '_upload') !== false) {
711  // attribut des champs file
712  if (!empty($_SESSION["session_display_popup"][$this_key])) {
713  // si l'image a été déjà téléchargée
714  $combinaisons_array[] = $this_nom_attribut_id . '|0|' . $_SESSION["session_display_popup"][$this_key];
715  unset($GLOBALS['error_attribut_mandatory'][$this_nom_attribut_id]);
716  } elseif (!empty($this_value)) {
717  // Cas où on vient de télécharger, ou si on vient de la sauvegarde de panier
718  $combinaisons_array[] = $this_nom_attribut_id . '|0|' . $this_value;
719  // on sauvegarde le nom de l'image en session
720  $_SESSION["session_display_popup"][$this_key] = $this_value;
721  unset($GLOBALS['error_attribut_mandatory'][$this_nom_attribut_id]);
722  }
723  } elseif (empty($temp[1]) || is_numeric($temp[1])) {
724  // Attribut standard au format 'attributN' ou 'attributN_N' si checkbox
725  if (is_array($this_value)) {
726  // Tableau d'attributs
727  foreach($this_value as $this_combinaison) {
728  // On teste la validité des données
729  $value_array = explode('|', $this_combinaison);
730  if($value_array[0] == $this_nom_attribut_id && !empty($attribut_infos[$this_nom_attribut_id][$value_array[1]])) {
731  // L'option existe bien pour cet attribut
732  $combinaisons_array[] = $this_combinaison;
733  unset($GLOBALS['error_attribut_mandatory'][$this_nom_attribut_id]);
734  }
735  }
736  } else {
737  $combinaisons_array[] = $this_value;
738  unset($GLOBALS['error_attribut_mandatory'][$this_nom_attribut_id]);
739  }
740  }
741  }
742  }
743  }
744  return implode('§', $combinaisons_array);
745 }
746 
755 function get_product_options($id_or_technical_code, $lang, $return_mode = 'value') {
756  $options_array = array();
757  if(is_numeric($id_or_technical_code)) {
758  $where = "p.id = '" . intval($id) . "'";
759  } else {
760  $where = "p.technical_code = '" . nohtml_real_escape_string() . "'";
761  }
762  if($return_mode == 'array') {
763  $sql = "SELECT a.descriptif_" . $_SESSION['session_langue'] . " AS descriptif, na.nom_" . $_SESSION['session_langue'] . " AS nom
764  FROM peel_attributs a
765  INNER JOIN peel_produits_attributs pa ON pa.attribut_id=a.id
766  INNER JOIN peel_nom_attributs na ON na.id=pa.nom_attribut_id AND " . get_filter_site_cond('nom_attributs', 'na') . "
767  INNER JOIN peel_produits p ON pa.produit_id = p.id AND " . get_filter_site_cond('produits', 'p') . "
768  WHERE " . $where . " AND " . get_filter_site_cond('attributs', 'a') . "
769  ORDER BY na.technical_code";
770  } else {
771  $sql = "SELECT a.descriptif_" . $lang . "
772  FROM peel_attributs a
773  INNER JOIN peel_produits_attributs pa ON pa.attribut_id = a.id
774  WHERE " . $where . " AND " . get_filter_site_cond('attributs', 'a');
775  }
776  $query = query($sql);
777  while ($result = fetch_assoc($query)) {
778  if($return_mode == 'array') {
779  $options_array[] = $result;
780  } else {
781  $options_array[] = $result['descriptif_' . $this->lang];
782  }
783  }
784  return $options_array;
785 }
786 
797 function attributes_create_or_update($this_field_name, $this_field_value, $product_id, $site_id, $admin_mode = false) {
798  // Pour chaque attribut, on sépare le nom de l'ID
799  $nom_attrib = explode('#', $this_field_name);
800  $q = query('SELECT id
801  FROM peel_nom_attributs
802  WHERE id=' . intval($nom_attrib[1]) . " AND " . get_filter_site_cond('nom_attributs'));
803  if(!empty($nom_attrib[1])) {
804  // attribut existant
805  if ($att = fetch_assoc($q)) {
806  $nom_attrib[1] = $att['id'];
807  } else {
808  // Attribut inexistant, on l'insère en base de données.
809  $q = query("INSERT INTO peel_nom_attributs
810  SET site_id='" . nohtml_real_escape_string(get_site_id_sql_set_value($site_id)) . "', id=" . intval($nom_attrib[1]) . ", nom_" . $_SESSION['session_langue'] . "='" . nohtml_real_escape_string($nom_attrib[0]) . "', etat='1'");
811  $nom_attrib[1] = insert_id();
812  if($admin_mode) {
813  $output .= $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_IMPORT_PRODUCTS_MSG_ATTRIBUTE_CREATED'], $nom_attrib[0], $nom_attrib[1])))->fetch();
814  }
815  }
816  // Pour chaque attribut
817  if (!empty($this_field_value)) {
818  // On récupère toutes les options de cet attribut
819  $id_options = explode(',', $this_field_value);
820  // Pour chaque option de cet attribut
821  foreach($id_options as $id_o) {
822  // On sépare l'ID du nom
823  $desc_option = explode('#', $id_o);
824  if(!isset($desc_option[1])) {
825  continue;
826  }
827  unset($attribute_ids);
828  $sql = 'SELECT id, id_nom_attribut
829  FROM peel_attributs
830  WHERE id_nom_attribut="' . intval($nom_attrib[1]) . '"';
831  if(!empty($desc_option[0])) {
832  // Si on a spécifié l'id d'attribut, on ne prend que celui-là.
833  $sql .= ' AND id="' . intval($desc_option[0]) . '"';
834  } elseif(!empty($desc_option[1])) {
835  // Si on a spécifié le nom d'attribut, on ne prend que celui-là.
836  $sql .= ' AND descriptif_' . $_SESSION['session_langue'] . '="' . nohtml_real_escape_string($desc_option[1]) . '"';
837  }
838  $q = query($sql);
839  // Option existante
840  while ($attribut = fetch_assoc($q)) {
841  $attribute_ids[] = $attribut['id'];
842  }
843  if(empty($attribute_ids)) {
844  // Option inexistante et différente d'upload ou de texte libre, on l'insère en base de données sinon on modifie l'attribut.
845  if ($desc_option[1] == '__upload') {
846  $q = query('UPDATE peel_nom_attributs
847  SET upload=1
848  WHERE id="' . intval($nom_attrib[1]) . '" AND ' . get_filter_site_cond('nom_attributs'));
849  $attribute_ids[] = $desc_option[0];
850  } elseif ($desc_option[1] == '__texte_libre') {
851  $q = query('UPDATE peel_nom_attributs
852  SET texte_libre=1
853  WHERE id="' . intval($nom_attrib[1]) . '" AND ' . get_filter_site_cond('nom_attributs'));
854  $attribute_ids[] = $desc_option[0];
855  } else {
856  $q = query('INSERT INTO peel_attributs
857  SET id="' . intval($desc_option[0]) . '"
858  , id_nom_attribut="' . intval($nom_attrib[1]) . '"
859  , site_id="' . nohtml_real_escape_string(get_site_id_sql_set_value($site_id)) . '"
860  , descriptif_' . $_SESSION['session_langue'] . '="' . nohtml_real_escape_string($desc_option[1]) . '"
861  , mandatory=1', false, null, true);
862  $this_id = insert_id();
863  if(empty($this_id)) {
864  // On change l'id si déjà prise en BDD
865  // C'est un choix plutôt que d'effacer les attributs déjà existants
866  $q = query('INSERT INTO peel_attributs
867  SET id_nom_attribut="' . intval($nom_attrib[1]) . '"
868  , site_id="' . nohtml_real_escape_string(get_site_id_sql_set_value($site_id)) . '"
869  , descriptif_' . $_SESSION['session_langue'] . '="' . nohtml_real_escape_string($desc_option[1]) . '"
870  , mandatory=1', false, null, true);
871  $this_id = insert_id();
872  }
873  $attribute_ids[] = $this_id;
874  if($admin_mode) {
875  $output .= $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_IMPORT_PRODUCTS_MSG_OPTION_CREATED'], $desc_option[1], $this_id)))->fetch();
876  }
877  }
878  }
879  foreach($attribute_ids as $this_attribute_id) {
880  // Vérification que l'association entre les attributs, les options d'attributs et les produits existe, sinon, on l'ajoute
881  $q = query('SELECT produit_id
882  FROM peel_produits_attributs
883  WHERE produit_id="' . intval($product_id) . '"
884  AND nom_attribut_id="' . intval($nom_attrib[1]) . '"
885  AND attribut_id="' . intval($this_attribute_id) . '"');
886  if (!num_rows($q)) {
887  query('INSERT INTO peel_produits_attributs
888  SET produit_id="' . intval($product_id) . '",
889  nom_attribut_id="' . intval($nom_attrib[1]) . '",
890  attribut_id="' . intval($this_attribute_id) . '"');
891  }
892  }
893  }
894  }
895  }
896  return $output;
897 }
get_all_option_combinations(&$attributs_infos_array, $option_values_array=array(''), $get_agregated_attributs_values=true)
Construit les combinaisons possibles d'attributs.
Definition: fonctions.php:498
if(!empty($GLOBALS['site_parameters']['order_specific_field_titles'])) if(check_if_module_active('socolissimo')&&!empty($_REQUEST)&&!empty($_REQUEST['PUDOFOID'])&&!empty($_REQUEST['CEEMAIL'])&&!empty($_REQUEST['SIGNATURE'])&&!empty($_REQUEST['ORDERID'])) elseif(!empty($_POST)) elseif(check_if_module_active('socolissimo')&&!empty($_SESSION['session_commande']['is_socolissimo_order'])) foreach(array('bill'=> 1, 'ship'=> 2) as $address_type=> $session_commande_address_id) $frm['societe1']
$lang
Definition: spellchecker.php:9
$result
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
Definition: String.php:54
upload($field_name, $rename_file=true, $file_kind=null, $image_max_width=null, $image_max_height=null, $path=null, $new_file_name_without_extension=null, $default_return_value=null)
Fonction d'upload de fichiers.
Definition: fonctions.php:3302
$attributs_array
affiche_attributs_form_part(&$product_object, $display_mode= 'table', $save_cart_id=null, $save_suffix_id=null, $form_id=null, $technical_code_array=null, $excluded_technical_code_array=null, $force_reseller_mode=null, $get_attributes_with_multiple_options_only=true, $filter_using_show_description=false, $get_attributes_with_single_options_only=false, $update_last_calculation_additional_price_ht=true)
affiche_attributs_form_part()
Definition: fonctions.php:232
attributes_create_or_update($this_field_name, $this_field_value, $product_id, $site_id, $admin_mode=false)
Insertion d'une liste d'attributs en base de données pour un produit donné
Definition: fonctions.php:797
static html_entity_decode_if_needed($string)
String::html_entity_decode_if_needed()
Definition: String.php:533
if(!select_db($_SESSION['session_install_choixbase'], $GLOBALS['database_object'], true)) $error
Definition: verifdroits.php:33
get_option_combination_name_from_value($attributs_infos_array, $combinaison_option_value)
get_option_combination_name_from_code()
Definition: fonctions.php:537
insert_id($database_object=null)
insert_id()
Definition: database.php:339
static strlen($string)
Returns the length of the given string.
Definition: String.php:36
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
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
get_current_user_promotion_percentage()
Calcule la réduction générale applicable à un utilisateur et garde la valeur en session pour accélére...
Definition: user.php:939
if(!defined('IN_PEEL')) $GLOBALS['page_types_array']
Definition: fonctions.php:19
if(empty($_GET['id'])) if(!empty($GLOBALS['site_parameters']['allow_multiple_product_url_with_category'])) $product_object
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...
Definition: fonctions.php:33
static str_shorten_words($string, $length_limit=100, $separator=" ", $force_shorten_if_special_content=false, $add_separator_instead_of_cutting=true)
On rajoute des espaces à l'intérieur des mots trop longs => à utiliser pour éviter de casser une mise...
Definition: String.php:305
build_attr_var_js($attr_var_name, $attributs_infos_array, $form_id)
build_attr_var_js()
Definition: fonctions.php:556
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
if(!defined('IN_PEEL')) display_prices_with_taxes_active()
display_prices_with_taxes_active()
Definition: fonctions.php:23
get_product_options($id_or_technical_code, $lang, $return_mode= 'value')
Récupère la liste des attributs liés à un produit.
Definition: fonctions.php:755
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
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
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))
Definition: chart-data.php:160
num_rows($query_result)
num_rows()
Definition: database.php:321
get_possible_attributs($product_id=null, $return_mode= 'rough', $get_attributes_with_multiple_options_only=true, $get_attributes_with_single_options_only=false, $attributs_list=null)
get_possible_attributs()
Definition: fonctions.php:70
display_option_image($str_image, $set=false)
Formatte l'attribut (de type upload) du produit.
Definition: fonctions.php:449
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
attributs_hook_product_get_options(&$params)
Récupère la liste des options liées à un produit.
Definition: fonctions.php:56
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
get_file_type($filename)
get_file_type()
Definition: fonctions.php:3571
if(!defined('IN_PEEL')) attributs_hook_product_init_post(&$params)
Chargement des informations produit manquantes si nécessaire.
Definition: fonctions.php:24
get_mysql_date_from_user_input($string, $use_current_hour_min_sec_if_missing=false)
Transforme une date formattée par get_formatted_date() en date MySQL Si la date est vide...
Definition: format.php:496
attributs_hook_product_set_configuration(&$params)
Définition des informations de configuration d'un produit.
Definition: fonctions.php:36
vn(&$var, $default=0)
Variable nulle if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:110
get_site_id_sql_set_value($site_ids)
Retourne la valeur SQL d'un champ INT ou SET suivant que ce soit un entier ou un tableau.
Definition: fonctions.php:4747
get_attribut_list_from_post_data(&$product_object, &$frm, $keep_free_attributs_only=false, $keep_costly_attributs_only=false)
Traite les informations relatives aux attributs dans le post d'un formulaire produit.
Definition: fonctions.php:606
$id
Definition: articles.php:22
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
Definition: String.php:112
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...
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:48 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.