PEEL Shopping
Open source ecommerce : PEEL Shopping
rpc.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: rpc.php 46935 2015-09-18 08:49:48Z gboussin $
14 define('IN_PEEL_ADMIN', true);
15 define('IN_RPC', true);
16 define('LOAD_NO_OPTIONAL_MODULE', true);
17 include("../configuration.inc.php");
18 
19 if (!empty($_GET['encoding'])) {
20  $page_encoding = $_GET['encoding'];
21 } else {
22  $page_encoding = 'utf-8';
23 }
24 if (!est_identifie() || !a_priv("admin_products", true) || empty($_POST)) {
25  die();
26 }
28 $output = '';
29 $search = vb($_POST['search']);
30 $mode = vb($_POST['type']);
31 $return_mode_for_displayed_values = vb($_POST['return_mode_for_displayed_values']);
32 $id_utilisateur = vb($_POST['id_utilisateur']);
33 $apply_vat = vb($_POST['apply_vat']);
34 $currency = vb($_POST['currency']);
35 $currency_rate = vn($_POST['currency_rate']);
36 $results_array = array();
37 if (!empty($_POST['maxRows'])) {
38  $maxRows = $_POST['maxRows'];
39 } else {
40  $maxRows = 7;
41 }
42 
43 if (empty($currency_rate)) {
44  $currency_rate = 1;
45 }
46 if (String::strlen($search)>0) {
47  if($mode=="products"){
48  $queries_results_array = get_quick_search_results($search, $maxRows);
49  if(!empty($queries_results_array)) {
50  $is_reseller = false;
51  if(!empty($id_utilisateur)) {
52  $priv = query("SELECT priv
53  FROM peel_utilisateurs
54  WHERE id_utilisateur='" . intval($id_utilisateur) . "' AND " . get_filter_site_cond('utilisateurs') . "");
55  $rep = fetch_assoc($priv);
56  if ($rep['priv'] == 'reve') {
57  $is_reseller = true;
58  }
59  }
60  foreach($queries_results_array as $result) {
61  $product_object = new Product($result->id, $result, true, null, true, !check_if_module_active('micro_entreprise'));
62  // Prix hors ecotaxe
63  $purchase_prix_ht = $product_object->get_final_price(0, false, $is_reseller) * $currency_rate;
64  $purchase_prix = $product_object->get_final_price(0, $apply_vat, $is_reseller) * $currency_rate;
65  $prix_cat_ht = $product_object->get_original_price(false, false, false, false) * $currency_rate;
66  $prix_cat = $product_object->get_original_price($apply_vat, false, false, false) * $currency_rate;
68  $purchase_prix_displayed = fprix($purchase_prix, true, $currency, false, $currency_rate, false);
69  } else {
70  $purchase_prix_displayed = fprix($purchase_prix_ht, true, $currency, false, $currency_rate, false);
71  }
72  // Code pour recupérer select des tailles
73  $possible_sizes = $product_object->get_possible_sizes('infos', 0, true, false, false, true);
74  $size_options_html = '';
75  if (!empty($possible_sizes)) {
76  foreach ($possible_sizes as $this_size_id => $this_size_infos) {
77  $option_content = $this_size_infos['name'];
78  $option_content .= $GLOBALS['STR_BEFORE_TWO_POINTS'] . ': ' . fprix($purchase_prix + $this_size_infos['final_price_formatted'], true) . ' => ' . $GLOBALS["STR_ADMIN_UPDATE"];
79  $size_options_html .= '<option value="' . intval($this_size_id) . '">' . $option_content . '</option>';
80  }
81  }
82  $possible_colors = $product_object->get_possible_colors();
83  $color_options_html = '';
84  if (!empty($possible_colors)) {
85  // Code pour recupérer select des couleurs
86  foreach ($possible_colors as $this_color_id => $this_color_name) {
87  $color_options_html .= '<option value="' . intval($this_color_id) . '">' . $this_color_name . '</option>';
88  }
89  }
90  $display_picture = $product_object->get_product_main_picture(false);
91  if ($display_picture) {
92  $product_picture = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($display_picture, 75, 75, 'fit');
93  } elseif(!empty($GLOBALS['site_parameters']['default_picture'])) {
94  $product_picture = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($GLOBALS['site_parameters']['default_picture'], 75, 75, 'fit');
95  } else {
96  $product_picture = null;
97  }
98  $tva_options_html = get_vat_select_options($result->tva);
99  $results_array[] = array('id' => $result->id,
100  'reference' => $result->reference,
101  'label' => (!empty($GLOBALS['site_parameters']['autocomplete_hide_images']) && !empty($product_picture)?'<div>':'<div class="autocomplete_image"><img src="'.$product_picture.'" /></div><div style="display:table-cell; vertical-align:middle; height:45px;">') . highlight_found_text(String::html_entity_decode($result->nom), $search, $found_words_array) . (String::strlen($result->reference) ? ' - <span class="autocomplete_reference_result">' . highlight_found_text(String::html_entity_decode($result->reference), $search, $found_words_array) . '</span>' : '') . '</div><div class="clearfix" />',
102  'nom' => $result->nom,
103  'image' => $display_picture,
104  'image_thumbs' => $product_picture,
105  'prix' => fprix(String::str_form_value($result->prix)),
106  'promotion' => null,
107  'size_options_html' => $size_options_html,
108  'color_options_html' => $color_options_html,
109  'tva_options_html' => $tva_options_html,
110  'prix_cat' => $prix_cat,
111  'prix_cat_ht' => $prix_cat_ht,
112  'purchase_prix' => $purchase_prix,
113  'purchase_prix_ht' => $purchase_prix_ht,
114  'purchase_prix_displayed' => $purchase_prix_displayed
115  );
116  unset($product_object);
117  }
118  }
119  } elseif($mode=="offers" && !empty($GLOBALS['site_parameters']['user_offers_table_enable'])) {
120  $queries_results_array = get_quick_search_results($search, $maxRows, false, null, "offers");
121  foreach($queries_results_array as $result) {
122  $results_array[] = array('id' => $result->id_offre,
123  'nom' => $result->num_offre,
124  'user_id' => $id_utilisateur
125  );
126  }
127  } elseif($mode == "offer_add_user" && !empty($GLOBALS['site_parameters']['user_offers_table_enable'])) {
128  $queries_results_array = get_quick_search_results($search, $maxRows, false, null, "offer_add_user");
129  foreach($queries_results_array as $result_object) {
130  $result = (array)$result_object;
131  $result['msg'] = $GLOBALS['STR_ADMIN_MSG_UPDATE_OK'];
133  }
134  }
135 }
136 if (!empty($_POST['return_json_array_with_raw_information'])) {
137  $output = json_encode($results_array);
138 } elseif (!empty($search)) {
139  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_rpc.tpl');
140  if (!empty($results_array)) {
141  $tpl->assign('results', $results_array);
142  }
143  $tpl->assign('return_mode_for_displayed_values', $return_mode_for_displayed_values);
144  $tpl->assign('STR_ADMIN_COMMANDER_ADD_LINE_TO_ORDER', $GLOBALS['STR_ADMIN_COMMANDER_ADD_LINE_TO_ORDER']);
145  $tpl->assign('STR_TTC', $GLOBALS['STR_TTC']);
146  $tpl->assign('STR_AUCUN_RESULTAT', $GLOBALS['STR_AUCUN_RESULTAT']);
147  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
148  $tpl->assign('STR_ADMIN_PRODUITS_ADD_PRODUCT', $GLOBALS['STR_ADMIN_PRODUITS_ADD_PRODUCT']);
149  $tpl->assign('STR_MODIFY', $GLOBALS['STR_MODIFY']);
150  if(!empty($GLOBALS['site_parameters']['user_offers_table_enable'])) {
151  $tpl->assign('STR_OFFER_NO_RESULT', $GLOBALS['STR_OFFER_NO_RESULT']);
152  $tpl->assign('STR_ADMIN_OFFER_ADD_OFFER', $GLOBALS['STR_ADMIN_OFFER_ADD_OFFER']);
153  }
154  $tpl->assign('mode', $mode);
155  $output .= $tpl->fetch();
156 }
157 
158 echo String::convert_encoding($output, $page_encoding, GENERAL_ENCODING);
get_quick_search_results($search, $maxRows, $active_only=false, $search_category=null, $mode= 'products')
get_quick_search_results()
Definition: fonctions.php:4555
$results_array
Definition: rpc.php:36
highlight_found_text($text, $terms, &$found_words_array, $found_tags=array('< span class="search_tag">', '</span >'))
Highlights terms in text.
Definition: format.php:1120
$result
static convert_encoding($string, $new_encoding, $original_encoding=null)
Converts the character encoding of string $string to $new_encoding from optionally $original_encoding...
Definition: String.php:375
if(empty($currency_rate)) if(String::strlen($search)>0) if(!empty($_POST['return_json_array_with_raw_information'])) elseif(!empty($search))
Definition: rpc.php:138
$apply_vat
Definition: rpc.php:33
output_general_http_header($page_encoding=null, $cache_duration_in_seconds=null)
Envoie les headers avant l'envoi du HTML.
Definition: fonctions.php:1528
$output
Definition: rpc.php:28
if(!defined('IN_PEEL')) display_prices_with_taxes_in_admin()
display_prices_with_taxes_in_admin()
$return_mode_for_displayed_values
Definition: rpc.php:31
static strlen($string)
Returns the length of the given string.
Definition: String.php:36
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
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
get_vat_select_options($selected_vat=null, $approximative_amount_selected=false)
get_vat_select_options()
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
$found_words_array
Definition: search.php:147
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
if(!defined('IN_PEEL')) est_identifie()
Retourne true si l'utilisateur est identifié
Definition: user.php:23
static str_form_value($value, $flags=ENT_COMPAT)
Encode une chaine de caractères pour affichage dans un value="".
Definition: String.php:480
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
$priv
$search
Definition: rpc.php:29
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
$id_utilisateur
Definition: rpc.php:32
$currency
Definition: rpc.php:34
$GLOBALS['page_columns_count']
if(!check_if_module_active('search')) $page_encoding
Definition: produit.php:23
$currency_rate
Definition: rpc.php:35
$mode
Definition: rpc.php:30
vn(&$var, $default=0)
Variable nulle if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:110
a_priv($requested_priv, $demo_allowed=false, $site_configuration_modification=false, $user_id=null)
Renvoie true si l'utilisateur de la session a le privilège $requested_priv ou un droit supérieur Des ...
Definition: user.php:63
static html_entity_decode($string, $quote_style=ENT_COMPAT, $charset=GENERAL_ENCODING)
String::html_entity_decode()
Definition: String.php:517
$maxRows
Definition: produit.php:28
fprix($price, $display_currency=false, $currency_code_or_default=null, $convertion_needed_into_currency=true, $currency_rate=null, $display_iso_currency_code=false, $format=true, $force_format_separator=null, $add_rdfa_properties=false, $round_even_if_no_format=false)
fprix formatte le prix donné en le convertissant si nécessaire au préalable et en ajoutant éventuelle...
Definition: fonctions.php:242
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...

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