";
echo "".__('Active')." ";
Dropdown::showYesNo("is_active", $this->fields["is_active"]);
diff --git a/inc/processCategory.class.php b/inc/processCategory.class.php
new file mode 100644
index 0000000..e8feb2f
--- /dev/null
+++ b/inc/processCategory.class.php
@@ -0,0 +1,58 @@
+.
+--------------------------------------------------------------------------
+ */
+/**
+ * PluginProcessmakerTaskCategory short summary.
+ *
+ * PluginProcessmakerTaskCategory description.
+ *
+ * @version 1.0
+ * @author MoronO
+ */
+
+if (!defined('GLPI_ROOT')) {
+ die("Sorry. You can't access directly to this file");
+}
+
+
+class PluginProcessmakerProcessCategory extends CommonDBTM
+{
+ static function refreshCategories() {
+ global $PM_DB;
+
+ $processCategories = new self;
+ foreach($PM_DB->request('PROCESS_CATEGORY') as $data) {
+ if (!$processCategories->getFromDBByCrit(["category_guid" => $data['CATEGORY_UID']])) {
+ $processCategories->add([
+ 'name' => $data['CATEGORY_NAME'],
+ 'category_guid' => $data['CATEGORY_UID']
+ ]);
+ }
+ }
+ }
+
+}
diff --git a/inc/process_profile.class.php b/inc/process_profile.class.php
index 4b75b4b..db8d56d 100644
--- a/inc/process_profile.class.php
+++ b/inc/process_profile.class.php
@@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
ProcessMaker plugin for GLPI
-Copyright (C) 2014-2023 by Raynet SAS a company of A.Raymond Network.
+Copyright (C) 2014-2024 by Raynet SAS a company of A.Raymond Network.
https://www.araymond.com/
-------------------------------------------------------------------------
diff --git a/inc/processmaker.class.php b/inc/processmaker.class.php
index 5f5a72e..572cd66 100644
--- a/inc/processmaker.class.php
+++ b/inc/processmaker.class.php
@@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
ProcessMaker plugin for GLPI
-Copyright (C) 2014-2023 by Raynet SAS a company of A.Raymond Network.
+Copyright (C) 2014-2024 by Raynet SAS a company of A.Raymond Network.
https://www.araymond.com/
-------------------------------------------------------------------------
@@ -167,13 +167,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* @param mixed $txtForFollowup
* @param integer $users_id optional, if null will uses logged-in user
*/
- public function addItemFollowup($itemtype, $itemId, $txtForFollowup, $users_id = null) {
+ public function addItemFollowup($itemtype, $itemId, $txtForFollowup, $cases_id, $tasks_id, $users_id = null) {
global $DB;
$fu = new ITILFollowup();
$input = $fu->fields;
- if (isset($txtForFollowup['GLPI_ITEM_FOLLOWUP_CONTENT']) && $txtForFollowup['GLPI_ITEM_FOLLOWUP_CONTENT'] != "") {
- $input['content'] = $DB->escape($txtForFollowup['GLPI_ITEM_FOLLOWUP_CONTENT']);
- }
+
+ $input['content'] = $DB->escape($txtForFollowup['GLPI_ITEM_FOLLOWUP_CONTENT'] . " ");
+
if (isset($txtForFollowup['GLPI_ITEM_FOLLOWUP_IS_PRIVATE']) && $txtForFollowup['GLPI_ITEM_FOLLOWUP_IS_PRIVATE'] != "") {
$input['is_private'] = $txtForFollowup['GLPI_ITEM_FOLLOWUP_IS_PRIVATE'];
}
@@ -659,16 +659,18 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
*/
function cancelCase($caseUid) {
try {
- $pmCaseInfo = $this->getCaseInfo($caseUid);
- if ($pmCaseInfo->status_code == 0) {
- foreach ($pmCaseInfo->currentUsers as $pmUser) {
- $pmCancelTask = $this->cancelTask($caseUid, $pmUser->delIndex, $pmUser->userId);
- if ($pmCancelTask->status_code != 0) {
- return $pmCancelTask;
- }
- }
- }
- return $pmCancelTask;
+ $pmCaseInfo = $this->getCaseInfo($caseUid);
+ if ($pmCaseInfo->status_code == 0) {
+ if (count($pmCaseInfo->currentUsers) > 1) {
+ $pmCancelTask = $this->cancelTask($caseUid, null, null);
+ } else {
+ $pmCancelTask = $this->cancelTask($caseUid, $pmCaseInfo->currentUsers[0]->delIndex, PluginProcessmakerUser::getPMUserId($_SESSION['glpiID']));
+ if ($pmCancelTask->status_code != 0) {
+ return $pmCancelTask;
+ }
+ }
+ }
+ return $pmCancelTask;
} catch (Exception $e) {
Toolbox::logDebug($e);
return false;
@@ -1636,7 +1638,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// here we create a fake task that will be used to store the creator of the case
// this is due for traceability only
- $PM_SOAP->add1stTask($myCase->getID(), $myCase->fields['itemtype'], $myCase->fields['items_id'], $caseInfo, [ 'notif' => false]); // no notif
+ $PM_SOAP->add1stTask($myCase->getID(), $myCase->fields['itemtype'], $myCase->fields['items_id'], $caseInfo, ['notif' => false, 'userId' => Session::getLoginUserID()]); // no notif
// before routing, send items_id and itemtype
// as this information was not available at case creation
@@ -1766,6 +1768,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
* 'txtTaskContent' => '',
* 'start_date' => '',
* 'end_date' => '',
+ * 'reminder' => '',
* 'notif' => true
* @return
*/
@@ -1853,7 +1856,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$input['content'] .= "##processmakercase.url##";
$input['is_private'] = 0;
- $input['actiontime'] = 0;
+ //$input['actiontime'] = 0;
$input['state'] = Planning::TODO; // == TO_DO
$input['users_id_tech'] = 0; // by default as it can't be empty
if ($techId) {
@@ -1862,13 +1865,13 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$input['groups_id_tech'] = $groups_id_tech['id'];
}
- if ($options['reminder'] != '' && $techId) {
- $input['_planningrecall'] = ['before_time' => $options['reminder'],
- 'itemtype' => get_class($glpi_task),
- 'items_id' => '',
- 'users_id' => $techId,
- 'field' => 'begin'];
- }
+ //if ($options['reminder'] != '' && $techId) {
+ // $input['_planningrecall'] = ['before_time' => $options['reminder'],
+ // 'itemtype' => get_class($glpi_task),
+ // 'items_id' => '',
+ // 'users_id' => $techId,
+ // 'field' => 'begin'];
+ //}
$donotif = PluginProcessmakerNotificationTargetProcessmaker::saveNotificationState(false); // do not send notification yet as the PluginProcessmakerTask is not yet added to DB
$glpi_task->add(Toolbox::addslashes_deep($input));
@@ -1881,12 +1884,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if ($glpi_task->getId() > 0) {
// stores link to task in DB
- //$tmp = new PluginProcessmakerTask($glpi_task->getType());
- //$tmp->add([ 'itemtype' => $glpi_task->getType(),
- // 'items_id' => $glpi_task->getId(),
- // 'plugin_processmaker_cases_id' => $cases_id,
- // 'del_index' => $delIndex
- // ], [], false);
+ // can't use a GLPI framework object as PluginProcessmakerTask::getFromDB() has been overloaded
$DB->insert('glpi_plugin_processmaker_tasks',
[
'items_id' => $glpi_task->getId(),
@@ -1896,10 +1894,26 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
'del_index' => $delIndex,
'del_thread' => $delThread
]);
- //$query = "INSERT INTO glpi_plugin_processmaker_tasks (items_id, itemtype, plugin_processmaker_cases_id, plugin_processmaker_taskcategories_id, del_index, del_thread)
- // VALUES ({$glpi_task->getId()}, '{$glpi_task->getType()}', $cases_id, {$pmtaskcat->fields['id']}, $delIndex, $delThread);";
- //$DB->query($query);
- //}
+ $pmTaskId = $DB->insertId();
+
+ // check if there is a recall reminder from the $pm_taskcat
+ $before_time = $pmtaskcat->fields['before_time'];
+ $after_time = $pmtaskcat->fields['after_time'];
+ if ($options['reminder'] != '') {
+ $before_time = $options['reminder'];
+ }
+ if ($before_time != PluginProcessmakerTaskCategory::REMINDER_NONE || $after_time != PluginProcessmakerTaskCategory::REMINDER_NONE) {
+ // then add a PluginProcessmakerTaskrecall object in DB
+ $when = ($before_time > PluginProcessmakerTaskCategory::REMINDER_NONE ? date("Y-m-d H:i:s", strtotime($input['begin']) - $before_time) : date("Y-m-d H:i:s", strtotime($input['end']) + $after_time));
+ $pr = new PluginProcessmakerTaskrecall();
+ $pr->add([
+ 'plugin_processmaker_tasks_id' => $pmTaskId,
+ 'users_id' => $pmtaskcat->fields['users_id'],
+ 'before_time' => $before_time,
+ 'after_time' => $after_time,
+ 'when' => $when
+ ]);
+ }
// send notification if needed for new task as now we have the PluginProcessmakerTask in the DB
$donotif = PluginProcessmakerNotificationTargetProcessmaker::saveNotificationState($options['notif']);
@@ -1965,7 +1979,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$start_date = new DateTime($_SESSION["glpi_currenttime"]);
$official_date_time = $_SESSION["glpi_currenttime"];
$_SESSION["glpi_currenttime"] = $start_date->sub(new DateInterval("PT1S"))->format("Y-m-d H:i:s");
- $userId = $options['userId'] ? $options['userId'] : Session::getLoginUserID();
+ $userId = $options['userId'];
unset($options['userId']); // unset it as it's not in the options of addTask
$this->addTask($cases_id,
@@ -2239,7 +2253,6 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$pm_task->sendNotification('task_done', $glpi_task, $hostItem);
PluginProcessmakerNotificationTargetProcessmaker::restoreNotificationState($donotif);
-
// restore current glpi time
$_SESSION["glpi_currenttime"] = $saved_date_time;
@@ -2452,26 +2465,114 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
$tmpCase->getFromDB($pmTask->fields['plugin_processmaker_cases_id']);
$urlLink = $tmpCase->getLinkURL().'&forcetab=PluginProcessmakerTask$'.$pmTask->fields['items_id'];
+ if ($pmTask->fields['del_thread_status'] != PluginProcessmakerTask::CLOSED) {
+ if ($params['item']->fields['state'] != Planning::INFO) {
+ echo Html::scriptBlock("
+ function $taskJSId(ev) {
+ //debugger;
+ if ($(ev.target).parent('.read_more').length == 0) {
+ $('div[data-items-id=\"$dataItemId\"]').width('100%');
+ $('div[data-items-id=\"$dataItemId\"]').find('.edit_content').width('100%').css({ 'background-color': 'white', 'padding': '5px 0', 'text-align': 'center'})
+ $('div[data-items-id=\"$dataItemId\"]').find('.read-only-content').hide();
+ $('div[data-items-id=\"$dataItemId\"]').find('.edit_content').show().load('/plugins/processmaker/ajax/task.php',
+ {'cases_id': {$pmTask->fields['plugin_processmaker_cases_id']},
+ 'tabnum': {$pmTask->fields['items_id']}});
+ $('div[data-items-id=\"$dataItemId\"] .close-edit-content').show().toggleClass('d-none')
+ .click(function() {
+ $(this).hide();
+ $('div[data-items-id=\"$dataItemId\"] .edit_content').empty().hide();
+ $('div[data-items-id=\"$dataItemId\"] .read-only-content').show();
+ $('div[data-items-id=\"$dataItemId\"]').width('');
+ });
+ }
+ };
+//debugger;
+ $('div[data-items-id=\"$dataItemId\"]').find('.read-only-content').parent().append('
');
+ $('div[data-items-id=\"$dataItemId\"]').find('.edit_content').hide();
+ //$('div[data-items-id=\"$dataItemId\"]').find('.timeline-header .timeline-item-buttons').append('
');
+ $('div[data-items-id=\"$dataItemId\"]').find('.timeline-header .close-edit-content').appendTo('div[data-items-id=\"$dataItemId\"] .timeline-item-buttons');
+ $('div[data-items-id=\"$dataItemId\"]').find('.close-edit-content').hide();
+ $('div[data-items-id=\"$dataItemId\"]').find('.text-content').on('click', $taskJSId).css('cursor', 'pointer');
+ $('div[data-items-id=\"$dataItemId\"]').find('.read_more').css('cursor', 'auto');
+ $('tr[id=\"$taskJSId\"]').children().on('click', $taskJSId).css('cursor', 'pointer');
+ $(function() {
+ $('div[data-items-id=\"$dataItemId\"]').find('.timeline-item-buttons').prepend(
+ '".str_replace("'", "\\'", $tmpCase->fields['name'])."' +
+ 'fields['id']}\">{$tmpCase->fields['id']} ' +
+ ' '
+ );
+ });
+ ");
+ } else {
+ echo Html::scriptBlock("
+ function $taskJSId(ev) {
+ //debugger;
+ if ($(ev.target).parent('.read_more').length == 0) {
+ document.location='$urlLink';
+ }
+ };
+ $('#$taskJSId').find('.item-content').on('click', $taskJSId).css('cursor', 'pointer');
+ $('#$taskJSId').find('.read_more').css('cursor', 'auto');
+ $('tr[id=\"$taskJSId\"]').children().on('click', $taskJSId).css('cursor', 'pointer');
+ $(function() {
+ $('#$taskJSId').find('.displayed_content span.state').parent().append(
+ '".str_replace("'", "\\'", $tmpCase->fields['name'])."' +
+ 'fields['id']}\">{$tmpCase->fields['id']} ' +
+ ' '
+ );
+ });
+ ");
+ }
+ } else {
+ echo Html::scriptBlock("
+ function $taskJSId(ev) {
+ if ($(ev.target).parent('.read_more').length == 0) {
+ document.location='$urlLink';
+ }
+ };
+ $('div[data-items-id=\"$dataItemId\"]').find('.text-content').on('click', $taskJSId).css('cursor', 'pointer');
+ $('div[data-items-id=\"$dataItemId\"]').find('.read_more').css('cursor', 'auto');
+ $('tr[id=\"$taskJSId\"]').children().on('click', $taskJSId).css('cursor', 'pointer');
+ $(function() {
+ $('div[data-items-id=\"$dataItemId\"]').find('.timeline-item-buttons').prepend(
+ '".str_replace("'", "\\'", $tmpCase->fields['name'])."' +
+ 'fields['id']}\">{$tmpCase->fields['id']} ' +
+ ' '
+ );
+ });
+ //$('#$taskJSId').find('.displayed_content > div').last().html(
+ // $('#$taskJSId').find('.displayed_content > div').last().html().replace(/(.*?)( .*)/, '$1 $2')
+ //);
+ ");
+ }
+ //will open all todo tasks when created within last 30 seconds
+ if ((strtotime($pmTask->fields['date_creation']) > strtotime("-30 second") || strtotime($pmTask->fields['date_mod']) > strtotime("-30 second"))
+ && (Session::getLoginUserID() === $pmTask->fields['users_id_tech'] || !empty(Group_User::getGroupUsers($pmTask->fields['groups_id_tech'], ['users_id' => Session::getLoginUserID()])))
+ && $params['item']->fields['state'] == Planning::TODO) {
+ echo Html::scriptBlock("
+ $('div[data-items-id=\"$dataItemId\"]').width('100%');
+ $('div[data-items-id=\"$dataItemId\"]').find('.edit_content').width('100%').css({ 'background-color': 'white', 'padding': '5px 0', 'text-align': 'center'})
+ $('div[data-items-id=\"$dataItemId\"]').find('.read-only-content').hide();
+ $('div[data-items-id=\"$dataItemId\"]').find('.edit_content').show().load('/plugins/processmaker/ajax/task.php',
+ {'cases_id': {$pmTask->fields['plugin_processmaker_cases_id']},
+ 'tabnum': {$pmTask->fields['items_id']}}, function() {
+ $('div[data-items-id=\"$dataItemId\"]')[0].scrollIntoView({ behavior: 'smooth', block: 'start' });
+ });
+ $('div[data-items-id=\"$dataItemId\"] .close-edit-content').show().toggleClass('d-none')
+ .click(function() {
+ $(this).hide();
+ $('div[data-items-id=\"$dataItemId\"] .edit_content').empty().hide();
+ $('div[data-items-id=\"$dataItemId\"] .read-only-content').show();
+ $('div[data-items-id=\"$dataItemId\"]').width('');
+ });
+ ");
+ }
+ // will add a class to the div.h_content
echo Html::scriptBlock("
- function $taskJSId(ev) {
- if ($(ev.target).parent('.read_more').length == 0) {
- document.location='$urlLink';
- }
- };
- $('div[data-items-id=\"$dataItemId\"]').find('.text-content').on('click', $taskJSId).css('cursor', 'pointer');
- $('div[data-items-id=\"$dataItemId\"]').find('.read_more').css('cursor', 'auto');
- $('tr[id=\"$taskJSId\"]').children().on('click', $taskJSId).css('cursor', 'pointer');
- $(function() {
- $('div[data-items-id=\"$dataItemId\"]').find('.timeline-item-buttons').prepend(
- '".str_replace("'", "\\'", $tmpCase->fields['name'])."' +
- 'fields['id']}\">{$tmpCase->fields['id']} ' +
- ' '
- );
- });
- //$('#$taskJSId').find('.displayed_content > div').last().html(
- // $('#$taskJSId').find('.displayed_content > div').last().html().replace(/(.*?)( .*)/, '$1 $2')
- //);
- ");
+ //$('div[data-items-id=\"$dataItemId\"]').removeClass('ITILTask');
+ $('div[data-items-id=\"$dataItemId\"]').addClass('Case-".$pmTask->fields['plugin_processmaker_cases_id']."');
+ ");
+
// in order to set NavigationList
Session::initNavigateListItems('PluginProcessmakerCase',
//TRANS : %1$s is the itemtype name,
@@ -2483,6 +2584,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
static function show_in_timeline_processmaker($params) {
+ global $CFG_GLPI;
foreach($params['timeline'] as $key => $timelineObject) {
if (is_subclass_of($timelineObject['type'], 'CommonITILTask')) {
$pmTask = new PluginProcessmakerTask($timelineObject['type']);
@@ -2531,8 +2633,137 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
}
}
}
+ //$itemtype = $params['item']->getType();
+ // if (in_array($itemtype, ['Ticket', 'Problem', 'Change'])
+ // && $params['item']->getID()
+ // && Session::getCurrentInterface() == "central") {
+ // $rand = rand();
+ //$status = $params['item']->fields['status'];
+ //if ($status !== CommonITILObject::CLOSED && $status !== CommonITILObject::SOLVED) {
+ // $user = User::getById(Session::getLoginUserID());
+ // $btnLayout = $user->fields["timeline_action_btn_layout"];
+ // if ($btnLayout == null) {
+ // $btnLayout = 0;
+ // }
+ // echo Html::scriptBlock("
+ // if (window.jQuery != undefined) {
+ // $(document).ready(function() {
+ // function newCasebutton(){
+ // $('.timeline-buttons .main-actions').hide();
+ // $('#right-actions').hide();
+ // $(document).on('click', '#new-itilobject-form .close-new-case-form', function() {
+ // $('#itil-footer .main-actions').show();
+ // $('#right-actions').show();
+ // });
+ // }
+ // if ($btnLayout) {
+ // $('.timeline-buttons .main-actions').append('".__('Case', 'processmaker')." ');
+ // }
+ // else {
+ // $('.timeline-buttons .main-actions .dropdown-menu').append(\"".__('Add a case', 'processmaker')." \");
+ // }
+ // $('.timeline-buttons .main-actions .newCase').css('background-color', '#4185F4');
+ // $('.timeline-buttons .main-actions .newCase').on('click', newCasebutton).css('cursor', 'pointer');
+ // $('#new-itilobject-form').append('')
+ // $('#new-CaseForm-block').load('/plugins/processmaker/ajax/case.php', {'items_id': {$params['item']->getID()}, 'itemtype': '{$params['item']->getType()}'});
+ // })
+ // };");
+ //}
+ //
+ //
+
+ //// will add filter for each cases in this object
+ //foreach (getAllDataFromTable(PluginProcessmakerCase::GetTable(), ['itemtype' => $itemtype, 'items_id' => $params['item']->getID()]) as $row) {
+ // echo Html::scriptBlock("
+ // if (window.jQuery != undefined) {
+ // $(document).ready(function() {
+ // $('.filter-timeline div.ITILTask').parents('li').before(' " . Toolbox::addslashes_deep($row['name']) . " - ". $row['id'] . "
');
+ // })};");
+ //}
+ //echo Html::scriptBlock("
+ // if (window.jQuery != undefined) {
+ // $(document).ready(function() {
+ // $('.filter-timeline div.list-group').prepend('
All
')
+ // $('.filter-timeline #timeline-filter-filter-all').on('click', function (e) {
+ // $('.filter-timeline li').each(function () {
+ // if ($(this).find('.FilterAll').length == 0
+ // && $(this).find('.Log').length == 0
+ // && $(this).find('input[type=checkbox]').prop('checked') != $('#timeline-filter-filter-all').prop('checked')) {
+ // $(this).find('input[type=checkbox]').click();
+ // }
+ // })
+ // })
+ // })
+ // }");
+ //}
}
+ /**
+ * Summary of post_show_item_processmaker
+ * @param mixed $params
+ */
+ public static function post_show_item_processmaker($params) {
+ $itemtype = $params['item']->getType();
+ if (in_array($itemtype, ['Ticket', 'Problem', 'Change'])
+ && $params['item']->getID()
+ && Session::getCurrentInterface() == "central") {
+ $status = $params['item']->fields['status'];
+ if ($status !== CommonITILObject::CLOSED && $status !== CommonITILObject::SOLVED) {
+ $user = User::getById(Session::getLoginUserID());
+ $btnLayout = $user->fields["timeline_action_btn_layout"];
+ if ($btnLayout == null) {
+ $btnLayout = 0;
+ }
+ echo Html::scriptBlock("
+ $(document).ready(function() {
+ function newCasebutton(){
+ $('.timeline-buttons .main-actions').hide();
+ $('#right-actions').hide();
+ $(document).on('click', '#new-itilobject-form .close-new-case-form', function() {
+ $('#itil-footer .main-actions').show();
+ $('#right-actions').show();
+ });
+ }
+ if ($btnLayout) {
+ $('.timeline-buttons .main-actions').append('
".__('Case', 'processmaker')." ');
+ }
+ else {
+ $('.timeline-buttons .main-actions .dropdown-menu').append(\"
".__('Add a case', 'processmaker')." \");
+ }
+ $('.timeline-buttons .main-actions .newCase').css('background-color', '#4185F4');
+ $('.timeline-buttons .main-actions .newCase').on('click', newCasebutton).css('cursor', 'pointer');
+ $('#new-itilobject-form').append('
')
+ $('#new-CaseForm-block').load('/plugins/processmaker/ajax/case.php', {'items_id': {$params['item']->getID()}, 'itemtype': '{$params['item']->getType()}'});
+ })
+ ;");
+ }
+ // will add filter for each cases in this object
+ foreach (getAllDataFromTable(PluginProcessmakerCase::GetTable(), ['itemtype' => $itemtype, 'items_id' => $params['item']->getID()]) as $row) {
+ echo Html::scriptBlock("
+ if (window.jQuery != undefined) {
+ $(document).ready(function() {
+ $('.filter-timeline div.ITILTask').parents('li').before('
" . Toolbox::addslashes_deep($row['name']) . " - ". $row['id'] . "
');
+ })};");
+ }
+ echo Html::scriptBlock("
+ if (window.jQuery != undefined) {
+ $(document).ready(function() {
+ $('.filter-timeline div.list-group').prepend('
All
')
+ $('.filter-timeline #timeline-filter-filter-all').on('click', function (e) {
+ $('.filter-timeline li').each(function () {
+ if ($(this).find('.FilterAll').length == 0
+ && $(this).find('.Log').length == 0
+ && $(this).find('input[type=checkbox]').prop('checked') != $('#timeline-filter-filter-all').prop('checked')) {
+ $(this).find('input[type=checkbox]').click();
+ }
+ })
+ })
+ })
+ }");
+ }
+ }
+
+
/**
* Summary of getItemUsers
* returns an array of glpi ids and pm ids for each user type assigned to given ticket
@@ -2748,9 +2979,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
//if ($pmtask->getFromDBByQuery("WHERE itemtype = '$pmtask_itemtype' AND items_id = $pmtask_items_id")) {
if ($pmtask->getFromDBByRequest($restrict)) {
- if (!in_array("tasks", $item->tag_descriptions)) {
- $item->html_tags[] = "tasks"; // to force GLPI to keep the below HTML tags, otherwise it will apply a Html::entities_deep() to the task.description
- }
+ //if (!in_array("tasks", $item->tag_descriptions)) {
+ // $item->html_tags[] = "tasks"; // to force GLPI to keep the below HTML tags, otherwise it will apply a Html::entities_deep() to the task.description
+ //}
$task['##task.description##'] = str_replace('##processmaker.taskcomment##', $task['##task.categorycomment##'], $task['##task.description##']);
$task['##task.description##'] = nl2br($task['##task.description##']);
@@ -2960,6 +3191,9 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
],
[], true);
+ if ($caseInfo->currentUsers[0]->userId == "") { // in case the task is "to be claimed"
+ $users_id = 0;
+ }
$this->add1stTask($locCase->getID(), $itemtype, $items_id, $caseInfo, ['userId' => $users_id]);
}
@@ -3209,7 +3443,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// create a followup if requested
if ($createFollowup) { // && $itemtype == 'Ticket') {
- $this->addItemFollowup($itemtype, $items_id, $casevariablevalues);
+ $this->addItemFollowup($itemtype, $items_id, $casevariablevalues, $myCase->getID(), $glpi_task->getID());
}
if ($txtItemTitle != '') {
diff --git a/inc/profile.class.php b/inc/profile.class.php
index 30d085e..f613b9f 100644
--- a/inc/profile.class.php
+++ b/inc/profile.class.php
@@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
ProcessMaker plugin for GLPI
-Copyright (C) 2014-2023 by Raynet SAS a company of A.Raymond Network.
+Copyright (C) 2014-2024 by Raynet SAS a company of A.Raymond Network.
https://www.araymond.com/
-------------------------------------------------------------------------
diff --git a/inc/selfservicedraft.class.php b/inc/selfservicedraft.class.php
index 45d26ec..015ab32 100644
--- a/inc/selfservicedraft.class.php
+++ b/inc/selfservicedraft.class.php
@@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
ProcessMaker plugin for GLPI
-Copyright (C) 2014-2023 by Raynet SAS a company of A.Raymond Network.
+Copyright (C) 2014-2024 by Raynet SAS a company of A.Raymond Network.
https://www.araymond.com/
-------------------------------------------------------------------------
diff --git a/inc/task.class.php b/inc/task.class.php
index 26aca76..56e403f 100644
--- a/inc/task.class.php
+++ b/inc/task.class.php
@@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
ProcessMaker plugin for GLPI
-Copyright (C) 2014-2023 by Raynet SAS a company of A.Raymond Network.
+Copyright (C) 2014-2024 by Raynet SAS a company of A.Raymond Network.
https://www.araymond.com/
-------------------------------------------------------------------------
@@ -35,10 +35,21 @@ along with this plugin. If not, see
.
*/
class PluginProcessmakerTask extends CommonITILTask
{
+ private $users_id_sender;
+
private $itemtype;
+
function __construct($itemtype = 'TicketTask') {
parent::__construct();
- $this->itemtype = $itemtype;
+ $this->itemtype = $itemtype;
+ $this->users_id_sender = 0;
+ }
+
+ function getSender() {
+ return $this->users_id_sender;
+ }
+ function setSender($users_id) {
+ $this->users_id_sender = $users_id;
}
@@ -66,7 +77,6 @@ class PluginProcessmakerTask extends CommonITILTask
function getFromDB($items_id) {
global $DB;
- //if ($this->getFromDBByQuery(" WHERE itemtype='".$this->itemtype."' AND items_id=$items_id;" )) {
if ($this->getFromDBByRequest([
'WHERE' => [
'itemtype' => $this->itemtype,
@@ -137,7 +147,6 @@ class PluginProcessmakerTask extends CommonITILTask
$events = [];
if (isset($params['start'])) {
- $params['begin'] = $params['start']; //'2000-01-01 00:00:00';
if ($params['type'] == 'group') {
$params['who_group'] = $params['who'];
$params['whogroup'] = $params['who'];
@@ -188,7 +197,7 @@ class PluginProcessmakerTask extends CommonITILTask
$caseInfo = $case->getCaseInfo();
- if (property_exists($caseInfo, 'currentUsers')) {
+ if (property_exists($caseInfo, 'currentUsers') && $caseInfo->caseStatus != PluginProcessmakerCase::CANCELLED) {
$dbu = new DbUtils;
$GLPICurrentPMUserId = PluginProcessmakerUser::getPMUserId(Session::getLoginUserID());
@@ -377,7 +386,7 @@ class PluginProcessmakerTask extends CommonITILTask
$used_users = [];
- $used_users[] = $current_assigned_user;
+ //$used_users[] = $current_assigned_user; // not set to be able to alert when trying to re-assigned to the same user
if (array_key_exists($currentUser->taskId, $prevent_assign)) {
if (!is_array($prevent_assign[$currentUser->taskId])) {
$prevent_assign[$currentUser->taskId] = [$prevent_assign[$currentUser->taskId]];
@@ -401,7 +410,7 @@ class PluginProcessmakerTask extends CommonITILTask
taskGuid : '{$currentUser->taskId}',
delIndex : {$task[$tabnum]['del_index']},
delThread : {$currentUser->delThread},
-// used : [".join(',', array_unique($used_users))."] // not set to be able to alert when trying to re-assigned to the same user
+ used : [".join(',', array_unique($used_users))."]
}";
echo html::scriptBlock("$('#divUsers-{$task[$tabnum]['del_index']}-{$rand}').load('".Plugin::getWebDir('processmaker')."/ajax/task_users.php', $data);");
}
@@ -470,7 +479,7 @@ class PluginProcessmakerTask extends CommonITILTask
// search if at least one active notification is existing for that pm task with that event 'task_update_'.$glpi_task->fields['taskcategories_id']
$res = PluginProcessmakerNotificationTargetTask::getNotifications($type, $task->fields['taskcategories_id'], $item->fields['entities_id']);
if ($res['notifications'] && count($res['notifications']) > 0) {
- NotificationEvent::raiseEvent($res['event'],
+ return NotificationEvent::raiseEvent($res['event'],
$this,
['plugin_processmaker_cases_id' => $this->fields['plugin_processmaker_cases_id'],
'itemtype' => $item->getType(),
@@ -482,7 +491,7 @@ class PluginProcessmakerTask extends CommonITILTask
'obj' => $item
]);
} else {
- NotificationEvent::raiseEvent(PluginProcessmakerNotificationTargetTask::getDefaultGLPIEvents($type),
+ return NotificationEvent::raiseEvent(PluginProcessmakerNotificationTargetTask::getDefaultGLPIEvents($type),
$item,
['plugin_processmaker_cases_id' => $this->fields['plugin_processmaker_cases_id'],
'itemtype' => $item->getType(),
diff --git a/inc/taskalert.class.php b/inc/taskalert.class.php
new file mode 100644
index 0000000..d04b799
--- /dev/null
+++ b/inc/taskalert.class.php
@@ -0,0 +1,30 @@
+.
+--------------------------------------------------------------------------
+ */
+class PluginProcessmakerTaskalert extends CommonDBTM {
+
+}
diff --git a/inc/taskcategory.class.php b/inc/taskcategory.class.php
index 5203987..68e38c6 100644
--- a/inc/taskcategory.class.php
+++ b/inc/taskcategory.class.php
@@ -2,7 +2,7 @@
/*
-------------------------------------------------------------------------
ProcessMaker plugin for GLPI
-Copyright (C) 2014-2023 by Raynet SAS a company of A.Raymond Network.
+Copyright (C) 2014-2024 by Raynet SAS a company of A.Raymond Network.
https://www.araymond.com/
-------------------------------------------------------------------------
@@ -42,6 +42,9 @@ if (!defined('GLPI_ROOT')) {
class PluginProcessmakerTaskCategory extends CommonDBTM
{
+ const REMINDER_NONE = -10;
+ const REMINDER_STOP = -20;
+
static $rightname = 'taskcategory';
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
@@ -57,6 +60,46 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
}
+ static function getAllAfterReminders() {
+ $possible_values = [];
+ $possible_values[self::REMINDER_NONE] = __('None');
+
+ $min_values = [15, 30];
+ foreach ($min_values as $val) {
+ $possible_values[$val * MINUTE_TIMESTAMP] = sprintf(_n('%d minute', '%d minutes', $val), $val);
+ }
+
+ $h_values = [1, 2, 4, 8, 12];
+ foreach ($h_values as $val) {
+ $possible_values[$val * HOUR_TIMESTAMP] = sprintf(_n('%d hour', '%d hours', $val), $val);
+ }
+ $d_values = [1, 2, 4, 6];
+ foreach ($d_values as $val) {
+ $possible_values[$val * DAY_TIMESTAMP] = sprintf(_n('%d day', '%d days', $val), $val);
+ }
+ $w_values = [1, 2, 3];
+ foreach ($w_values as $val) {
+ $possible_values[$val * WEEK_TIMESTAMP] = sprintf(_n('%d week', '%d weeks', $val), $val);
+ }
+ $m_values = [1, 2];
+ foreach ($m_values as $val) {
+ $possible_values[$val * MONTH_TIMESTAMP] = sprintf(_n('%d month', '%d months', $val), $val);
+ }
+
+ return $possible_values;
+ }
+
+
+ static function getAfterReminder($value) {
+ $arr = self::getAllAfterReminders();
+ if (array_key_exists($value, $arr)) {
+ return $arr[$value];
+ } else {
+ return null;
+ }
+ }
+
+
static function displayTabContentForProcess(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
global $DB, $CFG_GLPI;
@@ -272,6 +315,7 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
echo Dropdown::getYesNo($taskCat['is_subprocess']);
echo "
";
+ echo " ";
echo "