|
|
|
@ -20,7 +20,7 @@ class Machine implements JsonSerializable {
|
|
|
|
|
$this->machineid = $machineid;
|
|
|
|
|
if (Machine::exists($machineid)) {
|
|
|
|
|
$this->exists = true;
|
|
|
|
|
$this->machine = $database->get('machines', ['type [Int]', 'model', 'condition [Number]', 'price [Number]', 'os', 'serial', 'manufacturer', 'clientid [Int]', 'privatenotes', 'publicnotes'], ['machineid' => $machineid]);
|
|
|
|
|
$this->machine = $database->get('machines', ['type [Int]', 'model', 'condition [Number]', 'price [Number]', 'os', 'serial', 'manufacturer', 'clientid [Int]', 'privatenotes', 'publicnotes', 'deleted [Bool]'], ['machineid' => $machineid]);
|
|
|
|
|
$typeinfo = $database->get("machine_types", ["machinetypeid (id) [Int]", "typename (label)", "icon"], ["machinetypeid" => $this->machine["type"]]);
|
|
|
|
|
$this->icon = $typeinfo["icon"];
|
|
|
|
|
$this->typeid = $typeinfo["id"];
|
|
|
|
@ -130,6 +130,8 @@ class Machine implements JsonSerializable {
|
|
|
|
|
$data["machineid"] = $this->machineid;
|
|
|
|
|
$database->insert("machines", $data);
|
|
|
|
|
$this->exists = true;
|
|
|
|
|
// Insert event for machine creation
|
|
|
|
|
Event::create($data["machineid"], date("Y-m-d H:i:s"), 99);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -273,6 +275,14 @@ class Machine implements JsonSerializable {
|
|
|
|
|
return $this->components;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setDeleted(bool $deleted = true) {
|
|
|
|
|
$this->machine["deleted"] = $deleted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function isDeleted(): bool {
|
|
|
|
|
return $this->machine["deleted"] == true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addEvent(string $date, int $event, string $techuid = "", string $publicnotes = "", string $privatenotes = "") {
|
|
|
|
|
$evt = Event::create($this->machineid, $date, $event, $techuid, $publicnotes, $privatenotes);
|
|
|
|
|
|
|
|
|
|