| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Classes helpdeskEvent, helpdeskTicket, helpdeskFollowup
|
| 4 |
* @package helpdesk
|
| 5 |
* Copyright OSI 2005. Licensed under GPL version 2.
|
| 6 |
* $Id$
|
| 7 |
*/
|
| 8 |
|
| 9 |
// echo "<p>Start of " . __FILE__ . "</p>" ;
|
| 10 |
|
| 11 |
$_event_saved_er = error_reporting(E_ALL || E_STRICT) ;
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Import time-related code
|
| 15 |
*/
|
| 16 |
require_once("misc.php") ;
|
| 17 |
require_once("timeinfo.php") ;
|
| 18 |
|
| 19 |
/**
|
| 20 |
* import HD core
|
| 21 |
*/
|
| 22 |
require_once("core.php");
|
| 23 |
|
| 24 |
/**
|
| 25 |
* Support event
|
| 26 |
* @package helpdesk
|
| 27 |
*/
|
| 28 |
abstract class helpdeskEvent extends helpdeskObject
|
| 29 |
{
|
| 30 |
public $nid ; ///< link to drupal node object
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Generates the code for hook_form when node is a Helpdesk event
|
| 34 |
* @return string
|
| 35 |
*/
|
| 36 |
function form ()
|
| 37 |
{
|
| 38 |
// Now we define the form elements specific to our node type.
|
| 39 |
$ret = t ("<p>Defining new %nodename</p>\n", array ('%nodename' => helpdesk_node_name ($node))) ;
|
| 40 |
// This would allow format selection, but events are plain text, so we use 1 = filtered html
|
| 41 |
// $ret .= filter_form ('format', $node->format);
|
| 42 |
$node->format = 1 ; // Filtered HTML
|
| 43 |
|
| 44 |
/**
|
| 45 |
* TimeID information for new event
|
| 46 |
*/
|
| 47 |
$ret .= helpdeskTimeInfo::form (
|
| 48 |
t ('Date and time problem was notified'),
|
| 49 |
t('The start time defines the start of any contractual answering answer time guarantee. '
|
| 50 |
. 'It is automatically inserted at the time the issue is created and the '
|
| 51 |
. 'ticket is issued.'),
|
| 52 |
format_date(time(), 'small', NULL,NULL), TRUE, FALSE,
|
| 53 |
format_date(time(), 'small', NULL,NULL), FALSE, FALSE,
|
| 54 |
format_date(time(), 'small', NULL,NULL), FALSE, FALSE,
|
| 55 |
'', helpdesk_access (HELPDESKHOOKACCESSUPDATE,HELPDESKNODETICKET), TRUE
|
| 56 |
) ;
|
| 57 |
|
| 58 |
/**
|
| 59 |
* Contents for new event
|
| 60 |
*/
|
| 61 |
$ret .= form_textarea (
|
| 62 |
t ('Describe the issue you\'re having as thouroughly as possible, including the version numbers of any piece of software'
|
| 63 |
. ' and the serial number of any product affected by the issue. More precision yields shorter response times.'),
|
| 64 |
'body', isset ($node->body) ? $node->body : '', 60, 20) ;
|
| 65 |
return $ret ;
|
| 66 |
}
|
| 67 |
|
| 68 |
/**
|
| 69 |
* Generates a human-readable ticket number based on the nid of the
|
| 70 |
* ticket itself, or the ticket to which a followup is bound
|
| 71 |
* @return string the readable ticket number
|
| 72 |
*/
|
| 73 |
abstract function getTicket () ;
|
| 74 |
|
| 75 |
/**
|
| 76 |
* @return string HTML
|
| 77 |
*
|
| 78 |
* @return unknown
|
| 79 |
*/
|
| 80 |
function view()
|
| 81 |
{
|
| 82 |
return "helpdeskEvent/view(nid = $this->nid)" ;
|
| 83 |
}
|
| 84 |
|
| 85 |
function init($node, $fromDB)
|
| 86 |
{
|
| 87 |
if (HELPDESKDEBUGALLFUNCTIONS == TRUE)
|
| 88 |
{
|
| 89 |
echo "<pre>HD EVENT/init ("
|
| 90 |
. (isset($node->nid) ? $node->nid : 'new node')
|
| 91 |
. ','
|
| 92 |
. ($fromDB ? 'from DB' : 'from passed node')
|
| 93 |
. ")</pre>\r\n" ;
|
| 94 |
}
|
| 95 |
$this->nid = $node->nid ;
|
| 96 |
return get_class($this) . "/view(nid = $this->nid" ;
|
| 97 |
}
|
| 98 |
|
| 99 |
/**
|
| 100 |
* class constructor
|
| 101 |
*/
|
| 102 |
function __construct()
|
| 103 |
{
|
| 104 |
$this->nid = 0 ;
|
| 105 |
}
|
| 106 |
}
|
| 107 |
|
| 108 |
/**
|
| 109 |
* @package helpdesk
|
| 110 |
*/
|
| 111 |
class helpdeskTicket extends helpdeskEvent
|
| 112 |
{
|
| 113 |
public $timeid ;
|
| 114 |
public $contractnid ;
|
| 115 |
public $txnid ;
|
| 116 |
public $tidseverity ;
|
| 117 |
public $tidstatus ;
|
| 118 |
public $tempcontact ;
|
| 119 |
public $attachment ;
|
| 120 |
public $uidtech ;
|
| 121 |
public $techname;
|
| 122 |
|
| 123 |
/**
|
| 124 |
* @return string the readable ticket number
|
| 125 |
*/
|
| 126 |
function getTicket ()
|
| 127 |
{
|
| 128 |
$prefix = variable_get(HELPDESKVARTICKETPREFIX, '') ;
|
| 129 |
$offset = variable_get(HELPDESKVARTICKETOFFSET , 0) ;
|
| 130 |
|
| 131 |
if (!isset($this->nid))
|
| 132 |
return '' ;
|
| 133 |
else
|
| 134 |
return sprintf ("%s%u", $prefix, $offset + $this->nid) ;
|
| 135 |
}
|
| 136 |
|
| 137 |
/**
|
| 138 |
* Generates the code for hook_form when node is a helpdesk Ticket
|
| 139 |
* @return string HTML
|
| 140 |
*/
|
| 141 |
function form()
|
| 142 |
{
|
| 143 |
// Now we define the form elements specific to our node type.
|
| 144 |
if (HELPDESKDEBUGALLFUNCTIONS == TRUE)
|
| 145 |
{
|
| 146 |
$ret = t ("<p>Defining new %nodename</p>\n", array ('%nodename' => $this->node_name())) ;
|
| 147 |
}
|
| 148 |
else
|
| 149 |
$ret = '' ;
|
| 150 |
|
| 151 |
|
| 152 |
/* This would allow format selection, but tickets are plain text (are they ?), so we use 1 = filtered html */
|
| 153 |
// $ret .= filter_form ('format', $node->format);
|
| 154 |
// $node->format = 1 ; // Filtered HTML
|
| 155 |
// But there's no "node" code in this method !
|
| 156 |
// @todo find where input filtering goes in this model
|
| 157 |
|
| 158 |
// Select contract holder
|
| 159 |
/* To be processed:
|
| 160 |
attachment
|
| 161 |
contractid
|
| 162 |
nidparent, nidroot
|
| 163 |
tempcontact
|
| 164 |
X ticket
|
| 165 |
X tidseverity
|
| 166 |
X tidstatus
|
| 167 |
txnid
|
| 168 |
uidtech
|
| 169 |
uiduser
|
| 170 |
*/
|
| 171 |
|
| 172 |
$ret .= t('The human-readable ticket number is ') . $this->getTicket() ;
|
| 173 |
|
| 174 |
/* display ticket timeinfo */
|
| 175 |
$ti = new helpdeskTimeInfo();
|
| 176 |
$ti->init(array(
|
| 177 |
'S' => time(),
|
| 178 |
'A' => time(),
|
| 179 |
'M' => time(),
|
| 180 |
'E' => '',
|
| 181 |
'showS' => TRUE, 'showA' => TRUE, 'showM' => TRUE, 'showE' => TRUE,
|
| 182 |
'enabledS' => TRUE, 'enabledA' => FALSE, 'enabledM' => FALSE, 'enabledE' => TRUE),
|
| 183 |
FALSE) ; // Load from params, not from DB
|
| 184 |
$items = $ti->form();
|
| 185 |
$ret .= form_group
|
| 186 |
(
|
| 187 |
t ('Ticket date information'),
|
| 188 |
$items,
|
| 189 |
t ('Here you must define the date the ticket is issued (default to current date)'
|
| 190 |
. ' optionally define when it ends if it happens to be closed during the opening call,'
|
| 191 |
. ' and access/modification dates (default to current date)'
|
| 192 |
),
|
| 193 |
NULL) ;
|
| 194 |
|
| 195 |
//==== OK above this line ====
|
| 196 |
/* this might be usable for terms selection, although a better function probably exists in taxonomy.module */
|
| 197 |
$arTerms = _helpdesk_get_terms(HELPDESKVARVIDSEVERITY) ;
|
| 198 |
$ret .= form_select(
|
| 199 |
t('Severity of event'), // title
|
| 200 |
HELPDESKVARVIDSEVERITY, // name
|
| 201 |
variable_get(HELPDESKVARVIDSEVERITY, NULL), // current value
|
| 202 |
$arTerms, // array of vocabularies
|
| 203 |
t('Choose the severity from the values allowed for severity conditions.'), // description
|
| 204 |
NULL, // extra
|
| 205 |
FALSE, // Only one vocabulary used
|
| 206 |
TRUE); // One vocabulary must be selected
|
| 207 |
/* */
|
| 208 |
|
| 209 |
/**
|
| 210 |
* Parameters for new ticket
|
| 211 |
*/
|
| 212 |
$items = form_checkbox (t ('Suspended'), 'isSuspended', 1, $this->isSuspended, '', NULL, FALSE) ;
|
| 213 |
$items .= theme_table
|
| 214 |
(
|
| 215 |
array (t ('Contract limits'), t ('Limit value'), t ('Increment')),
|
| 216 |
array
|
| 217 |
(
|
| 218 |
array (
|
| 219 |
form_checkbox (t ('Minutes spent'), 'useMaxTime', 1, $this->useMaxTime, '', NULL, FALSE),
|
| 220 |
form_textfield ('', 'maxTime', $this->maxTime, 16, 16, NULL, NULL, FALSE),
|
| 221 |
form_textfield ('', 'defTimeIncrement', $this->defTimeIncrement, 4, 4, NULL, NULL, FALSE)
|
| 222 |
),
|
| 223 |
array (
|
| 224 |
form_checkbox (t ('Number of tickets'), 'useMaxIssue', 1, $this->useMaxIssue, '', NULL, FALSE),
|
| 225 |
form_textfield ('', 'maxIssue', $this->maxIssue, 16, 16, NULL, NULL, FALSE),
|
| 226 |
' '),
|
| 227 |
array (
|
| 228 |
form_checkbox (t ('Date'), 'useMaxDate', 1, $this->useMaxDate, '', NULL, FALSE),
|
| 229 |
form_textfield ('', 'maxDate', $this->maxDate, 16, 16, NULL, NULL, FALSE),
|
| 230 |
' ')
|
| 231 |
)
|
| 232 |
) ;
|
| 233 |
|
| 234 |
$ret .= form_group (
|
| 235 |
t ('Contract status'),
|
| 236 |
$items,
|
| 237 |
t ('Here you set the attributes of the contract: is it time-limited, duration-limited, issue-limited ? does it start suspended ?'
|
| 238 |
. ' The increment value for time-limited contracts is the default duration consumed by each followup.'),
|
| 239 |
NULL) ;
|
| 240 |
|
| 241 |
$ret .= form_textarea(t('Contract wording'), 'body', (isset($this->node->body) ? $this->node->body : ''), 60, 20);
|
| 242 |
return $ret ;
|
| 243 |
}
|
| 244 |
|
| 245 |
function init($node, $fromDB)
|
| 246 |
{
|
| 247 |
if (HELPDESKDEBUGALLFUNCTIONS == TRUE)
|
| 248 |
{ echo "<pre>HD TICKET/init (" . (isset($node->nid) ? $node->nid : 'new node') . ", fromDB = " . ($fromDB ? 'True' : 'False') . ")</pre>\r\n" ; }
|
| 249 |
$ret = parent::init($node, $fromDB);
|
| 250 |
if ($fromDB)
|
| 251 |
{
|
| 252 |
// As we are querying for a Ticket, parent and root will be equal to self: we don't need to query for them
|
| 253 |
$q = '
|
| 254 |
SELECT
|
| 255 |
hde.timeid, hde.contractnid, hde.txnid,
|
| 256 |
hde.tidseverity, hde.tidstatus,
|
| 257 |
hde.tempcontact, hde.attachment,
|
| 258 |
hdt.stime, hdt.atime, hdt.mtime, hdt.etime,
|
| 259 |
hde.uidtech, u.name techname
|
| 260 |
FROM {hd_event} hde
|
| 261 |
LEFT JOIN {hd_timeinfo} hdt on hde.timeid = hdt.timeid
|
| 262 |
LEFT JOIN {users} u on hde.uidtech = u.uid
|
| 263 |
WHERE
|
| 264 |
hde.nid = %d
|
| 265 |
' ;
|
| 266 |
$req = db_query ($q, $node->nid);
|
| 267 |
$ar = db_fetch_array($req) ; // Should give exactly one row of result, zero if ticket does not exist yet
|
| 268 |
foreach ($ar as $key => $value)
|
| 269 |
{
|
| 270 |
$this->$key = $value ;
|
| 271 |
}
|
| 272 |
echo "<pre>New ticket object: " . print_r ($this, True) . "</pre>\r\n";
|
| 273 |
}
|
| 274 |
else
|
| 275 |
echo "<p>Ticket not from DB</p>" ;
|
| 276 |
}
|
| 277 |
|
| 278 |
/**
|
| 279 |
* @return string HTML
|
| 280 |
*
|
| 281 |
*/
|
| 282 |
function view()
|
| 283 |
{
|
| 284 |
$headers = array(
|
| 285 |
t('Parameter'),
|
| 286 |
t('Value')
|
| 287 |
);
|
| 288 |
|
| 289 |
$cnode = node_load(array('nid' => $this->contractnid));
|
| 290 |
// Must still add display for timeid, txnid, tempcontact, attachment
|
| 291 |
$rows = array
|
| 292 |
( // Row with attributes on the row and some of its cells.
|
| 293 |
array
|
| 294 |
(
|
| 295 |
t('Current ticket status'),
|
| 296 |
array ('data' => taxonomy_get_term ($this->tidstatus)->name, 'style' => 'text-align: center')
|
| 297 |
),
|
| 298 |
array
|
| 299 |
(
|
| 300 |
t('Current ticket severity'),
|
| 301 |
array ('data' => taxonomy_get_term ($this->tidseverity)->name, 'style' => 'text-align: center')
|
| 302 |
),
|
| 303 |
array
|
| 304 |
(
|
| 305 |
t('Helpdesk Tech in charge'),
|
| 306 |
array ('data' => isset ($this->techname) ? l($this->techname, "user/$this->uidtech") : t('None assigned yet'), 'style' => 'text-align: center'),
|
| 307 |
),
|
| 308 |
array
|
| 309 |
(
|
| 310 |
t('Contract being charged'),
|
| 311 |
array ('data' => l($cnode->title, "node/$this->contractnid"), 'style' => 'text-align: center'),
|
| 312 |
)
|
| 313 |
);
|
| 314 |
|
| 315 |
$output = theme_table($headers, $rows);
|
| 316 |
return $output;
|
| 317 |
}
|
| 318 |
}
|
| 319 |
|
| 320 |
/**
|
| 321 |
* @package helpdesk
|
| 322 |
*/
|
| 323 |
class helpdeskFollowup extends helpdeskTicket
|
| 324 |
{
|
| 325 |
}
|
| 326 |
|
| 327 |
|
| 328 |
error_reporting($_event_saved_er) ;
|
| 329 |
unset($_event_saved_er) ;
|
| 330 |
// echo "<p>End of " . __FILE__ . "</p>" ;
|
| 331 |
?>
|