Added a flag on tasks to be able to view active tasks
Added task deletion when they are not yet used and are deleted from PM Fixed also issue on quote for process main taskcategory Fixed issue GATEWAYTOGATEWAY: no longer import these as if they were tasks
This commit is contained in:
7
hook.php
7
hook.php
@@ -331,6 +331,7 @@ function plugin_processmaker_install() {
|
|||||||
`pm_task_guid` VARCHAR(32) NOT NULL,
|
`pm_task_guid` VARCHAR(32) NOT NULL,
|
||||||
`taskcategories_id` INT(11) NOT NULL,
|
`taskcategories_id` INT(11) NOT NULL,
|
||||||
`start` BIT(1) NOT NULL DEFAULT b'0',
|
`start` BIT(1) NOT NULL DEFAULT b'0',
|
||||||
|
`is_active` TINYINT(1) NOT NULL DEFAULT '1',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE INDEX `pm_task_guid` (`pm_task_guid`),
|
UNIQUE INDEX `pm_task_guid` (`pm_task_guid`),
|
||||||
UNIQUE INDEX `items` (`taskcategories_id`),
|
UNIQUE INDEX `items` (`taskcategories_id`),
|
||||||
@@ -342,8 +343,14 @@ function plugin_processmaker_install() {
|
|||||||
";
|
";
|
||||||
|
|
||||||
$DB->query($query) or die("error creating glpi_plugin_processmaker_taskcategories" . $DB->error());
|
$DB->query($query) or die("error creating glpi_plugin_processmaker_taskcategories" . $DB->error());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FieldExists('glpi_plugin_processmaker_taskcategories', 'is_active')) {
|
||||||
|
$query = "ALTER TABLE `glpi_plugin_processmaker_taskcategories`
|
||||||
|
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `start`;" ;
|
||||||
|
$DB->query($query) or die("error adding field is_active to glpi_plugin_processmaker_taskcategories table" . $DB->error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$DB->TableExists("glpi_plugin_processmaker_crontaskactions")) {
|
if (!$DB->TableExists("glpi_plugin_processmaker_crontaskactions")) {
|
||||||
$query = "CREATE TABLE `glpi_plugin_processmaker_crontaskactions` (
|
$query = "CREATE TABLE `glpi_plugin_processmaker_crontaskactions` (
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
$lang = locale_get_primary_language( $CFG_GLPI['language'] );
|
$lang = locale_get_primary_language( $CFG_GLPI['language'] );
|
||||||
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
|
$query = "SELECT TASK.TAS_UID, TASK.TAS_START, CONTENT.CON_LANG, CONTENT.CON_CATEGORY, CONTENT.CON_VALUE FROM TASK
|
||||||
INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
|
INNER JOIN CONTENT ON CONTENT.CON_ID=TASK.TAS_UID
|
||||||
WHERE TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
|
WHERE TASK.TAS_TYPE = 'NORMAL' AND TASK.PRO_UID = '".$this->fields['process_guid']."' AND CONTENT.CON_CATEGORY IN ('TAS_TITLE', 'TAS_DESCRIPTION') ".($translates ? "" : " AND CONTENT.CON_LANG='$lang'")." ;";
|
||||||
$taskArray = array();
|
$taskArray = array();
|
||||||
$defaultLangTaskArray=array();
|
$defaultLangTaskArray=array();
|
||||||
foreach ($PM_DB->request( $query ) as $task) {
|
foreach ($PM_DB->request( $query ) as $task) {
|
||||||
@@ -84,6 +84,33 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pmtask = new PluginProcessmakerTaskCategory;
|
||||||
|
$currentasksinprocess = getAllDatasFromTable($pmtask->getTable(), 'is_active = 1 AND processes_id = '.$this->getID());
|
||||||
|
foreach($currentasksinprocess as $task){
|
||||||
|
$tasks[$task['pm_task_guid']] = $task;
|
||||||
|
}
|
||||||
|
$inactivetasks = array_diff_key($tasks, $defaultLangTaskArray);
|
||||||
|
foreach($inactivetasks as $taskkey => $task) {
|
||||||
|
// must verify if this taskcategory are used in a task somewhere
|
||||||
|
$objs = ['TicketTask', 'ProblemTask', 'ChangeTask'];
|
||||||
|
$countElt = 0 ;
|
||||||
|
foreach($objs as $obj) {
|
||||||
|
$countElt += countElementsInTable( getTableForItemType($obj), "taskcategories_id = ".$task['taskcategories_id'] );
|
||||||
|
if ($countElt != 0) {
|
||||||
|
// just set 'is_active' to 0
|
||||||
|
$pmtask->Update( array( 'id' => $task['id'], 'start' => 0, 'is_active' => 0 ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($countElt == 0) {
|
||||||
|
// purge this category as it is not used anywhere
|
||||||
|
$taskCat = new TaskCategory;
|
||||||
|
$taskCat->delete(array( 'id' => $task['taskcategories_id'] ), 1);
|
||||||
|
$pmTaskCat = new PluginProcessmakerTaskCategory;
|
||||||
|
$pmTaskCat->delete(array( 'id' => $task['id'] ), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($defaultLangTaskArray as $taskGUID => $task) {
|
foreach ($defaultLangTaskArray as $taskGUID => $task) {
|
||||||
$pmTaskCat = new PluginProcessmakerTaskCategory;
|
$pmTaskCat = new PluginProcessmakerTaskCategory;
|
||||||
$taskCat = new TaskCategory;
|
$taskCat = new TaskCategory;
|
||||||
@@ -108,7 +135,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
// taskcat must be created
|
// taskcat must be created
|
||||||
$taskCat->add( array( 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
|
$taskCat->add( array( 'is_recursive' => true, 'name' => $PM_DB->escape($task['TAS_TITLE']), 'comment' => $PM_DB->escape($task['TAS_DESCRIPTION']), 'taskcategories_id' => $this->fields['taskcategories_id'] ) );
|
||||||
// pmTaskCat must be created too
|
// pmTaskCat must be created too
|
||||||
$pmTaskCat->add( array( 'processes_id' => $this->getID(), 'pm_task_guid' => $taskGUID, 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'] ) );
|
$pmTaskCat->add( array( 'processes_id' => $this->getID(), 'pm_task_guid' => $taskGUID, 'taskcategories_id' => $taskCat->getID(), 'start' => $task['start'], 'is_active' => 1 ) );
|
||||||
}
|
}
|
||||||
// here we should take into account translations if any
|
// here we should take into account translations if any
|
||||||
if ($translates && isset($taskArray[ $taskGUID ])) {
|
if ($translates && isset($taskArray[ $taskGUID ])) {
|
||||||
@@ -150,6 +177,30 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepareInputForAdd($input){
|
||||||
|
global $PM_DB;
|
||||||
|
if (isset($input['name'])) {
|
||||||
|
$input['name'] = $PM_DB->escape($input['name']);
|
||||||
|
}
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareInputForUpdate($input){
|
||||||
|
global $PM_DB;
|
||||||
|
if (isset($input['name'])) {
|
||||||
|
$input['name'] = $PM_DB->escape($input['name']);
|
||||||
|
}
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
function post_addItem() {
|
||||||
|
$this->getFromDB($this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
function post_updateItem($history = 1) {
|
||||||
|
$this->getFromDB($this->getID());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary of refresh
|
* Summary of refresh
|
||||||
* used to refresh process list and task category list
|
* used to refresh process list and task category list
|
||||||
@@ -171,7 +222,7 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
if ($glpiprocess->getFromDBbyExternalID($process->guid)) {
|
if ($glpiprocess->getFromDBbyExternalID($process->guid)) {
|
||||||
// then update it only if name has changed
|
// then update it only if name has changed
|
||||||
if ($glpiprocess->fields['name'] != $process->name) {
|
if ($glpiprocess->fields['name'] != $process->name) {
|
||||||
$glpiprocess->update( array( 'id' => $glpiprocess->getID(), 'name' => $process->name ) );
|
$glpiprocess->update( array( 'id' => $glpiprocess->getID(), 'name' => $process->name) );
|
||||||
}
|
}
|
||||||
// and check if main task category needs update
|
// and check if main task category needs update
|
||||||
if (!$glpiprocess->fields['taskcategories_id']) {
|
if (!$glpiprocess->fields['taskcategories_id']) {
|
||||||
@@ -207,9 +258,10 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
* @return boolean true if update is done, false otherwise
|
* @return boolean true if update is done, false otherwise
|
||||||
*/
|
*/
|
||||||
function updateTaskCategory( $pmMainTaskCat ) {
|
function updateTaskCategory( $pmMainTaskCat ) {
|
||||||
|
global $PM_DB;
|
||||||
$taskCat = new TaskCategory;
|
$taskCat = new TaskCategory;
|
||||||
if ($taskCat->getFromDB( $this->fields['taskcategories_id'] ) && $taskCat->fields['name'] != $this->fields['name']) {
|
if ($taskCat->getFromDB( $this->fields['taskcategories_id'] ) && $taskCat->fields['name'] != $this->fields['name']) {
|
||||||
return $taskCat->update( array( 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name'] ) );
|
return $taskCat->update( array( 'id' => $taskCat->getID(), 'taskcategories_id' => $pmMainTaskCat, 'name' => $PM_DB->escape($this->fields['name'])) );
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -221,8 +273,9 @@ class PluginProcessmakerProcess extends CommonDBTM {
|
|||||||
* @return boolean true if TaskCategory has been created and updated into $this process, else otherwise
|
* @return boolean true if TaskCategory has been created and updated into $this process, else otherwise
|
||||||
*/
|
*/
|
||||||
function addTaskCategory( $pmMainTaskCat ) {
|
function addTaskCategory( $pmMainTaskCat ) {
|
||||||
|
global $PM_DB;
|
||||||
$taskCat = new TaskCategory;
|
$taskCat = new TaskCategory;
|
||||||
if ($taskCat->add( array( 'is_recursive' => true, 'taskcategories_id' => $pmMainTaskCat, 'name' => $this->fields['name']) )) {
|
if ($taskCat->add( array( 'is_recursive' => true, 'taskcategories_id' => $pmMainTaskCat, 'name' => $PM_DB->escape($this->fields['name'])) )) {
|
||||||
return $this->update( array( 'id' => $this->getID(), 'taskcategories_id' => $taskCat->getID() ) );
|
return $this->update( array( 'id' => $this->getID(), 'taskcategories_id' => $taskCat->getID() ) );
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,33 +25,54 @@ class PluginProcessmakerTaskCategory extends CommonDBTM
|
|||||||
|
|
||||||
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
|
||||||
|
|
||||||
global $LANG, $DB;
|
global $LANG, $DB, $CFG_GLPI;
|
||||||
|
|
||||||
self::title($item);
|
self::title($item);
|
||||||
|
|
||||||
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
|
echo "<div class='center'><br><table class='tab_cadre_fixehov'>";
|
||||||
echo "<tr><th colspan='5'>".$LANG['processmaker']['title'][3]."</th></tr>";
|
echo "<tr><th colspan='6'>".$LANG['processmaker']['title'][3]."</th></tr>";
|
||||||
echo "<tr><th>".$LANG['processmaker']['process']['taskcategories']['name']."</th>".
|
echo "<tr><th>".$LANG['processmaker']['process']['taskcategories']['name']."</th>".
|
||||||
"<th>".$LANG['processmaker']['process']['taskcategories']['completename']."</th>" .
|
"<th>".$LANG['processmaker']['process']['taskcategories']['completename']."</th>" .
|
||||||
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
|
|
||||||
"<th>".$LANG['processmaker']['process']['taskcategories']['start']."</th>" .
|
"<th>".$LANG['processmaker']['process']['taskcategories']['start']."</th>" .
|
||||||
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th></tr>";
|
"<th>".$LANG['processmaker']['process']['taskcategories']['guid']."</th>" .
|
||||||
|
"<th>".$LANG['processmaker']['process']['taskcategories']['comment']."</th>" .
|
||||||
|
"<th>".$LANG['processmaker']['process']['taskcategories']['is_active']."</th>" .
|
||||||
|
"</tr>";
|
||||||
|
|
||||||
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment` FROM glpi_plugin_processmaker_taskcategories AS pm
|
$query = "SELECT pm.pm_task_guid, pm.taskcategories_id, pm.`start`, gl.name, gl.completename, gl.`comment`, pm.is_active FROM glpi_plugin_processmaker_taskcategories AS pm
|
||||||
LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
|
LEFT JOIN glpi_taskcategories AS gl ON pm.taskcategories_id=gl.id
|
||||||
WHERE pm.processes_id=".$item->getID().";";
|
WHERE pm.processes_id=".$item->getID().";";
|
||||||
|
|
||||||
foreach ($DB->request($query) as $taskCat) {
|
foreach ($DB->request($query) as $taskCat) {
|
||||||
echo "<tr class='tab_bg_1'><td class='b'><a href='".
|
echo "<tr class='tab_bg_1'>";
|
||||||
|
|
||||||
|
echo "<td class='b'><a href='".
|
||||||
Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=".
|
Toolbox::getItemTypeFormURL( 'TaskCategory' )."?id=".
|
||||||
$taskCat['taskcategories_id']."'>".str_replace(" ", " ", $taskCat['name']);
|
$taskCat['taskcategories_id']."'>".str_replace(" ", " ", $taskCat['name']);
|
||||||
if ($_SESSION["glpiis_ids_visible"]) {
|
if ($_SESSION["glpiis_ids_visible"]) {
|
||||||
echo " (".$taskCat['taskcategories_id'].")";
|
echo " (".$taskCat['taskcategories_id'].")";
|
||||||
}
|
}
|
||||||
echo "</a></td><td >".str_replace(" ", " ", $taskCat['completename'])."</td>
|
echo "</a></td>";
|
||||||
<td >".$taskCat['pm_task_guid']."</td>".
|
|
||||||
"<td>".($taskCat['start']?'x':'')."</td><td >".
|
echo "<td >".str_replace(" ", " ", $taskCat['completename'])."</td>";
|
||||||
$taskCat['comment']."</td></tr>";
|
|
||||||
|
echo "<td class='center'>";
|
||||||
|
if ($taskCat['start']) {
|
||||||
|
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
|
||||||
|
$LANG['processmaker']['process']['taskcategories']['start']."\">";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
|
|
||||||
|
echo "<td >".$taskCat['pm_task_guid']."</td>";
|
||||||
|
|
||||||
|
echo "<td>".$taskCat['comment']."</td>";
|
||||||
|
|
||||||
|
echo "<td class='center'>";
|
||||||
|
if ($taskCat['is_active']) {
|
||||||
|
echo "<img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14' alt=\"".
|
||||||
|
$LANG['processmaker']['process']['taskcategories']['is_active']."\">";
|
||||||
|
}
|
||||||
|
echo "</td></tr>";
|
||||||
}
|
}
|
||||||
echo "</table></div>";
|
echo "</table></div>";
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ $LANG['processmaker']['process']['taskcategories']['name']="Task name";
|
|||||||
$LANG['processmaker']['process']['taskcategories']['completename']="Complete name";
|
$LANG['processmaker']['process']['taskcategories']['completename']="Complete name";
|
||||||
$LANG['processmaker']['process']['taskcategories']['start']="Start";
|
$LANG['processmaker']['process']['taskcategories']['start']="Start";
|
||||||
$LANG['processmaker']['process']['taskcategories']['comment']="Comment";
|
$LANG['processmaker']['process']['taskcategories']['comment']="Comment";
|
||||||
|
$LANG['processmaker']['process']['taskcategories']['is_active']="Active";
|
||||||
$LANG['processmaker']['process']['profile']="Delete permanently";
|
$LANG['processmaker']['process']['profile']="Delete permanently";
|
||||||
|
|
||||||
$LANG['processmaker']['config']['name']="Name";
|
$LANG['processmaker']['config']['name']="Name";
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ $LANG['processmaker']['process']['taskcategories']['name']="Nom de la Tâche";
|
|||||||
$LANG['processmaker']['process']['taskcategories']['completename']="Nom complet";
|
$LANG['processmaker']['process']['taskcategories']['completename']="Nom complet";
|
||||||
$LANG['processmaker']['process']['taskcategories']['start']="Début";
|
$LANG['processmaker']['process']['taskcategories']['start']="Début";
|
||||||
$LANG['processmaker']['process']['taskcategories']['comment']="Commentaire";
|
$LANG['processmaker']['process']['taskcategories']['comment']="Commentaire";
|
||||||
|
$LANG['processmaker']['process']['taskcategories']['is_active']="Active";
|
||||||
$LANG['processmaker']['process']['profile']="Effacer définitivement";
|
$LANG['processmaker']['process']['profile']="Effacer définitivement";
|
||||||
|
|
||||||
$LANG['processmaker']['config']['name']="Nom";
|
$LANG['processmaker']['config']['name']="Nom";
|
||||||
|
|||||||
Reference in New Issue
Block a user