ryxeo-glpi-git / front / reservation.php @ b67d8923
Historique | Voir | Annoter | Télécharger (7,28 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: reservation.php 7763 2009-01-06 18:44:50Z moyo $
|
||
4 | -------------------------------------------------------------------------
|
||
5 | GLPI - Gestionnaire Libre de Parc Informatique
|
||
6 | Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
||
7 | |||
8 | http://indepnet.net/ http://glpi-project.org
|
||
9 | -------------------------------------------------------------------------
|
||
10 | |||
11 | LICENSE
|
||
12 | |||
13 | This file is part of GLPI.
|
||
14 | |||
15 | GLPI is free software; you can redistribute it and/or modify
|
||
16 | it under the terms of the GNU General Public License as published by
|
||
17 | the Free Software Foundation; either version 2 of the License, or
|
||
18 | (at your option) any later version.
|
||
19 | |||
20 | GLPI is distributed in the hope that it will be useful,
|
||
21 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
23 | GNU General Public License for more details.
|
||
24 | |||
25 | You should have received a copy of the GNU General Public License
|
||
26 | along with GLPI; if not, write to the Free Software
|
||
27 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
28 | --------------------------------------------------------------------------
|
||
29 | */
|
||
30 | |||
31 | // ----------------------------------------------------------------------
|
||
32 | // Original Author of file:
|
||
33 | // Purpose of file:
|
||
34 | // ----------------------------------------------------------------------
|
||
35 | |||
36 | |||
37 | |||
38 | $NEEDED_ITEMS=array("reservation","search","user","computer","printer","monitor","peripheral","networking","software","phone"); |
||
39 | |||
40 | define('GLPI_ROOT', '..'); |
||
41 | include (GLPI_ROOT . "/inc/includes.php"); |
||
42 | |||
43 | |||
44 | checkCentralAccess(); |
||
45 | |||
46 | |||
47 | $ri=new ReservationItem(); |
||
48 | $rr=new ReservationResa(); |
||
49 | |||
50 | if (isset($_POST["clear_resa"])||isset($_POST["add_resa"])||isset($_POST["edit_resa"])||(isset($_GET["show"]) && strcmp($_GET["show"],"resa") == 0)){ |
||
51 | |||
52 | checkRight("reservation_helpdesk","1"); |
||
53 | |||
54 | if (isset($_POST["edit_resa"])){ |
||
55 | list($begin_year,$begin_month,$begin_day)=split("-",$_POST["begin_date"]); |
||
56 | if (haveRight("reservation_central","w")||$_SESSION["glpiID"]==$_POST["id_user"]){ |
||
57 | $_POST['_target']=$_SERVER['PHP_SELF']; |
||
58 | $_POST['_item']=key($_POST["items"]); |
||
59 | if ($rr->update($_POST)){ |
||
60 | glpi_header($CFG_GLPI["root_doc"]."/front/reservation.php?show=resa&ID=".$_POST['_item']."&mois_courant=$begin_month&annee_courante=$begin_year"); |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | |||
65 | |||
66 | commonHeader($LANG["Menu"][17],$_SERVER['PHP_SELF'],"utils","reservation"); |
||
67 | if (isset($_POST["clear_resa"])){ |
||
68 | $id_item=key($_POST["items"]); |
||
69 | if ($rr->delete($_POST)){ |
||
70 | logEvent($_POST["ID"], "reservation", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][22]); |
||
71 | } |
||
72 | |||
73 | list($begin_year,$begin_month,$begin_day)=split("-",$_POST["begin_date"]); |
||
74 | $_GET["mois_courant"]=$begin_month; |
||
75 | $_GET["annee_courant"]=$begin_year; |
||
76 | printCalendrier($_SERVER['PHP_SELF'],$id_item); |
||
77 | } else if (isset($_GET["add_resa_on_item"])){ |
||
78 | if (!isset($_GET["date"])) $_GET["date"]=date("Y-m-d"); |
||
79 | if (count($_GET["add_item"])){ |
||
80 | showAddReservationForm($_SERVER['PHP_SELF'],$_GET["add_item"],$_GET["date"]); |
||
81 | }else {
|
||
82 | glpi_header($_SERVER['HTTP_REFERER']); |
||
83 | } |
||
84 | } |
||
85 | else if (isset($_GET["edit"])){ |
||
86 | showAddReservationForm($_SERVER['PHP_SELF'],$_GET["edit_item"],"",$_GET["edit"]); |
||
87 | } |
||
88 | else if (isset($_POST["add_resa"])){ |
||
89 | $all_ok=true; |
||
90 | $id_item=0; |
||
91 | foreach ($_POST['items'] as $id_item){ |
||
92 | $_POST['id_item']=$id_item; |
||
93 | |||
94 | $times=$_POST["periodicity_times"]; |
||
95 | list($begin_year,$begin_month,$begin_day)=split("-",$_POST["begin_date"]); |
||
96 | list($end_year,$end_month,$end_day)=split("-",$_POST["end_date"]); |
||
97 | $to_add=1; |
||
98 | |||
99 | if ($_POST["periodicity"]=="week") { |
||
100 | $to_add=7; |
||
101 | } |
||
102 | $_POST['_target']=$_SERVER['PHP_SELF']; |
||
103 | |||
104 | $_POST['_ok']=true; |
||
105 | for ($i=1;$i<=$times&&($_POST['_ok']);$i++){ |
||
106 | $_POST["begin_date"]=date("Y-m-d",mktime(0,0,0,$begin_month,$begin_day+($i-1)*$to_add,$begin_year)); |
||
107 | $_POST["end_date"]=date("Y-m-d",mktime(0,0,0,$end_month,$end_day+($i-1)*$to_add,$end_year)); |
||
108 | |||
109 | if (haveRight("reservation_central","w")||$_SESSION["glpiID"]==$_POST["id_user"]) { |
||
110 | unset($rr->fields["ID"]); |
||
111 | $_POST['_ok']=$rr->add($_POST); |
||
112 | } |
||
113 | |||
114 | } |
||
115 | // Positionnement du calendrier au mois de debut
|
||
116 | $_GET["mois_courant"]=$begin_month; |
||
117 | $_GET["annee_courant"]=$begin_year; |
||
118 | |||
119 | if ($_POST['_ok']){ |
||
120 | logEvent($_POST["id_item"], "reservation", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][20]); |
||
121 | } else $all_ok=false; |
||
122 | |||
123 | if ($all_ok){ |
||
124 | // Several reservations
|
||
125 | if (count($_POST['items'])>1){ |
||
126 | glpi_header($CFG_GLPI["root_doc"] . "/front/reservation.php?show=resa&ID="); |
||
127 | } else { // Only one reservation |
||
128 | glpi_header($CFG_GLPI["root_doc"] . "/front/reservation.php?show=resa&ID=$id_item"); |
||
129 | } |
||
130 | } |
||
131 | } |
||
132 | |||
133 | } else if (isset($_GET["ID"])){ |
||
134 | printCalendrier($_SERVER['PHP_SELF'],$_GET["ID"]); |
||
135 | }else {
|
||
136 | manageGetValuesInSearch(RESERVATION_TYPE);
|
||
137 | |||
138 | searchForm(RESERVATION_TYPE,$_SERVER['PHP_SELF'],$_GET["field"],$_GET["contains"],$_GET["sort"],$_GET["deleted"],$_GET["link"],$_GET["distinct"],$_GET["link2"],$_GET["contains2"],$_GET["field2"],$_GET["type2"]); |
||
139 | |||
140 | showList(RESERVATION_TYPE,$_SERVER['PHP_SELF'],$_GET["field"],$_GET["contains"],$_GET["sort"],$_GET["order"],$_GET["start"],$_GET["deleted"],$_GET["link"],$_GET["distinct"],$_GET["link2"],$_GET["contains2"],$_GET["field2"],$_GET["type2"]); |
||
141 | |||
142 | // printReservationItems($_SERVER['PHP_SELF']);
|
||
143 | } |
||
144 | } |
||
145 | else {
|
||
146 | checkSeveralRightsOr(array("reservation_central"=>"r","reservation_helpdesk"=>"1")); |
||
147 | if (!haveRight("reservation_central","r")){ |
||
148 | commonHeader($LANG["Menu"][17],$_SERVER['PHP_SELF'],"utils","reservation"); |
||
149 | printReservationItems($_SERVER['PHP_SELF']); |
||
150 | } |
||
151 | else {
|
||
152 | if (isset($_GET["add"])) |
||
153 | { |
||
154 | checkRight("reservation_central","w"); |
||
155 | if ($newID=$ri->add($_GET)){ |
||
156 | logEvent($newID, "reservation", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][20]." ".$_GET["device_type"]."-".$_GET["id_device"]."."); |
||
157 | } |
||
158 | glpi_header($_SERVER['HTTP_REFERER']); |
||
159 | } |
||
160 | else if (isset($_GET["delete"])) |
||
161 | { |
||
162 | checkRight("reservation_central","w"); |
||
163 | $ri->delete($_GET); |
||
164 | logEvent($_GET['ID'], "reservation", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][22]); |
||
165 | glpi_header($CFG_GLPI["root_doc"] . "/front/reservation.php"); |
||
166 | } else if (isset($_GET["active"])) |
||
167 | { |
||
168 | checkRight("reservation_central","w"); |
||
169 | $ri->update($_GET); |
||
170 | logEvent($_GET['ID'], "reservation", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][21]); |
||
171 | glpi_header($CFG_GLPI["root_doc"] . "/front/reservation.php"); |
||
172 | } |
||
173 | |||
174 | if (isset($_POST["updatecomment"])) |
||
175 | { |
||
176 | checkRight("reservation_central","w"); |
||
177 | $ri->update($_POST); |
||
178 | logEvent($_POST['ID'], "reservation", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][21]); |
||
179 | } |
||
180 | |||
181 | checkRight("reservation_central","r"); |
||
182 | |||
183 | commonHeader($LANG["Menu"][17],$_SERVER['PHP_SELF'],"utils","reservation"); |
||
184 | |||
185 | if (isset($_GET["comment"])){ |
||
186 | showReservationCommentForm($_SERVER['PHP_SELF'],$_GET["comment"]); |
||
187 | } else {
|
||
188 | |||
189 | manageGetValuesInSearch(RESERVATION_TYPE);
|
||
190 | |||
191 | searchForm(RESERVATION_TYPE,$_SERVER['PHP_SELF'],$_GET["field"],$_GET["contains"],$_GET["sort"],$_GET["deleted"],$_GET["link"],$_GET["distinct"],$_GET["link2"],$_GET["contains2"],$_GET["field2"],$_GET["type2"]); |
||
192 | |||
193 | showList(RESERVATION_TYPE,$_SERVER['PHP_SELF'],$_GET["field"],$_GET["contains"],$_GET["sort"],$_GET["order"],$_GET["start"],$_GET["deleted"],$_GET["link"],$_GET["distinct"],$_GET["link2"],$_GET["contains2"],$_GET["field2"],$_GET["type2"]); |
||
194 | } |
||
195 | } |
||
196 | } |
||
197 | commonFooter(); |
||
198 | |||
199 | |||
200 | ?> |