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 
26 function show_preview_next($product_id, $product_position, $prev_next, $category_id)
27 {
28  $output = '';
29  $sql_cond='';
30  if($GLOBALS['site_parameters']['in_category']==0) {
31  // Recherche des catégories fille de chaque catégorie trouvée précédemment + suppression des doublons + supression de la categorie 0
32  $descending_category_array = array_unique(get_category_tree_and_itself(0, 'sons'));
33  $sql_cond = 'ppc.categorie_id IN ("' . implode('","', $descending_category_array) . '")';
34  } else {
35  $sql_cond = 'ppc.categorie_id="'. intval($category_id) . '"';
36  }
37  // ATTENTION : dans params_affiche_produits on affiche par défaut avec pp.position ASC, pp.id DESC
38  // Donc les tris sur id et position sont inversés
39  // Par ailleurs, on fait attention à la compatibilité si plusieurs produits ont la même position
40  if($prev_next=='prev') {
41  $sql_cond .= " AND (pp.position<" . intval(vn($product_position)) . " OR (pp.position=" . intval(vn($product_position)) . " AND pp.id>" . intval($product_id) . "))";
42  $sql_order = "pp.position DESC, pp.id ASC";
43  } elseif($prev_next=='next') {
44  $sql_cond .= " AND (pp.position>" . intval(vn($product_position)) . " OR (pp.position=" . intval(vn($product_position)) . " AND pp.id<" . intval($product_id) . "))";
45  $sql_order = "pp.position ASC, pp.id DESC";
46  }
47  $sql_cond .= " AND pp.etat = 1 AND pp.on_gift = 0";
48  $sql = "SELECT ppc.produit_id AS id, ppc.categorie_id as idC, pp.nom_".(!empty($GLOBALS['site_parameters']['product_name_forced_lang'])?$GLOBALS['site_parameters']['product_name_forced_lang']:$_SESSION['session_langue'])." AS nom, pp.position
49  FROM peel_produits pp
50  INNER JOIN peel_produits_categories ppc ON ppc.produit_id = pp.id
51  INNER JOIN peel_categories pc ON ppc.categorie_id = pc.id AND pc.etat = 1 AND " . get_filter_site_cond('categories', 'pc') . "
52  WHERE ".$sql_cond." AND " . get_filter_site_cond('produits', 'pp') . "
53  ORDER BY ".$sql_order."
54  LIMIT 1";
55  $query = query($sql);
56  if($result = fetch_assoc($query)) {
57  if($prev_next=='prev') {
58  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/precedent_suivant_prev.tpl');
59  $tpl->assign('STR_PREV', $GLOBALS['STR_PREV']);
60  } elseif($prev_next=='next') {
61  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/precedent_suivant_next.tpl');
62  $tpl->assign('STR_NEXT', $GLOBALS['STR_NEXT']);
63  }
64  $tpl->assign('href', get_product_url($result['id'], $result['nom'], $result['idC'], get_name_category($result['idC'])));
65  $output .= $tpl->fetch();
66  }
67  return $output;
68 }
69 
70 /*
71  * @param integer idcat
72  * @param return
73  */
74 function get_name_category($idcat){
75  // On recupère le nom de la catégorie correspondant au produit actuel
76  $output="";
77  $sql='SELECT nom_'. $_SESSION['session_langue'] . ' AS nom
78  FROM peel_categories
79  WHERE id = "' . intval(vn($idcat)) . '" AND ' . get_filter_site_cond('categories') . '';
80  $result = query($sql);
81  if($data = fetch_assoc($result)){
82  $output .= $data['nom'];
83  }
84  return $output;
85 }
foreach(array('date1', 'date2', 'type', 'renewals', 'width') as $item) $data
Definition: chart-data.php:29
$result
get_name_category($idcat)
Definition: fonctions.php:74
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
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
get_category_tree_and_itself($id_or_ids_array, $mode= 'sons', $table_to_use= 'categories')
get_category_tree_and_itself()
Definition: fonctions.php:933
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(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
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
if(!defined('IN_PEEL')) show_preview_next($product_id, $product_position, $prev_next, $category_id)
show_preview_next()
Definition: fonctions.php:26
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.