You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
3.7 KiB
PHP
89 lines
3.7 KiB
PHP
<?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/. */
|
|
|
|
require_once __DIR__ . '/../required.php';
|
|
|
|
redirectifnotloggedin();
|
|
|
|
$custdata = [
|
|
'id' => '',
|
|
'name' => '',
|
|
'email' => '',
|
|
'phone' => '',
|
|
'address' => '',
|
|
'notes' => ''
|
|
];
|
|
|
|
$editing = false;
|
|
|
|
if (!empty($VARS['id']) && !is_empty($VARS['id'])) {
|
|
if ($database->has('customers', ['customerid' => $VARS['id']])) {
|
|
$editing = true;
|
|
$custdata = $database->get(
|
|
'customers', [
|
|
'customerid (id)',
|
|
'name',
|
|
'email',
|
|
'phone',
|
|
'address',
|
|
'notes'
|
|
], [
|
|
'customerid' => $VARS['id']
|
|
]);
|
|
} else {
|
|
// customer id is invalid, redirect to a version of the page that won't
|
|
// cause an error when pressing Save
|
|
header('Location: app.php?page=editcustomer');
|
|
}
|
|
}
|
|
?>
|
|
|
|
<form role="form" action="action.php" method="POST">
|
|
<div class="card border-green">
|
|
<h3 class="card-header text-green">
|
|
<?php
|
|
if ($editing) {
|
|
?>
|
|
<i class="fas fa-edit"></i> <?php lang2("editing customer", ['name' => "<span id=\"name_title\">" . htmlspecialchars($custdata['name']) . "</span>"]); ?>
|
|
<?php
|
|
} else {
|
|
?>
|
|
<i class="fas fa-edit"></i> <?php lang("adding customer"); ?>
|
|
<?php
|
|
}
|
|
?>
|
|
</h3>
|
|
<div class="card-body row">
|
|
<div class="form-group col-12">
|
|
<label for="name"><i class="fas fa-user"></i> <?php lang("name"); ?></label>
|
|
<input type="text" class="form-control" id="name" name="name" placeholder="Foo Bar" required="required" value="<?php echo htmlspecialchars($custdata['name']); ?>" />
|
|
</div>
|
|
<div class="form-group col-sm-6">
|
|
<label for="email"><i class="fas fa-at"></i> <?php lang("email"); ?></label>
|
|
<input type="email" class="form-control" id="email" name="email" placeholder="user@example.com" value="<?php echo htmlspecialchars($custdata['email']); ?>" />
|
|
</div>
|
|
<div class="form-group col-sm-6">
|
|
<label for="phone"><i class="fas fa-phone"></i> <?php lang("phone"); ?></label>
|
|
<input type="phone" class="form-control" id="phone" name="phone" placeholder="" value="<?php echo htmlspecialchars($custdata['phone']); ?>" />
|
|
</div>
|
|
<div class="form-group col-sm-6">
|
|
<label for="address"><i class="fas fa-map-marker"></i> <?php lang("address"); ?></label>
|
|
<textarea rows="3" class="form-control" id="address" name="address" placeholder=""><?php echo htmlspecialchars($custdata['address']); ?></textarea>
|
|
</div>
|
|
<div class="form-group col-sm-6">
|
|
<label for="notes"><i class="fas fa-sticky-note"></i> <?php lang("notes"); ?></label>
|
|
<textarea rows="3" class="form-control" id="notes" name="notes" placeholder=""><?php echo htmlspecialchars($custdata['notes']); ?></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<input type="hidden" name="id" value="<?php echo htmlspecialchars($custdata['id']); ?>" />
|
|
<input type="hidden" name="action" value="editcustomer" />
|
|
<input type="hidden" name="source" value="customers" />
|
|
|
|
<div class="card-footer d-flex">
|
|
<button type="submit" class="btn btn-success mr-auto"><i class="fas fa-save"></i> <?php lang("save"); ?></button>
|
|
</div>
|
|
</div>
|
|
</form>
|