-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin_edit_room.php
1159 lines (1093 loc) · 55.9 KB
/
admin_edit_room.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* admin_edit_room.php
* Interface de création/modification
* des sites, domaines et des ressources de l'application GRR
* Dernière modification : $Date: 2010-04-07 15:38:14 $
* @author Laurent Delineau <[email protected]>
* @author Marc-Henri PAMISEUX <[email protected]>
* @copyright Copyright 2003-2008 Laurent Delineau
* @copyright Copyright 2008 Marc-Henri PAMISEUX
* @link http://www.gnu.org/licenses/licenses.html
* @package admin
* @version $Id: admin_edit_room.php,v 1.16 2010-04-07 15:38:14 grr Exp $
* @filesource
*
* This file is part of GRR.
*
* GRR 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.
*
* GRR 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 GRR; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* $Log: admin_edit_room.php,v $
* Revision 1.16 2010-04-07 15:38:14 grr
* *** empty log message ***
*
* Revision 1.15 2009-09-29 18:02:56 grr
* *** empty log message ***
*
* Revision 1.14 2009-06-04 15:30:17 grr
* *** empty log message ***
*
* Revision 1.13 2009-04-14 12:59:17 grr
* *** empty log message ***
*
* Revision 1.12 2009-04-09 14:52:31 grr
* *** empty log message ***
*
* Revision 1.11 2009-03-24 13:30:07 grr
* *** empty log message ***
*
* Revision 1.10 2009-02-27 13:28:19 grr
* *** empty log message ***
*
* Revision 1.9 2009-01-20 07:19:17 grr
* *** empty log message ***
*
* Revision 1.8 2008-11-16 22:00:58 grr
* *** empty log message ***
*
* Revision 1.7 2008-11-13 21:32:51 grr
* *** empty log message ***
*
* Revision 1.6 2008-11-11 22:01:14 grr
* *** empty log message ***
*
* Revision 1.5 2008-11-06 21:57:34 grr
* *** empty log message ***
*
*
*/
include "include/admin.inc.php";
$grr_script_name = "admin_edit_room.php";
$ok = NULL;
if (getSettingValue("module_multisite") == "Oui")
$id_site = isset($_POST["id_site"]) ? $_POST["id_site"] : (isset($_GET["id_site"]) ? $_GET["id_site"] : -1);
$action = isset($_POST["action"]) ? $_POST["action"] : (isset($_GET["action"]) ? $_GET["action"] : NULL);
$add_area = isset($_POST["add_area"]) ? $_POST["add_area"] : (isset($_GET["add_area"]) ? $_GET["add_area"] : NULL);
$area_id = isset($_POST["area_id"]) ? $_POST["area_id"] : (isset($_GET["area_id"]) ? $_GET["area_id"] : NULL);
$retour_page = isset($_POST["retour_page"]) ? $_POST["retour_page"] : (isset($_GET["retour_page"]) ? $_GET["retour_page"] : NULL);
$room = isset($_POST["room"]) ? $_POST["room"] : (isset($_GET["room"]) ? $_GET["room"] : NULL);
$id_area = isset($_POST["id_area"]) ? $_POST["id_area"] : (isset($_GET["id_area"]) ? $_GET["id_area"] : NULL);
$change_area = isset($_POST["change_area"]) ? $_POST["change_area"] : NULL;
$area_name = isset($_POST["area_name"]) ? $_POST["area_name"] : NULL;
$access = isset($_POST["access"]) ? $_POST["access"] : NULL;
$filter_empty_resources = isset($_POST["filter_empty_resources"]) ? $_POST["filter_empty_resources"] : NULL;
$ip_adr = isset($_POST["ip_adr"]) ? $_POST["ip_adr"] : NULL;
$room_name = isset($_POST["room_name"]) ? $_POST["room_name"] : NULL;
$description = isset($_POST["description"]) ? $_POST["description"] : NULL;
$capacity = isset($_POST["capacity"]) ? $_POST["capacity"] : NULL;
$duree_max_resa_area1 = isset($_POST["duree_max_resa_area1"]) ? $_POST["duree_max_resa_area1"] : NULL;
$duree_max_resa_area2 = isset($_POST["duree_max_resa_area2"]) ? $_POST["duree_max_resa_area2"] : NULL;
$delais_max_resa_room = isset($_POST["delais_max_resa_room"]) ? $_POST["delais_max_resa_room"] : NULL;
$delais_min_resa_room = isset($_POST["delais_min_resa_room"]) ? $_POST["delais_min_resa_room"] : NULL;
$delais_option_reservation = isset($_POST["delais_option_reservation"]) ? $_POST["delais_option_reservation"] : NULL;
$allow_action_in_past = isset($_POST["allow_action_in_past"]) ? $_POST["allow_action_in_past"] : NULL;
$dont_allow_modify = isset($_POST["dont_allow_modify"]) ? $_POST["dont_allow_modify"] : NULL;
$qui_peut_reserver_pour = isset($_POST["qui_peut_reserver_pour"]) ? $_POST["qui_peut_reserver_pour"] : NULL;
$who_can_see = isset($_POST["who_can_see"]) ? $_POST["who_can_see"] : NULL;
$max_booking = isset($_POST["max_booking"]) ? $_POST["max_booking"] : NULL;
settype($max_booking,"integer");
if ($max_booking<-1) $max_booking = -1;
$statut_room = isset($_POST["statut_room"]) ? "0" : "1";
$show_fic_room = isset($_POST["show_fic_room"]) ? "y" : "n";
if (isset($_POST["active_ressource_empruntee"])) {
$active_ressource_empruntee = 'y';
} else {
$active_ressource_empruntee = 'n';
// toutes les réservations sont considérées comme restituée
grr_sql_query("update ".TABLE_PREFIX."_entry set statut_entry = '-' where room_id = '".$room."'");
}
$picture_room = isset($_POST["picture_room"]) ? $_POST["picture_room"] : NULL;
$comment_room = isset($_POST["comment_room"]) ? $_POST["comment_room"] : NULL;
$show_comment = isset($_POST["show_comment"]) ? "y" : "n";
$change_done = isset($_POST["change_done"]) ? $_POST["change_done"] : NULL;
$area_order = isset($_POST["area_order"]) ? $_POST["area_order"] : NULL;
$room_order = isset($_POST["room_order"]) ? $_POST["room_order"] : NULL;
$change_room = isset($_POST["change_room"]) ? $_POST["change_room"] : NULL;
$number_periodes = isset($_POST["number_periodes"]) ? $_POST["number_periodes"] : NULL;
$type_affichage_reser = isset($_POST["type_affichage_reser"]) ? $_POST["type_affichage_reser"] : NULL;
$retour_resa_obli = isset($_POST["retour_resa_obli"]) ? $_POST["retour_resa_obli"] : NULL;
$moderate = isset($_POST['moderate']) ? $_POST["moderate"] : NULL;
if ($moderate == 'on') $moderate = 1;
else $moderate = 0;
settype($type_affichage_reser,"integer");
$back = '';
if (isset($_SERVER['HTTP_REFERER'])) $back = my_htmlspecialcharacters($_SERVER['HTTP_REFERER']);
if (isset($_POST["change_room_and_back"])) {
$change_room = "yes";
$change_done = "yes";
}
if (isset($_POST["change_area_and_back"])) {
$change_area = "yes";
$change_done = "yes";
}
// mémorisation du chemin de retour
if (!isset($retour_page)) {
$retour_page = $back;
// on nettoie la chaine :
$long_chaine_a_supprimer = strlen(strstr($retour_page,"&msg=")); // longueur de la chaine à partir de la première occurence de &msg=
if ($long_chaine_a_supprimer==0) $long_chaine_a_supprimer = strlen(strstr($retour_page,"?msg="));
$long = strlen($retour_page) - $long_chaine_a_supprimer;
$retour_page = substr($retour_page,0,$long);
}
$day = date("d");
$month = date("m");
$year = date("Y");
// modification d'une resource : admin ou gestionnaire
if (authGetUserLevel(getUserName(),-1) < 6)
{
if (isset($room))
{
// Il s'agit d'une modif de ressource
if (((authGetUserLevel(getUserName(),$room) < 3)) or (!verif_acces_ressource(getUserName(), $room))) {
showAccessDenied($day, $month, $year, '',$back);
exit();
}
} else {
if (isset($area_id)) {
// On vérifie que le domaine $area_id existe
$test = grr_sql_query1("select id from ".TABLE_PREFIX."_area where id='".$area_id."'");
if ($test == -1) {
showAccessDenied($day, $month, $year, '',$back);
exit();
}
// Il s'agit de l'ajout d'une ressource
// On vérifie que l'utilisateur a le droit d'ajouter des ressources
if ((authGetUserLevel(getUserName(),$area_id,'area') < 4)) {
showAccessDenied($day, $month, $year, '',$back);
exit();
}
} else if (isset($id_area)) {
// On vérifie que le domaine $area existe
$test = grr_sql_query1("select id from ".TABLE_PREFIX."_area where id='".$id_area."'");
if ($test == -1) {
showAccessDenied($day, $month, $year, '',$back);
exit();
}
// Il s'agit de la modif d'un domaine
if ((authGetUserLevel(getUserName(),$id_area,'area') < 4)) {
showAccessDenied($day, $month, $year, '',$back);
exit();
}
}
}
}
$msg ='';
// Gestion des ressources
if ((!empty($room)) or (isset($area_id))) {
// Enregistrement d'une ressource
if (isset($change_room))
{
if (isset($_POST['sup_img'])) {
$dest = './images/';
$ok1 = false;
if ($f = @fopen("$dest/.test", "w")) {
@fputs($f, '<'.'?php $ok1 = true; ?'.'>');
@fclose($f);
include("$dest/.test");
}
if (!$ok1) {
$msg .= "L\'image n\'a pas pu être supprimée : problème d\'écriture sur le répertoire. Veuillez signaler ce problème à l\'administrateur du serveur.\\n";
$ok = 'no';
} else {
if (@file_exists($dest."img_".$room.".jpg")) unlink($dest."img_".$room.".jpg");
if (@file_exists($dest."img_".$room.".png")) unlink($dest."img_".$room.".png");
if (@file_exists($dest."img_".$room.".gif")) unlink($dest."img_".$room.".gif");
$picture_room = "";
}
}
if (empty($capacity)) $capacity = 0;
if ($capacity<0) $capacity = 0;
settype($delais_max_resa_room,"integer");
if ($delais_max_resa_room<0) $delais_max_resa_room = -1;
settype($delais_min_resa_room,"integer");
if ($delais_min_resa_room<0) $delais_min_resa_room = 0;
settype($delais_option_reservation,"integer");
if ($delais_option_reservation<0) $delais_option_reservation = 0;
if ($allow_action_in_past == '') $allow_action_in_past = 'n';
if ($dont_allow_modify == '') $dont_allow_modify = 'n';
if ((isset($room)) and !((isset($action) and ($action=="duplique_room"))) ) {
$sql = "UPDATE ".TABLE_PREFIX."_room SET
room_name='".protect_data_sql($room_name)."',
description='".protect_data_sql($description)."', ";
if ($picture_room != '') $sql .= "picture_room='".protect_data_sql($picture_room)."', ";
$sql .= "comment_room='".protect_data_sql(corriger_caracteres($comment_room))."',
show_comment='".$show_comment."',
area_id='".$area_id."',
show_fic_room='".$show_fic_room."',
active_ressource_empruntee = '".$active_ressource_empruntee."',
capacity='".$capacity."',
delais_max_resa_room='".$delais_max_resa_room."',
delais_min_resa_room='".$delais_min_resa_room."',
delais_option_reservation='".$delais_option_reservation."',
allow_action_in_past='".$allow_action_in_past."',
dont_allow_modify='".$dont_allow_modify."',
qui_peut_reserver_pour = '".$qui_peut_reserver_pour."',
who_can_see = '".$who_can_see."',
order_display='".protect_data_sql($area_order)."',
type_affichage_reser='".$type_affichage_reser."',
max_booking='".$max_booking."',
moderate='".$moderate."',
statut_room='".$statut_room."'
WHERE id=$room";
if (grr_sql_command($sql) < 0) {
fatal_error(0, get_vocab('update_room_failed') . grr_sql_error());
$ok = 'no';
}
} else {
$sql = "insert into ".TABLE_PREFIX."_room
SET room_name='".protect_data_sql($room_name)."',
area_id='".$area_id."',
description='".protect_data_sql($description)."',
picture_room='".protect_data_sql($picture_room)."',
comment_room='".protect_data_sql(corriger_caracteres($comment_room))."',
show_fic_room='".$show_fic_room."',
active_ressource_empruntee = '".$active_ressource_empruntee."',
capacity='".$capacity."',
delais_max_resa_room='".$delais_max_resa_room."',
delais_min_resa_room='".$delais_min_resa_room."',
delais_option_reservation='".$delais_option_reservation."',
allow_action_in_past='".$allow_action_in_past."',
dont_allow_modify='".$dont_allow_modify."',
qui_peut_reserver_pour = '".$qui_peut_reserver_pour."',
who_can_see = '".$who_can_see."',
order_display='".protect_data_sql($area_order)."',
type_affichage_reser='".$type_affichage_reser."',
max_booking='".$max_booking."',
moderate='".$moderate."',
statut_room='".$statut_room."'";
if (grr_sql_command($sql) < 0) fatal_error(1, "<p>" . grr_sql_error());
$room = mysql_insert_id();
}
#Si room_name est vide on le change maintenant que l'on a l'id room
if ($room_name == '') {
$room_name = get_vocab("room")." ".$room;
grr_sql_command("UPDATE ".TABLE_PREFIX."_room SET room_name='".protect_data_sql($room_name)."' WHERE id=$room");
}
$doc_file = isset($_FILES["doc_file"]) ? $_FILES["doc_file"] : NULL;
if (preg_match("`\.([^.]+)$`", $doc_file['name'], $match)) {
$ext = strtolower($match[1]);
if ($ext!='jpg' and $ext!='png'and $ext!='gif') {
$msg .= "L\'image n\'a pas pu être enregistrée : les seules extentions autorisées sont gif, png et jpg.\\n";
$ok = 'no';
} else {
$dest = './images/';
$ok1 = false;
if ($f = @fopen("$dest/.test", "w")) {
@fputs($f, '<'.'?php $ok1 = true; ?'.'>');
@fclose($f);
include("$dest/.test");
}
if (!$ok1) {
$msg .= "L\'image n\'a pas pu être enregistrée : problème d\'écriture sur le répertoire IMAGES. Veuillez signaler ce problème à l\'administrateur du serveur.\\n";
$ok = 'no';
} else {
$ok1 = @copy($doc_file['tmp_name'], $dest.$doc_file['name']);
if (!$ok1) $ok1 = @move_uploaded_file($doc_file['tmp_name'], $dest.$doc_file['name']);
if (!$ok1) {
$msg .= "L\'image n\'a pas pu être enregistrée : problème de transfert. Le fichier n\'a pas pu être transféré sur le répertoire IMAGES. Veuillez signaler ce problème à l\'administrateur du serveur.\\n";
$ok = 'no';
} else {
$tab = explode(".", $doc_file['name']);
$ext = strtolower($tab[1]);
if (($dest.$doc_file['name']!=$dest."img_".$room.".".$ext)) {
if (@file_exists($dest."img_".$room.".".$ext)) @unlink($dest."img_".$room.".".$ext);
rename($dest.$doc_file['name'],$dest."img_".$room.".".$ext);
}
@chmod($dest."img_".$room.".".$ext, 0666);
$picture_room = "img_".$room.".".$ext;
$sql_picture = "UPDATE ".TABLE_PREFIX."_room SET picture_room='".protect_data_sql($picture_room)."' WHERE id=".$room;
if (grr_sql_command($sql_picture) < 0) {
fatal_error(0, get_vocab('update_room_failed') . grr_sql_error());
$ok = 'no';
}
}
}
}
} else if ($doc_file['name'] != '') {
$msg .= "L\'image n\'a pas pu être enregistrée : le fichier image sélectionné n'est pas valide !\\n";
$ok = 'no';
}
$msg .= get_vocab("message_records");
}
// Si pas de problème, retour à la page d'accueil après enregistrement
if ((isset($change_done)) and (!isset($ok))) {
if ($msg != '') {
$_SESSION['displ_msg'] = 'yes';
if (strpos($retour_page, ".php?") == "") $param = "?msg=".$msg; else $param = "&msg=".$msg;
} else
$param = '';
Header("Location: ".$retour_page.$param);
exit();
}
# print the page header
print_header("","","","",$type="with_session", $page="admin");
affiche_pop_up($msg,"admin");
echo "<div class=\"page_sans_col_gauche\">";
// affichage du formulaire
if (isset($room)) {
// Il s'agit d'une modification d'une ressource
$res = grr_sql_query("SELECT * FROM ".TABLE_PREFIX."_room WHERE id=$room");
if (! $res) fatal_error(0, get_vocab('error_room') . $room . get_vocab('not_found'));
$row = grr_sql_row_keyed($res, 0);
grr_sql_free($res);
$area_id = grr_sql_query1("select area_id from ".TABLE_PREFIX."_room where id='".$room."'");
$area_name = grr_sql_query1("select area_name from ".TABLE_PREFIX."_area where id='".$area_id."'");
if ($action=="duplique_room")
echo "<h2>".get_vocab("match_area").get_vocab('deux_points')." ".$area_name."<br />".get_vocab("duplique_ressource")."</h2>\n";
else
echo "<h2>".get_vocab("match_area").get_vocab('deux_points')." ".$area_name."<br />".get_vocab("editroom")."</h2>\n";
} else {
// Il s'agit de l'enregistrement d'une nouvelle ressource
$row['picture_room'] = '';
$row["id"] = '';
$row["room_name"]= '';
$row["description"] = '';
$row['comment_room'] = '';
$row['show_comment'] = 'n';
$row["capacity"] = '';
$row["delais_max_resa_room"] = -1;
$row["delais_min_resa_room"] = 0;
$row["delais_option_reservation"] = 0;
$row["allow_action_in_past"] = 'n';
$row["dont_allow_modify"] = 'n';
$row["qui_peut_reserver_pour"] = 6;
$row["who_can_see"] = 0;
$row["order_display"] = 0;
$row["type_affichage_reser"] = 0;
$row["max_booking"] = -1;
$row['statut_room'] = '';
$row['moderate'] = '';
$row['show_fic_room'] = '';
$row['active_ressource_empruntee'] = 'n';
$area_name = grr_sql_query1("select area_name from ".TABLE_PREFIX."_area where id='".$area_id."'");
echo "<h2>".get_vocab("match_area").get_vocab('deux_points')." ".$area_name."<br />".get_vocab("addroom")."</h2>\n";
}
?>
<form enctype="multipart/form-data" action="admin_edit_room.php" method="post">
<?php
echo "<div>";
if (isset($action)) echo "<input type=\"hidden\" name=\"action\" value=\"duplique_room\" />\n";
if ($row["id"] != '') echo "<input type=\"hidden\" name=\"room\" value=\"".$row["id"]."\" />\n";
if (isset($retour_page)) echo "<input type=\"hidden\" name=\"retour_page\" value=\"".$retour_page."\" />\n";
echo "</div>";
$nom_picture = '';
if ($row['picture_room'] != '') $nom_picture = "./images/".$row['picture_room'];
if (getSettingValue("use_fckeditor") == 1) {
echo "<script type=\"text/javascript\" src=\"./ckeditor/ckeditor.js\"></script>\n";
}
echo "<table border=\"1\" cellspacing=\"1\" cellpadding=\"6\">\n";
echo "<tr><td>".get_vocab("name").get_vocab("deux_points")."</td><td style=\"width:30%;\">\n";
// seul l'administrateur peut modifier le nom de la ressource
if ((authGetUserLevel(getUserName(),$area_id,"area") >=4) or (authGetUserLevel(getUserName(),$room) >=4)) {
echo "<input type=\"text\" name=\"room_name\" size=\"40\" value=\"".my_htmlspecialcharacters($row["room_name"])."\" />\n";
} else {
echo "<input type=\"hidden\" name=\"room_name\" value=\"".my_htmlspecialcharacters($row["room_name"])."\" />\n";
echo "<b>".my_htmlspecialcharacters($row["room_name"])."</b>\n";
}
echo "</td></tr>\n";
// Description
echo "<tr><td>".get_vocab("description")."</td><td><input type=\"text\" name=\"description\" size=\"40\" value=\"".my_htmlspecialcharacters($row["description"])."\" /></td></tr>\n";
// Domaine
$enable_periods = grr_sql_query1("select enable_periods from ".TABLE_PREFIX."_area where id='".$area_id."'");
if (((authGetUserLevel(getUserName(),$area_id,"area") >=4) or (authGetUserLevel(getUserName(),$room) >=4)) and ($enable_periods == 'n')) {
// les créneaux sont basés sur le temps : on ne peut pas changer une ressource de domaine
if(authGetUserLevel(getUserName(),-1,'area') >= 6)
$sql = "SELECT id,area_name
FROM ".TABLE_PREFIX."_area where enable_periods='n'
ORDER BY area_name ASC";
else if(authGetUserLevel(getUserName(),$area_id,'area') == 5)
$sql = "SELECT distinct a.id, a.area_name
FROM ".TABLE_PREFIX."_area a, ".TABLE_PREFIX."_j_site_area j, ".TABLE_PREFIX."_site s, ".TABLE_PREFIX."_j_useradmin_site u
WHERE a.id=j.id_area and u.id_site=j.id_site and s.id=u.id_site and u.login='".getUserName()."' and enable_periods='n'
ORDER BY a.area_name ASC";
else
$sql = "SELECT id,area_name
FROM ".TABLE_PREFIX."_area a, ".TABLE_PREFIX."_j_useradmin_area u
WHERE a.id=u.id_area and u.login='".getUserName()."' and a.enable_periods='n'
ORDER BY a.area_name ASC";
$res = grr_sql_query($sql);
$nb_area = grr_sql_count($res);
if ($nb_area > 1) {
echo "<tr><td>".get_vocab('match_area').get_vocab('deux_points')."</td>\n";
echo "<td><select name=\"area_id\" >\n
<option value=\"-1\">".get_vocab('choose_an_area')."</option>\n";
for ($enr = 0; ($row1 = grr_sql_row($res, $enr)); $enr++) {
echo "<option value=\"".$row1[0]."\"";
if ($area_id == $row1[0])
echo ' selected="selected"';
echo '>'.my_htmlspecialcharacters($row1[1]);
echo '</option>'."\n";
}
grr_sql_free($res);
echo "</select></td></tr>";
} else {
if (isset($area_id)) echo "<input type=\"hidden\" name=\"area_id\" value=\"".$area_id."\" />\n";
}
} else {
// les créneaux sont basés sur les intitulés : on ne peut pas changer une ressource de domaine
if (isset($area_id)) echo "<input type=\"hidden\" name=\"area_id\" value=\"".$area_id."\" />\n";
}
// Ordre d'affichage du domaine
echo "<tr><td>".get_vocab("order_display").get_vocab("deux_points")."</td>\n";
echo "<td><input type=\"text\" name=\"area_order\" size=\"1\" value=\"".my_htmlspecialcharacters($row["order_display"])."\" /></td>\n";
echo "</tr>\n";
// Qui peut voir cette ressource
echo "<tr><td colspan=\"2\">".get_vocab("qui_peut_voir_ressource")."<br />\n";
echo "<select name=\"who_can_see\" size=\"1\">\n
<option value=\"0\" ";
if ($row["who_can_see"]==0) echo " selected=\"selected\" ";
echo ">".get_vocab("visu_fiche_description0")."</option>\n
<option value=\"1\" ";
if ($row["who_can_see"]==1) echo " selected=\"selected\" ";
echo ">".get_vocab("visu_fiche_description1")."</option>\n
<option value=\"2\" ";
if ($row["who_can_see"]==2) echo " selected=\"selected\" ";
echo ">".get_vocab("visu_fiche_description2")."</option>\n
<option value=\"3\" ";
if ($row["who_can_see"]==3) echo " selected=\"selected\" ";
echo ">".get_vocab("visu_fiche_description3")."</option>\n
<option value=\"4\" ";
if ($row["who_can_see"]==4) echo " selected=\"selected\" ";
echo ">".get_vocab("visu_fiche_description4")."</option>\n";
if (getSettingValue("module_multisite") != "Oui") {
echo "<option value=\"5\" ";
if ($row["who_can_see"]==5) echo " selected=\"selected\" ";
echo ">".get_vocab("visu_fiche_description5")."</option>\n";
};
echo "<option value=\"6\" ";
if ($row["who_can_see"]==6) echo " selected=\"selected\" ";
echo ">".get_vocab("visu_fiche_description6")."</option>\n
</select></td></tr>\n";
// Déclarer ressource indisponible
echo "<tr><td>".get_vocab("declarer_ressource_indisponible")."<br /><i>".get_vocab("explain_max_booking")."</i></td>
<td><input type=\"checkbox\" name=\"statut_room\" ";
if ($row['statut_room'] == "0") echo " checked=\"checked\" ";
echo "/></td></tr>\n";
// Afficher la fiche de présentation de la ressource
echo "<tr><td>".get_vocab("montrer_fiche_présentation_ressource")."</td>
<td><input type=\"checkbox\" name=\"show_fic_room\" ";
if ($row['show_fic_room'] == "y") echo " checked=\"checked\" ";
echo "/><a href='javascript:centrerpopup(\"view_room.php?id_room=$room\",600,480,\"scrollbars=yes,statusbar=no,resizable=yes\")' title=\"".get_vocab("fiche_ressource")."\">
<img src=\"img_grr/details.png\" alt=\"détails\" class=\"image\" /></a></td></tr>\n";
// Choix de l'image de la ressource
echo "<tr><td>".get_vocab("choisir_image_ressource")."</td>
<td><input type=\"file\" name=\"doc_file\" size=\"30\" /></td></tr>\n";
echo "<tr><td>".get_vocab("supprimer_image_ressource").get_vocab("deux_points");
if (@file_exists($nom_picture)) {
echo "<b>$nom_picture</b></td><td><input type=\"checkbox\" name=\"sup_img\" /></td></tr>";}
else{
echo "<b>".get_vocab("nobody")."</b></td><td><input type=\"checkbox\" disabled=\"disabled\" name=\"sup_img\" /></td></tr>";
}
echo "<tr><td>".get_vocab("Afficher_description_complete_dans_titre_plannings")."</td>\n
<td><input type=\"checkbox\" name=\"show_comment\" ";
if ($row['show_comment'] == "y") echo " checked ";
echo "/></td></tr>\n";
// Description complète
echo "<tr><td colspan=\"2\">".get_vocab("description complete");
if (getSettingValue("use_fckeditor") != 1)
echo " ".get_vocab("description complete2");
echo get_vocab("deux_points")."<br />";
if (getSettingValue("use_fckeditor") == 1) {
echo "<textarea class=\"ckeditor\" id=\"editor1\" name=\"comment_room\" rows=\"8\" cols=\"120\">\n";
echo $row['comment_room'];
echo "</textarea>\n";
?>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'editor1',
{
toolbar :
[
['Source'],
['Cut','Copy','Paste','PasteText','PasteFromWord', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Image','Table','HorizontalRule','SpecialChar','PageBreak'],
]
});
//]]>
</script>
<?php
} else {
echo "<textarea name=\"comment_room\" rows=\"8\" cols=\"120\" >".$row['comment_room']."</textarea>";
}
echo "</td></tr></table>\n";
echo "<h3>".get_vocab("configuration_ressource")."</h3>\n";
// Type d'affichage : durée ou heure/date de fin de réservation
echo "<table border=\"1\" cellspacing=\"1\" cellpadding=\"6\">\n";
echo "<tr><td>".get_vocab("type_affichage_reservation").get_vocab("deux_points")."</td>\n";
echo "<td>";
echo "<label><input type=\"radio\" name=\"type_affichage_reser\" value=\"0\" ";
if (($row["type_affichage_reser"]) == 0) echo " checked=\"checked\" ";
echo "/>";
echo get_vocab("affichage_reservation_duree");
echo "</label><br /><label><input type=\"radio\" name=\"type_affichage_reser\" value=\"1\" ";
if (($row["type_affichage_reser"]) == 1) echo " checked=\"checked\" ";
echo "/>";
echo get_vocab("affichage_reservation_date_heure");
echo "</label></td>\n";
echo "</tr>\n";
// Capacité
echo "<tr><td>".get_vocab("capacity").": </td><td><input type=\"text\" name=\"capacity\" size=\"1\" value=\"".$row["capacity"]."\" /></td></tr>\n";
// seul les administrateurs de la ressource peuvent modifier le nombre max de réservation par utilisateur
if ((authGetUserLevel(getUserName(),$area_id,"area") >=4) or (authGetUserLevel(getUserName(),$room) >=4)) {
echo "<tr><td>".get_vocab("max_booking")." ";
echo grr_help("aide_grr_max_reservation");
echo "</td><td><input type=\"text\" name=\"max_booking\" size=\"1\" value=\"".$row["max_booking"]."\" /></td></tr>";
} else if ($row["max_booking"] != "-1") {
echo "<tr><td>".get_vocab("msg_max_booking").get_vocab("deux_points")."</td><td>
<input type=\"hidden\" name=\"max_booking\" value=\"".$row["max_booking"]."\" />
<b>".my_htmlspecialcharacters($row["max_booking"])."</b>
</td></tr>";
}
// L'utilisateur ne peut pas réserver au-delà d'un certain temps
echo "<tr><td>".get_vocab("delais_max_resa_room").": </td><td><input type=\"text\" name=\"delais_max_resa_room\" size=\"1\" value=\"".$row["delais_max_resa_room"]."\" /></td></tr>\n";
// L'utilisateur ne peut pas réserver en-dessous d'un certain temps
echo "<tr><td>".get_vocab("delais_min_resa_room").": ";
echo "</td><td><input type=\"text\" name=\"delais_min_resa_room\" size=\"5\" value=\"".$row["delais_min_resa_room"]."\" /></td></tr>\n";
// L'utilisateur peut poser poser une option de réservation
echo "<tr><td>".get_vocab("msg_option_de_reservation")." ".grr_help("aide_grr_reservation_sous_reserve")."</td>
<td><input type=\"text\" name=\"delais_option_reservation\" size=\"5\" value=\"".$row["delais_option_reservation"]."\" /></td></tr>\n";
// Les demandes de réservations sont modérés
echo "<tr><td>".get_vocab("msg_moderation_reservation").get_vocab("deux_points");
echo grr_help("aide_grr_moderation");
echo "</td>" .
"<td><input type='checkbox' name='moderate' ";
if ($row['moderate']) echo 'checked="checked"';
echo " /></td></tr>\n";
// L'utilisateur peut réserver dans le passé
echo "<tr><td>".get_vocab("allow_action_in_past")."<br /><i>".get_vocab("allow_action_in_past_explain")."</i></td><td><input type=\"checkbox\" name=\"allow_action_in_past\" value=\"y\" ";
if ($row["allow_action_in_past"] == 'y') echo " checked=\"checked\"";
echo " /></td></tr>\n";
// L'utilisateur ne peut pas modifier ou supprimer ses propres réservations
echo "<tr><td>".get_vocab("dont_allow_modify")."</td><td><input type=\"checkbox\" name=\"dont_allow_modify\" value=\"y\" ";
if ($row["dont_allow_modify"] == 'y') echo " checked=\"checked\"";
echo " /></td></tr>\n";
// Quels utilisateurs ont le droit de réserver cette ressource au nom d'un autre utilisateur ?
echo "<tr><td>".get_vocab("qui peut reserver pour autre utilisateur")."</td><td>
<select name=\"qui_peut_reserver_pour\" size=\"1\">\n
<option value=\"5\" ";
if ($row["qui_peut_reserver_pour"]==6) echo " selected=\"selected\" ";
echo ">".get_vocab("personne")."</option>\n
<option value=\"4\" ";
if ($row["qui_peut_reserver_pour"]==4) echo " selected=\"selected\" ";
echo ">".get_vocab("les administrateurs restreints")."</option>\n
<option value=\"3\" ";
if ($row["qui_peut_reserver_pour"]==3) echo " selected=\"selected\" ";
echo ">".get_vocab("les gestionnaires de la ressource")."</option>\n
<option value=\"2\" ";
if ($row["qui_peut_reserver_pour"]==2) echo " selected=\"selected\" ";
echo ">".get_vocab("tous les utilisateurs")."</option>\n
</select></td></tr>\n";
// Activer la fonctionalité "ressource empruntée/restituée"
echo "<tr><td>".get_vocab("activer fonctionalité ressource empruntee restituee").grr_help("aide_grr_ressource_empruntee")."</td>
<td><input type=\"checkbox\" name=\"active_ressource_empruntee\" ";
if ($row['active_ressource_empruntee'] == "y") echo " checked=\"checked\" ";
echo "/></td></tr>\n";
echo "</table>\n";
echo "<div style=\"text-align:center;\"><br />\n";
echo "<input type=\"submit\" name=\"change_room\" value=\"".get_vocab("save")."\" />\n";
echo "<input type=\"submit\" name=\"change_done\" value=\"".get_vocab("back")."\" />";
echo "<input type=\"submit\" name=\"change_room_and_back\" value=\"".get_vocab("save_and_back")."\" />";
if (@file_exists($nom_picture) && $nom_picture) {
echo "<br /><br /><b>".get_vocab("Image de la ressource").get_vocab("deux_points")."</b><br /><img src=\"".$nom_picture."\" alt=\"logo\" />";
} else {
echo "<br /><br /><b>".get_vocab("Pas image disponible")."</b>";
}
?>
</div>
</form>
</div>
<?php
}
// Ajout ou modification d'un domaine
if ((!empty($id_area)) or (isset($add_area)))
{
if (isset($change_area)) {
// Affectation à un site : si aucun site n'a été affecté
if ((getSettingValue("module_multisite") == "Oui") and ($id_site==-1)) {
// On affiche un message d'avertissement
?>
<script type="text/javascript">
alert("<?php echo get_vocab('choose_a_site'); ?>");
</script>
<?php
// On empêche le retour à la page admin_room
unset($change_done);
} else {
// Un site a été affecté, on peut continuer
// la valeur par défaut ne peut être inférieure au plus petit bloc réservable
if ($_POST['duree_par_defaut_reservation_area'] < $_POST['resolution_area']) $_POST['duree_par_defaut_reservation_area'] = $_POST['resolution_area'];
// la valeur par défaut doit être un multiple du plus petit bloc réservable
$_POST['duree_par_defaut_reservation_area']= intval($_POST['duree_par_defaut_reservation_area']/$_POST['resolution_area'])*$_POST['resolution_area'];
// Durée maximale de réservation
if (isset($_POST['enable_periods'])) {
if ($_POST['enable_periods'] == 'y')
$duree_max_resa_area = $duree_max_resa_area2*1440;
else {
$duree_max_resa_area = $duree_max_resa_area1;
if ($duree_max_resa_area >= 0)
$duree_max_resa_area = max ($duree_max_resa_area, $_POST['resolution_area']/60, $_POST['duree_par_defaut_reservation_area']/60);
}
settype($duree_max_resa_area,"integer");
if ($duree_max_resa_area<0) $duree_max_resa_area = -1;
}
$display_days = "";
for ($i = 0; $i < 7; $i++) {
if (isset($_POST['display_day'][$i]))
$display_days .= "y";
else
$display_days .= "n";
}
if ($display_days != "nnnnnnn") {
while(!isset($_POST['display_day'][$_POST['weekstarts_area']])) {
$_POST['weekstarts_area']++;
}
}
if ($_POST['morningstarts_area'] > $_POST['eveningends_area'])
$_POST['eveningends_area'] = $_POST['morningstarts_area'];
if ($access) {$access='r';} else {$access='a';}
if ((isset($id_area)) and !((isset($action) and ($action=="duplique_area"))) ) {
// s'il y a changement de type de créneaux, on efface les réservations du domaines
$old_enable_periods = grr_sql_query1("select enable_periods from ".TABLE_PREFIX."_area WHERE id='".$id_area."'");
if ($old_enable_periods != $_POST['enable_periods']) {
$del = grr_sql_query("DELETE ".TABLE_PREFIX."_entry FROM ".TABLE_PREFIX."_entry, ".TABLE_PREFIX."_room, ".TABLE_PREFIX."_area WHERE
".TABLE_PREFIX."_entry.room_id = ".TABLE_PREFIX."_room.id and
".TABLE_PREFIX."_room.area_id = ".TABLE_PREFIX."_area.id and
".TABLE_PREFIX."_area.id = '".$id_area."'");
$del = grr_sql_query("DELETE ".TABLE_PREFIX."_repeat FROM ".TABLE_PREFIX."_repeat, ".TABLE_PREFIX."_room, ".TABLE_PREFIX."_area WHERE
".TABLE_PREFIX."_repeat.room_id = ".TABLE_PREFIX."_room.id and
".TABLE_PREFIX."_room.area_id = ".TABLE_PREFIX."_area.id and
".TABLE_PREFIX."_area.id = '".$id_area."'");
}
$sql = "UPDATE ".TABLE_PREFIX."_area SET
area_name='".protect_data_sql($area_name)."',
filter_empty_resources='".protect_data_sql($filter_empty_resources)."',
access='".protect_data_sql($access)."',
order_display='".protect_data_sql($area_order)."',
ip_adr='".protect_data_sql($ip_adr)."',
calendar_default_values = 'n',
duree_max_resa_area = '".protect_data_sql($duree_max_resa_area)."',
morningstarts_area = '".protect_data_sql($_POST['morningstarts_area'])."',
eveningends_area = '".protect_data_sql($_POST['eveningends_area'])."',
resolution_area = '".protect_data_sql($_POST['resolution_area'])."',
duree_par_defaut_reservation_area = '".protect_data_sql($_POST['duree_par_defaut_reservation_area'])."',
eveningends_minutes_area = '".protect_data_sql($_POST['eveningends_minutes_area'])."',
weekstarts_area = '".protect_data_sql($_POST['weekstarts_area'])."',
enable_periods = '".protect_data_sql($_POST['enable_periods'])."',
twentyfourhour_format_area = '".protect_data_sql($_POST['twentyfourhour_format_area'])."',
max_booking='".$max_booking."',
display_days = '".$display_days."'
WHERE id=$id_area";
if (grr_sql_command($sql) < 0) {
fatal_error(0, get_vocab('update_area_failed') . grr_sql_error());
$ok = 'no';
}
} else {
$sql = "INSERT INTO ".TABLE_PREFIX."_area SET
area_name='".protect_data_sql($area_name)."',
filter_empty_resources='".protect_data_sql($filter_empty_resources)."',
access='".protect_data_sql($access)."',
order_display='".protect_data_sql($area_order)."',
ip_adr='".protect_data_sql($ip_adr)."',
calendar_default_values = 'n',
duree_max_resa_area = '".protect_data_sql($duree_max_resa_area)."',
morningstarts_area = '".protect_data_sql($_POST['morningstarts_area'])."',
eveningends_area = '".protect_data_sql($_POST['eveningends_area'])."',
resolution_area = '".protect_data_sql($_POST['resolution_area'])."',
duree_par_defaut_reservation_area = '".protect_data_sql($_POST['duree_par_defaut_reservation_area'])."',
eveningends_minutes_area = '".protect_data_sql($_POST['eveningends_minutes_area'])."',
weekstarts_area = '".protect_data_sql($_POST['weekstarts_area'])."',
enable_periods = '".protect_data_sql($_POST['enable_periods'])."',
twentyfourhour_format_area = '".protect_data_sql($_POST['twentyfourhour_format_area'])."',
display_days = '".$display_days."',
max_booking='".$max_booking."',
id_type_par_defaut = '-1'
";
if (grr_sql_command($sql) < 0) fatal_error(1, "<p>" . grr_sql_error());
$id_area = grr_sql_insert_id("".TABLE_PREFIX."_area", "id");
}
// Affectation à un site
if (getSettingValue("module_multisite") == "Oui") {
$sql = "delete from ".TABLE_PREFIX."_j_site_area where id_area='".$id_area."'";
if (grr_sql_command($sql) < 0) fatal_error(0, "<p>".grr_sql_error()."</p>");
$sql = "INSERT INTO ".TABLE_PREFIX."_j_site_area SET id_site='".$id_site."', id_area='".$id_area."'";
if (grr_sql_command($sql) < 0) fatal_error(0, "<p>".grr_sql_error()."</p>");
}
#Si area_name est vide on le change maintenant que l'on a l'id area
if ($area_name == '') {
$area_name = get_vocab("match_area")." ".$id_area;
grr_sql_command("UPDATE ".TABLE_PREFIX."_area SET area_name='".protect_data_sql($area_name)."' WHERE id=$id_area");
}
#on crée ou recrée ".TABLE_PREFIX."_area_periodes pour le domaine
if (protect_data_sql($_POST['enable_periods'])=='y') {
if (isset($number_periodes)) {
settype($number_periodes,"integer");
if ($number_periodes < 1) $number_periodes = 1;
$del_periode = grr_sql_query("delete from ".TABLE_PREFIX."_area_periodes where id_area='".$id_area."'");
#on efface le modèle par défaut avec area=0
$del_periode = grr_sql_query("delete from ".TABLE_PREFIX."_area_periodes where id_area='0'");
$i = 0;
$num = 0;
while ($i < $number_periodes) {
$temp = "periode_".$i;
if (isset($_POST[$temp])) {
$nom_periode = corriger_caracteres($_POST[$temp]);
$reg_periode = grr_sql_query("insert into ".TABLE_PREFIX."_area_periodes set
id_area='".$id_area."',
num_periode='".$num."',
nom_periode='".protect_data_sql($nom_periode)."'
");
#on crée un modèle par défaut avec area=0
$reg_periode = grr_sql_query("insert into ".TABLE_PREFIX."_area_periodes set
id_area='0',
num_periode='".$num."',
nom_periode='".protect_data_sql($nom_periode)."'");
$num++;
}
$i++;
}
}
}
$msg = get_vocab("message_records");
}
}
if ($access=='a') {
$sql = "DELETE FROM ".TABLE_PREFIX."_j_user_area WHERE id_area='$id_area'";
if (grr_sql_command($sql) < 0)
fatal_error(0, get_vocab('update_area_failed') . grr_sql_error());
}
if ((isset($change_done)) and (!isset($ok))) {
if ($msg != '') {
$_SESSION['displ_msg'] = 'yes';
if (strpos($retour_page, ".php?") == "") $param = "?msg=".$msg; else $param = "&msg=".$msg;
} else
$param = '';
Header("Location: ".$retour_page.$param);
exit();
}
# print the page header
print_header("","","","",$type="with_session", $page="admin");
affiche_pop_up($msg,"admin");
$avertissement = get_vocab("avertissement_change_type");
?>
<script type="text/javascript">
function bascule()
{
menu_1 = document.getElementById('menu1');
menu_2 = document.getElementById('menu2');
if (document.getElementById('main').enable_periods[0].checked)
{
menu_1.style.display = "";
menu_2.style.display = "none";
}
if (document.getElementById('main').enable_periods[1].checked)
{
menu_1.style.display = "none";
menu_2.style.display = "";
}
alert("<?php echo $avertissement; ?>");
}
function aff_creneaux()
{
nb_cr = document.getElementById('nb_per');
if (isNaN(Number(nb_cr.value))) nb_cr.value=1;
if (nb_cr.value>50) nb_cr.value=50;
if (nb_cr.value<1) nb_cr.value=1;
for (var i=1; i<=nb_cr.value; i++) {
document.getElementById('c'+i).style.display='';
}
for (var i; i<=50; i++) {
document.getElementById('c'+i).style.display='none';
}
return false;
}
</script>
<?php
echo "<div class=\"page_sans_col_gauche\">";
if (isset($id_area)) {
$res = grr_sql_query("SELECT * FROM ".TABLE_PREFIX."_area WHERE id=$id_area");
if (! $res) fatal_error(0, get_vocab('error_area') . $id_area . get_vocab('not_found'));
$row = grr_sql_row_keyed($res, 0);
grr_sql_free($res);
if ($action=="duplique_area") {
echo "<h2>".get_vocab("duplique_domaine")."</h2>";
} else {
echo "<h2>".get_vocab("editarea")."</h2>";
}
if ($row["calendar_default_values"] == 'y') {
$row["morningstarts_area"] = $morningstarts;
$row["eveningends_area"] = $eveningends;
$row["resolution_area"] = $resolution;
$row["duree_par_defaut_reservation_area"] = $duree_par_defaut_reservation_area;
$row["duree_max_resa_area"] = $duree_max_resa;
$row["eveningends_minutes_area"] = $eveningends_minutes;
$row["weekstarts_area"] = $weekstarts;
$row["twentyfourhour_format_area"] = $twentyfourhour_format;
$row["display_days"] = $display_days;
}
if ($row["enable_periods"] != 'y') $row["enable_periods"] = 'n';
if (getSettingValue("module_multisite") == "Oui")
$id_site=grr_sql_query1("select id_site from ".TABLE_PREFIX."_j_site_area where id_area='".$id_area."'");
}
else
{
$row["id"] = '';
$row["area_name"] = '';
$row["filter_empty_resources"] = '';
$row["order_display"] = '';
$row["access"] = '';
$row["ip_adr"] = '';
$row["morningstarts_area"] = $morningstarts;
$row["eveningends_area"] = $eveningends;
$row["resolution_area"] = $resolution;
$row["duree_par_defaut_reservation_area"] = $resolution;
$row["duree_max_resa_area"] = $duree_max_resa;
$row["eveningends_minutes_area"] = $eveningends_minutes;
$row["weekstarts_area"] = $weekstarts;
$row["twentyfourhour_format_area"] = $twentyfourhour_format;
$row["enable_periods"] = 'n';
$row["display_days"] = "yyyyyyy";
$row['max_booking'] = '-1';
echo "<h2>".get_vocab('addarea')."</h2>";
}
?>
<form action="admin_edit_room.php" method="post" id="main">
<?php
echo "<div>";
if (isset($action)) echo "<input type=\"hidden\" name=\"action\" value=\"duplique_area\" />\n";
if (isset($retour_page)) echo "<input type=\"hidden\" name=\"retour_page\" value=\"".$retour_page."\" />";
if ($row['id'] != '') echo "<input type=\"hidden\" name=\"id_area\" value=\"".$row["id"]."\" />";
if (isset($add_area)) echo "<input type=\"hidden\" name=\"add_area\" value=\"".$add_area."\" />\n";
echo "</div>";
echo "<table border=\"1\" cellspacing=\"1\" cellpadding=\"6\"><tr>";
// Nom du domaine
echo "<td>".get_vocab("name").get_vocab("deux_points")."</td>\n";
echo "<td style=\"width:30%;\"><input type=\"text\" name=\"area_name\" size=\"40\" value=\"".my_htmlspecialcharacters($row["area_name"])."\" /></td>\n";
echo "</tr><tr>\n";
// Ordre d'affichage du domaine
echo "<td>".get_vocab("order_display").get_vocab("deux_points")."</td>\n";
echo "<td><input type=\"text\" name=\"area_order\" size=\"1\" value=\"".my_htmlspecialcharacters($row["order_display"])."\" /></td>\n";
echo "</tr><tr>\n";
// Accès restreint ou non ?
echo "<td>".get_vocab("access").get_vocab("deux_points")."</td>\n";
echo "<td><input type=\"checkbox\" name=\"access\"";
if ($row["access"] == 'r') echo "checked=\"checked\"";
echo " /></td>\n";
echo "</tr>";
echo "</tr><tr>\n";
// Est-ce qu'on masque les resources sans réservations ?
echo "<td>".get_vocab("filter_empty_resources").get_vocab("deux_points")."</td>\n";
echo "<td><input type=\"checkbox\" value=\"1\" name=\"filter_empty_resources\"";
if ($row["filter_empty_resources"] == '1') echo "checked=\"checked\"";
echo " /></td>\n";
echo "</tr>";
// Site
if (getSettingValue("module_multisite") == "Oui") {
// Affiche une liste déroulante des sites;
if(authGetUserLevel(getUserName(),-1,'area') >= 6)
$sql = "SELECT id,sitecode,sitename
FROM ".TABLE_PREFIX."_site
ORDER BY sitename ASC";
else
$sql = "SELECT id,sitecode,sitename
FROM ".TABLE_PREFIX."_site s, ".TABLE_PREFIX."_j_useradmin_site u
WHERE s.id=u.id_site and u.login='".getUserName()."'
ORDER BY s.sitename ASC";
$res = grr_sql_query($sql);
$nb_site = grr_sql_count($res);
echo "<tr><td>".get_vocab('site').get_vocab('deux_points')."</td>\n";
if ($nb_site > 1) {
echo "<td><select name=\"id_site\" >\n
<option value=\"-1\">".get_vocab('choose_a_site')."</option>\n";
for ($enr = 0; ($row1 = grr_sql_row($res, $enr)); $enr++) {
echo "<option value=\"".$row1[0]."\"";
if ($id_site == $row1[0])
echo ' selected="selected"';
echo '>'.my_htmlspecialcharacters($row1[2]);
echo '</option>'."\n";
}
grr_sql_free($res);
echo "</select></td></tr>";
} else {
// un seul site
$row1 = grr_sql_row($res, 0);
echo "<td>".$row1[2]."<input type=\"hidden\" name=\"id_site\" value=\"".$id_site."\" /></td></tr>\n";
}
}
// Adresse IP client :
if (OPTION_IP_ADR==1) {
echo "<tr>\n";
echo "<td>".get_vocab("ip_adr").get_vocab("deux_points")."</td>";
echo "<td><input type=\"text\" name=\"ip_adr\" value=\"".my_htmlspecialcharacters($row["ip_adr"])."\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan=\"2\">".get_vocab("ip_adr_explain")."</td>\n";
echo "</tr>\n";
}
echo "</table>";
// Configuration des plages horaires ...
echo "<h3>".get_vocab("configuration_plages_horaires").grr_help("Configuration_affichage","conf_planning")."</h3>";
// Début de la semaine: 0 pour dimanche, 1 pou lundi, etc.
echo "<table border=\"1\" cellspacing=\"1\" cellpadding=\"6\">";
echo "<tr>\n";
echo "<td>".get_vocab("weekstarts_area").get_vocab("deux_points")."</td>\n";
echo "<td style=\"width:30%;\"><select name=\"weekstarts_area\" size=\"1\">\n";