本文整理汇总了PHP中Ticket::getField方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::getField方法的具体用法?PHP Ticket::getField怎么用?PHP Ticket::getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::getField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pdfForTicket
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
{
global $CFG_GLPI, $DB;
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Approvals for the ticket') . "</b>");
if (!Session::haveRight('validate_request', 1) && !Session::haveRight('validate_incident', 1) && !Session::haveRight('create_incident_validation', 1) && !Session::haveRight('create_request_validation', 1)) {
return false;
}
$ID = $ticket->getField('id');
$query = "SELECT *\n FROM `glpi_ticketvalidations`\n WHERE `tickets_id` = '" . $ticket->getField('id') . "'\n ORDER BY submission_date DESC";
$result = $DB->query($query);
$number = $DB->numrows($result);
if ($number) {
$pdf->setColumnsSize(20, 19, 21, 19, 21);
$pdf->displayTitle(_x('item', 'State'), __('Request date'), __('Approval requester'), __('Approval date'), __('Approver'));
while ($row = $DB->fetch_assoc($result)) {
$pdf->setColumnsSize(20, 19, 21, 19, 21);
$pdf->displayLine(TicketValidation::getStatus($row['status']), Html::convDateTime($row["submission_date"]), getUserName($row["users_id"]), Html::convDateTime($row["validation_date"]), getUserName($row["users_id_validate"]));
$tmp = trim($row["comment_submission"]);
$pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Request comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
if ($row["validation_date"]) {
$tmp = trim($row["comment_validation"]);
$pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Approval comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1));
}
}
} else {
$pdf->displayLine(__('No item found'));
}
$pdf->displaySpace();
}
示例2: createGroup
function createGroup(Ticket $ticket, $date, $groups_id, $type)
{
$calendar = new Calendar();
if ($type == 'new') {
$calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
$begin = $calendar->getActiveTimeBetween($ticket->fields['date'], $date);
} else {
// cas 24/24 - 7/7
$begin = strtotime($date) - strtotime($ticket->fields['date']);
}
$this->add(array('tickets_id' => $ticket->getField("id"), 'date' => $date, 'groups_id' => $groups_id, 'begin' => $begin));
} else {
if ($type == 'delete') {
$a_dbentry = $this->find("`tickets_id`='" . $ticket->getField("id") . "'\n AND `groups_id`='" . $groups_id . "'\n AND `delay` IS NULL", "", 1);
if (count($a_dbentry) == 1) {
$input = current($a_dbentry);
$calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
$input['delay'] = $calendar->getActiveTimeBetween($input['date'], $date);
} else {
// cas 24/24 - 7/7
$input['delay'] = strtotime($date) - strtotime($input['date']);
}
$this->update($input);
}
}
}
}
示例3: pdfForTicket
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job)
{
global $CFG_GLPI, $DB;
$ID = $job->getField('id');
//////////////followups///////////
$query = "SELECT *\n FROM `glpi_ticketcosts`\n WHERE `tickets_id` = '{$ID}'\n ORDER BY `begin_date`";
$result = $DB->query($query);
if (!$DB->numrows($result)) {
$pdf->setColumnsSize(100);
$pdf->displayLine(__('No ticket cost for this ticket', 'pdf'));
} else {
$pdf->setColumnsSize(60, 20, 20);
$pdf->displayTitle("<b>" . TicketCost::getTypeName($DB->numrows($result)), __('Ticket duration'), CommonITILObject::getActionTime($job->fields['actiontime']) . "</b>");
$pdf->setColumnsSize(20, 10, 10, 10, 10, 10, 10, 10, 10);
$pdf->setColumnsAlign('center', 'center', 'center', 'left', 'right', 'right', 'right', 'right', 'right');
$pdf->displayTitle("<b><i>" . __('Name') . "</i></b>", "<b><i>" . __('Begin date') . "</i></b>", "<b><i>" . __('End date') . "</i></b>", "<b><i>" . __('Budget') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Time cost') . "</i></b>", "<b><i>" . __('Fixed cost') . "</i></b>", "<b><i>" . __('Material cost') . "</i></b>", "<b><i>" . __('Total cost') . "</i></b>");
while ($data = $DB->fetch_array($result)) {
$cost = TicketCost::computeTotalCost($data['actiontime'], $data['cost_time'], $data['cost_fixed'], $data['cost_material']);
$pdf->displayLine($data['name'], Html::convDate($data['begin_date']), Html::convDate($data['end_date']), Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']), CommonITILObject::getActionTime($data['actiontime']), Html::formatNumber($data['cost_time']), Html::formatNumber($data['cost_fixed']), Html::formatNumber($data['cost_material']), Html::formatNumber($cost));
$total_time += $data['actiontime'];
$total_costtime += $data['actiontime'] * $data['cost_time'] / HOUR_TIMESTAMP;
$total_fixed += $data['cost_fixed'];
$total_material += $data['cost_material'];
$total += $cost;
}
$pdf->setColumnsSize(50, 10, 10, 10, 10, 10);
$pdf->setColumnsAlign('right', 'right', 'right', 'right', 'right', 'right');
$pdf->displayLine('<b>' . __('Total'), CommonITILObject::getActionTime($total_time), Html::formatNumber($total_costtime), Html::formatNumber($total_fixed), Html::formatNumber($total_material), Html::formatNumber($total));
}
$pdf->displaySpace();
}
示例4:
static function plugin_vip_item_delete(Ticket $ticket)
{
global $DB;
$ticketid = $ticket->getField('id');
$delticketquery = "DELETE FROM glpi_plugin_vip_tickets\n\t\t\t\t\t\t\t\t WHERE id = " . $ticketid;
$delvipticket = $DB->query($delticketquery);
}
示例5: pdfForTicket
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
{
global $CFG_GLPI, $DB;
$ID = $job->getField('id');
//////////////Tasks///////////
$RESTRICT = "";
if (!$private) {
// Don't show private'
$RESTRICT = " AND `is_private` = '0' ";
} else {
if (!Session::haveRight("show_full_ticket", "1")) {
// No right, only show connected user private one
$RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
}
}
$query = "SELECT *\n FROM `glpi_tickettasks`\n WHERE `tickets_id` = '{$ID}'\n {$RESTRICT}\n ORDER BY `date` DESC";
$result = $DB->query($query);
if (!$DB->numrows($result)) {
$pdf->setColumnsSize(100);
$pdf->displayLine(__('No task found.'));
} else {
$pdf->displayTitle("<b>" . TicketTask::getTypeName($DB->numrows($result) . "</b>"));
$pdf->setColumnsSize(20, 20, 20, 20, 20);
$pdf->displayTitle("<b><i>" . __('Type') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Writer') . "</i></b>", "<b><i>" . __('Planning') . "</i></b>");
while ($data = $DB->fetch_array($result)) {
$actiontime = Html::timestampToString($data['actiontime'], false);
$planification = '';
if (empty($data['begin'])) {
if (isset($data["state"])) {
$planification = Planning::getState($data["state"]) . "<br>";
}
$planification .= _e('None');
} else {
if (isset($data["state"])) {
$planification = sprintf(__('%1$s: %2$s'), _x('item', 'State'), Planning::getState($data["state"]));
}
$planificiation = sprintf(__('%1$s - %2$s'), $planification, Html::convDateTime($data["begin"]) . " -> " . Html::convDateTime($data["end"]));
$planificiation = sprintf(__('%1$s - %2$s'), $planification, sprintf(__('%1$s %2$s'), __('By'), getUserName($data["users_id_tech"])));
}
if ($data['taskcategories_id']) {
$lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']);
} else {
$lib = '';
}
if ($data['is_private']) {
$lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
}
toolbox::logdebug("lib", $data);
$pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::timestampToString($data["actiontime"], 0), Html::clean(getUserName($data["users_id"])), Html::clean($planification), 1);
$pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Description') . "</i></b>", Html::clean($data["content"]), 1));
}
}
$pdf->displaySpace();
}
示例6: pdfForTicket
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
{
global $CFG_GLPI, $DB;
$ID = $job->getField('id');
//////////////followups///////////
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Ticket followup') . "</b>");
$RESTRICT = "";
if (!$private) {
// Don't show private'
$RESTRICT = " AND `is_private` = '0' ";
} else {
if (!Session::haveRight("show_full_ticket", "1")) {
// No right, only show connected user private one
$RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
}
}
$query = "SELECT *\n FROM `glpi_ticketfollowups`\n WHERE `tickets_id` = '{$ID}'\n {$RESTRICT}\n ORDER BY `date` DESC";
$result = $DB->query($query);
if (!$DB->numrows($result)) {
$pdf->displayLine(__('No followup for this ticket.'));
} else {
while ($data = $DB->fetch_array($result)) {
$pdf->setColumnsSize(44, 14, 42);
$pdf->displayTitle("<b><i>" . __('Source of followup') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Requester') . "</i></b>");
// Author
if ($data['requesttypes_id']) {
$lib = Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']);
} else {
$lib = '';
}
if ($data['is_private']) {
$lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
}
$pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::clean(getUserName($data["users_id"])));
$pdf->displayText('<b><i>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</i></b>', $data["content"]));
}
}
$pdf->displaySpace();
}
示例7: showForTicket
/**
* Show problems for a ticket
*
* @param $ticket Ticket object
**/
static function showForTicket(Ticket $ticket)
{
global $DB, $CFG_GLPI;
$ID = $ticket->getField('id');
if (!Session::haveRight("show_all_problem", 1) || !$ticket->can($ID, 'r')) {
// if (!$ticket->can($ID,'r')) {
return false;
}
$canedit = $ticket->can($ID, 'w');
$rand = mt_rand();
$query = "SELECT DISTINCT `glpi_problems_tickets`.`id` AS linkID,\n `glpi_problems`.*\n FROM `glpi_problems_tickets`\n LEFT JOIN `glpi_problems`\n ON (`glpi_problems_tickets`.`problems_id` = `glpi_problems`.`id`)\n WHERE `glpi_problems_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_problems`.`name`";
$result = $DB->query($query);
$problems = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$problems[$data['id']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='problemticket_form{$rand}' id='problemticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a problem') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
$condition = "`glpi_problems`.`status` NOT IN ('" . implode("', '", array_merge(Problem::getSolvedStatusArray(), Problem::getClosedStatusArray())) . "')";
Problem::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID(), 'condition' => $condition));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td><td>";
echo "<a href='" . Toolbox::getItemTypeFormURL('Problem') . "?tickets_id={$ID}'>";
_e('Create a problem from this ticket');
echo "</a>";
echo "</td></tr></table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $numrows) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $numrows);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='11'>" . Problem::getTypeName($numrows) . "</th>";
echo "</tr>";
if ($numrows) {
Problem::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
Session::initNavigateListItems('Problem', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
$i = 0;
foreach ($problems as $data) {
Session::addToNavigateListItems('Problem', $data["id"]);
Problem::showShort($data['id'], Search::HTML_OUTPUT, $i, $data['linkID']);
$i++;
}
}
echo "</table>";
if ($canedit && $numrows) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions(__CLASS__, $massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例8: methodsetTicketAssign
/**
* Assign and actor in a ticket for an authenticated user
*
* @param $params array of options (ticket, id2name)
* @param $protocol the communication protocol used
*
* @return array of hashtable as glpi.getTicket
**/
static function methodsetTicketAssign($params, $protocol)
{
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('ticket' => 'integer,mandatory', 'user' => 'integer,optional', 'supplier' => 'integer,optional', 'group' => 'integer,optional', 'user_email' => 'string,optional', 'use_email_notification' => 'bool,optional', 'help' => 'bool,optional');
}
if (!Session::getLoginUserID()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
}
if (!Session::haveRight("assign_ticket", "1")) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
}
if (!isset($params['user']) && !isset($params['group']) && !isset($params['supplier'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'user or group or supplier');
}
$ticket = new Ticket();
if (!isset($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket');
}
if (!is_numeric($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket=' . $params['ticket']);
}
if (!$ticket->can($params['ticket'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
}
if (!$ticket->getFromDB($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'ticket');
}
$ticket_user = new Ticket_User();
$user = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN);
// technician : optionnal, default = none
if (isset($params['user'])) {
if (!is_numeric($params['user'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user');
}
$user['users_id'] = $params['user'];
if ($ticket->getFromDB($params['ticket'])) {
$entity = $ticket->getField('entities_id');
}
if (!$ticket_user->can(-1, 'w', $user) || !self::checkUserRights($params['user'], "own_ticket", 1, $entity)) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
}
if ($ticket->isUser(CommonITILActor::ASSIGN, $user['users_id'])) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'User already assign for this ticket');
}
if (isset($params['user_email'])) {
if (!NotificationMail::isUserAddressValid($params['user_email'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user_email');
}
$user['alternative_email'] = $params['user_email'];
$user['use_notification'] = 1;
} else {
if (isset($params['use_email_notification']) && $params['use_email_notification']) {
$user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 1);
} else {
if (isset($params['use_email_notification']) && !$params['use_email_notification']) {
$user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 0);
}
}
}
if (!$ticket_user->add($user)) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'user not assign');
}
}
// group (technicians group) : optionnal, default = none
$group_ticket = new Group_Ticket();
$group = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN);
if (isset($params['group'])) {
if (!is_numeric($params['group'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'group');
}
$group['groups_id'] = $params['group'];
if (!$group_ticket->can(-1, 'w', $group)) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
}
if ($ticket->isGroup(CommonITILActor::ASSIGN, $params['group'])) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'Group already assign for this ticket');
}
if (!$group_ticket->add($group)) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'group not assign');
}
}
// supplier to assign : optionnal, default = none
$supplier_ticket = new Supplier_Ticket();
$supplier = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN);
if (isset($params['supplier'])) {
if (!is_numeric($params['supplier'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'supplier');
}
$supplier['suppliers_id'] = $params['supplier'];
if (!$supplier_ticket->can(-1, 'w', $supplier)) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
//.........这里部分代码省略.........
示例9: showForm
/**
* Print the wainting ticket form
*
* @param $ID integer ID of the item
* @param $options array
* - target filename : where to go when done.
* - withtemplate boolean : template or basic item
*
* @return Nothing (display)
* */
function showForm($ID, $options = array())
{
global $CFG_GLPI;
// validation des droits
if (!$this->canview()) {
return false;
}
$ticket = new Ticket();
if ($ID > 0) {
if (!$ticket->getFromDB($ID)) {
$ticket->getEmpty();
}
} else {
// Create item
$ticket->getEmpty();
}
// If values are saved in session we retrieve it
if (isset($_SESSION['glpi_plugin_moreticket_close'])) {
foreach ($_SESSION['glpi_plugin_moreticket_close'] as $key => $value) {
$ticket->fields[$key] = str_replace(array('\\r\\n', '\\r', '\\n'), '', $value);
}
}
unset($_SESSION['glpi_plugin_moreticket_close']);
echo "<div class='spaced' id='moreticket_close_ticket'>";
echo "</br>";
echo "<table class='moreticket_close_ticket' id='cl_menu'>";
echo "<tr><td>";
echo _n('Solution template', 'Solution templates', 1) . " : ";
$rand_template = mt_rand();
$rand_type = 0;
$rand_text = mt_rand();
$rand_type = mt_rand();
SolutionTemplate::dropdown(array('value' => 0, 'entity' => $ticket->getEntityID(), 'rand' => $rand_template, 'toupdate' => array('value_fieldname' => 'value', 'to_update' => 'solution' . $rand_text, 'url' => $CFG_GLPI["root_doc"] . "/ajax/solution.php", 'moreparams' => array('type_id' => 'dropdown_solutiontypes_id' . $rand_type))));
echo "</td></tr>";
echo "<tr><td>";
echo _n('Solution type', 'Solution types', 1);
$config = new PluginMoreticketConfig();
if ($config->mandatorySolutionType() == true) {
echo " : <span class='red'>*</span> ";
}
Dropdown::show('SolutionType', array('value' => $ticket->getField('solutiontypes_id'), 'rand' => $rand_type, 'entity' => $ticket->getEntityID()));
echo "</td></tr>";
echo "<tr><td>";
echo __('Solution description', 'moreticket') . " : <span class='red'>*</span> ";
$rand = mt_rand();
Html::initEditorSystem("solution" . $rand);
echo "<div id='solution{$rand_text}'>";
echo "<textarea id='solution{$rand}' name='solution' rows='3'>" . stripslashes($ticket->fields['solution']) . "</textarea></div>";
echo "</td></tr>";
echo "</table>";
echo "</div>";
}
示例10: getDatasForObject
/**
* @see NotificationTargetCommonITILObject::getDatasForObject()
**/
function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
{
global $CFG_GLPI;
// Common ITIL datas
$datas = parent::getDatasForObject($item, $options, $simple);
// Specific datas
$datas['##change.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $item->getField("id") . "_ChangeValidation\$1");
$datas['##change.globalvalidation##'] = ChangeValidation::getStatus($item->getField('global_validation'));
// $datas["##problem.impacts##"] = $item->getField('impactcontent');
// $datas["##problem.causes##"] = $item->getField('causecontent');
// $datas["##problem.symptoms##"] = $item->getField('symptomcontent');
// Complex mode
if (!$simple) {
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$tickets = getAllDatasFromTable('glpi_changes_tickets', $restrict);
$datas['tickets'] = array();
if (count($tickets)) {
$ticket = new Ticket();
foreach ($tickets as $data) {
if ($ticket->getFromDB($data['tickets_id'])) {
$tmp = array();
$tmp['##ticket.id##'] = $data['tickets_id'];
$tmp['##ticket.date##'] = $ticket->getField('date');
$tmp['##ticket.title##'] = $ticket->getField('name');
$tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']);
$tmp['##ticket.content##'] = $ticket->getField('content');
$datas['tickets'][] = $tmp;
}
}
}
$datas['##change.numberoftickets##'] = count($datas['tickets']);
$restrict = "`changes_id`='" . $item->getField('id') . "'";
$problems = getAllDatasFromTable('glpi_changes_problems', $restrict);
$datas['problems'] = array();
if (count($problems)) {
$problem = new Problem();
foreach ($problems as $data) {
if ($problem->getFromDB($data['problems_id'])) {
$tmp = array();
$tmp['##problem.id##'] = $data['problems_id'];
$tmp['##problem.date##'] = $problem->getField('date');
$tmp['##problem.title##'] = $problem->getField('name');
$tmp['##problem.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Problem_" . $data['problems_id']);
$tmp['##problem.content##'] = $problem->getField('content');
$datas['problems'][] = $tmp;
}
}
}
$datas['##change.numberofproblems##'] = count($datas['problems']);
$restrict = "`changes_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_changes_items', $restrict);
$datas['items'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##item.itemtype##'] = $item2->getTypeName();
$tmp['##item.name##'] = $item2->getField('name');
$tmp['##item.serial##'] = $item2->getField('serial');
$tmp['##item.otherserial##'] = $item2->getField('otherserial');
$tmp['##item.contact##'] = $item2->getField('contact');
$tmp['##item.contactnum##'] = $item2->getField('contactnum');
$tmp['##item.location##'] = '';
$tmp['##item.user##'] = '';
$tmp['##item.group##'] = '';
$tmp['##item.model##'] = '';
//Object location
if ($item2->getField('locations_id') != NOT_AVAILABLE) {
$tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
}
//Object user
if ($item2->getField('users_id')) {
$user_tmp = new User();
if ($user_tmp->getFromDB($item2->getField('users_id'))) {
$tmp['##item.user##'] = $user_tmp->getName();
}
}
//Object group
if ($item2->getField('groups_id')) {
$tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
}
$modeltable = getSingular($item2->getTable()) . "models";
$modelfield = getForeignKeyFieldForTable($modeltable);
if ($item2->isField($modelfield)) {
$tmp['##item.model##'] = $item2->getField($modelfield);
}
$datas['items'][] = $tmp;
}
}
}
}
$datas['##change.numberofitems##'] = count($datas['items']);
//Validation infos
$restrict = "`changes_id`='" . $item->getField('id') . "'";
if (isset($options['validation_id']) && $options['validation_id']) {
$restrict .= " AND `glpi_changevalidations`.`id` = '" . $options['validation_id'] . "'";
//.........这里部分代码省略.........
示例11: showForm
function showForm($ID, $options = array())
{
global $CFG_GLPI, $DB;
if (!static::canView()) {
return false;
}
// In percent
$colsize1 = '13';
$colsize2 = '37';
$default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
// Set default options
if (!$ID) {
$values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
foreach ($values as $key => $val) {
if (!isset($options[$key])) {
$options[$key] = $val;
}
}
if (isset($options['tickets_id'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($options['tickets_id'])) {
$options['content'] = $ticket->getField('content');
$options['name'] = $ticket->getField('name');
$options['impact'] = $ticket->getField('impact');
$options['urgency'] = $ticket->getField('urgency');
$options['priority'] = $ticket->getField('priority');
$options['itilcategories_id'] = $ticket->getField('itilcategories_id');
$options['due_date'] = $ticket->getField('due_date');
}
}
if (isset($options['problems_id'])) {
$problem = new Problem();
if ($problem->getFromDB($options['problems_id'])) {
$options['content'] = $problem->getField('content');
$options['name'] = $problem->getField('name');
$options['impact'] = $problem->getField('impact');
$options['urgency'] = $problem->getField('urgency');
$options['priority'] = $problem->getField('priority');
$options['itilcategories_id'] = $problem->getField('itilcategories_id');
$options['due_date'] = $problem->getField('due_date');
}
}
}
if ($ID > 0) {
$this->check($ID, READ);
} else {
// Create item
$this->check(-1, CREATE, $options);
}
$showuserlink = 0;
if (User::canView()) {
$showuserlink = 1;
}
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>";
echo "<td class='left' width='{$colsize2}%'>";
if (isset($options['tickets_id'])) {
echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
}
if (isset($options['problems_id'])) {
echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
}
$date = $this->fields["date"];
if (!$ID) {
$date = date("Y-m-d H:i:s");
}
Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>";
echo "<td width='{$colsize2}%' class='left'>";
if ($this->fields["due_date"] == 'NULL') {
$this->fields["due_date"] = '';
}
Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1));
echo "</td></tr>";
if ($ID) {
echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>";
User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
echo "</td>";
echo "<th>" . __('Last update') . "</th>";
echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
if ($this->fields['users_id_lastupdater'] > 0) {
printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
}
echo "</td></tr>";
}
if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
echo "<tr class='tab_bg_1'>";
echo "<th>" . __('Date of solving') . "</th>";
echo "<td>";
Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
echo "<th>" . __('Closing date') . "</th>";
echo "<td>";
Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
} else {
echo "<td colspan='2'> </td>";
//.........这里部分代码省略.........
示例12: showForm
/**
* Print the ticket user form for notification
*
* @param $ID integer ID of the item
* @param $options array
*
* @return Nothing (display)
**/
function showForm($ID, $options = array())
{
global $CFG_GLPI, $LANG;
$this->check($ID, 'w');
echo "<br><form method='post' action='" . $CFG_GLPI['root_doc'] . "/front/popup.php'>";
echo "<div class='center'>";
echo "<table class='tab_cadre'>";
echo "<tr class='tab_bg_2'><td>" . $LANG['job'][38] . " :</td>";
echo "<td>";
$ticket = new Ticket();
if ($ticket->getFromDB($this->fields["tickets_id"])) {
echo $ticket->getField('name');
}
echo "</td></tr>";
$user = new User();
$email = "";
if ($user->getFromDB($this->fields["users_id"])) {
$email = $user->getField('email');
}
echo "<tr class='tab_bg_2'><td>" . $LANG['common'][34] . " :</td>";
echo "<td>" . $user->getName() . "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . $LANG['job'][19] . " :</td>";
echo "<td>";
Dropdown::showYesNo('use_notification', $this->fields['use_notification']);
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . $LANG['mailing'][118] . " :</td>";
echo "<td>";
if (!empty($email) && NotificationMail::isUserAddressValid($email)) {
echo $email;
} else {
echo "<input type='text' size='40' name='alternative_email' value='" . $this->fields['alternative_email'] . "'>";
}
echo "</td></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td class='center' colspan='2'>";
echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
echo "<input type='hidden' name='id' value='{$ID}'>";
echo "</td></tr>";
echo "</table></div></form>";
}
示例13: showForm
/**
* @param $ID
* @param $options array
**/
function showForm($ID, $options = array())
{
global $CFG_GLPI, $DB;
if (!static::canView()) {
return false;
}
// In percent
$colsize1 = '13';
$colsize2 = '37';
// Set default options
if (!$ID) {
$values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'name' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'itilcategories_id' => 0);
foreach ($values as $key => $val) {
if (!isset($options[$key])) {
$options[$key] = $val;
}
}
if (isset($options['tickets_id'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($options['tickets_id'])) {
$options['content'] = $ticket->getField('content');
$options['name'] = $ticket->getField('name');
$options['impact'] = $ticket->getField('impact');
$options['urgency'] = $ticket->getField('urgency');
$options['priority'] = $ticket->getField('priority');
$options['itilcategories_id'] = $ticket->getField('itilcategories_id');
}
}
}
$this->initForm($ID, $options);
$showuserlink = 0;
if (Session::haveRight('user', 'r')) {
$showuserlink = 1;
}
$this->showTabs($options);
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>";
echo "<td class='left' width='{$colsize2}%'>";
if (isset($options['tickets_id'])) {
echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
}
$date = $this->fields["date"];
if (!$ID) {
$date = date("Y-m-d H:i:s");
}
Html::showDateTimeFormItem("date", $date, 1, false);
echo "</td>";
echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>";
echo "<td width='{$colsize2}%' class='left'>";
if ($this->fields["due_date"] == 'NULL') {
$this->fields["due_date"] = '';
}
Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, true);
echo "</td></tr>";
if ($ID) {
echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>";
User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
echo "</td>";
echo "<th>" . __('Last update') . "</th>";
echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
if ($this->fields['users_id_lastupdater'] > 0) {
printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
}
echo "</td></tr>";
}
if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
echo "<tr class='tab_bg_1'>";
echo "<th>" . __('Date of solving') . "</th>";
echo "<td>";
Html::showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false);
echo "</td>";
if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
echo "<th>" . __('Closing date') . "</th>";
echo "<td>";
Html::showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false);
echo "</td>";
} else {
echo "<td colspan='2'> </td>";
}
echo "</tr>";
}
echo "</table>";
echo "<table class='tab_cadre_fixe' id='mainformtable2'>";
echo "<tr class='tab_bg_1'>";
echo "<th width='{$colsize1}%'>" . __('Status') . "</th>";
echo "<td width='{$colsize2}%'>";
self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
echo "</td>";
echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>";
echo "<td width='{$colsize2}%'>";
// Only change during creation OR when allowed to change priority OR when user is the creator
$idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<th>" . __('Category') . "</th>";
//.........这里部分代码省略.........
示例14: pdfSolution
static function pdfSolution(PluginPdfSimplePDF $pdf, Ticket $job)
{
global $CFG_GLPI, $DB;
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Solution') . "</b>");
if ($job->fields['solutiontypes_id'] || !empty($job->fields['solution'])) {
if ($job->fields['solutiontypes_id']) {
$title = Html::clean(Dropdown::getDropdownName('glpi_solutiontypes', $job->getField('solutiontypes_id')));
} else {
$title = __('Solution');
}
$sol = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($job->getField('solution'), ENT_QUOTES, "UTF-8")));
$pdf->displayText("<b><i>{$title}</i></b> : ", $sol);
} else {
$pdf->displayLine(__('None'));
}
$pdf->displaySpace();
}
示例15: getDatasForTemplate
/**
* @see NotificationTarget::getDatasForTemplate()
**/
function getDatasForTemplate($event, $options = array())
{
global $CFG_GLPI, $DB;
//----------- Reservation infos -------------- //
$events = $this->getAllEvents();
$item = $this->obj;
$this->datas['##projecttask.action##'] = $events[$event];
$this->datas['##projecttask.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "ProjectTask_" . $item->getField("id"));
$this->datas["##projecttask.name##"] = $item->getField('name');
$this->datas["##projecttask.project##"] = Dropdown::getDropdownName('glpi_projects', $item->getField('projects_id'));
$this->datas["##projecttask.projecturl##"] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("projects_id"));
$this->datas["##projecttask.description##"] = $item->getField('content');
$this->datas["##projecttask.comments##"] = $item->getField('comment');
$this->datas["##projecttask.creationdate##"] = Html::convDateTime($item->getField('date'));
$this->datas["##projecttask.lastupdatedate##"] = Html::convDateTime($item->getField('date_mod'));
$this->datas["##projecttask.percent##"] = Dropdown::getValueWithUnit($item->getField('percent_done'), "%");
$this->datas["##projecttask.planstartdate##"] = Html::convDateTime($item->getField('plan_start_date'));
$this->datas["##projecttask.planenddate##"] = Html::convDateTime($item->getField('plan_end_date'));
$this->datas["##projecttask.realstartdate##"] = Html::convDateTime($item->getField('real_start_date'));
$this->datas["##projecttask.realenddate##"] = Html::convDateTime($item->getField('real_end_date'));
$this->datas["##projecttask.plannedduration##"] = Html::timestampToString($item->getField('planned_duration'), false);
$this->datas["##projecttask.effectiveduration##"] = Html::timestampToString($item->getField('effective_duration'), false);
$ticket_duration = ProjectTask_Ticket::getTicketsTotalActionTime($item->getID());
$this->datas["##projecttask.ticketsduration##"] = Html::timestampToString($ticket_duration, false);
$this->datas["##projecttask.totalduration##"] = Html::timestampToString($ticket_duration + $item->getField('effective_duration'), false);
$entity = new Entity();
$this->datas["##projecttask.entity##"] = '';
$this->datas["##projecttask.shortentity##"] = '';
if ($entity->getFromDB($this->getEntity())) {
$this->datas["##projecttask.entity##"] = $entity->getField('completename');
$this->datas["##projecttask.shortentity##"] = $entity->getField('name');
}
$this->datas["##projecttask.father##"] = '';
if ($item->getField('projecttasks_id')) {
$this->datas["##projecttask.father##"] = Dropdown::getDropdownName('glpi_projecttasks', $item->getField('projecttasks_id'));
}
$this->datas["##projecttask.state##"] = '';
if ($item->getField('projectstates_id')) {
$this->datas["##projecttask.state##"] = Dropdown::getDropdownName('glpi_projectstates', $item->getField('projectstates_id'));
}
$this->datas["##projecttask.type##"] = '';
if ($item->getField('projecttasktypes_id')) {
$this->datas["##projecttask.type##"] = Dropdown::getDropdownName('glpi_projecttasktypes', $item->getField('projecttasktypes_id'));
}
$this->datas["##projecttask.createbyuser##"] = '';
if ($item->getField('users_id')) {
$user_tmp = new User();
$user_tmp->getFromDB($item->getField('users_id'));
$this->datas["##projecttask.createbyuser##"] = $user_tmp->getName();
}
// Team infos
$restrict = "`projecttasks_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_projecttaskteams', $restrict);
$this->datas['teammembers'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##teammember.itemtype##'] = $item2->getTypeName();
$tmp['##teammember.name##'] = $item2->getName();
$this->datas['teammembers'][] = $tmp;
}
}
}
}
$this->datas['##projecttask.numberofteammembers##'] = count($this->datas['teammembers']);
// Task infos
$restrict = "`projecttasks_id`='" . $item->getField('id') . "'";
$restrict .= " ORDER BY `date` DESC, `id` ASC";
$tasks = getAllDatasFromTable('glpi_projecttasks', $restrict);
$this->datas['tasks'] = array();
foreach ($tasks as $task) {
$tmp = array();
$tmp['##task.creationdate##'] = Html::convDateTime($task['date']);
$tmp['##task.lastupdatedate##'] = Html::convDateTime($task['date_mod']);
$tmp['##task.name##'] = $task['name'];
$tmp['##task.description##'] = $task['content'];
$tmp['##task.comments##'] = $task['comment'];
$tmp['##task.state##'] = Dropdown::getDropdownName('glpi_projectstates', $task['projectstates_id']);
$tmp['##task.type##'] = Dropdown::getDropdownName('glpi_projecttasktypes', $task['projecttasktypes_id']);
$tmp['##task.percent##'] = Dropdown::getValueWithUnit($task['percent_done'], "%");
$this->datas["##task.planstartdate##"] = '';
$this->datas["##task.planenddate##"] = '';
$this->datas["##task.realstartdate##"] = '';
$this->datas["##task.realenddate##"] = '';
if (!is_null($task['plan_start_date'])) {
$tmp['##task.planstartdate##'] = Html::convDateTime($task['plan_start_date']);
}
if (!is_null($task['plan_end_date'])) {
$tmp['##task.planenddate##'] = Html::convDateTime($task['plan_end_date']);
}
if (!is_null($task['real_start_date'])) {
$tmp['##task.realstartdate##'] = Html::convDateTime($task['real_start_date']);
}
if (!is_null($task['real_end_date'])) {
$tmp['##task.realenddate##'] = Html::convDateTime($task['real_end_date']);
//.........这里部分代码省略.........