14 if (!defined(
'IN_PEEL')) {
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']);
37 if ($params[
'this']->configuration_attributs_list !== $params[
'attributs_list']) {
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 =
"";
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']);
57 return get_product_options($params[
'id_or_technical_code'], $params[
'lang'], $params[
'return_mode']);
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)
72 static $possible_attributs;
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])) {
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]).
'"';
86 $sql_cond_array[] =
'(na.id="'.intval($this_attributs_list_array[0]).
'" AND a.id="'.intval($this_attributs_list_array[1]).
'")';
91 if(empty($sql_cond_array) && ($attributs_list ===
'' || !empty($attributs_list))) {
93 $sql_cond_array[] =
'0';
95 if (!isset($possible_attributs[
$product_id .
'-' .
$_SESSION[
'session_langue'] .
'-' . $attributs_list])) {
96 $possible_attributs[
$product_id .
'-' .
$_SESSION[
'session_langue'] .
'-' . $attributs_list] = 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) .
"'";
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') .
"
114 if(!empty($sql_cond_array)) {
115 $sql_from_and_where .=
" AND (".implode(
' OR ', $sql_cond_array).
")";
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";
122 if (
$result[
'type_affichage_attribut'] == 3) {
124 $result[
'type_affichage_attribut'] =
$GLOBALS[
'site_parameters'][
'type_affichage_attribut'];
131 if (!empty($possible_attributs)) {
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']])) {
140 $this_function =
$GLOBALS[
'site_parameters'][
'attribut_fictive_options_functions_by_technical_codes_array'][$this_attribut_values_array[0][
'technical_code']];
142 if(!empty($attribut_and_options_filter_array[$this_nom_attribut_id])) {
144 $fictive_options_array = $this_function($attribut_and_options_filter_array[$this_nom_attribut_id]);
147 $fictive_options_array = $this_function();
154 foreach($fictive_options_array as $this_id => $this_fictive_options) {
158 $attributs_array[$this_nom_attribut_id][$this_id][
'descriptif'] = $this_fictive_options;
160 $attributs_array[$this_nom_attribut_id][$this_id][
'attribut_id'] = $this_id;
163 if ($this_attribut_values_array[0][
'type_affichage_attribut'] == 1) {
166 foreach (
$attributs_array[$this_nom_attribut_id] as $this_attribut_id => $this_attribut_values) {
168 if($this_attribut_values[
'attribut_id'] === NULL) {
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)];
182 if($get_attributes_with_multiple_options_only || $get_attributes_with_single_options_only) {
185 if($get_attributes_with_multiple_options_only && (count($this_options_array)<=1 && $this_options_array[key($this_options_array)][
'type_affichage_attribut']!=2)) {
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'])) {
192 }
elseif($get_attributes_with_single_options_only && (count($this_options_array)>1 || $this_options_array[key($this_options_array)][
'type_affichage_attribut']==2)) {
197 if ($return_mode ==
'option_name' || $return_mode ==
'full_name') {
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'];
205 if(!empty($this_attribut_infos[
'description'])) {
206 $this_name_parts[] = $this_attribut_infos[
'description'];
208 $attributs_array[$this_nom_attribut_id][$this_attribut_id] = implode(
' - ', $this_name_parts);
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)
235 $GLOBALS[
'last_calculation_additional_price_ht'] = 0;
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);
241 $attribut_preselect_infos[intval($this_attributs_list_array[0])] = end($this_attributs_list_array);
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])) {
245 $this_function =
$GLOBALS[
'site_parameters'][
'affiche_attributs_form_part_function_by_product_technical_codes_array'][
$product_object->technical_code];
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);
255 foreach (
$attributs_array as $this_nom_attribut_id => $this_attribut_values_array) {
263 $input_on_change =
'';
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)) {
273 if (!empty($excluded_technical_code_array) && in_array($this_attribut_infos[
'technical_code'], $excluded_technical_code_array)) {
276 if($force_reseller_mode!==null) {
277 $reseller_mode = $force_reseller_mode;
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']);
289 $additional_price_ttc =
vn($this_attribut_infos[
'prix']);
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];
296 $attribut_additional_price_ttc += $additional_price_ttc;
297 $additional_price_ht = $additional_price_ttc / (1 +
$product_object->tva / 100);
299 if (!empty($update_last_calculation_additional_price_ht)) {
300 $GLOBALS[
'last_calculation_additional_price_ht'] += $additional_price_ht;
302 if ($additional_price_ttc != 0 && $show_additionnal_price) {
308 if($filter_using_show_description && empty($this_attribut_infos[
'show_description'])) {
313 if ($this_attribut_infos[
'type_affichage_attribut'] == 3) {
315 $type_affichage_attribut =
$GLOBALS[
'site_parameters'][
'type_affichage_attribut'];
317 $type_affichage_attribut = $this_attribut_infos[
'type_affichage_attribut'];
319 if (!empty($this_attribut_infos[
'upload']) && empty($this_attribut_id)) {
321 if($display_mode ==
'selected_text') {
322 $input_value = $preselected_value;
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)) {
329 $_SESSION[
"session_display_popup"][$input_name] = $preselected_value;
331 if (!empty(
$_SESSION[
"session_display_popup"][$input_name])) {
336 $input_type =
'file';
339 }
elseif (!empty($this_attribut_infos[
'texte_libre']) && empty($this_attribut_id)) {
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';
350 if(!empty($this_attribut_infos[
'texte_libre'])) {
353 $input_name =
'attribut' . $this_nom_attribut_id .
'_texte_libre';
355 $this_value = $this_nom_attribut_id .
'|' . $this_attribut_id;
357 if ($type_affichage_attribut == 0) {
359 if(empty($input_name)) {
360 $input_name =
'attribut' . $this_nom_attribut_id;
362 $input_id = $form_id .
'_custom_attribut' . $this_nom_attribut_id;
363 $input_type =
'select';
365 'value' => $this_value,
367 'issel' => in_array($this_value, $attributs_list_array)
369 }
elseif ($type_affichage_attribut == 1) {
371 if(empty($input_name)) {
372 $input_name =
'attribut' . $this_nom_attribut_id;
374 $input_type =
'radio';
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),
381 'onclick' => $input_on_change.
' update_product_price' . $save_suffix_id .
'();'
383 }
elseif ($type_affichage_attribut == 2) {
385 $input_type =
'checkbox';
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),
392 'onclick' => $input_on_change.
' update_product_price' . $save_suffix_id .
'();'
394 }
elseif ($type_affichage_attribut == 4) {
396 $input_type =
'link';
398 'value' => $this_attribut_id,
399 'name' =>
'custom_attribut[' . $this_nom_attribut_id .
']',
407 if(isset($type_affichage_attribut)) {
408 $attributes_text_array[] = array(
409 'text' => $attribut_text,
410 'technical_code' => $this_attribut_infos[
'technical_code'],
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 .
'();'
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);
437 $output .= trim(str_replace(array(
"\r\n",
"\r",
"\n",
"\t"),
' ',
$tpl->fetch()));
454 $inital_text = $str_image;
455 $option_tab = explode(
"{{", $str_image);
456 if (count($option_tab) > 1) {
458 foreach ($option_tab as $str_img) {
462 $small_option_image = get_url(
'/images/logoPDF_small.png');
465 $small_option_image =
$GLOBALS[
'repertoire_upload'] .
'/thumbs/' .
thumbs($str_img, 0, 25,
'fit');
468 $str_img_new =
$GLOBALS[
'tplEngine']->createTemplate(
'modules/attributs_option_image.tpl', array(
470 'href' =>
$GLOBALS[
'repertoire_upload'] .
'/' . $str_img,
471 'src' => $small_option_image,
474 $str_image = str_replace(
'{{' . $str_img .
'}}', $str_img_new, $str_image);
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(
483 'href' =>
$GLOBALS[
'repertoire_upload'] .
'/' . $str_image,
484 'src' => $small_option_image
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) {
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;
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;
519 $next_attributs_infos_array = $attributs_infos_array;
520 unset($next_attributs_infos_array[$this_nom_attribut_id]);
522 if(!empty($next_attributs_infos_array)) {
526 return array_unique($option_values_array_tmp);
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'];
545 return implode(
' - ', $combinaison_option_name_parts);
558 $attributs_infos_array_count = count($attributs_infos_array);
559 $output =
'' . $attr_var_name .
'="";
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'])) {
568 if ($this_attributs_infos[
'type_affichage_attribut'] == 0) {
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) {
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;
582 }
elseif ($this_attributs_infos[
'type_affichage_attribut'] == 2) {
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;
609 $combinaisons_array = array();
610 foreach(array_keys($_FILES) as $this_key) {
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) {
615 $_SESSION[
"session_display_popup"][$this_key] =
false;
617 $tpl =
$GLOBALS[
'tplEngine']->createTemplate(
'image_upload_error_option.tpl');
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();
625 $tpl_labels[] = $label;
628 $tpl->assign(
'labels', $tpl_labels);
629 $_SESSION[
"session_display_popup"][
"upload_error_text"] =
$tpl->fetch();
632 $frm[$this_key] =
'{{' .
$frm[$this_key] .
'}}';
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) {
649 $GLOBALS[
'error_attribut_mandatory'][$this_nom_attribut_id] = $attributs_infos[
'nom'];
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];
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']])) {
665 }
elseif (($reseller_mode && floatval($attributs_infos[
"prix_revendeur"]) > 0) || floatval($attributs_infos[
"prix"]) > 0) {
670 if(($keep_free_attributs_only && $costly) || ($keep_costly_attributs_only && !$costly)) {
675 $combinaisons_array[] = $this_attributs_list;
679 foreach(
$frm as $this_key => $this_value) {
682 $temp = explode(
'_', $this_key);
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']])) {
692 }
elseif (($reseller_mode && floatval($attributs_infos[
"prix_revendeur"]) > 0) || floatval($attributs_infos[
"prix"]) > 0) {
697 if(($keep_free_attributs_only && $costly) || ($keep_costly_attributs_only && !$costly)) {
702 if (!empty($this_value)) {
704 unset(
$GLOBALS[
'error_attribut_mandatory'][$this_nom_attribut_id]);
706 if(!empty($this_value) &&
String::strpos($attributs_infos[
'technical_code'],
'date') === 0) {
709 $combinaisons_array[] = $this_nom_attribut_id .
'|0|' . $this_value;
712 if (!empty(
$_SESSION[
"session_display_popup"][$this_key])) {
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)) {
718 $combinaisons_array[] = $this_nom_attribut_id .
'|0|' . $this_value;
720 $_SESSION[
"session_display_popup"][$this_key] = $this_value;
721 unset(
$GLOBALS[
'error_attribut_mandatory'][$this_nom_attribut_id]);
723 }
elseif (empty($temp[1]) || is_numeric($temp[1])) {
725 if (is_array($this_value)) {
727 foreach($this_value as $this_combinaison) {
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]])) {
732 $combinaisons_array[] = $this_combinaison;
733 unset(
$GLOBALS[
'error_attribut_mandatory'][$this_nom_attribut_id]);
737 $combinaisons_array[] = $this_value;
738 unset(
$GLOBALS[
'error_attribut_mandatory'][$this_nom_attribut_id]);
744 return implode(
'§', $combinaisons_array);
756 $options_array = array();
757 if(is_numeric($id_or_technical_code)) {
758 $where =
"p.id = '" . intval(
$id) .
"'";
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') .
"
769 ORDER BY na.technical_code";
771 $sql =
"SELECT a.descriptif_" .
$lang .
"
772 FROM peel_attributs a
773 INNER JOIN peel_produits_attributs pa ON pa.attribut_id = a.id
778 if($return_mode ==
'array') {
784 return $options_array;
799 $nom_attrib = explode(
'#', $this_field_name);
801 FROM peel_nom_attributs
803 if(!empty($nom_attrib[1])) {
806 $nom_attrib[1] = $att[
'id'];
809 $q =
query(
"INSERT INTO peel_nom_attributs
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();
817 if (!empty($this_field_value)) {
819 $id_options = explode(
',', $this_field_value);
821 foreach($id_options as $id_o) {
823 $desc_option = explode(
'#', $id_o);
824 if(!isset($desc_option[1])) {
827 unset($attribute_ids);
828 $sql =
'SELECT id, id_nom_attribut
830 WHERE id_nom_attribut="' . intval($nom_attrib[1]) .
'"';
831 if(!empty($desc_option[0])) {
833 $sql .=
' AND id="' . intval($desc_option[0]) .
'"';
834 }
elseif(!empty($desc_option[1])) {
841 $attribute_ids[] = $attribut[
'id'];
843 if(empty($attribute_ids)) {
845 if ($desc_option[1] ==
'__upload') {
846 $q =
query(
'UPDATE peel_nom_attributs
849 $attribute_ids[] = $desc_option[0];
850 }
elseif ($desc_option[1] ==
'__texte_libre') {
851 $q =
query(
'UPDATE peel_nom_attributs
854 $attribute_ids[] = $desc_option[0];
856 $q =
query(
'INSERT INTO peel_attributs
857 SET id="' . intval($desc_option[0]) .
'"
858 , id_nom_attribut="' . intval($nom_attrib[1]) .
'"
861 , mandatory=1',
false, null,
true);
863 if(empty($this_id)) {
866 $q =
query(
'INSERT INTO peel_attributs
867 SET id_nom_attribut="' . intval($nom_attrib[1]) .
'"
870 , mandatory=1',
false, null,
true);
873 $attribute_ids[] = $this_id;
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();
879 foreach($attribute_ids as $this_attribute_id) {
882 FROM peel_produits_attributs
884 AND nom_attribut_id="' . intval($nom_attrib[1]) .
'"
885 AND attribut_id="' . intval($this_attribute_id) .
'"');
887 query(
'INSERT INTO peel_produits_attributs
889 nom_attribut_id="' . intval($nom_attrib[1]) .
'",
890 attribut_id="' . intval($this_attribute_id) .
'"');
get_all_option_combinations(&$attributs_infos_array, $option_values_array=array(''), $get_agregated_attributs_values=true)
Construit les combinaisons possibles d'attributs.
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']
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
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.
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()
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é
static html_entity_decode_if_needed($string)
String::html_entity_decode_if_needed()
if(!select_db($_SESSION['session_install_choixbase'], $GLOBALS['database_object'], true)) $error
get_option_combination_name_from_value($attributs_infos_array, $combinaison_option_value)
get_option_combination_name_from_code()
insert_id($database_object=null)
insert_id()
static strlen($string)
Returns the length of the given string.
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 ...
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...
if(!defined('IN_PEEL')) $GLOBALS['page_types_array']
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...
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...
build_attr_var_js($attr_var_name, $attributs_infos_array, $form_id)
build_attr_var_js()
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.
if(!defined('IN_PEEL')) display_prices_with_taxes_active()
display_prices_with_taxes_active()
get_product_options($id_or_technical_code, $lang, $return_mode= 'value')
Récupère la liste des attributs liés à un produit.
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.
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))
num_rows($query_result)
num_rows()
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()
display_option_image($str_image, $set=false)
Formatte l'attribut (de type upload) du produit.
fetch_assoc($query_result)
fetch_assoc()
attributs_hook_product_get_options(&$params)
Récupère la liste des options liées à un produit.
get_file_type($filename)
get_file_type()
if(!defined('IN_PEEL')) attributs_hook_product_init_post(&$params)
Chargement des informations produit manquantes si nécessaire.
attributs_hook_product_set_configuration(&$params)
Définition des informations de configuration d'un produit.
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.
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.
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...
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']