diff --git a/action.php b/action.php index 8ea1cb3..646a4af 100644 --- a/action.php +++ b/action.php @@ -68,11 +68,15 @@ switch ($VARS['action']) { $component->setMachineID($VARS['machine']); $component->setSerial($VARS['serial']); $component->setTypeID($VARS['type']); - $component->setTestedDate(date( - "Y-m-d H:i:s", - strtotime($VARS['date'] . " " . $VARS['time']) - ) - ); + if (!empty($VARS['date'])) { + $component->setTestedDate(date( + "Y-m-d H:i:s", + strtotime(trim($VARS['date'] . " " . $VARS['time'])) + ) + ); + } else { + $component->clearTestedDate(); + } $component->setCapacity($VARS['capacity']); $component->setModel($VARS['model']); $component->setPrice($VARS['price'] * 1.0); diff --git a/lib/Component.lib.php b/lib/Component.lib.php index bf7ad20..a6ad7cb 100644 --- a/lib/Component.lib.php +++ b/lib/Component.lib.php @@ -139,6 +139,10 @@ class Component { public function setTestedDate(string $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) { $this->component["capacity"] = $capacity; diff --git a/pages/editcomponent.php b/pages/editcomponent.php index b3b7a66..073caa4 100644 --- a/pages/editcomponent.php +++ b/pages/editcomponent.php @@ -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"); diff --git a/pages/editmachine.php b/pages/editmachine.php index 14567a7..5a180b7 100644 --- a/pages/editmachine.php +++ b/pages/editmachine.php @@ -31,7 +31,7 @@ if ($editing) { $form->setID("editmachine"); $form->addHiddenInput("action", "editmachine"); -$form->addHiddenInput("source", "editmachine"); +$form->addHiddenInput("source", "viewmachine"); $clients = [ "" => ""