本文整理汇总了PHP中Ticket::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::getID方法的具体用法?PHP Ticket::getID怎么用?PHP Ticket::getID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::getID方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: geTimelineItems
static function geTimelineItems(Ticket $ticket, $rand)
{
global $DB, $CFG_GLPI;
$timeline = array();
$user = new User();
$group = new Group();
$followup_obj = new TicketFollowup();
$task_obj = new TicketTask();
$document_item_obj = new Document_Item();
$ticket_valitation_obj = new TicketValidation();
//checks rights
$showpublic = Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE)) && Session::haveRightsOr("task", array(TicketTask::SEEPUBLIC, TicketTask::SEEPRIVATE));
$restrict_fup = $restrict_task = "";
if (!Session::haveRight("ticket", TicketFollowup::SEEPRIVATE)) {
$restrict_fup = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!Session::haveRight("ticket", TicketTask::SEEPRIVATE)) {
$restrict_task = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!$showpublic) {
$restrict = " AND 1 = 0";
}
//add ticket followups to timeline
$followups = $followup_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_fup}", 'date DESC');
foreach ($followups as $followups_id => $followup) {
$followup_obj->getFromDB($followups_id);
$can_edit = $followup_obj->canUpdateItem();
$followup['can_edit'] = $can_edit;
$timeline[$followup['date'] . "_followup_" . $followups_id] = array('type' => 'TicketFollowup', 'item' => $followup);
}
//add ticket tasks to timeline
$tasks = $task_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_task}", 'date DESC');
foreach ($tasks as $tasks_id => $task) {
$task_obj->getFromDB($tasks_id);
$can_edit = $task_obj->canUpdateItem();
$task['can_edit'] = $can_edit;
$timeline[$task['date'] . "_task_" . $tasks_id] = array('type' => 'TicketTask', 'item' => $task);
}
//add ticket documents to timeline
$document_obj = new Document();
$document_items = $document_item_obj->find("itemtype = 'Ticket' AND items_id = " . $ticket->getID());
foreach ($document_items as $document_item) {
$document_obj->getFromDB($document_item['documents_id']);
$timeline[$document_obj->fields['date_mod'] . "_document_" . $document_item['documents_id']] = array('type' => 'Document_Item', 'item' => $document_obj->fields);
}
//add assign changes
/*$log_obj = new Log;
$gassign_items = $log_obj->find("itemtype = 'Ticket' AND items_id = ".$ticket->getID()."
AND itemtype_link = 'Group' AND linked_action = '15'");
foreach ($gassign_items as $logs_id => $gassign) {
//find group
$group_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['new_value']);
$groups = $group->find("name = '$group_name'");
$first_group = array_shift($groups);
$group->getFromDB($first_group['id']);
$content = __("Assigned to")." : ".
"<img src='".$CFG_GLPI['root_doc']."/plugins/talk/pics/group.png' class='group_assign' />".
" <strong>".$group->getLink()."</strong>";
//find user
$user_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['user_name']);
$users = $user->find("CONCAT(firstname, ' ', realname) = '$user_name'");
$first_user = array_shift($users);
if ($first_user == NULL) {
$first_user['id'] = false;
}
$timeline[$gassign['date_mod']."_assign_".$logs_id] = array('type' => 'Assign',
'item' => array(
'date' => $gassign['date_mod'],
'content' => $content,
'can_edit' => false,
'users_id' => $first_user['id']
));
}*/
//add existing solution
if (!empty($ticket->fields['solution'])) {
$users_id = 0;
$solution_date = $ticket->fields['solvedate'];
//search date and user of last solution in glpi_logs
if ($res_solution = $DB->query("SELECT date_mod AS solution_date, user_name FROM glpi_logs\n WHERE itemtype = 'Ticket' \n AND items_id = " . $ticket->getID() . "\n AND id_search_option = 24\n ORDER BY id DESC\n LIMIT 1")) {
$data_solution = $DB->fetch_assoc($res_solution);
if (!empty($data_solution['solution_date'])) {
$solution_date = $data_solution['solution_date'];
}
// find user
if (!empty($data_solution['user_name'])) {
$users_id = addslashes(trim(preg_replace("/.*\\(([0-9]+)\\)/", "\$1", $data_solution['user_name'])));
}
}
// fix trouble with html_entity_decode who skip accented characters (on windows browser)
$solution_content = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $ticket->fields['solution']);
$timeline[$solution_date . "_solution"] = array('type' => 'Solution', 'item' => array('id' => 0, 'content' => Html::clean(html_entity_decode($solution_content)), 'date' => $solution_date, 'users_id' => $users_id, 'solutiontypes_id' => $ticket->fields['solutiontypes_id'], 'can_edit' => Ticket::canUpdate() && $ticket->canSolve()));
}
// add ticket validation to timeline
if ($ticket->fields['type'] == Ticket::DEMAND_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST) || Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) || $ticket->fields['type'] == Ticket::INCIDENT_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT))) {
$ticket_validations = $ticket_valitation_obj->find('tickets_id = ' . $ticket->getID());
//.........这里部分代码省略.........
示例3: pdfForTicket
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
{
$survey = new TicketSatisfaction();
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Satisfaction survey') . "</b>");
if (!$survey->getFromDB($ticket->getID())) {
$pdf->displayLine(__('No generated survey'));
} else {
if ($survey->getField('type') == 2) {
$url = Entity::generateLinkSatisfaction($ticket);
$pdf->displayLine(sprintf(__('%1$s (%2$s)'), __('External survey'), $url));
} else {
if ($survey->getField('date_answered')) {
$sat = $survey->getField('satisfaction');
$tabsat = array(0 => __('None'), 1 => __('1 star', 'pdf'), 2 => __('2 stars', 'pdf'), 3 => __('3 stars', 'pdf'), 4 => __('4 stars', 'pdf'), 5 => __('5 stars', 'pdf'));
if (isset($tabsat[$sat])) {
$sat = $tabsat[$sat] . " ({$sat}/5)";
}
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Response date to the satisfaction survey') . '</b>', Html::convDateTime($survey->getField('date_answered'))));
$pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Satisfaction with the resolution of the ticket') . '</b>', $sat));
$pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</b>', $survey->getField('comment')));
} else {
// No answer
$pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Creation date of the satisfaction survey'), Html::convDateTime($survey->getField('date_begin'))));
$pdf->displayLine(__('No answer', 'pdf'));
}
}
}
$pdf->displaySpace();
}
示例4: testCreateTicketWithActors
/**
* @dataProvider ticketProvider
*/
public function testCreateTicketWithActors($ticketActors)
{
$ticket = new Ticket();
$ticket->add(array('name' => 'ticket title', 'description' => 'a description') + $ticketActors);
$this->assertFalse($ticket->isNewItem());
$ticketId = $ticket->getID();
foreach ($ticketActors as $actorType => $actorsList) {
// Convert single actor (scalar value) to array
if (!is_array($actorsList)) {
$actorsList = array($actorsList);
}
// Check all actors are assigned to the ticket
foreach ($actorsList as $index => $actor) {
$notify = isset($actorList['_users_id_requester_notif']['use_notification'][$index]) ? $actorList['_users_id_requester_notif']['use_notification'][$index] : 1;
$alternateEmail = isset($actorList['_users_id_requester_notif']['use_notification'][$index]) ? $actorList['_users_id_requester_notif']['alternative_email'][$index] : '';
switch ($actorType) {
case '_users_id_assign':
$this->_testTicketUser($ticket, $actor, CommonITILActor::REQUESTER, $notify, $alternateEmail);
break;
case '_users_id_observer':
$this->_testTicketUser($ticket, $actor, CommonITILActor::OBSERVER, $notify, $alternateEmail);
break;
case '_users_id_assign':
$this->_testTicketUser($ticket, $actor, CommonITILActor::ASSIGN, $notify, $alternateEmail);
break;
}
}
}
}
示例5: 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']));
}
}
示例6: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'solveticket':
$input = $ma->getInput();
$ticket = new Ticket();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id']) && $ticket->canSolve()) {
$toupdate = array();
$toupdate['id'] = $ticket->getID();
$toupdate['solutiontypes_id'] = $input['solutiontypes_id'];
$toupdate['solution'] = $input['solution'];
if ($ticket->update($toupdate)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($ticket->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例7: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'add_task':
if (!($task = getItemForItemtype('TicketTask'))) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
break;
}
$ticket = new Ticket();
$field = $ticket->getForeignKeyField();
$input = $ma->getInput();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id'])) {
$input2 = array($field => $item->fields['tickets_id'], 'taskcategories_id' => $input['taskcategories_id'], 'actiontime' => $input['actiontime'], 'content' => $input['content']);
if ($task->can(-1, CREATE, $input2)) {
if ($task->add($input2)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
}
return;
case 'solveticket':
$input = $ma->getInput();
$ticket = new Ticket();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id']) && $ticket->canSolve()) {
$toupdate = array();
$toupdate['id'] = $ticket->getID();
$toupdate['solutiontypes_id'] = $input['solutiontypes_id'];
$toupdate['solution'] = $input['solution'];
if ($ticket->update($toupdate)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($ticket->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例8: showSltForTicket
/**
* Show SLT for ticket
*
* @param $ticket Ticket item
* @param $type
* @param $tt
* @param $canupdate
**/
function showSltForTicket(Ticket $ticket, $type, $tt, $canupdate)
{
global $CFG_GLPI;
list($dateField, $sltField) = self::getSltFieldNames($type);
echo "<table width='100%'>";
echo "<tr class='tab_bg_1'>";
if (!isset($ticket->fields[$dateField]) || $ticket->fields[$dateField] == 'NULL') {
$ticket->fields[$dateField] = '';
}
if ($ticket->fields['id']) {
if ($this->getSltDataForTicket($ticket->fields['id'], $type)) {
echo "<td>";
echo Html::convDateTime($ticket->fields[$dateField]);
echo "</td>";
echo "<th>" . __('SLT') . "</th>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_slts', $ticket->fields[$sltField]) . " ";
$commentsla = "";
$slalevel = new SlaLevel();
$nextaction = new SlaLevel_Ticket();
if ($nextaction->getFromDBForTicket($ticket->fields["id"], $type)) {
$commentsla .= '<span class="b spaced">' . sprintf(__('Next escalation: %s'), Html::convDateTime($nextaction->fields['date'])) . '</span><br>';
if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) {
$commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span>';
}
}
$slaoptions = array();
if (Session::haveRight('sla', READ)) {
$slaoptions['link'] = Toolbox::getItemTypeFormURL('SLT') . "?id=" . $this->fields["id"];
}
Html::showToolTip($commentsla, $slaoptions);
if ($canupdate) {
$fields = array('slt_delete' => 'slt_delete', 'id' => $ticket->getID(), 'type' => $type, '_glpi_csrf_token' => Session::getNewCSRFToken(), '_glpi_simple_form' => 1);
$JS = " function delete_date{$type}(){\n if (nativeConfirm('" . addslashes(__('Also delete date ?')) . "')) {\n submitGetLink('" . $ticket->getFormURL() . "',\n " . json_encode(array_merge($fields, array('delete_date' => 1))) . ");\n } else {\n submitGetLink('" . $ticket->getFormURL() . "',\n " . json_encode(array_merge($fields, array('delete_date' => 0))) . ");\n }\n }";
echo Html::scriptBlock($JS);
echo "<a class='pointer' onclick='delete_date{$type}();return false;'>";
echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/delete.png' title='" . _x('button', 'Delete permanently') . "' " . "alt='" . _x('button', 'Delete permanently') . "' class='pointer'>";
echo "</a>";
}
echo "</td>";
} else {
echo "<td width='200px'>";
echo $tt->getBeginHiddenFieldValue($dateField);
if ($canupdate) {
Html::showDateTimeField($dateField, array('value' => $ticket->fields[$dateField], 'timestep' => 1, 'maybeempty' => true));
} else {
echo Html::convDateTime($ticket->fields[$dateField]);
}
echo $tt->getEndHiddenFieldValue($dateField, $ticket);
echo "</td>";
$slt_data = $this->getSltData("`type` = '{$type}'\n AND `entities_id` = '" . $ticket->fields['entities_id'] . "'");
if ($canupdate && !empty($slt_data)) {
echo "<td>";
echo $tt->getBeginHiddenFieldText($sltField);
echo "<span id='slt_action{$type}'>";
echo "<a " . Html::addConfirmationOnAction(array(__('The assignment of a SLT to a ticket causes the recalculation of the date.'), __("Escalations defined in the SLT will be triggered under this new date.")), "cleanhide('slt_action{$type}');cleandisplay('slt_choice{$type}');") . "><img src='" . $CFG_GLPI['root_doc'] . "/pics/clock.png' title='" . __('SLT') . "' alt='" . __('SLT') . "' class='pointer'></a>";
echo "</span>";
echo "<div id='slt_choice{$type}' style='display:none'>";
echo "<span class='b'>" . __('SLT') . "</span> ";
Slt::dropdown(array('name' => $sltField, 'entity' => $ticket->fields["entities_id"], 'condition' => "`type` = '" . $type . "'"));
echo "</div>";
echo $tt->getEndHiddenFieldText($sltField);
echo "</td>";
}
}
} else {
// New Ticket
echo "<td>";
echo $tt->getBeginHiddenFieldValue($dateField);
Html::showDateTimeField($dateField, array('value' => $ticket->fields[$dateField], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate));
echo $tt->getEndHiddenFieldValue($dateField, $ticket);
echo "</td>";
$slt_data = $this->getSltData("`type` = '{$type}'\n AND `entities_id` = '" . $ticket->fields['entities_id'] . "'");
if ($canupdate && !empty($slt_data)) {
echo "<th>" . $tt->getBeginHiddenFieldText($sltField);
printf(__('%1$s%2$s'), __('SLT'), $tt->getMandatoryMark($sltField));
echo $tt->getEndHiddenFieldText('slas_id') . "</th>";
echo "<td class='nopadding'>" . $tt->getBeginHiddenFieldValue($sltField);
Slt::dropdown(array('name' => $sltField, 'entity' => $ticket->fields["entities_id"], 'value' => isset($ticket->fields[$sltField]) ? $ticket->fields[$sltField] : 0, 'condition' => "`type` = '" . $type . "'"));
echo $tt->getEndHiddenFieldValue($sltField, $ticket);
echo "</td>";
}
}
echo "</tr>";
echo "</table>";
}
示例9: doSpecificMassiveActions
/**
* @see CommonDBTM::doSpecificMassiveActions()
*
* @since version 0.84
**/
function doSpecificMassiveActions($input = array())
{
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case "solveticket":
$ticket = new Ticket();
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'r')) {
if ($ticket->getFromDB($this->fields['tickets_id']) && $ticket->canSolve()) {
$toupdate = array();
$toupdate['id'] = $ticket->getID();
$toupdate['solutiontypes_id'] = $input['solutiontypes_id'];
$toupdate['solution'] = $input['solution'];
if ($ticket->update($toupdate)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
} else {
$res['noright']++;
}
}
}
break;
default:
return parent::doSpecificMassiveActions($input);
}
return $res;
}
示例10: methodAddTicketDocument
/**
* Add a document to a existing ticket
* for an authenticated user
*
* @param $params array of options (ticket, uri, name, base64, comment)
* only one of uri and base64 must be set
* name is mandatory when base64 set, for extension check (filename)
* @param $protocol the communication protocol used
*
* @return array of hashtable
**/
static function methodAddTicketDocument($params, $protocol)
{
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('ticket' => 'integer,mandatory', 'uri' => 'string,optional', 'base64' => 'string,optional', 'content' => 'string,optional', 'close' => 'bool,optional', 'reopen' => 'bool,optional', 'source' => 'string,optional', 'private' => 'bool,optional', 'help' => 'bool,optional');
}
if (!Session::getLoginUserID()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
}
$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');
}
if (!$ticket->can($params['ticket'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
}
if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'closed ticket');
}
if (!$ticket->canAddFollowups()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'access denied');
}
if (isset($params['name']) && !empty($params['name'])) {
$document_name = addslashes($params['name']);
} else {
$document_name = addslashes(sprintf(__('%1$s %2$s'), _x('phone', 'Number'), $ticket->fields['id']));
}
$filename = tempnam(GLPI_DOC_DIR . '/_tmp', 'PWS');
$response = parent::uploadDocument($params, $protocol, $filename, $document_name);
//An error occured during document upload
if (parent::isError($protocol, $response)) {
return $response;
}
$doc = new Document();
$documentitem = new Document_Item();
$docid = $doc->getFromDBbyContent($ticket->fields["entities_id"], $filename);
if ($docid) {
$input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'documents_id' => $doc->getID());
if ($DB->request('glpi_documents_items', $input)->numrows()) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'document already associated to this ticket');
}
$new = $documentitem->add($input);
} else {
$input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'tickets_id' => $ticket->getID(), 'entities_id' => $ticket->getEntityID(), 'is_recursive' => $ticket->isRecursive(), 'documentcategories_id' => $CFG_GLPI["documentcategories_id_forticket"]);
$new = $doc->add($input);
}
// to not add it twice during followup
unset($_FILES['filename']);
if (!$new) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError());
}
if (isset($params['comment']) && !empty($params['comment'])) {
$params['content'] = $params['comment'];
unset($params['comment']);
}
if (isset($params['content']) && !empty($params['content'])) {
return self::methodAddTicketFollowup($params, $protocol);
}
return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol);
}
示例11: checkAssignGroup
static function checkAssignGroup(Ticket $ticket)
{
global $DB;
$ok = 0;
$ptConfig = new PluginTimelineticketConfig();
$ptConfig->getFromDB(1);
if ($ptConfig->fields["add_waiting"] == 0) {
$ok = 1;
}
if ($ok && in_array("status", $ticket->updates) && isset($ticket->oldvalues["status"]) && $ticket->oldvalues["status"] == Ticket::WAITING) {
if ($ticket->countGroups(CommonITILActor::ASSIGN)) {
foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $d) {
$ptAssignGroup = new PluginTimelineticketAssignGroup();
$calendar = new Calendar();
$calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
$datedebut = $ticket->fields['date'];
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
$delay = $calendar->getActiveTimeBetween($datedebut, $_SESSION["glpi_currenttime"]);
} else {
// cas 24/24 - 7/7
$delay = strtotime($_SESSION["glpi_currenttime"]) - strtotime($datedebut);
}
$input = array();
$input['tickets_id'] = $ticket->getID();
$input['groups_id'] = $d["groups_id"];
$input['date'] = $_SESSION["glpi_currenttime"];
$input['begin'] = $delay;
$ptAssignGroup->add($input);
}
}
} else {
if ($ok && in_array("status", $ticket->updates) && isset($ticket->fields["status"]) && $ticket->fields["status"] == Ticket::WAITING) {
if ($ticket->countGroups(CommonITILActor::ASSIGN)) {
foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $d) {
$calendar = new Calendar();
$calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
$ptAssignGroup = new PluginTimelineticketAssignGroup();
$query = "SELECT MAX(`date`) AS datedebut, id\n FROM `" . $ptAssignGroup->getTable() . "`\n WHERE `tickets_id` = '" . $ticket->getID() . "'\n AND `groups_id`='" . $d["groups_id"] . "'\n AND `delay` IS NULL";
$result = $DB->query($query);
$datedebut = '';
$input = array();
if ($result && $DB->numrows($result)) {
$datedebut = $DB->result($result, 0, 'datedebut');
$input['id'] = $DB->result($result, 0, 'id');
} else {
return;
}
if (!$datedebut) {
$delay = 0;
// Utilisation calendrier
} else {
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
$delay = $calendar->getActiveTimeBetween($datedebut, $_SESSION["glpi_currenttime"]);
} else {
// cas 24/24 - 7/7
$delay = strtotime($_SESSION["glpi_currenttime"]) - strtotime($datedebut);
}
}
$input['delay'] = $delay;
$ptAssignGroup->update($input);
}
}
}
}
}
示例12: showForm
function showForm(Ticket $ticket)
{
global $CFG_GLPI;
echo "<form method='post' name='' id='' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/escalation/front/ticketcopy.form.php\">";
echo "<table width='950' class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th colspan='3'>";
echo "Copie de ticket (Liste des champs à copier)";
echo "</th>";
echo "</tr>";
echo "<tr>";
echo "<td colspan='3' align='center'>";
echo "<a href=\"javascript:showHideDiv('listfields','imgcat0','../../pics/folder.png'," . "'../../pics/folder-open.png');\">";
echo "Voir tous les champs</a>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "</td>";
echo "<td>";
echo "Lier au ticket";
echo "</td>";
echo "<td>";
Dropdown::showYesNo('link');
echo "</td>";
echo "</tr>";
$this->displayField(__('Title'), "name", $ticket->fields['name'], '', 'checked');
$this->displayField(__('Description'), "content", $ticket->fields['content'], '', 'checked');
echo "</table>";
echo "<div id='listfields' style='display:none;'>";
echo "<table width='950' class='tab_cadre_fixe'>";
$this->displayField(__('Status'), "status", Ticket::getStatus($ticket->fields['status']), $ticket->fields['status']);
$this->displayField(__('Type'), "type", Ticket::getTicketTypeName($ticket->fields['type']), $ticket->fields['type']);
$this->displayField(__('Urgency'), "urgency", Ticket::getUrgencyName($ticket->fields['urgency']), $ticket->fields['urgency']);
$this->displayField(__('Impact'), "impact", Ticket::getImpactName($ticket->fields['impact']), $ticket->fields['impact']);
$this->displayField(__('Priority'), "priority", Ticket::getPriorityName($ticket->fields['priority']), $ticket->fields['priority']);
$this->displayField(__('Due date'), "due_date", Html::convDateTime($ticket->fields['due_date']), $ticket->fields['due_date']);
$this->displayField(__('Category'), "itilcategories_id", Dropdown::getDropdownName('glpi_itilcategories', $ticket->fields['itilcategories_id']), $ticket->fields['itilcategories_id']);
if ($ticket->fields['items_id'] > 0) {
$this->displayField(__('Associated element') . ' - ' . __('Type'), "itemtype", call_user_func(array($ticket->fields['itemtype'], 'getTypeName')), $ticket->fields['itemtype']);
$this->displayField(__('Associated element'), "items_id", Dropdown::getDropdownName(getTableForItemType($ticket->fields['itemtype']), $ticket->fields['items_id']), $ticket->fields['items_id']);
}
$this->displayField(__('Request source'), "requesttypes_id", Dropdown::getDropdownName('glpi_requesttypes', $ticket->fields['requesttypes_id']), $ticket->fields['requesttypes_id']);
$this->displayField(__('SLA'), "slas_id", Dropdown::getDropdownName('glpi_slas', $ticket->fields['slas_id']), $ticket->fields['slas_id']);
$ticket_User = new Ticket_User();
$a_ticket_users = $ticket_User->find("`tickets_id`='" . $ticket->getID() . "'\n AND `type`='1'");
foreach ($a_ticket_users as $data) {
$name = '';
if ($data['users_id'] == 0) {
$name = $data['alternative_email'];
} else {
$name = Dropdown::getDropdownName('glpi_users', $data['users_id']);
}
$this->displayField(__('Requester'), "_users_id_requester", $name, $data['id']);
}
$group_Ticket = new Group_Ticket();
$a_group_tickets = $group_Ticket->find("`tickets_id`='" . $ticket->getID() . "'\n AND `type`='1'");
foreach ($a_group_tickets as $data) {
$this->displayField(__('Requester group'), "_groups_id_requester", Dropdown::getDropdownName('glpi_groups', $data['groups_id']), $data['groups_id']);
}
// Techs
$peConfig = new PluginEscalationConfig();
if ($peConfig->getValue('workflow', $ticket->fields['entities_id']) == '0') {
$a_ticket_uers = $ticket_User->find("`tickets_id`='" . $ticket->getID() . "'\n AND `type`='2'");
foreach ($a_ticket_uers as $data) {
$name = '';
if ($data['users_id'] == 0) {
$name = $data['alternative_email'];
} else {
$name = Dropdown::getDropdownName('glpi_users', $data['users_id']);
}
$this->displayField(__('Technician'), "_users_id_assign", $name, $data['id']);
}
$a_group_tickets = $group_Ticket->find("`tickets_id`='" . $ticket->getID() . "'\n AND `type`='2'");
foreach ($a_group_tickets as $data) {
$this->displayField(__('Group in charge of the ticket'), "_groups_id_assign", Dropdown::getDropdownName('glpi_groups', $data['groups_id']), $data['groups_id']);
}
}
$ticketFollowup = new TicketFollowup();
$followups = $ticketFollowup->find("`tickets_id`='" . $ticket->getID() . "'");
foreach ($followups as $data) {
$this->displayField(__('Follow-up'), "followup-" . $data['id'], $data['content'], $data['id']);
}
$ticketTask = new TicketTask();
$tasks = $ticketTask->find("`tickets_id`='" . $ticket->getID() . "'");
foreach ($tasks as $data) {
$this->displayField(__('Task'), "task-" . $data['id'], $data['content'], $data['id']);
}
// Documents
// $document_Item = new Document_Item();
// $docs = $document_Item->find("`items_id`='".$ticket->getID()."'
// AND `itemtype`='Ticket'");
// foreach ($docs as $data) {
// $this->displayField($LANG['document'][18], "filename",
// Dropdown::getDropdownName("glpi_documents", $data['documents_id']),
// $data['documents_id']);
// }
// // filename[]
echo "</table>";
echo "</div>";
//.........这里部分代码省略.........