-
Notifications
You must be signed in to change notification settings - Fork 0
/
pays.php
303 lines (243 loc) · 10.1 KB
/
pays.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?php
/*************************************************************************************/
/* */
/* Thelia - Gestion des pays depuis le back office */
/* */
/* Copyright (c) 2009-2001, Franck Allimant, CQFDev */
/* email : contact@cqfdev.fr */
/* web : http://www.cqfdev.fr */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/*************************************************************************************/
require_once("pre.php");
require_once("auth.php");
if(! est_autorise("acces_configuration")) exit;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php require_once("title.php");?>
</head>
<body>
<div id="wrapper">
<div id="subwrapper">
<?php
$menu="configuration";
require_once("entete.php");
class AdmGestionpays
{
function __construct()
{
}
function ajouter()
{
}
function supprimer()
{
$id = intval(lireParam('pays', 'int'));
mysql_query("delete from pays where id=$id");
mysql_query("delete from paysdesc where pays=$id");
}
function edition()
{
$id = intval(lireParam('pays', 'int'));
$maj = ($id > 0);
$pays = new Pays();
if ($maj)
$pays->charger($id);
else
{
$pays->lang = 0;
$pays->defaut = 0;
}
$pays->tva = intval($_REQUEST['tva']) != 0 ? 1 : 0;
$pays->zone = intval($_REQUEST['zone']);
$pays->isocode = intval($_REQUEST['isocode']);
$pays->isoalpha2 = $_REQUEST['isoalpha2'];
$pays->isoalpha3 = $_REQUEST['isoalpha3'];
if ($maj)
$pays->maj();
else
$id = $pays->add();
if ($id > 0)
{
foreach($_REQUEST['langue'] as $langue)
{
$paysdesc = new Paysdesc();
if ($maj) $paysdesc->charger($id, $langue);
$paysdesc->pays = $id;
$paysdesc->lang = $langue;
$paysdesc->titre = $_REQUEST['titre'][$langue];
$paysdesc->chapo = $_REQUEST['chapo'][$langue];
$paysdesc->description = $_REQUEST['description'][$langue];
if ($maj)
$paysdesc->maj();
else
$paysdesc->add();
}
}
}
function prepare_page()
{
}
}
$adm = new AdmGestionpays();
$commande = lireParam('commande', 'string');
switch($commande)
{
case 'edition' :
$adm->edition();
break;
case 'supprimer' :
$adm->supprimer();
break;
}
$adm->prepare_page();
?>
<script type="text/javascript">
var ajaxurl = 'ajax/pays.php';
function supprimer_pays(id)
{
if (confirm("<?php echo trad('Supprimer définitivement ce pays ?', 'admin'); ?>"))
{
$('#commande').val('supprimer');
$('#pays').val(id);
$('#offset').val($('#scroller').scrollTop());
$('#pays_form').submit();
}
return false;
}
function change_tva(id)
{
jQuery.ajax({
url: ajaxurl,
type:'POST',
data: { action: 'tva', pays: id, tva: ($('input[name=tva-'+id+']').attr('checked') ? '1' : '0') },
async: false
})
}
function change_defaut(id)
{
jQuery.ajax({
url: ajaxurl,
type:'POST',
data: { action: 'defaut', pays: id },
async: false
})
}
function change_boutique(id)
{
jQuery.ajax({
url: ajaxurl,
type:'POST',
data: { action: 'boutique', pays: id },
async: false
})
}
function nouveau()
{
$('.bloc_modif_pays').hide();
$('.bloc_load_pays').show();
$('.bloc_modif_pays').load(ajaxurl, {}, function() {
$('.bloc_load_pays').hide();
$('.bloc_modif_pays').show();
});
}
function modifier(id, link)
{
$('.bloc_modif_pays').hide();
$('.bloc_load_pays').show();
$('.bloc_modif_pays').load(ajaxurl, {pays: id, offset: $('#scroller').scrollTop()}, function() {
$('.bloc_load_pays').hide();
$('.bloc_modif_pays').show();
});
}
$(document).ready(function() {
// Scroller vers le dernier element modifié/supprime
<?php if (isset($_REQUEST['offset'])) { ?>
$('#scroller').scrollTop(<?php echo $_REQUEST['offset'] ?>);
<?php } ?>
});
</script>
<style type="text/css">
#contenu_int table th {
height: 30px;
font-weight: bold;
}
</style>
<div id="contenu_int">
<p align="left"><a href="index.php" class="lien04"><?php echo trad('Accueil', 'admin'); ?></a> <img src="gfx/suivant.gif" width="12" height="9" border="0" /><a href="configuration.php" class="lien04"> <?php echo trad('Configuration', 'admin'); ?></a> <img src="gfx/suivant.gif" width="12" height="9" border="0" /><a href="pays.php" class="lien04"><?php echo trad('Gestion des pays', 'admin'); ?></a></p>
<div id="bloc_description">
<div class="entete_liste_config">
<div class="titre"><?php echo trad('GESTION DES PAYS', 'admin'); ?></div>
<div class="fonction_ajout"><a href="#" onclick="nouveau(); return false;"><?php echo trad('NOUVEAU', 'admin'); ?></a></div>
</div>
<div id="scroller" style="border: 1px solid #9DACB6; border-top: none; height: 571px; overflow-y: scroll; overflox-x: hidden">
<form method="post" action="pays.php" id="pays_form">
<input type="hidden" name="commande" id="commande" value="" />
<input type="hidden" name="pays" id="pays" value="" />
<input type="hidden" name="offset" id="offset" value="0" />
<table width="100%">
<tr>
<th><?php echo trad('ID', 'admin'); ?></th>
<th><?php echo trad('Nom', 'admin'); ?></th>
<th style="text-align: center;"><?php echo trad('TVA', 'admin'); ?></th>
<th style="text-align: center;"><?php echo trad('Défaut', 'admin'); ?></th>
<th style="text-align: center;"><?php echo trad('boutique', 'admin') ?></th>
<th style="text-align: center;"><?php echo trad('N° ISO', 'admin'); ?></th>
<th style="text-align: center;"><?php echo trad('Codes ISO', 'admin'); ?></th>
<th> </th>
<th> </th>
</tr>
<?php
$query = "SELECT *,p.id as id_pays FROM pays p left join paysdesc pd on pd.pays = p.id where pd.lang=".ActionsLang::instance()->get_id_langue_courante()." order by pd.titre";
$result = mysql_query($query);
$style = 'fonce';
while ($result && $row = mysql_fetch_object($result))
{
?>
<tr class="<?php echo $style ?>">
<td style="padding-left: 5px;"><?php echo $row->id_pays ?></td>
<td><?php echo $row->titre != '' ? $row->titre : '<i>Non spécifié</i>' ?></td>
<td style="text-align: center;"><input type="checkbox" name="tva-<?php echo($row->id_pays); ?>" value="1" <?php echo $row->tva ? 'checked="checked"' : '' ?> onclick="change_tva(<?php echo($row->id_pays); ?>);" /></td>
<td style="text-align: center;"><input type="radio" name="defaut" value="<?php echo($row->id_pays); ?>" <?php echo $row->defaut ? 'checked="checked"' : '' ?> onclick="change_defaut(<?php echo($row->id_pays); ?>);" /></td>
<td style="text-align: center;"><input type="radio" name="boutique" value="<?php echo($row->id_pays); ?>" <?php echo $row->boutique ? 'checked="checked"' : '' ?> onclick="change_boutique(<?php echo($row->id_pays); ?>);" /></td>
<td style="text-align: center;"><?php echo $row->isocode; ?></td>
<td style="text-align: center;"><?php echo $row->isoalpha2; ?> / <?php echo $row->isoalpha3; ?></td>
<td><a href="#" onclick="modifier(<?php echo($row->id_pays); ?>, $(this)); return false;"><?php echo trad('édition', 'admin'); ?></a></td>
<td style="text-align: center;padding-right: 5px; padding-left: 5px;"><a href="#" onclick="return supprimer_pays(<?php echo($row->id_pays); ?>)" title="<?php echo trad('Supprimer ce pays', 'admin'); ?>"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></td>
</tr>
<?php
$style = $style == 'fonce' ? 'claire' : 'fonce';
}
?>
</table>
</form>
</div>
</div>
<div id="bloc_colonne_droite" class="bloc_load_pays" style="display: none;">
<div class="entete_config">
<div class="titre"><?php echo trad('Chargement en cours...', 'admin'); ?></div>
</div>
</div>
<div id="bloc_colonne_droite" class="bloc_modif_pays"></div>
<!-- fin du bloc de description / colonne de gauche -->
</div>
<?php require_once("pied.php");?>
</div>
</div>
</body>
</html>