. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: Olivier Moron // Purpose of file: // ---------------------------------------------------------------------- // Direct access to file if (strpos($_SERVER['PHP_SELF'], "task_users.php")) { include ("../../../inc/includes.php"); header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } if (!defined('GLPI_ROOT')) { die("Can not access directly to this file"); } Session::checkLoginUser(); $rand = rand(); $commoninputs = "". "". "". "". "". "". "". "". ""; $PM_SOAP = new PluginProcessmakerProcessmaker; $PM_DB = new PluginProcessmakerDB; echo "
"; echo ""; echo ""; echo $commoninputs; echo ''; echo ''; echo ''; $can_unclaim = false; // by default $grp = false; $query = "SELECT TAS_GROUP_VARIABLE FROM TASK WHERE TAS_UID='".$_REQUEST['taskGuid']."' AND TAS_ASSIGN_TYPE='SELF_SERVICE';"; $res = $PM_DB->query($query); if ($PM_DB->numrows($res) > 0 && $row = $PM_DB->fetchAssoc($res)) { $can_unclaim = true; if ($row['TAS_GROUP_VARIABLE'] != '') { //self-service value based assignment $PM_SOAP->login(true); // needs to be logged in to be able to call SOAP $grp = $PM_SOAP->getGLPIGroupIdForSelfServiceTask($_REQUEST['caseGuid'], $_REQUEST['taskGuid']); } } $task_table = getTableForItemType($_REQUEST['tasktype']); $res = $DB->request([ 'SELECT' => [ 'pm.is_reassignreason_mandatory AS pm_is_reassignreason_mandatory', 'gppp.is_reassignreason_mandatory AS gppp_is_reassignreason_mandatory', 'pm.before_time AS pm_before_time', 'pm.after_time AS pm_after_time', 'pm.users_id AS pm_users_id', 'gpptr.before_time AS tr_before_time', 'gpptr.after_time AS tr_after_time', 'gpptr.users_id AS tr_users_id', 'gpptr.id AS plugin_processmaker_taskrecalls_id', 'gtt.begin AS task_begin', 'gtt.end AS task_end', 'gpptr.when AS tr_when', 'gppt.id AS pm_tasks_id' ], 'FROM' => 'glpi_plugin_processmaker_taskcategories AS pm', 'LEFT JOIN' => [ 'glpi_plugin_processmaker_processes AS gppp' => [ 'ON' => [ 'gppp' => 'id', 'pm' => 'plugin_processmaker_processes_id' ] ], 'glpi_plugin_processmaker_tasks as gppt' => [ 'ON' => [ 'pm' => 'id', 'gppt' => 'plugin_processmaker_taskcategories_id', ['AND' => ['gppt.items_id' => $_REQUEST['tasks_id'], 'gppt.itemtype'=> $_REQUEST['tasktype']] ] ] ], 'glpi_plugin_processmaker_taskrecalls as gpptr' => [ 'ON' => [ 'gpptr' => 'plugin_processmaker_tasks_id', 'gppt' => 'id' ] ], $task_table . ' as gtt' => [ 'ON' => [ 'gtt' => 'id', 'gppt' => 'items_id' ] ] ], 'WHERE' => [ 'pm.pm_task_guid' => $_REQUEST['taskGuid'] ] ]); // there is only one row $taskCat = $res->current(); $ask_for_reason = PluginProcessmakerTaskCategory::inheritedReAssignReason($taskCat['pm_is_reassignreason_mandatory'], $taskCat['gppp_is_reassignreason_mandatory']); echo ''; echo ''; echo ''; echo ''; // check rights $caneditreminders = Session::getCurrentInterface() == 'central' && $PM_SOAP->config['users_id'] != $_REQUEST['users_id']; if ($caneditreminders) { echo ''; } echo ''; echo '
'; echo "" . __('Re-assign task to', 'processmaker') . ""; echo ''; PluginProcessmakerUser::dropdown( ['name' => 'users_id_recipient', 'value' => $_REQUEST['users_id'], 'used' => $_REQUEST['used'] ?? [], 'entity' => 0, //$item->fields["entities_id"], // not used, as any user can be assigned to any tasks 'entity_sons' => false, // not used, as any user can be assigned to any tasks 'right' => 'all', 'all' => ($can_unclaim ? 0 : -1), 'rand' => $rand, 'width' => '', 'specific_tags' => ['taskGuid' => $_REQUEST['taskGuid'], 'grpGuid' => ($grp !== false ? $grp['uid'] : 0)] ]); echo ''; echo ""; echo ""; echo HTML::scriptBlock(" $(function () { // Dialog helpers // Create the dialog with \"Re-assign\" button function showCommentDlg(title, content, alttext) { modalId = title.replaceAll(' ', '_') var modal = $('#'+title); if (modal && modal.length == 0) { var modal = '
' + '
' + '
' + '
' + '
'+ title +'
' + '' + '
' + '
' + '
' + '
' + '' + '
' + '
' + '
'; $('body').append(modal); } $('#'+modalId).modal('show'); $('#'+modalId+' .modal-body').append('

