1
0
Fork 0
cl-workflow/includes/include.workflow_steps.php

399 Zeilen
15 KiB
PHP

2019-11-04 15:22:11 +00:00
<?php
2020-08-20 16:30:16 +00:00
2019-11-04 15:22:11 +00:00
/**
* Project:
* Contenido Content Management System
*
* Description:
* Class for workflow allocation management
*
* Requirements:
* @con_php_req 5.0
*
*
* @package Contenido Backend classes
* @version 1.0
* @author Unknwon
* @copyright four for business AG <www.4fb.de>
* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
*
* @modified 2008-12-05 Andreas Lindner, make select box values for time unit selection language independent
* {@internal
* created
*
* $Id: include.workflow_steps.php 128 2019-07-03 11:58:28Z oldperl $:
* }}
*
*/
2020-08-20 16:30:16 +00:00
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
2019-11-04 15:22:11 +00:00
}
cInclude("includes", "functions.encoding.php");
$iIdMarked = (int) $_GET['idworkflowitem'];
2020-08-20 16:30:16 +00:00
$availableWorkflowActions = WorkflowActions :: getAvailableWorkflowActions();
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$sCurrentEncoding = getEncodingByLanguage($db, $lang, $cfg);
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
if (clHtmlEntities($adduser, ENT_COMPAT, $sCurrentEncoding) == i18n("Add User", "cl-workflow")) {
$action = "workflow_create_user";
2019-11-04 15:22:11 +00:00
}
/* Function: Move step up */
if ($action == "workflow_step_up") {
2020-08-20 16:30:16 +00:00
$workflowitems = new WorkflowItems;
$workflowitems->swap($idworkflow, $position, $position - 1);
2019-11-04 15:22:11 +00:00
}
/* Function: Move step down */
if ($action == "workflow_step_down") {
2020-08-20 16:30:16 +00:00
$workflowitems = new WorkflowItems;
$workflowitems->swap($idworkflow, $position, $position + 1);
2019-11-04 15:22:11 +00:00
}
/* Function: Move user up */
if ($action == "workflow_user_up") {
2020-08-20 16:30:16 +00:00
$workflowitems = new WorkflowUserSequences;
$workflowitems->swap($idworkflowitem, $position, $position - 1);
2019-11-04 15:22:11 +00:00
}
/* Function: Move step down */
if ($action == "workflow_user_down") {
2020-08-20 16:30:16 +00:00
$workflowitems = new WorkflowUserSequences;
$workflowitems->swap($idworkflowitem, $position, $position + 1);
2019-11-04 15:22:11 +00:00
}
/* Function: Create new step */
if ($action == "workflow_create_step") {
2020-08-20 16:30:16 +00:00
$workflowitems = new WorkflowItems;
$item = $workflowitems->create($idworkflow);
$item->set("name", i18n("New Workflow Step", "cl-workflow"));
$item->store();
$idworkflowitem = $item->get("idworkflowitem");
2019-11-04 15:22:11 +00:00
}
/* Function: Delete step */
if ($action == "workflow_step_delete") {
2020-08-20 16:30:16 +00:00
$workflowitems = new WorkflowItems;
$workflowitems->delete($idworkflowitem);
2019-11-04 15:22:11 +00:00
}
/* Function: Add user */
if ($action == "workflow_create_user") {
2020-08-20 16:30:16 +00:00
$workflowusers = new WorkflowUserSequences;
$new = $workflowusers->create($idworkflowitem);
2019-11-04 15:22:11 +00:00
}
/* Function: Remove user */
if ($action == "workflow_user_delete") {
2020-08-20 16:30:16 +00:00
$workflowusers = new WorkflowUserSequences;
$workflowusers->delete($idusersequence);
2019-11-04 15:22:11 +00:00
}
/* Function: Save step */
if ($action == "workflow_save_step" || $action == "workflow_create_user") {
2020-08-20 16:30:16 +00:00
$workflowactions = new WorkflowActions;
foreach ($availableWorkflowActions as $key => $value) {
if ($wfactions[$key] == 1) {
$workflowactions->set($idworkflowitem, $key);
} else {
$workflowactions->remove($idworkflowitem, $key);
}
}
$workflowitem = new WorkflowItem;
$workflowitem->loadByPrimaryKey($idworkflowitem);
$workflowitem->setField('idtask', $wftaskselect);
$workflowitem->setField('name', $wfstepname);
$workflowitem->setField('description', $wfstepdescription);
$workflowitem->store();
$usersequences = new WorkflowUserSequences;
$usersequences->select("idworkflowitem = '$idworkflowitem'");
while ($usersequence = $usersequences->next()) {
$wftime = "time" . $usersequence->get("idusersequence");
$wfuser = "user" . $usersequence->get("idusersequence");
$wftimelimit = "wftimelimit" . $usersequence->get("idusersequence");
$usersequence->set("timeunit", $$wftime);
$usersequence->set("iduser", $$wfuser);
$usersequence->set("timelimit", $$wftimelimit);
$usersequence->set("emailnoti", $wfemailnoti[$usersequence->get("idusersequence")]);
$usersequence->set("escalationnoti", $wfescalnoti[$usersequence->get("idusersequence")]);
$usersequence->store();
}
2019-11-04 15:22:11 +00:00
}
function getTimeUnitSelector($listid, $default) {
2020-08-20 16:30:16 +00:00
global $idclient, $cfg, $auth;
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$timeunits = array();
$timeunits['Seconds'] = i18n("Seconds", "cl-workflow");
$timeunits['Minutes'] = i18n("Minutes", "cl-workflow");
$timeunits['Hours'] = i18n("Hours", "cl-workflow");
$timeunits['Days'] = i18n("Days", "cl-workflow");
$timeunits['Weeks'] = i18n("Weeks", "cl-workflow");
$timeunits['Months'] = i18n("Months", "cl-workflow");
$timeunits['Years'] = i18n("Years", "cl-workflow");
2019-11-04 15:22:11 +00:00
2021-08-23 13:57:01 +00:00
$tpl2 = new Template();
2020-08-20 16:30:16 +00:00
$tpl2->set('s', 'NAME', 'time' . $listid);
$tpl2->set('s', 'CLASS', 'text_small');
$tpl2->set('s', 'OPTIONS', 'size=1');
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
foreach ($timeunits as $key => $value) {
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$tpl2->set('d', 'VALUE', $key);
$tpl2->set('d', 'CAPTION', $value);
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
if ($default == $key) {
$tpl2->set('d', 'SELECTED', 'SELECTED');
} else {
$tpl2->set('d', 'SELECTED', '');
}
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$tpl2->next();
}
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
return $tpl2->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true);
2019-11-04 15:22:11 +00:00
}
function getWorkflowList() {
2020-08-20 16:30:16 +00:00
global $idworkflow, $cfg;
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$ui = new UI_Menu;
$workflowitems = new WorkflowItems;
$workflowitems->select("idworkflow = '$idworkflow'", "", "position ASC");
while ($workflowitem = $workflowitems->next()) {
$pos = $workflowitem->get("position");
$name = $workflowitem->get("name");
$id = $workflowitem->get("idworkflowitem");
$edititem = new Link;
$edititem->setCLink("workflow_steps", 4, "workflow_step_edit");
$edititem->setCustom("idworkflowitem", $id);
$edititem->setCustom("idworkflow", $idworkflow);
$moveup = new Link;
$moveup->setCLink("workflow_steps", 4, "workflow_step_up");
$moveup->setCustom("idworkflowitem", $id);
$moveup->setCustom("idworkflow", $idworkflow);
$moveup->setCustom("position", $pos);
$moveup->setAlt(i18n("Move step up", "cl-workflow"));
2021-08-23 13:57:01 +00:00
$moveup->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/no_verschieben.gif" . '">');
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$movedown = new Link;
$movedown->setCLink("workflow_steps", 4, "workflow_step_down");
$movedown->setCustom("idworkflowitem", $id);
$movedown->setCustom("idworkflow", $idworkflow);
$movedown->setCustom("position", $pos);
$movedown->setAlt(i18n("Move step down", "cl-workflow"));
2021-08-23 13:57:01 +00:00
$movedown->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/nu_verschieben.gif" . '">');
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$deletestep = new Link;
$deletestep->setCLink("workflow_steps", 4, "workflow_step_delete");
$deletestep->setCustom("idworkflowitem", $id);
$deletestep->setCustom("idworkflow", $idworkflow);
$deletestep->setCustom("position", $pos);
$deletestep->setAlt(i18n("Delete step", "cl-workflow"));
2021-08-23 13:57:01 +00:00
$deletestep->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/workflow_step_delete.gif" . '">');
2020-08-20 16:30:16 +00:00
$ui->setTitle($id, "$pos. $name");
$ui->setLink($id, $edititem);
if ($pos > 1) {
$ui->setActions($id, "moveup", $moveup->render());
} else {
$ui->setActions($id, "moveup", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
}
if ($pos < $workflowitems->count()) {
$ui->setActions($id, "movedown", $movedown->render());
} else {
$ui->setActions($id, "movedown", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
}
$ui->setActions($id, "delete", $deletestep->render());
if ($_GET['idworkflowitem'] == $id) {
$ui->setExtra($id, 'id="marked" ');
}
}
$content = $ui->render(false);
return ($content);
}
function createNewWorkflow() {
global $idworkflow, $cfg;
$content = "";
$ui = new UI_Menu;
$rowmark = false;
$createstep = new Link;
$createstep->setCLink("workflow_steps", 4, "workflow_create_step");
$createstep->setCustom("idworkflow", $idworkflow);
#$ui->setLink("spacer", NULL);
$ui->setTitle("create", i18n("Create new step", "cl-workflow"));
2021-08-23 13:57:01 +00:00
$ui->setImage("create", $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/workflow_step_new.gif");
2020-08-20 16:30:16 +00:00
$ui->setLink("create", $createstep);
$ui->setRowmark($rowmark);
$ui->setBgColor("create", $cfg['color']['table_header']);
$content = $ui->render(false);
return $content;
2019-11-04 15:22:11 +00:00
}
function editWorkflowStep($idworkflowitem) {
2020-08-20 16:30:16 +00:00
global $area, $idworkflow, $idworkflowitem, $frame, $availableWorkflowActions;
global $notification;
$workflowitem = new WorkflowItem;
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
if ($workflowitem->loadByPrimaryKey($idworkflowitem) == false) {
return "&nbsp;";
}
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$workflowactions = new WorkflowActions;
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$stepname = $workflowitem->get("name");
$stepdescription = $workflowitem->get("description");
$id = $workflowitem->get("idworkflowitem");
$task = $workflowitem->get("idtask");
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$form = new UI_Table_Form("workflow_edit");
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$form->setVar("area", $area);
$form->setVar("action", "workflow_save_step");
$form->setVar("idworkflow", $idworkflow);
$form->setVar("idworkflowitem", $idworkflowitem);
$form->setVar("frame", $frame);
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$form->addHeader(i18n("Edit workflow step", "cl-workflow"));
$form->add(i18n("Step name", "cl-workflow"), formGenerateField("text", "wfstepname", $stepname, 40, 255));
$form->add(i18n("Step description", "cl-workflow"), formGenerateField("textbox", "wfstepdescription", $stepdescription, 60, 10));
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
foreach ($availableWorkflowActions as $key => $value) {
$actions .= formGenerateCheckbox("wfactions[" . $key . "]", "1", $workflowactions->get($id, $key)) . '<label for="wfactions[' . $key . ']1">' . $value . '</label>' . "<br>";
}
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$form->add(i18n("Actions", "cl-workflow"), $actions);
$form->add(i18n("Assigned users", "cl-workflow"), getWorkflowUsers($idworkflowitem));
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
return $form->render(true);
2019-11-04 15:22:11 +00:00
}
function getWorkflowUsers($idworkflowitem) {
2020-08-20 16:30:16 +00:00
global $idworkflow, $cfg;
$ui = new UI_Menu;
$workflowusers = new WorkflowUserSequences;
$workflowusers->select("idworkflowitem = '$idworkflowitem'", "", "position ASC");
while ($workflowitem = $workflowusers->next()) {
$pos = $workflowitem->get("position");
$iduser = $workflowitem->get("iduser");
$timelimit = $workflowitem->get("timelimit");
$timeunit = $workflowitem->get("timeunit");
$email = $workflowitem->get("emailnoti");
$escalation = $workflowitem->get("escalationnoti");
$timeunit = $workflowitem->get("timeunit");
$id = $workflowitem->get("idusersequence");
$moveup = new Link;
$moveup->setCLink("workflow_steps", 4, "workflow_user_up");
$moveup->setCustom("idworkflowitem", $idworkflowitem);
$moveup->setCustom("idworkflow", $idworkflow);
$moveup->setCustom("position", $pos);
$moveup->setAlt(i18n("Move user up", "cl-workflow"));
#$moveup->setContent('<img border="0" style="padding-left: 2px" src="images/pfeil_hoch.gif">');
2021-08-23 13:57:01 +00:00
$moveup->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/no_verschieben.gif" . '">');
2020-08-20 16:30:16 +00:00
$movedown = new Link;
$movedown->setCLink("workflow_steps", 4, "workflow_user_down");
$movedown->setCustom("idworkflowitem", $idworkflowitem);
$movedown->setCustom("idworkflow", $idworkflow);
$movedown->setCustom("position", $pos);
$movedown->setAlt(i18n("Move user down", "cl-workflow"));
2021-08-23 13:57:01 +00:00
$movedown->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/nu_verschieben.gif" . '">');
2020-08-20 16:30:16 +00:00
$deletestep = new Link;
$deletestep->setCLink("workflow_steps", 4, "workflow_user_delete");
$deletestep->setCustom("idworkflowitem", $idworkflowitem);
$deletestep->setCustom("idworkflow", $idworkflow);
$deletestep->setCustom("position", $pos);
$deletestep->setCustom("idusersequence", $id);
$deletestep->setAlt(i18n("Delete user", "cl-workflow"));
2021-08-23 13:57:01 +00:00
$deletestep->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/workflow_step_delete.gif" . '">');
2020-08-20 16:30:16 +00:00
$title = "$pos. " . getUsers($id, $iduser);
$title .= formGenerateField("text", "wftimelimit" . $id, $timelimit, 3, 6);
$title .= getTimeUnitSelector($id, $timeunit);
$altmail = i18n("Notify this user via E-Mail", "cl-workflow");
$altnoti = i18n("Escalate to this user via E-Mail", "cl-workflow");
2021-08-23 13:57:01 +00:00
$title .= formGenerateCheckbox("wfemailnoti[" . $id . "]", "1", $email) . '<label for="wfemailnoti[' . $id . ']1"><img alt="' . $altmail . '" title="' . $altmail . '" style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/workflow_email_noti.gif" . '"></label>';
$title .= formGenerateCheckbox("wfescalnoti[" . $id . "]", "1", $escalation) . '<label for="wfescalnoti[' . $id . ']1"><img alt="' . $altnoti . '" title="' . $altnoti . '" style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/workflow_escal_noti.gif" . '"></label>';
2020-08-20 16:30:16 +00:00
$ui->setTitle($id, $title);
$ui->setLink($id, NULL);
if ($pos > 1) {
$ui->setActions($id, "moveup", $moveup->render());
} else {
$ui->setActions($id, "moveup", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
}
if ($pos < $workflowusers->count()) {
$ui->setActions($id, "movedown", $movedown->render());
} else {
$ui->setActions($id, "movedown", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
}
$ui->setActions($id, "delete", $deletestep->render());
2021-08-23 13:57:01 +00:00
$ui->setImage($id, $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "cl-workflow/images/workflow_user.gif");
2020-08-20 16:30:16 +00:00
}
$createstep = new Link;
$createstep->setCLink("workflow_steps", 4, "workflow_create_user");
$createstep->setCustom("idworkflow", $idworkflow);
$createstep->setCustom("idworkflowitem", $idworkflowitem);
$ui->setLink("spacer", NULL);
$ui->setTitle("create", '<input class="text_medium" type="submit" name="adduser" value="' . i18n("Add User", "cl-workflow") . '">');
$ui->setLink("create", NULL);
$content = $ui->render(false);
return ($content);
2019-11-04 15:22:11 +00:00
}
2021-08-23 13:57:01 +00:00
$tpl = new Template();
$tpl->setDomain('cl-workflow');
2019-11-04 15:22:11 +00:00
$tpl->set('s', 'NEW', createNewWorkflow());
$tpl->set('s', 'STEPS', getWorkflowList());
$tpl->set('s', 'EDITSTEP', editWorkflowStep($idworkflowitem));
$tpl->set('s', 'BORDERCOLOR', $cfg["color"]["table_border"]);
2021-08-23 13:57:01 +00:00
$frame = $tpl->generate($cfg["path"]["contenido"] . $cfg["path"]["plugins"] . "cl-workflow/templates/template.workflow_steps.html", true);
2019-11-04 15:22:11 +00:00
2020-08-20 16:30:16 +00:00
$page = new UI_Page;
2019-11-04 15:22:11 +00:00
$page->setContent($frame);
$page->render();