Added position to equipment
This commit is contained in:
@@ -39,6 +39,8 @@ locale/de/LC_MESSAGES/ymsgui.mo: locale/de.po
|
||||
|
||||
# Clean generated files
|
||||
clean:
|
||||
find . -type d -name "__pycache__" -prune -exec rm -rf {} +
|
||||
find . -type f -name "*.pyc" -delete
|
||||
rm -f locale/program.pot
|
||||
rm -f locale/ui.pot
|
||||
rm -f locale/combined.pot
|
||||
|
||||
+13
-5
@@ -122,7 +122,7 @@ CREATE TABLE storage (
|
||||
sname varchar(40) NOT NULL,
|
||||
stype tinyint(3) NOT NULL DEFAULT 0, -- ddid=3
|
||||
capacity smallint(6) DEFAULT NULL,
|
||||
capaunit enum('kg','l') DEFAULT NULL,
|
||||
capaunit enum('kg','l','pcs') DEFAULT NULL,
|
||||
x smallint(6) UNSIGNED NOT NULL DEFAULT 0,
|
||||
y smallint(6) NOT NULL DEFAULT 0,
|
||||
z smallint(6) NOT NULL DEFAULT 0,
|
||||
@@ -205,6 +205,9 @@ CREATE TABLE equipment (
|
||||
purchdate date DEFAULT NULL,
|
||||
price decimal(12,2) DEFAULT NULL,
|
||||
weight float(5,2) UNSIGNED DEFAULT NULL,
|
||||
x smallint(6) UNSIGNED NOT NULL DEFAULT 0,
|
||||
y smallint(6) NOT NULL DEFAULT 0,
|
||||
z smallint(6) NOT NULL DEFAULT 0,
|
||||
remarks varchar(150) DEFAULT NULL,
|
||||
flags set('ordered','removed','deleted') DEFAULT NULL,
|
||||
PRIMARY KEY(eid),
|
||||
@@ -216,7 +219,12 @@ CREATE TABLE equipment (
|
||||
ON DELETE RESTRICT,
|
||||
FOREIGN KEY fk_equipment_manufacturer (manufacturer)
|
||||
REFERENCES company(compid)
|
||||
ON DELETE RESTRICT
|
||||
ON DELETE RESTRICT,
|
||||
CONSTRAINT chk_equipment_pos CHECK (
|
||||
(x IS NULL AND y IS NULL AND z IS NULL)
|
||||
OR
|
||||
(x IS NOT NULL AND y IS NOT NULL AND z IS NOT NULL)
|
||||
)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE inventory (
|
||||
@@ -245,7 +253,7 @@ CREATE TABLE inventory (
|
||||
FOREIGN KEY fk_inventory_equipment (eid)
|
||||
REFERENCES equipment(eid)
|
||||
ON DELETE RESTRICT,
|
||||
CHECK (
|
||||
CONSTRAINT chk_inventory_stor CHECK (
|
||||
(sid IS NOT NULL AND boxid IS NULL)
|
||||
OR
|
||||
(sid IS NULL AND boxid IS NOT NULL)
|
||||
@@ -306,7 +314,6 @@ CREATE table fuse (
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- change vals to decimal(12,4)?
|
||||
-- additional signalk id?
|
||||
CREATE TABLE measurement (
|
||||
mid smallint(6) NOT NULL AUTO_INCREMENT,
|
||||
mname varchar(80) NOT NULL,
|
||||
@@ -518,7 +525,7 @@ CREATE TABLE checkref (
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
/* Expansion for future use: signalk mapping (just an idea) */
|
||||
/* Expansion for future use: signalk mapping (experimental) */
|
||||
CREATE TABLE signalk (
|
||||
skid int(10) NOT NULL AUTO_INCREMENT,
|
||||
vid smallint(6) NOT NULL,
|
||||
@@ -526,6 +533,7 @@ CREATE TABLE signalk (
|
||||
objid int(10) NOT NULL,
|
||||
datatype enum('engine_hours','tank_level') NOT NULL,
|
||||
skpath varchar(255) NOT NULL,
|
||||
mid smallint(6) DEFAULT NULL,
|
||||
PRIMARY KEY (skid),
|
||||
UNIQUE KEY ix_signalk
|
||||
(vid, objtype, objid, datatype),
|
||||
|
||||
+3
-1
@@ -18,7 +18,8 @@ INSERT INTO settings (userid, sno, valint, valstr) VALUES
|
||||
(0, 20, 1280, NULL), -- Image width limit
|
||||
(0, 21, 1024, NULL), -- Image height limit
|
||||
(0, 4, NULL, '€'), -- Currency symbol
|
||||
(0, 5, 0, 'http://127.0.0.1:3000'); -- Signal K: to enable set valint=1
|
||||
(0, 5, 0, 'http://127.0.0.1:3000'), -- Signal K: to enable set valint=1
|
||||
(0, 6, 0, 'localhost:2597'); -- NMEA2000 (for future use)
|
||||
|
||||
/* setting descriptions */
|
||||
INSERT INTO settings (userid, sno, valstr) VALUES
|
||||
@@ -28,6 +29,7 @@ INSERT INTO settings (userid, sno, valstr) VALUES
|
||||
(-1, 3, 'user menu'),
|
||||
(-1, 4, 'currency symbol e.g. €, $, £, ¥'),
|
||||
(-1, 5, 'signalk connection'),
|
||||
(-1, 6, 'nmea2000 connection'),
|
||||
(-1, 10, 'rows in table'),
|
||||
(-1, 20, 'maximum image width'),
|
||||
(-1, 21, 'maximum image height'),
|
||||
|
||||
+3
-1
@@ -18,7 +18,8 @@ INSERT INTO settings (userid, sno, valint, valstr) VALUES
|
||||
(0, 20, 1280, NULL), -- Image width limit
|
||||
(0, 21, 1024, NULL), -- Image height limit
|
||||
(0, 4, NULL, '€'), -- Currency symbol
|
||||
(0, 5, 0, 'http://127.0.0.1:3000'); -- Signal K: to enable set valint=1
|
||||
(0, 5, 0, 'http://127.0.0.1:3000'), -- Signal K: to enable set valint=1
|
||||
(0, 6, 0, 'localhost:2597'); -- NMEA2000 (for future use)
|
||||
|
||||
/* setting descriptions */
|
||||
INSERT INTO settings (userid, sno, valstr) VALUES
|
||||
@@ -27,6 +28,7 @@ INSERT INTO settings (userid, sno, valstr) VALUES
|
||||
(-1, 3, 'user menu'),
|
||||
(-1, 4, 'currency symbol e.g. €, $, £, ¥'),
|
||||
(-1, 5, 'signalk connection'),
|
||||
(-1, 6, 'nmea2000 connection'),
|
||||
(-1, 10, 'rows in table'),
|
||||
(-1, 20, 'maximum image width'),
|
||||
(-1, 21, 'maximum image height'),
|
||||
|
||||
+23
-2
@@ -75,6 +75,9 @@ switch ($submit = form_get_action()) {
|
||||
if ($p[':manufacturer'] <= 0) $p[':manufacturer'] = NULL;
|
||||
$p[':ecat'] = gpc_get_int($_POST, 'category');
|
||||
if ($p[':ecat'] <= 0) $p[':ecat'] = NULL;
|
||||
$p[':x'] = gpc_get_uint($_POST, 'x');
|
||||
$p[':y'] = gpc_get_int($_POST, 'y');
|
||||
$p[':z'] = gpc_get_int($_POST, 'z');
|
||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||
$allowed = db_load_enum('equipment', 'flags');
|
||||
$p[':flags'] = gpc_get_set($_POST, 'flags', $allowed, true, NULL);
|
||||
@@ -443,7 +446,8 @@ elseif ($action == ACT_VIEW):
|
||||
// ========== VARIANT: view single record =====================================
|
||||
|
||||
$sql = "SELECT eid, ename, model, serial, purchdate, price, weight, "
|
||||
. " supplier, manufacturer, ecat, shortname, remarks, flags "
|
||||
. "supplier, manufacturer, ecat, shortname, x, y, z, flags, "
|
||||
. "remarks "
|
||||
. "FROM equipment "
|
||||
. "WHERE eid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -468,6 +472,9 @@ echo '<tr><th>', _('Price'),"</th><td>", format_currency($equipment->price), "</
|
||||
echo '<tr><th>', _('Purchase date'),"</th><td>", format_date($equipment->purchdate), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Supplier'),"</th><td>", $equipment->supplier ? $opt_supplier[$equipment->supplier] : 'n/a', "</td></tr>\n";
|
||||
echo '<tr><th>', _('Category'),"</th><td>", $opt_ecat[$equipment->ecat], "</td></tr>\n";
|
||||
if (!empty($equipment->x)) {
|
||||
echo '<tr><th>', _('Location (x, y, z)'),"</th><td>(", $equipment->x, ', ', $equipment->y, ', ', $equipment->z, ")</td></tr>\n";
|
||||
}
|
||||
echo '<tr><th>', _('Remarks'),"</th><td>", h($equipment->remarks, br:true), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Flags'),"</th><td>", $equipment->flags, "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
@@ -696,7 +703,7 @@ foreach ($sth->fetchAll() as $row) {
|
||||
}
|
||||
|
||||
$sql = "SELECT eid, ename, model, serial, weight, price, purchdate, "
|
||||
. " supplier, manufacturer, ecat, shortname, remarks, flags "
|
||||
. "supplier, manufacturer, ecat, shortname, x, y, z, remarks, flags "
|
||||
. "FROM equipment "
|
||||
. "WHERE eid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -739,6 +746,20 @@ $equipment = $sth->fetch(PDO::FETCH_OBJ);
|
||||
form_create_select('supplier', _('Supplier'), $opt_supplier, $equipment->supplier);
|
||||
form_create_select('category', _('Category'), $g_opt_unknown + $opt_ecat, $equipment->ecat);
|
||||
?>
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><?=_('Position (x, y, z) in mm')?></label>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="x" name="x" min="0" value="<?=$equipment->x ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="y" name="y" value="<?=$equipment->y ?>">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" class="form-control" id="z" name="z" value="<?=$equipment->z ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($equipment->remarks, br:false)?></textarea>
|
||||
|
||||
+19
-6
@@ -8,17 +8,31 @@
|
||||
|
||||
*/
|
||||
|
||||
function db_get_setting($sno, $default=NULL) {
|
||||
// TODO WIP
|
||||
function db_get_setting($sno, $userid, $autocreate=false, $default=NULL) {
|
||||
global $pdo;
|
||||
$sql = "SELECT valint, valstr FROM settings WHERE userid=0 AND sno=?";
|
||||
global $g_error;
|
||||
global $g_warning;
|
||||
$sql = "SELECT valint, valstr FROM settings WHERE userid=? AND sno=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
try {
|
||||
$sth->execute([$sno]);
|
||||
$sth->execute([$userid, $sno]);
|
||||
} catch (Exception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
$g_error->Add($sql);
|
||||
$g_error->Add("userid=$userid, sno=$sno", true));
|
||||
return $default;
|
||||
}
|
||||
$row = $sth->fetch();
|
||||
if ($row === false) {
|
||||
if ($autocreate) {
|
||||
// create empty settings record if it not exists
|
||||
$p[':userid'] = $userid;
|
||||
$p[':sno'] = $sno;
|
||||
db_exec_insert('settings', $p);
|
||||
$g_warning->Add("Added missing settings record with id=$sno");
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
$row = $sth->fetchOne();
|
||||
return $row;
|
||||
}
|
||||
|
||||
@@ -61,7 +75,6 @@ function db_lock_refresh($token) {
|
||||
return $sth->rowCount() === 1;
|
||||
}
|
||||
|
||||
|
||||
function db_lock_release($token) {
|
||||
global $pdo;
|
||||
$sql = "DELETE FROM recordlock WHERE token=?";
|
||||
|
||||
+9
-9
@@ -13,7 +13,7 @@
|
||||
function gpc_get_string(&$GPC, $varname, $maxlen = NULL, $default = NULL) {
|
||||
// TODO Parameter nullval: single value or array of values which considered as null
|
||||
// Default value for nullval is "-1"
|
||||
if (!isset($GPC[$varname]) or (strlen(trim($GPC[$varname])) == 0)) {
|
||||
if (!isset($GPC[$varname]) || (strlen(trim($GPC[$varname])) == 0)) {
|
||||
return $default;
|
||||
}
|
||||
$s = trim($GPC[$varname]);
|
||||
@@ -24,14 +24,14 @@ function gpc_get_string(&$GPC, $varname, $maxlen = NULL, $default = NULL) {
|
||||
}
|
||||
|
||||
function gpc_get_int(&$GPC, $varname, $default = NULL) {
|
||||
if (!isset($GPC[$varname])) {
|
||||
if (!isset($GPC[$varname]) || $GPC[$varname] === '') {
|
||||
return $default;
|
||||
}
|
||||
return (int)$GPC[$varname];
|
||||
}
|
||||
|
||||
function gpc_get_uint(&$GPC, $varname, $default = NULL) {
|
||||
if (!isset($GPC[$varname])) {
|
||||
if (!isset($GPC[$varname]) || $GPC[$varname] === '') {
|
||||
return $default;
|
||||
}
|
||||
$val = (int)$GPC[$varname];
|
||||
@@ -43,7 +43,7 @@ function gpc_get_uint(&$GPC, $varname, $default = NULL) {
|
||||
|
||||
function gpc_get_float(&$GPC, $varname, $default = NULL) {
|
||||
global $g_lconv;
|
||||
if (!isset($GPC[$varname]) or (strlen(trim($GPC[$varname])) == 0)) {
|
||||
if (!isset($GPC[$varname]) || (strlen(trim($GPC[$varname])) == 0)) {
|
||||
return $default;
|
||||
}
|
||||
$var = str_replace($g_lconv['thousands_sep'], '', $GPC[$varname]);
|
||||
@@ -55,7 +55,7 @@ function gpc_get_float(&$GPC, $varname, $default = NULL) {
|
||||
|
||||
function gpc_get_currency(&$GPC, $varname, $default = NULL) {
|
||||
global $g_lconv;
|
||||
if (!isset($GPC[$varname]) or (strlen(trim($GPC[$varname])) == 0)) {
|
||||
if (!isset($GPC[$varname]) || (strlen(trim($GPC[$varname])) == 0)) {
|
||||
return $default;
|
||||
}
|
||||
$var = str_replace($g_lconv['thousands_sep'], '', $GPC[$varname]);
|
||||
@@ -132,21 +132,21 @@ function gpc_get_datetime(&$GPC, $varname, $default = NULL) {
|
||||
}
|
||||
|
||||
function gpc_get_color(&$GPC, $varname, $default = NULL) {
|
||||
if (!isset($GPC[$varname]) or (strlen(trim($GPC[$varname])) == 0)) {
|
||||
if (!isset($GPC[$varname]) || (strlen(trim($GPC[$varname])) == 0)) {
|
||||
return $default;
|
||||
}
|
||||
$color = $GPC[$varname];
|
||||
if ((strlen($color) == 7) and (substr($color, 0, 1) == '#')) {
|
||||
if ((strlen($color) == 7) && (substr($color, 0, 1) == '#')) {
|
||||
$color = substr($color, 1);
|
||||
}
|
||||
if ((strlen($color) != 6) or (! ctype_xdigit($color))) {
|
||||
if ((strlen($color) != 6) || (! ctype_xdigit($color))) {
|
||||
return $default;
|
||||
}
|
||||
return strtoupper($color);
|
||||
}
|
||||
|
||||
function gpc_get_enum(&$GPC, $varname, $values, $default = NULL) {
|
||||
if (!isset($GPC[$varname]) or (strlen(trim($GPC[$varname])) == 0)) {
|
||||
if (!isset($GPC[$varname]) || (strlen(trim($GPC[$varname])) == 0)) {
|
||||
return $default;
|
||||
}
|
||||
if (! in_array($GPC[$varname], $values)) {
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ switch ($submit = form_get_action()) {
|
||||
$p[':sid'] = $id;
|
||||
$p[':sname'] = gpc_get_string($_POST, 'sname');
|
||||
$p[':stype'] = gpc_get_string($_POST, 'stype');
|
||||
$p[':x'] = gpc_get_int($_POST, 'x');
|
||||
$p[':x'] = gpc_get_uint($_POST, 'x');
|
||||
$p[':y'] = gpc_get_int($_POST, 'y');
|
||||
$p[':z'] = gpc_get_int($_POST, 'z');
|
||||
$p[':wx'] = gpc_get_int($_POST, 'wx');
|
||||
|
||||
Reference in New Issue
Block a user