".addslashes(__('Input at least 10 words to justify.','processmaker'))."'); $('#commenttxtarea$rand').focus(); $('#commenttxtarea$rand').on('keydown keyup', function(e) { if ($('#commenttxtarea$rand').val().split(/\W+/).length > 10) { $('#submit$rand').prop('disabled', false); } else { $('#submit$rand').prop('disabled', true); } }); $('#'+modalId).on('hide.bs.modal', function () { $('#'+modalId).remove(); }) $('#submit$rand').click(() => { $('#comment$rand').val($('#commenttxtarea$rand').val()); $('#reassign$rand').click(); $('#submit$rand').button('disable'); $('#'+modalId).modal('hide').remove(); }); }; $('input[name=reassign$rand]').click(function (e) { //debugger; let post = true; e.preventDefault(); let users_id_val = $('#users_id$rand').val(); let users_id_recipient_val = $('#dropdown_users_id_recipient$rand').val(); if (users_id_val == users_id_recipient_val) { // task is already assigned to this user if (users_id_val == 0) { alert('".addslashes(__('Task is already un-assigned!', 'processmaker'))."', '".addslashes(__('Re-assign task', 'processmaker'))."'); } else { alert('".addslashes(__('Task is already assigned to this user!', 'processmaker'))."', '".addslashes(__('Re-assign task', 'processmaker'))."'); } post = false; } else if (users_id_recipient_val == 0) { // un-claim if (".($can_unclaim ? 1 : 0)." && users_id_val != 0) { if (" . ($ask_for_reason ? 1 : 0) . ") { showCommentDlg('".addslashes(__('Un-claim task', 'processmaker'))."', '".addslashes(__('Please input reason to un-claim
(task will be re-assigned to former group):', 'processmaker'))."', '".addslashes(__('Un-claim', 'processmaker'))."'); post = false; } } else { // task can't be unclaimed because it isn't SELF_SERVICE alert('".addslashes(__("Can't un-assign task!", 'processmaker'))."', '".addslashes(__('Un-claim task', 'processmaker'))."'); post = false; } } else if (" . ($ask_for_reason ? 1 : 0) . ") { showCommentDlg('".addslashes(__('Re-assign task', 'processmaker'))."', '".addslashes(__('Please input reason to re-assign:', 'processmaker'))."', '".addslashes(__('Re-assign', 'processmaker'))."'); post = false; } if (post) { // here we must click on the reassign button to force POST $('#reassign$rand').click(); } return false; }); }) "); echo '
'; echo ''; if (!isset($PM_SOAP->config)) { $PM_SOAP->config = Config::getConfigurationValues('plugin:processmaker'); } if (Session::getLoginUserID() != $_REQUEST['users_id'] && $PM_SOAP->config['users_id'] != $_REQUEST['users_id']) { echo ""; } echo ''; echo '
Automatic reminder settings 
'; echo Html::scriptBlock(" function showHideReminderSettings() { if ($('.reminder_settings').css('display') == 'none') { $('.reminder_settings').css('display', ''); } else { $('.reminder_settings').css('display', 'none'); } $('#reminder_arrow').toggleClass('fa-caret-up fa-caret-down'); } "); echo '
'; if ($caneditreminders) { // add info on reminder // show before time // show after time // show next date // show user // add submit button echo Html::scriptBlock(" function formatedTimestamp (d, hm_only) { const date = d.toISOString().split('T')[0]; const time = d.toTimeString().split(' ')[0]; if (typeof hm_only === 'undefined' && hm_only === true) { return date + ' ' + time; } const hm = time.split(':') return date + ' ' + hm[0] + ':' + hm[1]; } function computeNextDate (elt_name, new_date_name, ref_name, ope) { var delta = $('[name=' + elt_name + ']').val() * 1000; // in milliseconds var ref = $('[name=' + ref_name + ']').val(); // date_begin or date_end var new_date = __('None', 'processmaker'); // by default if (delta >= 0) { if (ope === 'sub') { delta = -delta; } new_date = formatedTimestamp(new Date(Date.parse(ref) + delta)); var current_date = formatedTimestamp(new Date()); if (new_date < current_date) { new_date = formatedTimestamp(new Date(Date.parse(current_date) + delta)); } } $('[name=' + new_date_name + ']').val(new_date); $('#' + new_date_name).text(new_date); } function selectUser (userid, username) { // Set the actual_users_id value, creating a new option if necessary if ($('[name=actual_users_id]').find('option[value=' + userid + ']').length) { $('[name=actual_users_id]').val(userid).trigger('change'); } else { // Create a DOM Option and pre-select by default var newOption = new Option(decodeURIComponent(username.replace(/\+/g, ' ')), userid, true, true); // Append it to the select $('[name=actual_users_id]').append(newOption).trigger('change'); } } function reset2Defaults () { if ($('[name=actual_before_time]').val() != " . PluginProcessmakerTaskCategory::REMINDER_STOP . " && $('[name=task_begin]').val() > '" . $_SESSION["glpi_currenttime"] . "') { $('[name=actual_before_time]').val($('[name=default_before_time]').val()).trigger('change'); } $('[name=actual_after_time]').val($('[name=default_after_time]').val()).trigger('change'); // Set the actual_users_id value, creating a new option if necessary selectUser($('[name=default_users_id]').val(), $('[name=default_user_name]').val()); } "); echo ""; echo ""; echo ""; echo ""; echo ''; echo ''; echo ""; echo ""; $taskCat['pm_users_id'] = $taskCat['pm_users_id'] ?? 0; echo ""; $user_info = urlencode($taskCat['pm_users_id'] > 0 ? getUserName($taskCat['pm_users_id']) : Dropdown::EMPTY_VALUE); echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ""; echo ''; echo ''; echo ""; echo ''; echo ''; echo ''; echo ''; } echo '
'; Html::closeForm(true);