|
1 | | -<?php |
2 | | -include_once ("../../../inc/includes.php"); |
3 | | - |
4 | | -switch ($_POST["action"]) { |
5 | | - case 'newcase': |
6 | | - if (isset($_POST['items_id']) && $_POST['items_id'] > 0) { |
7 | | - |
8 | | - // then this case will be bound to an item |
9 | | - if ($_POST['plugin_processmaker_processes_id'] > 0) { |
10 | | - |
11 | | - $resultCase = $PM_SOAP->startNewCase($_POST['plugin_processmaker_processes_id'], $_POST['itemtype'], $_POST['items_id'], Session::getLoginUserID()); |
12 | | - |
13 | | - if ($resultCase->status_code == 0) { |
14 | | - $case = new PluginProcessmakerCase; |
15 | | - if ($case->getFromGUID($resultCase->caseId)) { |
16 | | - $link = $case->getLinkURL(); |
17 | | - $task = new PluginProcessmakerTask($_POST['itemtype'].'Task'); |
18 | | - |
19 | | - $task->getFromDBByRequest([ |
20 | | - 'WHERE' => [ |
21 | | - 'plugin_processmaker_cases_id' => $case->getID() |
22 | | - ], |
23 | | - ]); |
24 | | - |
25 | | - |
26 | | - //$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task |
27 | | - //$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID(); |
28 | | - |
29 | | - Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->fields['id']); |
30 | | - $item = new $_POST['itemtype']; |
31 | | - $item->getFromDB($_POST['items_id']); |
32 | | - unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList |
33 | | - Session::initNavigateListItems('PluginProcessmakerCase', |
34 | | - //TRANS : %1$s is the itemtype name, |
35 | | - // %2$s is the name of the item (used for headings of a list) |
36 | | - sprintf('%1$s = %2$s', |
37 | | - $_POST['itemtype']::getTypeName(1), $item->fields["name"])); |
38 | | - Html::redirect($link); |
39 | | - } |
40 | | - Html::back(); |
41 | | - } else { |
42 | | - Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR); |
43 | | - } |
44 | | - } else { |
45 | | - Html::back(); |
46 | | - } |
47 | | - } else { // the case is created before the ticket (used for post-only case creation before ticket creation) |
48 | | - $pm_user_guid = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() ); |
49 | | - $resultCase = $PM_SOAP->newCase( $_POST['plugin_processmaker_processes_id'], |
50 | | - ['GLPI_ITEM_CAN_BE_SOLVED' => 0, |
51 | | - 'GLPI_SELFSERVICE_CREATED' => '1', |
52 | | - 'GLPI_ITEM_TYPE' => 'Ticket', |
53 | | - 'GLPI_URL' => $CFG_GLPI['url_base'], |
54 | | - // Specific to Tickets |
55 | | - // GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request) |
56 | | - 'GLPI_TICKET_TYPE' => $_POST['type'], |
57 | | - 'GLPI_ITEM_REQUESTER_GLPI_ID' => Session::getLoginUserID(), |
58 | | - 'GLPI_ITEM_REQUESTER_PM_ID' => $pm_user_guid |
59 | | - ] ); |
60 | | - if ($resultCase->status_code == 0) { |
61 | | - // case is created |
62 | | - // Must show it... |
63 | | - // |
64 | | - $rand = rand( ); |
65 | | - Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?processes_id=".$_POST['plugin_processmaker_processes_id']."&case_guid=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_POST["itilcategories_id"]."&type=".$_POST["type"]."&entities_id=".$_POST['entities_id']); |
66 | | - |
67 | | - } else { |
68 | | - Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); |
69 | | - Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1"); |
70 | | - } |
71 | | - |
72 | | - } |
73 | | - break; |
74 | | - |
75 | | - case 'reassign_reminder' : |
76 | | - if (isset($_POST['reassign'])) { |
77 | | - // here we should re-assign the current task to $_POST['users_id_recipient'] |
78 | | - $locCase = new PluginProcessmakerCase; |
79 | | - $locCase->getFromDB($_POST['cases_id']); |
80 | | - if ($_POST['users_id_recipient'] != 0) { |
81 | | - // we are assigning a new tech to a task |
82 | | - $pmResponse = $locCase->reassignCase($_POST['delIndex'], |
83 | | - $_POST['taskGuid'], |
84 | | - $_POST['delThread'], |
85 | | - $_POST['users_id'], |
86 | | - $_POST['users_id_recipient'], |
87 | | - ['comment' => $_POST['comment']]); |
88 | | - if ($pmResponse) { |
89 | | - Session::addMessageAfterRedirect(__('Task re-assigned!', 'processmaker'), true, INFO); |
90 | | - } else { |
91 | | - Session::addMessageAfterRedirect(__('Error re-assigning task: ', 'processmaker').$pmResponse->message, true, ERROR); |
92 | | - } |
93 | | - } elseif ($_POST['users_id_recipient'] == 0) { |
94 | | - // we are unassigning a task, i.e.: task un-claim |
95 | | - $pmResponse = $locCase->unassignCase($_POST['delIndex'], |
96 | | - $_POST['taskGuid'], |
97 | | - $_POST['tasktype'], |
98 | | - $_POST['tasks_id'], |
99 | | - $_POST['itemtype'], |
100 | | - ['comment' => $_POST['comment']]); |
101 | | - if ($pmResponse) { |
102 | | - Session::addMessageAfterRedirect(__('Task un-claimed!', 'processmaker'), true, INFO); |
103 | | - } else { |
104 | | - Session::addMessageAfterRedirect(__("Can't un-claim task! Verify 'Assignement Rules' in the process definition.", 'processmaker'), true, ERROR); |
105 | | - } |
106 | | - } |
107 | | - } elseif (isset($_POST['reminder'])) { |
108 | | - // send notification remider as requested for this task |
109 | | - |
110 | | - $locCase = new PluginProcessmakerCase; |
111 | | - $locCase->getFromDB($_POST['cases_id']); |
112 | | - $glpi_item = new $_POST['itemtype']; |
113 | | - $glpi_item->getFromDB($_POST['items_id']); |
114 | | - $pm_task = new PluginProcessmakerTask($_POST['tasktype']); |
115 | | - $pm_task->getFromDB($_POST['tasks_id']); |
116 | | - $glpi_task = new $_POST['tasktype']; |
117 | | - $glpi_task->getFromDB($_POST['tasks_id']); |
118 | | - |
119 | | - // send notification now! |
120 | | - $pm_task->sendNotification('task_reminder', $glpi_task, $glpi_item, $locCase); |
121 | | - } |
122 | | -} |
123 | | - |
124 | | -// to return to item |
125 | | -Html::back(); |
126 | | - |
| 1 | +<?php |
| 2 | +include_once ("../../../inc/includes.php"); |
| 3 | + |
| 4 | +switch ($_REQUEST["action"]) { |
| 5 | + case 'newcase': |
| 6 | + if (isset($_REQUEST['items_id']) && $_REQUEST['items_id'] > 0) { |
| 7 | + |
| 8 | + // then this case will be bound to an item |
| 9 | + if ($_REQUEST['plugin_processmaker_processes_id'] > 0) { |
| 10 | + |
| 11 | + $resultCase = $PM_SOAP->startNewCase($_REQUEST['plugin_processmaker_processes_id'], $_REQUEST['itemtype'], $_REQUEST['items_id'], Session::getLoginUserID()); |
| 12 | + |
| 13 | + if ($resultCase->status_code == 0) { |
| 14 | + $case = new PluginProcessmakerCase; |
| 15 | + if ($case->getFromGUID($resultCase->caseId)) { |
| 16 | + $link = $case->getLinkURL(); |
| 17 | + $task = new PluginProcessmakerTask($_REQUEST['itemtype'].'Task'); |
| 18 | + |
| 19 | + $task->getFromDBByRequest([ |
| 20 | + 'WHERE' => [ |
| 21 | + 'plugin_processmaker_cases_id' => $case->getID() |
| 22 | + ], |
| 23 | + ]); |
| 24 | + |
| 25 | + |
| 26 | + //$task->getFromDBByQuery(" WHERE `plugin_processmaker_cases_id`=".$case->getID()); // normally there is only one and only one first task |
| 27 | + //$link .= '&forcetab=PluginProcessmakerTask$'.$task->getID(); |
| 28 | + |
| 29 | + Session::setActiveTab('PluginProcessmakerCase', 'PluginProcessmakerTask$'.$task->fields['id']); |
| 30 | + $item = new $_REQUEST['itemtype']; |
| 31 | + $item->getFromDB($_REQUEST['items_id']); |
| 32 | + unset($_SERVER['REQUEST_URI']); // to prevent use of processmaker.form.php in NavigateList |
| 33 | + Session::initNavigateListItems('PluginProcessmakerCase', |
| 34 | + //TRANS : %1$s is the itemtype name, |
| 35 | + // %2$s is the name of the item (used for headings of a list) |
| 36 | + sprintf('%1$s = %2$s', |
| 37 | + $_REQUEST['itemtype']::getTypeName(1), $item->fields["name"])); |
| 38 | + Html::redirect($link); |
| 39 | + } |
| 40 | + Html::back(); |
| 41 | + } else { |
| 42 | + Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>".$resultCase->message." (".$resultCase->status_code.")", true, ERROR); |
| 43 | + } |
| 44 | + } else { |
| 45 | + Html::back(); |
| 46 | + } |
| 47 | + } else { // the case is created before the ticket (used for post-only case creation before ticket creation) |
| 48 | + $pm_user_guid = PluginProcessmakerUser::getPMUserId( Session::getLoginUserID() ); |
| 49 | + $resultCase = $PM_SOAP->newCase( $_REQUEST['plugin_processmaker_processes_id'], |
| 50 | + ['GLPI_ITEM_CAN_BE_SOLVED' => 0, |
| 51 | + 'GLPI_SELFSERVICE_CREATED' => '1', |
| 52 | + 'GLPI_ITEM_TYPE' => 'Ticket', |
| 53 | + 'GLPI_URL' => $CFG_GLPI['url_base'], |
| 54 | + // Specific to Tickets |
| 55 | + // GLPI_TICKET_TYPE will contains 1 (= incident) or 2 (= request) |
| 56 | + 'GLPI_TICKET_TYPE' => $_REQUEST['type'], |
| 57 | + 'GLPI_ITEM_REQUESTER_GLPI_ID' => Session::getLoginUserID(), |
| 58 | + 'GLPI_ITEM_REQUESTER_PM_ID' => $pm_user_guid |
| 59 | + ] ); |
| 60 | + if ($resultCase->status_code == 0) { |
| 61 | + // case is created |
| 62 | + // Must show it... |
| 63 | + // |
| 64 | + $rand = rand( ); |
| 65 | + Html::redirect($CFG_GLPI['root_doc']."/plugins/processmaker/front/processmaker.helpdesk.form.php?processes_id=".$_REQUEST['plugin_processmaker_processes_id']."&case_guid=".$resultCase->caseId."&rand=$rand&itilcategories_id=".$_REQUEST["itilcategories_id"]."&type=".$_REQUEST["type"]."&entities_id=".$_REQUEST['entities_id']); |
| 66 | + |
| 67 | + } else { |
| 68 | + Session::addMessageAfterRedirect( PluginProcessmakerProcessmaker::getPMErrorMessage($resultCase->status_code)."<br>$resultCase->message ($resultCase->status_code)", true, ERROR); |
| 69 | + Html::redirect($CFG_GLPI["root_doc"]."/front/helpdesk.public.php?create_ticket=1"); |
| 70 | + } |
| 71 | + |
| 72 | + } |
| 73 | + break; |
| 74 | + |
| 75 | + case 'reassign_reminder' : |
| 76 | + if (isset($_REQUEST['reassign'])) { |
| 77 | + // here we should re-assign the current task to $_REQUEST['users_id_recipient'] |
| 78 | + $locCase = new PluginProcessmakerCase; |
| 79 | + $locCase->getFromDB($_REQUEST['cases_id']); |
| 80 | + if ($_REQUEST['users_id_recipient'] != 0) { |
| 81 | + // we are assigning a new tech to a task |
| 82 | + $pmResponse = $locCase->reassignCase($_REQUEST['delIndex'], |
| 83 | + $_REQUEST['taskGuid'], |
| 84 | + $_REQUEST['delThread'], |
| 85 | + $_REQUEST['users_id'], |
| 86 | + $_REQUEST['users_id_recipient'], |
| 87 | + ['comment' => $_REQUEST['comment']]); |
| 88 | + if ($pmResponse) { |
| 89 | + Session::addMessageAfterRedirect(__('Task re-assigned!', 'processmaker'), true, INFO); |
| 90 | + } else { |
| 91 | + Session::addMessageAfterRedirect(__('Error re-assigning task: ', 'processmaker').$pmResponse->message, true, ERROR); |
| 92 | + } |
| 93 | + } elseif ($_REQUEST['users_id_recipient'] == 0) { |
| 94 | + // we are unassigning a task, i.e.: task un-claim |
| 95 | + $pmResponse = $locCase->unassignCase($_REQUEST['delIndex'], |
| 96 | + $_REQUEST['taskGuid'], |
| 97 | + $_REQUEST['tasktype'], |
| 98 | + $_REQUEST['tasks_id'], |
| 99 | + $_REQUEST['itemtype'], |
| 100 | + ['comment' => $_REQUEST['comment']]); |
| 101 | + if ($pmResponse) { |
| 102 | + Session::addMessageAfterRedirect(__('Task un-claimed!', 'processmaker'), true, INFO); |
| 103 | + } else { |
| 104 | + Session::addMessageAfterRedirect(__("Can't un-claim task! Verify 'Assignement Rules' in the process definition.", 'processmaker'), true, ERROR); |
| 105 | + } |
| 106 | + } |
| 107 | + } elseif (isset($_REQUEST['reminder'])) { |
| 108 | + // send notification remider as requested for this task |
| 109 | + |
| 110 | + $locCase = new PluginProcessmakerCase; |
| 111 | + $locCase->getFromDB($_REQUEST['cases_id']); |
| 112 | + $glpi_item = new $_REQUEST['itemtype']; |
| 113 | + $glpi_item->getFromDB($_REQUEST['items_id']); |
| 114 | + $pm_task = new PluginProcessmakerTask($_REQUEST['tasktype']); |
| 115 | + $pm_task->getFromDB($_REQUEST['tasks_id']); |
| 116 | + $glpi_task = new $_REQUEST['tasktype']; |
| 117 | + $glpi_task->getFromDB($_REQUEST['tasks_id']); |
| 118 | + |
| 119 | + // send notification now! |
| 120 | + $pm_task->sendNotification('task_reminder', $glpi_task, $glpi_item, $locCase); |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +// to return to item |
| 125 | +Html::back(); |
| 126 | +
|
0 commit comments