use same form for ind and grp

The two forms differ in just minor things which can easily be set by
a parameter
This commit is contained in:
Uwe Steinmann 2018-01-30 07:59:15 +01:00
parent 59dd1a9155
commit 1a9c7c213d
2 changed files with 93 additions and 196 deletions

View File

@ -37,8 +37,8 @@ class SeedDMS_View_ApproveDocument extends SeedDMS_Bootstrap_Style {
function checkIndForm()
{
msg = new Array();
if (document.form1.approvalStatus.value == "") msg.push("<?php printMLText("js_no_approval_status");?>");
if (document.form1.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (document.formind.approvalStatus.value == "") msg.push("<?php printMLText("js_no_approval_status");?>");
if (document.formind.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (msg != "") {
noty({
text: msg.join('<br />'),
@ -56,9 +56,9 @@ function checkIndForm()
function checkGrpForm()
{
msg = new Array();
// if (document.form2.approvalGroup.value == "") msg.push("<?php printMLText("js_no_approval_group");?>");
if (document.form2.approvalStatus.value == "") msg.push("<?php printMLText("js_no_approval_status");?>");
if (document.form2.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
// if (document.formgrp.approvalGroup.value == "") msg.push("<?php printMLText("js_no_approval_group");?>");
if (document.formgrp.approvalStatus.value == "") msg.push("<?php printMLText("js_no_approval_status");?>");
if (document.formgrp.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (msg != "")
{
noty({
@ -75,11 +75,11 @@ function checkGrpForm()
return true;
}
$(document).ready(function() {
$('body').on('submit', '#form1', function(ev){
$('body').on('submit', '#formind', function(ev){
if(checkIndForm()) return;
ev.preventDefault();
});
$('body').on('submit', '#form2', function(ev){
$('body').on('submit', '#formgrp', function(ev){
if(checkGrpForm()) return;
ev.preventDefault();
});
@ -112,58 +112,7 @@ $(document).ready(function() {
$this->contentContainerStart();
// Display the Approval form.
if ($approvalStatus['type'] == 0) {
if($approvalStatus["status"]!=0) {
print "<table class=\"folderView\"><thead><tr>";
print "<th>".getMLText("status")."</th>";
print "<th>".getMLText("comment")."</th>";
print "<th>".getMLText("last_update")."</th>";
print "</tr></thead><tbody><tr>";
print "<td>";
printApprovalStatusText($approvalStatus["status"]);
print "</td>";
print "<td>".htmlspecialchars($approvalStatus["comment"])."</td>";
$indUser = $dms->getUser($approvalStatus["userID"]);
print "<td>".$approvalStatus["date"]." - ". $indUser->getFullname() ."</td>";
print "</tr></tbody></table><br>\n";
}
?>
<form method="post" action="../op/op.ApproveDocument.php" id="form1" name="form1" enctype="multipart/form-data">
<?php echo createHiddenFieldWithKey('approvedocument'); ?>
<table>
<tr>
<td><?php printMLText("comment")?>:</td>
<td><textarea name="comment" cols="80" rows="4"></textarea></td>
</tr>
<tr>
<td><?php printMLText("approval_file")?>:</td>
<td>
<?php
$this->printFileChooser('approvalfile', false);
?>
</td>
</tr>
<tr><td><?php printMLText("approval_status")?>:</td>
<td><select name="approvalStatus">
<?php if($approvalStatus['status'] != 1) { ?>
<option value='1'><?php printMLText("status_approved")?></option>
<?php } ?>
<?php if($approvalStatus['status'] != -1) { ?>
<option value='-1'><?php printMLText("rejected")?></option>
<?php } ?>
</select>
</td></tr><tr><td></td><td>
<input type='hidden' name='approvalType' value='ind'/>
<input type='hidden' name='documentid' value='<?php echo $document->getId() ?>'/>
<input type='hidden' name='version' value='<?php echo $latestContent->getVersion(); ?>'/>
<input type='submit' class="btn" name='indApproval' value='<?php printMLText("submit_approval")?>'/>
</td></tr></table>
</form>
<?php
}
else if ($approvalStatus['type'] == 1) {
$approvaltype = ($approvalStatus['type'] == 0) ? 'ind' : 'grp';
if($approvalStatus["status"]!=0) {
print "<table class=\"folderView\"><thead><tr>";
@ -179,14 +128,14 @@ $(document).ready(function() {
print "<td>".$approvalStatus["date"]." - ". htmlspecialchars($indUser->getFullname()) ."</td>";
print "</tr></tbody></table><br>\n";
}
?>
<form method="POST" action="../op/op.ApproveDocument.php" id="form2" name="form2" enctype="multipart/form-data">
<form method="POST" action="../op/op.ApproveDocument.php" id="form<?= $approvaltype ?>" name="form<?= $approvaltype ?>" enctype="multipart/form-data">
<?php echo createHiddenFieldWithKey('approvedocument'); ?>
<table>
<tr><td><?php printMLText("comment")?>:</td>
<td><textarea name="comment" cols="80" rows="4"></textarea>
</td></tr>
<tr>
<td><?php printMLText("comment")?>:</td>
<td><textarea name="comment" cols="80" rows="4"></textarea></td>
</tr>
<tr>
<td><?php printMLText("approval_file")?>:</td>
<td>
@ -207,15 +156,16 @@ $(document).ready(function() {
</select>
</td></tr>
<tr><td></td><td>
<input type='submit' class="btn" name='<?= $approvaltype ?>Approval' value='<?php printMLText("submit_approval")?>'/></td></tr>
</table>
<input type='hidden' name='approvalType' value='<?= $approvaltype ?>'/>
<?php if($approvaltype == 'grp'): ?>
<input type='hidden' name='approvalGroup' value="<?php echo $approvalStatus['required']; ?>" />
<input type='hidden' name='approvalType' value='grp'/>
<?php endif; ?>
<input type='hidden' name='documentid' value='<?php echo $document->getId() ?>'/>
<input type='hidden' name='version' value='<?php echo $latestContent->getVersion(); ?>'/>
<input type='submit' class="btn" name='groupApproval' value='<?php printMLText("submit_approval")?>'/></td></tr>
</table>
</form>
<?php
}
$this->contentContainerEnd();
$this->contentEnd();

View File

@ -37,8 +37,8 @@ class SeedDMS_View_ReviewDocument extends SeedDMS_Bootstrap_Style {
function checkIndForm()
{
msg = new Array();
if (document.form1.reviewStatus.value == "") msg.push("<?php printMLText("js_no_review_status");?>");
if (document.form1.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (document.formind.reviewStatus.value == "") msg.push("<?php printMLText("js_no_review_status");?>");
if (document.formind.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (msg != "") {
noty({
text: msg.join('<br />'),
@ -55,10 +55,10 @@ function checkIndForm()
}
function checkGrpForm()
{
msg = "";
if (document.form2.reviewGroup.value == "") msg += "<?php printMLText("js_no_review_group");?>\n";
if (document.form2.reviewStatus.value == "") msg += "<?php printMLText("js_no_review_status");?>\n";
if (document.form2.comment.value == "") msg += "<?php printMLText("js_no_comment");?>\n";
msg = new Array();
// if (document.formgrp.reviewGroup.value == "") msg.push("<?php printMLText("js_no_review_group");?>");
if (document.formgrp.reviewStatus.value == "") msg.push("<?php printMLText("js_no_review_status");?>");
if (document.formgrp.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (msg != "")
{
noty({
@ -75,11 +75,11 @@ function checkGrpForm()
return true;
}
$(document).ready(function() {
$('body').on('submit', '#form1', function(ev){
$('body').on('submit', '#formind', function(ev){
if(checkIndForm()) return;
ev.preventDefault();
});
$('body').on('submit', '#form2', function(ev){
$('body').on('submit', '#formgrp', function(ev){
if(checkGrpForm()) return;
ev.preventDefault();
});
@ -110,7 +110,7 @@ $(document).ready(function() {
$this->contentContainerStart();
// Display the Review form.
if ($reviewStatus['type'] == 0) {
$reviewtype = ($reviewStatus['type'] == 0) ? 'ind' : 'grp';
if($reviewStatus["status"]!=0) {
print "<table class=\"folderView\"><thead><tr>";
@ -127,7 +127,7 @@ $(document).ready(function() {
print "</tr></tbody></table><br>\n";
}
?>
<form method="post" action="../op/op.ReviewDocument.php" id="form1" name="form1" enctype="multipart/form-data">
<form method="post" action="../op/op.ReviewDocument.php" id="form<?= $reviewtype ?>" name="form<?= $reviewtype ?>" enctype="multipart/form-data">
<?php echo createHiddenFieldWithKey('reviewdocument'); ?>
<table class="table-condensed">
<tr>
@ -157,71 +157,18 @@ $(document).ready(function() {
</tr>
<tr>
<td></td>
<td><input type='submit' class="btn" name='indReview' value='<?php printMLText("submit_review")?>'/></td>
<td><input type='submit' class="btn" name='<?= $reviewtype ?>Review' value='<?php printMLText("submit_review")?>'/></td>
</tr>
</table>
<input type='hidden' name='reviewType' value='ind'/>
<input type='hidden' name='documentid' value='<?php echo $document->getID() ?>'/>
<input type='hidden' name='version' value='<?php echo $content->getVersion() ?>'/>
</form>
<?php
} elseif ($reviewStatus['type'] == 1) {
if($reviewStatus["status"]!=0) {
print "<table class=\"folderView\"><thead><tr>";
print "<th>".getMLText("status")."</th>";
print "<th>".getMLText("comment")."</th>";
print "<th>".getMLText("last_update")."</th>";
print "</tr></thead><tbody><tr>";
print "<td>";
printReviewStatusText($reviewStatus["status"]);
print "</td>";
print "<td>".htmlspecialchars($reviewStatus["comment"])."</td>";
$indUser = $dms->getUser($reviewStatus["userID"]);
print "<td>".$reviewStatus["date"]." - ". htmlspecialchars($indUser->getFullname()) ."</td>";
print "</tr></tbody></table><br>\n";
}
?>
<form method="post" action="../op/op.ReviewDocument.php" id="form2" name="form2" enctype="multipart/form-data">
<?php echo createHiddenFieldWithKey('reviewdocument'); ?>
<table class="table-condensed">
<tr>
<td><?php printMLText("comment")?>:</td>
<td><textarea name="comment" cols="80" rows="4"></textarea></td>
</tr>
<tr>
<td><?php printMLText("review_file")?>:</td>
<td>
<?php
$this->printFileChooser('reviewfile', false);
?>
</td>
</tr>
<tr>
<td><?php printMLText("review_status")?>:</td>
<td>
<select name="reviewStatus">
<?php if($reviewStatus['status'] != 1) { ?>
<option value='1'><?php printMLText("status_reviewed")?></option>
<?php } ?>
<?php if($reviewStatus['status'] != -1) { ?>
<option value='-1'><?php printMLText("rejected")?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type='submit' class="btn" name='groupReview' value='<?php printMLText("submit_review")?>'/></td>
</tr>
</table>
<input type='hidden' name='reviewType' value='grp'/>
<input type='hidden' name='reviewType' value='<?= $reviewtype ?>'/>
<?php if($reviewtype == 'grp'): ?>
<input type='hidden' name='reviewGroup' value='<?php echo $reviewStatus['required']; ?>'/>
<?php endif; ?>
<input type='hidden' name='documentid' value='<?php echo $document->getID() ?>'/>
<input type='hidden' name='version' value='<?php echo $content->getVersion() ?>'/>
</form>
<?php
}
$this->contentContainerEnd();
$this->contentEnd();
$this->htmlEndPage();