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() {
|
public function toArray() {
|
||||||
global $Strings;
|
global $Strings;
|
||||||
if ($this->exists) {
|
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 [
|
return [
|
||||||
"status" => "OK",
|
"status" => "OK",
|
||||||
"id" => $this->machineid,
|
"id" => $this->machineid,
|
||||||
@ -47,7 +62,8 @@ class Machine implements JsonSerializable {
|
|||||||
"id" => $this->typeid,
|
"id" => $this->typeid,
|
||||||
"label" => $this->typelabel
|
"label" => $this->typelabel
|
||||||
],
|
],
|
||||||
"info" => $this->machine,
|
"clientinfo" => $clientinfo,
|
||||||
|
"info" => $info,
|
||||||
"events" => $this->events,
|
"events" => $this->events,
|
||||||
"components" => $this->components,
|
"components" => $this->components,
|
||||||
"formdata" => [
|
"formdata" => [
|
||||||
@ -65,8 +81,7 @@ class Machine implements JsonSerializable {
|
|||||||
"clientid" => "select",
|
"clientid" => "select",
|
||||||
"privatenotes" => "textarea",
|
"privatenotes" => "textarea",
|
||||||
"publicnotes" => "textarea",
|
"publicnotes" => "textarea",
|
||||||
"type" => "select",
|
"type" => "select"
|
||||||
"deleted" => "hidden"
|
|
||||||
],
|
],
|
||||||
"labels" => [
|
"labels" => [
|
||||||
"model" => $Strings->get("Model", false),
|
"model" => $Strings->get("Model", false),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user