private static function transformUpdate($out = NULL) { $returnOut = []; $linkeSpalte = []; $rechteSpalte = []; for ($i = 0; $i < count(Ausleihe::getNames()); $i++) { array_push($linkeSpalte, Ausleihe::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 $selected = NULL; if ($out !== NULL) { if ($out->getAuto() !== NULL) { $selected = $out->getAuto()->getId(); // Foreign Key } } $options = Option::buildOptions('Auto', $selected); $selected = NULL; if ($out !== NULL) { if ($out->getMitarbeiter() !== NULL) { $selected = $out->getMitarbeiter()->getId(); // Foreign Key } } $options2 = Option::buildOptions('Mitarbeiter', $selected); if ($out !== NULL) { array_push($rechteSpalte, HTML::buildDropDown('fahrzeug', '1', $options, NULL, 'fahrzeug')); array_push($rechteSpalte, HTML::buildDropDown('mitarbeiter', '1', $options2, NULL, 'mitarbeiter')); array_push($rechteSpalte, HTML::buildInput('text', 'vonTag', HTML::extractDateFromDateTime($dbWerte['von']), NULL, 'vonTag', NULL, 'TT.MM.JJJJ')); array_push($rechteSpalte, HTML::buildInput('text', 'vonZeit', HTML::extractTimeFromDateTime($dbWerte['von']))); array_push($rechteSpalte, HTML::buildInput('text', 'bisTag', HTML::extractDateFromDateTime($dbWerte['bis']), NULL, 'bisTag', NULL, 'TT.MM.JJJJ')); array_push($rechteSpalte, HTML::buildInput('text', 'bisZeit', HTML::extractTimeFromDateTime($dbWerte['bis']))); array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'updateAusleihe', 'OK')); } else { array_push($rechteSpalte, HTML::buildDropDown('fahrzeug', '1', $options, NULL, 'fahrzeug')); array_push($rechteSpalte, HTML::buildDropDown('mitarbeiter', '1', $options2, NULL, 'mitarbeiter')); array_push($rechteSpalte, HTML::buildInput('text', 'vonTag', '', NULL, 'vonTag', NULL, 'TT.MM.JJJJ')); array_push($rechteSpalte, HTML::buildInput('text', 'vonZeit', '', NULL, 'vonZeit', NULL, 'HH:MM')); array_push($rechteSpalte, HTML::buildInput('text', 'bisTag', '', NULL, 'bisTag', NULL, 'TT.MM.JJJJ')); array_push($rechteSpalte, HTML::buildInput('text', 'bisZeit', '', NULL, 'bisZeit', NULL, 'HH:MM')); array_push($rechteSpalte, HTML::buildButton('OK', 'ok', 'insertAusleihe', 'OK')); } $returnOut = HTML::buildFormularTable($linkeSpalte, $rechteSpalte); return $returnOut; }
private static function transformUpdate($out = NULL) { $returnOut = []; $linkeSpalte = []; $rechteSpalte = []; for ($i = 0; $i < count(Ausleihe::getNames()); $i++) { array_push($linkeSpalte, Ausleihe::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 // auto $options erstellen // $auto = Auto::getAll(); // $options = []; // $options[0] = ['value' => 0, 'label' => '']; // $hatirgendwas = FALSE; // foreach ($auto as $o) { // $options[$o->getId()] = ['value' => $o->getId(), 'label' => $o->getHersteller()->getName() . ' ' . $o->getName() . ' ' . $o->getKennzeichen()]; // if ($out !== NULL) { // if ($o->getId() == $out->getAuto()->getId()) { // $options[$o->getId()]['selected'] = TRUE; // $hatirgendwas = TRUE; // } // } // } // if ($hatirgendwas == FALSE) { // $options[0]['selected'] = TRUE; // } $selected = NULL; if ($out !== NULL) { if ($out->getAuto() !== NULL) { $selected = $out->getAuto()->getId(); } } $options = Option::buildOptions('Auto', $selected); // mitarbeiter $options erstellen // $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; // } $selected = NULL; if ($out !== NULL) { if ($out->getMitarbeiter() !== NULL) { $selected = $out->getMitarbeiter()->getId(); } } $options2 = Option::buildOptions('Mitarbeiter', $selected); if ($out !== NULL) { array_push($rechteSpalte, HTML::buildDropDown('fahrzeug', '1', $options, NULL, 'fahrzeug')); 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', 'updateAusleihe', 'OK')); } else { array_push($rechteSpalte, HTML::buildDropDown('fahrzeug', '1', $options, NULL, 'fahrzeug')); 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', 'insertAusleihe', 'OK')); } $returnOut = HTML::buildFormularTable($linkeSpalte, $rechteSpalte); return $returnOut; }