private static function transformUpdate($out = NULL)
 {
     $returnOut = [];
     $linkeSpalte = [];
     $rechteSpalte = [];
     for ($i = 0; $i < count(Projekt::getNames()); $i++) {
         array_push($linkeSpalte, Projekt::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
     if ($out !== NULL) {
         array_push($rechteSpalte, HTML::buildInput('text', 'projekt', $dbWerte['name'], NULL, 'projekt'));
         array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'updateProjekt', 'OK'));
     } else {
         array_push($rechteSpalte, HTML::buildInput('text', 'projekt', '', NULL, 'projekt'));
         array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'insertProjekt', 'OK'));
     }
     $returnOut = HTML::buildFormularTable($linkeSpalte, $rechteSpalte);
     return $returnOut;
 }
 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 = ProjektMitarbeiter::getAll();
             $out = self::transform($out);
             break;
         case 'showUpdate':
             $out = ProjektMitarbeiter::getById($id);
             $out = self::transformUpdate($out);
             break;
         case 'showInsert':
             $out = self::transformUpdate();
             break;
         case 'update':
             $ProjektFiltered = filter_input(INPUT_POST, 'Projekt', 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);
             $updatemitarbeiterprojektidFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT & FILTER_SANITIZE_SPECIAL_CHARS);
             $out = new ProjektMitarbeiter(Projekt::getById($ProjektFiltered), Mitarbeiter::getById($mitarbeiterFiltered), HTML::dateAndTimeToDateTime($vonFiltered), HTML::dateAndTimeToDateTime($bisFiltered), $updatemitarbeiterprojektidFiltered);
             $out = ProjektMitarbeiter::update($out);
             $out = ProjektMitarbeiter::getAll();
             $out = self::transform($out);
             break;
         case 'insert':
             $projektFiltered = filter_input(INPUT_POST, 'projekt', 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 ProjektMitarbeiter(Projekt::getById($projektFiltered), Mitarbeiter::getById($mitarbeiterFiltered), HTML::dateAndTimeToDateTime($vonFiltered), HTML::dateAndTimeToDateTime($bisFiltered), NULL);
             $out = ProjektMitarbeiter::insert($out);
             $out = ProjektMitarbeiter::getAll();
             $out = self::transform($out);
             break;
         case 'delete':
             $deleteprojektmitarbeiteridFiltered = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT & FILTER_SANITIZE_SPECIAL_CHARS);
             $out = $deleteprojektmitarbeiteridFiltered;
             $out = ProjektMitarbeiter::delete($out);
             $out = ProjektMitarbeiter::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;
 }