public static function getById($id)
 {
     $pdo = DbConnect::connect();
     $sql = "SELECT * from projektmitarbeiter WHERE id=:id";
     $stmt = $pdo->prepare($sql);
     $stmt->execute([':id' => $id]);
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     return new ProjektMitarbeiter(Projekt::getById($rows[0]['projekt_id']), Mitarbeiter::getById($rows[0]['mitarbeiter_id']), $rows[0]['von'], $rows[0]['bis'], $rows[0]['id']);
 }
 public static function doAction($action, $id)
 {
     switch ($action) {
         case 'showList':
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         case 'showUpdate':
             $out = Ausleihe::getById($id);
             $out = self::transformUpdate($out);
             break;
         case 'showInsert':
             $out = self::transformUpdate();
             break;
         case 'update':
             $fahrzeugFiltered = filter_input(INPUT_POST, 'fahrzeug', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $mitarbeiterFiltered = filter_input(INPUT_POST, 'mitarbeiter', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $vonFiltered = filter_input(INPUT_POST, 'von', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $bisFiltered = filter_input(INPUT_POST, 'bis', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $updateausleiheidFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT & FILTER_SANITIZE_SPECIAL_CHARS);
             $out = new Ausleihe(Auto::getById($fahrzeugFiltered), Mitarbeiter::getById($mitarbeiterFiltered), HTML::dateAndTimeToDateTime($vonFiltered), HTML::dateAndTimeToDateTime($bisFiltered), $updateausleiheidFiltered);
             $out = Ausleihe::update($out);
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         case 'insert':
             $fahrzeugFiltered = filter_input(INPUT_POST, 'fahrzeug', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $mitarbeiterFiltered = filter_input(INPUT_POST, 'mitarbeiter', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $vonFiltered = filter_input(INPUT_POST, 'von', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $bisFiltered = filter_input(INPUT_POST, 'bis', FILTER_SANITIZE_MAGIC_QUOTES & FILTER_SANITIZE_SPECIAL_CHARS);
             $out = new Ausleihe(Auto::getById($fahrzeugFiltered), Mitarbeiter::getById($mitarbeiterFiltered), HTML::dateAndTimeToDateTime($vonFiltered), HTML::dateAndTimeToDateTime($bisFiltered), NULL);
             $out = Ausleihe::insert($out);
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         case 'delete':
             $deleteausleiheidFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT & FILTER_SANITIZE_SPECIAL_CHARS);
             $out = $deleteausleiheidFiltered;
             $out = Ausleihe::delete($out);
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         default:
             break;
     }
     return $out;
 }
 public static function doAction($action, &$view, $id)
 {
     switch ($action) {
         case 'showList':
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         case 'showUpdate':
             $out = Ausleihe::getById($id);
             $out = self::transformUpdate($out);
             break;
         case 'showInsert':
             $out = self::transformUpdate();
             break;
         case 'update':
             $daten = $_POST['daten'];
             $daten = json_decode($daten, FALSE);
             $out = new Ausleihe(Auto::getById($daten->fahrzeug), Mitarbeiter::getById($daten->mitarbeiter), HTML::dateAndTimeToDateTime($daten->von), HTML::dateAndTimeToDateTime($daten->bis), $daten->uausid);
             $out = Ausleihe::update($out);
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         case 'insert':
             $daten = $_POST['daten'];
             $daten = json_decode($daten, FALSE);
             $out = new Ausleihe(Auto::getById($daten->fahrzeug), Mitarbeiter::getById($daten->mitarbeiter), HTML::dateAndTimeToDateTime($daten->von), HTML::dateAndTimeToDateTime($daten->bis), NULL);
             $out = Ausleihe::insert($out);
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         case 'delete':
             $out = $_POST['lausid'];
             $out = Ausleihe::delete($out);
             $out = Ausleihe::getAll();
             $out = self::transform($out);
             break;
         default:
             break;
     }
     return $out;
 }
 private static function transformUpdate($out = NULL)
 {
     $returnOut = [];
     $linkeSpalte = [];
     $rechteSpalte = [];
     for ($i = 0; $i < count(ProjektMitarbeiter::getNames()); $i++) {
         array_push($linkeSpalte, ProjektMitarbeiter::getNames()[$i]);
     }
     if ($out !== NULL) {
         array_push($linkeSpalte, HTML::buildInput('hidden', 'id', $out->getId()));
     } else {
         array_push($linkeSpalte, '');
     }
     if ($out !== NULL) {
         $dbWerte = json_decode(json_encode($out), true);
     }
     // überführe $dbWerte in rechte Spalte
     // options für die vorgesetzten
     $projekte = Projekt::getAll();
     $options = [];
     // zum abwählen
     $options[0] = ['value' => 0, 'label' => ''];
     $hatProjekt = FALSE;
     foreach ($projekte as $o) {
         $options[$o->getId()] = ['value' => $o->getId(), 'label' => $o->getName()];
         if ($out !== NULL) {
             if ($o->getId() === $out->getProjekt()->getId()) {
                 $options[$o->getId()]['selected'] = TRUE;
                 $hatProjekt = TRUE;
             }
         }
     }
     if ($hatProjekt == FALSE) {
         $options[0]['selected'] = TRUE;
     }
     $mitarbeiter = Mitarbeiter::getAll();
     $options2 = [];
     // zum abwählen
     $options2[0] = ['value' => 0, 'label' => ''];
     $hatMitarbeiter = FALSE;
     foreach ($mitarbeiter as $o) {
         $options2[$o->getId()] = ['value' => $o->getId(), 'label' => $o->getVorname() . ' ' . $o->getNachname()];
         if ($out !== NULL) {
             if ($o->getId() === $out->getMitarbeiter()->getId()) {
                 $options2[$o->getId()]['selected'] = TRUE;
                 $hatMitarbeiter = TRUE;
             }
         }
     }
     if ($hatMitarbeiter == FALSE) {
         $options2[0]['selected'] = TRUE;
     }
     if ($out !== NULL) {
         array_push($rechteSpalte, HTML::buildDropDown('projekt', '1', $options, NULL, 'projekt'));
         array_push($rechteSpalte, HTML::buildDropDown('mitarbeiter', '1', $options2, NULL, 'mitarbeiter'));
         array_push($rechteSpalte, HTML::buildInput('text', 'vonTag', HTML::extractDateFromDateTime($dbWerte['von'])));
         array_push($rechteSpalte, HTML::buildInput('text', 'vonZeit', HTML::extractTimeFromDateTime($dbWerte['von'])));
         array_push($rechteSpalte, HTML::buildInput('text', 'bisTag', HTML::extractDateFromDateTime($dbWerte['bis'])));
         array_push($rechteSpalte, HTML::buildInput('text', 'bisZeit', HTML::extractTimeFromDateTime($dbWerte['bis'])));
         array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'updateProjektMitarbeiter', 'OK'));
     } else {
         array_push($rechteSpalte, HTML::buildDropDown('projekt', '1', $options, NULL, 'projekt'));
         array_push($rechteSpalte, HTML::buildDropDown('mitarbeiter', '1', $options2, NULL, 'mitarbeiter'));
         array_push($rechteSpalte, HTML::buildInput('text', 'vonTag', '', NULL, 'vonTag'));
         array_push($rechteSpalte, HTML::buildInput('text', 'vonZeit', '', NULL, 'vonZeit'));
         array_push($rechteSpalte, HTML::buildInput('text', 'bisTag', '', NULL, 'bisTag'));
         array_push($rechteSpalte, HTML::buildInput('text', 'bisZeit', '', NULL, 'bisZeit'));
         array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'insertProjektMitarbeiter', 'OK'));
     }
     $returnOut = HTML::buildFormularTable($linkeSpalte, $rechteSpalte);
     return $returnOut;
 }
include_once "../libs/libraries.php";
function invokeLogin($txt)
{
    $_SESSION['txt'] = $txt;
    include "login.php";
    exit;
}
if (isset($_POST['pass']) && isset($_POST['user'])) {
    $user = addslashes($_POST['user']);
    $_SESSION['mdpass'] = md5($_POST['pass']);
    $_SESSION['user'] = $user;
    $_POST['pass'] = "";
    $pass = "";
}
$err = new ErrorQueue();
$conn = new Connection();
$mitarbeiter = new Mitarbeiter($conn);
if (!isset($_SESSION['mdpass']) || !isset($_SESSION['user'])) {
    invokeLogin("Geben Sie Ihre Benutzernamen und Passwort ein!");
} else {
    if ($conn->connect(Config::DB_SERVER, Config::DB_NAME, Config::DB_USERNAME, Config::DB_PASSWORD)) {
        if (!$mitarbeiter->login($_SESSION['user'], $_SESSION['mdpass'])) {
            invokeLogin($mitarbeiter->getLastError());
        }
        // if can't init, do login, else it's OK
    } else {
        $err->addError($conn->getLastError());
    }
    // if-else connection
}
// if-else variables
            }
            $vorhandene_studiengaenge .= "</table>";
        } else {
            $vorhandene_studiengaenge = "Keine";
        }
    }
} else {
    $err->addError($conn->getLastError());
}
if (($dozenumeraton = Dozent::enumDozenten($conn)) == false) {
    unset($dozenumeraton);
} else {
    $err->addError($conn->getLastError());
}
$allemitarbeiter = new UtilBuffer();
Mitarbeiter::getAlleMitarbeiter($conn, $err, $allemitarbeiter);
if (($studiengaegenum = Studiengang::enumStudiengaenge($conn)) == false) {
    unset($studiengaegenum);
} else {
    $err->addError($conn->getLastError());
}
?>

