1402 lines
65 KiB
PHP
1402 lines
65 KiB
PHP
<html>
|
|
<link rel="stylesheet" href="css/kunden.css">
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
</html>
|
|
<div class="sort">
|
|
<a>A</a>
|
|
<a>B</a>
|
|
<a>C</a>
|
|
<a>D</a>
|
|
<a>E</a>
|
|
<a>F</a>
|
|
<a>G</a>
|
|
<a>H</a>
|
|
<a>I</a>
|
|
<a>J</a>
|
|
<a>K</a>
|
|
<a>L</a>
|
|
<a>M</a>
|
|
<a>N</a>
|
|
<a>O</a>
|
|
<a>P</a>
|
|
<a>Q</a>
|
|
<a>R</a>
|
|
<a>S</a>
|
|
<a>T</a>
|
|
<a>U</a>
|
|
<a>V</a>
|
|
<a>W</a>
|
|
<a>X</a>
|
|
<a>Y</a>
|
|
<a>Z</a>
|
|
</div>
|
|
<div class="haupt_div">
|
|
<select class="sort_select">
|
|
<option>Sortieren</option>
|
|
<option disabled>A</option>
|
|
<option disabled>B</option>
|
|
<option disabled>C</option>
|
|
<option disabled>D</option>
|
|
<option disabled>E</option>
|
|
<option disabled>F</option>
|
|
<option disabled>G</option>
|
|
<option disabled>H</option>
|
|
<option disabled>I</option>
|
|
<option disabled>J</option>
|
|
<option disabled>K</option>
|
|
<option disabled>L</option>
|
|
<option disabled>M</option>
|
|
<option disabled>N</option>
|
|
<option disabled>O</option>
|
|
<option disabled>P</option>
|
|
<option disabled>Q</option>
|
|
<option disabled>R</option>
|
|
<option disabled>S</option>
|
|
<option disabled>T</option>
|
|
<option disabled>U</option>
|
|
<option disabled>V</option>
|
|
<option disabled>W</option>
|
|
<option disabled>X</option>
|
|
<option disabled>Y</option>
|
|
<option disabled>Z</option>
|
|
</select>
|
|
|
|
<?php
|
|
|
|
$sql = "SELECT * FROM kunden ORDER BY vorname";
|
|
$result = mysqli_query($db,$sql);
|
|
$eintraege = mysqli_num_rows($result);
|
|
if (mysqli_num_rows($result) == null) {
|
|
?>
|
|
<select class="kunden_daten_laden_select">
|
|
<option class="sort_select_kunde" value="standart">Kunde Wählen</option>
|
|
<option class="sort_select_kunde" data-id="kunde_anlegen">Kunde Anlegen</option>
|
|
</select>
|
|
<?php
|
|
}else {
|
|
?>
|
|
<select class="kunden_daten_laden_select">
|
|
<option class="sort_select_kunde" value="standart">Kunde Wählen</option>
|
|
<option class="sort_select_kunde" data-id="kunde_anlegen">Kunde Anlegen</option>
|
|
<?php
|
|
while($row = mysqli_fetch_assoc($result)) {
|
|
$fahrzeuge = json_decode($row['fahrzeuge'], true);
|
|
|
|
?>
|
|
<option data-id="<?php echo $row['id'] ?>" class="<?php echo mb_substr(strtoupper($row['vorname']), 0, 1); ?>"><?php echo $row['vorname']. " ". $row['nachname'] . " ( ". $fahrzeuge['fahrzeug0']['modell'] . " )"; ?></option>
|
|
|
|
<?php
|
|
}
|
|
|
|
|
|
?>
|
|
</select>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
$sql = "SELECT * FROM kunden ORDER BY vorname";
|
|
$result = mysqli_query($db,$sql);
|
|
$eintraege = mysqli_num_rows($result);
|
|
$old = "";
|
|
$beginn = "a";
|
|
$zaeler = 0;
|
|
if (mysqli_num_rows($result) == null) {
|
|
?>
|
|
<div id="kunden_auswahl_div">
|
|
<div class="kunden_anlegen"><label>Kunden Anlegen</label></div>
|
|
</div>
|
|
<?php
|
|
}else {
|
|
?>
|
|
<div id="kunden_auswahl_div">
|
|
<?php
|
|
while($row = mysqli_fetch_assoc($result)) {
|
|
|
|
if (mb_substr(strtolower($row['vorname']), 0, 1) != $old) {
|
|
?>
|
|
|
|
<div id="<?php echo mb_substr(strtoupper($row['vorname']), 0, 1); ?>" class="kunden_label">
|
|
<label ><?php echo mb_substr(strtoupper($row['vorname']), 0, 1); ?></label>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php
|
|
}else {
|
|
?>
|
|
|
|
<?php
|
|
}
|
|
|
|
$fahrzeuge = json_decode($row['fahrzeuge'], true);
|
|
|
|
?>
|
|
|
|
<a class="kunden_daten_laden kunden_auswahl" data-id="<?php echo $row['id'] ?>"><?php echo $row['vorname']. " ". $row['nachname'] . " ( ". $fahrzeuge['fahrzeug0']['modell'] . " )"; ?></a>
|
|
|
|
|
|
|
|
<?php
|
|
$zaeler = $zaeler+1;
|
|
|
|
if (mb_substr(strtolower($row['vorname']), 0, 1) != $beginn && mb_substr(strtolower($row['vorname']), 0, 1) == $old || $zaeler == $eintraege) {
|
|
?>
|
|
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
<?php
|
|
$old = mb_substr(strtolower($row['vorname']), 0, 1);
|
|
|
|
|
|
|
|
}
|
|
?>
|
|
|
|
<?php
|
|
}
|
|
|
|
|
|
?>
|
|
<div class="kunden_anlegen"><label>Kunden Anlegen</label></div>
|
|
</div>
|
|
<div class="kunden_daten_übertragen"><h1>Erfolgreich Gesendet!</h1></div>
|
|
<?php
|
|
$sql = "SELECT * FROM kunden ORDER BY vorname";
|
|
$result = mysqli_query($db,$sql);
|
|
while($row = mysqli_fetch_assoc($result)) {
|
|
?>
|
|
<div class="<?php echo $row['id'] ?> kunden_daten">
|
|
<div class="kunden_label">Kundendaten:</div>
|
|
<div class="box_33">
|
|
<label class="box_label">Vorname</label>
|
|
<input class="box_input" value="<?php echo $row['vorname'] ?>">
|
|
</div>
|
|
<div class="box_33">
|
|
<label class="box_label">Nachname</label>
|
|
<input class="box_input" value="<?php echo $row['nachname'] ?>">
|
|
</div>
|
|
<div class="box_33">
|
|
<label class="box_label">Straße</label>
|
|
<input class="box_input" value="<?php echo $row['straße'] ?>">
|
|
</div>
|
|
<div class="box_33">
|
|
<label class="box_label">Ort</label>
|
|
<input class="box_input" value="<?php echo $row['ort'] ?>">
|
|
</div>
|
|
<div class="box_33">
|
|
<label class="box_label">PLZ</label>
|
|
<input class="box_input" value="<?php echo $row['plz'] ?>">
|
|
</div>
|
|
<div class="box_33 nav_box">
|
|
<label class="box_label">Navigation</label>
|
|
<a class="nav_button" href="https://www.google.com/maps/search/?api=1&query=<?php echo rawurlencode($row['straße']. ', ' . $row['plz'] . ' '. $row['ort']); ?>"><button style="margin-top: 5px;" class="box_input">Navigation</button></a>
|
|
</div>
|
|
<?php
|
|
$json_telefonnummer = json_decode($row['telefonnummer'], true);
|
|
if ($json_telefonnummer == null) {
|
|
?>
|
|
<div class="box_33">
|
|
<label class="box_label">Telefonnummer</label>
|
|
<input class="box_input">
|
|
</div>
|
|
<?php
|
|
}else {
|
|
foreach ($json_telefonnummer as $key => $value){
|
|
?>
|
|
<div class="box_33">
|
|
<label class="box_label">Telefonnummer</label>
|
|
<input class="box_input" value="<?php echo $value ?>">
|
|
<a class="tel_button" href="tel://<?php echo $value ?>"><button style="margin-top: 5px;" class="box_input">Anrufen</button></a>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<div class="box_33">
|
|
<label class="box_label">Aufträge</label>
|
|
<a style="text-decoration: none;" href="?seite=aufträge&kunden_id=<?php echo $row['id'] ?>"><button class="box_input">Öffnen</button></a>
|
|
</div>
|
|
<div class="kunden_label">Fahrzeuge:</div>
|
|
<?php
|
|
$json_fahrzeuge = json_decode($row['fahrzeuge'], true);
|
|
if ($json_fahrzeuge == null) {
|
|
?>
|
|
<div class="box_33">
|
|
<label class="box_label">Fahrzeuge</label>
|
|
<input class="box_input">
|
|
</div>
|
|
<?php
|
|
}else {
|
|
?>
|
|
<div class="box kunden_fahrzeug_auswahl_div_komplett">
|
|
<label class="box_label">Fahrzeug Auswahl</label>
|
|
<div class="kunden_fahrzeug_auswahl_div">
|
|
|
|
<?php
|
|
foreach ($json_fahrzeuge as $key => $value){
|
|
?>
|
|
<a class="kunden_fahrzeug_auswahl"><?php echo $json_fahrzeuge[$key]['modell'] ?></a>
|
|
<?php
|
|
}
|
|
?>
|
|
<a class="fahrzeug_hinzufügen">+</a>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
|
|
foreach ($json_fahrzeuge as $key => $value){
|
|
?>
|
|
<div class="box_33 fahrzeug <?php echo str_replace(' ', '_', $json_fahrzeuge[$key]['modell']) ;?>" style="display: none">
|
|
<label class="box_label">Modell</label>
|
|
<input class="box_input" value="<?php echo $json_fahrzeuge[$key]['modell'] ?>">
|
|
</div>
|
|
<div class="box_33 fahrzeug <?php echo str_replace(' ', '_', $json_fahrzeuge[$key]['modell']) ;?>" style="display: none">
|
|
<label class="box_label">HSN</label>
|
|
<input class="box_input" value="<?php echo $json_fahrzeuge[$key]['hsn'] ?>">
|
|
<input class="box_input" type="hidden" value="<?php echo $json_fahrzeuge[$key]['ktypnr'] ?>">
|
|
</div>
|
|
<div class="box_33 fahrzeug <?php echo str_replace(' ', '_', $json_fahrzeuge[$key]['modell']) ;?>" style="display: none">
|
|
<label class="box_label">Motor</label>
|
|
<input class="box_input" value="<?php echo $json_fahrzeuge[$key]['motor'] ?>">
|
|
</div>
|
|
<div class="box_33 fahrzeug <?php echo str_replace(' ', '_', $json_fahrzeuge[$key]['modell']) ;?>" style="display: none">
|
|
<label class="box_label">Kennzeichen</label>
|
|
<input class="box_input" value="<?php echo $json_fahrzeuge[$key]['kennzeichen'] ?>">
|
|
</div>
|
|
<div class="box_33 fahrzeug <?php echo str_replace(' ', '_', $json_fahrzeuge[$key]['modell']) ;?>" style="display: none">
|
|
<label class="box_label">Baujahr</label>
|
|
<input class="box_input" value="<?php echo $json_fahrzeuge[$key]['bj'] ?>">
|
|
</div>
|
|
<div class="box_33 fahrzeug <?php echo str_replace(' ', '_', $json_fahrzeuge[$key]['modell']) ;?>" style="display: none">
|
|
<label class="box_label">Fahrgestellnr.</label>
|
|
<input class="box_input" value="<?php echo $json_fahrzeuge[$key]['vin'] ?>">
|
|
</div>
|
|
<div class="box_33 fahrzeug <?php echo str_replace(' ', '_', $json_fahrzeuge[$key]['modell']) ;?>" style="display: none">
|
|
<label class="box_label">Entfernen?</label>
|
|
<button class="box_input kunden_fahrzeug_entfernen">Bestätigen</button>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
}
|
|
?>
|
|
|
|
<div style="width: 100%; margin-bottom: 10px; margin-top: 10px;"><button class="kunden_daten_übernehmen button">Übernehmen</button></div>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
|
$('.sort a').click(function() {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Buchstabe gedrückt:' + this.text);
|
|
}
|
|
|
|
if ($(this).attr('class') != "focus") {
|
|
if ($('div .kunden_label:contains("'+this.text+'")').children().parent().length){
|
|
$(this).siblings().removeClass('focus');
|
|
$(this).addClass('focus');
|
|
$('div .kunden_label').children().parent().hide()
|
|
$('div .kunden_label').children().parent().nextUntil('div').hide()
|
|
|
|
$('div .kunden_label:contains("'+this.text+'")').children().parent().show()
|
|
$('div .kunden_label:contains("'+this.text+'")').children().parent().nextUntil('div').show()
|
|
}else {
|
|
$(this).siblings().removeClass('focus');
|
|
$('div .kunden_label').children().parent().show()
|
|
$('div .kunden_label').children().parent().nextUntil('div').show()
|
|
}
|
|
}else {
|
|
$(this).removeClass('focus');
|
|
$('div .kunden_label').children().parent().show()
|
|
$('div .kunden_label').children().parent().nextUntil('div').show()
|
|
}
|
|
});
|
|
|
|
$('.sort_select').change( function () {
|
|
var sort = this.value;
|
|
|
|
if (sort != "Sortieren") {
|
|
$(".kunden_daten_laden_select option").hide()
|
|
$(".kunden_daten_laden_select option[class*='"+sort+"']").show()
|
|
$(".kunden_daten_laden_select option[class*='sort_select_kunde']").show()
|
|
}else {
|
|
$(".kunden_daten_laden_select option").show()
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Lade vorhandene Kunden');
|
|
}
|
|
|
|
var vorhandene_kunden = $(".kunden_daten_laden_select option")
|
|
|
|
$.each(vorhandene_kunden, function(key, value) {
|
|
$('.sort_select option:contains("'+vorhandene_kunden[key].className+'")').prop('disabled', false)
|
|
});
|
|
|
|
});
|
|
|
|
$(document).on("click", ".kunden_auswahl", function() {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kunde Auswahl:' + $(this).data('id'));
|
|
}
|
|
|
|
$(this).siblings().removeClass('kunden_auswahl_focus');
|
|
$(this).addClass('kunden_auswahl_focus');
|
|
$('.kunden_daten_laden_select [data-id="'+$(this).data('id')+'"]').prop('selected', true);
|
|
});
|
|
|
|
$(document).on("click", ".kunden_fahrzeug_auswahl", function() {
|
|
$(this).siblings().removeClass('kunden_fahrzeug_auswahl_focus');
|
|
$(this).addClass('kunden_fahrzeug_auswahl_focus');
|
|
});
|
|
|
|
|
|
$(document).on("click", ".fahrzeug_hinzufügen", function() {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Fahrzeug Hinzufügen');
|
|
}
|
|
|
|
var name = window.prompt("Fahrzeug Modell", "");
|
|
if (name != null) {
|
|
var id = $('.kunden_auswahl_focus').data('id');
|
|
|
|
$(this).before('<a class="kunden_fahrzeug_auswahl">'+name+'</a>')
|
|
|
|
$('.kunden_fahrzeug_auswahl_div_komplett').after('<div class="box_33 fahrzeug '+name.replaceAll(' ', '_')+'" style="display: none">' +
|
|
'<label class="box_label">Modell</label>' +
|
|
'<input class="box_input" value="'+name+'">' +
|
|
'</div>' +
|
|
'<div class="box_33 fahrzeug '+name.replaceAll(' ', '_')+'" style="display: none">' +
|
|
'<label class="box_label">HSN</label>' +
|
|
'<input class="box_input" >' +
|
|
'</div>' +
|
|
'<div class="box_33 fahrzeug '+name.replaceAll(' ', '_')+'" style="display: none">' +
|
|
'<label class="box_label">Motor</label>' +
|
|
'<input class="box_input" >' +
|
|
'</div>' +
|
|
'<div class="box_33 fahrzeug '+name.replaceAll(' ', '_')+'" style="display: none">' +
|
|
'<label class="box_label">Kennzeichen</label>' +
|
|
'<input class="box_input" >' +
|
|
'</div>' +
|
|
'<div class="box_33 fahrzeug '+name.replaceAll(' ', '_')+'" style="display: none">' +
|
|
'<label class="box_label">Baujahr</label>' +
|
|
'<input class="box_input" >' +
|
|
'</div>' +
|
|
'<div class="box_33 fahrzeug '+name.replaceAll(' ', '_')+'" style="display: none">' +
|
|
'<label class="box_label">Fahrgestellnr.</label>' +
|
|
'<input class="box_input" >' +
|
|
'</div>' +
|
|
'<div class="box_33 fahrzeug '+name.replaceAll(' ', '_')+'" style="display: none">' +
|
|
'<label class="box_label">Entfernen?</label>' +
|
|
'<button class="box_input kunden_fahrzeug_entfernen">Bestätigen</button>' +
|
|
'</div>')
|
|
|
|
$('.' + id + ' .kunden_fahrzeug_auswahl_focus').removeClass('kunden_fahrzeug_auswahl_focus');
|
|
$('.' + id + ' .kunden_fahrzeug_auswahl:contains('+name+')').click();
|
|
|
|
|
|
|
|
}
|
|
});
|
|
|
|
$(document).on("click", ".kunden_fahrzeug_entfernen", function() {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Fahrzeug entfernen:' + $('.kunden_auswahl_focus').data('id'));
|
|
}
|
|
|
|
|
|
var id = $('.kunden_auswahl_focus').data('id');
|
|
|
|
if ( confirm("Fahrzeug "+$('.'+id+' .kunden_fahrzeug_auswahl_focus').text()+" wirklich entfernen?")){
|
|
|
|
|
|
var fahrzeug = $('.'+id+' .kunden_fahrzeug_auswahl_focus').text()
|
|
|
|
$('.'+id+' .fahrzeug.'+fahrzeug.replaceAll(' ', '_')).remove()
|
|
$('.'+id+' .kunden_fahrzeug_auswahl_focus').remove()
|
|
|
|
if ($('.'+id+' .kunden_fahrzeug_auswahl').first().length) {
|
|
$('.'+id+' .kunden_fahrzeug_auswahl').first().addClass('kunden_fahrzeug_auswahl_focus');
|
|
var kunden_fahrzeug_auswahl = $('.'+id+' .kunden_fahrzeug_auswahl_focus').text().replaceAll(' ', '_');
|
|
$('.'+id+' .fahrzeug.'+kunden_fahrzeug_auswahl).show();
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
|
|
|
function kunden_auswahl_scroll() {
|
|
var kunden_auswahl = document.getElementById('kunden_auswahl_div')
|
|
if ( kunden_auswahl.scrollWidth > kunden_auswahl.clientWidth || kunden_auswahl.scrollHeight > kunden_auswahl.clientHeight ) {
|
|
$('.kunden_anlegen').css('position', 'sticky')
|
|
}else {
|
|
$('.kunden_anlegen').css('position', 'absolute')
|
|
}
|
|
}
|
|
|
|
kunden_auswahl_scroll();
|
|
|
|
$(document).on("click", ".kunden_daten_laden", function() {
|
|
var id = $(this).data('id');
|
|
|
|
$('.kunden_daten').hide();
|
|
$('.'+id).css('display', 'flex');
|
|
if ($('.'+id+' .kunden_fahrzeug_auswahl_div').children().length > 1) {
|
|
if ($('.' + id + ' .kunden_fahrzeug_auswahl_focus').text() == "") {
|
|
$('.' + id + ' .kunden_fahrzeug_auswahl').first().addClass('kunden_fahrzeug_auswahl_focus');
|
|
var kunden_fahrzeug_auswahl = $('.' + id + ' .kunden_fahrzeug_auswahl_focus').text().replaceAll(' ', '_');
|
|
$('.' + id + ' .fahrzeug.' + kunden_fahrzeug_auswahl).show();
|
|
}
|
|
}
|
|
|
|
$(document).on("click", '.'+id+' .kunden_fahrzeug_auswahl_div a', function() {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Fahrzeug Auswahl:' + this.innerHTML);
|
|
}
|
|
|
|
$('.'+id+' .fahrzeug').hide();
|
|
var kunden_fahrzeug_auswahl = $('.'+id+' .kunden_fahrzeug_auswahl_focus').text().replaceAll(' ', '_');
|
|
$('.'+id+' .fahrzeug.'+kunden_fahrzeug_auswahl).show();
|
|
|
|
});
|
|
|
|
if ($('.'+id+' .box_33:contains("Telefonnummer") .box_input').last().val() != "") {
|
|
|
|
$('.'+id+' .box_33:contains("Telefonnummer")').last().after("<div class='box_33'><label class='box_label'>Telefonnummer</label><input class='box_input'></div>")
|
|
|
|
}
|
|
|
|
telefonnummer_hinzufuegen()
|
|
});
|
|
|
|
$(document).on("change", ".kunden_daten_laden_select", function() {
|
|
|
|
if ($(this).find(':selected').data('id') == "kunde_anlegen") {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kunden Anlegen');
|
|
}
|
|
|
|
$('.kunden_anlegen').click();
|
|
$('.kunden_daten_laden_select').val("standart")
|
|
}else {
|
|
$('.kunden_daten_laden.kunden_auswahl[data-id="'+$(this).find(':selected').data('id')+'"]').click();
|
|
}
|
|
|
|
|
|
});
|
|
|
|
function telefonnummer_hinzufuegen() {
|
|
|
|
var id = $('.kunden_auswahl_focus').data('id');
|
|
|
|
|
|
|
|
$(document).on("change", '.'+id+' .box_33:contains("Telefonnummer") .box_input', function() {
|
|
$('.'+id+' .box_33:contains("Telefonnummer") .box_input').last().off()
|
|
if ($('.'+id+' .box_33:contains("Telefonnummer") .box_input').last().val() != "") {
|
|
$('.'+id+' .box_33:contains("Telefonnummer")').last().after("<div class='box_33'><label class='box_label'>Telefonnummer</label><input class='box_input'></div>")
|
|
telefonnummer_hinzufuegen()
|
|
}
|
|
});
|
|
}
|
|
|
|
$('.kunden_anlegen').click(function() {
|
|
var name = window.prompt("Vor- Nachname", "");
|
|
if (name != null) {
|
|
if ($('#'+name.split('', 1)).length) {
|
|
var vorhanden = $('#'+name.split('', 1)).nextUntil('div')
|
|
|
|
var pos = 0
|
|
var vorhanden_text = [];
|
|
|
|
$.each(vorhanden, function(key, value) {
|
|
vorhanden_text[key] = vorhanden[key].text
|
|
});
|
|
|
|
vorhanden_text.push(name)
|
|
|
|
vorhanden_text.sort(function (a, b) {
|
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
|
});
|
|
|
|
|
|
$.each(vorhanden_text, function(key, value) {
|
|
if (vorhanden_text[key] == name) {
|
|
pos = key
|
|
}
|
|
});
|
|
|
|
if (pos > 0) {
|
|
if (pos - 1 > vorhanden_text.length) {
|
|
|
|
var danach = vorhanden_text[pos + 1]
|
|
$('.kunden_auswahl:contains(' + danach + ')').before('<a class="kunden_daten_laden kunden_auswahl" data-id="' + name.replaceAll(' ', '_') + '">' + name + '</a>')
|
|
|
|
}else {
|
|
|
|
var danach = vorhanden_text[pos - 1]
|
|
$('.kunden_auswahl:contains(' + danach + ')').after('<a class="kunden_daten_laden kunden_auswahl" data-id="' + name.replaceAll(' ', '_') + '">' + name + '</a>')
|
|
|
|
}
|
|
}else if (pos == 0){
|
|
var davor = vorhanden_text[pos + 1]
|
|
$('.kunden_auswahl:contains('+davor+')').before('<a class="kunden_daten_laden kunden_auswahl" data-id="'+name.replaceAll(' ', '_')+'">'+name+'</a>')
|
|
}
|
|
|
|
}else {
|
|
|
|
var vorhandene_labels = [];
|
|
var vorhandene_labels_text = [];
|
|
var pos_label = 0;
|
|
|
|
vorhandene_labels = $('.kunden_label label')
|
|
|
|
$.each(vorhandene_labels, function(key, value) {
|
|
vorhandene_labels_text[key] = vorhandene_labels[key].textContent
|
|
});
|
|
|
|
vorhandene_labels_text.push(name.split('', 1)[0])
|
|
|
|
vorhandene_labels_text.sort(function (a, b) {
|
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
|
});
|
|
|
|
|
|
$.each(vorhandene_labels_text, function(key, value) {
|
|
if (vorhandene_labels_text[key] == name.split('', 1)[0]) {
|
|
pos_label = key
|
|
}
|
|
});
|
|
|
|
if (pos_label > 0) {
|
|
if (pos_label - 1 > vorhandene_labels_text.length) {
|
|
|
|
var danach = vorhandene_labels_text[pos_label + 1]
|
|
$('#'+danach).nextUntil('div').last().before('<div id="'+name.split('', 1)[0].toUpperCase()+'" class="kunden_label"><label>'+name.split('', 1)[0].toUpperCase()+'</label></div>')
|
|
$('#'+name.split('', 1)[0].toUpperCase()).after('<a class="kunden_daten_laden kunden_auswahl" data-id="'+name.replaceAll(' ', '_')+'">'+name+'</a>')
|
|
|
|
}else {
|
|
|
|
var danach = vorhandene_labels_text[pos_label - 1]
|
|
$('#'+danach).nextUntil('div').last().after('<div id="'+name.split('', 1)[0].toUpperCase()+'" class="kunden_label"><label>'+name.split('', 1)[0].toUpperCase()+'</label></div>')
|
|
$('#'+name.split('', 1)[0].toUpperCase()).after('<a class="kunden_daten_laden kunden_auswahl" data-id="'+name.replaceAll(' ', '_')+'">'+name+'</a>')
|
|
}
|
|
}else if (pos_label == 0){
|
|
var davor = vorhandene_labels_text[pos_label + 1]
|
|
$('#'+davor).nextUntil('div').last().before('<div id="'+name.split('', 1)[0].toUpperCase()+'" class="kunden_label"><label>'+name.split('', 1)[0].toUpperCase()+'</label></div>')
|
|
$('#'+name.split('', 1)[0].toUpperCase()).after('<a class="kunden_daten_laden kunden_auswahl" data-id="'+name.replaceAll(' ', '_')+'">'+name+'</a>')
|
|
}
|
|
|
|
kunden_auswahl_scroll();
|
|
|
|
}
|
|
|
|
|
|
$('.kunden_daten_übertragen').after('<div class="'+name.replaceAll(' ', '_')+' kunden_daten" style="width: 80%; float: left; text-align: center; display: none; flex-wrap: wrap;">' +
|
|
'<div class="kunden_label">Kundendaten:</div>' +
|
|
'<div class="box_33">' +
|
|
'<label class="box_label">Vorname</label>' +
|
|
'<input class="box_input" value="'+name.split(' ')[0]+'">' +
|
|
'</div>' +
|
|
'<div class="box_33">' +
|
|
'<label class="box_label">Nachname</label>' +
|
|
'<input class="box_input" value="'+name.split(' ')[1]+'">' +
|
|
'</div>' +
|
|
'<div class="box_33">' +
|
|
'<label class="box_label">Straße</label>' +
|
|
'<input class="box_input">' +
|
|
'</div>' +
|
|
'<div class="box_33">' +
|
|
'<label class="box_label">Ort</label>' +
|
|
'<input class="box_input">' +
|
|
'</div>' +
|
|
'<div class="box_33">' +
|
|
'<label class="box_label">PLZ</label>' +
|
|
'<input class="box_input" >' +
|
|
'</div>' +
|
|
'<div class="box_33">' +
|
|
'<label class="box_label">Telefonnummer</label>' +
|
|
'<input class="box_input">' +
|
|
'</div>' +
|
|
'<div class="kunden_label">Fahrzeuge:</div>' +
|
|
'<div class="box kunden_fahrzeug_auswahl_div_komplett">' +
|
|
'<label class="box_label">Fahrzeug Auswahl</label>' +
|
|
'<div class="kunden_fahrzeug_auswahl_div" style="display: flex; justify-content: space-around; flex-wrap: wrap;">' +
|
|
'<a class="fahrzeug_hinzufügen">+</a>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'<div style="width: 100%; margin-bottom: 10px; margin-top: 10px;"><button class="kunden_daten_anlegen button">Übernehmen</button></div>' +
|
|
'</div>')
|
|
|
|
$('.kunden_auswahl_focus').removeClass('kunden_auswahl_focus');
|
|
$('.kunden_auswahl:contains("'+name+'")').click();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
$('.kunden_daten_übernehmen').click(function () {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Übernehmen:' + $('.kunden_auswahl_focus').data('id'));
|
|
}
|
|
|
|
var id = $('.kunden_auswahl_focus').data('id');
|
|
|
|
var fahrzeuge = {};
|
|
var fahrzeuge_daten = {};
|
|
fahrzeuge = $('.'+id+' .kunden_fahrzeug_auswahl');
|
|
|
|
$.each(fahrzeuge, function(key, value) {
|
|
|
|
fahrzeuge_daten['fahrzeug'+[key]] = {modell: fahrzeuge[key].text, hsn: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("HSN") .box_input').val(), motor: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Motor") .box_input').val(), kennzeichen: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Kennzeichen") .box_input').val(), bj: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Baujahr") .box_input').val(), vin: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Fahrgestellnr.") .box_input').val()}
|
|
});
|
|
|
|
|
|
var telefonnummern = {};
|
|
var telefonnummern_liste = $('.'+id+' .box_33:contains("Telefonnummer") .box_input');
|
|
|
|
$.each(telefonnummern_liste, function(key, value) {
|
|
|
|
if (telefonnummern_liste[key].value != "") {
|
|
telefonnummern['tel'+[key]] = telefonnummern_liste[key].value
|
|
}
|
|
});
|
|
|
|
var formData = {
|
|
id: id,
|
|
vorname: $('.'+id+' .box_label:contains("Vorname")').next().val(),
|
|
nachname: $('.'+id+' .box_label:contains("Nachname")').next().val(),
|
|
straße: $('.'+id+' .box_label:contains("Straße")').next().val(),
|
|
ort: $('.'+id+' .box_label:contains("Ort")').next().val(),
|
|
plz: $('.'+id+' .box_label:contains("PLZ")').next().val(),
|
|
telefonnummer: JSON.stringify(telefonnummern),
|
|
fahrzeuge: JSON.stringify(fahrzeuge_daten)
|
|
};
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/db/write.php",
|
|
data: formData,
|
|
dataType: "json",
|
|
encode: true,
|
|
}).done(function (data) {
|
|
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Übernehmen Data:' + data);
|
|
}
|
|
|
|
|
|
if (data['success'] == true){
|
|
$('.'+id).css('opacity', '0.4');
|
|
$('.kunden_daten_übertragen').show()
|
|
setTimeout(
|
|
function()
|
|
{
|
|
$('.kunden_daten_übertragen').hide()
|
|
$('.'+id).css('opacity', '1');
|
|
}, 2000);
|
|
|
|
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
$(document).on('click', '.kunden_daten_anlegen', function () {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Anlegen:' + $('.kunden_auswahl_focus').data('id'));
|
|
}
|
|
|
|
var id = $('.kunden_auswahl_focus').data('id');
|
|
|
|
var fahrzeuge = {};
|
|
var fahrzeuge_daten = {};
|
|
fahrzeuge = $('.'+id+' .kunden_fahrzeug_auswahl');
|
|
|
|
$.each(fahrzeuge, function(key, value) {
|
|
|
|
fahrzeuge_daten['fahrzeug'+[key]] = {modell: fahrzeuge[key].text, hsn: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("HSN") .box_input').val(), motor: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Motor") .box_input').val(), kennzeichen: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Kennzeichen") .box_input').val(), bj: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Baujahr") .box_input').val(), vin: $('.'+id+' .fahrzeug.'+fahrzeuge[key].text.replaceAll(' ', '_')+':contains("Fahrgestellnr.") .box_input').val()}
|
|
});
|
|
|
|
|
|
var telefonnummern = {};
|
|
var telefonnummern_liste = $('.'+id+' .box_33:contains("Telefonnummer") .box_input');
|
|
|
|
$.each(telefonnummern_liste, function(key, value) {
|
|
|
|
if (telefonnummern_liste[key].value != "") {
|
|
telefonnummern['tel'+[key]] = telefonnummern_liste[key].value
|
|
}
|
|
});
|
|
|
|
var formData = {
|
|
id: id,
|
|
vorname: $('.'+id+' .box_label:contains("Vorname")').next().val(),
|
|
nachname: $('.'+id+' .box_label:contains("Nachname")').next().val(),
|
|
straße: $('.'+id+' .box_label:contains("Straße")').next().val(),
|
|
ort: $('.'+id+' .box_label:contains("Ort")').next().val(),
|
|
plz: $('.'+id+' .box_label:contains("PLZ")').next().val(),
|
|
telefonnummer: JSON.stringify(telefonnummern),
|
|
fahrzeuge: JSON.stringify(fahrzeuge_daten)
|
|
};
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/db/add.php",
|
|
data: formData,
|
|
dataType: "json",
|
|
encode: true,
|
|
}).done(function (data) {
|
|
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Anlegen Data:' + data);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data['success'] == true){
|
|
$('.'+id).css('opacity', '0.4');
|
|
$('.kunden_daten_übertragen').show()
|
|
setTimeout(
|
|
function()
|
|
{
|
|
$('.kunden_daten_übertragen').hide()
|
|
$('.'+id).css('opacity', '1');
|
|
}, 2000);
|
|
|
|
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
// popup toggle und bearbeiten daten laden
|
|
$('.load_daten').click(function(){
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Laden:' + $(this).data('id'));
|
|
}
|
|
|
|
var el = this;
|
|
var id = $(this).data('id');
|
|
|
|
|
|
$(".bearbeiten").show();
|
|
document.getElementById('bearbeiten_form').style.display = 'block';
|
|
document.getElementById('bearbeiten_success').style.display = 'none';
|
|
document.getElementById('bearbeiten_fahrzeug_liste').innerHTML = ""
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen').innerHTML = ""
|
|
document.getElementById('bearbeiten_fahrzeug_bj').innerHTML = ""
|
|
document.getElementById('bearbeiten_fahrzeug_vin').innerHTML = ""
|
|
document.getElementById('bearbeiten_fahrzeug_hsn').innerHTML = ""
|
|
document.getElementById('bearbeiten_fahrzeug_modell').innerHTML = ""
|
|
document.getElementById('bearbeiten_fahrzeug_motor').innerHTML = ""
|
|
|
|
var formData = {
|
|
id: id
|
|
};
|
|
// AJAX Request
|
|
$.ajax({
|
|
url: '/db/get.php',
|
|
type: 'POST',
|
|
data: formData,
|
|
dataType: "json",
|
|
encode: true,
|
|
}).done(function (data) {
|
|
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Laden:' + data);
|
|
}
|
|
|
|
if (data['success'] == true){
|
|
var fahrzeug = JSON.parse(data['fahrzeuge'])
|
|
|
|
$.each(fahrzeug, function(key, value) {
|
|
$('#bearbeiten_fahrzeug_liste').append("<option id='"+key+"' value='"+key+"'>"+fahrzeug[key].modell+"</option>");
|
|
document.getElementById('bearbeiten_fahrzeug_modell').innerHTML += '<input type="text" style="display: none" id="bearbeiten_fahrzeug_modell_'+key+'" value="'+fahrzeug[key].modell+'">'
|
|
document.getElementById('bearbeiten_fahrzeug_hsn').innerHTML += '<input type="text" style="display: none" id="bearbeiten_fahrzeug_hsn_'+key+'" value="'+fahrzeug[key].hsn+'">'
|
|
document.getElementById('bearbeiten_fahrzeug_motor').innerHTML += '<input type="text" style="display: none" id="bearbeiten_fahrzeug_motor_'+key+'" value="'+fahrzeug[key].motor+'">'
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen').innerHTML += '<input type="text" style="display: none" id="bearbeiten_fahrzeug_kennzeichen_'+key+'" value="'+fahrzeug[key].kennzeichen+'">'
|
|
document.getElementById('bearbeiten_fahrzeug_bj').innerHTML += '<input type="text" style="display: none" id="bearbeiten_fahrzeug_bj_'+key+'" value="'+fahrzeug[key].bj+'">'
|
|
document.getElementById('bearbeiten_fahrzeug_vin').innerHTML += '<input type="text" style="display: none" id="bearbeiten_fahrzeug_vin_'+key+'" value="'+fahrzeug[key].vin+'">'
|
|
|
|
$("#bearbeiten_fahrzeug_modell").on("change", "#bearbeiten_fahrzeug_modell_"+key, function(){
|
|
$("#bearbeiten_fahrzeug_modell_"+key).attr("value", $("#bearbeiten_fahrzeug_modell_"+key).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_hsn").on("change", "#bearbeiten_fahrzeug_hsn_"+key, function(){
|
|
$("#bearbeiten_fahrzeug_hsn_"+key).attr("value", $("#bearbeiten_fahrzeug_hsn_"+key).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_motor").on("change", "#bearbeiten_fahrzeug_motor_"+key, function(){
|
|
$("#bearbeiten_fahrzeug_motor_"+key).attr("value", $("#bearbeiten_fahrzeug_motor_"+key).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_kennzeichen").on("change", "#bearbeiten_fahrzeug_kennzeichen_"+key, function(){
|
|
$("#bearbeiten_fahrzeug_kennzeichen_"+key).attr("value", $("#bearbeiten_fahrzeug_kennzeichen_"+key).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_bj").on("change", "#bearbeiten_fahrzeug_bj_"+key, function(){
|
|
$("#bearbeiten_fahrzeug_bj_"+key).attr("value", $("#bearbeiten_fahrzeug_bj_"+key).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_vin").on("change", "#bearbeiten_fahrzeug_vin_"+key, function(){
|
|
$("#bearbeiten_fahrzeug_vin_"+key).attr("value", $("#bearbeiten_fahrzeug_vin_"+key).val());
|
|
});
|
|
|
|
|
|
});
|
|
|
|
aktuell_bearbeiten = $('#bearbeiten_fahrzeug_liste').val();
|
|
|
|
if (aktuell_bearbeiten != null) {
|
|
document.getElementById('bearbeiten_fahrzeug_modell_' + aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_hsn_' + aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_motor_' + aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen_' + aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_bj_' + aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_vin_' + aktuell_bearbeiten).style.display = "block";
|
|
}
|
|
|
|
$("#bearbeiten_vorname").val(data['vorname']);
|
|
$("#bearbeiten_nachname").val(data['nachname']);
|
|
$("#bearbeiten_straße").val(data['straße']);
|
|
$("#bearbeiten_ort").val(data['ort']);
|
|
$("#bearbeiten_plz").val(data['plz']);
|
|
$("#bearbeiten_telefonnummer").val(data['telefonnummer']);
|
|
$("#bearbeiten_id").val(id);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#bearbeiten_fahrzeug_liste').change(function() {
|
|
|
|
document.getElementById('bearbeiten_fahrzeug_modell_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_hsn_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_motor_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_bj_'+aktuell_bearbeiten).style.display = "none";
|
|
aktuell_bearbeiten = $('#bearbeiten_fahrzeug_liste').val();
|
|
document.getElementById('bearbeiten_fahrzeug_modell_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_hsn_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_motor_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_bj_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_vin_'+aktuell_bearbeiten).style.display = "block";
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.hinzufügen_link_fahrzeug').click(function () {
|
|
var fahrzeuge_zahl = 0;
|
|
var fahrzeuge = document.querySelectorAll('#bearbeiten_fahrzeug_liste option')
|
|
Array.from(fahrzeuge).forEach( element => fahrzeuge_zahl = parseInt(element.value.slice(-1)));
|
|
fahrzeuge_zahl = fahrzeuge_zahl+1;
|
|
|
|
if ( aktuell_bearbeiten != null) {
|
|
document.getElementById('bearbeiten_fahrzeug_modell_' + aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_hsn_' + aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_motor_' + aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen_' + aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_bj_' + aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_vin_' + aktuell_bearbeiten).style.display = "none";
|
|
}
|
|
document.getElementById('bearbeiten_fahrzeug_modell').innerHTML += '<input type="text" style="display: block" id="bearbeiten_fahrzeug_modell_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('bearbeiten_fahrzeug_hsn').innerHTML += '<input type="text" style="display: block" id="bearbeiten_fahrzeug_hsn_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('bearbeiten_fahrzeug_motor').innerHTML += '<input type="text" style="display: block" id="bearbeiten_fahrzeug_motor_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen').innerHTML += '<input type="text" style="display: block" id="bearbeiten_fahrzeug_kennzeichen_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('bearbeiten_fahrzeug_bj').innerHTML += '<input type="text" style="display: block" id="bearbeiten_fahrzeug_bj_fahrzeug'+fahrzeuge_zahl+'">'
|
|
document.getElementById('bearbeiten_fahrzeug_vin').innerHTML += '<input type="text" style="display: block" id="bearbeiten_fahrzeug_vin_fahrzeug'+fahrzeuge_zahl+'">'
|
|
$('#bearbeiten_fahrzeug_liste').append("<option id='fahrzeug"+fahrzeuge_zahl+"' value='fahrzeug"+fahrzeuge_zahl+"'>Fahrzeug"+fahrzeuge_zahl+"</option>");
|
|
$('#bearbeiten_fahrzeug_liste').val('fahrzeug'+fahrzeuge_zahl);
|
|
|
|
$("#bearbeiten_fahrzeug_modell").on("change", "#bearbeiten_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#bearbeiten_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl).attr("value", $("#bearbeiten_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_hsn").on("change", "#bearbeiten_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#bearbeiten_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl).attr("value", $("#bearbeiten_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_motor").on("change", "#bearbeiten_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#bearbeiten_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl).attr("value", $("#bearbeiten_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_kennzeichen").on("change", "#bearbeiten_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#bearbeiten_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl).attr("value", $("#bearbeiten_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_bj").on("change", "#bearbeiten_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#bearbeiten_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl).attr("value", $("#bearbeiten_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#bearbeiten_fahrzeug_bj").on("change", "#bearbeiten_fahrzeug_vin_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#bearbeiten_fahrzeug_vin_fahrzeug"+fahrzeuge_zahl).attr("value", $("#bearbeiten_fahrzeug_vin_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
aktuell_bearbeiten = "fahrzeug"+fahrzeuge_zahl;
|
|
|
|
});
|
|
|
|
$('.delete_link_fahrzeug').click(function () {
|
|
document.getElementById( $('#bearbeiten_fahrzeug_liste').val() ).remove()
|
|
document.getElementById('bearbeiten_fahrzeug_modell_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_hsn_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_motor_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_bj_'+aktuell_bearbeiten).style.display = "none";
|
|
document.getElementById('bearbeiten_fahrzeug_vin_'+aktuell_bearbeiten).style.display = "none";
|
|
|
|
aktuell_bearbeiten = $('#bearbeiten_fahrzeug_liste').val();
|
|
|
|
document.getElementById('bearbeiten_fahrzeug_modell_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_hsn_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_motor_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_kennzeichen_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_bj_'+aktuell_bearbeiten).style.display = "block";
|
|
document.getElementById('bearbeiten_fahrzeug_vin_'+aktuell_bearbeiten).style.display = "block";
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
$('.bearbeiten_close').click(function(){
|
|
$(".bearbeiten").hide();
|
|
});
|
|
|
|
$('.übernehmen').click(function () {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Übernehmen:' + $(this).data('id'));
|
|
}
|
|
|
|
var el = this;
|
|
|
|
var json = {};
|
|
var liste = document.getElementById('bearbeiten_fahrzeug_liste').options;
|
|
|
|
$.each(liste, function(key, value) {
|
|
json[liste[key].value] = {modell: $('#bearbeiten_fahrzeug_modell_'+liste[key].value).val(), hsn: $('#bearbeiten_fahrzeug_modell_'+liste[key].value).val(), motor: $('#bearbeiten_fahrzeug_motor_'+liste[key].value).val(), kennzeichen: $('#bearbeiten_fahrzeug_kennzeichen_'+liste[key].value).val(), bj: $('#bearbeiten_fahrzeug_bj_'+liste[key].value).val(), vin: $('#bearbeiten_fahrzeug_vin_'+liste[key].value).val()}
|
|
});
|
|
|
|
var formData = {
|
|
id: $("#bearbeiten_id").val(),
|
|
vorname: $("#bearbeiten_vorname").val(),
|
|
nachname: $("#bearbeiten_nachname").val(),
|
|
straße: $("#bearbeiten_straße").val(),
|
|
ort: $("#bearbeiten_ort").val(),
|
|
plz: $("#bearbeiten_plz").val(),
|
|
telefonnummer: $("#bearbeiten_telefonnummer").val(),
|
|
fahrzeuge: JSON.stringify(json),
|
|
};
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/db/write.php",
|
|
data: formData,
|
|
dataType: "json",
|
|
encode: true,
|
|
}).done(function (data) {
|
|
//console.log(data);
|
|
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kundendaten Laden:' + data);
|
|
}
|
|
|
|
|
|
|
|
if (data['success'] == true){
|
|
document.getElementById('bearbeiten_form').style.display = 'none';
|
|
document.getElementById('bearbeiten_success').style.display = 'block';
|
|
setTimeout(
|
|
function()
|
|
{
|
|
$(".bearbeiten").hide();
|
|
}, 1000);
|
|
|
|
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
$('.hinzufügen_link').click(function() {
|
|
document.getElementById('anlegen_fahrzeug_liste').innerHTML = ""
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen').innerHTML = ""
|
|
document.getElementById('anlegen_fahrzeug_bj').innerHTML = ""
|
|
document.getElementById('anlegen_fahrzeug_vin').innerHTML = ""
|
|
document.getElementById('anlegen_fahrzeug_hsn').innerHTML = ""
|
|
document.getElementById('anlegen_fahrzeug_modell').innerHTML = ""
|
|
document.getElementById('anlegen_fahrzeug_motor').innerHTML = ""
|
|
$('#anlegen_fahrzeug_liste').append("<option id='fahrzeug1' value='fahrzeug1'>Fahrzeug1</option>");
|
|
|
|
document.getElementById('anlegen_fahrzeug_modell').innerHTML = '<input type="text" style="display: block" id="anlegen_fahrzeug_modell_fahrzeug1">'
|
|
document.getElementById('anlegen_fahrzeug_hsn').innerHTML = '<input type="text" style="display: block" id="anlegen_fahrzeug_hsn_fahrzeug1" >'
|
|
document.getElementById('anlegen_fahrzeug_motor').innerHTML = '<input type="text" style="display: block" id="anlegen_fahrzeug_motor_fahrzeug1" >'
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen').innerHTML = '<input type="text" style="display: block" id="anlegen_fahrzeug_kennzeichen_fahrzeug1" >'
|
|
document.getElementById('anlegen_fahrzeug_bj').innerHTML = '<input type="text" style="display: block" id="anlegen_fahrzeug_bj_fahrzeug1">'
|
|
document.getElementById('anlegen_fahrzeug_vin').innerHTML = '<input type="text" style="display: block" id="anlegen_fahrzeug_vin_fahrzeug1">'
|
|
|
|
|
|
|
|
$("#anlegen_fahrzeug_modell").on("change", "#anlegen_fahrzeug_modell_fahrzeug1", function(){
|
|
$("#anlegen_fahrzeug_modell_fahrzeug1").attr("value", $("#anlegen_fahrzeug_modell_fahrzeug1").val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_hsn").on("change", "#anlegen_fahrzeug_hsn_fahrzeug1", function(){
|
|
$("#anlegen_fahrzeug_hsn_fahrzeug1").attr("value", $("#anlegen_fahrzeug_hsn_fahrzeug1").val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_motor").on("change", "#anlegen_fahrzeug_motor_fahrzeug1", function(){
|
|
$("#anlegen_fahrzeug_motor_fahrzeug1").attr("value", $("#anlegen_fahrzeug_motor_fahrzeug1").val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_kennzeichen").on("change", "#anlegen_fahrzeug_kennzeichen_fahrzeug1", function(){
|
|
$("#anlegen_fahrzeug_kennzeichen_fahrzeug1").attr("value", $("#anlegen_fahrzeug_kennzeichen_fahrzeug1").val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_bj").on("change", "#anlegen_fahrzeug_bj_fahrzeug1", function(){
|
|
$("#anlegen_fahrzeug_bj_fahrzeug1").attr("value", $("#anlegen_fahrzeug_bj_fahrzeug1").val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_vin").on("change", "#anlegen_fahrzeug_vin_fahrzeug1", function(){
|
|
$("#anlegen_fahrzeug_vin_fahrzeug1").attr("value", $("#anlegen_fahrzeug_vin_fahrzeug1").val());
|
|
});
|
|
|
|
aktuell_anlegen = "fahrzeug1";
|
|
|
|
$(".anlegen").show();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#anlegen_fahrzeug_liste').change(function() {
|
|
|
|
document.getElementById('anlegen_fahrzeug_modell_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_hsn_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_motor_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_bj_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_vin_'+aktuell_anlegen).style.display = "none";
|
|
aktuell_anlegen = $('#anlegen_fahrzeug_liste').val();
|
|
document.getElementById('anlegen_fahrzeug_modell_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_hsn_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_motor_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_bj_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_vin_'+aktuell_anlegen).style.display = "block";
|
|
|
|
});
|
|
|
|
$('.hinzufügen_link_fahrzeug_anlegen').click(function () {
|
|
|
|
var fahrzeuge_zahl = 0;
|
|
var fahrzeuge = document.querySelectorAll('#anlegen_fahrzeug_liste option')
|
|
Array.from(fahrzeuge).forEach( element => fahrzeuge_zahl = parseInt(element.value.slice(-1)));
|
|
fahrzeuge_zahl = fahrzeuge_zahl+1;
|
|
|
|
document.getElementById('anlegen_fahrzeug_modell_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_hsn_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_motor_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_bj_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_vin_'+aktuell_anlegen).style.display = "none";
|
|
|
|
document.getElementById('anlegen_fahrzeug_modell').innerHTML += '<input type="text" style="display: block" id="anlegen_fahrzeug_modell_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('anlegen_fahrzeug_hsn').innerHTML += '<input type="text" style="display: block" id="anlegen_fahrzeug_hsn_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('anlegen_fahrzeug_motor').innerHTML += '<input type="text" style="display: block" id="anlegen_fahrzeug_motor_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen').innerHTML += '<input type="text" style="display: block" id="anlegen_fahrzeug_kennzeichen_fahrzeug'+fahrzeuge_zahl+'" >'
|
|
document.getElementById('anlegen_fahrzeug_bj').innerHTML += '<input type="text" style="display: block" id="anlegen_fahrzeug_bj_fahrzeug'+fahrzeuge_zahl+'">'
|
|
document.getElementById('anlegen_fahrzeug_vin').innerHTML += '<input type="text" style="display: block" id="anlegen_fahrzeug_vin_fahrzeug'+fahrzeuge_zahl+'">'
|
|
$('#anlegen_fahrzeug_liste').append("<option id='fahrzeug"+fahrzeuge_zahl+"' value='fahrzeug"+fahrzeuge_zahl+"'>Fahrzeug"+fahrzeuge_zahl+"</option>");
|
|
$('#anlegen_fahrzeug_liste').val('fahrzeug'+fahrzeuge_zahl);
|
|
|
|
|
|
$("#anlegen_fahrzeug_modell").on("change", "#anlegen_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#anlegen_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_hsn").on("change", "#anlegen_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#anlegen_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_motor").on("change", "#anlegen_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#anlegen_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_kennzeichen").on("change", "#anlegen_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#anlegen_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_bj").on("change", "#anlegen_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#anlegen_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
$("#anlegen_fahrzeug_vin").on("change", "#anlegen_fahrzeug_vin_fahrzeug"+fahrzeuge_zahl, function(){
|
|
$("#anlegen_fahrzeug_vin_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_vin_fahrzeug"+fahrzeuge_zahl).val());
|
|
});
|
|
|
|
//$('#anlegen_fahrzeug_modell_fahrzeug'+fahrzeuge_zahl).change(function() { $("#anlegen_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_modell_fahrzeug"+fahrzeuge_zahl).val()); });
|
|
//$('#anlegen_fahrzeug_hsn_fahrzeug'+fahrzeuge_zahl).change(function() { $("#anlegen_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_hsn_fahrzeug"+fahrzeuge_zahl).val()); });
|
|
//$('#anlegen_fahrzeug_motor_fahrzeug'+fahrzeuge_zahl).change(function() { $("#anlegen_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_motor_fahrzeug"+fahrzeuge_zahl).val()); });
|
|
//$('#anlegen_fahrzeug_kennzeichen_fahrzeug'+fahrzeuge_zahl).change(function() { $("#anlegen_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_kennzeichen_fahrzeug"+fahrzeuge_zahl).val()); });
|
|
//$('#anlegen_fahrzeug_bj_fahrzeug'+fahrzeuge_zahl).change(function() { $("#anlegen_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl).attr("value", $("#anlegen_fahrzeug_bj_fahrzeug"+fahrzeuge_zahl).val()); });
|
|
|
|
aktuell_anlegen = "fahrzeug"+fahrzeuge_zahl;
|
|
|
|
});
|
|
|
|
$('.delete_link_fahrzeug_anlegen').click(function () {
|
|
document.getElementById( $('#anlegen_fahrzeug_liste').val() ).remove()
|
|
document.getElementById('anlegen_fahrzeug_modell_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_hsn_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_motor_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_bj_'+aktuell_anlegen).style.display = "none";
|
|
document.getElementById('anlegen_fahrzeug_vin_'+aktuell_anlegen).style.display = "none";
|
|
|
|
aktuell_anlegen = $('#anlegen_fahrzeug_liste').val();
|
|
|
|
document.getElementById('anlegen_fahrzeug_modell_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_hsn_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_motor_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_kennzeichen_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_bj_'+aktuell_anlegen).style.display = "block";
|
|
document.getElementById('anlegen_fahrzeug_vin_'+aktuell_anlegen).style.display = "block";
|
|
|
|
|
|
|
|
});
|
|
|
|
$('.angelegen_close').click(function(){
|
|
$(".anlegen").hide();
|
|
});
|
|
|
|
$('.kunde_anlegen').click(function () {
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kunden Anlegen $(".kunde_anlegen").click(function ()');
|
|
}
|
|
|
|
var el = this;
|
|
|
|
var json = {};
|
|
var liste = document.getElementById('anlegen_fahrzeug_liste').options;
|
|
|
|
$.each(liste, function(key, value) {
|
|
json[liste[key].value] = {modell: $('#anlegen_fahrzeug_modell_'+liste[key].value).val(), hsn: $('#anlegen_fahrzeug_modell_'+liste[key].value).val(), motor: $('#anlegen_fahrzeug_motor_'+liste[key].value).val(), kennzeichen: $('#anlegen_fahrzeug_kennzeichen_'+liste[key].value).val(), bj: $('#anlegen_fahrzeug_bj_'+liste[key].value).val(), vin: $('#anlegen_fahrzeug_vin_'+liste[key].value).val()}
|
|
});
|
|
|
|
var formData = {
|
|
vorname: $("#anlegen_vorname").val(),
|
|
nachname: $("#anlegen_nachname").val(),
|
|
straße: $("#anlegen_straße").val(),
|
|
ort: $("#anlegen_ort").val(),
|
|
plz: $("#anlegen_plz").val(),
|
|
telefonnummer: $("#anlegen_telefonnummer").val(),
|
|
fahrzeuge: JSON.stringify(json),
|
|
};
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/db/add.php",
|
|
data: formData,
|
|
dataType: "json",
|
|
encode: true,
|
|
}).done(function (data) {
|
|
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kunden Anlegen $(".kunde_anlegen").click(function ():' + data);
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data['success'] == true){
|
|
document.getElementById('anlegen_form').style.display = 'none';
|
|
document.getElementById('anlegen_success').style.display = 'block';
|
|
|
|
var id = data['id'];
|
|
var name = $("#anlegen_vorname").val().split('','1').toString().toUpperCase();
|
|
var name_lower = $("#anlegen_vorname").val().split('','1').toString().toLowerCase();
|
|
var caption = [];
|
|
|
|
var new_table = '<table id="'+name_lower+'">' +
|
|
'<caption>'+name+'</caption>' +
|
|
'<tbody>' +
|
|
'<tr id="'+id+'">' +
|
|
'<td id="vorname" style="width: 10%;">'+$("#anlegen_vorname").val()+'</td>' +
|
|
'<td id="nachname" style="width: 10%;">'+$("#anlegen_nachname").val()+'</td>' +
|
|
'<td id="straße" style="width: 20%;">'+$("#anlegen_straße").val()+'</td>' +
|
|
'<td id="ort" style="width: 20%;">'+$("#anlegen_ort").val()+'</td>' +
|
|
'<td id="plz" style="width: 5%;">'+$("#anlegen_plz").val()+'</td>' +
|
|
'<td id="telefonnummer" style="width: 20%;">'+$("#anlegen_telefonnummer").val()+'</td>' +
|
|
'<td style="width: 5%;"><button style="display: block; margin: auto;" class="load_daten" data-id="'+id+'">Bearbeiten</button></td>' +
|
|
'<td style="width: 5%;"><button style="display: block; margin: auto;" class="delete_daten" data-name="'+$("#anlegen_vorname").val()+ ' ' +$("#anlegen_nachname").val()+'" data-char="'+name_lower+'" data-id="'+id+'">Löschen</button></td>' +
|
|
'<td style="width: 5%;"><button style="display: block; margin: auto;" onclick="window.location.href = ?seite=aufträge&kunden_id='+id+';">Aufträge</button></td>' +
|
|
'</tr>' +
|
|
'</tbody>' +
|
|
'</table>';
|
|
|
|
var insert_table = '<tr id="'+id+'">' +
|
|
'<td id="vorname" style="width: 10%;">'+$("#anlegen_vorname").val()+'</td>' +
|
|
'<td id="nachname" style="width: 10%;">'+$("#anlegen_nachname").val()+'</td>' +
|
|
'<td id="straße" style="width: 20%;">'+$("#anlegen_straße").val()+'</td>' +
|
|
'<td id="ort" style="width: 20%;">'+$("#anlegen_ort").val()+'</td>' +
|
|
'<td id="plz" style="width: 5%;">'+$("#anlegen_plz").val()+'</td>' +
|
|
'<td id="telefonnummer" style="width: 20%;">'+$("#anlegen_telefonnummer").val()+'</td>' +
|
|
'<td style="width: 5%;"><button style="display: block; margin: auto;" class="load_daten" data-id="'+id+'">Bearbeiten</button></td>' +
|
|
'<td style="width: 5%;"><button style="display: block; margin: auto;" class="delete_daten" data-name="'+$("#anlegen_vorname").val()+ ' ' +$("#anlegen_nachname").val()+'" data-char="'+name_lower+'" data-id="'+id+'">Löschen</button></td>' +
|
|
'<td style="width: 5%;"><button style="display: block; margin: auto;" onclick="window.location.href = ?seite=aufträge&kunden_id='+id+';">Aufträge</button></td>' +
|
|
'</tr>';
|
|
|
|
var current = document.querySelectorAll('caption');
|
|
if (current) {
|
|
Array.from(current).forEach( element => caption.push(element.innerHTML.toLowerCase()));
|
|
|
|
if (caption.includes(name_lower) == false) {
|
|
caption.push(name_lower);
|
|
caption.sort();
|
|
|
|
$.each(caption, function(key, value) {
|
|
if (value === name_lower) {
|
|
if (key == 0) {
|
|
$(insert_table).insertAfter(document.getElementById(caption[key+1]));
|
|
}else {
|
|
$(new_table).insertAfter(document.getElementById(caption[key-1]));
|
|
}
|
|
}
|
|
|
|
});
|
|
}else {
|
|
$("#"+name_lower).append(insert_table)
|
|
}
|
|
|
|
|
|
}
|
|
|
|
setTimeout(
|
|
function()
|
|
{
|
|
$(".anlegen").hide();
|
|
}, 1000);
|
|
|
|
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
$('.delete_daten').click(function(){
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kunde Löschen:' + $(this).data('id'));
|
|
}
|
|
|
|
var el = this;
|
|
var id = $(this).data('id');
|
|
var name = $(this).data('name');
|
|
var char = $(this).data('char');
|
|
|
|
if (confirm('Kunde '+name+' Löschen?')) {
|
|
alert('Kunde Gelöscht');
|
|
|
|
|
|
var formData = {
|
|
id: id,
|
|
};
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "/db/del.php",
|
|
data: formData,
|
|
dataType: "json",
|
|
encode: true,
|
|
}).done(function (data) {
|
|
|
|
|
|
if (<?php echo DEBUG ?>) {
|
|
console.log('Kunde Löschen Data:' + data);
|
|
}
|
|
|
|
if (data['success'] == true){
|
|
|
|
|
|
if ($('#'+char).children().length == 2) {
|
|
$('#'+char).remove();
|
|
}else {
|
|
$('#'+id).remove()
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
} else {
|
|
alert('Kunde nicht gelöscht!');
|
|
}
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|