Enhance toArray() with client info
This commit is contained in:
parent
038033df65
commit
bcf91412f9
@ -39,6 +39,21 @@ class Machine implements JsonSerializable {
|
||||
public function toArray() {
|
||||
global $Strings;
|
||||
if ($this->exists) {
|
||||
$info = $this->machine;
|
||||
// only show deleted if true
|
||||
if (!$this->isDeleted()) {
|
||||
unset($info["deleted"]);
|
||||
}
|
||||
$clientinfo = [];
|
||||
if (!empty($this->getClientID())) {
|
||||
$client = Clients::getClient($this->getClientID());
|
||||
$clientinfo = [
|
||||
"name" => $client->getName(),
|
||||
"phone" => $client->getPhone(),
|
||||
"billingaddress" => $client->getBillingAddress(),
|
||||
"mailingaddress" => $client->getMailingAddress()
|
||||
];
|
||||
}
|
||||
return [
|
||||
"status" => "OK",
|
||||
"id" => $this->machineid,
|
||||
@ -47,7 +62,8 @@ class Machine implements JsonSerializable {
|
||||
"id" => $this->typeid,
|
||||
"label" => $this->typelabel
|
||||
],
|
||||
"info" => $this->machine,
|
||||
"clientinfo" => $clientinfo,
|
||||
"info" => $info,
|
||||
"events" => $this->events,
|
||||
"components" => $this->components,
|
||||
"formdata" => [
|
||||
@ -65,8 +81,7 @@ class Machine implements JsonSerializable {
|
||||
"clientid" => "select",
|
||||
"privatenotes" => "textarea",
|
||||
"publicnotes" => "textarea",
|
||||
"type" => "select",
|
||||
"deleted" => "hidden"
|
||||
"type" => "select"
|
||||
],
|
||||
"labels" => [
|
||||
"model" => $Strings->get("Model", false),
|
||||
|
Loading…
x
Reference in New Issue
Block a user