Added GLPI_TICKET_ID to case after ticket creation via simplified interface

Added GLPI_ITEM_TYPE to case at ticket creation via simplified interface
Fixed problem of ticket text in simplified interface
Fixed problem of viewing pm task when task is too high in simplified interface
Created scripts folder and moved importUsersGLPI2PM.php into it
Set version to 3.1.6
This commit is contained in:
tomolimo
2017-09-01 10:47:29 +02:00
parent 1a29ccc1c6
commit 8168c7a8ed
6 changed files with 36 additions and 26 deletions

View File

@@ -27,6 +27,7 @@ switch ($_POST["action"]) {
$resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], $resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'],
array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0, array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0,
'GLPI_SELFSERVICE_CREATED' => '1', 'GLPI_SELFSERVICE_CREATED' => '1',
'GLPI_ITEM_TYPE' => 'Ticket',
'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) ); 'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) );
if ($resultCase->status_code == 0) { if ($resultCase->status_code == 0) {
// case is created // case is created

View File

@@ -1062,7 +1062,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
} }
} }
/** /**
* summary of cronPMUsers * summary of cronPMUsers
@@ -1314,8 +1314,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
if (isset($parm->input['processmaker_caseid'])) { if (isset($parm->input['processmaker_caseid'])) {
// a case is already started for this ticket, then bind them together // a case is already started for this ticket, then bind them together
$itemType = $parm->getType(); //$myCase->getField('itemtype'); $itemType = $parm->getType();
$itemId = $parm->fields['id']; //$myCase->getField('items_id'); $itemId = $parm->fields['id'];
$caseId = $parm->input['processmaker_caseid']; $caseId = $parm->input['processmaker_caseid'];
$myCase = new PluginProcessmakerCase; $myCase = new PluginProcessmakerCase;
@@ -1336,6 +1336,11 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// here we create a fake task that will be used to store the creator of the case // here we create a fake task that will be used to store the creator of the case
// this is due for traceability only // this is due for traceability only
$myProcessMaker->add1stTask( $myCase->fields['itemtype'], $myCase->fields['items_id'], $caseInfo, array( 'notif' => false) ); // no notif $myProcessMaker->add1stTask( $myCase->fields['itemtype'], $myCase->fields['items_id'], $caseInfo, array( 'notif' => false) ); // no notif
// before routing, send items_id and itemtype
// as this information was not available at case creation
$resultSave = $myProcessMaker->sendVariables( $myCase->getID(), array( "GLPI_TICKET_ID" => $itemId ) );
// route case // route case
$pmRouteCaseResponse = $myProcessMaker->routeCase( $myCase->getID(), $parm->input['processmaker_delindex'] ); $pmRouteCaseResponse = $myProcessMaker->routeCase( $myCase->getID(), $parm->input['processmaker_delindex'] );
@@ -1440,12 +1445,12 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
// then we should check if this user has rights on the item, if not then we must add it to the watcher list! // then we should check if this user has rights on the item, if not then we must add it to the watcher list!
$glpi_item = getItemForItemtype( $itemType ); $glpi_item = getItemForItemtype( $itemType );
$glpi_item->getFromDB( $itemId ); $glpi_item->getFromDB( $itemId );
$user_entities = Profile_User::getUserEntities( $techId, true, true ); //$user_entities = Profile_User::getUserEntities( $techId, true, true );
$user_can_view = in_array( $glpi_item->fields['entities_id'], $user_entities ); //$user_can_view = in_array( $glpi_item->fields['entities_id'], $user_entities );
if (!$glpi_item->isUser( CommonITILActor::REQUESTER, $techId ) if (!$glpi_item->isUser( CommonITILActor::REQUESTER, $techId )
&& !$glpi_item->isUser( CommonITILActor::OBSERVER, $techId ) && !$glpi_item->isUser( CommonITILActor::OBSERVER, $techId )
&& !$glpi_item->isUser( CommonITILActor::ASSIGN, $techId ) && !$glpi_item->isUser( CommonITILActor::ASSIGN, $techId ) ) {
&& !$user_can_view ) { //&& !$user_can_view ) {
// then we must add this tech user to watcher list // then we must add this tech user to watcher list
$glpi_item_user = getItemForItemtype( $glpi_item->getType() . "_User" ); $glpi_item_user = getItemForItemtype( $glpi_item->getType() . "_User" );
$donotif = $CFG_GLPI["use_mailing"]; $donotif = $CFG_GLPI["use_mailing"];
@@ -1667,8 +1672,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM {
/** /**
* Summary of computeTaskDuration * Summary of computeTaskDuration
* @param mixed $task * @param mixed $task
* @param mixed $entity * @param mixed $entity
* @return mixed * @return mixed
*/ */
function computeTaskDuration( $task, $entity ) { function computeTaskDuration( $task, $entity ) {

View File

@@ -5,14 +5,22 @@ var caseIFrame;
function onClickContinue(obj) { function onClickContinue(obj) {
//debugger; //debugger;
// call old handler contentDocument = caseIFrame.contentDocument;
var txtAreaUserRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
if (txtAreaUserRequestSumUp) {
$("textarea[name='content']").val($(txtAreaUserRequestSumUp).val());
} else {
$("textarea[name='content']").val('_');
}
// call old handler if any
if (obj != undefined && oldHandler) { if (obj != undefined && oldHandler) {
oldHandler(obj.target); oldHandler(obj.target);
} }
// hide the iFrame // hide the iFrame
caseIFrame.style.visibility = 'hidden'; caseIFrame.style.visibility = 'hidden';
// call new handler // trigger a click on the 'add' button of the ticket
submitButton.click(); submitButton.click();
} }
@@ -34,11 +42,10 @@ function bGLPIHideElement(eltList, attribute, value) {
function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) { function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
var caseTimerCounter = 0; var caseTimerCounter = 0;
var redimIFrame = false; var redimIFrame = false;
//var bAreaUseRequestSumUp = false;
var bButtonContinue = false; var bButtonContinue = false;
var caseTimer = window.setInterval(function () { var caseTimer = window.setInterval(function () {
//debugger ; //debugger ;
// look for frmDerivation form // look for caseiframe iFrame
caseIFrame = document.getElementById('caseiframe'); caseIFrame = document.getElementById('caseiframe');
@@ -50,15 +57,8 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
} }
if (caseIFrame != undefined && contentDocument) { if (caseIFrame != undefined && contentDocument) {
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]'); var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
var linkList = contentDocument.getElementsByTagName('a'); var linkList = contentDocument.getElementsByTagName('a');
if (txtAreaUseRequestSumUp != undefined) {
//debugger;
$("textarea[name='content']")[0].value = txtAreaUseRequestSumUp.value;
} else {
$("textarea[name='content']")[0].value = '_';
}
if (!bButtonContinue && buttonContinue != undefined && linkList != undefined && linkList.length > 0) { if (!bButtonContinue && buttonContinue != undefined && linkList != undefined && linkList.length > 0) {
bButtonContinue = true; //window.clearInterval(caseTimer); // to be sure that it will be done only one time bButtonContinue = true; //window.clearInterval(caseTimer); // to be sure that it will be done only one time
// change action for the attached form and add some parameters // change action for the attached form and add some parameters
@@ -84,13 +84,17 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
} }
// try to redim caseIFrame // try to redim caseIFrame
if (!redimIFrame) { if (!redimIFrame) {
redimIFrame = true; // to prevent several timer creation
// redim one time
redimTaskFrame(caseIFrame); redimTaskFrame(caseIFrame);
// redim each second
var redimFrameTimer = window.setInterval(function () { var redimFrameTimer = window.setInterval(function () {
redimTaskFrame(caseIFrame); redimTaskFrame(caseIFrame);
}, 1000); }, 1000);
redimIFrame = true;
} }
} }

View File

@@ -23,7 +23,7 @@
</authors> </authors>
<versions> <versions>
<version> <version>
<num>3.1.5</num> <num>3.1.6</num>
<compatibility>9.1</compatibility> <compatibility>9.1</compatibility>
</version> </version>
</versions> </versions>

View File

@@ -12,7 +12,7 @@
chdir(dirname($_SERVER["SCRIPT_FILENAME"])); chdir(dirname($_SERVER["SCRIPT_FILENAME"]));
define('DO_NOT_CHECK_HTTP_REFERER', 1); define('DO_NOT_CHECK_HTTP_REFERER', 1);
define('GLPI_ROOT', '../..'); define('GLPI_ROOT', '../../..');
include (GLPI_ROOT . "/inc/includes.php"); include (GLPI_ROOT . "/inc/includes.php");
include_once 'inc/processmaker.class.php' ; include_once 'inc/processmaker.class.php' ;

View File

@@ -100,7 +100,7 @@ function plugin_version_processmaker() {
global $LANG; global $LANG;
return array ('name' => 'Process Maker', return array ('name' => 'Process Maker',
'version' => '3.1.5', 'version' => '3.1.6',
'author' => 'Olivier Moron', 'author' => 'Olivier Moron',
'homepage' => '', 'homepage' => '',
'minGlpiVersion' => '9.1'); 'minGlpiVersion' => '9.1');