<html>
<head>
<title>Praktikumssachbearbeiter verwalten</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../styles/main.css" type="text/css">
<link rel="stylesheet" href="../styles/menu.css" type="text/css">
<link rel="stylesheet" href="../styles/admin.css" type="text/css">
Example #7
0
 * hier einige vorlagen später auch noch in die HTML umzusetzen
 */
//options für die abteilungen
$abteilung = $out;
$abt = Abteilung::getAll();
$options = [];
// zum abwählen
$options[0] = ['value' => 0, 'label' => ''];
foreach ($abt as $o) {
    $options[$o->getId()] = ['value' => $o->getId(), 'label' => $o->getName()];
    if ($o->getId() === $abteilung->getAbteilung()->getId()) {
        $options[$o->getId()]['selected'] = TRUE;
    }
}
// options für die vorgesetzten
$vorgesetzte = Mitarbeiter::getAll();
$options2 = [];
// zum abwählen
$options2[0] = ['value' => 0, 'label' => ''];
$hatVorgesetzte = FALSE;
foreach ($vorgesetzte as $o) {
    $options2[$o->getId()] = ['value' => $o->getId(), 'label' => $o->getVorname() . ' ' . $o->getNachname()];
    if ($o->getVorgesetzter() !== NULL) {
        if ($o->getId() === $out->getId()) {
            $options2[$o->getVorgesetzter()->getId()]['selected'] = TRUE;
            $hatVorgesetzte = TRUE;
        }
    }
}
if ($hatVorgesetzte == FALSE) {
    $options2[0]['selected'] = TRUE;
 private static function transformUpdate($out = NULL)
 {
     $returnOut = [];
     $linkeSpalte = [];
     $rechteSpalte = [];
     for ($i = 0; $i < count(Mitarbeiter::getNames()); $i++) {
         array_push($linkeSpalte, Mitarbeiter::getNames()[$i]);
     }
     if ($out !== NULL) {
         array_push($linkeSpalte, HTML::buildInput('hidden', 'id', $out->getId()));
     } else {
         array_push($linkeSpalte, '');
     }
     if ($out !== NULL) {
         $dbWerte = json_decode(json_encode($out), true);
     }
     // überführe $dbWerte in rechte Spalte
     //options für die abteilungen
     //        $abt = Abteilung::getAll();
     //        $options = [];
     //
     //        // zum abwählen
     //        $options[0] = ['value' => 0, 'label' => ''];
     //        $hatAbteilung = FALSE;
     //        foreach ($abt as $o) {
     //            $options[$o->getId()] = ['value' => $o->getId(), 'label' => $o->getName()];
     //            if ($out !== NULL) {
     //                if ($o->getId() === $out->getAbteilung()->getId()) {
     //                    $options[$o->getId()]['selected'] = TRUE;
     //                    $hatAbteilung = TRUE;
     //                }
     //            }
     //        }
     //        if ($hatAbteilung == FALSE) {
     //            $options[0]['selected'] = TRUE;
     //        }
     $selected = NULL;
     if ($out !== NULL) {
         if ($out->getAbteilung() !== NULL) {
             $selected = $out->getAbteilung()->getId();
             // Foreign Key
         }
     }
     $options = Option::buildOptions('Abteilung', $selected);
     $selected = NULL;
     if ($out !== NULL) {
         if ($out->getVorgesetzter() !== NULL) {
             $selected = $out->getVorgesetzter()->getId();
         }
     }
     $options2 = Option::buildOptions('Mitarbeiter', $selected, TRUE);
     // zum abwählen
     //        $options2[0] = ['value' => 0, 'label' => ''];
     //        $hatVorgesetzte = FALSE;
     //        foreach ($vorgesetzte as $o) {
     //            $options2[$o->getId()] = ['value' => $o->getId(), 'label' => $o->getVorname() . ' ' . $o->getNachname()];
     //            if ($out !== NULL) {
     //                if ($out->getVorgesetzter() !== NULL) {
     //                    if ($o->getId() === $out->getVorgesetzter()->getId()) {
     //                        $options2[$out->getVorgesetzter()->getId()]['selected'] = TRUE;
     //                        $hatVorgesetzte = TRUE;
     //                    }
     //                } else {
     //                    $options2[0]['selected'] = TRUE;
     //                }
     //            }
     //        }
     //        if ($hatVorgesetzte == FALSE) {
     //            $options2[0]['selected'] = TRUE;
     //        }
     //
     // radio $options erstellen
     $radioOptions = [];
     $radioOption = [];
     if ($out !== Null) {
         $radioOption['label'] = 'weibl.';
         if ($out->getGeschlecht() === 'w') {
             $radioOption['checked'] = TRUE;
         }
         $radioOption['value'] = 'w';
         array_push($radioOptions, $radioOption);
         $radioOption = [];
         $radioOption['label'] = 'männl.';
         if ($out->getGeschlecht() === 'm') {
             $radioOption['checked'] = TRUE;
         }
         $radioOption['value'] = 'm';
         array_push($radioOptions, $radioOption);
     } else {
         $radioOption['label'] = 'weibl.';
         $radioOption['checked'] = TRUE;
         $radioOption['value'] = 'w';
         array_push($radioOptions, $radioOption);
         $radioOption['label'] = 'männl.';
         $radioOption['checked'] = NULL;
         $radioOption['value'] = 'm';
         array_push($radioOptions, $radioOption);
     }
     if ($out !== NULL) {
         array_push($rechteSpalte, HTML::buildInput('text', 'vorname', $dbWerte['vorname'], NULL, 'vorname'));
         array_push($rechteSpalte, HTML::buildInput('text', 'nachname', $dbWerte['nachname'], NULL, 'nachname'));
         array_push($rechteSpalte, HTML::buildRadio('geschlecht', $radioOptions, FALSE));
         array_push($rechteSpalte, HTML::buildInput('text', 'geburtsdatum', HTML::mysqlToGerman($dbWerte['geburtsdatum']), NULL, 'geburtsdatum', NULL, 'TT.MM.JJJJ'));
         array_push($rechteSpalte, HTML::buildDropDown('abteilung', '1', $options, NULL, 'abteilung'));
         array_push($rechteSpalte, HTML::buildInput('text', 'stundenlohn', $dbWerte['stundenlohn'], NULL, 'stundenlohn'));
         array_push($rechteSpalte, HTML::buildDropDown('vorgesetzter', '1', $options2, NULL, 'vorgesetzter'));
         array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'updateMitarbeiter', 'OK'));
     } else {
         array_push($rechteSpalte, HTML::buildInput('text', 'vorname', '', NULL, 'vorname'));
         array_push($rechteSpalte, HTML::buildInput('text', 'nachname', '', NULL, 'nachname'));
         array_push($rechteSpalte, HTML::buildRadio('geschlecht', $radioOptions, FALSE));
         array_push($rechteSpalte, HTML::buildInput('text', 'geburtsdatum', '', NULL, 'geburtsdatum', NULL, 'TT.MM.JJJJ'));
         array_push($rechteSpalte, HTML::buildDropDown('abteilung', '1', $options, NULL, 'abteilung'));
         array_push($rechteSpalte, HTML::buildInput('text', 'stundenlohn', '', NULL, 'stundenlohn'));
         array_push($rechteSpalte, HTML::buildDropDown('vorgesetzter', '1', $options2, NULL, 'vorgesetzter'));
         array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'insertMitarbeiter', 'OK'));
     }
     $returnOut = HTML::buildFormularTable($linkeSpalte, $rechteSpalte);
     return $returnOut;
 }
Example #9
0
 public static function getById($id)
 {
     $pdo = DbConnect::connect();
     $sql = "SELECT * from mitarbeiter WHERE id=:id";
     $stmt = $pdo->prepare($sql);
     $stmt->execute([':id' => $id]);
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     return new Mitarbeiter($rows[0]['vorname'], $rows[0]['nachname'], $rows[0]['geschlecht'], $rows[0]['geburtsdatum'], Abteilung::getById($rows[0]['abteilung_id']), $rows[0]['stundenlohn'], Mitarbeiter::getVorgesetzterById($rows[0]['vorgesetzter_id']), $rows[0]['id']);
 }