PEEL Shopping
Open source ecommerce : PEEL Shopping
ProductsBought.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: ProductsBought.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 
28  var $nom;
29  var $couleur;
30  var $lien;
36  function ProductsBought($obj)
37  {
38  foreach(get_object_vars($obj) as $name => $val) {
39  if ($name == 'nom_' . $_SESSION['session_langue'] || $name == 'nom_produit') {
40  $name = 'nom';
41  } elseif ($name == 'couleur' && !empty($val)) {
42  $val = "Couleur : " . $val;
43  }
44  $this->$name = $val;
45  }
46  if (!empty($this->in_catalog)) {
47  $this->lien = '<a href="' . $GLOBALS['administrer_url'] . '/produits.php?mode=modif&amp;id=' . $this->produit_id . '">' . $this->nom . '</a>';
48  } else {
49  $this->lien = $this->nom . ' ('.$GLOBALS["STR_ADMIN_PRODUITS_NO_MORE_IN_CATALOG"].')';
50  }
51  $this->lien .= ' - ' . $this->couleur . ' - <a href="' . get_current_url(false) . '?id=' . $this->produit_id . '">'.$GLOBALS["STR_ADMIN_PRODUITS_BUYERS_LIST"].'</a>';
52  }
53 
61  function _sql_de_base($id = null, $limit = 500)
62  {
63  $sql = "SELECT ca.produit_id,
64  ca.commande_id,
65  ca.nom_produit,
66  ca.couleur,
67  ca.taille,
68  SUM( ca.quantite ) AS quantite_totale,
69  SUM( ca.total_prix ) AS montant_total,
70  IF(p.id IS NOT NULL, 1,0) AS in_catalog
71  FROM peel_commandes_articles ca
72  INNER JOIN peel_commandes c ON ca.commande_id = c.id AND " . get_filter_site_cond('commandes', 'c', true) . "
73  INNER JOIN peel_statut_paiement sp ON sp.id=c.id_statut_paiement AND " . get_filter_site_cond('statut_paiement', 'sp') . "
74  LEFT JOIN peel_produits p ON p.id = ca.produit_id AND " . get_filter_site_cond('produits', 'p') . "
75  WHERE " . get_filter_site_cond('commandes_articles', 'ca', true) . "
76  AND sp.technical_code IN ('being_checked','completed')
77  AND ca.quantite > '0'
78  " . (!empty($id)?" AND ca.produit_id='" . intval($id) . "'":"") . "
79  GROUP BY IF(ca.produit_id>0,ca.produit_id,ca.nom_produit), ca.couleur, ca.taille
80  ORDER BY quantite_totale DESC
81  LIMIT " . intval($limit);
82  return $sql;
83  }
84 
91  function find($id)
92  {
93  $ret = null;
95  if (!$req) {
96  return null;
97  }
98  $ret = fetch_object($req);
99  if ($ret) {
100  $ret = new ProductsBought($ret);
101  }
102  return $ret;
103  }
104 
111  function find_all($limit = 500)
112  {
113  $ret = array();
114  $req = query(ProductsBought::_sql_de_base(null, $limit));
115  while ($tmp = fetch_object($req)) {
116  $ret[] = new ProductsBought($tmp);
117  }
118  return $ret;
119  }
120 
126  function clients()
127  {
128  $ret = array();
129  $req = query("SELECT u.*,
130  SUM(ca.total_prix) AS total_paye,
131  SUM(ca.quantite) AS total_quantite
132  FROM peel_utilisateurs u
133  RIGHT JOIN peel_commandes c ON c.id_utilisateur = u.id_utilisateur AND " . get_filter_site_cond('commandes', 'c', true) . "
134  INNER JOIN peel_statut_paiement sp ON sp.id=c.id_statut_paiement AND " . get_filter_site_cond('statut_paiement', 'sp') . "
135  INNER JOIN peel_commandes_articles ca ON ca.commande_id=c.id AND " . get_filter_site_cond('commandes_articles', 'ca', true) . "
136  WHERE ca.produit_id = " . intval($this->produit_id) . " AND ca.quantite > 0 AND sp.technical_code IN ('being_checked','completed') AND " . get_filter_site_cond('utilisateurs', 'u', true) . "
137  GROUP BY u.id_utilisateur");
138  while ($tmp = fetch_object($req)) {
139  $ret[] = $tmp;
140  }
141  return $ret;
142  }
143 }
144 
clients()
ProductsBought::clients()
find_all($limit=500)
ProductsBought::find_all()
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
_sql_de_base($id=null, $limit=500)
ProductsBought::_sql_de_base()
ProductsBought($obj)
ProductsBought::ProductsBought()
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
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_object($query_result)
fetch_object()
Definition: database.php:302
find($id)
ProductsBought::find()
$GLOBALS['page_columns_count']
$req
Definition: ipn.php:30
$id
Definition: articles.php:22
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:07 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.