PEEL Shopping
Open source ecommerce : PEEL Shopping
prix_pourcentage.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: prix_pourcentage.php 46935 2015-09-18 08:49:48Z gboussin $
14 define('IN_PEEL_ADMIN', true);
15 include("../configuration.inc.php");
17 necessite_priv("admin_products");
18 
19 $GLOBALS['DOC_TITLE'] = $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_TITLE'];
20 include($GLOBALS['repertoire_modele'] . "/admin_haut.php");
21 
22 if (!empty($_POST['submit']) && !empty($_POST['operation']) && !empty($_POST['percent_prod']) && is_numeric($_POST['percent_prod']) && !empty($_POST['for_price'])) {
23  if (!verify_token($_SERVER['PHP_SELF'])) {
24  echo $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_INVALID_TOKEN']))->fetch();
25  } else {
26  if ($_POST['operation'] == 'minus') {
27  $operation_symbol = '-';
28  } else {
29  $operation_symbol = '+';
30  }
31  $percent_prod_to_apply = get_float_from_user_input($_POST['percent_prod']) / 100;
32 
33  switch ($_POST['for_price']) {
34  case "all" :
35  $sql_set = "prix = prix * (1 " . $operation_symbol . " " . floatval($percent_prod_to_apply) . "), prix_revendeur = prix_revendeur * (1 " . $operation_symbol . " " . floatval($percent_prod_to_apply) . ")";
36  break;
37 
38  case "1" :
39  $sql_set = "prix = prix * (1 " . $operation_symbol . " " . floatval($percent_prod_to_apply) . ")";
40  break;
41 
42  case "2" :
43  $sql_set = "prix_revendeur = prix_revendeur * (1 " . $operation_symbol . " " . floatval($percent_prod_to_apply) . ")";
44  break;
45 
46  default:
47  $sql_set = "prix = prix * (1 " . $operation_symbol . " " . floatval($percent_prod_to_apply) . "), prix_revendeur = prix_revendeur * (1 " . $operation_symbol . " " . floatval($percent_prod_to_apply) . ")";
48  break;
49  }
50  if (!empty($_POST['categories'])) {
51  if (!in_array('all', $_POST['categories'])) {
52  $sql_where = "id IN (SELECT produit_id FROM peel_produits_categories WHERE categorie_id IN (" . nohtml_real_escape_string(implode(',', get_category_tree_and_itself($_POST['categories'], 'sons'))) . "))";
53  } else {
54  $sql_where = '1';
55  }
56  query ('UPDATE peel_produits
57  SET ' . $sql_set . '
58  WHERE ' . get_filter_site_cond('produits', null, true) .' AND ' . $sql_where);
59  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_MSG_UPDATE_OK']))->fetch();
60  } elseif (!empty($_POST['produits'])) {
61  if (!in_array('all', $_POST['produits'])) {
62  $sql_where = ' id IN ("' . implode('","', nohtml_real_escape_string($_POST['produits'])) . '")';
63  } else {
64  $sql_where = ' 1';
65  }
66  query('UPDATE peel_produits
67  SET ' . $sql_set . '
68  WHERE ' . get_filter_site_cond('produits', null, true) .' AND ' . $sql_where);
69  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_MSG_UPDATE_OK']))->fetch();
70  } else {
71  echo $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_CHOOSE_ITEM']))->fetch();
72  }
73  }
74 } else {
75  if (isset($_POST['submit'])) {
76  echo $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_ERR_FORM']))->fetch();
77  }
78 }
79 $tpl = $GLOBALS['tplEngine']->createTemplate('admin_prix_pourcentage.tpl');
80 $tpl->assign('action', get_current_url(false));
81 $tpl->assign('form_token', get_form_token_input($_SERVER['PHP_SELF']));
83 $tpl_cats_options[] = array('value' => 'all',
84  'issel' => !empty($_POST['categories']) && in_array('all', vb($_POST['categories'])),
85  'name' => String::strtoupper($GLOBALS["STR_ADMIN_ALL_CATEGORIES"])
86  );
87 $q_select_cats = query('SELECT id, nom_' . $_SESSION['session_langue'] . '
88  FROM peel_categories
89  WHERE etat = "1" AND ' . get_filter_site_cond('categories') . '
90  ORDER BY nom_' . $_SESSION['session_langue'] . '');
91 while ($r_select_cats = fetch_assoc($q_select_cats)) {
92  $tpl_cats_options[] = array('value' => intval($r_select_cats['id']),
93  'issel' => !empty($_POST['categories']) && in_array($r_select_cats['id'], vb($_POST['categories'])),
94  'name' => (!empty($r_select_cats['nom_' . $_SESSION['session_langue']])?$r_select_cats['nom_' . $_SESSION['session_langue']]:'['.$r_select_cats['id'].']')
95  );
96 }
97 $tpl->assign('cats_options', $tpl_cats_options);
98 
99 $tpl->assign('nb_produits', 0);
100 $tpl->assign('for_price', vb($_POST['for_price']));
101 $tpl->assign('percent_prod', vb($_POST['percent_prod']));
102 $tpl->assign('operation', vb($_POST['operation']));
103 $tpl->assign('administrer_url', $GLOBALS['administrer_url']);
104 $tpl->assign('STR_DELETE', $GLOBALS['STR_DELETE']);
105 $tpl->assign('STR_VALIDATE', $GLOBALS['STR_VALIDATE']);
106 $tpl->assign('STR_CHOOSE', $GLOBALS['STR_CHOOSE']);
107 $tpl->assign('STR_OR', $GLOBALS['STR_OR']);
108 $tpl->assign('STR_ADMIN_NAME', $GLOBALS['STR_ADMIN_NAME']);
109 $tpl->assign('STR_REFERENCE', $GLOBALS['STR_REFERENCE']);
110 $tpl->assign('STR_ADMIN_COMMANDER_OR_ADD_PRODUCT_WITH_FAST_SEARCH', $GLOBALS['STR_ADMIN_COMMANDER_OR_ADD_PRODUCT_WITH_FAST_SEARCH']);
111 $tpl->assign('STR_ADMIN_PRODUCT_ORDERED_DELETE_CONFIRM', $GLOBALS['STR_ADMIN_PRODUCT_ORDERED_DELETE_CONFIRM']);
112 $tpl->assign('STR_ADMIN_PRODUCT_ORDERED_DELETE', $GLOBALS['STR_ADMIN_PRODUCT_ORDERED_DELETE']);
113 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_TITLE', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_TITLE']);
114 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_EXPLAIN', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_EXPLAIN']);
115 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_CHOOSE_CATEGORY', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_CHOOSE_CATEGORY']);
116 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_CHOOSE_PRODUCT', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_CHOOSE_PRODUCT']);
117 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_USERS_RELATED', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_USERS_RELATED']);
118 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_ENTER_PERCENTAGE', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_ENTER_PERCENTAGE']);
119 $tpl->assign('STR_ADMIN_ALL', $GLOBALS['STR_ADMIN_ALL']);
120 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_CLIENTS_ONLY', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_CLIENTS_ONLY']);
121 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_RESELLERS_ONLY', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_RESELLERS_ONLY']);
122 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_LOWER', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_LOWER']);
123 $tpl->assign('STR_ADMIN_PRIX_POURCENTAGE_RAISE', $GLOBALS['STR_ADMIN_PRIX_POURCENTAGE_RAISE']);
124 $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
125 echo $tpl->fetch();
126 
127 include($GLOBALS['repertoire_modele'] . "/admin_bas.php");
128 
static strtoupper($string)
Returns string with all alphabetic characters converted to uppercase.
Definition: String.php:154
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
$tpl_cats_options
$GLOBALS['DOC_TITLE']
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
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
$q_select_cats
get_float_from_user_input($string, $from_currency_rate=1)
Transforme tout nombre formaté en un float au format PHP Exemples : 12 004,34 ou 12,324.50.
Definition: format.php:196
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
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
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
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
get_form_token_input($name= 'general', $use_existing_token=true, $return_as_input_form=true)
get_form_token_input()
Definition: fonctions.php:94
verify_token($name= 'general', $delay_in_minutes=60, $check_referer_if_set_by_server=true, $cancel_token=true, $minimum_wait_in_seconds_before_use=0)
Vérification de la validité d'un token Par défaut, un token est valide 1h, et utilisable 1 seule fois...
Definition: fonctions.php:118
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:29:21 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.