use one form for ind and grp recipients

This commit is contained in:
Uwe Steinmann 2018-01-30 19:16:34 +01:00
parent 83e960fe03
commit 4fa0efa07d

View File

@ -37,8 +37,8 @@ class SeedDMS_View_ReceiptDocument extends SeedDMS_Bootstrap_Style {
function checkIndForm() function checkIndForm()
{ {
msg = new Array(); msg = new Array();
if (document.form1.reviewStatus.value == "") msg.push("<?php printMLText("js_no_receipt_status");?>"); if (document.formind.reviewStatus.value == "") msg.push("<?php printMLText("js_no_receipt_status");?>");
if (document.form1.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>"); if (document.formind.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (msg != "") { if (msg != "") {
noty({ noty({
text: msg.join('<br />'), text: msg.join('<br />'),
@ -55,10 +55,10 @@ function checkIndForm()
} }
function checkGrpForm() function checkGrpForm()
{ {
msg = ""; msg = new Array();
if (document.form2.reviewGroup.value == "") msg += "<?php printMLText("js_no_receipt_group");?>\n"; if (document.formgrp.reviewGroup.value == "") msg.push("<?php printMLText("js_no_receipt_group");?>");
if (document.form2.reviewStatus.value == "") msg += "<?php printMLText("js_no_receipt_status");?>\n"; if (document.formgrp.reviewStatus.value == "") msg.push("<?php printMLText("js_no_receipt_status");?>");
if (document.form2.comment.value == "") msg += "<?php printMLText("js_no_comment");?>\n"; if (document.formgrp.comment.value == "") msg.push("<?php printMLText("js_no_comment");?>");
if (msg != "") if (msg != "")
{ {
noty({ noty({
@ -75,11 +75,11 @@ function checkGrpForm()
return true; return true;
} }
$(document).ready(function() { $(document).ready(function() {
$('body').on('submit', '#form1', function(ev){ $('body').on('submit', '#formind', function(ev){
if(checkIndForm()) return; if(checkIndForm()) return;
event.preventDefault(); event.preventDefault();
}); });
$('body').on('submit', '#form2', function(ev){ $('body').on('submit', '#formgrp', function(ev){
if(checkGrpForm()) return; if(checkGrpForm()) return;
event.preventDefault(); event.preventDefault();
}); });
@ -110,24 +110,24 @@ $(document).ready(function() {
$this->contentContainerStart(); $this->contentContainerStart();
// Display the Receipt form. // Display the Receipt form.
if ($receiptStatus['type'] == 0) { $receipttype = ($receiptStatus['type'] == 0) ? 'ind' : 'grp';
if($receiptStatus["status"]!=0) { if($receiptStatus["status"]!=0) {
print "<table class=\"folderView\"><thead><tr>"; print "<table class=\"folderView\"><thead><tr>";
print "<th>".getMLText("status")."</th>"; print "<th>".getMLText("status")."</th>";
print "<th>".getMLText("comment")."</th>"; print "<th>".getMLText("comment")."</th>";
print "<th>".getMLText("last_update")."</th>"; print "<th>".getMLText("last_update")."</th>";
print "</tr></thead><tbody><tr>"; print "</tr></thead><tbody><tr>";
print "<td>"; print "<td>";
printReceiptStatusText($receiptStatus["status"]); printReceiptStatusText($receiptStatus["status"]);
print "</td>"; print "</td>";
print "<td>".htmlspecialchars($receiptStatus["comment"])."</td>"; print "<td>".htmlspecialchars($receiptStatus["comment"])."</td>";
$indUser = $dms->getUser($receiptStatus["userID"]); $indUser = $dms->getUser($receiptStatus["userID"]);
print "<td>".$receiptStatus["date"]." - ". htmlspecialchars($indUser->getFullname()) ."</td>"; print "<td>".$receiptStatus["date"]." - ". htmlspecialchars($indUser->getFullname()) ."</td>";
print "</tr></tbody></table><br>"; print "</tr></tbody></table><br>\n";
} }
?> ?>
<form class="form-horizontal" method="post" action="../op/op.ReceiptDocument.php" id="form1" name="form1"> <form class="form-horizontal" method="post" action="../op/op.ReceiptDocument.php" id="form<?= $receipttype ?>" name="form<?= $receipttype ?>">
<?php echo createHiddenFieldWithKey('receiptdocument'); ?> <?php echo createHiddenFieldWithKey('receiptdocument'); ?>
<div class="control-group"> <div class="control-group">
<label class="control-label"><?php printMLText("comment");?>:</label> <label class="control-label"><?php printMLText("comment");?>:</label>
@ -149,64 +149,16 @@ $(document).ready(function() {
</div> </div>
</div> </div>
<div class="controls"> <div class="controls">
<input type='submit' class="btn" name='indReceipt' value='<?php printMLText("submit_receipt")?>'/> <input type='submit' class="btn" name='<?= $receipttype ?>Receipt' value='<?php printMLText("submit_receipt")?>'/>
<div> <div>
<input type='hidden' name='receiptType' value='ind'/> <input type='hidden' name='receiptType' value='<?= $receipttype ?>'/>
<input type='hidden' name='documentid' value='<?php echo $document->getID() ?>'/> <?php if($receipttype == 'grp'): ?>
<input type='hidden' name='version' value='<?php echo $content->getVersion() ?>'/>
</form>
<?php
}
else if ($receiptStatus['type'] == 1) {
if($receiptStatus["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>";
printReceiptStatusText($receiptStatus["status"]);
print "</td>";
print "<td>".htmlspecialchars($receiptStatus["comment"])."</td>";
$indUser = $dms->getUser($receiptStatus["userID"]);
print "<td>".$receiptStatus["date"]." - ". htmlspecialchars($indUser->getFullname()) ."</td>";
print "</tr></tbody></table><br>\n";
}
?>
<form class="form-horizontal" method="post" action="../op/op.ReceiptDocument.php" id="form2" name="form2">
<?php echo createHiddenFieldWithKey('receiptdocument'); ?>
<div class="control-group">
<label class="control-label"><?php printMLText("comment");?>:</label>
<div class="controls">
<textarea name="comment" cols="80" rows="4"></textarea>
</div>
</div>
<div class="control-group">
<label class="control-label"><?php printMLText("receipt_status");?>:</label>
<div class="controls">
<select name="receiptStatus">
<?php if($receiptStatus['status'] != 1) { ?>
<option value='1'><?php printMLText("status_receipted")?></option>
<?php } ?>
<?php if($receiptStatus['status'] != -1) { ?>
<option value='-1'><?php printMLText("rejected")?></option>
<?php } ?>
</select>
</div>
</div>
<div class="controls">
<input type='submit' class="btn" name='groupReceipt' value='<?php printMLText("submit_receipt")?>'/>
</div>
<input type='hidden' name='receiptType' value='grp'/>
<input type='hidden' name='receiptGroup' value='<?php echo $receiptStatus['required']; ?>'/> <input type='hidden' name='receiptGroup' value='<?php echo $receiptStatus['required']; ?>'/>
<?php endif; ?>
<input type='hidden' name='documentid' value='<?php echo $document->getID() ?>'/> <input type='hidden' name='documentid' value='<?php echo $document->getID() ?>'/>
<input type='hidden' name='version' value='<?php echo $content->getVersion() ?>'/> <input type='hidden' name='version' value='<?php echo $content->getVersion() ?>'/>
</form> </form>
<?php <?php
}
$this->contentContainerEnd(); $this->contentContainerEnd();
$this->contentEnd(); $this->contentEnd();
$this->htmlEndPage(); $this->htmlEndPage();