Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / reminder.function.php @ b67d8923

Historique | Voir | Annoter | Télécharger (7,74 ko)

1
<?php
2
/*
3
 * @version $Id: reminder.function.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

    
33
if (!defined('GLPI_ROOT')){
34
        die("Sorry. You can't access directly to this file");
35
        }
36

    
37

    
38
function showCentralReminder($entity = -1, $parent = false){
39
        // show reminder that are not planned 
40

    
41
        global $DB,$CFG_GLPI, $LANG;
42

    
43
        $author=$_SESSION['glpiID'];        
44
        $today=$_SESSION["glpi_currenttime"];
45

    
46
        if ($entity < 0) {
47

    
48
                $query = "SELECT * FROM glpi_reminder WHERE FK_users='$author' AND private=1 AND (end>='$today' or rv='0') ";
49
                $titre = "<a href=\"".$CFG_GLPI["root_doc"]."/front/reminder.php\">".$LANG["reminder"][0]."</a>";        
50
                $private  = 1;
51

    
52
        } else if ($entity == $_SESSION["glpiactive_entity"]) {
53
                
54
                $query = "SELECT * FROM glpi_reminder WHERE private=0 ".getEntitiesRestrictRequest("AND","glpi_reminder","",$entity);
55
                $titre = "<a href=\"".$CFG_GLPI["root_doc"]."/front/reminder.php\">".$LANG["reminder"][1]."</a> (".getdropdownName("glpi_entities", $entity).")";
56
                
57
                if (haveRight("reminder_public","w")) {
58
                        $private  = 0;
59
                }
60
                
61
        } else if ($parent) {
62
                
63
                $query = "SELECT * FROM glpi_reminder WHERE private=0 AND recursive=1 ".getEntitiesRestrictRequest("AND","glpi_reminder","",$entity);
64
                $titre = $LANG["reminder"][1]." (".getdropdownName("glpi_entities", $entity).")";                
65
                
66
        } else { // Filles
67
                
68
                $query = "SELECT * FROM glpi_reminder WHERE private = 0 ".getEntitiesRestrictRequest("AND","glpi_reminder","",$entity);
69
                $titre = $LANG["reminder"][1]." (".getdropdownName("glpi_entities", $entity).")";
70

    
71
        }
72

    
73
        $result = $DB->query($query);
74
        $nb=$DB->numrows($result);
75

    
76
        if ($nb || isset($private)) {
77
                echo "<br><table class='tab_cadrehov'>";
78
        
79
                echo "<tr><th><div class='relative'><span>$titre</span>";
80
                if (isset($private)){
81
                        echo "<span class='reminder_right'><a href=\"".$CFG_GLPI["root_doc"]."/front/reminder.form.php?private=$private\"><img src=\"".$CFG_GLPI["root_doc"]."/pics/plus.png\" alt='+' title='".$LANG["buttons"][8]."'></a></span>";
82
                }
83
                echo "</div></th></tr>\n";
84
        }
85
        if ($nb) {
86
                $rand=mt_rand(); 
87
                while ($data =$DB->fetch_array($result)){ 
88

    
89
                        echo "<tr class='tab_bg_2'><td><div class='relative'><div class='reminder_list'><a href=\"".$CFG_GLPI["root_doc"]."/front/reminder.form.php?ID=".$data["ID"]."\">".$data["name"]."</a>";
90
                        echo "&nbsp;<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/aide.png' onmouseout=\"cleanhide('content_reminder_".$data["ID"].$rand."')\" onmouseover=\"cleandisplay('content_reminder_".$data["ID"].$rand."')\">";
91
                        echo "<div class='over_link' id='content_reminder_".$data["ID"].$rand."'>".$data["text"]."</div>";
92

    
93
                        if($data["rv"]=="1"){
94

    
95
                                $tab=split(" ",$data["begin"]);
96
                                $date_url=$tab[0];
97

    
98
                                echo "<span class='reminder_right'><a href=\"".$CFG_GLPI["root_doc"]."/front/planning.php?date=".$date_url."&amp;type=day\"><img src=\"".$CFG_GLPI["root_doc"]."/pics/rdv.png\" alt='".$LANG["Menu"][29]."' title='".convDateTime($data["begin"])."=>".convDateTime($data["end"])."'></a></span>";
99

    
100
                        }
101
                        echo "</div></div></td></tr>\n";
102
                }
103
        }
104

    
105
        if ($nb || isset($private)) {
106
                echo "</table>";
107
        }
108
}
109

    
110

    
111
function showListReminder($private=1,$recursive=0){
112
        // show reminder that are not planned 
113

    
114
        global $DB,$CFG_GLPI, $LANG;
115

    
116
        $planningRight=haveRight("show_planning","1");
117

    
118
        $author=$_SESSION['glpiID'];        
119

    
120
        if(!$private && $recursive){ // show public reminder
121
                $query="SELECT * FROM glpi_reminder WHERE private=0 and recursive = 1  ".getEntitiesRestrictRequest("AND","glpi_reminder","","",true);
122
                $titre=$LANG["reminder"][16];
123
        } else if(!$private && !$recursive){ // show public reminder
124
                $query="SELECT * FROM glpi_reminder WHERE private=0 and recursive = 0 ".getEntitiesRestrictRequest("AND","glpi_reminder");
125
                $titre=$LANG["reminder"][1];
126
        } else { // show private reminder
127
                $query="SELECT * FROM glpi_reminder WHERE FK_users='$author' AND private = 1 ";
128
                $titre=$LANG["reminder"][0];
129
        }
130

    
131

    
132
        $result = $DB->query($query);
133

    
134
        $tabremind=array();
135

    
136
        $remind=new Reminder();
137

    
138
        if ($DB->numrows($result)>0)
139
                for ($i=0 ; $data=$DB->fetch_array($result) ; $i++) {
140
                        $remind->getFromDB($data["ID"]);
141

    
142
                        if($data["rv"]==1){ //Un rdv on va trier sur la date begin
143
                                $sort=$data["begin"];
144
                        }else{ // non programmé on va trier sur la date de modif...
145
                                $sort=$data["date"];
146
                        }
147

    
148
                        $tabremind[$sort."$$".$i]["id_reminder"]=$remind->fields["ID"];
149
                        $tabremind[$sort."$$".$i]["FK_users"]=$remind->fields["FK_users"];
150
                        $tabremind[$sort."$$".$i]["entity"]=$remind->fields["FK_entities"];
151
                        $tabremind[$sort."$$".$i]["begin"]=($data["rv"]==1?"".$data["begin"]."":"".$data["date"]."");
152
                        $tabremind[$sort."$$".$i]["end"]=($data["rv"]==1?"".$data["end"]."":"");
153
                        $tabremind[$sort."$$".$i]["name"]=resume_text($remind->fields["name"],$CFG_GLPI["cut"]);
154
                        $tabremind[$sort."$$".$i]["text"]=resume_text($remind->fields["text"],$CFG_GLPI["cut"]);
155
                }
156

    
157

    
158

    
159
        ksort($tabremind);
160

    
161

    
162
        
163
        echo "<br><table class='tab_cadre_fixehov'>";
164
        if ($private) {
165
                echo "<tr><th>"."$titre"."</th><th colspan='2'>".$LANG["common"][27]."</th></tr>";
166
        } else {
167
                echo "<tr><th colspan='5'>"."$titre"."</th></tr>" .
168
                         "<tr><th>".$LANG["entity"][0]."</th><th>".$LANG["common"][37]."</th><th>".$LANG["title"][37]."</th>" .
169
                         "<th colspan='2'>".$LANG["common"][27]."</th></tr>";
170
                
171
        }
172

    
173
        if (count($tabremind)>0){
174
                foreach ($tabremind as $key => $val){
175

    
176
                        echo "<tr class='tab_bg_2'>";
177
                        
178
                        if (!$private) {
179
                                // ereg to split line (if needed) before ">" sign in completename
180
                                echo "<td>" .ereg_replace(" ([[:alnum:]])", "&nbsp;\\1", getdropdownName("glpi_entities", $val["entity"])). "</td>".
181
                                         "<td>" .getdropdownName("glpi_users", $val["FK_users"]) . "</td>";
182
                        }
183
                        echo         "<td width='60%' class='left'><a href=\"".$CFG_GLPI["root_doc"]."/front/reminder.form.php?ID=".$val["id_reminder"]."\">".$val["name"]."</a>" .
184
                                "<div class='kb_resume'>".resume_text($val["text"],125);
185
                                
186
                        /*
187
                        if ($type != 'private') {
188
                                echo "<br />&nbsp;<br /><strong>".
189
                                        getdropdownName("glpi_entities", $val["entity"]). "</strong> / ".
190
                                        getdropdownName("glpi_users", $val["FK_users"]);
191
                        } 
192
                        */
