2015-10-09 14:13:52 +02:00
< ? php
// ----------------------------------------------------------------------
// Original Author of file: Olivier Moron
// Purpose of file:
// ----------------------------------------------------------------------
// Direct access to file
2017-05-06 18:38:24 +02:00
if ( strpos ( $_SERVER [ 'PHP_SELF' ], " task_users.php " )) {
include ( " ../../../inc/includes.php " );
header ( " Content-Type: text/html; charset=UTF-8 " );
Html :: header_nocache ();
2015-10-09 14:13:52 +02:00
}
if ( ! defined ( 'GLPI_ROOT' )) {
2018-07-04 11:24:29 +02:00
die ( " Can not access directly to this file " );
2015-10-09 14:13:52 +02:00
}
Session :: checkLoginUser ();
2020-10-07 15:40:05 +02:00
$commoninputs = " <input type='hidden' name='items_id' value=' " . $_REQUEST [ 'items_id' ] . " '> " .
" <input type='hidden' name='itemtype' value=' " . $_REQUEST [ 'itemtype' ] . " '> " .
" <input type='hidden' name='cases_id' value=' " . $_REQUEST [ 'cases_id' ] . " '> " .
" <input type='hidden' name='delIndex' value=' " . $_REQUEST [ 'delIndex' ] . " '> " .
" <input type='hidden' name='users_id' value=' " . $_REQUEST [ 'users_id' ] . " '> " .
" <input type='hidden' name='taskGuid' value=' " . $_REQUEST [ 'taskGuid' ] . " '> " .
" <input type='hidden' name='delThread' value=' " . $_REQUEST [ 'delThread' ] . " '> " .
" <input type='hidden' name='tasktype' value=' " . $_REQUEST [ 'tasktype' ] . " '> " .
" <input type='hidden' name='tasks_id' value=' " . $_REQUEST [ 'tasks_id' ] . " '> " ;
2019-01-14 16:19:24 +01:00
$PM_SOAP = new PluginProcessmakerProcessmaker ; // not used in this context, just here to define the type of $PM_SOAP
2017-05-06 18:38:24 +02:00
$PM_DB = new PluginProcessmakerDB ;
2015-10-09 14:13:52 +02:00
$rand = rand ();
echo " <form style='margin-bottom: 0px' name='processmaker_form_task $rand - " . $_REQUEST [ 'delIndex' ] . " ' id='processmaker_form_task $rand - " . $_REQUEST [ 'delIndex' ] . " ' method='post' action=' " . Toolbox :: getItemTypeFormURL ( " PluginProcessmakerProcessmaker " ) . " '> " ;
2018-08-02 16:57:00 +02:00
echo __ ( 'Re-assign task to' , 'processmaker' ) . " " ;
2020-10-07 15:40:05 +02:00
echo " <input type='hidden' name='action' value='reassign_reminder'> " ;
echo " <input type='hidden' name='comment' value=''> " ;
echo $commoninputs ;
$can_unclaim = false ; // by default
$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 ) {
$can_unclaim = true ;
}
2017-05-06 18:38:24 +02:00
2019-01-14 16:19:24 +01:00
PluginProcessmakerUser :: dropdown ( [ 'name' => 'users_id_recipient' ,
2020-10-07 15:40:05 +02:00
'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' ,
'rand' => $rand ,
'width' => '' ,
'specific_tags' => [ 'taskGuid' => $_REQUEST [ 'taskGuid' ]]
]);
2017-05-06 18:38:24 +02:00
echo " " ;
2020-10-07 15:40:05 +02:00
echo " <input type='submit' name='reassign $rand ' value=' " . __ ( 'Re-assign' , 'processmaker' ) . " ' class='submit'> " ;
echo " <input type='submit' name='reassign' value=' " . __ ( 'Re-assign' , 'processmaker' ) . " ' class='submit' style='display:none'> " ;
echo HTML :: scriptBlock ( "
$ ( function () {
// Dialog helpers
// Create the dialog with \"Re-assign\" button
function showCommentDlg ( title , content , alttext ) {
var dlgContents = {
title : title ,
modal : true ,
width : 'auto' ,
height : 'auto' ,
resizable : false ,
close : function ( event , ui ) {
$ ( this ) . dialog ( 'destroy' ) . remove ();
},
buttons : [{
text : alttext ,
id : 'submit$rand' ,
disabled : 'disabled' ,
click : function () {
$ ( '#processmaker_form_task$rand-".$_REQUEST[' delIndex ']." input[name=comment]' ) . val ( $ ( '#comment$rand' ) . val ());
//$('#processmaker_form_task$rand-".$_REQUEST['delIndex']."').submit();
$ ( 'input[name=reassign' ) . click ();
$ ( '#submit$rand' ) . button ( 'disable' );
}
}],
show : true ,
hide : true
}
$ ( '<div id=reassign$rand></div>' ) . appendTo ( $ ( '#processmaker_form_task$rand-".$_REQUEST[' delIndex ']."' ));
var locDlg = $ ( '#reassign$rand' ) . html ( content + '<p><textarea id=comment$rand rows=6 cols=60></textarea></p><font color=red>Input at least 10 words in English to justify.</font>' ) . dialog ( dlgContents );
$ ( '#comment$rand' ) . focus ();
$ ( '#comment$rand' ) . on ( 'keydown keyup' , function ( e ) {
if ( $ ( '#comment$rand' ) . val () . split ( / \W +/ ) . length > 10 ) {
$ ( '#submit$rand' ) . button ( 'enable' );
} else {
$ ( '#submit$rand' ) . button ( 'disable' );
}
});
2016-10-25 11:37:01 +02:00
2020-10-07 15:40:05 +02:00
return locDlg ;
};
$ ( 'input[name=reassign$rand]' ) . click ( function ( e ) {
e . preventDefault ();
if ( $ ( 'input[name=users_id]' ) . val () == $ ( 'input[name=users_id_recipient]' ) . val ()) {
// task is already assigned to this user
alert ( '".__(' Task is already assigned to this user or group ! ', ' processmaker ')."' , '".__(' Re - assign task ', ' processmaker ')."' );
} else if ( $ ( 'input[name=users_id_recipient]' ) . val () == 0 ) {
// un-claim
if ( " .( $can_unclaim ? 1 : 0). " && $ ( 'input[name=users_id]' ) . val () != 0 ) {
showCommentDlg ( '".__(' Un - claim task ', ' processmaker ')."' ,
'".__(' Please input reason to un - claim < br /> ( task will be re - assigned to former group ) : ', ' processmaker ')."' ,
'".__(' Un - claim ', ' processmaker ')."' );
} else {
// task can't be unclaim because it isn't SELF_SERVICE
alert ( '".__(' Can\\\ 't un-assign Task!' , 'processmaker' ) . " ', ' " . __ ( 'Un-claim task' , 'processmaker' ) . " ');
}
} else {
showCommentDlg ( '".__(' Re - assign task ', ' processmaker ')."' ,
'".__(' Please input reason to re - assign : ', ' processmaker ')."' ,
'".__(' Re - assign ', ' processmaker ')."' );
}
return false ;
});
})
" );
if ( Session :: getLoginUserID () != $_REQUEST [ 'users_id' ]) {
echo " " ;
echo " <input type='submit' name='reminder' value=' " . __ ( 'Send reminder' , 'processmaker' ) . " ' class='submit'> " ;
}
Html :: closeForm ( true );