本文整理汇总了PHP中SLA类的典型用法代码示例。如果您正苦于以下问题:PHP SLA类的具体用法?PHP SLA怎么用?PHP SLA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SLA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doLevelForTicket
/**
* Do a specific SLAlevel for a ticket
*
* @param $data array data of an entry of slalevels_tickets
*
* @return nothing
**/
static function doLevelForTicket(array $data)
{
$ticket = new Ticket();
$slalevelticket = new self();
// existing ticket and not deleted
if ($ticket->getFromDB($data['tickets_id']) && !$ticket->isDeleted()) {
$slalevel = new SlaLevel();
$sla = new SLA();
// Check if sla datas are OK
if ($ticket->fields['slas_id'] > 0 && $ticket->fields['slalevels_id'] == $data['slalevels_id']) {
if ($ticket->fields['status'] == CommonITILObject::CLOSED) {
// Drop line when status is closed
$slalevelticket->delete(array('id' => $data['id']));
} else {
if ($ticket->fields['status'] != CommonITILObject::SOLVED) {
// If status = solved : keep the line in case of solution not validated
$input['id'] = $ticket->getID();
$input['_auto_update'] = true;
if ($slalevel->getRuleWithCriteriasAndActions($data['slalevels_id'], 1, 1) && $sla->getFromDB($ticket->fields['slas_id'])) {
$doit = true;
if (count($slalevel->criterias)) {
$doit = $slalevel->checkCriterias($ticket->fields);
}
// Process rules
if ($doit) {
$input = $slalevel->executeActions($input, array());
}
}
// Put next level in todo list
$next = $slalevel->getNextSlaLevel($ticket->fields['slas_id'], $ticket->fields['slalevels_id']);
$input['slalevels_id'] = $next;
$ticket->update($input);
$sla->addLevelToDo($ticket);
// Action done : drop the line
$slalevelticket->delete(array('id' => $data['id']));
}
}
} else {
// Drop line
$slalevelticket->delete(array('id' => $data['id']));
}
} else {
// Drop line
$slalevelticket->delete(array('id' => $data['id']));
}
}
示例2: showForm
/**
* Show the rule
*
* @param $ID ID of the rule
* @param $options array of possible options
*
* @return nothing
**/
function showForm($ID, $options = array())
{
$canedit = $this->can('sla', UPDATE);
$this->initForm($ID, $options);
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Name') . "</td>";
echo "<td>";
Html::autocompletionTextField($this, "name");
echo "</td>";
echo "<td>" . __('Active') . "</td>";
echo "<td>";
Dropdown::showYesNo("is_active", $this->fields["is_active"]);
echo "</td></tr>\n";
$sla = new SLA();
$sla->getFromDB($this->fields['slas_id']);
echo "<tr class='tab_bg_1'>";
echo "<td>" . SLA::getTypeName(1) . "</td>";
echo "<td>" . $sla->getLink() . "</td>";
echo "<td>" . __('Execution') . "</td>";
echo "<td>";
$resolution_time = $sla->getResolutionTime();
self::dropdownExecutionTime('execution_time', array('max_time' => $resolution_time, 'used' => self::getAlreadyUsedExecutionTime($sla->fields['id']), 'value' => $this->fields['execution_time']));
echo "</td></tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Logical operator') . "</td>";
echo "<td>";
$this->dropdownRulesMatch(array('value' => $this->fields["match"]));
echo "</td>";
echo "<td colspan='2'> </td></tr>";
$this->showFormButtons($options);
}
示例3: Copyright
Copyright (C) 2003-2014 by the INDEPNET Development Team.
http://indepnet.net/ http://glpi-project.org
-------------------------------------------------------------------------
LICENSE
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkRight("sla", "r");
Html::header(SLA::getTypeName(2), $_SERVER['PHP_SELF'], "config", "sla");
Search::show('SLA');
Html::footer();
示例4: getDefaultSLA
function getDefaultSLA()
{
if (!$this->defaultSLA && $this->getDefaultSLAId()) {
$this->defaultSLA = SLA::lookup($this->getDefaultSLAId());
}
return $this->defaultSLA;
}
示例5: pre_updateInDB
//.........这里部分代码省略.........
unset($this->updates[$key]);
unset($this->oldvalues['closedate']);
}
}
}
if (($key = array_search('status', $this->updates)) !== false && $this->oldvalues['status'] == $this->fields['status']) {
unset($this->updates[$key]);
unset($this->oldvalues['status']);
}
// Status solved : check dates
if (in_array($this->fields["status"], $this->getSolvedStatusArray()) && (in_array("date", $this->updates) || in_array("solvedate", $this->updates))) {
// Invalid dates : no change
// solvedate must be > create date
if ($this->fields["solvedate"] < $this->fields["date"]) {
Session::addMessageAfterRedirect(__('Invalid dates. Update cancelled.'), false, ERROR);
if (($key = array_search('date', $this->updates)) !== false) {
unset($this->updates[$key]);
unset($this->oldvalues['date']);
}
if (($key = array_search('solvedate', $this->updates)) !== false) {
unset($this->updates[$key]);
unset($this->oldvalues['solvedate']);
}
}
}
// Manage come back to waiting state
if (!is_null($this->fields['begin_waiting_date']) && ($key = array_search('status', $this->updates)) !== false && ($this->oldvalues['status'] == self::WAITING || in_array($this->oldvalues["status"], $this->getSolvedStatusArray()) && !in_array($this->fields["status"], $this->getClosedStatusArray()))) {
// Compute ticket waiting time use calendar if exists
$calendars_id = Entity::getUsedConfig('calendars_id', $this->fields['entities_id']);
$calendar = new Calendar();
$delay_time = 0;
// Compute ticket waiting time use calendar if exists
// Using calendar
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
$delay_time = $calendar->getActiveTimeBetween($this->fields['begin_waiting_date'], $_SESSION["glpi_currenttime"]);
} else {
// Not calendar defined
$delay_time = strtotime($_SESSION["glpi_currenttime"]) - strtotime($this->fields['begin_waiting_date']);
}
// SLA case : compute sla duration
if (isset($this->fields['slas_id']) && $this->fields['slas_id'] > 0) {
$sla = new SLA();
if ($sla->getFromDB($this->fields['slas_id'])) {
$sla->setTicketCalendar($calendars_id);
$delay_time_sla = $sla->getActiveTimeBetween($this->fields['begin_waiting_date'], $_SESSION["glpi_currenttime"]);
$this->updates[] = "sla_waiting_duration";
$this->fields["sla_waiting_duration"] += $delay_time_sla;
}
// Compute new due date
$this->updates[] = "due_date";
$this->fields['due_date'] = $sla->computeDueDate($this->fields['date'], $this->fields["sla_waiting_duration"]);
// Add current level to do
$sla->addLevelToDo($this);
} else {
// Using calendar
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
if ($this->fields['due_date'] > 0) {
// compute new due date using calendar
$this->updates[] = "due_date";
$this->fields['due_date'] = $calendar->computeEndDate($this->fields['due_date'], $delay_time);
}
} else {
// Not calendar defined
if ($this->fields['due_date'] > 0) {
// compute new due date : no calendar so add computed delay_time
$this->updates[] = "due_date";
$this->fields['due_date'] = date('Y-m-d H:i:s', $delay_time + strtotime($this->fields['due_date']));
}
}
}
$this->updates[] = "waiting_duration";
$this->fields["waiting_duration"] += $delay_time;
// Reset begin_waiting_date
$this->updates[] = "begin_waiting_date";
$this->fields["begin_waiting_date"] = 'NULL';
}
// Set begin waiting date if needed
if (($key = array_search('status', $this->updates)) !== false && ($this->fields['status'] == self::WAITING || in_array($this->fields["status"], $this->getSolvedStatusArray()))) {
$this->updates[] = "begin_waiting_date";
$this->fields["begin_waiting_date"] = $_SESSION["glpi_currenttime"];
// Specific for tickets
if (isset($this->fields['slas_id']) && $this->fields['slas_id'] > 0) {
SLA::deleteLevelsToDo($this);
}
}
// solve_delay_stat : use delay between opendate and solvedate
if (in_array("solvedate", $this->updates)) {
$this->updates[] = "solve_delay_stat";
$this->fields['solve_delay_stat'] = $this->computeSolveDelayStat();
}
// close_delay_stat : use delay between opendate and closedate
if (in_array("closedate", $this->updates)) {
$this->updates[] = "close_delay_stat";
$this->fields['close_delay_stat'] = $this->computeCloseDelayStat();
}
// Do not take into account date_mod if no update is done
if (count($this->updates) == 1 && ($key = array_search('date_mod', $this->updates)) !== false) {
unset($this->updates[$key]);
}
}
示例6: getCalendar
/**
* Get correct Calendar: Entity or Sla
*
* @since 0.90.4
*
**/
function getCalendar()
{
if (isset($this->fields['slts_ttr_id']) && $this->fields['slts_ttr_id'] > 0) {
$sla = new SLA();
if ($sla->getFromDB($this->fields['slts_ttr_id'])) {
// not -1: calendar of the entity
if ($sla->getField('calendars_id') >= 0) {
return $sla->getField('calendars_id');
}
}
}
return parent::getCalendar();
}
示例7: post_addItem
function post_addItem()
{
global $CFG_GLPI;
// Log this event
$username = 'anonymous';
if (isset($_SESSION["glpiname"])) {
$username = $_SESSION["glpiname"];
}
Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s adds the item %2$s'), $username, $this->fields['id']));
if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) {
$fup = new TicketFollowup();
$type = "new";
if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
$type = "solved";
}
$toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) {
$toadd["content"] = $this->input["_followup"]['content'];
}
if (isset($this->input["_followup"]['is_private'])) {
$toadd["is_private"] = $this->input["_followup"]['is_private'];
}
$toadd['_no_notif'] = true;
$fup->add($toadd);
}
if (isset($this->input["plan"]) && count($this->input["plan"]) || isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
$task = new TicketTask();
$type = "new";
if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
$type = "solved";
}
$toadd = array("type" => $type, "tickets_id" => $this->fields['id'], "actiontime" => $this->input["actiontime"]);
if (isset($this->input["plan"]) && count($this->input["plan"])) {
$toadd["plan"] = $this->input["plan"];
}
if (isset($_SESSION['glpitask_private'])) {
$toadd['is_private'] = $_SESSION['glpitask_private'];
}
$toadd['_no_notif'] = true;
$task->add($toadd);
}
$ticket_ticket = new Ticket_Ticket();
// From interface
if (isset($this->input['_link'])) {
$this->input['_link']['tickets_id_1'] = $this->fields['id'];
// message if ticket's ID doesn't exist
if (!empty($this->input['_link']['tickets_id_2'])) {
if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) {
$ticket_ticket->add($this->input['_link']);
} else {
Session::addMessageAfterRedirect(__('Unknown ticket'), false, ERROR);
}
}
}
// From mailcollector : do not check rights
if (isset($this->input["_linkedto"])) {
$input2['tickets_id_1'] = $this->fields['id'];
$input2['tickets_id_2'] = $this->input["_linkedto"];
$input2['link'] = Ticket_Ticket::LINK_TO;
$ticket_ticket->add($input2);
}
// Manage SLA Level : add actions
if (isset($this->input["slas_id"]) && $this->input["slas_id"] > 0 && isset($this->input["slalevels_id"]) && $this->input["slalevels_id"] > 0) {
$calendars_id = Entity::getUsedConfig('calendars_id', $this->fields['entities_id']);
$sla = new SLA();
if ($sla->getFromDB($this->input["slas_id"])) {
$sla->setTicketCalendar($calendars_id);
// Add first level in working table
if ($this->input["slalevels_id"] > 0) {
$sla->addLevelToDo($this);
}
// Replay action in case of open date is set before now
}
SlaLevel_Ticket::replayForTicket($this->getID());
}
parent::post_addItem();
//Action for send_validation rule
if (isset($this->input["_add_validation"])) {
$validations_to_send = array();
if (!is_array($this->input["_add_validation"])) {
$this->input["_add_validation"] = array($this->input["_add_validation"]);
}
foreach ($this->input["_add_validation"] as $validation) {
switch ($validation) {
case 'requester_supervisor':
if (isset($this->input['_groups_id_requester']) && $this->input['_groups_id_requester']) {
$users = Group_User::getGroupUsers($this->input['_groups_id_requester'], "is_manager='1'");
foreach ($users as $data) {
$validations_to_send[] = $data['id'];
}
}
break;
case 'assign_supervisor':
if (isset($this->input['_groups_id_assign']) && $this->input['_groups_id_assign']) {
$users = Group_User::getGroupUsers($this->input['_groups_id_assign'], "is_manager='1'");
foreach ($users as $data) {
$validations_to_send[] = $data['id'];
}
}
break;
//.........这里部分代码省略.........
示例8: doLevelForTicket
/**
* Do a specific SLAlevel for a ticket
*
* @param $data array data of an entry of slalevels_tickets
*
* @return nothing
**/
static function doLevelForTicket(array $data)
{
$ticket = new Ticket();
$slalevelticket = new self();
// existing ticket and not deleted
if ($ticket->getFromDB($data['tickets_id']) && !$ticket->isDeleted()) {
// search all actors of a ticket
foreach ($ticket->getUsers(CommonITILActor::REQUESTER) as $user) {
$ticket->fields['_users_id_requester'][] = $user['users_id'];
}
foreach ($ticket->getUsers(CommonITILActor::ASSIGN) as $user) {
$ticket->fields['_users_id_assign'][] = $user['users_id'];
}
foreach ($ticket->getUsers(CommonITILActor::OBSERVER) as $user) {
$ticket->fields['_users_id_observer'][] = $user['users_id'];
}
foreach ($ticket->getGroups(CommonITILActor::REQUESTER) as $group) {
$ticket->fields['_groups_id_requester'][] = $group['groups_id'];
}
foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $group) {
$ticket->fields['_groups_id_assign'][] = $group['groups_id'];
}
foreach ($ticket->getGroups(CommonITILActor::OBSERVER) as $groups) {
$ticket->fields['_groups_id_observer'][] = $group['groups_id'];
}
foreach ($ticket->getSuppliers(CommonITILActor::ASSIGN) as $supplier) {
$ticket->fields['_suppliers_id_assign'][] = $supplier['suppliers_id'];
}
$slalevel = new SlaLevel();
$sla = new SLA();
// Check if sla datas are OK
if ($ticket->fields['slas_id'] > 0 && $ticket->fields['slalevels_id'] == $data['slalevels_id']) {
if ($ticket->fields['status'] == CommonITILObject::CLOSED) {
// Drop line when status is closed
$slalevelticket->delete(array('id' => $data['id']));
} else {
if ($ticket->fields['status'] != CommonITILObject::SOLVED) {
// If status = solved : keep the line in case of solution not validated
$input['id'] = $ticket->getID();
$input['_auto_update'] = true;
if ($slalevel->getRuleWithCriteriasAndActions($data['slalevels_id'], 1, 1) && $sla->getFromDB($ticket->fields['slas_id'])) {
$doit = true;
if (count($slalevel->criterias)) {
$doit = $slalevel->checkCriterias($ticket->fields);
}
// Process rules
if ($doit) {
$input = $slalevel->executeActions($input, array());
}
}
// Put next level in todo list
$next = $slalevel->getNextSlaLevel($ticket->fields['slas_id'], $ticket->fields['slalevels_id']);
$input['slalevels_id'] = $next;
$ticket->update($input);
$sla->addLevelToDo($ticket);
// Action done : drop the line
$slalevelticket->delete(array('id' => $data['id']));
}
}
} else {
// Drop line
$slalevelticket->delete(array('id' => $data['id']));
}
} else {
// Drop line
$slalevelticket->delete(array('id' => $data['id']));
}
}
示例9: sprintf
if(db_query($sql) && ($num=db_affected_rows())) {
if($num==$count)
$msg = sprintf(__('Successfully disabled %s'),
_N('selected SLA plan', 'selected SLA plans', $count));
else
$warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count,
_N('selected SLA plan', 'selected SLA plans', $count));
} else {
$errors['err'] = sprintf(__('Unable to disable %s'),
_N('selected SLA plan', 'selected SLA plans', $count));
}
break;
case 'delete':
$i=0;
foreach($_POST['ids'] as $k=>$v) {
if (($p=SLA::lookup($v))
&& $p->getId() != $cfg->getDefaultSLAId()
&& $p->delete())
$i++;
}
if($i && $i==$count)
$msg = sprintf(__('Successfully deleted %s'),
_N('selected SLA plan', 'selected SLA plans', $count));
elseif($i>0)
$warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count,
_N('selected SLA plan', 'selected SLA plans', $count));
elseif(!$errors['err'])
$errors['err'] = sprintf(__('Unable to delete %s'),
_N('selected SLA plan', 'selected SLA plans', $count));
break;
示例10: IN
case 'disable':
$sql = 'UPDATE ' . SLA_TABLE . ' SET isactive=0 ' . ' WHERE id IN (' . implode(',', db_input($_POST['ids'])) . ')';
if (db_query($sql) && ($num = db_affected_rows())) {
if ($num == $count) {
$msg = sprintf(__('Successfully disabled %s'), _N('selected SLA plan', 'selected SLA plans', $count));
} else {
$warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, _N('selected SLA plan', 'selected SLA plans', $count));
}
} else {
$errors['err'] = sprintf(__('Unable to disable %s'), _N('selected SLA plan', 'selected SLA plans', $count));
}
break;
case 'delete':
$i = 0;
foreach ($_POST['ids'] as $k => $v) {
if (($p = SLA::lookup($v)) && $p->getId() != $cfg->getDefaultSLAId() && $p->delete()) {
$i++;
}
}
if ($i && $i == $count) {
$msg = sprintf(__('Successfully deleted %s'), _N('selected SLA plan', 'selected SLA plans', $count));
} elseif ($i > 0) {
$warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, _N('selected SLA plan', 'selected SLA plans', $count));
} elseif (!$errors['err']) {
$errors['err'] = sprintf(__('Unable to delete %s'), _N('selected SLA plan', 'selected SLA plans', $count));
}
break;
default:
$errors['err'] = __('Unknown action - get technical help.');
}
}
示例11: save
function save($id, $vars, &$errors)
{
if (!$vars['grace_period']) {
$errors['grace_period'] = 'Grace period required';
} elseif (!is_numeric($vars['grace_period'])) {
$errors['grace_period'] = 'Numeric value required (in hours)';
}
if (!$vars['name']) {
$errors['name'] = 'Name required';
} elseif (($sid = SLA::getIdByName($vars['name'])) && $sid != $id) {
$errors['name'] = 'Name already exists';
}
if ($errors) {
return false;
}
$sql = ' updated=NOW() ' . ',isactive=' . db_input($vars['isactive']) . ',name=' . db_input($vars['name']) . ',grace_period=' . db_input($vars['grace_period']) . ',disable_overdue_alerts=' . db_input(isset($vars['disable_overdue_alerts']) ? 1 : 0) . ',enable_priority_escalation=' . db_input(isset($vars['enable_priority_escalation']) ? 1 : 0) . ',notes=' . db_input($vars['notes']);
if ($id) {
$sql = 'UPDATE ' . SLA_TABLE . ' SET ' . $sql . ' WHERE id=' . db_input($id);
if (db_query($sql)) {
return true;
}
$errors['err'] = 'Unable to update SLA. Internal error occurred';
} else {
$sql = 'INSERT INTO ' . SLA_TABLE . ' SET ' . $sql . ',created=NOW() ';
if (db_query($sql) && ($id = db_insert_id())) {
return $id;
}
$errors['err'] = 'Unable to add SLA. Internal error';
}
return false;
}
示例12: getMenuContent
/**
* @see CommonGLPI::getMenuContent()
*
* @since version 0.85
**/
static function getMenuContent()
{
$menu = array();
if (Config::canUpdate()) {
$menu['title'] = SLA::getTypeName(Session::getPluralNumber());
$menu['page'] = '/front/sla.php';
$menu['links']['search'] = '/front/sla.php';
$menu['links']['add'] = '/front/sla.form.php';
$menu['options']['slt']['title'] = SLT::getTypeName(Session::getPluralNumber());
$menu['options']['slt']['page'] = '/front/slt.php';
$menu['options']['slt']['links']['search'] = '/front/slt.php';
$menu['options']['slalevel']['title'] = SlaLevel::getTypeName(Session::getPluralNumber());
$menu['options']['slalevel']['page'] = '/front/slalevel.php';
$menu['options']['slalevel']['links']['search'] = '/front/slalevel.php';
}
if (count($menu)) {
return $menu;
}
return false;
}
示例13: elseif
}
} elseif ($_POST['disable']) {
$sql = 'UPDATE ' . SLA_TABLE . ' SET isactive=0 WHERE id IN (' . implode(',', db_input($_POST['ids'])) . ')';
if (db_query($sql) && ($num = db_affected_rows())) {
if ($num == $count) {
$msg = 'Selected SLA plans disabled';
} else {
$warn = "{$num} of {$count} selected SLA plans disabled";
}
} else {
$errors['err'] = 'Unable to disable selected SLA plans';
}
} elseif ($_POST['delete']) {
$i = 0;
foreach ($_POST['ids'] as $k => $v) {
if (($p = SLA::lookup($v)) && $p->delete()) {
$i++;
}
}
if ($i && $i == $count) {
$msg = 'Selected SLA plans deleted successfully';
} elseif ($i > 0) {
$warn = "{$i} of {$count} selected SLA plans deleted";
} elseif (!$errors['err']) {
$errors['err'] = 'Unable to delete selected SLA plans';
}
} else {
$errors['err'] = 'Unknown action';
}
}
break;
示例14: showForSla
/**
* Print the HTML array for SLTs linked to a SLA
*
* @param SLA $sla
* @return boolean
*/
static function showForSla(SLA $sla)
{
global $CFG_GLPI;
$instID = $sla->fields['id'];
$slt = new self();
$calendar = new Calendar();
if (!$sla->can($instID, READ)) {
return false;
}
$canedit = $sla->canEdit($instID) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central";
$rand = mt_rand();
if ($canedit) {
echo "<div id='viewslt{$instID}{$rand}'></div>\n";
echo "<script type='text/javascript' >";
echo "function viewAddSlt{$instID}{$rand}() {";
$params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => -1);
Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "}";
echo "</script>";
echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddSlt{$instID}{$rand}();'>";
echo __('Add a new SLT') . "</a></div>\n";
}
// SLT list
$sltList = $slt->find("`slas_id` = '" . $instID . "'");
Session::initNavigateListItems('SLT', sprintf(__('%1$s = %2$s'), $sla::getTypeName(1), $sla->getName()));
echo "<div class='spaced'>";
if (count($sltList)) {
if ($canedit) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . __('Maximum time') . "</th>";
$header_end .= "<th>" . __('Calendar') . "</th>";
echo $header_begin . $header_top . $header_end;
foreach ($sltList as $val) {
$edit = $canedit ? "style='cursor:pointer' onClick=\"viewEditSlt" . $instID . $val["id"] . "{$rand}();\"" : '';
echo "\n<script type='text/javascript' >\n";
echo "function viewEditSlt" . $instID . $val["id"] . "{$rand}() {\n";
$params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => $val["id"]);
Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
echo "<tr class='tab_bg_1'>";
echo "<td width='10' {$edit}>";
if ($canedit) {
Html::showMassiveActionCheckBox($slt->getType(), $val['id']);
}
echo "</td>";
$slt->getFromDB($val['id']);
echo "<td {$edit}>" . $slt->getLink() . "</td>";
echo "<td {$edit}>" . $slt->getSpecificValueToDisplay('type', $slt->fields['type']) . "</td>";
echo "<td {$edit}>";
echo $slt->getSpecificValueToDisplay('number_time', array('number_time' => $slt->fields['number_time'], 'definition_time' => $slt->fields['definition_time']));
echo "</td>";
if (!$sla->fields['calendars_id']) {
$link = __('24/7');
} else {
if ($sla->fields['calendars_id'] == -1) {
$link = __('Calendar of the ticket');
} else {
if ($calendar->getFromDB($sla->fields['calendars_id'])) {
$link = $calendar->getLink();
}
}
}
echo "<td {$edit}>" . $link . "</td>";
echo "</tr>";
}
echo $header_begin . $header_bottom . $header_end;
echo "</table>";
if ($canedit) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
} else {
echo __('No item to display');
}
echo "</div>";
}
示例15: giveItem
//.........这里部分代码省略.........
$options['contains2'][0] = $data['id'];
$options['link2'][0] = 'AND';
}
}
$options['reset'] = 'reset';
$out = "<a id='ticket{$itemtype}" . $data['id'] . "' ";
$out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&') . "\">";
$out .= $data[$NAME . $num] . "</a>";
} else {
$out = $data[$NAME . $num];
}
return $out;
case "glpi_tickets.due_date":
// Due date + progress
if ($ID == 151) {
$out = Html::convDate($data[$NAME . $num]);
// No due date in waiting status
if ($data[$NAME . $num . '_2'] == CommonITILObject::WAITING) {
return '';
}
if (empty($data[$NAME . $num])) {
return '';
}
if ($data[$NAME . $num . '_2'] == Ticket::SOLVED || $data[$NAME . $num . '_2'] == Ticket::CLOSED) {
return $data[$NAME . $num];
}
$ticket = new Ticket();
$ticket->getFromDB($data['ITEM_0']);
$percentage = 0;
$totaltime = 0;
$currenttime = 0;
if ($ticket->fields['slas_id'] != 0) {
// Have SLA
$sla = new SLA();
$sla->getFromDB($ticket->fields['slas_id']);
$currenttime = $sla->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
$totaltime = $sla->getActiveTimeBetween($ticket->fields['date'], $data[$NAME . $num]);
} else {
$calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
if ($calendars_id != 0) {
// Ticket entity have calendar
$calendar = new Calendar();
$calendar->getFromDB($calendars_id);
$currenttime = $calendar->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
$totaltime = $calendar->getActiveTimeBetween($ticket->fields['date'], $data[$NAME . $num]);
} else {
// No calendar
$currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($ticket->fields['date']);
$totaltime = strtotime($data[$NAME . $num]) - strtotime($ticket->fields['date']);
}
}
if ($totaltime != 0) {
$percentage = round(100 * $currenttime / $totaltime);
} else {
// Total time is null : no active time
$percentage = 100;
}
if ($percentage > 100) {
$percentage = 100;
}
$percentage_text = $percentage;
if ($_SESSION['glpiduedatewarning_unit'] == '%') {
$less_warn_limit = $_SESSION['glpiduedatewarning_less'];
$less_warn = 100 - $percentage;
} else {
if ($_SESSION['glpiduedatewarning_unit'] == 'hours') {