PEEL Shopping
Open source ecommerce : PEEL Shopping
societe.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: societe.php 46935 2015-09-18 08:49:48Z gboussin $
14 
15 define('IN_PEEL_ADMIN', true);
16 include("../configuration.inc.php");
18 necessite_priv("admin_manage");
19 
20 $GLOBALS['DOC_TITLE'] = $GLOBALS['STR_ADMIN_SOCIETE_TITLE'];
21 $frm = $_POST;
23 
24 if (!isset($_REQUEST['mode']) && !empty($_SESSION['session_admin_multisite'])) {
25  $all_sites_name_array = get_all_sites_name_array();
26  if (count($all_sites_name_array) == 1) {
27  // Si il y a qu'un site configuré, on affiche directement la page de modification du site numéro défini par $_SESSION['session_admin_multisite'], sinon le site 1
28  if(isset($_SESSION['session_admin_multisite'])) {
29  redirect_and_die(get_current_url(false) . "?mode=modif&id=" . $_SESSION['session_admin_multisite']);
30  } else {
31  redirect_and_die(get_current_url(false) . "?mode=modif&id=1");
32  }
33  }
34 }
35 $output = '';
36 switch (vb($_REQUEST['mode'])) {
37  case "ajout" :
39  break;
40 
41  case "insere" :
42  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
43  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
44  }
45  if (!$form_error_object->count()) {
46  $output .= maj_societe($frm);
47  $output .= $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CONFIGURATION_MSG_CREATED'], vb($frm['nom_' . $_SESSION["session_langue"]]))))->fetch();
48  $output .= liste_societe($frm);
49  } else {
50  if ($form_error_object->has_error('token')) {
51  $output .= $form_error_object->text('token');
52  }
54  }
55  break;
56 
57  case "modif" :
58  $output .= affiche_formulaire_modif_societe(intval($_GET['id']), $frm);
59  break;
60 
61  case "maj" :
62  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
63  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
64  }
65  if (!$form_error_object->count()) {
66  $output .= maj_societe($frm);
68  } else {
69  if ($form_error_object->has_error('token')) {
70  $output .= $form_error_object->text('token');
71  }
72  $output .= affiche_formulaire_modif_societe(intval($frm['id']), $frm);
73  }
74  break;
75 
76  default :
77  $output .= liste_societe($frm);
78  break;
79 }
80 
81 include($GLOBALS['repertoire_modele'] . "/admin_haut.php");
82 echo $output;
83 include($GLOBALS['repertoire_modele'] . "/admin_bas.php");
84 
96 {
97  if(empty($frm)) {
98  $frm['societe'] = "";
99  $frm['nom_' . $_SESSION['session_langue']] = "";
100  $frm['prenom'] = "";
101  $frm['adresse1'] = "";
102  $frm['adresse2'] = "";
103  $frm['telephone'] = "";
104  $frm['telephone2'] = "";
105  $frm['fax'] = "";
106  $frm['fax2'] = "";
107  $frm['code_postal'] = "";
108  $frm['code_postal2'] = "";
109  $frm['ville'] = "";
110  $frm['ville2'] = "";
111  $frm['pays'] = "";
112  $frm['pays2'] = "";
113  $frm['siren'] = "";
114  $frm['tvaintra'] = "";
115  $frm['code_banque'] = "";
116  $frm['code_guichet'] = "";
117  $frm['numero_compte'] = "";
118  $frm['cle_rib'] = "";
119  $frm['titulaire'] = "";
120  $frm['numero_compte'] = "";
121  $frm['cnil'] = "";
122  $frm['iban'] = "";
123  $frm['swift'] = "";
124  $frm['fax'] = "";
125  }
126  $frm['nouveau_mode'] = "insere";
127  $frm['titre_soumet'] = $GLOBALS['STR_ADMIN_SOCIETE_UPDATE'];
128 
130 }
131 
140 {
141  if(empty($frm)) {
142  // Pas de données venant de validation de formulaire, donc on charge le contenu de la base de données
143  /* Récupère les informations de la societe */
144  $qid = query("SELECT *
145  FROM peel_societe
146  WHERE id = '" . intval($id) . "' AND " . get_filter_site_cond('societe', null, true) . "");
147  if (num_rows($qid) > 0) {
148  $frm = fetch_assoc($qid);
149  } else {
150  $frm = array();
151  }
152  }
153  if (!empty($frm)) {
154  $frm['nouveau_mode'] = "maj";
155  $frm['titre_soumet'] = $GLOBALS['STR_ADMIN_FORM_SAVE_CHANGES'];
157  } else {
158  redirect_and_die(get_current_url(false).'?mode=ajout');
159  }
160 }
161 
169 {
170  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_societe_form.tpl');
171  $tpl->assign('action', get_current_url(false));
172  $tpl->assign('form_token', get_form_token_input($_SERVER['PHP_SELF'] . $frm['nouveau_mode'] . intval(vb($frm['id']))));
173  $tpl->assign('mode', vb($frm['nouveau_mode']));
174  $tpl->assign('id', intval(vb($frm['id'])));
175  $tpl->assign('societe', vb($frm['societe']));
176  $tpl->assign('prenom', vb($frm['prenom']));
177  $tpl->assign('nom', vb($frm['nom']));
178  $tpl->assign('email', vb($frm['email']));
179  $tpl->assign('siteweb', vb($frm['siteweb']));
180  $tpl->assign('tel', vb($frm['tel']));
181  $tpl->assign('fax', vb($frm['fax']));
182  $tpl->assign('siren', vb($frm['siren']));
183  $tpl->assign('tvaintra', vb($frm['tvaintra']));
184  $tpl->assign('cnil', vb($frm['cnil']));
185  $tpl->assign('adresse', vb($frm['adresse']));
186  $tpl->assign('code_postal', vb($frm['code_postal']));
187  $tpl->assign('ville', vb($frm['ville']));
188  $tpl->assign('pays', vb($frm['pays']));
189  $tpl->assign('code_banque', vb($frm['code_banque']));
190  $tpl->assign('code_guichet', vb($frm['code_guichet']));
191  $tpl->assign('numero_compte', vb($frm['numero_compte']));
192  $tpl->assign('cle_rib', vb($frm['cle_rib']));
193  $tpl->assign('iban', vb($frm['iban']));
194  $tpl->assign('swift', vb($frm['swift']));
195  $tpl->assign('titulaire', vb($frm['titulaire']));
196  $tpl->assign('domiciliation', vb($frm['domiciliation']));
197  $tpl->assign('pays2', vb($frm['pays2']));
198  $tpl->assign('ville2', vb($frm['ville2']));
199  $tpl->assign('adresse2', vb($frm['adresse2']));
200  $tpl->assign('code_postal2', vb($frm['code_postal2']));
201  $tpl->assign('tel2', vb($frm['tel2']));
202  $tpl->assign('fax2', vb($frm['fax2']));
203  $tpl->assign('titre_soumet', vb($frm['titre_soumet']));
204  $tpl->assign('site_id_select_options', get_site_id_select_options(vb($frm['site_id'])));
205  $tpl->assign('site_id_select_multiple', !empty($GLOBALS['site_parameters']['multisite_using_array_for_site_id']));
206  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
207  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
208  $tpl->assign('STR_ADMIN_SOCIETE_FORM_COMPANY_PARAMETERS', $GLOBALS['STR_ADMIN_SOCIETE_FORM_COMPANY_PARAMETERS']);
209  $tpl->assign('STR_ADMIN_SOCIETE_FORM_EXPLAIN', $GLOBALS['STR_ADMIN_SOCIETE_FORM_EXPLAIN']);
210  $tpl->assign('STR_ADMIN_SOCIETE_FORM_SECOND_ADDRESS', $GLOBALS['STR_ADMIN_SOCIETE_FORM_SECOND_ADDRESS']);
211  $tpl->assign('STR_COUNTRY', $GLOBALS['STR_COUNTRY']);
212  $tpl->assign('STR_TOWN', $GLOBALS['STR_TOWN']);
213  $tpl->assign('STR_ADDRESS', $GLOBALS['STR_ADDRESS']);
214  $tpl->assign('STR_ZIP', $GLOBALS['STR_ZIP']);
215  $tpl->assign('STR_TELEPHONE', $GLOBALS['STR_TELEPHONE']);
216  $tpl->assign('STR_FAX', $GLOBALS['STR_FAX']);
217  $tpl->assign('STR_COMPANY', $GLOBALS['STR_COMPANY']);
218  $tpl->assign('STR_FIRST_NAME', $GLOBALS['STR_FIRST_NAME']);
219  $tpl->assign('STR_NAME', $GLOBALS['STR_NAME']);
220  $tpl->assign('STR_EMAIL', $GLOBALS['STR_EMAIL']);
221  $tpl->assign('STR_WEBSITE', $GLOBALS['STR_WEBSITE']);
222  $tpl->assign('STR_TELEPHONE', $GLOBALS['STR_TELEPHONE']);
223  $tpl->assign('STR_FAX', $GLOBALS['STR_FAX']);
224  $tpl->assign('STR_SIREN', $GLOBALS['STR_SIREN']);
225  $tpl->assign('STR_VAT_INTRACOM', $GLOBALS['STR_VAT_INTRACOM']);
226  $tpl->assign('STR_CNIL_NUMBER', $GLOBALS['STR_CNIL_NUMBER']);
227  $tpl->assign('STR_BANK_ACCOUNT_CODE', $GLOBALS['STR_BANK_ACCOUNT_CODE']);
228  $tpl->assign('STR_BANK_ACCOUNT_RIB', $GLOBALS['STR_BANK_ACCOUNT_RIB']);
229  $tpl->assign('STR_BANK_ACCOUNT_COUNTER', $GLOBALS['STR_BANK_ACCOUNT_COUNTER']);
230  $tpl->assign('STR_BANK_ACCOUNT_NUMBER', $GLOBALS['STR_BANK_ACCOUNT_NUMBER']);
231  $tpl->assign('STR_IBAN', $GLOBALS['STR_IBAN']);
232  $tpl->assign('STR_SWIFT', $GLOBALS['STR_SWIFT']);
233  $tpl->assign('STR_ACCOUNT_MASTER', $GLOBALS['STR_ACCOUNT_MASTER']);
234  $tpl->assign('STR_BANK_ACCOUNT_DOMICILIATION', $GLOBALS['STR_BANK_ACCOUNT_DOMICILIATION']);
235  return $tpl->fetch();
236 }
237 
244 function maj_societe($frm)
245 {
246  // get_filter_site_cond('configuration') => Ne pas utiliser le paramètre $use_admin_rights, il savoir si des informations sur la société relative au site $frm['site_id'] existe. Les droits de l'administrateur qui fait la demande ne sont pas à prendre en compte.
247  $sql_select = "SELECT *
248  FROM peel_societe
249  WHERE " . get_filter_site_cond('societe', null, false, $frm['site_id'], true) . "
250  LIMIT 1";
251  $query = query($sql_select);
252  if ($r = fetch_object($query)) {
253  $update = true;
254  } else {
255  $update = false;
256  }
257  $sql = "SET
258  societe = '" . nohtml_real_escape_string($frm['societe']) . "'
259  , prenom = '" . nohtml_real_escape_string($frm['prenom']) . "'
260  , nom = '" . nohtml_real_escape_string($frm['nom']) . "'
261  , tel = '" . nohtml_real_escape_string($frm['tel']) . "'
262  , fax = '" . nohtml_real_escape_string($frm['fax']) . "'
263  , tel2 = '" . nohtml_real_escape_string($frm['tel2']) . "'
264  , fax2 = '" . nohtml_real_escape_string($frm['fax2']) . "'
265  , email = '" . nohtml_real_escape_string($frm['email']) . "'
266  , adresse = '" . nohtml_real_escape_string($frm['adresse']) . "'
267  , adresse2 = '" . nohtml_real_escape_string($frm['adresse2']) . "'
268  , code_postal = '" . nohtml_real_escape_string($frm['code_postal']) . "'
269  , ville = '" . nohtml_real_escape_string($frm['ville']) . "'
270  , pays = '" . nohtml_real_escape_string($frm['pays']) . "'
271  , code_postal2 = '" . nohtml_real_escape_string($frm['code_postal2']) . "'
272  , ville2 = '" . nohtml_real_escape_string($frm['ville2']) . "'
273  , pays2 = '" . nohtml_real_escape_string($frm['pays2']) . "'
274  , siren = '" . nohtml_real_escape_string($frm['siren']) . "'
275  , tvaintra = '" . nohtml_real_escape_string($frm['tvaintra']) . "'
276  , siteweb = '" . nohtml_real_escape_string($frm['siteweb']) . "'
277  , code_banque = '" . nohtml_real_escape_string($frm['code_banque']) . "'
278  , code_guichet = '" . nohtml_real_escape_string($frm['code_guichet']) . "'
279  , numero_compte = '" . nohtml_real_escape_string($frm['numero_compte']) . "'
280  , cle_rib = '" . nohtml_real_escape_string($frm['cle_rib']) . "'
281  , titulaire = '" . nohtml_real_escape_string(String::strtoupper($frm['titulaire'])) . "'
282  , domiciliation = '" . nohtml_real_escape_string(String::strtoupper($frm['domiciliation'])) . "'
283  , cnil = '" . nohtml_real_escape_string($frm['cnil']) . "'
284  , iban = '" . nohtml_real_escape_string($frm['iban']) . "'
285  , swift = '" . nohtml_real_escape_string($frm['swift']) . "'
286  , site_id = '" . nohtml_real_escape_string(get_site_id_sql_set_value($frm['site_id'])) . "'";
287  if($update) {
288  $sql = "UPDATE peel_societe " . $sql . "
289  WHERE id = '" . intval($frm['id']) . "' AND " . get_filter_site_cond('societe', null, true);
290  } else {
291  // A FAIRE : Revérifier les droits sur site_id par l'administration avant de faire l'insertion
292  $sql = "INSERT INTO peel_societe " . $sql . "";
293  }
294  query($sql);
295  return $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_ADMIN_SOCIETE_MSG_UPDATED_OK']))->fetch();
296 }
297 
305 {
306  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_societe_liste.tpl');
307 
308  $tpl_results = array();
309  $query = query("SELECT *
310  FROM peel_societe
311  WHERE " . get_filter_site_cond('societe', null, true) . "
312  ORDER BY id DESC");
313  while ($r = fetch_object($query)) {
314  $tpl_results[] = array(
315  'drop_href' => get_current_url(false) . '?mode=suppr&id=' . $r->id,
316  'modif_href' => get_current_url(false) . '?mode=modif&id=' . $r->id,
317  'societe' => $r->societe,
318  'email' => $r->email
319  );
320  }
321  $tpl->assign('add_src', $GLOBALS['administrer_url'] . '/images/add.png');
322  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
323  $tpl->assign('edit_src', $GLOBALS['administrer_url'] . '/images/b_edit.png');
324  $tpl->assign('add_href', get_current_url(false) . '?mode=ajout');
325  $tpl->assign('results', $tpl_results);
326  $tpl->assign('STR_ADMIN_DELETE_WARNING', $GLOBALS['STR_ADMIN_DELETE_WARNING']);
327  $tpl->assign('STR_MODIFY', $GLOBALS['STR_MODIFY']);
328  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
329  $tpl->assign('STR_ADMIN_ACTION', $GLOBALS['STR_ADMIN_ACTION']);
330  $tpl->assign('STR_ADMIN_SOCIETE_LIST_TITLE', $GLOBALS['STR_ADMIN_SOCIETE_LIST_TITLE']);
331  $tpl->assign('STR_COMPANY', $GLOBALS['STR_COMPANY']);
332  $tpl->assign('STR_EMAIL', $GLOBALS['STR_EMAIL']);
333  $tpl->assign('STR_ADMIN_MENU_MANAGE_WEBMAIL_SEND', $GLOBALS['STR_ADMIN_MENU_MANAGE_WEBMAIL_SEND']);
334  $tpl->assign('STR_ADMIN_ADD', $GLOBALS['STR_ADMIN_ADD']);
335 
336  return $tpl->fetch();
337 }
static strtoupper($string)
Returns string with all alphabetic characters converted to uppercase.
Definition: String.php:154
liste_societe($frm)
Affiche la liste de sociétés (CODE INUTILISE - A ADAPTER SI ON VEUT L'UTILISER)
Definition: societe.php:304
affiche_formulaire_modif_societe($id, &$frm)
Affiche un formulaire vide pour modifier un societe.
Definition: societe.php:139
maj_societe($frm)
maj_societe()
Definition: societe.php:244
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
$GLOBALS['DOC_TITLE']
Definition: societe.php:20
redirect_and_die($url, $permanent_redirection=false, $avoid_loop=false)
Redirige vers l'URL demandée et arrête le programme.
Definition: fonctions.php:1551
if(!isset($_REQUEST['mode'])&&!empty($_SESSION['session_admin_multisite'])) $output
Definition: societe.php:35
get_site_id_select_options($selected_site_id=null, $selected_site_name=null, $display_first_option=null, $select_current_site_id_by_default=false)
Créer les options pour le select qui liste les noms de sites configurés en back office.
$form_error_object
Definition: societe.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
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
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
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_object($query_result)
fetch_object()
Definition: database.php:302
$frm
Definition: societe.php:21
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
get_all_sites_name_array($admin_force_multisite_if_allowed=false, $allow_null_site_id=false, $skip_rights_check=false)
Retourne un tableau des noms des sites configurés en fonction des droits de l'administrateur.
Definition: fonctions.php:4792
affiche_formulaire_societe(&$frm)
Affiche le formulaire pour modifier un societe.
Definition: societe.php:168
get_form_token_input($name= 'general', $use_existing_token=true, $return_as_input_form=true)
get_form_token_input()
Definition: fonctions.php:94
get_site_id_sql_set_value($site_ids)
Retourne la valeur SQL d'un champ INT ou SET suivant que ce soit un entier ou un tableau.
Definition: fonctions.php:4747
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
$id
Definition: articles.php:22
afficher_formulaire_ajout_societe()
FONCTIONS.
Definition: societe.php:95
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:35 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.