stattbuchung_php_open/templates/anmeldeformular.inc

325 lines
9.7 KiB
HTML

</nav>
<article id='bidat-event-registration'>
<header>
<h2>Anmeldung für: <?=$this->produkt_titel?></h2>
</header>
<div class='infoblock'>
<div class="table">
<div class="row">
<div class="col-3 ch">
Beginn
</div>
<div class="col-9">
<time itemprop='startDate' dateTime='<?=$this->von->format(DateTime::ATOM)?>'><?=strftime('%e. %B %G - %R',$this->von->getTimestamp())?></time>
</div>
</div>
<div class="row">
<div class="col-3 ch">
Ende
</div>
<div class="col-9">
<time itemprop='startDate' dateTime='<?=$this->bis->format(DateTime::ATOM)?>'><?=strftime('%e. %B %G - %R',$this->bis->getTimestamp())?></time>
</div>
</div>
<div class="row">
<div class="col-3 ch">Max. TN</div>
<div class="col-9"><?=$this->maxtn?></div>
</div>
<div class="row">
<div class="col-3 ch">aktuell TN</div>
<div class="col-9"><?=$this->tn?></div>
</div>
<div class="row">
<div class="col-3 ch">Freie Plätze</div>
<div class="col-9"><?=$this->freitn?></div>
</div>
</div>
<details>
<?=$this->produkt_beschreibung?>
</details>
</div>
<!--action="ajax.php?register=872"-->
<section class='form'>
<form id="event-registration" class="needs-validation" method="post">
<input type="hidden" name="de_stattbuchung_event_Modul" value="<?=$this->oid?>" required="">
<input type="hidden" name="tnvoll" value="1" required="">
<div class="formrow">
<label>Anrede </label>
<input list="anrede" placeholder="Anrede ausw&auml;hlen" name="anrede" allowautofill="no" required="">
<datalist id="anrede">
<option value="Herr"> </option>
<option value="Frau"> </option>
</datalist>
</div>
<div class="formrow">
<label>Vorname </label>
<input type="text" id="vorname" name="vorname" required="">
</div>
<div class="formrow">
<label>Nachname </label>
<input type="text" id="nachname" name="nachname" required="">
</div>
<div class="formrow">
<label>Strasse </label>
<input type="text" id="strasse" name="strasse" required="">
</div>
<div class="formrow">
<label>PLZ </label>
<input type="text" id="plz" name="plz" required="">
</div>
<div class="formrow">
<label>Ort </label>
<input type="text" id="ort" name="ort" required="">
</div>
<div class="formrow">
<label>Email </label>
<input type="text" id="email" name="email" required="">
</div>
<div class="formrow">
<label class="form-check-label" for="datenschutz">Ich Stimme den Datenschutzbestimmungen zu </label>
<input type="checkbox" class="form-check-input" id="datenschutz" required="">
</div>
<div class="formrow">
<label for="kommentar">Bemerkung </label> <textarea class="form-control bidat_textarea" id="kommentar" name="kommentar" rows="3">
</textarea>
</div>
<div class='tnartliste' freitn='<?=$this->freitn?>'>
<?php
$warenkorbZeilen = array();
setlocale(LC_MONETARY, 'de_DE');
if (!is_null($this->de_stattbuchung_Preismodell)) {
foreach ($this->de_stattbuchung_Preismodell as $preismodell) {
echo "<div class='formrow'><label>".$preismodell[de_stattbuchung_Teilnehmerart][label]." (".round($preismodell[items][0][preis_brutto], 2)
." &euro;)</label> ";
echo "<input type='text' class='tnart' autocomplete='off' id='".$preismodell[items][0][key_klasse]."' beschriftung='Ticket ".$preismodell[de_stattbuchung_Teilnehmerart][label]."' price='".str_replace(',','.',round($preismodell[items][0][preis_brutto], 2))."' name='".$preismodell[items][0][key_klasse]."'>";
echo "<div class='alertbox' style='display:none'></div>";
echo "</div>";
$warenkorbZeilen[] = $preismodell[items][0][key_klasse];
}
}
?>
</div>
<?php
if($this->paypal == false) {
echo "<div class='formrow submitrow'>";
echo " <button type='submit' id='step1-btn' class='btn btn-primary'>Anmeldung abschicken </button> ";
echo " <button type='button' class='btn btn-secondary' name='btnBack' value='Zurück' onclick='window.history.go(-1);'>Zurück</button>";
echo " </div>";
} else {
echo "<div class='formrow submitrow'>";
echo " <button id='step1-btn' type='button' class='btn btn-primary'>Weiter zur Zahlungsart </button> ";
echo " <button type='button' class='btn btn-secondary' name='btnBack' value='Zurück' onclick='window.history.go(-1);'>Zurück</button>";
echo " </div>";
}
?>
</div>
</form>
</section>
<aside>
<div class='warenkorb' style='display:none'>
<h1>Ticket-Auswahl</h1>
<div class='table table-striped'>
<div class="tnart row headrow">
<div class="tnart ntart1 titel col-4 th"> Ticket
</div>
<div class="tnart ntart1 anzahl col th text-center" >Anzahl
</div>
<div class="tnart ntart1 sum col th text-right" >Preis
</div>
</div>
<?php
foreach ($warenkorbZeilen as $zeile) {
echo " <div class='tnart ".$zeile." row' style='display:none'>";
echo " <div class='tnart ntart1 titel col-4' id='".$zeile."_label'>";
echo " </div>";
echo " <div class='tnart ntart1 anzahl col text-center' id='".$zeile."_amount'>";
echo " </div>";
echo " <div class='tnart ntart1 sum col text-right' id='".$zeile."_sum'>";
echo " </div>";
echo " </div>";
}
?>
<div class='sumrow row'>
<div class='col'>Gesamt</div>
<div class='col text-center' id='amount'></div>
<div class='col text-right' id='summe'></div>
</div>
</div>
</div>
<div id='ppplus'>
</div>
</aside>
</article>
<script>
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function() {
'use strict';
window.addEventListener('load', function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();
</script>
<script src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js" type="text/javascript">
</script>
<script src="style/jquery-3.3.1.min.js"></script>
<script>
function loadPaywall(link) {
console.log("-->load Paywall"+link);
PAYPAL.apps.PPP({
"approvalUrl": link,
"placeholder": 'ppplus',
"mode": "sandbox",
"country": "DE"});
}
function formatCurrency(total) {
var neg = false;
if(total < 0) {
neg = true;
total = Math.abs(total);
}
return (neg ? "- " : '') + parseFloat(total, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString().replace('.',',')+' €';
}
function update(event) {
console.log("-->Funktion Update");
let sum = 0.0;
let sumAmount = 0.0;
$('input.tnart').each(
function () {
console.log("-->AddItem");
console.error($(this));
let rowamount = $(this).val();
let rowsum = (rowamount*$(this).attr('price'));
sum += rowsum;
sumAmount += Number(rowamount);
console.log('Class'+$(this).attr('id'));
$('#'+$(this).attr('id')+'_label').html($(this).attr('beschriftung'));
$('#'+$(this).attr('id')+'_amount').html(rowamount);
$('#'+$(this).attr('id')+'_sum').html(formatCurrency(rowsum));
if(rowamount >0 ) $('div.'+$(this).attr('id')).slideDown("slow");
else $('div.'+$(this).attr('id')).slideUp("fast");
});
console.log('SumAmount: '+Number(sumAmount));
console.log('Freitn: '+(Number($('.tnartliste').attr('freitn')))<15);
if(Number(sumAmount) > Number($('.tnartliste').attr('freitn'))) {
console.log("Error too big");
let correctBy =sumAmount-$('.tnartliste').attr('freitn');
let newAmount =$(event.currentTarget).val()-correctBy;
$(event.currentTarget).val(newAmount);
sumAmount -= correctBy;
sum -= correctBy*$(event.currentTarget).attr('price');
//$(this).setVal($(this).val()- $('.tnartliste').attr('freitn')-sumAmount);
console.log("Alertbox");
console.error($('.alertbox'));
$(event.currentTarget).next('.alertbox').html('Die maximal verfügbare Anzahl von Karten liegt derzeit bei '+$('.tnartliste').attr('freitn')+"<br>Ihre Eingabe wurde entsprechend korrigiert.").slideDown("slow");
update();
}
console.error(sum);
if(sum > 0) {
$('#summe').html(formatCurrency(sum));
$('#amount').html(sumAmount);
$('.warenkorb').slideDown("slow");
$('#step1-btn').show();
}
console.log("<--Funktion Update");
}
$(document).ready(function(){
$('#step1-btn').hide();
$("#step1-btn").on('click', event =>{
console.log("--> Click submit Botton");
$("input").prop("readonly", true);
$("input").addClass("inaktiv", true);
$(event.currentTarget).html("... wird bearbeitet").addClass('icon-spinner icon-spin icon-large');
$.ajax({
url: 'ajax.php?register=872',
type: 'post',
dataType: 'json',
data: $('form#event-registration').serialize(),
success: function(data) {
console.log("--> Response recieved");
console.error(data);
var link = data.links[1].href;
console.error(link);
loadPaywall(link);
$(event.currentTarget).hide();
}
});
});
$('input.tnart').each(function () {
$(this).on('keyup',event => {
$(event.currentTarget).next('.alertbox').hide();
update(event)});
});
});
</script>