Merge branch 'fronkdev' into 'master'

Added warning when not uploading file in Contract Productchange

See merge request fronk/thetool!1166
This commit is contained in:
Frank Schubert
2025-04-03 17:36:36 +00:00
2 changed files with 149 additions and 12 deletions

View File

@@ -19,7 +19,7 @@
<div class="card-body">
<h4 class="text-center mb-3">Neuer Contract</h4>
<form method="post" action="<?=self::getUrl("Contract", "saveProductchange")?>">
<form method="post" action="<?=self::getUrl("Contract", "saveProductchange")?>" enctype="multipart/form-data" id="changeForm">
<input type="hidden" name="contract_id" value="<?=$contract->id?>"/>
<?php if($f): ?>
<input type="hidden" name="f" value="<?=$f?>" />
@@ -235,10 +235,29 @@
</table>
<?php endif; ?>
<!-- TODO: Fileupload -->
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="contract_file_upload">Vertragsdokument Upload *</label>
<div class="col-lg-10">
<div class="custom-file">
<input type="file" name="contract_file_upload[]" id="contract_file_upload" class="custom-file-input" multiple="multiple" />
<label class="custom-file-label" for="attachment"> Datei(en) auswählen</label>
</div>
<small class="text-danger">Vertragsdokument erforderlich</small>
</div>
</div>
<div class="form-group row" id="no-upload-confirm-box">
<label class="col-lg-2 col-form-label" for="contract_file_upload"></label>
<div class="col-lg-10">
<div class="alert alert-danger">
<p><strong>ACHTUNG</strong>: Der Upload eines Vertragsdokuments ist, bis auf wenige Ausnahmen, immer nötig. Wenn Sie sich sicher sind, dass der Upload nicht nötig ist, kreuzen Sie folgende Option an:</p>
<label><input type="checkbox" id="no-upload-confirm"> Ich, <?=($me->name)?>, versichere, dass für diesen Produktwechsel kein Vertragsdokument nötig ist.</label>
</div>
</div>
</div>
<div class="form-group row mt-3">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="note"
@@ -261,7 +280,14 @@
</div>
</div>
<script type="text/javascript" src="<?=self::getResourcePath()?>plugins/bs-custom-file-input/bs-custom-file-input.min.js"></script>
<script>
bsCustomFileInput.init();
$(document).ready(() => {
$("#no-upload-confirm-box").hide();
});
$(".select2").select2({
allowClear: true,
placeholder: ""
@@ -381,4 +407,32 @@
linkActionChange(link_id);
});
}
function validateOrderForm() {
$("#contract_file_upload").removeClass("is-invalid");
$("#no-upload-confirm-box").hide();
let filelist = document.getElementById("contract_file_upload").files;
let confirm = $("#no-upload-confirm").is(":checked");
if(!filelist.length && !confirm) {
$("#no-upload-confirm-box").show();
$("#contract_file_upload").addClass("is-invalid");
return false;
}
return true;
}
$('#changeForm').submit(function(e) {
console.log("submit");
if(!validateOrderForm()) {
console.log("nope");
e.preventDefault();
return false;
}
return true;
});
</script>