Add register editing and creation (issue #1)
parent
9ec33b06fe
commit
0acf33c9a6
@ -0,0 +1,70 @@
|
||||
<?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();
|
||||
|
||||
$regdata = [
|
||||
'id' => '',
|
||||
'name' => ''
|
||||
];
|
||||
|
||||
$editing = false;
|
||||
|
||||
if (!empty($VARS['id'])) {
|
||||
if ($database->has('registers', ['registerid' => $VARS['id']])) {
|
||||
$editing = true;
|
||||
$regdata = $database->get(
|
||||
'registers', [
|
||||
'registerid (id)',
|
||||
'registername (name)'
|
||||
], [
|
||||
'registerid' => $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=editregister');
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ($editing) {
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<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 register", ['name' => "<span id=\"name_title\">" . htmlspecialchars($regdata['name']) . "</span>"]); ?>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<i class="fas fa-edit"></i> <?php lang("adding register"); ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<div class="card-body row">
|
||||
<div class="form-group col-12">
|
||||
<label for="name"><i class="fas fa-font"></i> <?php lang("name"); ?></label>
|
||||
<input type="text" class="form-control" id="name" name="name" placeholder="Register #1" required="required" value="<?php echo htmlspecialchars($regdata['name']); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo htmlspecialchars($regdata['id']); ?>" />
|
||||
<input type="hidden" name="action" value="editregister" />
|
||||
<input type="hidden" name="source" value="registers" />
|
||||
|
||||
<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>
|
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
|
||||
$('#name').on('input propertychange paste', function () {
|
||||
$('#name_title').text($('#name').val());
|
||||
});
|
Loading…
Reference in New Issue