<?php require_once "lib/api.php"; require_once "lib/auftrag.php"; session_start(); if (!isset($_SESSION['phone']) || (!isset($_SESSION['name']) && !isset($_SESSION['firma']) && !isset($_SESSION['lname']))) { header('Location: index.php?error&num='.urlencode($_SESSION['phone']).'&name='.urlencode($_SESSION['name'])); die(); } $content = ''; $kunde = null; if (isset($_SESSION['name'])) { $kunde = suche_kunde($_SESSION['name'], $_SESSION['phone']); } if ($kunde) { $fields = array("kundennr" => "kundennr", "firma" => "firma", "fname" => "vorname", "lname" => "nachname", "address" => "adresse", "zip" => "plz", "city" => "ort"); foreach ($fields as $sesskey => $arrkey) { if (isset($_SESSION[$sesskey]) && $_SESSION[$sesskey] != '' && $_SESSION[$sesskey] != 'bekannt') { $kunde[$arrkey] = $_SESSION[$sesskey]; } if (isset($kunde[$arrkey])) { $_SESSION[$sesskey] = $kunde[$arrkey]; } } unset($_SESSION['name']); } if (isset($_REQUEST['error'])) { $content .= '<div class="card text-white bg-danger mb-3"> <div class="card-header">Fehler</div> <div class="card-body">Bitte geben Sie Ihren Namen an.</div> </div>'; } if (!$kunde) { $kunde = array('kundennr' => '', 'firma' => '', 'nachname' => '', 'vorname' => '', 'adresse' => '', 'plz' => '', 'ort' => ''); $fields = array("kundennr" => "kundennr", "firma" => "firma", "fname" => "vorname", "lname" => "nachname", "address" => "adresse", "zip" => "plz", "city" => "ort"); foreach ($fields as $sesskey => $arrkey) { if (isset($_SESSION[$sesskey])) { $kunde[$arrkey] = $_SESSION[$sesskey]; } } } $headline = 'Adresse eingeben'; if ($kunde) { $headline = 'Willkommen zurück!'; $content .= ' <p>Schön, wir kennen uns ja schon! Wenn sich an Ihrer Adresse seit Ihrem letztem Besuch etwas geändert hat, ändern Sie es bitte hier. Ansonsten können Sie die Felder so lassen. Aus Datenschutzgründen werden die gespeicherten Daten hier nicht angezeigt.</p> '; } else { $content .= ' <p>Bitte geben Sie in diesem Schritt Ihre Adresse ein.</p> '; } $fields = array("vorname" => "Vorname", "nachname" => "Nachname", "firma" => "Firmenname", "adresse" => "Adresse", "plz" => "PLZ", "ort" => "Ort"); $placeholders = $fields; $contents = $kunde; foreach ($fields as $field => $label) { if (isset($kunde[$field]) && $kunde[$field] == 'bekannt') { $placeholders[$field] = $label.' wie beim letzten Besuch'; $contents[$field] = ''; } elseif (!isset($contents[$field])) { $contents[$field] = ''; } } $content .= ' <form class="form" action="save.php" method="post"> <input type="hidden" name="form" value="address">'; if (isset($kunde['firma']) && $kunde['firma'] != '') { $content .= ' <div class="form-group form-group-lg row"> <div class="col-sm-12"><input class="form-control" id="address" name="address" type="text" placeholder="'.$placeholders['firma'].'" autocomplete="street-address" value="'.$contents['firma'].'"></div> </div>'; } $content .= ' <div class="form-group form-group-lg row"> <div class="col-sm-6"><input class="form-control" id="fname" name="fname" type="text" placeholder="'.$placeholders['vorname'].'" autocomplete="given-name" value="'.$contents['vorname'].'"></div> <div class="col-sm-6"><input class="form-control" id="lname" name="lname" type="text" placeholder="'.$placeholders['nachname'].'" autocomplete="family-name" value="'.$contents['nachname'].'"></div> </div> <div class="form-group form-group-lg row"> <div class="col-sm-12"><input class="form-control" id="address" name="address" type="text" placeholder="'.$placeholders['adresse'].'" autocomplete="street-address" value="'.$contents['adresse'].'"></div> </div> <div class="form-group form-group-lg row"> <div class="col-sm-4"><input class="form-control" id="zip" name="zip" type="text" placeholder="'.$placeholders['plz'].'" autocomplete="postal-code" value="'.$contents['plz'].'"></div> <div class="col-sm-8"><input class="form-control" id="city" name="city" type="text" placeholder="'.$placeholders['ort'].'" autocomplete="locality" value="'.$contents['ort'].'"></div> </div> <div class="form-group form-group-lg"> <div><input class="btn btn-primary btn-lg" type="submit" value="Weiter >"></div> </div> </form> '; include("template.php");