diff --git a/front/processmaker.form.php b/front/processmaker.form.php index 533f23a..fab2cd0 100644 --- a/front/processmaker.form.php +++ b/front/processmaker.form.php @@ -27,6 +27,7 @@ switch ($_POST["action"]) { $resultCase = $myProcessMaker->newCase( $_POST['plugin_processmaker_process_id'], array( 'GLPI_ITEM_CAN_BE_SOLVED' => 0, 'GLPI_SELFSERVICE_CREATED' => '1', + 'GLPI_ITEM_TYPE' => 'Ticket', 'GLPI_URL' => $CFG_GLPI['url_base'].$CFG_GLPI['root_doc']) ); if ($resultCase->status_code == 0) { // case is created diff --git a/inc/processmaker.class.php b/inc/processmaker.class.php index 913713d..3b12294 100644 --- a/inc/processmaker.class.php +++ b/inc/processmaker.class.php @@ -1062,7 +1062,7 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { } } - + /** * summary of cronPMUsers @@ -1314,8 +1314,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { if (isset($parm->input['processmaker_caseid'])) { // a case is already started for this ticket, then bind them together - $itemType = $parm->getType(); //$myCase->getField('itemtype'); - $itemId = $parm->fields['id']; //$myCase->getField('items_id'); + $itemType = $parm->getType(); + $itemId = $parm->fields['id']; $caseId = $parm->input['processmaker_caseid']; $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 // this is due for traceability only $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 $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! $glpi_item = getItemForItemtype( $itemType ); $glpi_item->getFromDB( $itemId ); - $user_entities = Profile_User::getUserEntities( $techId, true, true ); - $user_can_view = in_array( $glpi_item->fields['entities_id'], $user_entities ); + //$user_entities = Profile_User::getUserEntities( $techId, true, true ); + //$user_can_view = in_array( $glpi_item->fields['entities_id'], $user_entities ); if (!$glpi_item->isUser( CommonITILActor::REQUESTER, $techId ) && !$glpi_item->isUser( CommonITILActor::OBSERVER, $techId ) - && !$glpi_item->isUser( CommonITILActor::ASSIGN, $techId ) - && !$user_can_view ) { + && !$glpi_item->isUser( CommonITILActor::ASSIGN, $techId ) ) { + //&& !$user_can_view ) { // then we must add this tech user to watcher list $glpi_item_user = getItemForItemtype( $glpi_item->getType() . "_User" ); $donotif = $CFG_GLPI["use_mailing"]; @@ -1667,8 +1672,8 @@ class PluginProcessmakerProcessmaker extends CommonDBTM { /** * Summary of computeTaskDuration - * @param mixed $task - * @param mixed $entity + * @param mixed $task + * @param mixed $entity * @return mixed */ function computeTaskDuration( $task, $entity ) { diff --git a/js/cases.helpdesk.js b/js/cases.helpdesk.js index 612f28a..47fecb5 100644 --- a/js/cases.helpdesk.js +++ b/js/cases.helpdesk.js @@ -5,14 +5,22 @@ var caseIFrame; function onClickContinue(obj) { //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) { oldHandler(obj.target); } // hide the iFrame caseIFrame.style.visibility = 'hidden'; - // call new handler + // trigger a click on the 'add' button of the ticket submitButton.click(); } @@ -34,11 +42,10 @@ function bGLPIHideElement(eltList, attribute, value) { function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) { var caseTimerCounter = 0; var redimIFrame = false; - //var bAreaUseRequestSumUp = false; var bButtonContinue = false; var caseTimer = window.setInterval(function () { //debugger ; - // look for frmDerivation form + // look for caseiframe iFrame caseIFrame = document.getElementById('caseiframe'); @@ -50,15 +57,8 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) { } if (caseIFrame != undefined && contentDocument) { var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]'); - var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]'); 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) { 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 @@ -84,13 +84,17 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) { } - // try to redim caseIFrame + // try to redim caseIFrame if (!redimIFrame) { + redimIFrame = true; // to prevent several timer creation + + // redim one time redimTaskFrame(caseIFrame); + + // redim each second var redimFrameTimer = window.setInterval(function () { redimTaskFrame(caseIFrame); }, 1000); - redimIFrame = true; } } diff --git a/processmaker.xml b/processmaker.xml index d5e0875..b4934f8 100644 --- a/processmaker.xml +++ b/processmaker.xml @@ -23,7 +23,7 @@ - 3.1.5 + 3.1.6 9.1 diff --git a/importUsersGLPI2PM.php b/scripts/importUsersGLPI2PM.php similarity index 95% rename from importUsersGLPI2PM.php rename to scripts/importUsersGLPI2PM.php index 5cd6008..a3e52e2 100644 --- a/importUsersGLPI2PM.php +++ b/scripts/importUsersGLPI2PM.php @@ -12,7 +12,7 @@ chdir(dirname($_SERVER["SCRIPT_FILENAME"])); define('DO_NOT_CHECK_HTTP_REFERER', 1); -define('GLPI_ROOT', '../..'); +define('GLPI_ROOT', '../../..'); include (GLPI_ROOT . "/inc/includes.php"); include_once 'inc/processmaker.class.php' ; diff --git a/setup.php b/setup.php index bca8ca7..c53600b 100644 --- a/setup.php +++ b/setup.php @@ -100,7 +100,7 @@ function plugin_version_processmaker() { global $LANG; return array ('name' => 'Process Maker', - 'version' => '3.1.5', + 'version' => '3.1.6', 'author' => 'Olivier Moron', 'homepage' => '', 'minGlpiVersion' => '9.1');