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

217 lines
7.1 KiB
PHP
Raw Normal View History

2013-01-24 10:35:33 +00:00
<?php
/**
* Implementation of WorkspaceStatesMgr 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 WorkspaceStatesMgr 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_WorkflowStatesMgr extends SeedDMS_Theme_Style {
2013-01-24 10:35:33 +00:00
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
2021-05-31 17:14:19 +00:00
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
2013-01-24 10:35:33 +00:00
?>
2021-05-31 17:14:19 +00:00
function runValidation() {
$("#form1").validate({
rules: {
name: {
required: true
},
},
messages: {
name: "<?php printMLText("js_no_name");?>",
}
});
2013-01-24 10:35:33 +00:00
}
$(document).ready(function() {
$( "#selector" ).change(function() {
$('div.ajax').trigger('update', {workflowstateid: $(this).val()});
});
});
<?php
} /* }}} */
2013-01-24 10:35:33 +00:00
function info() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$selworkflowstate = $this->params['selworkflowstate'];
if($selworkflowstate) {
if($selworkflowstate->isUsed()) {
$transitions = $selworkflowstate->getTransitions();
if($transitions) {
echo "<table class=\"table table-condensed table-sm\">";
echo "<thead><tr><th>".getMLText('workflow')."</th><th>".getMLText('previous_state')."</th><th>".getMLText('next_state')."</th></tr></thead>\n";
echo "<tbody>";
foreach($transitions as $transition) {
$state = $transition->getState();
$nextstate = $transition->getNextState();
$docstatus = $nextstate->getDocumentStatus();
$workflow = $transition->getWorkflow();
echo "<tr>";
echo "<td>";
2020-03-26 06:54:27 +00:00
echo htmlspecialchars($workflow->getName());
echo "</td><td>";
2020-08-27 05:52:52 +00:00
echo '<i class="fa fa-circle'.($workflow->getInitState()->getId() == $state->getId() ? ' initstate' : ' in-workflow').'"></i> '.htmlspecialchars($state->getName());
echo "</td><td>";
2020-08-27 05:52:52 +00:00
echo '<i class="fa fa-circle'.($docstatus == S_RELEASED ? ' released' : ($docstatus == S_REJECTED ? ' rejected' : ' in-workflow')).'"></i> '.htmlspecialchars($nextstate->getName());
echo "</td></tr>";
}
echo "</tbody>";
echo "</table>";
}
}
}
} /* }}} */
2013-01-24 10:35:33 +00:00
2018-12-03 06:40:58 +00:00
function actionmenu() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$selworkflowstate = $this->params['selworkflowstate'];
if($selworkflowstate && !$selworkflowstate->isUsed()) {
2021-05-31 17:14:19 +00:00
$button = array(
'label'=>getMLText('action'),
'menuitems'=>array(
)
);
$button['menuitems'][] = array('label'=>'<i class="fa fa-remove"></i> '.getMLText("rm_workflow_state"), 'link'=>'../op/op.RemoveWorkflowState.php?workflowstateid='.$selworkflowstate->getID().'&formtoken='.createFormKey('removeworkflowstate'));
self::showButtonwithMenu($button);
2018-12-03 06:40:58 +00:00
}
} /* }}} */
function showWorkflowStateForm($state) { /* {{{ */
if($state) {
if($state->isUsed()) {
$this->infoMsg(getMLText('workflow_state_in_use'));
}
}
?>
2021-05-31 17:14:19 +00:00
<form action="../op/op.WorkflowStatesMgr.php" method="post" class="form-horizontal" id="form1" name="form1">
<?php
if($state) {
echo createHiddenFieldWithKey('editworkflowstate');
?>
<input type="Hidden" name="workflowstateid" value="<?php print $state->getID();?>">
<input type="Hidden" name="action" value="editworkflowstate">
<?php
} else {
echo createHiddenFieldWithKey('addworkflowstate');
?>
<input type="hidden" name="action" value="addworkflowstate">
<?php
}
$this->contentContainerStart();
$this->formField(
getMLText("workflow_state_name"),
array(
'element'=>'input',
'type'=>'text',
'id'=>'name',
'name'=>'name',
'value'=>($state ? htmlspecialchars($state->getName()) : '')
)
);
$options = array();
$options[] = array("", getMLText("keep_doc_status"));
$options[] = array(S_RELEASED, getMLText("released"), ($state && $state->getDocumentStatus() == S_RELEASED));
$options[] = array(S_REJECTED, getMLText("rejected"), ($state && $state->getDocumentStatus() == S_REJECTED));
$this->formField(
getMLText("workflow_state_docstatus"),
array(
'element'=>'select',
'name'=>'docstatus',
'options'=>$options
)
);
$this->contentContainerEnd();
2020-08-27 05:52:52 +00:00
$this->formSubmit('<i class="fa fa-save"></i> '.getMLText("save"));
?>
</form>
<?php
} /* }}} */
2013-01-24 10:35:33 +00:00
function form() { /* {{{ */
$selworkflowstate = $this->params['selworkflowstate'];
2013-01-24 10:35:33 +00:00
$this->showWorkflowStateForm($selworkflowstate);
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$selworkflowstate = $this->params['selworkflowstate'];
$workflowstates = $dms->getAllWorkflowStates();
2021-05-31 17:14:19 +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("admin_tools"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
2013-01-24 10:35:33 +00:00
$this->contentHeading(getMLText("workflow_states_management"));
$this->rowStart();
$this->columnStart(4);
2013-01-24 10:35:33 +00:00
?>
2018-12-03 06:40:58 +00:00
<form class="form-horizontal">
2013-01-24 10:35:33 +00:00
<?php
$options = array();
$options[] = array("-1", getMLText("choose_workflow_state"));
$options[] = array("0", getMLText("add_workflow_state"));
2013-01-24 10:35:33 +00:00
foreach ($workflowstates as $currWorkflowState) {
$options[] = array($currWorkflowState->getID(), htmlspecialchars($currWorkflowState->getName()), $selworkflowstate && $currWorkflowState->getID()==$selworkflowstate->getID());
2013-01-24 10:35:33 +00:00
}
$this->formField(
2018-12-03 06:40:58 +00:00
null, //getMLText("selection"),
array(
'element'=>'select',
'id'=>'selector',
2018-12-03 06:40:58 +00:00
'class'=>'chzn-select',
'options'=>$options
)
);
2013-01-24 10:35:33 +00:00
?>
2018-12-03 06:40:58 +00:00
</form>
<div class="ajax" style="margin-bottom: 15px;" data-view="WorkflowStatesMgr" data-action="actionmenu" <?php echo ($selworkflowstate ? "data-query=\"workflowstateid=".$selworkflowstate->getID()."\"" : "") ?>></div>
<div class="ajax" data-view="WorkflowStatesMgr" data-action="info" <?php echo ($selworkflowstate ? "data-query=\"workflowstateid=".$selworkflowstate->getID()."\"" : "") ?>></div>
<?php
$this->columnEnd();
$this->columnStart(8);
?>
2021-05-31 17:14:19 +00:00
<div class="ajax" data-view="WorkflowStatesMgr" data-action="form" data-afterload="()=>{runValidation();}" <?php echo ($selworkflowstate ? "data-query=\"workflowstateid=".$selworkflowstate->getID()."\"" : "") ?>></div>
2013-01-24 10:35:33 +00:00
<?php
$this->columnEnd();
$this->rowEnd();
$this->contentEnd();
2013-01-24 10:35:33 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>