Make component tested date/time optional

This commit is contained in:
Skylar Ittner 2020-05-16 15:30:04 -06:00
parent c06d2f7951
commit 6a26365168
4 changed files with 16 additions and 8 deletions

View File

@ -68,11 +68,15 @@ switch ($VARS['action']) {
$component->setMachineID($VARS['machine']);
$component->setSerial($VARS['serial']);
$component->setTypeID($VARS['type']);
if (!empty($VARS['date'])) {
$component->setTestedDate(date(
"Y-m-d H:i:s",
strtotime($VARS['date'] . " " . $VARS['time'])
strtotime(trim($VARS['date'] . " " . $VARS['time']))
)
);
} else {
$component->clearTestedDate();
}
$component->setCapacity($VARS['capacity']);
$component->setModel($VARS['model']);
$component->setPrice($VARS['price'] * 1.0);

View File

@ -140,6 +140,10 @@ class Component {
$this->component["tested"] = date("Y-m-d H:i:s", strtotime($tested));
}
public function clearTestedDate() {
$this->component["tested"] = null;
}
public function setCapacity(string $capacity) {
$this->component["capacity"] = $capacity;
}

View File

@ -70,8 +70,8 @@ if (!empty($component->getTestedDate())) {
}
$form->addInput("serial", $component->getSerial(), "text", false, null, null, "Serial", "fas fa-barcode", 4, 0, 200);
$form->addInput("type", $component->getTypeID(), "select", false, null, $types, "Type", "fas fa-list");
$form->addInput("date", $date, "date", true, null, null, "Tested Date", "fas fa-calendar");
$form->addInput("time", $time, "time", true, null, null, "Tested Time", "fas fa-clock");
$form->addInput("date", $date, "date", false, null, null, "Tested Date", "fas fa-calendar");
$form->addInput("time", $time, "time", false, null, null, "Tested Time", "fas fa-clock");
$form->addInput("capacity", $component->getCapacity(), "text", false, null, null, "Capacity", "fas fa-database", 4, 0, 200);
$form->addInput("model", $component->getModel(), "text", false, null, null, "Model", "fas fa-hashtag", 4, 0, 200);
$form->addInput("price", $component->getPrice(), "number", false, null, null, "Price", "fas fa-money-bill-wave");

View File

@ -31,7 +31,7 @@ if ($editing) {
$form->setID("editmachine");
$form->addHiddenInput("action", "editmachine");
$form->addHiddenInput("source", "editmachine");
$form->addHiddenInput("source", "viewmachine");
$clients = [
"" => ""