193
                        echo "</div></td>";
194

    
195
                        if($val["end"]!=""){        
196
                                echo "<td class='center'>";
197

    
198
                                $tab=split(" ",$val["begin"]);
199
                                $date_url=$tab[0];
200
                                if ($planningRight){
201
                                        echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/planning.php?date=".$date_url."&amp;type=day\">";
202
                                }
203
                                echo "<img src=\"".$CFG_GLPI["root_doc"]."/pics/rdv.png\" alt='".$LANG["Menu"][29]."' title='".$LANG["Menu"][29]."'>";
204
                                if ($planningRight){
205
                                        echo "</a>";
206
                                }
207
                                echo "</td>";
208
                                echo "<td class='center' >".convDateTime($val["begin"]);
209
                                echo "<br>".convDateTime($val["end"])."";
210

    
211
                        }else{
212
                                echo "<td>&nbsp;";
213
                                echo "</td>";
214
                                echo "<td  class='center'><span style='color:#aaaaaa;'>".convDateTime($val["begin"])."</span>";
215

    
216
                        }
217
                        echo "</td></tr>";
218
                }
219

    
220
        }
221

    
222
        echo "</table>";
223
}
224

    
225

    
226

    
227

    
228

    
229

    
230

    
231
?>
Redmine Appliance - Powered by TurnKey Linux