mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
368 lines
13 KiB
PHP
368 lines
13 KiB
PHP
<?php
|
|
/**
|
|
* Implementation of AttributeGroupMgr view
|
|
*
|
|
* @category DMS
|
|
* @package SeedDMS
|
|
* @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");
|
|
|
|
/**
|
|
* Class which outputs the html page for AttributeGroupMgr view
|
|
*
|
|
* @category DMS
|
|
* @package SeedDMS
|
|
* @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_AttributeGroupMgr extends SeedDMS_Theme_Style {
|
|
|
|
function js() { /* {{{ */
|
|
$selgroup = $this->params['selattrdefgroup'];
|
|
$strictformcheck = $this->params['strictformcheck'];
|
|
|
|
header("Content-type: text/javascript");
|
|
?>
|
|
function checkForm1() {
|
|
msg = new Array();
|
|
|
|
if($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>");
|
|
<?php
|
|
if ($strictformcheck) {
|
|
?>
|
|
if($("#comment").val() == "") msg.push("<?php printMLText("js_no_comment");?>");
|
|
<?php
|
|
}
|
|
?>
|
|
if (msg != "") {
|
|
noty({
|
|
text: msg.join('<br />'),
|
|
type: 'error',
|
|
dismissQueue: true,
|
|
layout: 'topRight',
|
|
theme: 'defaultTheme',
|
|
_timeout: 1500,
|
|
});
|
|
return false;
|
|
} else
|
|
return true;
|
|
}
|
|
|
|
function checkForm2() {
|
|
msg = "";
|
|
|
|
if($("#attrdefid").val() == -1) msg += "<?php printMLText("js_select_user");?>\n";
|
|
|
|
if (msg != "") {
|
|
noty({
|
|
text: msg,
|
|
type: 'error',
|
|
dismissQueue: true,
|
|
layout: 'topRight',
|
|
theme: 'defaultTheme',
|
|
_timeout: 1500,
|
|
});
|
|
return false;
|
|
} else
|
|
return true;
|
|
}
|
|
|
|
$(document).ready( function() {
|
|
$('body').on('submit', '#form_1', function(ev){
|
|
if(checkForm1())
|
|
return;
|
|
ev.preventDefault();
|
|
});
|
|
|
|
$('body').on('submit', '#form_2', function(ev){
|
|
if(checkForm2())
|
|
return;
|
|
ev.preventDefault();
|
|
});
|
|
|
|
$( "#selector" ).change(function() {
|
|
$('div.ajax').trigger('update', {attrdefgroupid: $(this).val()});
|
|
window.history.pushState({"html":"","pageTitle":""},"", '../out/out.AttributeGroupMgr.php?attrdefgroupid=' + $(this).val());
|
|
});
|
|
});
|
|
<?php
|
|
$this->printClickFolderJs();
|
|
} /* }}} */
|
|
|
|
function info() { /* {{{ */
|
|
$dms = $this->params['dms'];
|
|
$selgroup = $this->params['selattrdefgroup'];
|
|
$cachedir = $this->params['cachedir'];
|
|
$previewwidth = $this->params['previewWidthList'];
|
|
$workflowmode = $this->params['workflowmode'];
|
|
$timeout = $this->params['timeout'];
|
|
|
|
if($selgroup) {
|
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout);
|
|
$this->contentHeading(getMLText("group_info"));
|
|
|
|
$folders = $selgroup->getFolders();
|
|
if($folders) {
|
|
print $this->folderListHeader();
|
|
print "<tbody>\n";
|
|
foreach($folders as $subFolder) {
|
|
echo $this->folderListRow($subFolder);
|
|
}
|
|
echo "</tbody>\n</table>\n";
|
|
}
|
|
}
|
|
} /* }}} */
|
|
|
|
function actionmenu() { /* {{{ */
|
|
$dms = $this->params['dms'];
|
|
$user = $this->params['user'];
|
|
$selgroup = $this->params['selattrdefgroup'];
|
|
|
|
if($selgroup) {
|
|
?>
|
|
<form style="display: inline-block;" method="post" action="../op/op.AttributeGroupMgr.php" >
|
|
<?php echo createHiddenFieldWithKey('removegroup'); ?>
|
|
<input type="hidden" name="attrdefgroupid" value="<?php echo $selgroup->getID()?>">
|
|
<input type="hidden" name="action" value="removegroup">
|
|
<button type="submit" class="btn btn-danger"><i class="fa fa-remove"></i> <?php echo getMLText("rm_attrdefgroup")?></button>
|
|
</form>
|
|
<?php
|
|
}
|
|
} /* }}} */
|
|
|
|
function showAttributeGroupForm($group) { /* {{{ */
|
|
$dms = $this->params['dms'];
|
|
$user = $this->params['user'];
|
|
$allUsers = $this->params['attrdefs'];
|
|
$groups = $this->params['attrdefgroups'];
|
|
?>
|
|
<form class="form-horizontal" action="../op/op.AttributeGroupMgr.php" name="form_1" id="form_1" method="post">
|
|
<?php
|
|
if($group) {
|
|
echo createHiddenFieldWithKey('editgroup');
|
|
?>
|
|
<input type="hidden" name="attrdefgroupid" value="<?php print $group->getID();?>">
|
|
<input type="hidden" name="action" value="editgroup">
|
|
<?php
|
|
} else {
|
|
echo createHiddenFieldWithKey('addgroup');
|
|
?>
|
|
<input type="hidden" name="action" value="addgroup">
|
|
<?php
|
|
}
|
|
$this->formField(
|
|
getMLText("name"),
|
|
array(
|
|
'element'=>'input',
|
|
'type'=>'text',
|
|
'name'=>'name',
|
|
'value'=>($group ? htmlspecialchars($group->getName()) : '')
|
|
)
|
|
);
|
|
$this->formField(
|
|
getMLText("comment"),
|
|
array(
|
|
'element'=>'textarea',
|
|
'name'=>'comment',
|
|
'rows'=>5,
|
|
'value'=>($group ? htmlspecialchars($group->getComment()) : '')
|
|
)
|
|
);
|
|
$this->formSubmit('<i class="fa fa-save"></i> '.getMLText('save'));
|
|
?>
|
|
</form>
|
|
<?php
|
|
if($group) {
|
|
$this->contentHeading(getMLText("group_members"));
|
|
?>
|
|
<table class="table table-condensed table-sm">
|
|
<?php
|
|
$members = $group->getAttributeDefinitions();
|
|
if (count($members) == 0)
|
|
print "<tr><td>".getMLText("no_group_members")."</td></tr>";
|
|
else {
|
|
$seqs = array();
|
|
$i = 0;
|
|
foreach ($members as $member) {
|
|
$seqs[$i] = $group->getSequence($member['attrdef']);
|
|
$i++;
|
|
}
|
|
|
|
$i = 0;
|
|
foreach ($members as $memberarr) {
|
|
$member = $memberarr['attrdef'];
|
|
$seq = $seqs[$i];
|
|
$pseq = isset($seqs[$i-1]) ? $seqs[$i-1] : $seqs[$i] - 20.0;
|
|
$ppseq = isset($seqs[$i-2]) ? $seqs[$i-2] : $pseq - 20.0;
|
|
$nseq = isset($seqs[$i+1]) ? $seqs[$i+1] : $seqs[$i] + 20.0;
|
|
$nnseq = isset($seqs[$i+2]) ? $seqs[$i+2] : $nseq + 20.0;
|
|
|
|
$newupseq = ($pseq-$ppseq)/2+$ppseq;
|
|
$newdownseq = ($nnseq-$nseq)/2+$nseq;
|
|
|
|
switch($member->getObjType()) {
|
|
case SeedDMS_Core_AttributeDefinition::objtype_all:
|
|
$ot = getMLText("all");
|
|
break;
|
|
case SeedDMS_Core_AttributeDefinition::objtype_folder:
|
|
$ot = getMLText("folder");
|
|
break;
|
|
case SeedDMS_Core_AttributeDefinition::objtype_document:
|
|
$ot = getMLText("document");
|
|
break;
|
|
case SeedDMS_Core_AttributeDefinition::objtype_documentcontent:
|
|
$ot = getMLText("version");
|
|
break;
|
|
}
|
|
switch($member->getType()) {
|
|
case SeedDMS_Core_AttributeDefinition::type_int:
|
|
$t = getMLText("attrdef_type_int");
|
|
break;
|
|
case SeedDMS_Core_AttributeDefinition::type_float:
|
|
$t = getMLText("attrdef_type_float");
|
|
break;
|
|
case SeedDMS_Core_AttributeDefinition::type_string:
|
|
$t = getMLText("attrdef_type_string");
|
|
break;
|
|
case SeedDMS_Core_AttributeDefinition::type_date:
|
|
$t = getMLText("attrdef_type_date");
|
|
break;
|
|
case SeedDMS_Core_AttributeDefinition::type_boolean:
|
|
$t = getMLText("attrdef_type_boolean");
|
|
break;
|
|
}
|
|
print "<tr>";
|
|
print "<td><i class=\"fa fa-tag\"></i></td>";
|
|
print "<td>" . htmlspecialchars($member->getName()) ." (".$ot.", ".$t.")"."</td>";
|
|
$show = $group->getShow($member);
|
|
print "<td>";
|
|
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"setshow\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('setshow');
|
|
echo "<select class=\"chzn-select\" style=\"\" multiple=\"multiple\" name=\"shows[]\" data-placeholder=\"".getMLText('select_attrdefgrp_show')."\">";
|
|
foreach(SeedDMS_Core_AttributeDefinitionGroup::getShowValues() as $j=>$k)
|
|
echo "<option value=\"".$j."\"".(($show & $j) ? " selected" : "").">".getMLText('attrdefgrp_show_'.$k)."</option>";
|
|
echo "</select> ";
|
|
// print "</td>";
|
|
// print "<td>";
|
|
print "<button type=\"submit\" class=\"btn btn-primary btn-mini btn-sm\"><i class=\"fa fa-save\"></i></button>";
|
|
print "</form>";
|
|
print "</td>";
|
|
print "<td>";
|
|
if($i != 0)
|
|
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"setsequence\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" /><input type=\"hidden\" name=\"sequence\" value=\"".($newupseq)."\" />".createHiddenFieldWithKey('setsequence')."<button type=\"submit\" class=\"btn btn-secondary btn-mini btn-sm\"><i class=\"fa fa-arrow-up\"></i></button></form>";
|
|
print "</td><td>";
|
|
if($i < count($members)-1)
|
|
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"setsequence\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" /><input type=\"hidden\" name=\"sequence\" value=\"".($newdownseq)."\" />".createHiddenFieldWithKey('setsequence')."<button type=\"submit\" class=\"btn btn-secondary btn-mini btn-sm\"><i class=\"fa fa-arrow-down\"></i></button></form>";
|
|
print "</td><td>";
|
|
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"action\" value=\"rmmember\" /><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('rmmember')."<button type=\"submit\" class=\"btn btn-danger btn-mini btn-sm\"><i class=\"fa fa-remove\"></i> ".getMLText("delete")."</button></form>";
|
|
print "</td></tr>";
|
|
$i++;
|
|
}
|
|
}
|
|
?>
|
|
</table>
|
|
|
|
<?php
|
|
$this->contentHeading(getMLText("add_member"));
|
|
?>
|
|
|
|
<form class="form-inline" action="../op/op.AttributeGroupMgr.php" method="POST" name="form_2" id="form_2">
|
|
<?php echo createHiddenFieldWithKey('addmember'); ?>
|
|
<input type="Hidden" name="action" value="addmember">
|
|
<input type="Hidden" name="attrdefgroupid" value="<?php print $group->getID();?>">
|
|
<table class="table-condensed">
|
|
<tr>
|
|
<td>
|
|
<select class="chzn-select" name="attrdefid" id="attrdefid">
|
|
<option value="-1"><?php printMLText("select_one");?>
|
|
<?php
|
|
foreach ($allUsers as $currUser)
|
|
if (!$group->isMember($currUser))
|
|
print "<option value=\"".$currUser->getID()."\">" . htmlspecialchars($currUser->getName()) . "\n";
|
|
?>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<select class="chzn-select" multiple="multiple" name="shows[]" data-placeholder="<?php printMLText('select_attrdefgrp_show'); ?>">
|
|
<?php
|
|
foreach(SeedDMS_Core_AttributeDefinitionGroup::getShowValues() as $i=>$k)
|
|
echo "<option value=\"".$i."\"".(($show & $i) ? " selected" : "").">".getMLText('attrdefgrp_show_'.$k)."</option>";
|
|
?>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<input type="submit" class="btn btn-primary" value="<?php printMLText("add");?>">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<?php
|
|
}
|
|
} /* }}} */
|
|
|
|
function form() { /* {{{ */
|
|
$selgroup = $this->params['selattrdefgroup'];
|
|
|
|
$this->showAttributeGroupForm($selgroup);
|
|
} /* }}} */
|
|
|
|
function show() { /* {{{ */
|
|
$dms = $this->params['dms'];
|
|
$user = $this->params['user'];
|
|
$accessop = $this->params['accessobject'];
|
|
$selgroup = $this->params['selattrdefgroup'];
|
|
$allGroups = $this->params['attrdefgroups'];
|
|
$strictformcheck = $this->params['strictformcheck'];
|
|
|
|
$this->htmlStartPage(getMLText("admin_tools"));
|
|
$this->globalNavigation();
|
|
$this->contentStart();
|
|
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
|
|
|
|
$this->contentHeading(getMLText("attrdefgroup_management"));
|
|
$this->rowStart();
|
|
$this->columnStart(4);
|
|
?>
|
|
<form class="form-horizontal">
|
|
<select class="form-control chzn-select" id="selector">
|
|
<option value="-1"><?php echo getMLText("choose_attrdefgroup")?>
|
|
<option value="0"><?php echo getMLText("add_attrdefgroup")?>
|
|
<?php
|
|
foreach ($allGroups as $group) {
|
|
print "<option value=\"".$group->getID()."\" ".($selgroup && $group->getID()==$selgroup->getID() ? 'selected' : '').">" . htmlspecialchars($group->getName());
|
|
}
|
|
?>
|
|
</select>
|
|
</form>
|
|
<div class="ajax" style="margin-bottom: 15px;" data-view="AttributeGroupMgr" data-action="actionmenu" <?php echo ($selgroup ? "data-query=\"attrdefgroupid=".$selgroup->getID()."\"" : "") ?>></div>
|
|
<?php if($accessop->check_view_access($this, array('action'=>'info'))) { ?>
|
|
<div class="ajax" data-view="AttributeGroupMgr" data-action="info" <?php echo ($selgroup ? "data-query=\"attrdefgroupid=".$selgroup->getID()."\"" : "") ?>></div>
|
|
<?php } ?>
|
|
<?php
|
|
$this->columnEnd();
|
|
$this->columnStart(8);
|
|
?>
|
|
<?php if($accessop->check_view_access($this, array('action'=>'form'))) { ?>
|
|
<div class="ajax" data-view="AttributeGroupMgr" data-action="form" <?php echo ($selgroup ? "data-query=\"attrdefgroupid=".$selgroup->getID()."\"" : "") ?>></div>
|
|
<?php } ?>
|
|
<?php
|
|
$this->columnEnd();
|
|
$this->rowEnd();
|
|
$this->contentEnd();
|
|
$this->htmlEndPage();
|
|
} /* }}} */
|
|
}
|