Add client management
parent
f175ef642a
commit
7528468505
Binary file not shown.
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"Name": "Name",
|
||||||
|
"Phone": "Phone",
|
||||||
|
"Email": "Email",
|
||||||
|
"Billing Address": "Billing Address",
|
||||||
|
"Mailing Address": "Mailing Address"
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Public Notes": "Public Notes",
|
||||||
|
"Private Notes": "Private Notes"
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Machine saved!": "Machine saved!",
|
"Machine saved!": "Machine saved!",
|
||||||
"Component saved!": "Component saved!",
|
"Component saved!": "Component saved!",
|
||||||
"Event logged!": "Event logged!"
|
"Event logged!": "Event logged!",
|
||||||
|
"Client saved!": "Client saved!",
|
||||||
|
"Client must be edited in Invoice Ninja.": "Client must be edited in Invoice Ninja."
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Copyright 2019 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/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
redirectIfNotLoggedIn();
|
||||||
|
$user = new User($_SESSION['uid']);
|
||||||
|
if (!$user->hasPermission("MACHINEMANAGER_VIEW")) {
|
||||||
|
header("Location: ./app.php?msg=no_permission");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$writeaccess = $user->hasPermission("MACHINEMANAGER_EDIT");
|
||||||
|
|
||||||
|
$clients = Clients::getAll();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="btn-group">
|
||||||
|
<?php if ($writeaccess) { ?>
|
||||||
|
<a href="app.php?page=editclient" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Add Client"); ?></a>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<table id="clienttable" class="table table-bordered table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-priority="0"></th>
|
||||||
|
<th data-priority="1"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('Name'); ?></th>
|
||||||
|
<th data-priority="2"><i class="fas fa-phone hidden-sm"></i> <?php $Strings->get('Phone'); ?></th>
|
||||||
|
<th data-priority="2"><i class="fas fa-envelope hidden-sm"></i> <?php $Strings->get('Email'); ?></th>
|
||||||
|
<th data-priority="3"><i class="fas fa-file-invoice hidden-sm"></i> <?php $Strings->get('Billing Address'); ?></th>
|
||||||
|
<th data-priority="3"><i class="fas fa-mail-bulk hidden-sm"></i> <?php $Strings->get('Mailing Address'); ?></th>
|
||||||
|
<th data-priority="4"><i class="far fa-comment-dots hidden-sm"></i> <?php $Strings->get('Public Notes'); ?></th>
|
||||||
|
<th data-priority="4"><i class="fas fa-comment-dots hidden-sm"></i> <?php $Strings->get('Private Notes'); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ($clients as $c) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if ($c->isLocal() && $writeaccess) {
|
||||||
|
?>
|
||||||
|
<a class="btn btn-primary btn-sm" href="app.php?page=editclient&arg=<?php echo $c->getID(); ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
|
||||||
|
<a href="app.php?page=editclient&arg=<?php echo $c->getID(); ?>"><?php echo htmlspecialchars($c->getName()); ?></a>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
|
<?php echo htmlspecialchars($c->getName()); ?>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php if (!empty($c->getPhone())) { ?>
|
||||||
|
<a href="tel:<?php echo htmlspecialchars(preg_replace("/[^0-9]/", "", $c->getPhone())); ?>">
|
||||||
|
<?php echo htmlspecialchars($c->getPhone()); ?>
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php if (!empty($c->getEmail())) { ?>
|
||||||
|
<a href="mailto:<?php echo htmlspecialchars($c->getEmail()); ?>">
|
||||||
|
<?php echo htmlspecialchars($c->getEmail()); ?>
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
|
</td>
|
||||||
|
<td><?php echo implode("<br />", explode("\n", $c->getBillingAddress())); ?></td>
|
||||||
|
<td><?php echo implode("<br />", explode("\n", $c->getMailingAddress())); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($c->getPublicNotes()); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($c->getPrivateNotes()); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th data-priority="0"></th>
|
||||||
|
<th data-priority="1"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('Name'); ?></th>
|
||||||
|
<th data-priority="2"><i class="fas fa-phone hidden-sm"></i> <?php $Strings->get('Phone'); ?></th>
|
||||||
|
<th data-priority="2"><i class="fas fa-envelope hidden-sm"></i> <?php $Strings->get('Email'); ?></th>
|
||||||
|
<th data-priority="3"><i class="fas fa-file-invoice hidden-sm"></i> <?php $Strings->get('Billing Address'); ?></th>
|
||||||
|
<th data-priority="3"><i class="fas fa-mail-bulk hidden-sm"></i> <?php $Strings->get('Mailing Address'); ?></th>
|
||||||
|
<th data-priority="4"><i class="far fa-comment-dots hidden-sm"></i> <?php $Strings->get('Public Notes'); ?></th>
|
||||||
|
<th data-priority="4"><i class="fas fa-comment-dots hidden-sm"></i> <?php $Strings->get('Private Notes'); ?></th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
redirectIfNotLoggedIn();
|
||||||
|
$user = new User($_SESSION['uid']);
|
||||||
|
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
|
||||||
|
header("Location: ./app.php?msg=no_permission");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$editing = false;
|
||||||
|
|
||||||
|
if (!empty($_GET['arg']) && Client::exists($_GET['arg'], Clients::areLocal())) {
|
||||||
|
$editing = true;
|
||||||
|
$client = new Client($_GET['arg'], Clients::areLocal());
|
||||||
|
} else {
|
||||||
|
$client = new Client();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($editing) {
|
||||||
|
$form = new FormBuilder("Edit " . htmlspecialchars($client->getName()), "fas fa-user", "action.php", "POST");
|
||||||
|
} else {
|
||||||
|
$form = new FormBuilder("Add Client", "fas fa-user", "action.php", "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->setID("editclient");
|
||||||
|
|
||||||
|
$form->addHiddenInput("action", "editclient");
|
||||||
|
$form->addHiddenInput("source", "editclient");
|
||||||
|
|
||||||
|
if ($editing) {
|
||||||
|
$form->addHiddenInput("id", $client->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->addInput("name", $client->getName(), "text", true, null, null, "Name", "fas fa-user");
|
||||||
|
$form->addInput("phone", $client->getPhone(), "tel", false, null, null, "Phone", "fas fa-phone");
|
||||||
|
$form->addInput("email", $client->getEmail(), "email", false, null, null, "Email", "fas fa-envelope");
|
||||||
|
$form->addInput("billingaddress", $client->getBillingAddress(), "textarea", false, null, null, "Billing Address", "fas fa-file-invoice", 6);
|
||||||
|
$form->addInput("mailingaddress", $client->getMailingAddress(), "textarea", false, null, null, "Mailing Address", "fas fa-mail-bulk", 6);
|
||||||
|
$form->addInput("privatenotes", $client->getPrivateNotes(), "textarea", false, null, null, "Private Notes", "fas fa-comment-dots", 6);
|
||||||
|
$form->addInput("publicnotes", $client->getPublicNotes(), "textarea", false, null, null, "Public Notes", "far fa-comment-dots", 6);
|
||||||
|
|
||||||
|
$form->addButton("Save", "fas fa-save", null, "submit", "savebtn");
|
||||||
|
|
||||||
|
$form->generate();
|
@ -0,0 +1,30 @@
|
|||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
$('#clienttable').DataTable({
|
||||||
|
responsive: {
|
||||||
|
details: {
|
||||||
|
display: $.fn.dataTable.Responsive.display.modal({
|
||||||
|
header: function (row) {
|
||||||
|
var data = row.data();
|
||||||
|
return "<i class=\"fas fa-user fa-fw\"></i> " + data[2];
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
|
||||||
|
tableClass: 'table'
|
||||||
|
}),
|
||||||
|
type: "column"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: 0,
|
||||||
|
className: 'control',
|
||||||
|
orderable: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
order: [
|
||||||
|
[4, 'desc']
|
||||||
|
]
|
||||||
|
});
|
Loading…
Reference in New Issue