PEEL Shopping
Open source ecommerce : PEEL Shopping
kekoli.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: kekoli.php 46935 2015-09-18 08:49:48Z gboussin $
14 
15 define('IN_PEEL_ADMIN', true);
16 include("../../../configuration.inc.php");
17 include("fonctions.php");
19 necessite_priv("admin_sales,admin_webmastering");
20 
21 $GLOBALS['DOC_TITLE'] = $GLOBALS['STR_MODULE_KEKOLI_ADMIN_TITLE'];
22 $output = '';
23 
24 $tpl = $GLOBALS['tplEngine']->createTemplate('admin_ventes_information_select.tpl');
25 $tpl->assign('payment_status_options', get_payment_status_options(vb($_GET['statut'])));
26 $tpl->assign('STR_ORDER_STATUT_PAIEMENT', $GLOBALS['STR_ORDER_STATUT_PAIEMENT']);
27 $tpl->assign('STR_ADMIN_ALL_ORDERS', $GLOBALS['STR_ADMIN_ALL_ORDERS']);
29 $output .= get_admin_date_filter_form($GLOBALS['STR_MODULE_KEKOLI_ADMIN_RESULTS_TITLE'], $information_select_html);
30 
31 // PROCESS
32 if (isset($_GET['jour1']) or isset($dateAdded1)) {
33  $check_admin_date_data = check_admin_date_data($_GET);
34  if (empty($check_admin_date_data)) {
35  $dateAdded1 = $_GET['an1'] . '-' . str_pad($_GET['mois1'], 2, 0, STR_PAD_LEFT) . '-' . str_pad($_GET['jour1'], 2, 0, STR_PAD_LEFT) . " 00:00:00";
36  $dateAdded2 = $_GET['an2'] . '-' . str_pad($_GET['mois2'], 2, 0, STR_PAD_LEFT) . '-' . str_pad($_GET['jour2'], 2, 0, STR_PAD_LEFT) . " 23:59:59";
37  if (vb($_GET['order_date_field_filter']) == 'a_timestamp') {
38  $date_field = "a_timestamp";
39  } elseif (vb($_GET['order_date_field_filter']) == 'e_datetime') {
40  $date_field = "e_datetime";
41  } elseif (vb($_GET['order_date_field_filter']) == 'f_datetime') {
42  $date_field = "f_datetime";
43  } else {
44  $date_field = "o_timestamp";
45  }
46  $sql = "SELECT c.*, sp.nom_" . $_SESSION['session_langue'] . " AS statut_paiement
47  FROM peel_commandes c
48  LEFT JOIN peel_statut_paiement sp ON c.id_statut_paiement=sp.id AND " . get_filter_site_cond('statut_paiement', 'sp') . "
49  LEFT JOIN peel_types t ON t.id=c.typeId AND " . get_filter_site_cond('types', 't') . "
50  WHERE " . get_filter_site_cond('commandes', 'c', true) . " AND t.without_delivery_address!='1' AND c." . word_real_escape_string($date_field) . ">='" . nohtml_real_escape_string($dateAdded1) . "' AND c." . word_real_escape_string($date_field) . "<='" . nohtml_real_escape_string($dateAdded2) . "'";
51  if (isset($_GET['statut']) && is_numeric($_GET['statut'])) {
52  $sql .= " AND c.id_statut_paiement = '" . intval($_GET['statut']) . "'";
53  $extra_csv_param = "&id_statut_paiement=" . intval($_GET['statut']);
54  } else {
55  $extra_csv_param = '';
56  }
57  $sql .= "
58  ORDER BY c." . word_real_escape_string($date_field);
59  $query = query($sql);
60 
61  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_ventes.tpl');
62  $tpl->assign('period_text', ucfirst($GLOBALS['strStartingOn']) . ' ' . get_formatted_date($dateAdded1) . ' ' . $GLOBALS['strTillDay'] . ' ' . get_formatted_date($dateAdded2));
63  if (num_rows($query) > 0) {
64  $tpl_results = array();
65 
66  $totalVente = $totalVenteHt = 0;
67  $totalTransport = 0;
68  $netapayer = 0;
69  $totalAvoir = 0;
70  $totalTva = $totalTvaTransport = 0;
71  $i = 1;
72  while ($result = fetch_assoc($query)) {
73  $totalVente += $result['montant']+$result['avoir'];
74  $netapayer += $result['montant'];
75  $totalAvoir += $result['avoir'];
76  $totalVenteHt += $result['montant_ht'];
77  $totalTransport += $result['cout_transport'];
78  $totalTva += $result['total_tva'];
79  $totalTvaTransport += $result['tva_cout_transport'];
80  $vat_arrays[] = get_vat_array($result['code_facture']);
81  $avoir_devise_commande = '';
82  $montant_devise_commande = '';
83  $netapayer_devise_commande = '';
84  $montant_ht_devise_commande = '';
85  $total_tva_devise_commande = '';
86  $cout_transport_devise_commande = '';
87  if ($result['devise'] != $GLOBALS['site_parameters']['code']) {
88  // Si la devise de la commande est différente de la devise de l'admin alors on affiche le prix dans la devise de la commande en plus
89  $avoir_devise_commande = '(' . fprix($result['avoir'], true, $result['devise'], true, $result['currency_rate']) . ')';
90  $montant_devise_commande = '(' . fprix($result['montant']+$result['avoir'], true, $result['devise'], true, $result['currency_rate']) . ')';
91  $netapayer_devise_commande = '(' . fprix($result['montant'], true, $result['devise'], true, $result['currency_rate']) . ')';
92  $montant_ht_devise_commande = '(' . fprix($result['montant_ht'], true, $result['devise'], true, $result['currency_rate']) . ')';
93  $total_tva_devise_commande = '(' . fprix($result['total_tva'], true, $result['devise'], true, $result['currency_rate']) . ')';
94  if ($result['cout_transport'] != 0) {
95  // Si les frais de port ne sont pas nuls alors on affiche le prix dans la devise de la commande pour éviter un doublon
96  $cout_transport_devise_commande = '(' . fprix($result['cout_transport'], true, $result['devise'], true, $result['currency_rate']) . ')';
97  }
98  }
99  $tpl_results[] = array('tr_rollover' => tr_rollover($i, true),
100  'date' => get_formatted_date($result['o_timestamp']),
101  'id' => $result['id'],
102  'modif_href' => $GLOBALS['administrer_url'] . '/commander.php?commandeid=' . $result['id'] . '&mode=modif',
103  'statut_paiement' => $result['statut_paiement'],
104  'email' => $result['email'],
105  'montant_ht_prix' => fprix($result['montant_ht'], true, $GLOBALS['site_parameters']['code'], false),
106  'montant_ht_devise_commande' => $montant_ht_devise_commande,
107  'total_tva_prix' => fprix($result['total_tva'], true, $GLOBALS['site_parameters']['code'], false),
108  'total_tva_devise_commande' => $total_tva_devise_commande,
109  'montant_prix' => fprix($result['montant']+$result['avoir'], true, $GLOBALS['site_parameters']['code'], false),
110  'montant_devise_commande' => $montant_devise_commande,
111  'netapayer' => fprix($result['montant'], true, $GLOBALS['site_parameters']['code'], false),
112  'netapayer_devise_commande' => $netapayer_devise_commande,
113  'avoir' => fprix($result['avoir'], true, $GLOBALS['site_parameters']['code'], false),
114  'avoir_devise_commande' => $avoir_devise_commande,
115  'cout_transport_prix' => fprix($result['cout_transport'], true, $GLOBALS['site_parameters']['code'], false),
116  'cout_transport_devise_commande' => $cout_transport_devise_commande,
117  );
118  $i++;
119  }
120  $tpl->assign('results', $tpl_results);
121  foreach ($vat_arrays as $this_vat_array) {
122  foreach ($this_vat_array as $this_vat_rate => $this_amount) {
123  if (!isset($total_vat_array[$this_vat_rate])) {
124  $total_vat_array[$this_vat_rate] = $this_amount;
125  } else {
126  $total_vat_array[$this_vat_rate] += $this_amount;
127  }
128  }
129  }
130  $tpl_vats = array();
131  if(!empty($total_vat_array)) {
132  ksort($total_vat_array);
133  foreach ($total_vat_array as $this_vat_rate => $this_amount) {
134  $tpl_vats[] = array('rate' => $this_vat_rate,
135  'prix' => fprix($this_amount, true, $GLOBALS['site_parameters']['code'], false)
136  );
137  }
138  }
139  $tpl->assign('vats', $tpl_vats);
140  $tpl->assign('totalVenteHt_prix', fprix($totalVenteHt, true, $GLOBALS['site_parameters']['code'], false));
141  $tpl->assign('totalTva_prix', fprix($totalTva, true, $GLOBALS['site_parameters']['code'], false));
142  $tpl->assign('totalVente_prix', fprix($totalVente, true, $GLOBALS['site_parameters']['code'], false));
143  $tpl->assign('totalNet_a_payer', fprix($netapayer, true, $GLOBALS['site_parameters']['code'], false));
144  $tpl->assign('total_avoir', fprix($totalAvoir, true, $GLOBALS['site_parameters']['code'], false));
145  $tpl->assign('totalTransport_prix', fprix($totalTransport, true, $GLOBALS['site_parameters']['code'], false));
146  $tpl->assign('is_module_export_ventes_active', check_if_module_active('export', 'administrer/export_ventes.php'));
147  $tpl->assign('export_href', $GLOBALS['wwwroot_in_admin'] . '/modules/export/administrer/export_ventes.php?dateadded1=' . $dateAdded1 . '&dateadded2=' . $dateAdded2 . $extra_csv_param);
148  $tpl->assign('export_href_one_line_per_order', $GLOBALS['wwwroot_in_admin'] . '/modules/export/administrer/export_ventes.php?mode=one_line_per_order&dateadded1=' . $dateAdded1 . '&dateadded2=' . $dateAdded2 . $extra_csv_param);
149  $tpl->assign('excel_src', $GLOBALS['administrer_url'] . '/images/excel.jpg');
150 
151  if (!empty($_GET['statut'])) {
152  $tpl->assign('payment_status_name', get_payment_status_name($_GET['statut']));
153  }
154  } else {
155  $tpl->assign('are_results', false);
156  }
157  $tpl->assign('only_delivered', true);
158 
159  $tpl->assign('STR_TTC', $GLOBALS['STR_TTC']);
160  $tpl->assign('STR_HT', $GLOBALS['STR_HT']);
161  $tpl->assign('STR_PDF_AVOIR', $GLOBALS['STR_PDF_AVOIR']);
162  $tpl->assign('STR_PDF_NET', $GLOBALS['STR_PDF_NET']);
163  $tpl->assign('STR_ADMIN_VENTES_FORM_EXPLAIN', $GLOBALS['STR_ADMIN_VENTES_FORM_EXPLAIN']);
164  $tpl->assign('STR_DATE', $GLOBALS['STR_DATE']);
165  $tpl->assign('STR_ORDER_NAME', $GLOBALS['STR_ORDER_NAME']);
166  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
167  $tpl->assign('STR_EMAIL', $GLOBALS['STR_EMAIL']);
168  $tpl->assign('STR_AMOUNT', $GLOBALS['STR_AMOUNT']);
169  $tpl->assign('STR_VAT', $GLOBALS['STR_VAT']);
170  $tpl->assign('STR_AMOUNT', $GLOBALS['STR_AMOUNT']);
171  $tpl->assign('STR_ADMIN_INCLUDING_DELIVERY_COST', $GLOBALS['STR_ADMIN_INCLUDING_DELIVERY_COST']);
172  $tpl->assign('STR_ADMIN_BILL_TOTALS', $GLOBALS['STR_ADMIN_BILL_TOTALS']);
173  $tpl->assign('STR_ADMIN_TOTAL_VAT', $GLOBALS['STR_ADMIN_TOTAL_VAT']);
174  $tpl->assign('STR_ADMIN_VENTES_EXPORT_EXCEL', $GLOBALS['STR_MODULE_KEKOLI_ADMIN_EXPORT_EXCEL']);
175  $tpl->assign('STR_ADMIN_VENTES_EXPORT_EXCEL_ONE_LINE_PER_ORDER', $GLOBALS['STR_ADMIN_VENTES_EXPORT_EXCEL_ONE_LINE_PER_ORDER']);
176  $tpl->assign('STR_ADMIN_ASKED_STATUS', $GLOBALS['STR_ADMIN_ASKED_STATUS']);
177  $tpl->assign('STR_ADMIN_ALL_ORDERS', $GLOBALS['STR_ADMIN_ALL_ORDERS']);
178  $tpl->assign('STR_ADMIN_VENTES_NO_ORDER_FOUND', $GLOBALS['STR_ADMIN_VENTES_NO_ORDER_FOUND']);
179  $tpl->assign('STR_MODULE_KEKOLI_ADMIN_ONLY_DELIVERED', $GLOBALS["STR_MODULE_KEKOLI_ADMIN_ONLY_DELIVERED"]);
180  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
181  $output .= $tpl->fetch();
182  } else {
183  $output .= $check_admin_date_data;
184  }
185 }
186 include($GLOBALS['repertoire_modele'] . "/admin_haut.php");
187 echo $output;
188 include($GLOBALS['repertoire_modele'] . "/admin_bas.php");
189 
get_payment_status_name($id)
get_payment_status_name()
Definition: order.php:1065
$tpl
Definition: kekoli.php:24
$result
$netapayer
get_vat_array($code_facture)
Fonction permettant l'affichage des taux de TVA dans les factures.
Definition: order.php:1272
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
get_payment_status_options($selected_status_id=null)
get_payment_status_options()
$output
Definition: kekoli.php:22
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
Definition: database.php:400
necessite_priv($priv, $demo_allowed=true, $configuration_modification=false)
Cette fonction vérifie si l'utilisateur a les privilèges de $priv.
Definition: fonctions.php:1575
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
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
necessite_identification()
Si l'utilisateur n'est pas connecté à un compte, on affiche une page d'identification et arrête le sc...
Definition: fonctions.php:1596
num_rows($query_result)
num_rows()
Definition: database.php:321
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
get_formatted_date($datetime_or_timestamp=null, $mode= 'short', $hour_minute=false)
Afficher une date formatée, en évitant les problèmes liés aux noms de mois sur les serveurs qui ne so...
Definition: format.php:440
$information_select_html
Definition: kekoli.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...
$GLOBALS['DOC_TITLE']
Definition: kekoli.php:21
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:41:32 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.