Add client search and viewing
parent
f23af485d4
commit
358585680a
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2020 Netsyms Technologies.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
|
||||
function clientSearchAsync(routeTo, routeFrom, resolve, reject) {
|
||||
app.dialog.preloader("Searching...");
|
||||
|
||||
apirequest(
|
||||
"searchclients",
|
||||
{
|
||||
q: routeTo.params.q
|
||||
},
|
||||
function (resp) {
|
||||
app.dialog.close();
|
||||
if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
reject();
|
||||
} else {
|
||||
var context = {
|
||||
clients: resp.clients,
|
||||
q: routeTo.params.q
|
||||
};
|
||||
|
||||
resolve({
|
||||
templateUrl: "pages/clients.html",
|
||||
}, {
|
||||
context: context
|
||||
});
|
||||
}
|
||||
},
|
||||
function (xhr) {
|
||||
app.dialog.close();
|
||||
var error = $.parseJSON(xhr.responseText);
|
||||
if (error && typeof error.msg != 'undefined') {
|
||||
app.dialog.alert(error.msg, "Error");
|
||||
} else {
|
||||
app.dialog.alert("A server or network error occurred.", "Error");
|
||||
}
|
||||
reject();
|
||||
});
|
||||
}
|
||||
|
||||
function clientGetAsync(routeTo, routeFrom, resolve, reject) {
|
||||
app.dialog.preloader("Expanding client...");
|
||||
|
||||
apirequest(
|
||||
"getclient",
|
||||
{
|
||||
clientid: routeTo.params.clientid
|
||||
},
|
||||
function (resp) {
|
||||
app.dialog.close();
|
||||
if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
reject();
|
||||
} else {
|
||||
|
||||
var machinelist = [];
|
||||
for (var i = 0; i < resp.machines.length; i++) {
|
||||
var machine = resp.machines[i];
|
||||
machine["props"] = [];
|
||||
for (var k in machine.formdata.labels) {
|
||||
if (machine.hasOwnProperty(k)) {
|
||||
switch (k) {
|
||||
case "type":
|
||||
case "clientid":
|
||||
// skip these
|
||||
break;
|
||||
default:
|
||||
var value = machine.info[k];
|
||||
if (value == false || value == 0) {
|
||||
value = false;
|
||||
} else {
|
||||
value = value.toString().replace("\n", " <br />");
|
||||
}
|
||||
machine.props.push({
|
||||
name: k,
|
||||
value: value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(machine);
|
||||
machinelist.push(machine);
|
||||
}
|
||||
|
||||
// Add <br> for newlines
|
||||
for (var k in resp.client) {
|
||||
if (resp.client.hasOwnProperty(k)) {
|
||||
resp.client[k] = resp.client[k].toString().replace("\n", " <br>");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof resp.client.phone == 'string') {
|
||||
resp.client.phonestripped = resp.client.phone.replace(/\D/g, '');
|
||||
}
|
||||
|
||||
var context = {
|
||||
client: resp.client,
|
||||
machines: machinelist
|
||||
};
|
||||
|
||||
resolve({
|
||||
templateUrl: "pages/client.html",
|
||||
}, {
|
||||
context: context
|
||||
});
|
||||
}
|
||||
},
|
||||
function (xhr) {
|
||||
app.dialog.close();
|
||||
var error = $.parseJSON(xhr.responseText);
|
||||
if (error && typeof error.msg != 'undefined') {
|
||||
app.dialog.alert(error.msg, "Error");
|
||||
} else {
|
||||
app.dialog.alert("A server or network error occurred.", "Error");
|
||||
}
|
||||
reject();
|
||||
});
|
||||
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
<!--
|
||||
Copyright 2020 Netsyms Technologies.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
|
||||
<div class="page" data-name="client">
|
||||
|
||||
<div class="navbar">
|
||||
<div class="navbar-bg"></div>
|
||||
<div class="navbar-inner">
|
||||
<div class="left">
|
||||
<a href="#" class="link icon-only back">
|
||||
<i class="icon icon-back"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">Client Info</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar tabbar toolbar-top">
|
||||
<div class="toolbar-inner">
|
||||
<a href="#tab-info" class="tab-link tab-link-active">Info</a>
|
||||
<a href="#tab-machines" class="tab-link">Machines</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tabs-swipeable-wrap">
|
||||
<div class="tabs">
|
||||
|
||||
<div id="tab-info" class="page-content tab tab-active">
|
||||
{{#with client}}
|
||||
<div class="list no-margin-top">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-title">
|
||||
<div class="item-header">Name</div>
|
||||
{{name}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{#if phone}}
|
||||
<li>
|
||||
<a class="item-content item-link" href="tel:{{phonestripped}}">
|
||||
<div class="item-inner">
|
||||
<div class="item-title">
|
||||
<div class="item-header">Phone</div>
|
||||
{{phone}}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if billingaddress}}
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-title">
|
||||
<div class="item-header">Billing Address</div>
|
||||
{{billingaddress}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if mailingaddress}}
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-title">
|
||||
<div class="item-header">Mailing Address</div>
|
||||
{{mailingaddress}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if privatenotes}}
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-title">
|
||||
<div class="item-header">Private Notes</div>
|
||||
{{privatenotes}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if publicnotes}}
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-title">
|
||||
<div class="item-header">Public Notes</div>
|
||||
{{publicnotes}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</div>
|
||||
{{/with}}
|
||||
</div>
|
||||
|
||||
<div id="tab-machines" class="page-content tab">
|
||||
<div class="list accordion-list no-margin-top">
|
||||
<ul>
|
||||
{{#each machines}}
|
||||
<li class="accordion-item">
|
||||
<div class="item-content item-link">
|
||||
<div class="item-inner">
|
||||
<div class="item-title"><i class="{{icon}}"></i> {{id}}</div>
|
||||
<div class="item-after">{{type.label}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item-content">
|
||||
<a href="" onclick="openMachineInfo('{{id}}')" class="button">Open</a>
|
||||
<div class="list">
|
||||
<ul>
|
||||
{{#each props}}
|
||||
<li>
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-title" style="white-space: normal !important;">
|
||||
<div class="item-header">{{title}}</div>
|
||||
{{content}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Copyright 2020 Netsyms Technologies.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
|
||||
<div class="page" data-name="clients">
|
||||
|
||||
<div class="navbar">
|
||||
<div class="navbar-bg"></div>
|
||||
<div class="navbar-inner">
|
||||
<div class="left">
|
||||
<a href="#" class="link icon-only back">
|
||||
<i class="icon icon-back"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">Clients ({{q}})</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
<div class="list links-list no-margin-top">
|
||||
<ul>
|
||||
{{#each clients}}
|
||||
<li>
|
||||
<a href="/client/{{id}}">
|
||||
{{name}}
|
||||
</a>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue