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->setMachineID($VARS['machine']);
$component->setSerial($VARS['serial']); $component->setSerial($VARS['serial']);
$component->setTypeID($VARS['type']); $component->setTypeID($VARS['type']);
$component->setTestedDate(date( if (!empty($VARS['date'])) {
"Y-m-d H:i:s", $component->setTestedDate(date(
strtotime($VARS['date'] . " " . $VARS['time']) "Y-m-d H:i:s",
) strtotime(trim($VARS['date'] . " " . $VARS['time']))
); )
);
} else {
$component->clearTestedDate();
}
$component->setCapacity($VARS['capacity']); $component->setCapacity($VARS['capacity']);
$component->setModel($VARS['model']); $component->setModel($VARS['model']);
$component->setPrice($VARS['price'] * 1.0); $component->setPrice($VARS['price'] * 1.0);

View File

@ -139,6 +139,10 @@ class Component {
public function setTestedDate(string $tested) { public function setTestedDate(string $tested) {
$this->component["tested"] = date("Y-m-d H:i:s", strtotime($tested)); $this->component["tested"] = date("Y-m-d H:i:s", strtotime($tested));
} }
public function clearTestedDate() {
$this->component["tested"] = null;
}
public function setCapacity(string $capacity) { public function setCapacity(string $capacity) {
$this->component["capacity"] = $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("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("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("date", $date, "date", false, null, null, "Tested Date", "fas fa-calendar");
$form->addInput("time", $time, "time", true, null, null, "Tested Time", "fas fa-clock"); $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("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("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"); $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->setID("editmachine");
$form->addHiddenInput("action", "editmachine"); $form->addHiddenInput("action", "editmachine");
$form->addHiddenInput("source", "editmachine"); $form->addHiddenInput("source", "viewmachine");
$clients = [ $clients = [
"" => "" "" => ""