use formField() instead of table layout

This commit is contained in:
Uwe Steinmann 2018-06-26 06:52:16 +02:00
parent 643e948440
commit 613bf9387c

View File

@ -215,147 +215,153 @@ console.log(element);
$this->contentContainerStart();
?>
<form action="../op/op.UpdateDocument.php" enctype="multipart/form-data" method="post" name="form1" id="form1">
<form class="form-horizontal" action="../op/op.UpdateDocument.php" enctype="multipart/form-data" method="post" name="form1" id="form1">
<?php echo createHiddenFieldWithKey('updatedocument'); ?>
<input type="hidden" name="documentid" value="<?php print $document->getID(); ?>">
<table class="table-condensed">
<tr>
<td><?php printMLText("local_file");?>:</td>
<td>
<?php
if($enablelargefileupload)
$this->printFineUploaderHtml();
else
$this->printFileChooser('userfile', false);
?>
</td>
</tr>
<?php if($dropfolderdir) { ?>
<tr>
<td><?php printMLText("dropfolder_file");?>:</td>
<td><?php $this->printDropFolderChooserHtml("form1");?></td>
</tr>
<?php } ?>
<tr>
<td><?php printMLText("comment");?>:</td>
<td class="standardText">
<textarea name="comment" rows="4" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>></textarea>
</td>
</tr>
<?php
if($presetexpiration) {
if(!($expts = strtotime($presetexpiration)))
$expts = false;
} else {
$this->formField(
getMLText("local_file"),
$enablelargefileupload ? $this->getFineUploaderHtml() : $this->printFileChooser('userfile', false)
);
if($dropfolderdir) {
$this->formField(
getMLText("dropfolder_file"),
$this->getDropFolderChooserHtml("form1")
);
}
$this->formField(
getMLText("comment"),
array(
'element'=>'textarea',
'name'=>'comment',
'rows'=>4,
'cols'=>80
)
);
if($presetexpiration) {
if(!($expts = strtotime($presetexpiration)))
$expts = false;
} else {
$expts = false;
}
$options = array();
$options[] = array('never', getMLText('does_not_expire'));
$options[] = array('date', getMLText('expire_by_date'), $expts);
$options[] = array('1w', getMLText('expire_in_1w'));
$options[] = array('1m', getMLText('expire_in_1m'));
$options[] = array('1y', getMLText('expire_in_1y'));
$options[] = array('2y', getMLText('expire_in_2y'));
$this->formField(
getMLText("preset_expires"),
array(
'element'=>'select',
'id'=>'presetexpdate',
'name'=>'presetexpdate',
'options'=>$options
)
);
$this->formField(
getMLText("expires"),
$this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage())
);
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentContentAttribute', $document, $attrdef);
if(is_array($arr)) {
if($arr)
$this->formField($arr[0], $arr[1]);
} else {
$presetbtnhtml = '';
if($latestContent->getAttributeValue($attrdef)) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_string:
case SeedDMS_Core_AttributeDefinition::type_date:
case SeedDMS_Core_AttributeDefinition::type_int:
case SeedDMS_Core_AttributeDefinition::type_float:
$presetbtnhtml = $this->getInputPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef), $attrdef->getValueSetSeparator());
break;
case SeedDMS_Core_AttributeDefinition::type_boolean:
$presetbtnhtml = $this->gettCheckboxPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef));
break;
}
}
$this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, '', 'attributes_version')." ".$presetbtnhtml);
}
}
?>
<tr>
<td><?php printMLText("preset_expires");?>:</td>
<td>
<select class="span6" name="presetexpdate" id="presetexpdate">
<option value="never"><?php printMLText('does_not_expire');?></option>
<option value="date"<?php echo ($expts != '' ? " selected" : ""); ?>><?php printMLText('expire_by_date');?></option>
<option value="1w"><?php printMLText('expire_in_1w');?></option>
<option value="1m"><?php printMLText('expire_in_1m');?></option>
<option value="1y"><?php printMLText('expire_in_1y');?></option>
<option value="2y"><?php printMLText('expire_in_2y');?></option>
</select>
</td>
</tr>
<tr id="control_expdate" <?php echo ($expts == false ? 'style="display: none;"' : ''); ?>>
<td><?php printMLText("expires");?>:</td>
<td class="standardText">
<span class="input-append date span12" id="expirationdate" data-date="<?php echo ($expts ? date('Y-m-d', $expts) : ''); ?>" data-date-format="yyyy-mm-dd" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
<input class="span6" size="16" name="expdate" type="text" value="<?php echo ($expts ? date('Y-m-d', $expts) : ''); ?>">
<span class="add-on"><i class="icon-calendar"></i></span>
</span>
</td>
</tr>
<?php
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentContentAttribute', $document, $attrdef);
if(is_array($arr)) {
if($arr) {
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1]."</td>";
echo "</tr>";
}
$arrs = $this->callHook('addDocumentContentAttributes', $folder);
if(is_array($arrs)) {
foreach($arrs as $arr) {
$this->formField($arr[0], $arr[1]);
}
}
if($workflowmode == 'advanced') {
$mandatoryworkflows = $user->getMandatoryWorkflows();
if($mandatoryworkflows) {
if(count($mandatoryworkflows) == 1) {
$this->formField(
getMLText("workflow"),
htmlspecialchars($mandatoryworkflows[0]->getName()).'<input type="hidden" name="workflow" value="'.$mandatoryworkflows[0]->getID().'">'
);
} else {
$options = array();
$curworkflow = $latestContent->getWorkflow();
foreach ($mandatoryworkflows as $workflow) {
$options[] = array($workflow->getID(), htmlspecialchars($workflow->getName()), $curworkflow && $curworkflow->getID() == $workflow->getID());
}
$this->formField(
getMLText("workflow"),
array(
'element'=>'select',
'id'=>'workflow',
'name'=>'workflow',
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_workflow'))),
'options'=>$options
)
);
}
} else {
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td><?php $this->printAttributeEditField($attrdef, '', 'attributes_version') ?>
<?php
if($latestContent->getAttributeValue($attrdef)) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_string:
case SeedDMS_Core_AttributeDefinition::type_date:
case SeedDMS_Core_AttributeDefinition::type_int:
case SeedDMS_Core_AttributeDefinition::type_float:
$this->printInputPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef), $attrdef->getValueSetSeparator());
break;
case SeedDMS_Core_AttributeDefinition::type_boolean:
$this->printCheckboxPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef));
break;
$options = array();
$options[] = array('', '');
$workflows=$dms->getAllWorkflows();
foreach ($workflows as $workflow) {
$options[] = array($workflow->getID(), htmlspecialchars($workflow->getName()));
}
// print_r($latestContent->getAttributeValue($attrdef));
$this->formField(
getMLText("workflow"),
array(
'element'=>'select',
'id'=>'workflow',
'name'=>'workflow',
'class'=>'chzn-select',
'attributes'=>array(array('data-allow-clear', 'true'), array('data-placeholder', getMLText('select_workflow'))),
'options'=>$options
)
);
}
?></td>
</tr>
<?php
}
}
}
$arrs = $this->callHook('addDocumentContentAttributes', $folder);
if(is_array($arrs)) {
foreach($arrs as $arr) {
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1]."</td>";
echo "</tr>";
}
}
if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') {
// Retrieve a list of all users and groups that have review / approve
// privileges.
$docAccess = $folder->getReadAccessList($enableadminrevapp, $enableownerrevapp);
if($workflowmode != 'traditional_only_approval') {
?>
<tr>
<td colspan="2">
<?php $this->contentSubHeading(getMLText("assign_reviewers")); ?>
</td>
</tr>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("individuals");?>:</div>
</td>
<td>
<select id="IndReviewer" class="chzn-select span9" name="indReviewers[]" multiple="multiple" data-placeholder="<?php printMLText('select_ind_reviewers'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<?php
$this->warningMsg(getMLText("add_doc_workflow_warning"));
} else {
$docAccess = $document->getReadAccessList($enableadminrevapp, $enableownerrevapp);
if($workflowmode == 'traditional') {
$this->contentSubHeading(getMLText("assign_reviewers"));
$res=$user->getMandatoryReviewers();
$options = array();
foreach ($docAccess["users"] as $usr) {
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$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>";
$option = array($usr->getID(), htmlspecialchars($usr->getLogin()." - ".$usr->getFullName()), null);
if ($mandatory) $option[] = array(array('disabled', 'disabled'));
$options[] = $option;
}
?>
</select>
<?php
$tmp = array();
foreach($reviewStatus as $r) {
if($r['type'] == 0) {
if($res) {
if($res) {
$mandatory=false;
foreach ($res as $rr)
if ($rr['reviewerUserID']==$r['required']) {
@ -368,9 +374,24 @@ console.log(element);
}
}
}
$fieldwrap = '';
if($tmp) {
$this->printSelectPresetButtonHtml("IndReviewer", $tmp);
$fieldwrap = array('', $this->getSelectPresetButtonHtml("IndReviewers", $tmp));
}
$this->formField(
getMLText("individuals"),
array(
'element'=>'select',
'name'=>'indReviewers[]',
'id'=>'IndReviewers',
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_ind_reviewers'))),
'multiple'=>true,
'options'=>$options
),
array('field_wrap'=>$fieldwrap)
);
/* List all mandatory reviewers */
if($res) {
$tmp = array();
@ -386,6 +407,7 @@ console.log(element);
echo "</div>\n";
}
}
/* Check for mandatory reviewer without access */
foreach($res as $r) {
if($r['reviewerUserID']) {
@ -396,31 +418,20 @@ console.log(element);
}
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>";
$this->warningMsg(getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
}
}
?>
</td>
</tr>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("groups");?>:</div>
</td>
<td>
<select id="GrpReviewer" class="chzn-select span9" name="grpReviewers[]" multiple="multiple" data-placeholder="<?php printMLText('select_grp_reviewers'); ?>" data-no_results_text="<?php printMLText('unknown_group'); ?>">
<?php
$options = array();
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['reviewerGroupID']==$grp->getID()) $mandatory=true;
if ($mandatory || !$grp->getUsers()) print "<option value=\"".$grp->getID()."\" disabled=\"disabled\">".htmlspecialchars($grp->getName())."</option>";
else print "<option value=\"".$grp->getID()."\">".htmlspecialchars($grp->getName())."</option>";
$option = array($grp->getID(), htmlspecialchars($grp->getName()), null);
if ($mandatory || !$grp->getUsers()) $option[] = array(array('disabled', 'disabled'));
$options[] = $option;
}
?>
</select>
<?php
$tmp = array();
foreach($reviewStatus as $r) {
if($r['type'] == 1) {
@ -437,9 +448,24 @@ console.log(element);
}
}
}
$fieldwrap = '';
if($tmp) {
$this->printSelectPresetButtonHtml("GrpReviewer", $tmp);
$fieldwrap = array('', $this->getSelectPresetButtonHtml("GrpReviewers", $tmp));
}
$this->formField(
getMLText("groups"),
array(
'element'=>'select',
'name'=>'grpReviewers[]',
'id'=>'GrpReviewers',
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_grp_reviewers'))),
'multiple'=>true,
'options'=>$options
),
array('field_wrap'=>$fieldwrap)
);
/* List all mandatory groups of reviewers */
if($res) {
$tmp = array();
@ -455,7 +481,6 @@ console.log(element);
echo "</div>\n";
}
}
/* Check for mandatory reviewer group without access */
foreach($res as $r) {
if ($r['reviewerGroupID']) {
@ -466,58 +491,59 @@ console.log(element);
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['reviewerGroupID']);
echo "<div class=\"alert alert-warning\">".getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))."</div>";
$this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
}
?>
</td>
</tr>
<?php } ?>
<tr>
<td colspan=2>
<?php $this->contentSubHeading(getMLText("assign_approvers")); ?>
</td>
</tr>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("individuals");?>:</div>
</td>
<td>
<select id="IndApprover" class="chzn-select span9" name="indApprovers[]" multiple="multiple" data-placeholder="<?php printMLText('select_ind_approvers'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<?php
$res=$user->getMandatoryApprovers();
foreach ($docAccess["users"] as $usr) {
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
}
$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
$tmp = array();
foreach($approvalStatus as $r) {
if($r['type'] == 0) {
if($res) {
$mandatory=false;
foreach ($res as $rr)
if ($rr['approverUserID']==$r['required']) {
$mandatory=true;
}
if(!$mandatory)
$tmp[] = $r['required'];
} else {
$this->contentSubHeading(getMLText("assign_approvers"));
$options = array();
$res=$user->getMandatoryApprovers();
foreach ($docAccess["users"] as $usr) {
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$mandatory=false;
foreach ($res as $r) if ($r['approverUserID']==$usr->getID()) $mandatory=true;
$option = array($usr->getID(), htmlspecialchars($usr->getLogin()." - ".$usr->getFullName()), null);
if ($mandatory) $option[] = array(array('disabled', 'disabled'));
$options[] = $option;
}
$tmp = array();
foreach($approvalStatus as $r) {
if($r['type'] == 0) {
if($res) {
$mandatory=false;
foreach ($res as $rr)
if ($rr['approverUserID']==$r['required']) {
$mandatory=true;
}
if(!$mandatory)
$tmp[] = $r['required'];
}
} else {
$tmp[] = $r['required'];
}
}
if($tmp) {
$this->printSelectPresetButtonHtml("IndApprover", $tmp);
}
}
$fieldwrap = '';
if($tmp) {
$fieldwrap = array('', $this->getSelectPresetButtonHtml("IndApprovers", $tmp));
}
$this->formField(
getMLText("individuals"),
array(
'element'=>'select',
'name'=>'indApprovers[]',
'id'=>'IndApprovers',
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_ind_approvers'))),
'multiple'=>true,
'options'=>$options
),
array('field_wrap'=>$fieldwrap)
);
/* List all mandatory approvers */
if($res) {
$tmp = array();
@ -544,31 +570,22 @@ console.log(element);
}
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>";
$this->warningMsg(getMLText("mandatory_approver_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
}
}
?>
</td>
</tr>
<td>
<div class="cbSelectTitle"><?php printMLText("groups");?>:</div>
</td>
<td>
<select id="GrpApprover" class="chzn-select span9" name="grpApprovers[]" multiple="multiple" data-placeholder="<?php printMLText('select_grp_approvers'); ?>" data-no_results_text="<?php printMLText('unknown_group'); ?>">
<?php
$options = array();
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['approverGroupID']==$grp->getID()) $mandatory=true;
if ($mandatory || !$grp->getUsers()) print "<option value=\"". $grp->getID() ."\" disabled=\"disabled\">".htmlspecialchars($grp->getName())."</option>";
else print "<option value=\"". $grp->getID() ."\">".htmlspecialchars($grp->getName())."</option>";
$option = array($grp->getID(), htmlspecialchars($grp->getName()), null);
if ($mandatory || !$grp->getUsers()) $option[] = array(array('disabled', 'disabled'));
$options[] = $option;
}
?>
</select>
<?php
$tmp = array();
foreach($approvalStatus as $r) {
if($r['type'] == 1) {
@ -585,9 +602,24 @@ console.log(element);
}
}
}
$fieldwrap = '';
if($tmp) {
$this->printSelectPresetButtonHtml("GrpApprover", $tmp);
$fieldwrap = array('', $this->getSelectPresetButtonHtml("GrpApprovers", $tmp));
}
$this->formField(
getMLText("groups"),
array(
'element'=>'select',
'name'=>'grpApprovers[]',
'id'=>'GrpApprovers',
'class'=>'chzn-select',
'attributes'=>array(array('data-placeholder', getMLText('select_grp_approvers'))),
'multiple'=>true,
'options'=>$options
),
array('field_wrap'=>$fieldwrap)
);
/* List all mandatory groups of approvers */
if($res) {
$tmp = array();
@ -614,77 +646,14 @@ console.log(element);
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['approverGroupID']);
echo "<div class=\"alert alert-warning\">".getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))."</div>";
$this->warningMsg(getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
}
$this->warningMsg(getMLText("add_doc_reviewer_approver_warning"));
}
$this->formSubmit(getMLText('update_document'));
?>
</td>
</tr>
<tr>
<td colspan="2"><div class="alert"><?php printMLText("add_doc_reviewer_approver_warning")?></div></td>
</tr>
<?php
} else {
?>
<tr>
<td>
<div class="cbSelectTitle"><?php printMLText("workflow");?>:</div>
</td>
<td>
<?php
$mandatoryworkflows = $user->getMandatoryWorkflows();
if($mandatoryworkflows) {
if(count($mandatoryworkflows) == 1) {
?>
<?php echo htmlspecialchars($mandatoryworkflows[0]->getName()); ?>
<input type="hidden" name="workflow" value="<?php echo $mandatoryworkflows[0]->getID(); ?>">
<?php
} else {
?>
<select class="_chzn-select span9" _data-allow-clear="true" name="workflow" data-placeholder="<?php printMLText('select_workflow'); ?>">
<?php
$curworkflow = $latestContent->getWorkflow();
foreach ($mandatoryworkflows as $workflow) {
print "<option value=\"".$workflow->getID()."\"";
if($curworkflow && $curworkflow->getID() == $workflow->getID())
echo " selected=\"selected\"";
print ">". htmlspecialchars($workflow->getName())."</option>";
}
?>
</select>
<?php
}
} else {
?>
<select class="_chzn-select span9" _data-allow-clear="true" 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()."\"";
print ">". htmlspecialchars($workflow->getName())."</option>";
}
?>
</select>
<?php
}
?>
</td>
</tr>
<tr>
<td colspan="2">
<?php $this->warningMsg(getMLText("add_doc_workflow_warning")); ?>
</td>
</tr>
<?php
}
?>
<tr>
<td></td>
<td><input type="submit" class="btn" value="<?php printMLText("update_document")?>"></td>
</tr>
</table>
</form>
<?php