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 46977 2015-09-21 13:27:07Z sdelaporte $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 
27 function affiche_best_seller_produit_colonne($return_mode = false, $location = null, $nb_col_sm = 3, $nb_col_md = 4)
28 {
29  $output = '';
30  if (vb($GLOBALS['site_parameters']['act_on_top']) == '1') {
31  $requete = "SELECT p.*, SUM(pca.quantite) AS quantite, c.nom_" . $_SESSION['session_langue'] . " AS categorie
32  FROM peel_commandes_articles pca
33  INNER JOIN peel_commandes pc ON pca.commande_id = pc.id AND " . get_filter_site_cond('commandes', 'pc') . "
34  INNER JOIN peel_statut_paiement sp ON sp.id=pc.id_statut_paiement AND " . get_filter_site_cond('statut_paiement', 'sp') . "
35  INNER JOIN peel_produits p ON pca.produit_id = p.id AND " . get_filter_site_cond('produits', 'p') . "
36  INNER JOIN peel_categories c ON pca.categorie_id = c.id AND " . get_filter_site_cond('categories', 'c') . "
37  WHERE " . get_filter_site_cond('commandes_articles', 'pca', true) . " AND p.nom_".(!empty($GLOBALS['site_parameters']['product_name_forced_lang'])?$GLOBALS['site_parameters']['product_name_forced_lang']:$_SESSION['session_langue'])." != '' AND p.etat='1' AND sp.technical_code IN ('being_checked','completed')
38  GROUP BY pca.produit_id
39  ORDER BY quantite DESC
40  LIMIT 0, " . intval(vn($GLOBALS['site_parameters']['nb_on_top']));
41  } else {
42  $requete = "SELECT p.*, c.id AS categorie_id, c.nom_" . $_SESSION['session_langue'] . " AS categorie
43  FROM peel_produits p
44  INNER JOIN peel_produits_categories pc ON pc.produit_id=p.id
45  INNER JOIN peel_categories c ON c.id=pc.categorie_id AND " . get_filter_site_cond('categories', 'c') . "
46  WHERE p.nom_".(!empty($GLOBALS['site_parameters']['product_name_forced_lang'])?$GLOBALS['site_parameters']['product_name_forced_lang']:$_SESSION['session_langue'])." != '' AND p.etat='1' AND p.on_top='1' AND " .get_filter_site_cond('produits', 'p') . "
47  GROUP BY p.id
48  ORDER BY RAND()
49  LIMIT 0, " . intval(vn($GLOBALS['site_parameters']['nb_on_top']));
50  }
51  $qid = query($requete);
52  $numrows = num_rows($qid);
53  if ($numrows > 0) {
54  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/best_seller_produit_colonne.tpl');
55  $tpl_products = array();
56  $i = 0;
57  while ($prod = fetch_assoc($qid)) {
58  if ((!a_priv("admin_product") && !a_priv("reve")) && $prod['on_reseller'] == 1) {
59  continue;
60  } else {
61  // Faire attention que dans $prod on a bien les noms de colonnes correspondant à ce qui est nécessaire dans la classe product
62  $product_object = new Product($prod['id'], $prod, true, null, true, !is_user_tva_intracom_for_no_vat() && !check_if_module_active('micro_entreprise'));
63  if (empty($GLOBALS['site_parameters']['module_best_sellers_return_result_as_link'])) {
64  $this_product_in_container_html = get_product_in_container_html($product_object, $GLOBALS['site_parameters']['only_show_products_with_picture_in_containers']);
65  } else {
66  $this_product_in_container_html = '<a href="' . $product_object->get_product_url() . '">' . $product_object->name . '</a>';
67  }
68  if (!empty($this_product_in_container_html)) {
69  $tpl_products[] = array('html' => $this_product_in_container_html,
70  'i' => $i+1);
71  $i++;
72  }
73  }
74  }
75  $tpl->assign('module_best_sellers_return_result_as_link', !empty($GLOBALS['site_parameters']['module_best_sellers_return_result_as_link']));
76  $tpl->assign('nb_col_sm', $nb_col_sm);
77  $tpl->assign('nb_col_xs', 1);
78  $tpl->assign('nb_col_md', $nb_col_md);
79  $tpl->assign('products', $tpl_products);
80  $tpl->assign('STR_TOP', $GLOBALS['STR_TOP']);
81  $output .= $tpl->fetch();
82  }
83  if ($return_mode) {
84  return $output;
85  } else {
86  echo $output;
87  }
88 }
89 
is_user_tva_intracom_for_no_vat($user_id=null)
is_user_tva_intracom_for_no_vat()
Definition: user.php:959
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')) affiche_best_seller_produit_colonne($return_mode=false, $location=null, $nb_col_sm=3, $nb_col_md=4)
Affiche la liste des catégories qui sont spéciales.
Definition: fonctions.php:27
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
Definition: fonctions.php:4643
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
Definition: database.php:158
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
num_rows($query_result)
num_rows()
Definition: database.php:321
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
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
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:55 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.