Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / front / helpdesk.resa.php @ b67d8923

Historique | Voir | Annoter | Télécharger (4,69 ko)

1
<?php
2
/*
3
 * @version $Id: helpdesk.resa.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
$NEEDED_ITEMS=array("reservation","search","user","computer","printer","monitor","peripheral","networking","software","phone");
37

    
38
define('GLPI_ROOT', '..');
39
include (GLPI_ROOT . "/inc/includes.php");
40

    
41

    
42
// Redirect management
43
if (isset($_GET["redirect"])){
44
        manageRedirect($_GET["redirect"]);
45
}
46

    
47
//*******************
48
        // Affichage Module reservation 
49
        //******************
50
        checkRight("reservation_helpdesk","1");
51
        $rr=new ReservationResa();
52
        if (isset($_POST["edit_resa"])){
53
                list($begin_year,$begin_month,$begin_day)=split("-",$_POST["begin_date"]);
54
                $id_item=key($_POST["items"]);
55
                if ($_SESSION["glpiID"]==$_POST["id_user"]){
56
                        $_POST['_target']=$_SERVER['PHP_SELF'];
57
                        $_POST['_item']=key($_POST["items"]);
58

    
59
                        if ($rr->update($_POST)){
60
                                        glpi_header($CFG_GLPI["root_doc"]."/front/helpdesk.resa.php?show=resa&ID=".$_POST['_item']."&mois_courant=$begin_month&annee_courante=$begin_year");
61
                        } else {
62
                                exit();
63
                        }
64
                }
65
        }
66

    
67
        helpHeader($LANG["title"][1],$_SERVER['PHP_SELF'],$_SESSION["glpiname"]);
68

    
69
        if (isset($_POST["clear_resa"])){
70
                $id_item=key($_POST["items"]);
71
                if ($rr->delete($_POST)){ // delete() need an array !
72
                        logEvent($_POST["ID"], "reservation", 4, "inventory", $_SESSION["glpiname"]." delete a reservation.");
73
                }
74
                list($begin_year,$begin_month,$begin_day)=split("-",$_POST["begin_date"]);
75
                $_GET["mois_courant"]=$begin_month;
76
                $_GET["annee_courant"]=$begin_year;
77
                printCalendrier($_SERVER['PHP_SELF'],$id_item);
78

    
79
        }
80

    
81
        if (isset($_GET["ID"])){
82
                printCalendrier($_SERVER['PHP_SELF'],$_GET["ID"]);
83
        }
84
        else if (isset($_GET["add_item"])){
85
                if (!isset($_GET["date"])) $_GET["date"]=date("Y-m-d");
86
                showAddReservationForm($_SERVER['PHP_SELF'],$_GET["add_item"],$_GET["date"]);
87
        }
88
        else if (isset($_GET["edit"])){
89
                showAddReservationForm($_SERVER['PHP_SELF'],$_GET["edit_item"],"",$_GET["edit"]);
90
        }
91
        else if (isset($_POST["add_resa"])){
92
                $all_ok=true;
93
                $id_item=0;
94
                foreach ($_POST['items'] as $id_item){
95
                        $_POST['id_item']=$id_item;
96
                        $ok=true;
97
                        $times=$_POST["periodicity_times"];
98
                        list($begin_year,$begin_month,$begin_day)=split("-",$_POST["begin_date"]);
99
                        list($end_year,$end_month,$end_day)=split("-",$_POST["end_date"]);
100
                        $to_add=1;
101
                        if ($_POST["periodicity"]=="week") {
102
                                $to_add=7;
103
                        }
104
                        $_POST['_target']=$_SERVER['PHP_SELF'];
105
                        $_POST['_ok']=true;
106
                        for ($i=1;$i<=$times&&$_POST['_ok'];$i++){
107
                                $_POST["begin_date"]=date("Y-m-d",mktime(0,0,0,$begin_month,$begin_day+($i-1)*$to_add,$begin_year));
108
                                $_POST["end_date"]=date("Y-m-d",mktime(0,0,0,$end_month,$end_day+($i-1)*$to_add,$end_year));
109
                                if ($_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"]." add a reservation.");
121
                        } else $all_ok=false;
122
                }
123

    
124
                if ($all_ok){
125
                        // Several reservations
126
                        if (count($_POST['items'])>1){
127
                                glpi_header($CFG_GLPI["root_doc"] . "/front/helpdesk.resa.php?ID=");
128
                        } else { // Only one reservation
129
                                glpi_header($CFG_GLPI["root_doc"] . "/front/helpdesk.resa.php?ID=".$_POST['id_item']);
130
                        }
131
                }
132
        }
133
        else {
134

    
135
                printReservationItems($_SERVER['PHP_SELF']);
136
        }
137

    
138
//*******************
139
// fin  Affichage Module reservation 
140
//*******************
141
helpFooter();
142

    
143

    
144
?>
Redmine Appliance - Powered by TurnKey Linux