seeddms-code/views/bootstrap/class.TriggerWorkflow.php

159 lines
5.6 KiB
PHP
Raw Normal View History

2013-01-24 10:35:33 +00:00
<?php
/**
* Implementation of TriggerWorkflow view
*
* @category DMS
* @package SeedDMS
2013-01-24 10:35:33 +00:00
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Include parent class
*/
//require_once("class.Bootstrap.php");
2013-01-24 10:35:33 +00:00
/**
* Class which outputs the html page for TriggerWorkflow view
*
* @category DMS
* @package SeedDMS
2013-01-24 10:35:33 +00:00
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_TriggerWorkflow extends SeedDMS_Theme_Style {
2013-01-24 10:35:33 +00:00
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
2021-11-08 11:26:13 +00:00
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
2013-01-24 10:35:33 +00:00
?>
$(document).ready(function() {
2021-11-08 11:26:13 +00:00
$("#form1").validate({
messages: {
comment: "<?php printMLText("js_no_comment");?>"
},
});
});
<?php
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
2021-08-20 09:00:51 +00:00
$accessobject = $this->params['accessobject'];
$document = $this->params['document'];
$transition = $this->params['transition'];
$latestContent = $document->getLatestContent();
2021-11-08 11:26:13 +00:00
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
$this->contentHeading(getMLText("trigger_workflow"));
2013-01-24 10:35:33 +00:00
$action = $transition->getAction();
$currentstate = $latestContent->getWorkflowState();
2021-05-25 07:02:59 +00:00
$wkflogs = $latestContent->getWorkflowLog();
2022-07-26 11:39:46 +00:00
/* Check if latest content is still in workflow, which should be
* always the case, otherwise this code would be executed.
* In that case the returned log is just a list of entries for the
* current workflow. If the document was not in a workflow, then the
* log entries for all workflows of this content will be returned
*/
if($workflow = $latestContent->getWorkflow())
$wkflog = $wkflogs;
else
$wkflog = array_shift($wkflogs);
2013-01-24 10:35:33 +00:00
$msg = "The document is currently in state: ".$currentstate->getName()."<br />";
if($wkflog) {
foreach($wkflog as $entry) {
if($entry->getTransition()->getNextState()->getID() == $currentstate->getID()) {
$enterdate = $entry->getDate();
2014-11-14 19:23:26 +00:00
$enterts = makeTsFromLongDate($enterdate);
2013-01-24 10:35:33 +00:00
}
}
2021-08-20 07:45:58 +00:00
if(!empty($enterdate)) {
$msg .= "The state was entered at ".$enterdate." which was ";
$msg .= getReadableDuration((time()-$enterts))." ago.<br />";
}
2013-01-24 10:35:33 +00:00
}
$msg .= "The document may stay in this state for ".$currentstate->getMaxTime()." sec.";
2021-08-20 07:45:58 +00:00
//$this->contentContainerStart();
2013-01-24 10:35:33 +00:00
// Display the Workflow form.
$this->rowStart();
$this->columnStart(4);
2021-08-20 07:45:58 +00:00
$this->infoMsg($msg);
2013-01-24 10:35:33 +00:00
?>
2017-01-04 16:53:27 +00:00
<form class="form-horizontal" method="post" action="../op/op.TriggerWorkflow.php" id="form1" name="form1">
2013-01-24 10:35:33 +00:00
<input type='hidden' name='documentid' value='<?php echo $document->getId(); ?>'/>
<input type='hidden' name='version' value='<?php echo $latestContent->getVersion(); ?>'/>
<input type='hidden' name='transition' value='<?php echo $transition->getID(); ?>'/>
2018-04-23 13:50:46 +00:00
<?php echo createHiddenFieldWithKey('triggerworkflow'); ?>
<?php
$this->formField(
getMLText("comment"),
array(
'element'=>'textarea',
'name'=>'comment',
2021-11-08 11:26:13 +00:00
'rows'=>4,
'required'=>false
)
2018-04-23 13:50:46 +00:00
);
2022-12-06 10:15:51 +00:00
$this->formSubmit(getMLText("action_".strtolower($action->getName()), array(), htmlspecialchars($action->getName())));
2018-04-23 13:50:46 +00:00
?>
2013-01-24 10:35:33 +00:00
</form>
<?php
$this->columnEnd();
$this->columnStart(8);
?>
<div id="workflowgraph">
2021-08-20 09:00:51 +00:00
<?php
if($accessobject->check_view_access('WorkflowGraph')) {
?>
2021-08-20 07:45:58 +00:00
<iframe src="out.WorkflowGraph.php?workflow=<?php echo $workflow->getID(); ?>&transitions[]=<?php echo $transition->getID(); ?>&documentid=<?php echo $document->getID(); ?>" width="100%" height="600" style="border: 1px solid #AAA;"></iframe>
2021-08-20 09:00:51 +00:00
<?php
}
?>
2013-01-24 10:35:33 +00:00
</div>
<?php
$this->columnEnd();
$this->rowEnd();
2021-08-20 07:45:58 +00:00
//$this->contentContainerEnd();
2013-01-24 10:35:33 +00:00
if($wkflog) {
2021-08-20 07:45:58 +00:00
$this->contentHeading(getMLText("workflow_log"));
echo "<table class=\"table table-condensed table-sm\">";
2013-01-24 10:35:33 +00:00
echo "<tr><th>".getMLText('action')."</th><th>Start state</th><th>End state</th><th>".getMLText('date')."</th><th>".getMLText('user')."</th><th>".getMLText('comment')."</th></tr>";
foreach($wkflog as $entry) {
echo "<tr>";
2021-08-20 07:45:58 +00:00
echo "<td>".htmlspecialchars(getMLText('action_'.strtolower($entry->getTransition()->getAction()->getName()), array(), $entry->getTransition()->getAction()->getName()))."</td>";
echo "<td>".htmlspecialchars($entry->getTransition()->getState()->getName())."</td>";
echo "<td>".htmlspecialchars($entry->getTransition()->getNextState()->getName())."</td>";
2013-01-24 10:35:33 +00:00
echo "<td>".$entry->getDate()."</td>";
2021-08-20 07:45:58 +00:00
echo "<td>".htmlspecialchars($entry->getUser()->getFullname())."</td>";
echo "<td>".htmlspecialchars($entry->getComment())."</td>";
2013-01-24 10:35:33 +00:00
echo "</tr>";
}
echo "</table>\n";
}
$this->contentEnd();
2013-01-24 10:35:33 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>