ryxeo-glpi-git / htdocs / inc / tracking.function.php @ 1c14bcc4
Historique | Voir | Annoter | Télécharger (85 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: tracking.function.php 7899 2009-01-26 14:24:47Z remi $
|
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 |
if (!defined('GLPI_ROOT')){ |
37 |
die("Sorry. You can't access directly to this file"); |
38 |
} |
39 |
|
40 |
|
41 |
// FUNCTIONS Tracking System
|
42 |
|
43 |
/**
|
44 |
* Print "onglets" (on the top of items forms)
|
45 |
*
|
46 |
* Print "onglets" for a better navigation.
|
47 |
*
|
48 |
*@param $target filename : The php file to display then
|
49 |
*
|
50 |
*@return nothing (diplays)
|
51 |
*
|
52 |
**/
|
53 |
function showTrackingOnglets($target){ |
54 |
global $LANG,$CFG_GLPI; |
55 |
|
56 |
if (preg_match("/\?ID=([0-9]+)/",$target,$ereg)){ |
57 |
$ID=$ereg[1]; |
58 |
|
59 |
$job=new Job(); |
60 |
$job->getFromDB($ID); |
61 |
|
62 |
echo "<div id='barre_onglets'><ul id='onglet'>"; |
63 |
|
64 |
if ($_SESSION["glpiactiveprofile"]["interface"]=="central"){ |
65 |
echo "<li class='actif'><a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.form.php?ID=$ID&onglet=1\">".$LANG["job"][38]." $ID</a></li>"; |
66 |
|
67 |
if (haveRight("show_all_ticket","1")){ |
68 |
displayPluginHeadings($target,TRACKING_TYPE,"",""); |
69 |
} |
70 |
|
71 |
echo "<li class='invisible'> </li>"; |
72 |
|
73 |
|
74 |
// admin yes
|
75 |
if ($job->canAddFollowups()){ |
76 |
echo "<li onClick=\"showAddFollowup(); Effect.Appear('viewfollowup');\" id='addfollowup'><span class='fake'>".$LANG["job"][29]."</span></li>"; |
77 |
} |
78 |
|
79 |
|
80 |
// Post-only could'nt see other item but other user yes
|
81 |
if (haveRight("show_all_ticket","1")){ |
82 |
echo "<li class='invisible'> </li>"; |
83 |
|
84 |
$next=getNextItem("glpi_tracking",$ID,"","ID"); |
85 |
$prev=getPreviousItem("glpi_tracking",$ID,"","ID"); |
86 |
$cleantarget=preg_replace("/\?ID=([0-9]+)/","",$target); |
87 |
if ($prev>0) echo "<li><a href='$cleantarget?ID=$prev'><img src=\"".$CFG_GLPI["root_doc"]."/pics/left.png\" alt='".$LANG["buttons"][12]."' title='".$LANG["buttons"][12]."'></a></li>"; |
88 |
if ($next>0) echo "<li><a href='$cleantarget?ID=$next'><img src=\"".$CFG_GLPI["root_doc"]."/pics/right.png\" alt='".$LANG["buttons"][11]."' title='".$LANG["buttons"][11]."'></a></li>"; |
89 |
} |
90 |
}elseif (haveRight("comment_ticket","1")){ |
91 |
|
92 |
// Postonly could post followup in helpdesk area
|
93 |
echo "<li class='actif'><a href=\"".$CFG_GLPI["root_doc"]."/front/helpdesk.public.php?show=user&ID=$ID\">".$LANG["job"][38]." $ID</a></li>"; |
94 |
|
95 |
if (!ereg("old_",$job->fields["status"])&&$job->fields["author"]==$_SESSION["glpiID"]){ |
96 |
echo "<li class='invisible'> </li>"; |
97 |
|
98 |
echo "<li onClick=\"showAddFollowup(); Effect.Appear('viewfollowup');\" id='addfollowup'><a href='#'>".$LANG["job"][29]."</span></a></li>"; |
99 |
} |
100 |
} |
101 |
|
102 |
} |
103 |
|
104 |
echo "</ul></div>"; |
105 |
|
106 |
} |
107 |
|
108 |
function getTrackingSortOptions() { |
109 |
|
110 |
global $LANG,$CFG_GLPI; |
111 |
|
112 |
$items[$LANG["joblist"][0]]="glpi_tracking.status"; |
113 |
$items[$LANG["common"][27]]="glpi_tracking.date"; |
114 |
$items[$LANG["common"][26]]="glpi_tracking.date_mod"; |
115 |
if (count($_SESSION["glpiactiveentities"])>1){ |
116 |
$items[$LANG["Menu"][37]]="glpi_entities.completename"; |
117 |
} |
118 |
$items[$LANG["joblist"][2]]="glpi_tracking.priority"; |
119 |
$items[$LANG["job"][4]]="glpi_tracking.author"; |
120 |
$items[$LANG["joblist"][4]]="glpi_tracking.assign"; |
121 |
$items[$LANG["common"][1]]="glpi_tracking.device_type,glpi_tracking.computer"; |
122 |
$items[$LANG["common"][36]]="glpi_dropdown_tracking_category.completename"; |
123 |
$items[$LANG["common"][57]]="glpi_tracking.name"; |
124 |
|
125 |
return $items; |
126 |
} |
127 |
|
128 |
function commonTrackingListHeader($output_type=HTML_OUTPUT,$target="",$parameters="",$sort="",$order=""){ |
129 |
global $LANG,$CFG_GLPI; |
130 |
|
131 |
// New Line for Header Items Line
|
132 |
echo displaySearchNewLine($output_type); |
133 |
// $show_sort if
|
134 |
$header_num=1; |
135 |
|
136 |
$items = getTrackingSortOptions();
|
137 |
|
138 |
foreach ($items as $key => $val){ |
139 |
$issort=0; |
140 |
$link=""; |
141 |
if ($sort==$val) $issort=1; |
142 |
$link=$target."?".$parameters."&order=".($order=="ASC"?"DESC":"ASC")."&sort=$val"; |
143 |
if (ereg("helpdesk.public.php",$target)){ |
144 |
$link.="&show=user"; |
145 |
} |
146 |
echo displaySearchHeaderItem($output_type,$key,$header_num,$link,$issort,$order); |
147 |
} |
148 |
|
149 |
// End Line for column headers
|
150 |
echo displaySearchEndLine($output_type); |
151 |
} |
152 |
|
153 |
function getTrackingOrderPrefs ($ID) { |
154 |
// Returns users preference settings for job tracking
|
155 |
// Currently only supports sort order
|
156 |
|
157 |
|
158 |
if($_SESSION["glpitracking_order"]) |
159 |
{ |
160 |
return "DESC"; |
161 |
} |
162 |
else
|
163 |
{ |
164 |
return "ASC"; |
165 |
} |
166 |
|
167 |
} |
168 |
|
169 |
function showCentralJobList($target,$start,$status="process",$showgrouptickets=true) { |
170 |
|
171 |
|
172 |
global $DB,$CFG_GLPI, $LANG; |
173 |
|
174 |
if (!haveRight("show_all_ticket","1")&&!haveRight("show_assign_ticket","1")) return false; |
175 |
|
176 |
$search_assign="assign = '".$_SESSION["glpiID"]."'"; |
177 |
if ($showgrouptickets){ |
178 |
if (count($_SESSION['glpigroups'])){ |
179 |
$first=true; |
180 |
$groups=""; |
181 |
foreach ($_SESSION['glpigroups'] as $val){ |
182 |
if (!$first) $groups.=","; |
183 |
else $first=false; |
184 |
$groups.="'".$val."'"; |
185 |
} |
186 |
$search_assign.= " OR assign_group IN ($groups) "; |
187 |
} |
188 |
} |
189 |
|
190 |
|
191 |
if($status=="waiting"){ // on affiche les tickets en attente |
192 |
$query = "SELECT ID FROM glpi_tracking WHERE ( $search_assign ) AND status ='waiting' ".getEntitiesRestrictRequest("AND","glpi_tracking")." ORDER BY date_mod ".getTrackingOrderPrefs($_SESSION["glpiID"]); |
193 |
|
194 |
if($showgrouptickets){ |
195 |
$title=$LANG["central"][16]; |
196 |
}else{
|
197 |
$title=$LANG["central"][11]; |
198 |
} |
199 |
|
200 |
}else{ // on affiche les tickets planifiés ou assignés à glpiID |
201 |
|
202 |
$query = "SELECT ID FROM glpi_tracking WHERE ( $search_assign ) AND (status ='plan' OR status = 'assign') ".getEntitiesRestrictRequest("AND","glpi_tracking")." ORDER BY date_mod ".getTrackingOrderPrefs($_SESSION["glpiID"]); |
203 |
|
204 |
if($showgrouptickets){ |
205 |
$title=$LANG["central"][15]; |
206 |
}else{
|
207 |
$title=$LANG["central"][9]; |
208 |
} |
209 |
} |
210 |
|
211 |
$lim_query = " LIMIT ".intval($start).",".intval($_SESSION["glpilist_limit"]).""; |
212 |
|
213 |
$result = $DB->query($query); |
214 |
$numrows = $DB->numrows($result); |
215 |
|
216 |
$query .= $lim_query; |
217 |
|
218 |
$result = $DB->query($query); |
219 |
$i = 0; |
220 |
$number = $DB->numrows($result); |
221 |
|
222 |
if ($number > 0) { |
223 |
echo "<table class='tab_cadrehov'>"; |
224 |
|
225 |
$link="assign=mine&status=$status&reset=reset_before"; |
226 |
// Only mine
|
227 |
if (!$showgrouptickets&&(haveRight("show_all_ticket","1")||haveRight("show_assign_ticket",'1'))){ |
228 |
$link="assign=".$_SESSION["glpiID"]."&status=$status&reset=reset_before"; |
229 |
} |
230 |
|
231 |
echo "<tr><th colspan='5'><a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.php?$link\">".$title."</a></th></tr>"; |
232 |
echo "<tr><th></th>"; |
233 |
echo "<th>".$LANG["job"][4]."</th>"; |
234 |
echo "<th>".$LANG["common"][1]."</th>"; |
235 |
echo "<th>".$LANG["joblist"][6]."</th></tr>"; |
236 |
while ($i < $number) { |
237 |
$ID = $DB->result($result, $i, "ID"); |
238 |
showJobVeryShort($ID);
|
239 |
$i++;
|
240 |
} |
241 |
echo "</table>"; |
242 |
} |
243 |
else
|
244 |
{ |
245 |
echo "<table class='tab_cadrehov'>"; |
246 |
echo "<tr><th>".$title."</th></tr>"; |
247 |
|
248 |
echo "</table>"; |
249 |
} |
250 |
} |
251 |
|
252 |
function showCentralJobCount(){ |
253 |
// show a tab with count of jobs in the central and give link
|
254 |
|
255 |
global $DB,$CFG_GLPI, $LANG; |
256 |
|
257 |
if (!haveRight("show_all_ticket","1")) return false; |
258 |
|
259 |
$query="SELECT status, COUNT(*) AS COUNT FROM glpi_tracking ".getEntitiesRestrictRequest("WHERE","glpi_tracking")." GROUP BY status"; |
260 |
|
261 |
|
262 |
|
263 |
$result = $DB->query($query); |
264 |
|
265 |
|
266 |
$status=array("new"=>0, "assign"=>0, "plan"=>0, "waiting"=>0); |
267 |
|
268 |
if ($DB->numrows($result)>0) |
269 |
while ($data=$DB->fetch_assoc($result)){ |
270 |
|
271 |
$status[$data["status"]]=$data["COUNT"]; |
272 |
} |
273 |
|
274 |
echo "<table class='tab_cadrehov' >"; |
275 |
|
276 |
echo "<tr><th colspan='2'><a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.php?status=process&reset=reset_before\">".$LANG["title"][10]."</a></th></tr>"; |
277 |
echo "<tr><th>".$LANG["title"][28]."</th><th>".$LANG["tracking"][29]."</th></tr>"; |
278 |
echo "<tr class='tab_bg_2'>"; |
279 |
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.php?status=new&reset=reset_before\">".$LANG["tracking"][30]."</a> </td>"; |
280 |
echo "<td>".$status["new"]."</td></tr>"; |
281 |
echo "<tr class='tab_bg_2'>"; |
282 |
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.php?status=assign&reset=reset_before\">".$LANG["tracking"][31]."</a></td>"; |
283 |
echo "<td>".$status["assign"]."</td></tr>"; |
284 |
echo "<tr class='tab_bg_2'>"; |
285 |
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.php?status=plan&reset=reset_before\">".$LANG["tracking"][32]."</a></td>"; |
286 |
echo "<td>".$status["plan"]."</td></tr>"; |
287 |
echo "<tr class='tab_bg_2'>"; |
288 |
echo "<td><a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.php?status=waiting&reset=reset_before\">".$LANG["joblist"][26]."</a></td>"; |
289 |
echo "<td>".$status["waiting"]."</td></tr>"; |
290 |
|
291 |
|
292 |
echo "</table><br>"; |
293 |
|
294 |
|
295 |
} |
296 |
|
297 |
|
298 |
|
299 |
|
300 |
function showOldJobListForItem($username,$item_type,$item,$sort="",$order="") { |
301 |
// $item is required
|
302 |
// affiche toutes les vielles intervention pour un $item donn�
|
303 |
|
304 |
|
305 |
global $DB,$CFG_GLPI, $LANG; |
306 |
|
307 |
if (!haveRight("show_all_ticket","1")) return false; |
308 |
|
309 |
$sortitems = getTrackingSortOptions();
|
310 |
if (!in_array($sort, $sortitems)) { |
311 |
$sort="glpi_tracking.date_mod"; |
312 |
} |
313 |
if ($order!="ASC" && $order!="DESC") { |
314 |
$order=getTrackingOrderPrefs($_SESSION["glpiID"]); |
315 |
} |
316 |
|
317 |
$where = "(status = 'old_done' OR status = 'old_notdone')"; |
318 |
|
319 |
$query = "SELECT ".getCommonSelectForTrackingSearch(). |
320 |
" FROM glpi_tracking ".getCommonLeftJoinForTrackingSearch().
|
321 |
" WHERE $where AND (device_type = '$item_type' and computer = '$item') ORDER BY $sort $order";
|
322 |
|
323 |
|
324 |
$result = $DB->query($query); |
325 |
|
326 |
$i = 0; |
327 |
$number = $DB->numrows($result); |
328 |
|
329 |
if ($number > 0) |
330 |
{ |
331 |
echo "<div class='center'> <table class='tab_cadre_fixe'>"; |
332 |
echo "<tr><th colspan='10'>".$number." ".$LANG["job"][18]." ".$LANG["job"][17]; |
333 |
echo " ".$LANG["job"][16].": "; |
334 |
echo "<a href='".$CFG_GLPI["root_doc"]."/front/tracking.php?reset=reset_before&status=all&item=$item&type=$item_type'>".$LANG["buttons"][23]."</a>"; |
335 |
|
336 |
echo "</th></tr>"; |
337 |
|
338 |
commonTrackingListHeader(HTML_OUTPUT,$_SERVER['PHP_SELF'],"ID=$item",$sort,$order); |
339 |
|
340 |
while ($data=$DB->fetch_assoc($result)){ |
341 |
showJobShort($data, 0); |
342 |
$i++;
|
343 |
} |
344 |
|
345 |
echo "</table></div>"; |
346 |
} |
347 |
else
|
348 |
{ |
349 |
echo "<br><div class='center'>"; |
350 |
echo "<table class='tab_cadre_fixe'>"; |
351 |
echo "<tr><th>".$LANG["joblist"][22]."</th></tr>"; |
352 |
echo "</table>"; |
353 |
echo "</div><br>"; |
354 |
} |
355 |
|
356 |
} |
357 |
|
358 |
function showJobListForItem($username,$item_type,$item,$sort="",$order="") { |
359 |
// $item is required
|
360 |
//affiche toutes les vielles intervention pour un $item donn�
|
361 |
|
362 |
global $DB,$CFG_GLPI, $LANG; |
363 |
|
364 |
if (!haveRight("show_all_ticket","1")) return false; |
365 |
|
366 |
$sortitems = getTrackingSortOptions();
|
367 |
if (!in_array($sort, $sortitems)) { |
368 |
$sort="glpi_tracking.date_mod"; |
369 |
} |
370 |
if ($order!="ASC" && $order!="DESC") { |
371 |
$order=getTrackingOrderPrefs($_SESSION["glpiID"]); |
372 |
} |
373 |
|
374 |
|
375 |
$where = "(status = 'new' OR status= 'assign' OR status='plan' OR status='waiting')"; |
376 |
|
377 |
$query = "SELECT ".getCommonSelectForTrackingSearch(). |
378 |
" FROM glpi_tracking ".getCommonLeftJoinForTrackingSearch().
|
379 |
" WHERE $where and (computer = '$item' and device_type= '$item_type') ORDER BY $sort $order";
|
380 |
|
381 |
$result = $DB->query($query); |
382 |
|
383 |
$number = $DB->numrows($result); |
384 |
|
385 |
if ($number > 0) |
386 |
{ |
387 |
echo "<div class='center'> <table class='tab_cadre_fixe'>"; |
388 |
echo "<tr><th colspan='10'>".$number." ".$LANG["job"][17].""; |
389 |
//if ($number > 1) { echo "s"; }
|
390 |
echo " ".$LANG["job"][16].": "; |
391 |
echo "<a href='".$CFG_GLPI["root_doc"]."/front/tracking.php?reset=reset_before&status=all&item=$item&type=$item_type'>".$LANG["buttons"][23]."</a>"; |
392 |
echo "</th></tr>"; |
393 |
|
394 |
if ($item) |
395 |
{ |
396 |
echo "<tr><td align='center' class='tab_bg_2' colspan='10'>"; |
397 |
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/helpdesk.php?computer=$item&device_type=$item_type\"><strong>"; |
398 |
echo $LANG["joblist"][7]; |
399 |
echo "</strong></a>"; |
400 |
echo "</td></tr>"; |
401 |
} |
402 |
|
403 |
commonTrackingListHeader(HTML_OUTPUT,$_SERVER['PHP_SELF'],"ID=$item",$sort,$order); |
404 |
|
405 |
while ($data=$DB->fetch_assoc($result)){ |
406 |
showJobShort($data, 0); |
407 |
} |
408 |
echo "</table></div>"; |
409 |
} |
410 |
else
|
411 |
{ |
412 |
echo "<br><div class='center'>"; |
413 |
echo "<table class='tab_cadre_fixe'>"; |
414 |
echo "<tr><th>".$LANG["joblist"][8]."</th></tr>"; |
415 |
|
416 |
if ($item) |
417 |
{ |
418 |
|
419 |
echo "<tr><td align='center' class='tab_bg_2'>"; |
420 |
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/helpdesk.php?computer=$item&device_type=$item_type\"><strong>"; |
421 |
echo $LANG["joblist"][7]; |
422 |
echo "</strong></a>"; |
423 |
echo "</td></tr>"; |
424 |
} |
425 |
echo "</table>"; |
426 |
echo "</div><br>"; |
427 |
} |
428 |
} |
429 |
|
430 |
|
431 |
function showJobShort($data, $followups,$output_type=HTML_OUTPUT,$row_num=0) { |
432 |
// Prints a job in short form
|
433 |
// Should be called in a <table>-segment
|
434 |
// Print links or not in case of user view
|
435 |
|
436 |
global $CFG_GLPI, $LANG; |
437 |
|
438 |
// Make new job object and fill it from database, if success, print it
|
439 |
$job = new Job; |
440 |
|
441 |
$job->fields = $data; |
442 |
$candelete=haveRight("delete_ticket","1"); |
443 |
$canupdate=haveRight("update_ticket","1"); |
444 |
// $viewusers=haveRight("user","r");
|
445 |
$align="align='center'"; |
446 |
$align_desc="align='left'"; |
447 |
if ($followups) { |
448 |
$align.=" valign='top' "; |
449 |
$align_desc.=" valign='top' "; |
450 |
} |
451 |
if ($data["ID"]) |
452 |
{ |
453 |
$item_num=1; |
454 |
$bgcolor=$CFG_GLPI["priority_".$data["priority"]]; |
455 |
|
456 |
echo displaySearchNewLine($output_type,$row_num%2); |
457 |
|
458 |
|
459 |
|
460 |
// First column
|
461 |
$first_col= "ID: ".$data["ID"]; |
462 |
if ($output_type==HTML_OUTPUT) |
463 |
$first_col.="<br><img src=\"".$CFG_GLPI["root_doc"]."/pics/".$data["status"].".png\" alt='".getStatusName($data["status"])."' title='".getStatusName($data["status"])."'>"; |
464 |
else $first_col.=" - ".getStatusName($data["status"]); |
465 |
if (($candelete||$canupdate)&&$output_type==HTML_OUTPUT){ |
466 |
$sel=""; |
467 |
if (isset($_GET["select"])&&$_GET["select"]=="all") { |
468 |
$sel="checked"; |
469 |
} |
470 |
if (isset($_SESSION['glpimassiveactionselected'][$data["ID"]])){ |
471 |
$sel="checked"; |
472 |
} |
473 |
$first_col.=" <input type='checkbox' name='item[".$data["ID"]."]' value='1' $sel>"; |
474 |
} |
475 |
|
476 |
|
477 |
echo displaySearchItem($output_type,$first_col,$item_num,$row_num,$align); |
478 |
|
479 |
// Second column
|
480 |
$second_col=""; |
481 |
if (!ereg("old_",$data["status"])) |
482 |
{ |
483 |
$second_col.="<span class='tracking_open'>".$LANG["joblist"][11].":"; |
484 |
if ($output_type==HTML_OUTPUT) $second_col.="<br>"; |
485 |
$second_col.= " ".convDateTime($data["date"])."</span>"; |
486 |
} |
487 |
else
|
488 |
{ $second_col.="<div class='tracking_hour'>"; |
489 |
$second_col.="".$LANG["joblist"][11].":"; |
490 |
if ($output_type==HTML_OUTPUT) $second_col.="<br>"; |
491 |
$second_col.=" <span class='tracking_bold'>".convDateTime($data["date"]); |
492 |
$second_col.="</span><br>"; |
493 |
$second_col.="".$LANG["joblist"][12].":"; |
494 |
if ($output_type==HTML_OUTPUT) $second_col.="<br>"; |
495 |
$second_col.=" <span class='tracking_bold'>".convDateTime($data["closedate"])."</span>"; |
496 |
$second_col.="<br>"; |
497 |
if ($data["realtime"]>0) $second_col.=$LANG["job"][20].": "; |
498 |
if ($output_type==HTML_OUTPUT) $second_col.="<br>"; |
499 |
$second_col.=" ".getRealtime($data["realtime"]); |
500 |
$second_col.="</div>"; |
501 |
} |
502 |
|
503 |
echo displaySearchItem($output_type,$second_col,$item_num,$row_num,$align." width=130"); |
504 |
|
505 |
// Second BIS column
|
506 |
$second_col=convDateTime($data["date_mod"]); |
507 |
|
508 |
echo displaySearchItem($output_type,$second_col,$item_num,$row_num,$align." width=90"); |
509 |
|
510 |
// Second TER column
|
511 |
if (count($_SESSION["glpiactiveentities"])>1){ |
512 |
|
513 |
if ($data['entityID']==0){ |
514 |
$second_col=$LANG["entity"][2]; |
515 |
} else {
|
516 |
$second_col=$data['entityname']; |
517 |
} |
518 |
|
519 |
echo displaySearchItem($output_type,$second_col,$item_num,$row_num,$align." width=100"); |
520 |
} |
521 |
|
522 |
// Third Column
|
523 |
echo displaySearchItem($output_type,"<strong>".getPriorityName($data["priority"])."</strong>",$item_num,$row_num,"$align bgcolor='$bgcolor'"); |
524 |
|
525 |
// Fourth Column
|
526 |
$fourth_col=""; |
527 |
if ($data['author']){ |
528 |
$userdata=getUserName($data['author'],2); |
529 |
|
530 |
$comments_display=""; |
531 |
if ($output_type==HTML_OUTPUT){ |
532 |
$comments_display="<a href='".$userdata["link"]."'>"; |
533 |
$comments_display.="<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/aide.png' onmouseout=\"cleanhide('comments_trackauthor".$data['ID']."')\" onmouseover=\"cleandisplay('comments_trackauthor".$data['ID']."')\">"; |
534 |
$comments_display.="</a>"; |
535 |
$comments_display.="<span class='over_link' id='comments_trackauthor".$data['ID']."'>".$userdata["comments"]."</span>"; |
536 |
} |
537 |
|
538 |
$fourth_col.="<strong>".$userdata['name']." ".$comments_display."</strong>"; |
539 |
} |
540 |
|
541 |
if ($data["FK_group"]) |
542 |
$fourth_col.="<br>".$data["groupname"]; |
543 |
|
544 |
echo displaySearchItem($output_type,$fourth_col,$item_num,$row_num,$align); |
545 |
|
546 |
// Fifth column
|
547 |
$fifth_col=""; |
548 |
if ($data["assign"]>0){ |
549 |
$userdata=getUserName($data['assign'],2); |
550 |
|
551 |
$comments_display=""; |
552 |
if ($output_type==HTML_OUTPUT){ |
553 |
$comments_display="<a href='".$userdata["link"]."'>"; |
554 |
$comments_display.="<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/aide.png' onmouseout=\"cleanhide('comments_trackassign".$data['ID']."')\" onmouseover=\"cleandisplay('comments_trackassign".$data['ID']."')\">"; |
555 |
$comments_display.="</a>"; |
556 |
$comments_display.="<span class='over_link' id='comments_trackassign".$data['ID']."'>".$userdata["comments"]."</span>"; |
557 |
} |
558 |
|
559 |
$fifth_col="<strong>".$userdata['name']." ".$comments_display."</strong>"; |
560 |
} |
561 |
|
562 |
if ($data["assign_group"]>0){ |
563 |
if (!empty($fifth_col)){ |
564 |
$fifth_col.="<br>"; |
565 |
} |
566 |
$fifth_col.=getAssignName($data["assign_group"],GROUP_TYPE,1); |
567 |
} |
568 |
|
569 |
if ($data["assign_ent"]>0){ |
570 |
if (!empty($fifth_col)){ |
571 |
$fifth_col.="<br>"; |
572 |
} |
573 |
$fifth_col.=getAssignName($data["assign_ent"],ENTERPRISE_TYPE,1); |
574 |
} |
575 |
echo displaySearchItem($output_type,$fifth_col,$item_num,$row_num,$align); |
576 |
|
577 |
$ci=new CommonItem(); |
578 |
$ci->getFromDB($data["device_type"],$data["computer"]); |
579 |
// Sixth Colum
|
580 |
$sixth_col=""; |
581 |
|
582 |
$sixth_col.=$ci->getType(); |
583 |
if ($data["device_type"]>0&&$data["computer"]>0){ |
584 |
$sixth_col.="<br><strong>"; |
585 |
if (haveTypeRight($data["device_type"],"r")){ |
586 |
$sixth_col.=$ci->getLink($output_type==HTML_OUTPUT); |
587 |
} else {
|
588 |
$sixth_col.=$ci->getNameID(); |
589 |
} |
590 |
$sixth_col.="</strong>"; |
591 |
} |
592 |
|
593 |
echo displaySearchItem($output_type,$sixth_col,$item_num,$row_num,$align." ".($ci->getField("deleted")?" class='deleted' ":"")); |
594 |
|
595 |
// Seventh column
|
596 |
echo displaySearchItem($output_type,"<strong>".$data["catname"]."</strong>",$item_num,$row_num,$align); |
597 |
|
598 |
// Eigth column
|
599 |
|
600 |
$eigth_column="<strong>".$data["name"]."</strong> "; |
601 |
|
602 |
if ($output_type==HTML_OUTPUT){ |
603 |
$eigth_column.= "<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/aide.png' onmouseout=\"cleanhide('comments_tracking".$data["ID"]."')\" onmouseover=\"cleandisplay('comments_tracking".$data["ID"]."')\" >"; |
604 |
$eigth_column.="<span class='over_link' id='comments_tracking".$data["ID"]."'>".nl2br($data['contents'])."</span>"; |
605 |
} |
606 |
|
607 |
// Add link
|
608 |
if ($_SESSION["glpiactiveprofile"]["interface"]=="central"){ |
609 |
if ($job->canShowTicket()) { |
610 |
$eigth_column="<a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.form.php?ID=".$data["ID"]."\">$eigth_column</a>"; |
611 |
if ($followups&&$output_type==HTML_OUTPUT){ |
612 |
$eigth_column.=showFollowupsShort($data["ID"]); |
613 |
} else {
|
614 |
$eigth_column.=" (".$job->numberOfFollowups(haveRight("show_full_ticket","1")).")"; |
615 |
} |
616 |
|
617 |
} |
618 |
} |
619 |
else {
|
620 |
$eigth_column="<a href=\"".$CFG_GLPI["root_doc"]."/front/helpdesk.public.php?show=user&ID=".$data["ID"]."\">$eigth_column</a>"; |
621 |
if ($followups&&$output_type==HTML_OUTPUT){ |
622 |
$eigth_column.=showFollowupsShort($data["ID"]); |
623 |
} else {
|
624 |
$eigth_column.=" (".$job->numberOfFollowups(haveRight("show_full_ticket","1")).")"; |
625 |
} |
626 |
|
627 |
} |
628 |
|
629 |
|
630 |
echo displaySearchItem($output_type,$eigth_column,$item_num,$row_num,$align_desc."width='300'"); |
631 |
|
632 |
// Finish Line
|
633 |
echo displaySearchEndLine($output_type); |
634 |
} |
635 |
else
|
636 |
{ |
637 |
echo "<tr class='tab_bg_2'><td colspan='6' ><i>".$LANG["joblist"][16]."</i></td></tr>"; |
638 |
} |
639 |
} |
640 |
|
641 |
function showJobVeryShort($ID) { |
642 |
// Prints a job in short form
|
643 |
// Should be called in a <table>-segment
|
644 |
// Print links or not in case of user view
|
645 |
|
646 |
global $CFG_GLPI, $LANG; |
647 |
|
648 |
// Make new job object and fill it from database, if success, print it
|
649 |
$job = new Job; |
650 |
$viewusers=haveRight("user","r"); |
651 |
if ($job->getFromDBwithData($ID,0)) |
652 |
{ |
653 |
$bgcolor=$CFG_GLPI["priority_".$job->fields["priority"]]; |
654 |
|
655 |
echo "<tr class='tab_bg_2'>"; |
656 |
echo "<td align='center' bgcolor='$bgcolor' >ID: ".$job->fields["ID"]."</td>"; |
657 |
echo "<td class='center'>"; |
658 |
|
659 |
if ($viewusers){ |
660 |
$userdata=getUserName($job->fields['author'],2); |
661 |
|
662 |
$comments_display=""; |
663 |
$comments_display="<a href='".$userdata["link"]."'>"; |
664 |
$comments_display.="<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/aide.png' onmouseout=\"cleanhide('comments_trackauthor".$ID."')\" onmouseover=\"cleandisplay('comments_trackauthor".$ID."')\">"; |
665 |
$comments_display.="</a>"; |
666 |
$comments_display.="<span class='over_link' id='comments_trackauthor".$ID."'>".$userdata["comments"]."</span>"; |
667 |
|
668 |
echo "<strong>".$userdata['name']." ".$comments_display."</strong>"; |
669 |
} else {
|
670 |
echo "<strong>".$job->getAuthorName()."</strong>"; |
671 |
} |
672 |
|
673 |
if ($job->fields["FK_group"]) |
674 |
echo "<br>".getDropdownName("glpi_groups",$job->fields["FK_group"]); |
675 |
|
676 |
|
677 |
echo "</td>"; |
678 |
|
679 |
if (haveTypeRight($job->fields["device_type"],"r")){ |
680 |
echo "<td align='center' "; |
681 |
if ($job->hardwaredatas->getField("deleted")){ |
682 |
echo "class='tab_bg_1_2'"; |
683 |
} |
684 |
echo ">"; |
685 |
echo $job->hardwaredatas->getType()."<br>"; |
686 |
echo "<strong>"; |
687 |
echo $job->hardwaredatas->getLink(); |
688 |
echo "</strong>"; |
689 |
|
690 |
echo "</td>"; |
691 |
} |
692 |
else {
|
693 |
echo "<td align='center' >".$job->hardwaredatas->getType()."<br><strong>".$job->hardwaredatas->getNameID()."</strong></td>"; |
694 |
} |
695 |
|
696 |
echo "<td>"; |
697 |
|
698 |
if ($_SESSION["glpiactiveprofile"]["interface"]=="central") |
699 |
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/tracking.form.php?ID=".$job->fields["ID"]."\"><strong>"; |
700 |
else
|
701 |
echo "<a href=\"".$CFG_GLPI["root_doc"]."/front/helpdesk.public.php?show=user&ID=".$job->fields["ID"]."\"><strong>"; |
702 |
|
703 |
echo $job->fields["name"]; |
704 |
echo "</strong> <img alt='".$LANG["joblist"][6]."' src='".$CFG_GLPI["root_doc"]."/pics/aide.png' onmouseout=\"cleanhide('comments_tracking".$job->fields["ID"]."')\" onmouseover=\"cleandisplay('comments_tracking".$job->fields["ID"]."')\" >"; |
705 |
echo "<span class='over_link' id='comments_tracking".$job->fields["ID"]."'>".nl2br($job->fields['contents'])."</span>"; |
706 |
echo "</a> (".$job->numberOfFollowups().") "; |
707 |
|
708 |
echo "</td>"; |
709 |
|
710 |
// Finish Line
|
711 |
echo "</tr>"; |
712 |
} |
713 |
else
|
714 |
{ |
715 |
echo "<tr class='tab_bg_2'><td colspan='6' ><i>".$LANG["joblist"][16]."</i></td></tr>"; |
716 |
} |
717 |
} |
718 |
|
719 |
function addFormTracking ($device_type=0,$ID=0, $target, $author, $group=0, $assign=0, $assign_group=0, $name='',$contents='',$category=0, $priority=3,$request_type=1,$hour=0,$minute=0) { |
720 |
// Prints a nice form to add jobs
|
721 |
|
722 |
global $CFG_GLPI, $LANG,$CFG_GLPI,$REFERER,$DB; |
723 |
if (!haveRight("create_ticket","1")) return false; |
724 |
|
725 |
/* if (!empty($error)) {
|
726 |
echo "<div class='center'><strong>$error</strong></div>";
|
727 |
}
|
728 |
*/
|
729 |
|
730 |
$add_url=""; |
731 |
if ($device_type>0){ |
732 |
$add_url="?device_type=$device_type&computer=$ID"; |
733 |
} |
734 |
echo "<br><form name='form_ticket' method='post' action='$target$add_url' enctype=\"multipart/form-data\">"; |
735 |
echo "<div class='center'>"; |
736 |
echo "<input type='hidden' name='FK_entities' value='".$_SESSION["glpiactive_entity"]."'>"; |
737 |
|
738 |
echo "<table class='tab_cadre_fixe'><tr><th colspan='4'>".$LANG["job"][13]; |
739 |
if (haveRight("comment_all_ticket","1")){ |
740 |
echo " "; |
741 |
dropdownStatus("status",1); |
742 |
} |
743 |
|
744 |
if (isMultiEntitiesMode()){
|
745 |
echo " (".getDropdownName("glpi_entities",$_SESSION["glpiactive_entity"]).")"; |
746 |
} |
747 |
|
748 |
echo '<br>'; |
749 |
|
750 |
if ($device_type>0){ |
751 |
$m=new CommonItem; |
752 |
$m->getFromDB($device_type,$ID); |
753 |
echo $m->getType()." - ".$m->getLink(); |
754 |
} |
755 |
|
756 |
echo "<input type='hidden' name='computer' value=\"$ID\">"; |
757 |
echo "<input type='hidden' name='device_type' value=\"$device_type\">"; |
758 |
|
759 |
echo "</th></tr>"; |
760 |
|
761 |
$author_rand=0; |
762 |
if (haveRight("update_ticket","1")){ |
763 |
echo "<tr class='tab_bg_2' align='center'><td>".$LANG["job"][4].":</td>"; |
764 |
echo "<td align='center'>"; |
765 |
$author_rand=dropdownAllUsers("author",$author,1,$_SESSION["glpiactive_entity"],1); |
766 |
|
767 |
echo "</td><td>".$LANG["common"][35].":</td>"; |
768 |
echo "<td align='center'>"; |
769 |
dropdownValue("glpi_groups","FK_group",$group,1,$_SESSION["glpiactive_entity"]); |
770 |
echo "</td></tr>"; |
771 |
} |
772 |
|
773 |
|
774 |
if ($device_type==0 && $_SESSION["glpiactiveprofile"]["helpdesk_hardware"]!=0){ |
775 |
echo "<tr class='tab_bg_2'>"; |
776 |
echo "<td class='center'>".$LANG["help"][24].": </td>"; |
777 |
echo "<td align='center' colspan='3'>"; |
778 |
dropdownMyDevices($_SESSION["glpiID"],$_SESSION["glpiactive_entity"]); |
779 |
dropdownTrackingAllDevices("device_type",$device_type,0,$_SESSION["glpiactive_entity"]); |
780 |
echo "</td></tr>"; |
781 |
} |
782 |
|
783 |
|
784 |
if (haveRight("update_ticket","1")){ |
785 |
echo "<tr class='tab_bg_2'><td class='center'>".$LANG["common"][27].":</td>"; |
786 |
echo "<td align='center' class='tab_bg_2'>"; |
787 |
showCalendarForm("form_ticket","date",date("Y-m-d H:i"),true,true); |
788 |
echo "</td>"; |
789 |
|
790 |
echo "<td class='center'>".$LANG["job"][44].":</td>"; |
791 |
echo "<td class='center'>"; |
792 |
dropdownRequestType("request_type",$request_type); |
793 |
echo "</td></tr>"; |
794 |
} |
795 |
|
796 |
|
797 |
// Need comment right to add a followup with the realtime
|
798 |
if (haveRight("comment_all_ticket","1")){ |
799 |
echo "<tr class='tab_bg_2'>"; |
800 |
echo "<td class='center'>"; |
801 |
echo $LANG["job"][20].":</td>"; |
802 |
echo "<td align='center' colspan='3'>"; |
803 |
dropdownInteger('hour',$hour,0,100); |
804 |
|
805 |
echo $LANG["job"][21]." "; |
806 |
dropdownInteger('minute',$minute,0,59); |
807 |
|
808 |
echo $LANG["job"][22]." "; |
809 |
echo "</td></tr>"; |
810 |
} |
811 |
|
812 |
|
813 |
echo "<tr class='tab_bg_2'>"; |
814 |
|
815 |
echo "<td class='tab_bg_2' align='center'>".$LANG["joblist"][2].":</td>"; |
816 |
echo "<td align='center' class='tab_bg_2'>"; |
817 |
|
818 |
dropdownPriority("priority",$priority); |
819 |
echo "</td>"; |
820 |
|
821 |
echo "<td>".$LANG["common"][36].":</td>"; |
822 |
echo "<td class='center'>"; |
823 |
dropdownValue("glpi_dropdown_tracking_category","category",$category); |
824 |
echo "</td></tr>"; |
825 |
|
826 |
if (haveRight("assign_ticket","1")||haveRight("steal_ticket","1")){ |
827 |
echo "<tr class='tab_bg_2' align='center'><td>".$LANG["buttons"][3].":</td>"; |
828 |
echo "<td colspan='3'>"; |
829 |
|
830 |
if (haveRight("assign_ticket","1")){ |
831 |
echo $LANG["job"][6].": "; |
832 |
dropdownUsers("assign",$assign,"own_ticket",0,1,$_SESSION["glpiactive_entity"]); |
833 |
echo "<br>".$LANG["common"][35].": "; |
834 |
dropdownValue("glpi_groups", "assign_group", $assign_group,1,$_SESSION["glpiactive_entity"]); |
835 |
|
836 |
} else if (haveRight("steal_ticket","1")) { |
837 |
echo $LANG["job"][6].": "; |
838 |
dropdownUsers("assign",$assign,"ID",0,1,$_SESSION["glpiactive_entity"]); |
839 |
} |
840 |
echo "</td></tr>"; |
841 |
|
842 |
} |
843 |
|
844 |
|
845 |
|
846 |
|
847 |
if(isAuthorMailingActivatedForHelpdesk()){
|
848 |
|
849 |
$query="SELECT email from glpi_users WHERE ID='$author'"; |
850 |
|
851 |
$result=$DB->query($query); |
852 |
$email=""; |
853 |
if ($result&&$DB->numrows($result)) |
854 |
$email=$DB->result($result,0,"email"); |
855 |
echo "<tr class='tab_bg_1'>"; |
856 |
echo "<td class='center'>".$LANG["help"][8].":</td>"; |
857 |
echo "<td class='center'>"; |
858 |
dropdownYesNo('emailupdates',!empty($email)); |
859 |
echo "</td>"; |
860 |
echo "<td class='center'>".$LANG["help"][11].":</td>"; |
861 |
echo "<td><span id='uemail_result'>"; |
862 |
echo "<input type='text' size='30' name='uemail' value='$email'>"; |
863 |
echo "</span>"; |
864 |
|
865 |
echo "</td></tr>"; |
866 |
|
867 |
} |
868 |
|
869 |
echo "</table><br><table class='tab_cadre_fixe'>"; |
870 |
echo "<tr><th class='center'>".$LANG["common"][57].":"; |
871 |
echo "</th><th colspan='3' class='left'>"; |
872 |
|
873 |
echo "<input type='text' size='80' name='name' value='$name'>"; |
874 |
echo "</th> </tr>"; |
875 |
|
876 |
|
877 |
echo "<tr><th colspan='4' align='center'>".$LANG["job"][11].":"; |
878 |
echo "</th></tr>"; |
879 |
|
880 |
echo "<tr class='tab_bg_1'><td colspan='4' align='center'><textarea cols='100' rows='6' name='contents'>$contents</textarea></td></tr>"; |
881 |
|
882 |
$max_size=return_bytes_from_ini_vars(ini_get("upload_max_filesize")); |
883 |
$max_size/=1024*1024; |
884 |
$max_size=round($max_size,1); |
885 |
|
886 |
echo "<tr class='tab_bg_1'><td>".$LANG["document"][2]." (".$max_size." ".$LANG["common"][45]."): "; |
887 |
echo "<img src=\"".$CFG_GLPI["root_doc"]."/pics/aide.png\"class='pointer;' alt=\"aide\"onClick=\"window.open('".$CFG_GLPI["root_doc"]."/front/typedoc.list.php','Help','scrollbars=1,resizable=1,width=1000,height=500')\">"; |
888 |
echo "</td>"; |
889 |
echo "<td colspan='3'><input type='file' name='filename' value=\"\" size='25'></td>"; |
890 |
echo "</tr>"; |
891 |
|
892 |
echo "<tr class='tab_bg_1'>"; |
893 |
|
894 |
echo "<td colspan='2' class='center'><a href='$target'><img title=\"".$LANG["buttons"][16]."\" alt=\"".$LANG["buttons"][16]."\" src='".$CFG_GLPI["root_doc"]."/pics/reset.png' class='calendrier'></a></td>"; |
895 |
|
896 |
|
897 |
|
898 |
echo "<td colspan='2' align='center'><input type='submit' name='add' value=\"".$LANG["buttons"][2]."\" class='submit'>"; |
899 |
|
900 |
echo "</td></tr></table>"; |
901 |
|
902 |
if (haveRight("comment_all_ticket","1")){ |
903 |
// echo "<tr><th colspan='4' align='center'>".$LANG["job"][45].":</th></tr>";
|
904 |
echo "<br>"; |
905 |
echo "<script type='text/javascript' >\n"; |
906 |
echo "function showPlan(){\n"; |
907 |
|
908 |
echo "window.document.getElementById('plan').style.display='none';"; |
909 |
$params=array('form'=>'followups', |
910 |
'state'=>1, |
911 |
'author'=>$_SESSION['glpiID'], |
912 |
'entity'=>$_SESSION["glpiactive_entity"], |
913 |
); |
914 |
ajaxUpdateItemJsCode('viewplan',$CFG_GLPI["root_doc"]."/ajax/planning.php",$params,false); |
915 |
|
916 |
echo "};"; |
917 |
echo "</script>"; |
918 |
|
919 |
showAddFollowupForm(-1);
|
920 |
//echo "</td></tr></table>";
|
921 |
// echo "<tr class='tab_bg_1'><td colspan='4' align='center'><textarea cols='80' rows='8' name='_followup'></textarea></td></tr>";
|
922 |
} |
923 |
|
924 |
echo "</div></form>"; |
925 |
|
926 |
} |
927 |
|
928 |
function getRealtime($realtime){ |
929 |
global $LANG; |
930 |
$output=""; |
931 |
$hour=floor($realtime); |
932 |
if ($hour>0) $output.=$hour." ".$LANG["job"][21]." "; |
933 |
$output.=round((($realtime-floor($realtime))*60))." ".$LANG["job"][22]; |
934 |
return $output; |
935 |
} |
936 |
|
937 |
function searchSimpleFormTracking($extended=0,$target,$status="all",$tosearch='',$search='',$group=-1,$showfollowups=0,$category=0){ |
938 |
|
939 |
global $CFG_GLPI, $LANG; |
940 |
|
941 |
|
942 |
echo "<div align='center' >"; |
943 |
|
944 |
echo "<form method='get' name=\"form\" action=\"".$target."\">"; |
945 |
echo "<table class='tab_cadre_fixe'>"; |
946 |
|
947 |
echo "<tr><th colspan='5' class='middle' ><div class='relative'><span>".$LANG["search"][0]."</span>"; |
948 |
$parm=""; |
949 |
if ($_SESSION["glpiactiveprofile"]["interface"]=="helpdesk"){ |
950 |
$parm="show=user&"; |
951 |
} |
952 |
|
953 |
if ($extended){ |
954 |
echo "<span class='tracking_right'><a href='$target?".$parm."extended=0'><img src=\"".$CFG_GLPI["root_doc"]."/pics/deplier_up.png\" alt=''>".$LANG["buttons"][36]."</a></span>"; |
955 |
} else {
|
956 |
echo "<span class='tracking_right'><a href='$target?".$parm."extended=1'><img src=\"".$CFG_GLPI["root_doc"]."/pics/deplier_down.png\" alt=''>".$LANG["buttons"][35]."</a></span>"; |
957 |
} |
958 |
echo "</div></th></tr>"; |
959 |
|
960 |
|
961 |
echo "<tr class='tab_bg_1' align='center'>"; |
962 |
echo "<td colspan='1' >".$LANG["joblist"][0].": "; |
963 |
echo "<select name='status'>"; |
964 |
echo "<option value='new' ".($status=="new"?" selected ":"").">".$LANG["joblist"][9]."</option>"; |
965 |
echo "<option value='assign' ".($status=="assign"?" selected ":"").">".$LANG["joblist"][18]."</option>"; |
966 |
echo "<option value='plan' ".($status=="plan"?" selected ":"").">".$LANG["joblist"][19]."</option>"; |
967 |
echo "<option value='waiting' ".($status=="waiting"?" selected ":"").">".$LANG["joblist"][26]."</option>"; |
968 |
echo "<option value='old_done' ".($status=="old_done"?" selected ":"").">".$LANG["joblist"][10]."</option>"; |
969 |
echo "<option value='old_notdone' ".($status=="old_notdone"?" selected ":"").">".$LANG["joblist"][17]."</option>"; |
970 |
echo "<option value='notold' ".($status=="notold"?"selected":"").">".$LANG["joblist"][24]."</option>"; |
971 |
echo "<option value='process' ".($status=="process"?"selected":"").">".$LANG["joblist"][21]."</option>"; |
972 |
echo "<option value='old' ".($status=="old"?"selected":"").">".$LANG["joblist"][25]."</option>"; |
973 |
echo "<option value='all' ".($status=="all"?"selected":"").">".$LANG["common"][66]."</option>"; |
974 |
echo "</select></td>"; |
975 |
|
976 |
if (haveRight("show_group_ticket",1)){ |
977 |
echo "<td class='center'>"; |
978 |
echo "<select name='group'>"; |
979 |
echo "<option value='-1' ".($group==-1?" selected ":"").">".$LANG["common"][66]."</option>"; |
980 |
echo "<option value='0' ".($group==0?" selected ":"").">".$LANG["joblist"][1]."</option>"; |
981 |
echo "</select>"; |
982 |
echo "</td>"; |
983 |
} else {
|
984 |
echo '<td> </td>'; |
985 |
} |
986 |
|
987 |
echo "<td class='center' colspan='2'>".$LANG["reports"][59].": "; |
988 |
dropdownYesNo('showfollowups',$showfollowups); |
989 |
echo "</td>"; |
990 |
|
991 |
if ($extended){ |
992 |
echo "<td>".$LANG["common"][36].": "; |
993 |
dropdownValue("glpi_dropdown_tracking_category","category",$category); |
994 |
echo "</td></tr>"; |
995 |
echo "<tr class='tab_bg_1' align='center'>"; |
996 |
echo "<td class='center' colspan='2'>"; |
997 |
$elts=array("name"=>$LANG["common"][57], |
998 |
"contents"=>$LANG["joblist"][6], |
999 |
"followup"=>$LANG["job"][7], |
1000 |
"name_contents"=>$LANG["common"][57]." / ".$LANG["joblist"][6], |
1001 |
"name_contents_followup"=>$LANG["common"][57]." / ".$LANG["joblist"][6]." / ".$LANG["job"][7], |
1002 |
"ID"=>"ID"); |
1003 |
echo "<select name='tosearch'>"; |
1004 |
foreach ($elts as $key => $val){ |
1005 |
$selected=""; |
1006 |
if ($tosearch==$key) $selected="selected"; |
1007 |
echo "<option value=\"$key\" $selected>$val</option>"; |
1008 |
} |
1009 |
echo "</select>"; |
1010 |
|
1011 |
|
1012 |
|
1013 |
echo " ".$LANG["search"][2]." "; |
1014 |
echo "<input type='text' size='15' name=\"search\" value=\"".stripslashes($search)."\">"; |
1015 |
echo "</td>"; |
1016 |
echo "<td colspan='2'> </td>"; |
1017 |
|
1018 |
} |
1019 |
|
1020 |
|
1021 |
echo "<td align='center' colspan='1'><input type='submit' value=\"".$LANG["buttons"][0]."\" class='submit'></td>"; |
1022 |
echo "</tr>"; |
1023 |
echo "</table>"; |
1024 |
echo "<input type='hidden' name='start' value='0'>"; |
1025 |
echo "<input type='hidden' name='extended' value='$extended'>"; |
1026 |
// helpdesk case
|
1027 |
if (ereg("helpdesk.public.php",$target)){ |
1028 |
echo "<input type='hidden' name='show' value='user'>"; |
1029 |
} |
1030 |
echo "</form>"; |
1031 |
echo "</div>"; |
1032 |
|
1033 |
} |
1034 |
|
1035 |
function searchFormTracking($extended=0,$target,$start="",$status="new",$tosearch="",$search="",$author=0,$group=0,$showfollowups=0,$category=0,$assign=0,$assign_ent=0,$assign_group=0,$priority=0,$request_type=0,$item=0,$type=0,$field="",$contains="",$date1="",$date2="",$computers_search="",$enddate1="",$enddate2="",$datemod1="",$datemod2="",$recipient=0) { |
1036 |
// Print Search Form
|
1037 |
|
1038 |
global $CFG_GLPI, $LANG, $DB; |
1039 |
|
1040 |
if (!haveRight("show_all_ticket","1")) { |
1041 |
|
1042 |
if (haveRight("show_assign_ticket","1")) { |
1043 |
$assign='mine'; |
1044 |
} else if ($author==0&&$assign==0) |
1045 |
if (!haveRight("own_ticket","1")){ |
1046 |
$author=$_SESSION["glpiID"]; |
1047 |
} else {
|
1048 |
$assign=$_SESSION["glpiID"]; |
1049 |
} |
1050 |
} |
1051 |
|
1052 |
if ($extended==1){ |
1053 |
$option["comp.ID"] = $LANG["common"][2]; |
1054 |
$option["comp.name"] = $LANG["common"][16]; |
1055 |
$option["glpi_dropdown_locations.name"] = $LANG["common"][15]; |
1056 |
$option["glpi_type_computers.name"] = $LANG["common"][17]; |
1057 |
$option["glpi_dropdown_model.name"] = $LANG["common"][22]; |
1058 |
$option["glpi_dropdown_os.name"] = $LANG["computers"][9]; |
1059 |
$option["processor.designation"] = $LANG["computers"][21]; |
1060 |
$option["comp.serial"] = $LANG["common"][19]; |
1061 |
$option["comp.otherserial"] = $LANG["common"][20]; |
1062 |
$option["ram.designation"] = $LANG["computers"][23]; |
1063 |
$option["iface.designation"] = $LANG["setup"][9]; |
1064 |
$option["sndcard.designation"] = $LANG["devices"][7]; |
1065 |
$option["gfxcard.designation"] = $LANG["devices"][2]; |
1066 |
$option["moboard.designation"] = $LANG["devices"][5]; |
1067 |
$option["hdd.designation"] = $LANG["computers"][36]; |
1068 |
$option["comp.comments"] = $LANG["common"][25]; |
1069 |
$option["comp.contact"] = $LANG["common"][18]; |
1070 |
$option["comp.contact_num"] = $LANG["common"][21]; |
1071 |
$option["comp.date_mod"] = $LANG["common"][26]; |
1072 |
$option["glpi_networking_ports.ifaddr"] = $LANG["networking"][14]; |
1073 |
$option["glpi_networking_ports.ifmac"] = $LANG["networking"][15]; |
1074 |
$option["glpi_dropdown_netpoint.name"] = $LANG["networking"][51]; |
1075 |
$option["glpi_enterprises.name"] = $LANG["common"][5]; |
1076 |
$option["resptech.name"] =$LANG["common"][10]; |
1077 |
} |
1078 |
echo "<form method='get' name=\"form\" action=\"".$target."\">"; |
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
echo "<table class='tab_cadre_fixe'>"; |
1084 |
|
1085 |
|
1086 |
echo "<tr><th colspan='6' class='middle' ><div class='relative'><span>".$LANG["search"][0]."</span>"; |
1087 |
if ($extended){ |
1088 |
echo "<span class='tracking_right'><a href='$target?extended=0'><img src=\"".$CFG_GLPI["root_doc"]."/pics/deplier_up.png\" alt=''>".$LANG["buttons"][36]."</a></span>"; |
1089 |
} else {
|
1090 |
echo "<span class='tracking_right'><a href='$target?extended=1'><img src=\"".$CFG_GLPI["root_doc"]."/pics/deplier_down.png\" alt=''>".$LANG["buttons"][35]."</a></span>"; |
1091 |
} |
1092 |
echo "</div></th></tr>"; |
1093 |
|
1094 |
|
1095 |
|
1096 |
echo "<tr class='tab_bg_1'>"; |
1097 |
echo "<td colspan='1' align='center'>".$LANG["joblist"][0].":<br>"; |
1098 |
echo "<select name='status'>"; |
1099 |
echo "<option value='new' ".($status=="new"?" selected ":"").">".$LANG["joblist"][9]."</option>"; |
1100 |
echo "<option value='assign' ".($status=="assign"?" selected ":"").">".$LANG["joblist"][18]."</option>"; |
1101 |
echo "<option value='plan' ".($status=="plan"?" selected ":"").">".$LANG["joblist"][19]."</option>"; |
1102 |
echo "<option value='waiting' ".($status=="waiting"?" selected ":"").">".$LANG["joblist"][26]."</option>"; |
1103 |
echo "<option value='old_done' ".($status=="old_done"?" selected ":"").">".$LANG["joblist"][10]."</option>"; |
1104 |
echo "<option value='old_notdone' ".($status=="old_notdone"?" selected ":"").">".$LANG["joblist"][17]."</option>"; |
1105 |
echo "<option value='notold' ".($status=="notold"?"selected":"").">".$LANG["joblist"][24]."</option>"; |
1106 |
echo "<option value='process' ".($status=="process"?"selected":"").">".$LANG["joblist"][21]."</option>"; |
1107 |
echo "<option value='old' ".($status=="old"?"selected":"").">".$LANG["joblist"][25]."</option>"; |
1108 |
echo "<option value='all' ".($status=="all"?"selected":"").">".$LANG["common"][66]."</option>"; |
1109 |
echo "</select></td>"; |
1110 |
|
1111 |
|
1112 |
echo "<td colspan='1' class='center'>".$LANG["joblist"][2].":<br>"; |
1113 |
dropdownPriority("priority",$priority,1); |
1114 |
echo "</td>"; |
1115 |
|
1116 |
echo "<td colspan='2' class='center'>".$LANG["common"][36].":<br>"; |
1117 |
dropdownValue("glpi_dropdown_tracking_category","category",$category); |
1118 |
echo "</td>"; |
1119 |
|
1120 |
echo "<td colspan='2' class='center'>".$LANG["job"][44].":<br>"; |
1121 |
dropdownRequestType("request_type",$request_type); |
1122 |
echo "</td>"; |
1123 |
|
1124 |
echo "</tr>"; |
1125 |
echo "<tr class='tab_bg_1'>"; |
1126 |
|
1127 |
echo "<td class='center' colspan='2'>"; |
1128 |
echo "<table border='0'><tr><td>".$LANG["common"][1].":</td><td>"; |
1129 |
dropdownAllItems("item",$type,$item); |
1130 |
echo "</td></tr></table>"; |
1131 |
echo "</td>"; |
1132 |
|
1133 |
echo "<td colspan='2' class='center'>".$LANG["job"][4].":<br>"; |
1134 |
dropdownUsersTracking("author",$author,"author"); |
1135 |
|
1136 |
echo "<br>".$LANG["common"][35].": "; |
1137 |
dropdownValue("glpi_groups","group",$group); |
1138 |
echo "</td>"; |
1139 |
|
1140 |
|
1141 |
echo "<td colspan='2' align='center'>".$LANG["job"][5].":<br>"; |
1142 |
if (strcmp($assign,"mine")==0){ |
1143 |
echo formatUserName($_SESSION["glpiID"],$_SESSION["glpiname"],$_SESSION["glpirealname"],$_SESSION["glpifirstname"]); |
1144 |
// Display the group if unique
|
1145 |
if (count($_SESSION['glpigroups'])==1){ |
1146 |
echo "<br>".getDropdownName("glpi_groups",current($_SESSION['glpigroups'])); |
1147 |
} else if (count($_SESSION['glpigroups'])>1){ // Display limited dropdown |
1148 |
echo "<br>"; |
1149 |
$groups[0]='-----'; |
1150 |
$groups=array_merge($groups,getDropdownArrayNames('glpi_groups',$_SESSION['glpigroups'])); |
1151 |
dropdownArrayValues('assign_group',$groups,$assign_group); |
1152 |
} |
1153 |
} else {
|
1154 |
dropdownUsers("assign",$assign,"own_ticket",1); |
1155 |
echo "<br>".$LANG["common"][35].": "; |
1156 |
dropdownValue("glpi_groups","assign_group",$assign_group); |
1157 |
|
1158 |
echo "<br>"; |
1159 |
echo $LANG["financial"][26].": "; |
1160 |
dropdownValue("glpi_enterprises","assign_ent",$assign_ent); |
1161 |
} |
1162 |
|
1163 |
echo "</td>"; |
1164 |
|
1165 |
echo "</tr>"; |
1166 |
|
1167 |
if ($extended){ |
1168 |
echo "<tr class='tab_bg_1'><td colspan='6' class='center'>".$LANG["job"][3].":"; |
1169 |
dropdownUsersTracking("recipient",$recipient,"recipient"); |
1170 |
echo "</td></tr>"; |
1171 |
|
1172 |
echo "<tr class='tab_bg_1'>"; |
1173 |
echo "<td class='center' colspan='6'>"; |
1174 |
$selected=""; |
1175 |
if ($computers_search) $selected="checked"; |
1176 |
echo "<input type='checkbox' name='only_computers' value='1' $selected>".$LANG["reports"][24].": "; |
1177 |
|
1178 |
echo "<input type='text' size='15' name=\"contains\" value=\"". stripslashes($contains) ."\" >"; |
1179 |
echo " "; |
1180 |
echo $LANG["search"][10]." "; |
1181 |
|
1182 |
echo "<select name='field' size='1'>"; |
1183 |
echo "<option value='all' "; |
1184 |
if($field == "all") echo "selected"; |
1185 |
echo ">".$LANG["common"][66]."</option>"; |
1186 |
reset($option); |
1187 |
foreach ($option as $key => $val) { |
1188 |
echo "<option value=\"".$key."\""; |
1189 |
if($key == $field) echo "selected"; |
1190 |
echo ">". $val ."</option>\n"; |
1191 |
} |
1192 |
echo "</select> "; |
1193 |
|
1194 |
echo "</td></tr>"; |
1195 |
} |
1196 |
if($extended) { |
1197 |
echo "<tr class='tab_bg_1'><td colspan='2' class='right'>".$LANG["reports"][60].":</td><td class='center' colspan='2'>".$LANG["search"][8].": "; |
1198 |
showCalendarForm("form","date1",$date1); |
1199 |
echo "</td><td class='center' colspan='2'>"; |
1200 |
echo $LANG["search"][9].": "; |
1201 |
showCalendarForm("form","date2",$date2); |
1202 |
echo "</td></tr>"; |
1203 |
|
1204 |
echo "<tr class='tab_bg_1'><td colspan='2' class='right'>".$LANG["reports"][61].":</td><td class='center' colspan='2'>".$LANG["search"][8].": "; |
1205 |
showCalendarForm("form","enddate1",$enddate1); |
1206 |
echo "</td><td class='center' colspan='2'>"; |
1207 |
echo $LANG["search"][9].": "; |
1208 |
showCalendarForm("form","enddate2",$enddate2); |
1209 |
echo "</td></tr>"; |
1210 |
|
1211 |
echo "<tr class='tab_bg_1'><td colspan='2' class='right'>".$LANG["common"][26].":</td><td class='center' colspan='2'>".$LANG["search"][8].": "; |
1212 |
showCalendarForm("form","datemod1",$datemod1); |
1213 |
echo "</td><td class='center' colspan='2'>"; |
1214 |
echo $LANG["search"][9].": "; |
1215 |
showCalendarForm("form","datemod2",$datemod2); |
1216 |
echo "</td></tr>"; |
1217 |
} |
1218 |
echo "<tr class='tab_bg_1'>"; |
1219 |
|
1220 |
echo "<td class='center' colspan='2'>"; |
1221 |
$elts=array("name"=>$LANG["common"][57], |
1222 |
"contents"=>$LANG["joblist"][6], |
1223 |
"followup"=>$LANG["job"][7], |
1224 |
"name_contents"=>$LANG["common"][57]." / ".$LANG["joblist"][6], |
1225 |
"name_contents_followup"=>$LANG["common"][57]." / ".$LANG["joblist"][6]." / ".$LANG["job"][7], |
1226 |
"ID"=>"ID"); |
1227 |
echo "<select name='tosearch'>"; |
1228 |
foreach ($elts as $key => $val){ |
1229 |
$selected=""; |
1230 |
if ($tosearch==$key) $selected="selected"; |
1231 |
echo "<option value=\"$key\" $selected>$val</option>"; |
1232 |
} |
1233 |
echo "</select>"; |
1234 |
|
1235 |
|
1236 |
|
1237 |
echo " ".$LANG["search"][2]." "; |
1238 |
echo "<input type='text' size='15' name=\"search\" value=\"".stripslashes($search)."\">"; |
1239 |
echo "</td>"; |
1240 |
|
1241 |
echo "<td class='center' colspan='2'>".$LANG["reports"][59].": "; |
1242 |
dropdownYesNo('showfollowups',$showfollowups); |
1243 |
echo "</td>"; |
1244 |
|
1245 |
|
1246 |
echo "<td class='center' colspan='1'><input type='submit' value=\"".$LANG["buttons"][0]."\" class='submit'></td>"; |
1247 |
echo "<td class='center' colspan='1'><input type='submit' name='reset' value=\"".$LANG["buttons"][16]."\" class='submit'></td>"; |
1248 |
|
1249 |
echo "</tr>"; |
1250 |
|
1251 |
echo "</table>"; |
1252 |
echo "<input type='hidden' name='start' value='0'>"; |
1253 |
echo "</form>"; |
1254 |
|
1255 |
|
1256 |
} |
1257 |
|
1258 |
|
1259 |
function getCommonSelectForTrackingSearch(){ |
1260 |
$SELECT=""; |
1261 |
if (count($_SESSION["glpiactiveentities"])>1){ |
1262 |
$SELECT.= ", glpi_entities.completename as entityname, glpi_tracking.FK_entities as entityID"; |
1263 |
} |
1264 |
|
1265 |
|
1266 |
return " DISTINCT glpi_tracking.*, |
1267 |
glpi_dropdown_tracking_category.completename AS catname,
|
1268 |
glpi_groups.name as groupname ".$SELECT; |
1269 |
|
1270 |
//, author.name AS authorname, author.realname AS authorrealname, author.firstname AS authorfirstname,
|
1271 |
//glpi_tracking.assign as assignID, assign.name AS assignname, assign.realname AS assignrealname, assign.firstname AS assignfirstname,
|
1272 |
} |
1273 |
|
1274 |
function getCommonLeftJoinForTrackingSearch(){ |
1275 |
|
1276 |
$FROM=""; |
1277 |
|
1278 |
if (count($_SESSION["glpiactiveentities"])>1){ |
1279 |
$FROM.= " LEFT JOIN glpi_entities ON ( glpi_entities.ID = glpi_tracking.FK_entities)"; |
1280 |
} |
1281 |
|
1282 |
return //" LEFT JOIN glpi_users as author ON ( glpi_tracking.author = author.ID) " |
1283 |
//." LEFT JOIN glpi_users as assign ON ( glpi_tracking.assign = assign.ID) "
|
1284 |
" LEFT JOIN glpi_groups ON ( glpi_tracking.FK_group = glpi_groups.ID) "
|
1285 |
." LEFT JOIN glpi_dropdown_tracking_category ON ( glpi_tracking.category = glpi_dropdown_tracking_category.ID) ".$FROM; |
1286 |
} |
1287 |
|
1288 |
|
1289 |
function showTrackingList($target,$start="",$sort="",$order="",$status="new",$tosearch="",$search="",$author=0,$group=0,$showfollowups=0,$category=0,$assign=0,$assign_ent=0,$assign_group=0,$priority=0,$request_type=0,$item=0,$type=0,$field="",$contains="",$date1="",$date2="",$computers_search="",$enddate1="",$enddate2="",$datemod1="",$datemod2="",$recipient=0) { |
1290 |
// Lists all Jobs, needs $show which can have keywords
|
1291 |
// (individual, unassigned) and $contains with search terms.
|
1292 |
// If $item is given, only jobs for a particular machine
|
1293 |
// are listed.
|
1294 |
// group = 0 : not use
|
1295 |
// group = -1 : groups of the author if session variable OK
|
1296 |
// group > 0 : specific group
|
1297 |
|
1298 |
global $DB,$CFG_GLPI, $LANG; |
1299 |
|
1300 |
$candelete=haveRight("delete_ticket","1"); |
1301 |
$canupdate=haveRight("update_ticket","1"); |
1302 |
|
1303 |
if (!haveRight("show_all_ticket","1")) { |
1304 |
if (haveRight("show_assign_ticket","1")) { |
1305 |
$assign='mine'; |
1306 |
} else if ($author==0&&$assign==0) |
1307 |
if (!haveRight("own_ticket","1")){ |
1308 |
$author=$_SESSION["glpiID"]; |
1309 |
} else {
|
1310 |
$assign=$_SESSION["glpiID"]; |
1311 |
} |
1312 |
} |
1313 |
|
1314 |
// Reduce computer list
|
1315 |
$wherecomp=""; |
1316 |
if ($computers_search&&!empty($contains)){ |
1317 |
$SEARCH=makeTextSearch($contains); |
1318 |
// Build query
|
1319 |
if($field == "all") { |
1320 |
$wherecomp = " ("; |
1321 |
$query = "SHOW COLUMNS FROM glpi_computers"; |
1322 |
$result = $DB->query($query); |
1323 |
$i = 0; |
1324 |
|
1325 |
while($line = $DB->fetch_array($result)) { |
1326 |
if($i != 0) { |
1327 |
$wherecomp .= " OR "; |
1328 |
} |
1329 |
if(IsDropdown($line["Field"])) { |
1330 |
$wherecomp .= " glpi_dropdown_". $line["Field"] .".name $SEARCH" ; |
1331 |
} |
1332 |
elseif($line["Field"] == "location") { |
1333 |
$wherecomp .= " glpi_dropdown_locations.name $SEARCH"; |
1334 |
} |
1335 |
else {
|
1336 |
$wherecomp .= "comp.".$line["Field"] . $SEARCH; |
1337 |
} |
1338 |
$i++;
|
1339 |
} |
1340 |
foreach($CFG_GLPI["devices_tables"] as $key => $val) { |
1341 |
if ($val!="drive"&&$val!="control"&&$val!="pci"&&$val!="case"&&$val!="power") |
1342 |
$wherecomp .= " OR ".$val.".designation ".makeTextSearch($contains,0); |
1343 |
} |
1344 |
$wherecomp .= " OR glpi_networking_ports.ifaddr $SEARCH"; |
1345 |
$wherecomp .= " OR glpi_networking_ports.ifmac $SEARCH"; |
1346 |
$wherecomp .= " OR glpi_dropdown_netpoint.name $SEARCH"; |
1347 |
$wherecomp .= " OR glpi_enterprises.name $SEARCH"; |
1348 |
$wherecomp .= " OR resptech.name $SEARCH"; |
1349 |
|
1350 |
$wherecomp .= ")"; |
1351 |
} |
1352 |
else {
|
1353 |
if(IsDevice($field)) { |
1354 |
$wherecomp = "(glpi_device_".$field." $SEARCH )"; |
1355 |
} |
1356 |
else {
|
1357 |
$wherecomp = "($field $SEARCH)"; |
1358 |
} |
1359 |
} |
1360 |
} |
1361 |
if (!$start) { |
1362 |
$start = 0; |
1363 |
} |
1364 |
$SELECT = "SELECT ".getCommonSelectForTrackingSearch(); |
1365 |
|
1366 |
|
1367 |
$FROM = " FROM glpi_tracking ".getCommonLeftJoinForTrackingSearch(); |
1368 |
|
1369 |
if ($search!=""&&strpos($tosearch,"followup")!==false) { |
1370 |
$FROM.= " LEFT JOIN glpi_followups ON ( glpi_followups.tracking = glpi_tracking.ID)"; |
1371 |
} |
1372 |
|
1373 |
|
1374 |
$where=" WHERE "; |
1375 |
|
1376 |
|
1377 |
switch ($status){ |
1378 |
case "new": $where.=" glpi_tracking.status = 'new'"; break; |
1379 |
case "notold": $where.=" (glpi_tracking.status = 'new' OR glpi_tracking.status = 'plan' OR glpi_tracking.status = 'assign' OR glpi_tracking.status = 'waiting')"; break; |
1380 |
case "old": $where.=" ( glpi_tracking.status = 'old_done' OR glpi_tracking.status = 'old_notdone')"; break; |
1381 |
case "process": $where.=" ( glpi_tracking.status = 'plan' OR glpi_tracking.status = 'assign' )"; break; |
1382 |
case "waiting": $where.=" ( glpi_tracking.status = 'waiting' )"; break; |
1383 |
case "old_done": $where.=" ( glpi_tracking.status = 'old_done' )"; break; |
1384 |
case "old_notdone": $where.=" ( glpi_tracking.status = 'old_notdone' )"; break; |
1385 |
case "assign": $where.=" ( glpi_tracking.status = 'assign' )"; break; |
1386 |
case "plan": $where.=" ( glpi_tracking.status = 'plan' )"; break; |
1387 |
default : $where.=" ( 1 )";;break; |
1388 |
} |
1389 |
|
1390 |
if ($category > 0){ |
1391 |
$where.=" AND ".getRealQueryForTreeItem("glpi_dropdown_tracking_category",$category,"glpi_tracking.category"); |
1392 |
} |
1393 |
|
1394 |
if (!empty($date1)&&$date1!="0000-00-00") $where.=" AND glpi_tracking.date >= '$date1'"; |
1395 |
if (!empty($date2)&&$date2!="0000-00-00") $where.=" AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
1396 |
if (!empty($enddate1)&&$enddate1!="0000-00-00") $where.=" AND glpi_tracking.closedate >= '$enddate1'"; |
1397 |
if (!empty($enddate2)&&$enddate2!="0000-00-00") $where.=" AND glpi_tracking.closedate <= adddate( '". $enddate2 ."' , INTERVAL 1 DAY ) "; |
1398 |
if (!empty($datemod1)&&$datemod1!="0000-00-00") $where.=" AND glpi_tracking.date_mod >= '$datemod1'"; |
1399 |
if (!empty($datemod2)&&$datemod2!="0000-00-00") $where.=" AND glpi_tracking.date_mod <= adddate( '". $datemod2 ."' , INTERVAL 1 DAY ) "; |
1400 |
|
1401 |
if ($recipient!=0) |
1402 |
$where.=" AND glpi_tracking.recipient='$recipient'"; |
1403 |
|
1404 |
|
1405 |
if ($type!=0) |
1406 |
$where.=" AND glpi_tracking.device_type='$type'"; |
1407 |
|
1408 |
if ($item!=0&&$type!=0) |
1409 |
$where.=" AND glpi_tracking.computer = '$item'"; |
1410 |
|
1411 |
$search_author=false; |
1412 |
if ($group>0) $where.=" AND glpi_tracking.FK_group = '$group'"; |
1413 |
else if ($group==-1&&$author!=0&&haveRight("show_group_ticket",1)){ |
1414 |
// Get Author group's
|
1415 |
if (count($_SESSION["glpigroups"])){ |
1416 |
$first=true; |
1417 |
$groups=""; |
1418 |
foreach ($_SESSION['glpigroups'] as $val){ |
1419 |
if (!$first) $groups.=","; |
1420 |
else $first=false; |
1421 |
$groups.="'".$val."'"; |
1422 |
} |
1423 |
$where.=" AND ( glpi_tracking.FK_group IN ($groups) "; |
1424 |
|
1425 |
if ($author!=0) { |
1426 |
$where.=" OR "; |
1427 |
$where.=" glpi_tracking.author = '$author'"; |
1428 |
$search_author=true; |
1429 |
} |
1430 |
|
1431 |
$where.=")"; |
1432 |
} |
1433 |
} |
1434 |
|
1435 |
|
1436 |
if ($author!=0&&!$search_author) { |
1437 |
$where.=" AND glpi_tracking.author = '$author' "; |
1438 |
} |
1439 |
|
1440 |
if (strcmp($assign,"mine")==0){ |
1441 |
// Case : central acces with show_assign_ticket but without show_all_ticket
|
1442 |
|
1443 |
$search_assign=" glpi_tracking.assign = '".$_SESSION["glpiID"]."' "; |
1444 |
if (count($_SESSION['glpigroups'])){ |
1445 |
if ($assign_group>0){ |
1446 |
$search_assign.= " OR glpi_tracking.assign_group = '$assign_group' "; |
1447 |
} else {
|
1448 |
$first=true; |
1449 |
$groups=""; |
1450 |
foreach ($_SESSION['glpigroups'] as $val){ |
1451 |
if (!$first) $groups.=","; |
1452 |
else $first=false; |
1453 |
$groups.="'".$val."'"; |
1454 |
} |
1455 |
$search_assign.= " OR glpi_tracking.assign_group IN ($groups) "; |
1456 |
} |
1457 |
} |
1458 |
|
1459 |
// Display mine but also the ones which i am the author
|
1460 |
$author_part=""; |
1461 |
if (!$search_author&&isset($_SESSION['glpiID'])){ |
1462 |
$author_part.=" OR glpi_tracking.author = '".$_SESSION['glpiID']."'"; |
1463 |
|
1464 |
// Get Author group's
|
1465 |
if (haveRight("show_group_ticket",1)&&count($_SESSION["glpigroups"])){ |
1466 |
$first=true; |
1467 |
$groups=""; |
1468 |
foreach ($_SESSION['glpigroups'] as $val){ |
1469 |
if (!$first) $groups.=","; |
1470 |
else $first=false; |
1471 |
$groups.="'".$val."'"; |
1472 |
} |
1473 |
$author_part.=" OR glpi_tracking.FK_group IN ($groups) "; |
1474 |
|
1475 |
} |
1476 |
} |
1477 |
|
1478 |
$where.=" AND ($search_assign $author_part ) "; |
1479 |
|
1480 |
|
1481 |
} else {
|
1482 |
if ($assign_ent!=0) $where.=" AND glpi_tracking.assign_ent = '$assign_ent'"; |
1483 |
if ($assign!=0) $where.=" AND glpi_tracking.assign = '$assign'"; |
1484 |
if ($assign_group!=0) $where.=" AND glpi_tracking.assign_group = '$assign_group'"; |
1485 |
} |
1486 |
|
1487 |
|
1488 |
|
1489 |
if ($request_type!=0) $where.=" AND glpi_tracking.request_type = '$request_type'"; |
1490 |
|
1491 |
if ($priority>0) $where.=" AND glpi_tracking.priority = '$priority'"; |
1492 |
if ($priority<0) $where.=" AND glpi_tracking.priority >= '".abs($priority)."'"; |
1493 |
|
1494 |
|
1495 |
if ($search!=""){ |
1496 |
$SEARCH2=makeTextSearch($search); |
1497 |
if ($tosearch=="ID"){ |
1498 |
$where.= " AND (glpi_tracking.ID = '".$search."')"; |
1499 |
} |
1500 |
$TMPWHERE=""; |
1501 |
$first=true; |
1502 |
if (strpos($tosearch,"followup")!== false){ |
1503 |
if ($first){ |
1504 |
$first=false; |
1505 |
} else {
|
1506 |
$TMPWHERE.= " OR "; |
1507 |
} |
1508 |
$TMPWHERE.= "glpi_followups.contents $SEARCH2 "; |
1509 |
} |
1510 |
if (strpos($tosearch,"name")!== false){ |
1511 |
if ($first){ |
1512 |
$first=false; |
1513 |
} else {
|
1514 |
$TMPWHERE.= " OR "; |
1515 |
} |
1516 |
$TMPWHERE.= "glpi_tracking.name $SEARCH2 "; |
1517 |
} |
1518 |
if (strpos($tosearch,"contents")!== false){ |
1519 |
if ($first){ |
1520 |
$first=false; |
1521 |
} else {
|
1522 |
$TMPWHERE.= " OR "; |
1523 |
} |
1524 |
$TMPWHERE.= "glpi_tracking.contents $SEARCH2 "; |
1525 |
} |
1526 |
|
1527 |
if (!empty($TMPWHERE)){ |
1528 |
$where.=" AND ($TMPWHERE) "; |
1529 |
} |
1530 |
} |
1531 |
|
1532 |
$where.=getEntitiesRestrictRequest(" AND","glpi_tracking"); |
1533 |
|
1534 |
if (!empty($wherecomp)){ |
1535 |
$where.=" AND glpi_tracking.device_type= '1'"; |
1536 |
$where.= " AND glpi_tracking.computer IN (SELECT comp.ID FROM glpi_computers as comp "; |
1537 |
$where.= " LEFT JOIN glpi_computer_device as gcdev ON (comp.ID = gcdev.FK_computers) "; |
1538 |
$where.= "LEFT JOIN glpi_device_moboard as moboard ON (moboard.ID = gcdev.FK_device AND gcdev.device_type = '".MOBOARD_DEVICE."') "; |
1539 |
$where.= "LEFT JOIN glpi_device_processor as processor ON (processor.ID = gcdev.FK_device AND gcdev.device_type = '".PROCESSOR_DEVICE."') "; |
1540 |
$where.= "LEFT JOIN glpi_device_gfxcard as gfxcard ON (gfxcard.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".GFX_DEVICE."') "; |
1541 |
$where.= "LEFT JOIN glpi_device_hdd as hdd ON (hdd.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".HDD_DEVICE."') "; |
1542 |
$where.= "LEFT JOIN glpi_device_iface as iface ON (iface.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".NETWORK_DEVICE."') "; |
1543 |
$where.= "LEFT JOIN glpi_device_ram as ram ON (ram.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".RAM_DEVICE."') "; |
1544 |
$where.= "LEFT JOIN glpi_device_sndcard as sndcard ON (sndcard.ID = gcdev.FK_DEVICE AND gcdev.device_type = '".SND_DEVICE."') "; |
1545 |
$where.= "LEFT JOIN glpi_networking_ports on (comp.ID = glpi_networking_ports.on_device AND glpi_networking_ports.device_type='1')"; |
1546 |
$where.= "LEFT JOIN glpi_dropdown_netpoint on (glpi_dropdown_netpoint.ID = glpi_networking_ports.netpoint)"; |
1547 |
$where.= "LEFT JOIN glpi_dropdown_os on (glpi_dropdown_os.ID = comp.os)"; |
1548 |
$where.= "LEFT JOIN glpi_dropdown_locations on (glpi_dropdown_locations.ID = comp.location)"; |
1549 |
$where.= "LEFT JOIN glpi_dropdown_model on (glpi_dropdown_model.ID = comp.model)"; |
1550 |
$where.= "LEFT JOIN glpi_type_computers on (glpi_type_computers.ID = comp.type)"; |
1551 |
$where.= " LEFT JOIN glpi_enterprises ON (glpi_enterprises.ID = comp.FK_glpi_enterprise ) "; |
1552 |
$where.= " LEFT JOIN glpi_users as resptech ON (resptech.ID = comp.tech_num ) "; |
1553 |
$where.=" WHERE $wherecomp) "; |
1554 |
} |
1555 |
|
1556 |
$sortitems = getTrackingSortOptions();
|
1557 |
if (!in_array($sort, $sortitems)) { |
1558 |
$sort="glpi_tracking.date_mod"; |
1559 |
} |
1560 |
if ($order!="ASC" && $order!="DESC") { |
1561 |
$order=getTrackingOrderPrefs($_SESSION["glpiID"]); |
1562 |
} |
1563 |
|
1564 |
$query=$SELECT.$FROM.$where." ORDER BY $sort $order"; |
1565 |
//echo $query;
|
1566 |
// Get it from database
|
1567 |
if ($result = $DB->query($query)) { |
1568 |
|
1569 |
$numrows=$DB->numrows($result); |
1570 |
|
1571 |
if ($start<$numrows) { |
1572 |
|
1573 |
// Set display type for export if define
|
1574 |
$output_type=HTML_OUTPUT; |
1575 |
if (isset($_GET["display_type"])) |
1576 |
$output_type=$_GET["display_type"]; |
1577 |
|
1578 |
|
1579 |
// Pager
|
1580 |
$parameters2="field=$field&contains=$contains&date1=$date1&date2=$date2&only_computers=$computers_search&tosearch=$tosearch&search=$search&assign=$assign&assign_ent=$assign_ent&assign_group=$assign_group&author=$author&group=$group&start=$start&status=$status&category=$category&priority=$priority&type=$type&showfollowups=$showfollowups&enddate1=$enddate1&enddate2=$enddate2&datemod1=$datemod1&datemod2=$datemod2&item=$item&request_type=$request_type"; |
1581 |
|
1582 |
// Specific case of showing tracking of an item
|
1583 |
if (isset($_GET["ID"])){ |
1584 |
$parameters2.="&ID=".$_GET["ID"]; |
1585 |
} |
1586 |
|
1587 |
$parameters=$parameters2."&sort=$sort&order=$order"; |
1588 |
if (ereg("user.form.php",$_SERVER['PHP_SELF'])) $parameters.="&ID=$author"; |
1589 |
// Manage helpdesk
|
1590 |
if (ereg("helpdesk.public.php",$target)) |
1591 |
$parameters.="&show=user"; |
1592 |
if ($output_type==HTML_OUTPUT){ |
1593 |
if (!ereg("helpdesk.public.php",$target)) |
1594 |
printPager($start,$numrows,$target,$parameters,TRACKING_TYPE); |
1595 |
else printPager($start,$numrows,$target,$parameters); |
1596 |
} |
1597 |
|
1598 |
$nbcols=9; |
1599 |
|
1600 |
// Form to delete old item
|
1601 |
if (($candelete||$canupdate)&&$output_type==HTML_OUTPUT){ |
1602 |
echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"".$CFG_GLPI["root_doc"]."/front/massiveaction.php\">"; |
1603 |
|
1604 |
} |
1605 |
|
1606 |
$i=$start; |
1607 |
if (isset($_GET['export_all'])){ |
1608 |
$i=0; |
1609 |
} |
1610 |
|
1611 |
if ($i>0){ |
1612 |
$DB->data_seek($result,$i); |
1613 |
} |
1614 |
|
1615 |
$end_display=$start+$_SESSION["glpilist_limit"]; |
1616 |
if (isset($_GET['export_all'])){ |
1617 |
$end_display=$numrows; |
1618 |
} |
1619 |
// Display List Header
|
1620 |
echo displaySearchHeader($output_type,$end_display-$start+1,$nbcols); |
1621 |
|
1622 |
commonTrackingListHeader($output_type,$target,$parameters2,$sort,$order); |
1623 |
|
1624 |
while ($i < $numrows && $i<$end_display&&$data=$DB->fetch_array($result)){ |
1625 |
// $ID = $DB->result($result, $i, "ID");
|
1626 |
showJobShort($data, $showfollowups,$output_type,$i-$start+1); |
1627 |
$i++;
|
1628 |
} |
1629 |
$title=""; |
1630 |
// Title for PDF export
|
1631 |
if ($output_type==PDF_OUTPUT_LANDSCAPE || $output_type==PDF_OUTPUT_PORTRAIT){ |
1632 |
$title.=$LANG["joblist"][0]." = "; |
1633 |
switch($status){ |
1634 |
case "new": $title.=$LANG["joblist"][9];break; |
1635 |
case "assign": $title.=$LANG["joblist"][18];break; |
1636 |
case "plan": $title.=$LANG["joblist"][19];break; |
1637 |
case "waiting": $title.=$LANG["joblist"][26];break; |
1638 |
case "old_done": $title.=$LANG["joblist"][10];break; |
1639 |
case "old_notdone": $title.=$LANG["joblist"][17];break; |
1640 |
case "notold": $title.=$LANG["joblist"][24];break; |
1641 |
case "process": $title.=$LANG["joblist"][21];break; |
1642 |
case "old": $title.=$LANG["joblist"][25];break; |
1643 |
case "all": $title.=$LANG["common"][66];break; |
1644 |
} |
1645 |
if ($author!=0) $title.=" - ".$LANG["job"][4]." = ".getUserName($author); |
1646 |
if ($group>0) $title.=" - ".$LANG["common"][35]." = ".getDropdownName("glpi_groups",$group); |
1647 |
if ($assign!=0||$assign_ent!=0||$assign_group!=0){ |
1648 |
$title.=" - ".$LANG["job"][5]." ="; |
1649 |
if ($assign!=0) $title.=" ".$LANG["job"][6]." = ".getUserName($assign); |
1650 |
if ($assign_group!=0) $title.=" ".$LANG["common"][35]." = ".getDropdownName("glpi_groups",$assign_group); |
1651 |
if ($assign_ent!=0) $title.=" ".$LANG["financial"][26]." = ".getDropdownName("glpi_enterprises",$assign_ent); |
1652 |
} |
1653 |
if ($request_type!=0) $title.=" - ".$LANG["job"][44]." = ".getRequestTypeName($request_type); |
1654 |
if ($category!=0) $title.=" - ".$LANG["common"][36]." = ".getDropdownName("glpi_dropdown_tracking_category",$category); |
1655 |
if ($priority!=0) $title.=" - ".$LANG["joblist"][2]." = ".getPriorityName($priority); |
1656 |
if ($type!=0&&$item!=0){ |
1657 |
$ci=new CommonItem(); |
1658 |
$ci->getFromDB($type,$item); |
1659 |
$title.=" - ".$LANG["common"][1]." = ".$ci->getType()." / ".$ci->getNameID(); |
1660 |
|
1661 |
} |
1662 |
} |
1663 |
// Display footer
|
1664 |
echo displaySearchFooter($output_type,$title); |
1665 |
|
1666 |
// Delete selected item
|
1667 |
if (($candelete||$canupdate)&&$output_type==HTML_OUTPUT){ |
1668 |
echo "<div>"; |
1669 |
echo "<table width='80%'>"; |
1670 |
echo "<tr><td><img src=\"".$CFG_GLPI["root_doc"]."/pics/arrow-left.png\" alt=''></td><td><a onclick= \"if ( markAllRows('massiveaction_form') ) return false;\" href='".$_SERVER['PHP_SELF']."?$parameters&select=all&start=$start'>".$LANG["buttons"][18]."</a></td>"; |
1671 |
|
1672 |
echo "<td>/</td><td ><a onclick=\"if ( unMarkAllRows('massiveaction_form') ) return false;\" href='".$_SERVER['PHP_SELF']."?$parameters&select=none&start=$start'>".$LANG["buttons"][19]."</a>"; |
1673 |
echo "</td><td class='left' width='80%'>"; |
1674 |
dropdownMassiveAction(TRACKING_TYPE);
|
1675 |
echo "</td></table></div>"; |
1676 |
// End form for delete item
|
1677 |
echo "</form>"; |
1678 |
} |
1679 |
|
1680 |
// Pager
|
1681 |
if ($output_type==HTML_OUTPUT){ // In case of HTML display |
1682 |
echo "<br>"; |
1683 |
printPager($start,$numrows,$target,$parameters); |
1684 |
} |
1685 |
|
1686 |
} else {
|
1687 |
echo "<div class='center'><strong>".$LANG["joblist"][8]."</strong></div>"; |
1688 |
|
1689 |
} |
1690 |
} |
1691 |
// Clean selection
|
1692 |
$_SESSION['glpimassiveactionselected']=array(); |
1693 |
} |
1694 |
|
1695 |
function showFollowupsShort($ID) { |
1696 |
// Print Followups for a job
|
1697 |
|
1698 |
global $DB,$CFG_GLPI, $LANG; |
1699 |
|
1700 |
$showprivate=haveRight("show_full_ticket","1"); |
1701 |
|
1702 |
$RESTRICT=""; |
1703 |
if (!$showprivate) $RESTRICT=" AND ( private='0' OR author ='".$_SESSION["glpiID"]."' ) "; |
1704 |
|
1705 |
|
1706 |
// Get Number of Followups
|
1707 |
|
1708 |
$query="SELECT * FROM glpi_followups WHERE tracking='$ID' $RESTRICT ORDER BY date DESC"; |
1709 |
$result=$DB->query($query); |
1710 |
|
1711 |
$out=""; |
1712 |
if ($DB->numrows($result)>0) { |
1713 |
$out.="<div class='center'><table class='tab_cadre' width='100%' cellpadding='2'>\n"; |
1714 |
$out.="<tr><th>".$LANG["common"][27]."</th><th>".$LANG["job"][4]."</th><th>".$LANG["joblist"][6]."</th></tr>\n"; |
1715 |
|
1716 |
while ($data=$DB->fetch_array($result)) { |
1717 |
|
1718 |
$out.="<tr class='tab_bg_3'>"; |
1719 |
$out.="<td class='center'>".convDateTime($data["date"])."</td>"; |
1720 |
$out.="<td class='center'>".getUserName($data["author"],1)."</td>"; |
1721 |
$out.="<td width='70%'><strong>".resume_text($data["contents"],$CFG_GLPI["cut"])."</strong></td>"; |
1722 |
$out.="</tr>"; |
1723 |
} |
1724 |
|
1725 |
$out.="</table></div>"; |
1726 |
|
1727 |
} |
1728 |
return $out; |
1729 |
} |
1730 |
|
1731 |
|
1732 |
|
1733 |
|
1734 |
function getAssignName($ID,$type,$link=0){ |
1735 |
global $CFG_GLPI; |
1736 |
|
1737 |
switch ($type){ |
1738 |
case USER_TYPE : |
1739 |
if ($ID==0) return "[Nobody]"; |
1740 |
return getUserName($ID,$link); |
1741 |
break;
|
1742 |
case ENTERPRISE_TYPE : |
1743 |
case GROUP_TYPE : |
1744 |
$ci=new CommonItem(); |
1745 |
if ($ci->getFromDB($type,$ID)){ |
1746 |
$before=""; |
1747 |
$after=""; |
1748 |
if ($link&&haveTypeRight($type,'r')){ |
1749 |
$ci->getLink(1); |
1750 |
} |
1751 |
return $ci->getNameID(); |
1752 |
} else return ""; |
1753 |
break;
|
1754 |
} |
1755 |
|
1756 |
} |
1757 |
|
1758 |
|
1759 |
|
1760 |
function showJobDetails ($target,$ID){ |
1761 |
global $DB,$CFG_GLPI,$LANG; |
1762 |
$job=new Job(); |
1763 |
|
1764 |
$canupdate=haveRight("update_ticket","1"); |
1765 |
$showuserlink=0; |
1766 |
if (haveRight('user','r')){ |
1767 |
$showuserlink=1; |
1768 |
} |
1769 |
if ($job->getFromDB($ID)&&haveAccessToEntity($job->fields["FK_entities"])) { |
1770 |
|
1771 |
if (!$job->canShowTicket()){ |
1772 |
return false; |
1773 |
} |
1774 |
|
1775 |
$canupdate_descr=$canupdate||($job->numberOfFollowups()==0&&$job->fields["author"]==$_SESSION["glpiID"]); |
1776 |
$item=new CommonItem(); |
1777 |
$item->getFromDB($job->fields["device_type"],$job->fields["computer"]); |
1778 |
|
1779 |
showTrackingOnglets($_SERVER['PHP_SELF']."?ID=".$ID); |
1780 |
|
1781 |
//echo "<div class='center'>";
|
1782 |
echo "<form method='post' name='form_ticket' action='$target' enctype=\"multipart/form-data\">\n"; |
1783 |
echo "<table class='tab_cadre_fixe' cellpadding='5'>"; |
1784 |
|
1785 |
// OPtional line
|
1786 |
if (isMultiEntitiesMode()){
|
1787 |
echo "<tr><th colspan='3'>"; |
1788 |
echo getDropdownName("glpi_entities",$job->fields["FK_entities"]); |
1789 |
echo "</th></tr>"; |
1790 |
} |
1791 |
|
1792 |
// First line
|
1793 |
echo "<tr><th colspan='2' style='text-align:left;'><span class='tracking_small'>"; |
1794 |
echo $LANG["joblist"][11].": "; |
1795 |
if ($canupdate){ |
1796 |
showCalendarForm("form_ticket","date",$job->fields["date"],true,true,false); |
1797 |
} else {
|
1798 |
echo $job->fields["date"]; |
1799 |
} |
1800 |
echo " ".$LANG["job"][2]." "; |
1801 |
if ($canupdate){ |
1802 |
dropdownAllUsers("recipient",$job->fields["recipient"],1,$job->fields["FK_entities"]); |
1803 |
} else {
|
1804 |
echo getUserName($job->fields["recipient"],$showuserlink); |
1805 |
} |
1806 |
|
1807 |
echo "</span>"; |
1808 |
|
1809 |
if (ereg("old_",$job->fields["status"])){ |
1810 |
echo "<br><span class='tracking_small'>".$LANG["joblist"][12].": "; |
1811 |
|
1812 |
if ($canupdate){ |
1813 |
showCalendarForm("form_ticket","closedate",$job->fields["closedate"],true,true,false); |
1814 |
} else {
|
1815 |
echo $job->fields["closedate"]; |
1816 |
} |
1817 |
echo "</span>\n"; |
1818 |
} |
1819 |
|
1820 |
echo "</th>"; |
1821 |
echo "<th><span class='tracking_small'>".$LANG["common"][26].":<br>"; |
1822 |
|
1823 |
echo convDateTime($job->fields["date_mod"])."\n"; |
1824 |
|
1825 |
echo "</span></th></tr>"; |
1826 |
echo "<tr class='tab_bg_2'>"; |
1827 |
// Premier Colonne
|
1828 |
echo "<td class='top' width='27%'>"; |
1829 |
echo "<table cellpadding='3'>"; |
1830 |
echo "<tr class='tab_bg_2'><td class='left'>"; |
1831 |
echo $LANG["joblist"][0].":</td><td>"; |
1832 |
if ($canupdate){ |
1833 |
dropdownStatus("status",$job->fields["status"]); |
1834 |
} else {
|
1835 |
echo getStatusName($job->fields["status"]); |
1836 |
} |
1837 |
echo "</td></tr>"; |
1838 |
|
1839 |
|
1840 |
echo "<tr><td class='left'>"; |
1841 |
echo $LANG["joblist"][2].":</td><td>"; |
1842 |
if ($canupdate) |
1843 |
dropdownPriority("priority",$job->fields["priority"]); |
1844 |
else echo getPriorityName($job->fields["priority"]); |
1845 |
echo "</td></tr>"; |
1846 |
|
1847 |
echo "<tr><td class='left'>"; |
1848 |
echo $LANG["common"][36].":</td><td >"; |
1849 |
if ($canupdate) |
1850 |
dropdownValue("glpi_dropdown_tracking_category","category",$job->fields["category"]); |
1851 |
else echo getDropdownName("glpi_dropdown_tracking_category",$job->fields["category"]); |
1852 |
echo "</td></tr>"; |
1853 |
|
1854 |
echo "<tr><td class='center' colspan='2'><strong>"; |
1855 |
echo $LANG["job"][4].":</strong></td></tr>"; |
1856 |
|
1857 |
echo "<tr><td class='left'>"; |
1858 |
echo $LANG["common"][34].":</td><td>"; |
1859 |
if ($canupdate){ |
1860 |
dropdownAllUsers("author",$job->fields["author"],1,$job->fields["FK_entities"]); |
1861 |
} else {
|
1862 |
echo getUserName($job->fields["author"],$showuserlink); |
1863 |
} |
1864 |
echo "</td></tr>"; |
1865 |
|
1866 |
echo "<tr><td class='left'>"; |
1867 |
echo $LANG["common"][35].":</td><td>"; |
1868 |
if ($canupdate){ |
1869 |
dropdownValue("glpi_groups","FK_group",$job->fields["FK_group"],1,$job->fields["FK_entities"]); |
1870 |
} else {
|
1871 |
echo getDropdownName("glpi_groups",$job->fields["FK_group"]); |
1872 |
} |
1873 |
echo "</td></tr>"; |
1874 |
|
1875 |
|
1876 |
echo "</table></td>"; |
1877 |
|
1878 |
// Deuxieme colonne
|
1879 |
echo "<td class='top' width='33%'>"; |
1880 |
|
1881 |
echo "<table>"; |
1882 |
|
1883 |
echo "<tr><td class='left'>"; |
1884 |
echo $LANG["job"][44].":</td><td>"; |
1885 |
if ($canupdate) |
1886 |
dropdownRequestType("request_type",$job->fields["request_type"]); |
1887 |
else echo getRequestTypeName($job->fields["request_type"]); |
1888 |
echo "</td></tr>"; |
1889 |
|
1890 |
echo "<tr><td class='left'>"; |
1891 |
echo $LANG["common"][1].":</td><td>"; |
1892 |
if ($canupdate){ |
1893 |
if (haveTypeRight($job->fields["device_type"],'r')){ |
1894 |
echo $item->getType()." - ".$item->getLink(1); |
1895 |
} else {
|
1896 |
echo $item->getType()." ".$item->getNameID(); |
1897 |
} |
1898 |
dropdownTrackingAllDevices("device_type",$job->fields["device_type"],1,$job->fields["FK_entities"]); |
1899 |
} |
1900 |
else {
|
1901 |
echo $item->getType()." ".$item->getNameID(); |
1902 |
} |
1903 |
|
1904 |
echo "</td></tr>"; |
1905 |
|
1906 |
|
1907 |
echo "<tr><td class='center' colspan='2'><strong>"; |
1908 |
echo $LANG["job"][5].":</strong></td></tr>"; |
1909 |
|
1910 |
if (haveRight("assign_ticket","1")){ |
1911 |
echo "<tr><td class='left'>"; |
1912 |
echo $LANG["job"][6].":</td><td>"; |
1913 |
dropdownUsers("assign",$job->fields["assign"],"own_ticket",0,1,$job->fields["FK_entities"]); |
1914 |
echo "</td></tr>"; |
1915 |
} else if (haveRight("steal_ticket","1")) { |
1916 |
echo "<tr><td class='right'>"; |
1917 |
echo $LANG["job"][6].":</td><td>"; |
1918 |
dropdownUsers("assign",$job->fields["assign"],"ID",0,1,$job->fields["FK_entities"]); |
1919 |
echo "</td></tr>"; |
1920 |
}else {
|
1921 |
echo "<tr><td class='left'>"; |
1922 |
echo $LANG["job"][6].":</td><td>"; |
1923 |
echo getUserName($job->fields["assign"],$showuserlink); |
1924 |
echo "</td></tr>"; |
1925 |
} |
1926 |
|
1927 |
if (haveRight("assign_ticket","1")){ |
1928 |
echo "<tr><td class='left'>"; |
1929 |
echo $LANG["common"][35].":</td><td>"; |
1930 |
dropdownValue("glpi_groups","assign_group",$job->fields["assign_group"],1,$job->fields["FK_entities"]); |
1931 |
echo "</td></tr>"; |
1932 |
echo "<tr><td class='left'>"; |
1933 |
echo $LANG["financial"][26].":</td><td>"; |
1934 |
dropdownValue("glpi_enterprises","assign_ent",$job->fields["assign_ent"],1,$job->fields["FK_entities"]); |
1935 |
echo "</td></tr>"; |
1936 |
} else {
|
1937 |
echo "<tr><td class='left'>"; |
1938 |
echo $LANG["common"][35].":</td><td>"; |
1939 |
echo getDropdownName("glpi_groups",$job->fields["assign_group"]); |
1940 |
echo "</td></tr>"; |
1941 |
echo "<tr><td class='left'>"; |
1942 |
echo $LANG["financial"][26].":</td><td>"; |
1943 |
echo getDropdownName("glpi_enterprises",$job->fields["assign_ent"]); |
1944 |
echo "</td></tr>"; |
1945 |
} |
1946 |
echo "</table>"; |
1947 |
|
1948 |
|
1949 |
echo "</td>"; |
1950 |
|
1951 |
// Troisieme Colonne
|
1952 |
echo "<td class='top' width='20%'>"; |
1953 |
echo "<table border='0'>"; |
1954 |
|
1955 |
echo "<tr><td class='left'>"; |
1956 |
echo $LANG["job"][20].":</td><td>"; |
1957 |
echo "<strong>".getRealtime($job->fields["realtime"])."</strong>"; |
1958 |
echo "</td></tr>"; |
1959 |
|
1960 |
if(haveRight("contract_infocom","r")){ // admin = oui on affiche les couts liés à l'interventions |
1961 |
|
1962 |
echo "<tr><td class='left'>"; |
1963 |
// cout
|
1964 |
echo $LANG["job"][40].": "; |
1965 |
echo "</td><td><input type='text' maxlength='100' size='15' name='cost_time' value=\"".formatNumber($job->fields["cost_time"],true)."\"></td></tr>"; |
1966 |
|
1967 |
echo "<tr><td class='left'>"; |
1968 |
|
1969 |
echo $LANG["job"][41].": "; |
1970 |
echo "</td><td><input type='text' maxlength='100' size='15' name='cost_fixed' value=\"".formatNumber($job->fields["cost_fixed"],true)."\">"; |
1971 |
|
1972 |
echo "</td></tr>\n"; |
1973 |
|
1974 |
echo "<tr><td class='left'>"; |
1975 |
|
1976 |
echo $LANG["job"][42].": "; |
1977 |
echo "</td><td><input type='text' maxlength='100' size='15' name='cost_material' value=\"".formatNumber($job->fields["cost_material"],true)."\">"; |
1978 |
|
1979 |
echo "</td></tr>\n"; |
1980 |
|
1981 |
echo "<tr><td class='left'>"; |
1982 |
|
1983 |
echo $LANG["job"][43].": "; |
1984 |
echo "</td><td><strong>"; |
1985 |
echo trackingTotalCost($job->fields["realtime"],$job->fields["cost_time"],$job->fields["cost_fixed"],$job->fields["cost_material"]); |
1986 |
echo "</strong></td></tr>\n"; |
1987 |
} |
1988 |
echo '</table>'; |
1989 |
echo "</td></tr>"; |
1990 |
|
1991 |
|
1992 |
// Deuxieme Ligne
|
1993 |
// Colonnes 1 et 2
|
1994 |
echo "<tr class='tab_bg_1'><td colspan='2'>"; |
1995 |
echo "<table width='99%' >"; |
1996 |
echo "<tr class='tab_bg_2'><th colspan='2'>"; |
1997 |
if ($canupdate_descr){ |
1998 |
$rand=mt_rand();
|
1999 |
echo "<script type='text/javascript' >\n"; |
2000 |
echo "function showName$rand(){\n"; |
2001 |
echo "window.document.getElementById('name$rand').style.display='none';"; |
2002 |
$params=array('maxlength'=>250, |
2003 |
'size'=>80, |
2004 |
'name'=>'name', |
2005 |
'data'=>rawurlencode($job->fields["name"]), |
2006 |
); |
2007 |
ajaxUpdateItemJsCode("viewname$rand",$CFG_GLPI["root_doc"]."/ajax/inputtext.php",$params,false); |
2008 |
echo "}"; |
2009 |
echo "</script>\n"; |
2010 |
echo "<div id='name$rand' class='tracking' onClick='showName$rand()'>\n"; |
2011 |
if (empty($job->fields["name"])){ |
2012 |
echo $LANG["reminder"][15]; |
2013 |
} else {
|
2014 |
echo $job->fields["name"]; |
2015 |
} |
2016 |
echo "</div>\n"; |
2017 |
|
2018 |
echo "<div id='viewname$rand'>\n"; |
2019 |
echo "</div>\n"; |
2020 |
//echo "<input type='text' maxlength='250' size='80' name='name' value=\"".$job->fields["name"]."\">";
|
2021 |
} else {
|
2022 |
if (empty($job->fields["name"])){ |
2023 |
echo $LANG["reminder"][15]; |
2024 |
} else {
|
2025 |
echo $job->fields["name"]; |
2026 |
} |
2027 |
} |
2028 |
echo "</th></tr>"; |
2029 |
echo "<tr class='tab_bg_2'><td width='15%'>".$LANG["joblist"][6]."</td>"; |
2030 |
echo "<td width='85%' class='left'>"; |
2031 |
|
2032 |
if ($canupdate_descr){ // Admin =oui on autorise la modification de la description |
2033 |
$rand=mt_rand();
|
2034 |
echo "<script type='text/javascript' >\n"; |
2035 |
echo "function showDesc$rand(){\n"; |
2036 |
|
2037 |
echo "window.document.getElementById('desc$rand').style.display='none';"; |
2038 |
$params=array('rows'=>6, |
2039 |
'cols'=>60, |
2040 |
'name'=>'contents', |
2041 |
'data'=>rawurlencode($job->fields["contents"]), |
2042 |
); |
2043 |
ajaxUpdateItemJsCode("viewdesc$rand",$CFG_GLPI["root_doc"]."/ajax/textarea.php",$params,false); |
2044 |
|
2045 |
echo "}"; |
2046 |
echo "</script>\n"; |
2047 |
echo "<div id='desc$rand' class='tracking' onClick='showDesc$rand()'>\n"; |
2048 |
if (!empty($job->fields["contents"])) |
2049 |
echo nl2br($job->fields["contents"]); |
2050 |
else echo $LANG["job"][33]; |
2051 |
|
2052 |
echo "</div>\n"; |
2053 |
|
2054 |
echo "<div id='viewdesc$rand'>\n"; |
2055 |
echo "</div>\n"; |
2056 |
} else echo nl2br($job->fields["contents"]); |
2057 |
|
2058 |
echo "</td>"; |
2059 |
echo "</tr>"; |
2060 |
echo "</table>"; |
2061 |
echo "</td>"; |
2062 |
// Colonne 3
|
2063 |
|
2064 |
echo "<td class='top'>"; |
2065 |
|
2066 |
// Mailing ? Y or no ?
|
2067 |
|
2068 |
if ($CFG_GLPI["mailing"]==1){ |
2069 |
echo "<table><tr><td class='right'>"; |
2070 |
echo $LANG["job"][19].":</td><td>"; |
2071 |
if ($canupdate){ |
2072 |
dropdownYesNo('emailupdates',$job->fields["emailupdates"]); |
2073 |
} else {
|
2074 |
if ($job->fields["emailupdates"]) echo $LANG["choice"][1]; |
2075 |
else $LANG["choice"][0]; |
2076 |
} |
2077 |
echo "</td></tr>"; |
2078 |
|
2079 |
echo "<tr><td class='right'>"; |
2080 |
echo $LANG["joblist"][27].":"; |
2081 |
echo "</td><td>"; |
2082 |
if ($canupdate){ |
2083 |
autocompletionTextField("uemail","glpi_tracking","uemail",$job->fields["uemail"],15,$job->fields["FK_entities"]); |
2084 |
|
2085 |
if (!empty($job->fields["uemail"])) |
2086 |
echo "<a href='mailto:".$job->fields["uemail"]."'><img src='".$CFG_GLPI["root_doc"]."/pics/edit.png' alt='Mail'></a>"; |
2087 |
} else if (!empty($job->fields["uemail"])) |
2088 |
echo "<a href='mailto:".$job->fields["uemail"]."'>".$job->fields["uemail"]."</a>"; |
2089 |
else echo " "; |
2090 |
echo "</td></tr></table>"; |
2091 |
|
2092 |
|
2093 |
} |
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 |
// File associated ?
|
2099 |
$query2 = "SELECT * FROM glpi_doc_device WHERE glpi_doc_device.FK_device = '".$job->fields["ID"]."' AND glpi_doc_device.device_type = '".TRACKING_TYPE."' "; |
2100 |
$result2 = $DB->query($query2); |
2101 |
$numfiles=$DB->numrows($result2); |
2102 |
echo "<table width='100%'><tr><th colspan='2'>".$LANG["document"][21]."</th></tr>"; |
2103 |
|
2104 |
if ($numfiles>0){ |
2105 |
$doc=new Document; |
2106 |
while ($data=$DB->fetch_array($result2)){ |
2107 |
$doc->getFromDB($data["FK_doc"]); |
2108 |
|
2109 |
echo "<tr><td>"; |
2110 |
|
2111 |
if (empty($doc->fields["filename"])){ |
2112 |
if (haveRight("document","r")){ |
2113 |
echo "<a href='".$CFG_GLPI["root_doc"]."/front/document.form.php?ID=".$data["FK_doc"]."'>".$doc->fields["name"]."</a>"; |
2114 |
} else {
|
2115 |
echo $LANG["document"][37]; |
2116 |
} |
2117 |
} else {
|
2118 |
echo getDocumentLink($doc->fields["filename"],"&tracking=$ID"); |
2119 |
} |
2120 |
if (haveRight("document","w")) |
2121 |
echo "<a href='".$CFG_GLPI["root_doc"]."/front/document.form.php?deleteitem=delete&ID=".$data["ID"]."&devtype=".TRACKING_TYPE."&devid=".$ID."&docid=".$data["FK_doc"]."'><img src='".$CFG_GLPI["root_doc"]."/pics/delete.png' alt='".$LANG["buttons"][6]."'></a>"; |
2122 |
echo "</td></tr>"; |
2123 |
} |
2124 |
} |
2125 |
if ($canupdate||haveRight("comment_all_ticket","1") |
2126 |
||(haveRight("comment_ticket","1")&&!ereg('old_',$job->fields["status"])) |
2127 |
){ |
2128 |
echo "<tr><td colspan='2'>"; |
2129 |
echo "<input type='file' name='filename' size='20'>"; |
2130 |
if ($canupdate&&haveRight("document","r")){ |
2131 |
echo "<br>"; |
2132 |
dropdownDocument("document",$job->fields["FK_entities"]); |
2133 |
} |
2134 |
echo "</td></tr>"; |
2135 |
} |
2136 |
echo "</table>"; |
2137 |
|
2138 |
echo "</td></tr>"; |
2139 |
// Troisi�e Ligne
|
2140 |
if ($canupdate||$canupdate_descr||haveRight("comment_all_ticket","1") |
2141 |
||(haveRight("comment_ticket","1")&&!ereg('old_',$job->fields["status"])) |
2142 |
||haveRight("assign_ticket","1")||haveRight("steal_ticket","1") |
2143 |
|
2144 |
){ |
2145 |
echo "<tr class='tab_bg_1'><td colspan='3' class='center'>"; |
2146 |
echo "<input type='submit' class='submit' name='update' value='".$LANG["buttons"][14]."'></td></tr>"; |
2147 |
} |
2148 |
|
2149 |
echo "</table>"; |
2150 |
echo "<input type='hidden' name='ID' value='$ID'>"; |
2151 |
echo "</form>"; |
2152 |
// echo "</div>";
|
2153 |
|
2154 |
echo "<script type='text/javascript' >\n"; |
2155 |
echo "function showPlan(){\n"; |
2156 |
|
2157 |
echo "window.document.getElementById('plan').style.display='none';"; |
2158 |
$params=array('form'=>'followups', |
2159 |
'state'=>1, |
2160 |
'author'=>$job->fields["assign"], |
2161 |
'entity'=>$job->fields["FK_entities"], |
2162 |
); |
2163 |
ajaxUpdateItemJsCode('viewplan',$CFG_GLPI["root_doc"]."/ajax/planning.php",$params,false); |
2164 |
|
2165 |
echo "};"; |
2166 |
echo "function showAddFollowup(){\n"; |
2167 |
echo "$('viewfollowup').scrollTo();"; |
2168 |
echo "window.document.getElementById('viewfollowup').style.display='none';"; |
2169 |
$params=array('tID'=>$ID, |
2170 |
); |
2171 |
ajaxUpdateItemJsCode('viewfollowup',$CFG_GLPI["root_doc"]."/ajax/addfollowup.php",$params,false); |
2172 |
|
2173 |
echo "};"; |
2174 |
|
2175 |
echo "</script>"; |
2176 |
|
2177 |
echo "<div id='viewfollowup'>\n"; |
2178 |
echo "</div>\n"; |
2179 |
|
2180 |
|
2181 |
return true; |
2182 |
} else {
|
2183 |
echo "<div class='center'><strong>".$LANG["common"][54]."</strong></div>"; |
2184 |
return false; |
2185 |
} |
2186 |
} |
2187 |
|
2188 |
function showFollowupsSummary($tID){ |
2189 |
global $DB,$LANG,$CFG_GLPI; |
2190 |
|
2191 |
|
2192 |
if (!haveRight("observe_ticket","1")&&!haveRight("show_full_ticket","1")) return false; |
2193 |
|
2194 |
$job=new Job; |
2195 |
$job->getFromDB($tID); |
2196 |
// Display existing Followups
|
2197 |
$showprivate=haveRight("show_full_ticket","1"); |
2198 |
$caneditall=haveRight("update_followups","1"); |
2199 |
|
2200 |
$RESTRICT=""; |
2201 |
if (!$showprivate) $RESTRICT=" AND ( private='0' OR author ='".$_SESSION["glpiID"]."' ) "; |
2202 |
|
2203 |
$query = "SELECT * FROM glpi_followups WHERE (tracking = '$tID') $RESTRICT ORDER BY date DESC"; |
2204 |
$result=$DB->query($query); |
2205 |
|
2206 |
|
2207 |
|
2208 |
$rand=mt_rand();
|
2209 |
|
2210 |
|
2211 |
echo "<div class='center'>"; |
2212 |
echo "<h3>".$LANG["job"][37]."</h3>"; |
2213 |
|
2214 |
if ($DB->numrows($result)==0){ |
2215 |
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'><th>"; |
2216 |
echo "<strong>".$LANG["job"][12]."</strong>"; |
2217 |
echo "</th></tr></table>"; |
2218 |
} |
2219 |
else {
|
2220 |
echo "<table class='tab_cadrehov'>"; |
2221 |
echo "<tr><th> </th><th>".$LANG["common"][27]."</th><th>".$LANG["joblist"][6]."</th><th>".$LANG["job"][31]."</th><th>".$LANG["job"][35]."</th><th>".$LANG["common"][37]."</th>"; |
2222 |
if ($showprivate) |
2223 |
echo "<th>".$LANG["common"][77]."</th>"; |
2224 |
echo "</tr>"; |
2225 |
while ($data=$DB->fetch_array($result)){ |
2226 |
$canedit=($caneditall||$data['author']==$_SESSION['glpiID']); |
2227 |
|
2228 |
echo "<tr class='tab_bg_2' ".($canedit?"style='cursor:pointer' onClick=\"viewEditFollowup".$data["ID"]."$rand();\"":"style='cursor:none'") |
2229 |
." id='viewfollowup".$data["ID"]."$rand'>"; |
2230 |
echo "<td>".$data["ID"]."</td>"; |
2231 |
|
2232 |
echo "<td>"; |
2233 |
if ($canedit){ |
2234 |
echo "<script type='text/javascript' >\n"; |
2235 |
echo "function viewEditFollowup".$data["ID"]."$rand(){\n"; |
2236 |
|
2237 |
//echo "window.document.getElementById('viewfollowup').style.display='none';";
|
2238 |
$params=array('ID'=>$data["ID"], |
2239 |
); |
2240 |
ajaxUpdateItemJsCode("viewfollowup",$CFG_GLPI["root_doc"]."/ajax/viewfollowup.php",$params,false); |
2241 |
echo "};"; |
2242 |
|
2243 |
echo "</script>\n"; |
2244 |
} |
2245 |
|
2246 |
|
2247 |
echo convDateTime($data["date"])."</td>"; |
2248 |
echo "<td class='left'>".nl2br($data["contents"])."</td>"; |
2249 |
|
2250 |
$hour=floor($data["realtime"]); |
2251 |
$minute=round(($data["realtime"]-$hour)*60,0); |
2252 |
echo "<td>"; |
2253 |
if ($hour) echo "$hour ".$LANG["job"][21]."<br>"; |
2254 |
if ($minute||!$hour) |
2255 |
echo "$minute ".$LANG["job"][22]."</td>"; |
2256 |
|
2257 |
echo "<td>"; |
2258 |
$query2="SELECT * from glpi_tracking_planning WHERE id_followup='".$data['ID']."'"; |
2259 |
$result2=$DB->query($query2); |
2260 |
if ($DB->numrows($result2)==0){ |
2261 |
echo $LANG["job"][32]; |
2262 |
} else {
|
2263 |
$data2=$DB->fetch_array($result2); |
2264 |
echo "<script type='text/javascript' >\n"; |
2265 |
echo "function showPlan".$data['ID']."(){\n"; |
2266 |
|
2267 |
echo "window.document.getElementById('plan').style.display='none';"; |
2268 |
$params=array('form'=>'followups', |
2269 |
'author'=>$data2["id_assign"], |
2270 |
'ID'=>$data2["ID"], |
2271 |
'state'=>$data2["state"], |
2272 |
'begin_date'=>$data2["begin"], |
2273 |
'end_date'=>$data2["end"], |
2274 |
'entity'=>$job->fields["FK_entities"], |
2275 |
); |
2276 |
ajaxUpdateItemJsCode('viewplan',$CFG_GLPI["root_doc"]."/ajax/planning.php",$params,false); |
2277 |
echo "}"; |
2278 |
echo "</script>\n"; |
2279 |
|
2280 |
echo getPlanningState($data2["state"])."<br>".convDateTime($data2["begin"])."<br>->".convDateTime($data2["end"])."<br>".getUserName($data2["id_assign"]); |
2281 |
} |
2282 |
echo "</td>"; |
2283 |
|
2284 |
echo "<td>".getUserName($data["author"])."</td>"; |
2285 |
if ($showprivate){ |
2286 |
echo "<td>"; |
2287 |
if ($data["private"]) |
2288 |
echo $LANG["choice"][1]; |
2289 |
else echo $LANG["choice"][0]; |
2290 |
echo "</td>"; |
2291 |
} |
2292 |
|
2293 |
echo "</tr>"; |
2294 |
} |
2295 |
echo "</table>"; |
2296 |
} |
2297 |
echo "</div>"; |
2298 |
} |
2299 |
|
2300 |
/** Form to add a followup to a ticket
|
2301 |
* @param $tID integer : ticket ID
|
2302 |
* @param $massiveaction boolean : add followup using massive action
|
2303 |
*/
|
2304 |
function showAddFollowupForm($tID,$massiveaction=false){ |
2305 |
global $DB,$LANG,$CFG_GLPI; |
2306 |
|
2307 |
$job=new Job; |
2308 |
|
2309 |
if ($tID>0){ |
2310 |
$job->getFromDB($tID); |
2311 |
} else {
|
2312 |
$job->getEmpty();
|
2313 |
} |
2314 |
$prefix=""; |
2315 |
$postfix=""; |
2316 |
// Add followup at creating ticket : prefix values
|
2317 |
if ($tID<0&&!$massiveaction){ |
2318 |
$prefix="_followup["; |
2319 |
$postfix="]"; |
2320 |
} |
2321 |
if (!haveRight("comment_ticket","1")&&!haveRight("comment_all_ticket","1")&&$job->fields["assign"]!=$_SESSION["glpiID"]&&!in_array($job->fields["assign_group"],$_SESSION["glpigroups"])) return false; |
2322 |
|
2323 |
|
2324 |
$commentall=(haveRight("comment_all_ticket","1")||$job->fields["assign"]==$_SESSION["glpiID"]||in_array($job->fields["assign_group"],$_SESSION["glpigroups"])); |
2325 |
|
2326 |
if ($_SESSION["glpiactiveprofile"]["interface"]=="central"){ |
2327 |
$target=$CFG_GLPI["root_doc"]."/front/tracking.form.php"; |
2328 |
} else {
|
2329 |
$target=$CFG_GLPI["root_doc"]."/front/helpdesk.public.php?show=user"; |
2330 |
} |
2331 |
// Display Add Table
|
2332 |
echo "<div class='center'>"; |
2333 |
if ($tID>0){ |
2334 |
echo "<form name='followups' method='post' action=\"$target\">\n"; |
2335 |
} |
2336 |
echo "<table class='tab_cadre_fixe'>"; |
2337 |
echo "<tr><th colspan='2'>"; |
2338 |
echo $LANG["job"][29]; |
2339 |
echo "</th></tr>"; |
2340 |
|
2341 |
if ($commentall){ |
2342 |
$width_left=$width_right="50%"; |
2343 |
$cols=50; |
2344 |
} else {
|
2345 |
$width_left="80%"; |
2346 |
$width_right="20%"; |
2347 |
$cols=80; |
2348 |
} |
2349 |
|
2350 |
echo "<tr class='tab_bg_2'><td width='$width_left'>"; |
2351 |
echo "<table width='100%'>"; |
2352 |
echo "<tr><td>".$LANG["joblist"][6]."</td>"; |
2353 |
echo "<td><textarea name='".$prefix."contents".$postfix."' rows='8' cols='$cols'></textarea>"; |
2354 |
echo "</td></tr>"; |
2355 |
echo "</table>"; |
2356 |
echo "</td>"; |
2357 |
|
2358 |
echo "<td width='$width_right' valign='top'>"; |
2359 |
echo "<table width='100%'>"; |
2360 |
|
2361 |
if ($commentall){ |
2362 |
echo "<tr>"; |
2363 |
echo "<td>".$LANG["common"][77].":</td>"; |
2364 |
echo "<td>"; |
2365 |
echo "<select name='".$prefix."private".$postfix."'>"; |
2366 |
echo "<option value='0'>".$LANG["choice"][0]."</option>"; |
2367 |
echo "<option value='1'>".$LANG["choice"][1]."</option>"; |
2368 |
echo "</select>"; |
2369 |
echo "</td>"; |
2370 |
echo "</tr>"; |
2371 |
|
2372 |
if ($tID>0){ |
2373 |
echo "<tr><td>".$LANG["job"][31].":</td><td>"; |
2374 |
dropdownInteger('hour',0,0,100); |
2375 |
echo $LANG["job"][21]." "; |
2376 |
dropdownInteger('minute',0,0,59); |
2377 |
echo $LANG["job"][22]; |
2378 |
echo "</tr>"; |
2379 |
} |
2380 |
|
2381 |
if (haveRight("show_planning","1")&&!$massiveaction){ |
2382 |
echo "<tr>"; |
2383 |
echo "<td>".$LANG["job"][35]."</td>"; |
2384 |
|
2385 |
echo "<td>"; |
2386 |
|
2387 |
|
2388 |
echo "<div id='plan' onClick='showPlan()'>\n"; |
2389 |
echo "<span class='showplan'>".$LANG["job"][34]."</span>"; |
2390 |
echo "</div>\n"; |
2391 |
|
2392 |
echo "<div id='viewplan'>\n"; |
2393 |
echo "</div>\n"; |
2394 |
|
2395 |
|
2396 |
echo "</td>"; |
2397 |
|
2398 |
echo "</tr>"; |
2399 |
} |
2400 |
} |
2401 |
if ($tID>0||$massiveaction){ |
2402 |
echo "<tr class='tab_bg_2'>"; |
2403 |
echo "<td class='center'>"; |
2404 |
echo "<input type='submit' name='add' value='".$LANG["buttons"][8]."' class='submit'>"; |
2405 |
echo "</td>"; |
2406 |
if ($commentall&&$tID>0){ |
2407 |
echo "<td class='center'>"; |
2408 |
echo "<input type='submit' name='add_close' value='".$LANG["buttons"][26]."' class='submit'>"; |
2409 |
echo "</td>"; |
2410 |
} |
2411 |
echo "</tr>"; |
2412 |
} else {
|
2413 |
|
2414 |
} |
2415 |
|
2416 |
|
2417 |
echo "</table>"; |
2418 |
echo "</td></tr>"; |
2419 |
echo "</table>"; |
2420 |
if ($tID>0){ |
2421 |
echo "<input type='hidden' name='tracking' value='$tID'>"; |
2422 |
echo "</form>"; |
2423 |
} |
2424 |
echo "</div>"; |
2425 |
|
2426 |
} |
2427 |
|
2428 |
|
2429 |
/** Form to update a followup to a ticket
|
2430 |
* @param $ID integer : followup ID
|
2431 |
*/
|
2432 |
function showUpdateFollowupForm($ID){ |
2433 |
global $DB,$LANG,$CFG_GLPI; |
2434 |
|
2435 |
$fup=new Followup(); |
2436 |
|
2437 |
if ($fup->getFromDB($ID)){ |
2438 |
if ($fup->fields["author"]!=$_SESSION['glpiID']&&!haveRight("update_followups","1")) { |
2439 |
return false; |
2440 |
} |
2441 |
|
2442 |
$commentall=haveRight("update_followups","1"); |
2443 |
|
2444 |
$job=new Job(); |
2445 |
$job->getFromDB($fup->fields["tracking"]); |
2446 |
|
2447 |
echo "<div class='center'>"; |
2448 |
echo "<table class='tab_cadre_fixe'>"; |
2449 |
echo "<tr><th>"; |
2450 |
echo $LANG["job"][39]; |
2451 |
echo "</th></tr>"; |
2452 |
echo "<tr class='tab_bg_2'><td>"; |
2453 |
echo "<form method='post' action=\"".$CFG_GLPI["root_doc"]."/front/tracking.form.php\">\n"; |
2454 |
|
2455 |
echo "<table width='100%'>"; |
2456 |
echo "<tr class='tab_bg_2'><td width='50%'>"; |
2457 |
echo "<table width='100%' bgcolor='#FFFFFF'>"; |
2458 |
echo "<tr class='tab_bg_1'><td align='center' width='10%'>".$LANG["joblist"][6]."<br><br>".$LANG["common"][27].":<br>".convDateTime($fup->fields["date"])."</td>"; |
2459 |
echo "<td width='90%'>"; |
2460 |
|
2461 |
if ($commentall){ |
2462 |
echo "<textarea name='contents' cols='50' rows='6'>".$fup->fields["contents"]."</textarea>"; |
2463 |
} else echo nl2br($fup->fields["contents"]); |
2464 |
|
2465 |
|
2466 |
echo "</td></tr>"; |
2467 |
echo "</table>"; |
2468 |
echo "</td>"; |
2469 |
|
2470 |
echo "<td width='50%' valign='top'>"; |
2471 |
echo "<table width='100%'>"; |
2472 |
|
2473 |
|
2474 |
if ($commentall){ |
2475 |
echo "<tr>"; |
2476 |
echo "<td>".$LANG["common"][77].":</td>"; |
2477 |
echo "<td>"; |
2478 |
echo "<select name='private'>"; |
2479 |
echo "<option value='0' ".(!$fup->fields["private"]?" selected":"").">".$LANG["choice"][0]."</option>"; |
2480 |
echo "<option value='1' ".($fup->fields["private"]?" selected":"").">".$LANG["choice"][1]."</option>"; |
2481 |
echo "</select>"; |
2482 |
echo "</td>"; |
2483 |
echo "</tr>"; |
2484 |
} |
2485 |
|
2486 |
|
2487 |
|
2488 |
echo "<tr><td>".$LANG["job"][31].":</td><td>"; |
2489 |
$hour=floor($fup->fields["realtime"]); |
2490 |
$minute=round(($fup->fields["realtime"]-$hour)*60,0); |
2491 |
|
2492 |
if ($commentall){ |
2493 |
|
2494 |
dropdownInteger('hour',$hour,0,100); |
2495 |
echo $LANG["job"][21]." "; |
2496 |
dropdownInteger('minute',$minute,0,59); |
2497 |
echo $LANG["job"][22]; |
2498 |
} else {
|
2499 |
echo $hour." ".$LANG["job"][21]." ".$minute." ".$LANG["job"][22]; |
2500 |
|
2501 |
} |
2502 |
|
2503 |
echo "</tr>"; |
2504 |
|
2505 |
echo "<tr>"; |
2506 |
echo "<td>".$LANG["job"][35]."</td>"; |
2507 |
echo "<td>"; |
2508 |
|
2509 |
$query2="SELECT * from glpi_tracking_planning WHERE id_followup='".$fup->fields['ID']."'"; |
2510 |
$result2=$DB->query($query2); |
2511 |
if ($DB->numrows($result2)==0){ |
2512 |
if ($commentall){ |
2513 |
|
2514 |
echo "<div id='plan' onClick='showPlan()'>\n"; |
2515 |
echo "<span class='showplan'>".$LANG["job"][34]."</span>"; |
2516 |
echo "</div>\n"; |
2517 |
echo "<div id='viewplan'></div>\n"; |
2518 |
} else {
|
2519 |
echo $LANG["job"][32]; |
2520 |
} |
2521 |
} else {
|
2522 |
$fup->fields2=$DB->fetch_array($result2); |
2523 |
if ($commentall){ |
2524 |
|
2525 |
echo "<div id='plan' onClick='showPlan".$ID."()'>\n"; |
2526 |
echo "<span class='showplan'>"; |
2527 |
} |
2528 |
echo getPlanningState($fup->fields2["state"])."<br>".convDateTime($fup->fields2["begin"])."<br>->".convDateTime($fup->fields2["end"])."<br>".getUserName($fup->fields2["id_assign"]); |
2529 |
if ($commentall){ |
2530 |
echo "</span>"; |
2531 |
echo "</div>\n"; |
2532 |
echo "<div id='viewplan'></div>\n"; |
2533 |
} |
2534 |
} |
2535 |
|
2536 |
echo "</td>"; |
2537 |
echo "</tr>"; |
2538 |
|
2539 |
if ($commentall){ |
2540 |
echo "<tr class='tab_bg_2'>"; |
2541 |
echo "<td align='center' colspan='2'>"; |
2542 |
echo "<table width='100%'><tr><td class='center'>"; |
2543 |
echo "<input type='submit' name='update_followup' value='".$LANG["buttons"][14]."' class='submit'>"; |
2544 |
echo "</td><td class='center'>"; |
2545 |
echo "<input type='submit' name='delete_followup' value='".$LANG["buttons"][6]."' class='submit'>"; |
2546 |
echo "</td></tr></table>"; |
2547 |
echo "</td>"; |
2548 |
echo "</tr>"; |
2549 |
} |
2550 |
|
2551 |
|
2552 |
echo "</table>"; |
2553 |
echo "</td></tr>"; |
2554 |
|
2555 |
echo "</table>"; |
2556 |
if ($commentall){ |
2557 |
echo "<input type='hidden' name='ID' value='".$fup->fields["ID"]."'>"; |
2558 |
echo "<input type='hidden' name='tracking' value='".$fup->fields["tracking"]."'>"; |
2559 |
echo "</form>"; |
2560 |
} |
2561 |
echo "</td></tr>"; |
2562 |
echo "</table>"; |
2563 |
echo "</div>"; |
2564 |
|
2565 |
|
2566 |
} |
2567 |
} |
2568 |
|
2569 |
/** Computer total cost of a ticket
|
2570 |
* @param $realtime float : ticket realtime
|
2571 |
* @param $cost_time float : ticket time cost
|
2572 |
* @param $cost_fixed float : ticket fixed cost
|
2573 |
* @param $cost_material float : ticket material cost
|
2574 |
* @return total cost formatted string
|
2575 |
*/
|
2576 |
function trackingTotalCost($realtime,$cost_time,$cost_fixed,$cost_material){ |
2577 |
return formatNumber(($realtime*$cost_time)+$cost_fixed+$cost_material); |
2578 |
} |
2579 |
|
2580 |
/**
|
2581 |
* Calculate Ticket TCO for a device
|
2582 |
*
|
2583 |
*
|
2584 |
*
|
2585 |
*@param $item_type device type
|
2586 |
*@param $item ID of the device
|
2587 |
*
|
2588 |
*@return float
|
2589 |
*
|
2590 |
**/
|
2591 |
function computeTicketTco($item_type,$item){ |
2592 |
global $DB; |
2593 |
$totalcost=0; |
2594 |
|
2595 |
$query="SELECT * |
2596 |
FROM glpi_tracking
|
2597 |
WHERE (device_type = '$item_type'
|
2598 |
AND computer = '$item')
|
2599 |
AND (cost_time>0
|
2600 |
OR cost_fixed>0
|
2601 |
OR cost_material>0)";
|
2602 |
$result = $DB->query($query); |
2603 |
|
2604 |
$i = 0; |
2605 |
if ($DB->numrows($result)){ |
2606 |
while ($data=$DB->fetch_array($result)){ |
2607 |
$totalcost+=trackingTotalCost($data["realtime"],$data["cost_time"],$data["cost_fixed"],$data["cost_material"]); |
2608 |
} |
2609 |
} |
2610 |
return $totalcost; |
2611 |
} |
2612 |
|
2613 |
?>
|