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

507 lines
16 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of AddDocument view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +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");
/**
* Class which outputs the html page for AddDocument view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +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_AddDocument extends SeedDMS_Bootstrap_Style {
2012-12-14 07:53:13 +00:00
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$enablelargefileupload = $this->params['enablelargefileupload'];
$enableadminrevapp = $this->params['enableadminrevapp'];
$enableownerrevapp = $this->params['enableownerrevapp'];
$enableselfrevapp = $this->params['enableselfrevapp'];
2012-12-14 07:53:13 +00:00
$strictformcheck = $this->params['strictformcheck'];
$dropfolderdir = $this->params['dropfolderdir'];
$workflowmode = $this->params['workflowmode'];
$presetexpiration = $this->params['presetexpiration'];
2012-12-14 07:53:13 +00:00
$folderid = $folder->getId();
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$this->pageNavigation($this->getFolderPathHTML($folder, true), "view_folder", $folder);
?>
2013-05-23 14:07:00 +00:00
<script language="JavaScript">
function checkForm()
{
msg = new Array();
//if (document.form1.userfile[].value == "") msg += "<?php printMLText("js_no_file");?>\n";
2012-12-14 07:53:13 +00:00
<?php
if ($strictformcheck) {
?>
2013-05-23 14:07:00 +00:00
if(!document.form1.name.disabled){
if (document.form1.name.value == "") msg.push("<?php printMLText("js_no_name");?>");
}
if (document.form1.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (document.form1.keywords.value == "") msg.push("<?php printMLText("js_no_keywords");?>");
2012-12-14 07:53:13 +00:00
<?php
}
?>
2013-05-23 14:07:00 +00:00
if (msg != ""){
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
}
return true;
}
2012-12-14 07:53:13 +00:00
2014-05-16 07:19:36 +00:00
$(document).ready(function() {
$('#new-file').click(function(event) {
$("#upload-file").clone().appendTo("#upload-files").removeAttr("id").children('div').children('input').val('');
});
});
2013-05-23 14:07:00 +00:00
</script>
2012-12-14 07:53:13 +00:00
<?php
$msg = getMLText("max_upload_size").": ".ini_get( "upload_max_filesize");
if($enablelargefileupload) {
$msg .= "<p>".sprintf(getMLText('link_alt_updatedocument'), "out.AddMultiDocument.php?folderid=".$folderid."&showtree=".showtree())."</p>";
}
$this->warningMsg($msg);
2012-12-14 07:53:13 +00:00
$this->contentHeading(getMLText("add_document"));
$this->contentContainerStart();
// Retrieve a list of all users and groups that have review / approve
// privileges.
$docAccess = $folder->getReadAccessList($enableadminrevapp, $enableownerrevapp);
2012-12-14 07:53:13 +00:00
?>
<form action="../op/op.AddDocument.php" enctype="multipart/form-data" method="post" name="form1" onsubmit="return checkForm();">
<?php echo createHiddenFieldWithKey('adddocument'); ?>
<input type="hidden" name="folderid" value="<?php print $folderid; ?>">
<input type="hidden" name="showtree" value="<?php echo showtree();?>">
<table class="table-condensed">
2015-01-30 07:18:52 +00:00
<tr>
<td>
<?php $this->contentSubHeading(getMLText("document_infos")); ?>
</td>
</tr>
2012-12-14 07:53:13 +00:00
<tr>
<td><?php printMLText("name");?>:</td>
<td><input type="text" name="name" size="60"></td>
</tr>
<tr>
<td><?php printMLText("comment");?>:</td>
<td><textarea name="comment" rows="3" cols="80"></textarea></td>
</tr>
<tr>
<td><?php printMLText("keywords");?>:</td>
<td><?php $this->printKeywordChooser("form1");?></td>
2012-12-14 07:53:13 +00:00
</tr>
<tr>
<td><?php printMLText("categories")?>:</td>
<td>
<select class="chzn-select" name="categories[]" multiple="multiple" data-placeholder="<?php printMLText('select_category'); ?>" data-no_results_text="<?php printMLText('unknown_document_category'); ?>">
<?php
$categories = $dms->getDocumentCategories();
foreach($categories as $category) {
echo "<option value=\"".$category->getID()."\"";
echo ">".$category->getName()."</option>";
}
?>
</select>
</td>
2012-12-14 07:53:13 +00:00
</tr>
<tr>
<td><?php printMLText("sequence");?>:</td>
<td><?php $this->printSequenceChooser($folder->getDocuments('s'));?></td>
2012-12-14 07:53:13 +00:00
</tr>
<?php
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_all));
2012-12-14 07:53:13 +00:00
if($attrdefs) {
foreach($attrdefs as $attrdef) {
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?></td>
<td><?php $this->printAttributeEditField($attrdef, '') ?></td>
</tr>
<?php
}
}
if($presetexpiration) {
if(!($expts = strtotime($presetexpiration)))
$expts = time();
} else {
$expts = time();
}
2012-12-14 07:53:13 +00:00
?>
<tr>
<td><?php printMLText("expires");?>:</td>
<td>
<span class="input-append date span12" id="expirationdate" data-date="<?php echo date('d-m-Y', $expts); ?>" data-date-format="dd-mm-yyyy" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
<input class="span3" size="16" name="expdate" type="text" value="<?php echo date('d-m-Y', $expts); ?>">
<span class="add-on"><i class="icon-calendar"></i></span>
2012-12-14 07:53:13 +00:00
</span>&nbsp;
<label class="checkbox inline">
<input type="checkbox" name="expires" value="false" <?php echo ($presetexpiration ? "" : "checked");?>><?php printMLText("does_not_expire");?>
2012-12-14 07:53:13 +00:00
</label>
</td>
</tr>
<tr>
<td>
<?php $this->contentSubHeading(getMLText("version_info")); ?>
</td>
</tr>
<tr>
<td><?php printMLText("version");?>:</td>
<td><input type="text" name="reqversion" value="1"></td>
</tr>
<tr>
<td><?php printMLText("local_file");?>:</td>
<td>
2014-05-16 07:19:36 +00:00
<!--
2012-12-14 07:53:13 +00:00
<a href="javascript:addFiles()"><?php printMLtext("add_multiple_files") ?></a>
<ol id="files">
<li><input type="file" name="userfile[]" size="60"></li>
</ol>
2014-05-16 07:19:36 +00:00
-->
<?php
$this->printFileChooser('userfile[]', false);
?>
<a class="" id="new-file"><?php printMLtext("add_multiple_files") ?></a>
2012-12-14 07:53:13 +00:00
</td>
</tr>
<?php if($dropfolderdir) { ?>
<tr>
<td><?php printMLText("dropfolder_file");?>:</td>
<td><?php $this->printDropFolderChooser("form1");?></td>
</tr>
<?php } ?>
<tr>
<td><?php printMLText("comment_for_current_version");?>:</td>
<td><textarea name="version_comment" rows="3" cols="80"></textarea><br />
<label class="checkbox inline"><input type="checkbox" name="use_comment" value="1" /> <?php printMLText("use_comment_of_document"); ?></label></td>
2012-12-14 07:53:13 +00:00
</tr>
<?php
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));
2012-12-14 07:53:13 +00:00
if($attrdefs) {
foreach($attrdefs as $attrdef) {
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?></td>
<td><?php $this->printAttributeEditField($attrdef, '', 'attributes_version') ?></td>
</tr>
<?php
}
}
if($workflowmode == 'advanced') {
2012-12-14 07:53:13 +00:00
?>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("workflow");?>:</div>
</td>
<td>
<?php
$mandatoryworkflow = $user->getMandatoryWorkflow();
if($mandatoryworkflow) {
?>
<?php echo $mandatoryworkflow->getName(); ?>
<input type="hidden" name="workflow" value="<?php echo $mandatoryworkflow->getID(); ?>">
<?php
} else {
?>
<select class="_chzn-select-deselect span9" name="workflow" data-placeholder="<?php printMLText('select_workflow'); ?>">
<?php
$workflows=$dms->getAllWorkflows();
print "<option value=\"\">"."</option>";
foreach ($workflows as $workflow) {
print "<option value=\"".$workflow->getID()."\"";
if($mandatoryworkflow && $mandatoryworkflow->getID() == $workflow->getID())
echo " selected=\"selected\"";
print ">". htmlspecialchars($workflow->getName())."</option>";
}
?>
</select>
<?php
}
?>
</td>
</tr>
<tr>
<td colspan="2">
<?php $this->warningMsg(getMLText("add_doc_workflow_warning")); ?>
</td>
</tr>
<?php
} else {
if($workflowmode == 'traditional') {
?>
<tr>
2012-12-14 07:53:13 +00:00
<td>
<?php $this->contentSubHeading(getMLText("assign_reviewers")); ?>
</td>
</tr>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("individuals");?>:</div>
</td>
<td>
<?php
$res=$user->getMandatoryReviewers();
2014-06-17 16:11:09 +00:00
?>
<select class="chzn-select span9" name="indReviewers[]" multiple="multiple" data-placeholder="<?php printMLText('select_ind_reviewers'); ?>">
<?php
2012-12-14 07:53:13 +00:00
foreach ($docAccess["users"] as $usr) {
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
2012-12-14 07:53:13 +00:00
$mandatory=false;
foreach ($res as $r) if ($r['reviewerUserID']==$usr->getID()) $mandatory=true;
if ($mandatory) print "<option disabled=\"disabled\" value=\"".$usr->getID()."\">". htmlspecialchars($usr->getLogin()." - ".$usr->getFullName())."</option>";
else print "<option value=\"".$usr->getID()."\">". htmlspecialchars($usr->getLogin()." - ".$usr->getFullName())."</option>";
}
?>
</select>
<?php
2014-06-17 16:11:09 +00:00
/* List all mandatory reviewers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['reviewerUserID'] > 0) {
$u = $dms->getUser($r['reviewerUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
2014-06-17 16:11:09 +00:00
}
}
if($tmp) {
echo '<div class="mandatories"><span>'.getMLText('mandatory_reviewers').':</span> ';
echo implode(', ', $tmp);
echo "</div>\n";
}
}
/* Check for mandatory reviewer without access */
foreach($res as $r) {
if($r['reviewerUserID']) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['reviewerUserID']==$usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['reviewerUserID']);
echo "<div class=\"alert alert-warning\">".getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")")))."</div>";
}
}
}
?>
2012-12-14 07:53:13 +00:00
</td>
</tr>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("groups");?>:</div>
</td>
<td>
<select class="chzn-select span9" name="grpReviewers[]" multiple="multiple" data-placeholder="<?php printMLText('select_grp_reviewers'); ?>">
<?php
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['reviewerGroupID']==$grp->getID()) $mandatory=true;
if ($mandatory) print "<option value=\"".$grp->getID()."\" disabled=\"disabled\">".htmlspecialchars($grp->getName())."</option>";
else print "<option value=\"".$grp->getID()."\">".htmlspecialchars($grp->getName())."</option>";
}
?>
</select>
<?php
2014-06-17 16:11:09 +00:00
/* List all mandatory groups of reviewers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['reviewerGroupID'] > 0) {
$u = $dms->getGroup($r['reviewerGroupID']);
$tmp[] = htmlspecialchars($u->getName());
2014-06-17 16:11:09 +00:00
}
}
if($tmp) {
echo '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> ';
echo implode(', ', $tmp);
echo "</div>\n";
}
}
/* Check for mandatory reviewer group without access */
foreach($res as $r) {
if ($r['reviewerGroupID']) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['reviewerGroupID']==$grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['reviewerGroupID']);
echo "<div class=\"alert alert-warning\">".getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))."</div>";
}
}
}
?>
2012-12-14 07:53:13 +00:00
</td>
</tr>
<?php } ?>
2012-12-14 07:53:13 +00:00
<tr>
<td>
<?php $this->contentSubHeading(getMLText("assign_approvers")); ?>
</td>
</tr>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("individuals");?>:</div>
</td>
<td>
<select class="chzn-select span9" name="indApprovers[]" multiple="multiple" data-placeholder="<?php printMLText('select_ind_approvers'); ?>">
<?php
$res=$user->getMandatoryApprovers();
foreach ($docAccess["users"] as $usr) {
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
2012-12-14 07:53:13 +00:00
$mandatory=false;
foreach ($res as $r) if ($r['approverUserID']==$usr->getID()) $mandatory=true;
if ($mandatory) print "<option value=\"". $usr->getID() ."\" disabled='disabled'>". htmlspecialchars($usr->getFullName())."</option>";
else print "<option value=\"". $usr->getID() ."\">". htmlspecialchars($usr->getLogin()." - ".$usr->getFullName())."</option>";
}
?>
</select>
<?php
2014-06-17 16:11:09 +00:00
/* List all mandatory approvers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['approverUserID'] > 0) {
$u = $dms->getUser($r['approverUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
2014-06-17 16:11:09 +00:00
}
}
if($tmp) {
echo '<div class="mandatories"><span>'.getMLText('mandatory_approvers').':</span> ';
echo implode(', ', $tmp);
echo "</div>\n";
}
}
/* Check for mandatory approvers without access */
foreach($res as $r) {
if($r['approverUserID']) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['approverUserID']==$usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['approverUserID']);
echo "<div class=\"alert alert-warning\">".getMLText("mandatory_approver_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")")))."</div>";
}
}
}
?>
2012-12-14 07:53:13 +00:00
</td>
</tr>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("groups");?>:</div>
</td>
<td>
<select class="chzn-select span9" name="grpApprovers[]" multiple="multiple" data-placeholder="<?php printMLText('select_grp_approvers'); ?>">
<?php
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['approverGroupID']==$grp->getID()) $mandatory=true;
if ($mandatory) print "<option value=\"". $grp->getID() ."\" disabled=\"disabled\">".htmlspecialchars($grp->getName())."</option>";
else print "<option value=\"". $grp->getID() ."\">".htmlspecialchars($grp->getName())."</option>";
}
?>
</select>
<?php
2014-06-17 16:11:09 +00:00
/* List all mandatory groups of approvers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['approverGroupID'] > 0) {
$u = $dms->getGroup($r['approverGroupID']);
$tmp[] = htmlspecialchars($u->getName());
2014-06-17 16:11:09 +00:00
}
}
if($tmp) {
echo '<div class="mandatories"><span>'.getMLText('mandatory_approvergroups').':</span> ';
echo implode(', ', $tmp);
echo "</div>\n";
}
}
/* Check for mandatory approver groups without access */
foreach($res as $r) {
if ($r['approverGroupID']) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['approverGroupID']==$grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['approverGroupID']);
echo "<div class=\"alert alert-warning\">".getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))."</div>";
}
}
}
?>
2012-12-14 07:53:13 +00:00
</td>
</tr>
<tr>
<td colspan="2">
<div class="alert"><?php printMLText("add_doc_reviewer_approver_warning")?></div>
</td>
</tr>
<?php
}
?>
2012-12-14 07:53:13 +00:00
</table>
<p><input type="submit" class="btn" value="<?php printMLText("add_document");?>"></p>
</form>
<?php
$this->contentContainerEnd();
$this->htmlEndPage();
} /* }}} */
}
?>