本文整理汇总了PHP中SLA::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP SLA::getFromDB方法的具体用法?PHP SLA::getFromDB怎么用?PHP SLA::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SLA
的用法示例。
在下文中一共展示了SLA::getFromDB方法的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: unset
//.........这里部分代码省略.........
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";
示例3: giveItem
//.........这里部分代码省略.........
$comp = '';
if ($data[$num][$k]['is_recursive']) {
$comp = __('R');
if ($data[$num][$k]['is_dynamic']) {
$comp = sprintf(__('%1$s%2$s'), $comp, ", ");
}
}
if ($data[$num][$k]['is_dynamic']) {
$comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
}
if (!empty($comp)) {
$text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
}
if (!in_array($text, $added)) {
if ($count_display) {
$out .= self::LBBR;
}
$count_display++;
$out .= $text;
$added[] = $text;
}
}
}
return $out;
}
break;
case "glpi_documenttypes.icon":
if (!empty($data[$num][0]['name'])) {
return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$num][0]['name'] . "'>";
}
return " ";
case "glpi_documents.filename":
$doc = new Document();
if ($doc->getFromDB($data['id'])) {
return $doc->getDownloadLink();
}
return NOT_AVAILABLE;
case "glpi_tickets_tickets.tickets_id_1":
$out = "";
$displayed = array();
for ($k = 0; $k < $data[$num]['count']; $k++) {
$linkid = $data[$num][$k]['tickets_id_2'] == $data['id'] ? $data[$num][$k]['name'] : $data[$num][$k]['tickets_id_2'];
if ($linkid > 0 && !isset($displayed[$linkid])) {
$text = "<a ";
$text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">";
$text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>";
if (count($displayed)) {
$out .= self::LBBR;
}
$displayed[$linkid] = $linkid;
$out .= $text;
}
}
return $out;
case "glpi_problems.id":
if ($searchopt[$ID]["datatype"] == 'count') {
if ($data[$num][0]['name'] > 0 && Session::haveRight("problem", Problem::READALL)) {
if ($itemtype == 'ITILCategory') {
$options['criteria'][0]['field'] = 7;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $data['id'];
$options['criteria'][0]['link'] = 'AND';
} else {
$options['criteria'][0]['field'] = 12;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = 'all';
示例4: 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();
}
示例5: sprintf
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;
//.........这里部分代码省略.........
示例6: TicketFollowup
function post_addItem()
{
global $LANG, $CFG_GLPI;
// Add document if needed
$this->addFiles($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"] == "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"]) || isset($this->input["_hour"]) && isset($this->input["_minute"]) && isset($this->input["realtime"]) && $this->input["realtime"] > 0) {
$task = new TicketTask();
$type = "new";
if (isset($this->fields["status"]) && $this->fields["status"] == "solved") {
$type = "solved";
}
$toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
if (isset($this->input["_hour"])) {
$toadd["hour"] = $this->input["_hour"];
}
if (isset($this->input["_minute"])) {
$toadd["minute"] = $this->input["_minute"];
}
if (isset($this->input["plan"])) {
$toadd["plan"] = $this->input["plan"];
}
$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'];
if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) {
$ticket_ticket->add($this->input['_link']);
}
}
// 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) {
$sla = new SLA();
if ($sla->getFromDB($this->input["slas_id"])) {
// Add first level in working table
if ($this->input["slalevels_id"] > 0) {
$sla->addLevelToDo($this);
}
}
}
// Add user groups linked to tickets
$ticket_user = new Ticket_User();
$group_ticket = new Group_Ticket();
if (isset($this->input["_users_id_requester"]) && ($this->input["_users_id_requester"] > 0 || isset($this->input["_users_id_requester_notif"]['alternative_email']) && !empty($this->input["_users_id_requester_notif"]['alternative_email']))) {
$input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_requester"], 'type' => self::REQUESTER);
if (isset($this->input["_users_id_requester_notif"])) {
foreach ($this->input["_users_id_requester_notif"] as $key => $val) {
$input2[$key] = $val;
}
}
$ticket_user->add($input2);
}
if (isset($this->input["_users_id_observer"]) && ($this->input["_users_id_observer"] > 0 || isset($this->input["_users_id_observer_notif"]['alternative_email']) && !empty($this->input["_users_id_observer_notif"]['alternative_email']))) {
$input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_observer"], 'type' => self::OBSERVER);
if (isset($this->input["_users_id_observer_notif"])) {
foreach ($this->input["_users_id_observer_notif"] as $key => $val) {
$input2[$key] = $val;
}
}
$ticket_user->add($input2);
}
if (isset($this->input["_users_id_assign"]) && $this->input["_users_id_assign"] > 0) {
$input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_assign"], 'type' => self::ASSIGN);
if (isset($this->input["_users_id_assign_notif"])) {
foreach ($this->input["_users_id_assign_notif"] as $key => $val) {
$input2[$key] = $val;
}
}
$ticket_user->add($input2);
}
if (isset($this->input["_groups_id_requester"]) && $this->input["_groups_id_requester"] > 0) {
$group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_requester"], 'type' => self::REQUESTER));
}
if (isset($this->input["_groups_id_assign"]) && $this->input["_groups_id_assign"] > 0) {
$group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_assign"], 'type' => self::ASSIGN));
//.........这里部分代码省略.........
示例7: 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']));
}
}
示例8: getFromDB
/**
* @see CommonDBTM::getFromDB
**/
function getFromDB($ID)
{
if (!parent::getFromDB($ID)) {
return false;
}
// get calendar from sla
$sla = new SLA();
if ($sla->getFromDB($this->fields['slas_id'])) {
$this->fields['calendars_id'] = $sla->fields['calendars_id'];
return true;
} else {
return false;
}
}
示例9: 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);
}
示例10: sprintf
function post_addItem()
{
global $CFG_GLPI;
if (isset($this->input['content'])) {
if (isset($this->input['_stock_image'])) {
$this->addImagePaste();
}
}
// 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, CREATE, $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());
}
// Add project task link if needed
if (isset($this->input['_projecttasks_id'])) {
$projecttask = new ProjectTask();
if ($projecttask->getFromDB($this->input['_projecttasks_id'])) {
$pt = new ProjectTask_Ticket();
$pt->add(array('projecttasks_id' => $this->input['_projecttasks_id'], 'tickets_id' => $this->fields['id']));
}
}
if (!empty($this->input['itemtype']) && !empty($this->input['items_id'])) {
$item_ticket = new Item_Ticket();
$item_ticket->add(array('items_id' => $this->input['items_id'], 'itemtype' => $this->input['itemtype'], 'tickets_id' => $this->fields['id'], '_disablenotif' => true));
}
parent::post_addItem();
$this->manageValidationAdd($this->input);
// Processing Email
if ($CFG_GLPI["use_mailing"]) {
// Clean reload of the ticket
$this->getFromDB($this->fields['id']);
$type = "new";
if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
//.........这里部分代码省略.........
示例11: getPeriodTime
static function getPeriodTime(CommonGLPI $ticket, $start, $end)
{
$totaltime = 0;
if ($ticket->fields['slas_id'] != 0) {
// Have SLA
$sla = new SLA();
$sla->getFromDB($ticket->fields['slas_id']);
$totaltime = $sla->getActiveTimeBetween($start, $end);
} 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);
$totaltime = $calendar->getActiveTimeBetween($start, $end);
} else {
// No calendar
$totaltime = strtotime($end) - strtotime($start);
}
}
return $totaltime;
}
示例12: showForm
/**
* Show the rule
*
* @param $ID ID of the rule
* @param $options options
*
* @return nothing
**/
function showForm($ID, $options = array())
{
global $CFG_GLPI, $LANG;
if (!$this->isNewID($ID)) {
$this->check($ID, 'r');
} else {
// Create item
$this->check(-1, 'w');
}
$canedit = $this->can($this->right, "w");
$this->showTabs($options);
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['common'][16] . " :</td>";
echo "<td>";
autocompletionTextField($this, "name");
echo "</td>";
echo "<td>" . $LANG['common'][60] . " :</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>" . $LANG['sla'][1] . " :</td>";
echo "<td>";
echo $sla->getLink();
echo "</td>";
echo "<td>" . $LANG['sla'][3] . "</td>";
echo "<td>";
self::dropdownExecutionTime('execution_time', array('max_time' => $sla->fields['resolution_time'], 'used' => self::getAlreadyUsedExecutionTime($sla->fields['id']), 'value' => $this->fields['execution_time']));
echo "</td></tr>\n";
$this->showFormButtons($options);
$this->addDivForTabs();
}
示例13: SLA
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
if (!isset($_POST["id"])) {
exit;
}
if (empty($_POST["id"])) {
$_POST["id"] = -1;
}
$sla = new SLA();
$slalevel = new SlaLevel();
if ($_POST['id'] > 0 && $sla->getFromDB($_POST['id'])) {
switch ($_REQUEST['glpi_tab']) {
case -1:
$slalevel->showForSLA($sla);
$rule = new RuleTicket();
$rule->showAndAddRuleForm($sla);
Ticket::showListForItem('Sla', $_POST["id"]);
Plugin::displayAction($sla, $_REQUEST['glpi_tab']);
break;
case 4:
$rule = new RuleTicket();
$rule->showAndAddRuleForm($sla);
break;
case 6:
Ticket::showListForItem('Sla', $_POST["id"]);
break;
示例14: giveItem
//.........这里部分代码省略.........
$comp = '';
if ($split3[$k]) {
$comp = __(READ);
if ($split4[$k]) {
$comp = sprintf(__('%1$s%2$s'), $comp, ", ");
}
}
if ($split4[$k]) {
$comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
}
if (!empty($comp)) {
$text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
}
if (!in_array($text, $added)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $text;
$added[] = $text;
}
}
}
return $out;
}
break;
case "glpi_documenttypes.icon":
if (!empty($data[$NAME . $num])) {
return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
}
return " ";
case "glpi_documents.filename":
$doc = new Document();
if ($doc->getFromDB($data['id'])) {
return $doc->getDownloadLink();
}
return NOT_AVAILABLE;
case "glpi_deviceharddrives.specificity":
case "glpi_devicememories.specificity":
case "glpi_deviceprocessors.specificity":
return $data[$NAME . $num];
case "glpi_networkports.mac":
$out = "";
if ($itemtype == 'Computer') {
$displayed = array();
if (!empty($data[$NAME . $num . "_2"])) {
$split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
$count_display = 0;
for ($k = 0; $k < count($split); $k++) {
$lowstr = Toolbox::strtolower($split[$k]);
if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
if ($count_display) {
$out .= "<br>";
}
$count_display++;
$out .= $split[$k];
$displayed[] = $lowstr;
}
}
if (!empty($data[$NAME . $num])) {
$out .= "<br>";
}
}
if (!empty($data[$NAME . $num])) {
$split = explode("\$\$\$\$", $data[$NAME . $num]);
$count_display = 0;
示例15: cronSlaTicket
/**
* Cron for ticket's automatic close
* @param $task : crontask object
*
* @return integer (0 : nothing done - 1 : done)
*
*/
static function cronSlaTicket($task)
{
global $DB;
$tot = 0;
$query = "SELECT *\n FROM `glpi_slalevels_tickets`\n WHERE `glpi_slalevels_tickets`.`date` < NOW()";
$slalevelticket = new self();
foreach ($DB->request($query) as $data) {
$tot++;
$ticket = new Ticket();
if ($ticket->getFromDB($data['tickets_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'] == 'closed') {
// Drop line when status is closed
$slalevelticket->delete(array('id' => $data['id']));
} else {
if ($ticket->fields['status'] != 'solved') {
// If status = solved : keep the line in case of solution not validated
$input = $ticket->fields;
$input['_auto_update'] = true;
if ($slalevel->getRuleWithCriteriasAndActions($data['slalevels_id'], 0, 1) && $sla->getFromDB($ticket->fields['slas_id'])) {
// Process rules
$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);
}
}
}
} else {
// Drop line
$slalevelticket->delete(array('id' => $data['id']));
}
}
$task->setVolume($tot);
return $tot > 0;
}