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 
24 function pensebete_hook_account_show($params) {
25  $result['modules_data_group']['pensebete'] = array('header' => $GLOBALS['STR_PENSE_BETE'], 'position' => 11);
26  $result['modules_data']['pensebete'][] = array('txt' => '<span class="fa fa-list fa-5x"></span><br />' . $GLOBALS['STR_VOIR_PENSE_BETE'], 'href' => get_url('/modules/pensebete/voir.php'));
27  return $result;
28 }
29 
35 function insere_pense($item_id = null, $type = null)
36 {
37  if (empty($item_id) || empty($type)) {
38  return false;
39  }
40  $url_prod = vb($_SERVER['HTTP_REFERER']);
41  if ($type == 'produit') {
42  $product_object = new Product($item_id, null, false, null, true, !is_user_tva_intracom_for_no_vat() && !check_if_module_active('micro_entreprise'));
43  $this_url = $product_object->get_product_url();
44  $this_name = $product_object->name;
45  $this_item = $GLOBALS['STR_THE_PRODUCT'];
46  $back_to_item = $GLOBALS['STR_BACK_TO_PRODUCT'];
47  $this_field = 'id_produit';
48  } elseif ($type == 'annonce') {
49  $annonce_object = new Annonce($item_id);
50  $this_url = $annonce_object->get_annonce_url();
51  $this_name = $annonce_object->get_titre();
52  $this_item = $GLOBALS['STR_MODULE_ANNONCES_THE_AD'];
53  $back_to_item = $GLOBALS['STR_MODULE_ANNONCES_BACK_TO_ADS'];
54  $this_field = 'id_annonce';
55  }
56  $query = query("SELECT 1
57  FROM peel_pensebete
58  WHERE id_utilisateur = '" . intval($_SESSION['session_utilisateur']['id_utilisateur']) . "' AND " . word_real_escape_string($this_field) . " = '" . intval($item_id) . "'");
59  if (num_rows($query) == 0) {
60  $sql = "INSERT INTO peel_pensebete (
61  " . word_real_escape_string($this_field) . "
62  , id_utilisateur
63  , date_insertion
64  ) VALUES (
65  '" . intval($item_id) . "'
66  , '" . intval($_SESSION['session_utilisateur']['id_utilisateur']) . "'
67  , '" . date('Y-m-d H:i:s', time()) . "')";
68  query($sql);
69  }
70  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/pensebete_insere.tpl');
71  $tpl->assign('item', $this_item);
72  $tpl->assign('name', $this_name);
73  $tpl->assign('account_url', get_account_url(false, false));
74  $tpl->assign('url', $this_url);
75  $tpl->assign('back_to_item', $back_to_item);
76  $tpl->assign('STR_COMPTE', $GLOBALS['STR_COMPTE']);
77  $tpl->assign('STR_AJOUT_PENSE_BETE', $GLOBALS['STR_AJOUT_PENSE_BETE']);
78  $tpl->assign('STR_MODULE_PENSEBETE_HAS_BEEN_ADD_REMINDER', $GLOBALS['STR_MODULE_PENSEBETE_HAS_BEEN_ADD_REMINDER']);
79  $tpl->assign('STR_MODULE_PENSEBETE_YOUR_REMINDER_ON_RUB', $GLOBALS['STR_MODULE_PENSEBETE_YOUR_REMINDER_ON_RUB']);
80  $tpl->assign('STR_MODULE_PENSEBETE_OF_OUR_ONLINE_SHOP', $GLOBALS['STR_MODULE_PENSEBETE_OF_OUR_ONLINE_SHOP']);
81  return $tpl->fetch();
82 }
83 
88 function display_product_in_reminder($return_mode = false)
89 {
90  $sql = "SELECT pb.id as id_pense_bete, p.id, p.reference, p.nom_" . $_SESSION['session_langue'] . " AS name, p.image1, p.prix * (1-p.promotion/100) as prix, p.promotion, c.id as categorie_id, c.nom_" . $_SESSION['session_langue'] . " as categorie
91  FROM peel_produits p
92  INNER JOIN peel_pensebete pb ON (pb.id_produit = p.id)
93  INNER JOIN peel_produits_categories pc ON p.id = pc.produit_id
94  INNER JOIN peel_categories c ON c.id = pc.categorie_id AND " . get_filter_site_cond('categories', 'c') . "
95  WHERE pb.id_utilisateur = '" . intval($_SESSION['session_utilisateur']['id_utilisateur']) . "' AND " . get_filter_site_cond('produits', 'p') . "
96  GROUP BY p.id";
97  $query = query($sql);
98  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/pensebete_display.tpl');
99  $tpl->assign('del_src', get_url('/images/suppression.png'));
100  $tpl->assign('STR_MODULE_PENSEBETE_PENSE_BETE_PRODUIT', $GLOBALS['STR_MODULE_PENSEBETE_PENSE_BETE_PRODUIT']);
101  $tpl->assign('STR_MODULE_PENSEBETE_NO_PRODUCT_IN_REMINDER', $GLOBALS['STR_MODULE_PENSEBETE_NO_PRODUCT_IN_REMINDER']);
102  $tpl->assign('STR_TABLE_SUMMARY_CADDIE', $GLOBALS['STR_TABLE_SUMMARY_CADDIE']);
103  $tpl->assign('STR_PRODUCT', $GLOBALS['STR_PRODUCT']);
104  $tpl->assign('STR_REMISE', $GLOBALS['STR_REMISE']);
105  $tpl->assign('STR_UNIT_PRICE', $GLOBALS['STR_UNIT_PRICE']);
106  $tpl->assign('STR_DELETE_PROD_CART', $GLOBALS['STR_DELETE_PROD_CART']);
107  $tpl->assign('ttc_ht', (display_prices_with_taxes_active() ? $GLOBALS['STR_TTC'] : $GLOBALS['STR_HT']));
108  $user_info = get_user_information($_SESSION['session_utilisateur']['id_utilisateur']);
109  $tpl->assign('pseudo', $user_info['pseudo']);
110 
111  if (num_rows($query) > 0) {
112  $tpl->assign('are_prods', true);
113  $tpl_prods = array();
114  while ($prod = fetch_assoc($query)) {
115  $product_object = new Product($prod['id'], null, false, null, true, !is_user_tva_intracom_for_no_vat() && !check_if_module_active('micro_entreprise'));
116  $display_picture = $product_object->get_product_main_picture($product_object->id, $product_object->default_color_id);
117  $urlprod = get_product_url($prod['id'], $prod['name'], $prod['categorie_id'], $prod['categorie']);
118 
119  $tpl_img = null;
120  if ($display_picture) {
121  $tpl_img = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($display_picture, 75, 75, 'fit');
122  } elseif(!empty($GLOBALS['site_parameters']['default_picture'])) {
123  $tpl_img = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($GLOBALS['site_parameters']['default_picture'], 75, 75, 'fit');
124  }
125  $tpl_promo = null;
126  if($prod['promotion'] > 0) {
127  $tpl_promo = fprix($prod['promotion']);
128  }
129  $tpl_prods[] = array(
130  'del_href' => $GLOBALS['wwwroot'] . '/modules/pensebete/voir.php?mode=delete&id=' . $prod['id_pense_bete'],
131  'attributes_with_single_options_array' => $product_object->attributes_with_single_options_array,
132  'img' => $tpl_img,
133  'urlprod' => $urlprod,
134  'name' => $prod['name'],
135  'promotion' => $tpl_promo,
136  'prix' => $product_object->affiche_prix(display_prices_with_taxes_active(), check_if_module_active('reseller') && is_reseller(), true)
137  );
138  }
139  $tpl->assign('prods', $tpl_prods);
140  } else {
141  $tpl->assign('are_prods', false);
142  }
143  if ($return_mode) {
144  return $tpl->fetch();
145  } else {
146  echo $tpl->fetch();
147 
148  }
149 }
150 
$result
get_user_information($user_id=null, $get_full_infos=false)
Chargement des détails de l'utilisateur.
Definition: user.php:906
is_user_tva_intracom_for_no_vat($user_id=null)
is_user_tva_intracom_for_no_vat()
Definition: user.php:959
word_real_escape_string($value)
Applique real_escape_string dans le cas où on n'insère qu'un seul mot, de moins de 30 caractères...
Definition: database.php:424
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(!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
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
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
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
insere_pense($item_id=null, $type=null)
Definition: fonctions.php:35
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
if(!defined('IN_PEEL')) pensebete_hook_account_show($params)
Renvoie les tableaux d'informations à afficher dans Mon compte.
Definition: fonctions.php:24
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...
display_product_in_reminder($return_mode=false)
Definition: fonctions.php:88
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:31:01 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.