Files
finanzen/app/Views/newBill.php
Markus 995e2ec111 redesign for mulituser
change validation concept (client and server)
using entities
2026-10-06 08:55:35 +02:00

141 lines
9.9 KiB
PHP

<?= $this->extend('layout'); ?>
<?= $this->section('css'); ?>
<link rel="stylesheet" href="/css/mawim.css">
<?= $this->endSection(); ?>
<?= $this->section('menu'); ?>
<?= $this->include('sidebar') ?>
<?= $this->endSection(); ?>
<?= $this->section('content'); ?>
<!-- Basic Vertical form layout section start -->
<section id="basic-vertical-layouts">
<div class="row match-height">
<div class="col-md-8 col-12">
<div class="card">
<div class="card-header pb-0">
<?php if ($booking['id']) : ?>
<h4 class="card-title"><?= ($booking['transfer']?'Transfer '.$booking['id'].' bearbeiten':($booking['scheduled']?'Terminbuchung '.$booking['id'].' bearbeiten':'Rechnung '.$booking['id'].' bearbeiten'))?></h4>
<?php else: ?>
<h4 class="card-title"><?= ($booking['transfer']?'Neuer Transfer':($booking['scheduled']?'Neue Terminbuchung':'Neue Rechnung'))?></h4>
<?php endif; ?>
<?php if (! empty($validation)) : ?>
<div class='alert alert-danger mt-2'>
<div class="errors" role="alert">
<ul>
<?php foreach ($validation as $error) : ?>
<li><?= esc($error) ?></li>
<?php endforeach ?>
</ul>
</div>
</div>
<?php endif; ?>
</div>
<div class="card-content">
<div class="card-body">
<?= view("bill_bookingline",['booking'=>$booking, 'template'=>true]); ?>
<form id="newbill" action="/edit" class="form form-vertical needs-validation" method="post" enctype="multipart/form-data" onsubmit="checkForm(event,this)" novalidate>
<!-- <form class="form form-vertical" id="newbill" method="post" enctype="multipart/form-data" onsubmit="logData(event)" action="<?= base_url() ?>newBill"> -->
<input type="hidden" value="<?= $booking['id'] ?>" name="id">
<input type="hidden" value="<?= $booking['amount']??0.0 ?>" name="amount">
<input type="hidden" value="<?= $booking['transfer']?'1':'0' ?>" name="transfer">
<input type="hidden" value="<?= ($booking['scheduled']??false)?'1':'0' ?>" name="scheduled">
<div class="form-body">
<div class="row">
<div class="col-12 <?= ($booking['transfer']?' d-none':(($booking['scheduled']??false)?' d-none':'')) ?>">
<label for="billfile">Rechnung:</label>
<input type="file" id="billfile" name="billfile" class="form-control <?= (!isset($booking['rechnung']))?'':'d-none' ?>" capture="environment" accept="image/*, application/pdf">
<?php if (isset($booking['rechnung'])): ?>
<a href="/viewInvoice/<?= $booking['rechnung'] ?>" id="billfileRef" target="_blank"> <?= $booking['rechnung'] ?></a>
<a class="" onclick="removeBillFile(this);"><i class="fa fa-trash"></i></a>
<?php endif; ?>
</div>
<div class="col-12 <?= ($booking['transfer']?' d-none':'d-none') ?>">
<div class='form-check'>
<div class="checkbox">
<label for="renummer">Re-Nr.</label>
<input type="checkbox" id="renummer" name="renummer" value="on" class='form-check-input' <?= set_checkbox('renummer', 'on', $renummer??false) ?>>
</div>
</div>
</div>
<div class="col-12">
<label for="datum">Datum</label>
<input type="date" class="form-control" id="datum" name="datum" value="<?= $booking['datum'] ?>" onclick="openBox(this);"/>
</div>
</div>
<div class="col-12 <?= ($booking['transfer']?' d-none':'') ?>">
<div class="form-group">
<label for="receiver">Empfänger</label>
<input type="text" class="form-control" id="receiver" name="receiver" <?=(($booking['transfer'])?'':'required')?> value="<?= $booking['receiver'] ?>">
</div>
</div>
<div class="col-12">
<div class="form-group">
<label for="sourceID">Konto:</label>
<select name="source_id" class="form-select" required id="sourceID" >
<option value="">----</option>
<?php foreach ($booking['sourcelist'] as $key => $value): ?>
<option value="<?= $key ?>" <?= ($key == $booking['source_id'])?'selected':'' ?>><?= $value ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-12 multi">
<div class="input-group has-validation">
<input type="text" id="total_in" name="total_in" value="<?= $booking['total_in'] ?>"
class="form-control dt-amount input"
pattern="[0-9\*\(\)\-\+\/,.]*"
oninput="if (!this.checkValidity()) this.value = this.value.slice(0, -1)"
placeholder="Einnahme" maxlength=120 ">
<input type="text" id="total_out" name="total_out" value="<?= $booking['total_out'] ?>"
class="form-control dt-amount output text-danger"
pattern="[0-9\*\(\)\-\+\/,.]*"
oninput="if (!this.checkValidity()) this.value = this.value.slice(0, -1)"
placeholder="Ausgabe" maxlength=120>
</div>
</div>
<?php if ($booking['scheduled']??false)
echo view("bill_scheduled",['booking'=>$booking]);
?>
<div class="col-12 d-none multi">
<div class="form-group">
<label for="openamount">Offener Betrag:</label>
<input type="text" class="form-control dt-amount" readonly="readonly" id="openamount" name="openamount">
<div class="invalid-feedback"></div>
</div>
</div>
<div class="col-12" id="linecont">
<?php $i = 0; foreach ($booking['sid'] as $_sid) :
echo view("bill_bookingline",['booking'=>$booking, 'i'=>$i,'template'=>false]);
?>
<?php $i++; endforeach; ?>
</div>
<div class="col-12 d-flex" role="group">
<a id="multiadd" class="btn btn-info <?= ($booking['transfer']?' d-none':'') ?>" onclick="addLine();" role="button">+ Zeile</a>
<input type="checkbox" id="validate" name="validate" value="1" class='btn-check' autocomplete="off" <?= set_checkbox('validate', '1', ($booking['validate'])?true:false) ?>>
<label class="btn btn-outline-danger" for="validate">Entwurf</label>
<?php if ($booking['id']) : ?>
<a class="btn btn-danger" data-bs-toggle="modal" data-bs-table="<?= ($booking['scheduled']??false)?'scheduled':'bill'?>" data-bs-id="<?= $booking['id'] ?>" data-bs-target="#mymodalDelete"><i class="fa fa-trash"></i></a>
<?php endif; ?>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<?= $this->endSection(); ?>
<?= $this->section('scripts'); ?>
<script>
function openBox(e) {
e.showPicker();
}
subsdata = <?= json_encode($booking['category']['subs']) ?>;
</script>
<script src="/js/billing.js"></script>
<?= $this->endSection(); ?>