diff --git a/db/mariadb.sql b/db/mariadb.sql index 1fdd94a..8bd4dc7 100644 --- a/db/mariadb.sql +++ b/db/mariadb.sql @@ -146,6 +146,7 @@ CREATE TABLE inventory ( price decimal(12,2) DEFAULT NULL, purchdate date DEFAULT NULL, invcond enum('unknown','good','normal','bad','repairable','defect') NOT NULL default 'unknown', + remarks varchar(150) DEFAULT NULL, PRIMARY KEY (invid), INDEX ix_invname (invname) ); @@ -189,16 +190,20 @@ CREATE TABLE document ( pages smallint(6) unsigned NOT NULL DEFAULT 1, remarks varchar(150) DEFAULT NULL, PRIMARY KEY (docid) -); +) ENGINE=InnoDB; CREATE TABLE docref ( drid int(10) NOT NULL AUTO_INCREMENT, - reftype enum('vessel', 'box', 'equipment', 'project', 'task') NOT NULL DEFAULT 'vessel', + reftype enum('vessel', 'box', 'equipment', 'project', 'task', 'user') NOT NULL DEFAULT 'vessel', docid smallint(6) NOT NULL, refid smallint(6) NOT NULL, PRIMARY KEY (drid), - UNIQUE INDEX ix_docref (docid, refid) -); + UNIQUE INDEX ix_docref (docid, refid), + FOREIGN KEY fx_docref_doc (docid) + REFERENCES document (docid) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB; CREATE TABLE company ( compid smallint(6) NOT NULL AUTO_INCREMENT, diff --git a/webgui/box.php b/webgui/box.php index a91019f..fdf193e 100644 --- a/webgui/box.php +++ b/webgui/box.php @@ -36,33 +36,18 @@ switch ($submit = form_get_action()) { $p[':sid'] = gpc_get_int($_POST, 'sid'); $p[':content'] = gpc_get_string($_POST, 'content'); $p[':remarks'] = gpc_get_string($_POST, 'remarks'); - $keys = array_keys($p); - $fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys)); - $pnames = join(',', $keys); - $sth = $pdo->prepare("INSERT INTO box ($fields) VALUES ($pnames)"); - try { - $sth->execute($p); - } catch (PDOexception $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } - $id = $pdo->LastInsertId(); + $id = db_exec_insert('box', $p); $action = ACT_VIEW; break; case 'update': + $p[':boxid'] = $id; $p[':label'] = gpc_get_string($_POST, 'label'); $p[':content'] = gpc_get_string($_POST, 'content'); $p[':color'] = gpc_get_color($_POST, 'color'); $p[':weight'] = min(gpc_get_float($_POST, 'weight'), 99.99); $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); - $fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p))); - $sth = $pdo->prepare("UPDATE box SET $fields WHERE boxid=:boxid"); - $p[':boxid'] = $id; - try { - $sth->execute($p); - } catch (PDOexception $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } + db_exec_update('box', $p, 'boxid'); $action = ACT_VIEW; break; diff --git a/webgui/config.inc-sample b/webgui/config.inc-sample index ee48b72..8a703b3 100644 --- a/webgui/config.inc-sample +++ b/webgui/config.inc-sample @@ -38,3 +38,6 @@ $g_doc_maxsize = 1024*1024*16; // 16 MB $g_storage_limit = 1024; // MB $g_thumb_size = 120; + +$g_rows_pp = 10; // pagination limit + diff --git a/webgui/documents.php b/webgui/documents.php index cc760c6..e690ada 100644 --- a/webgui/documents.php +++ b/webgui/documents.php @@ -24,9 +24,7 @@ switch ($submit = form_get_action()) { case 'insert': // WIP New standalone document - $p[':title'] = gpc_get_string($_POST, 'title'); - $p[':remarks'] = gpc_get_string($_POST, 'remarks'); - $g_message->Add(print_r($_FILES, true)); + // debug $g_message->Add(print_r($_FILES, true)); if (empty($_FILES['files']['tmp_name']) ) { $g_warning->Add(_('No file for upload submitted. Try again by selecting a file first.')); $action = ACT_ADD; @@ -66,6 +64,7 @@ switch ($submit = form_get_action()) { case 'application/pdf': $file_techname = $g_doc_basepath . '/doc-'.$file_hash.'.'.$file_ext; $doctype = 'generic'; + // $p['pages'] = pdf_get_pagecount($file_tmp); break; case 'image/svg+xml': $file_techname = $g_doc_basepath . '/drw-'.$file_hash.'.'.$file_ext; @@ -86,41 +85,17 @@ switch ($submit = form_get_action()) { $p[':docsize'] = $file_size; $p[':title'] = gpc_get_string($_POST, 'title'); $p[':remarks'] = gpc_get_string($_POST, 'remarks'); -/* $sql = "INSERT INTO document" - . " (doctype, filename, extension, hash, doctime, docsize, mimetype) " - . "VALUES" - . " (?, ?, ?, ?, ?, ?, ?)"; - $sth = $pdo->prepare($sql); - try { - $sth->execute([$doctype, $file_name, $file_ext, $file_hash, $file_timestamp, $file_size, $file_mimetype]); - } catch (PDOException $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } - $id = $pdo->lastInsertId(); */ $id = db_exec_insert('document', $p); move_uploaded_file($file_tmp, $file_techname); $action = ACT_VIEW; break; case 'update': - $filename = gpc_get_string($_POST, 'filename'); - $title = gpc_get_string($_POST, 'title', 40); - $remarks = gpc_get_string($_POST, 'remarks', 150); - $sql = "UPDATE document " - . "SET filename=:filename," - . " title=:title," - . " remarks=:remarks " - . "WHERE docid=:docid"; - $sth = $pdo->prepare($sql); - $sth->bindValue(':docid', $id, PDO::PARAM_INT); - $sth->bindValue(':filename', $filename, PDO::PARAM_STR); - $sth->bindValue(':title', $title, PDO::PARAM_STR); - $sth->bindValue(':remarks', $remarks, PDO::PARAM_STR); - try { - $sth->execute(); - } catch (PDOException $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } + $p[':docid'] = $id; + $p['filename'] = gpc_get_string($_POST, 'filename'); + $p['title'] = gpc_get_string($_POST, 'title', 40); + $p['remarks'] = gpc_get_string($_POST, 'remarks', 150); + db_exec_update('document', $p, 'docid'); $action = ACT_VIEW; break; diff --git a/webgui/dropdown.php b/webgui/dropdown.php index 3809c63..cceddc3 100644 --- a/webgui/dropdown.php +++ b/webgui/dropdown.php @@ -236,7 +236,7 @@ foreach ($sth->fetchAll() as $row) { echo '', $row['ddval'],''; echo '', $row['ddtext'], ''; echo '', $row['ddshort'], ''; - echo '', $row['color'], ''; + echo '', format_color($row['color']), ''; echo '', $row['sort'], ''; // Action links echo ''; diff --git a/webgui/equipment.php b/webgui/equipment.php index 0cedd22..568e51e 100644 --- a/webgui/equipment.php +++ b/webgui/equipment.php @@ -11,8 +11,8 @@ $pagetitle = _('Equipment'); $id = gpc_get_int($_REQUEST, 'id', 0); -$opt_supplier = db_get_opt_supp(array(-1 => _('unknown'))); -$opt_manufacturer = db_get_opt_manuf(array(-1 => _('unknown'))); +$opt_supplier = db_get_opt_supp(array(-1 => _('--- unknown ---'))); +$opt_manufacturer = db_get_opt_manuf(array(-1 => _('--- unknown ---'))); $opt_ecat = db_get_options(4); // Equipment categories // ========== ACTIONS START =================================================== @@ -26,72 +26,47 @@ switch ($submit = form_get_action()) { case 'edit': $action = ACT_EDIT; break; case 'del': $action = ACT_DELETE; break; - case 'insert': - $ename = gpc_get_string($_POST, 'ename'); - $ecat = gpc_get_int($_POST, 'category'); - $manufacturer = gpc_get_int($_POST, 'manufacturer'); - $model = gpc_get_string($_POST, 'model'); - $remarks = gpc_get_string($_POST, 'remarks', 150); - $sql = "INSERT INTO equipment " - . " (vid, ename, manufacturer, model, ecat, remarks) " - . "VALUES " - . " (:vid, :ename, :manufacturer, :model, :ecat, :remarks)"; + case 'filter': + // TODO save new filter settings + $flt = array(); + $flt['cat'] = gpc_get_int($_POST, 'flt_category'); + $flt['manuf'] = gpc_get_int($_POST, 'flt_manuf'); + $flt['supp'] = gpc_get_int($_POST, 'flt_supp'); + $flt['txt'] = gpc_get_string($_POST, 'flt_txt'); + $sql = "UPDATE settings SET valstr=? WHERE userid=? AND sno=200"; $sth = $pdo->prepare($sql); - $sth->bindValue(':vid', $user->vid, PDO::PARAM_INT); - $sth->bindValue(':ename', $ename, PDO::PARAM_STR); - $sth->bindValue(':model', $model, PDO::PARAM_STR); - $sth->bindValue(':ecat', $ecat, PDO::PARAM_INT); - $sth->bindValue(':manufacturer', $manufacturer, PDO::PARAM_INT); - $sth->bindValue(':remarks', $remarks, PDO::PARAM_STR); - try { - $sth->execute(); - } catch (PDOException $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } - $id = $pdo->lastInsertId(); + $sth->execute([json_encode($flt), $user->id]); + // Only warning in case of failure + $action = ACT_DEFAULT; + break; + + case 'insert': + $p[':vid'] = $user->vid; + $p[':ename'] = gpc_get_string($_POST, 'ename'); + $p[':ecat'] = gpc_get_int($_POST, 'category'); + $p[':manufacturer'] = gpc_get_int($_POST, 'manufacturer'); + $p[':model'] = gpc_get_string($_POST, 'model'); + $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); + $id = db_exec_insert('equipment', $p); $action = ACT_VIEW; break; case 'update': - $ename = gpc_get_string($_POST, 'ename'); - $model = gpc_get_string($_POST, 'model'); - $serial = gpc_get_string($_POST, 'serial'); - $weight = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value - $price = gpc_get_currency($_POST, 'price'); - $purchdate = gpc_get_date($_POST, 'purchdate'); - $supplier = gpc_get_int($_POST, 'supplier'); - $manufacturer = gpc_get_int($_POST, 'manufacturer'); - $ecat = gpc_get_int($_POST, 'category'); - $remarks = gpc_get_string($_POST, 'remarks', 150); - $sql = "UPDATE equipment " - . "SET ename=:ename," - . " model=:model," - . " serial=:serial," - . " weight=:weight," - . " price=:price," - . " purchdate=:purchdate," - . " supplier=:supplier," - . " manufacturer=:manufacturer," - . " ecat=:ecat," - . " remarks=:remarks " - . "WHERE eid=:eid"; - $sth = $pdo->prepare($sql); - $sth->bindValue(':eid', $id, PDO::PARAM_INT); - $sth->bindValue(':ename', $ename, PDO::PARAM_STR); - $sth->bindValue(':model', $model, PDO::PARAM_STR); - $sth->bindValue(':serial', $serial, PDO::PARAM_STR); - $sth->bindValue(':weight', $weight); - $sth->bindValue(':price', $price); - $sth->bindValue(':purchdate', $purchdate, PDO::PARAM_STR); - $sth->bindValue(':supplier', $supplier, PDO::PARAM_INT); - $sth->bindValue(':manufacturer', $manufacturer, PDO::PARAM_INT); - $sth->bindValue(':ecat', $ecat, PDO::PARAM_INT); - $sth->bindValue(':remarks', $remarks, PDO::PARAM_STR); - try { - $sth->execute(); - } catch (PDOException $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } + $p[':eid'] = $id; + $p[':ename'] = gpc_get_string($_POST, 'ename'); + $p[':model'] = gpc_get_string($_POST, 'model'); + $p[':serial'] = gpc_get_string($_POST, 'serial'); + $p[':weight'] = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value + $p[':price'] = gpc_get_currency($_POST, 'price'); + $p[':purchdate'] = gpc_get_date($_POST, 'purchdate'); + $p[':supplier'] = gpc_get_int($_POST, 'supplier'); + if ($p[':supplier'] <= 0) $p[':supplier'] = NULL; + $p[':manufacturer'] = gpc_get_int($_POST, 'manufacturer'); + if ($p[':manufacturer'] <= 0) $p[':manufacturer'] = NULL; + $p[':ecat'] = gpc_get_int($_POST, 'category'); + if ($p[':ecat'] <= 0) $p[':ecat'] = NULL; + $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); + db_exec_update('equipment', $p, 'eid'); $action = ACT_VIEW; break; @@ -208,24 +183,80 @@ require 'header.php'; if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= +// load filter from db +$flt = db_get_filter($user->id, 200); +/*$flt = new stdClass(); +$sth = $pdo->prepare("SELECT valstr FROM settings WHERE userid=? AND sno=200"); +try { + $sth->execute([$user->id]); + $json = $sth->fetchColumn(); + if (!$json) { + // no settings record. create empty one for later updates + $sth = $pdo->prepare("INSERT INTO settings (userid, sno, valstr) VALUES (?, 200, '[]')"); + $sth->execute([$user->id]); + } else { + $flt = json_decode($json); + } +} catch (PDOexception $e) { + $g_warning->Add('SQL-Error: '. $e->getMessage()); +} */ + $sort = array( 1 => 'ename', 2 => 'ename DESC' ); +$w = array('vid=:vid'); +$p = array(':vid' => $user->vid); +if ($flt->cat == -1) { + $w[] = 'ecat IS NULL'; +} elseif ($flt->cat > 0) { + $w[] = 'ecat=:ecat'; + $p[':ecat'] = $flt->cat; +} +if ($flt->manuf > 0) { + $w[] = 'manufacturer=:manuf'; + $p[':manuf'] = $flt->manuf; +} +if ($flt->supp > 0) { + $w[] = 'supplier=:supp'; + $p[':supp'] = $flt->supp; +} +if (strlen($flt->txt) > 1) { + $w[] = '(ename LIKE :txt OR model LIKE :txt OR remarks LIK :txt'; + $p[':txt'] = '%'.$flt->txt.'%'; +} +$where = join(' AND ', $w); +$order = ' ORDER BY ename'; + +// get total recond count for pagination and limit +$sth = $pdo->prepare("SELECT COUNT(*) FROM equipment WHERE " . $where); +$sth->execute($p); +$numrows = $sth->fetchColumn(); +$lastpage = ceil($numrows/$g_rows_pp); +$page = gpc_get_int($_REQUEST, 'p', 1); + $sql = "SELECT eid, ename, manufacturer, model, serial, remarks," . " TIMESTAMPDIFF(MONTH, purchdate, NOW()) AS age_mon " - . "FROM equipment WHERE vid=? " - . "ORDER BY eid"; + . "FROM equipment"; +$sql .= ' WHERE ' . $where; +$sql .= $order; + +// if pagination: +$sql .= ' LIMIT ' . ($page - 1) * $g_rows_pp . ',' . $g_rows_pp; + $sth = $pdo->prepare($sql); -$sth->execute([$user->vid]); +$sth->execute($p); $res = $sth->fetchAll(); echo "

$pagetitle

\n"; // Filter +$opt_special = array( + -2 => _('― all ―'), + -1 => _('― none ―') +); ?> -
Filter
@@ -233,35 +264,61 @@ echo "

$pagetitle

\n"; - $v) { - echo ''; +foreach ($opt_special + $opt_manufacturer as $k => $v) { + echo ''; } ?> - + + + + +
', "\n"; echo "\n"; -echo ""; -echo "" . _('Description') . ""; -echo "" . _('Manufacturer') . ""; -echo "" . _('Model') . ""; -echo "" . _('Serial') . ""; -echo "" . _('Age') . ""; -echo "" . _('Remarks') . ""; +echo ''; +echo '', _('Description'), ""; +echo '', _('Manufacturer'), ""; +echo '', _('Model'), ""; +echo '', _('Serial'), ""; +echo '', _('Age'), ""; +echo '', _('Remarks'), ""; echo " "; echo "\n"; echo "\n"; @@ -275,20 +332,22 @@ foreach ($res as $row) { $age = sprintf(_('%dy'), intdiv($row['age_mon'], 12)); } echo "\n"; - echo "". $row['ename'] ."\n"; - echo "". $opt_manufacturer[$row['manufacturer']] ."\n"; - echo "". $row['model'] ."\n"; - echo "". $row['serial'] ."\n"; - echo "". $age ."\n"; - echo "". $row['remarks'] ."\n"; + echo "", $row['ename'], "\n"; + echo "", ($opt_manufacturer[$row['manufacturer']] ?? ''), "\n"; + echo "", $row['model'], "\n"; + echo "", $row['serial'], "\n"; + echo "", $age, "\n"; + echo "", $row['remarks'], "\n"; // Action buttons form_action_buttons($g_scriptname, $row['eid']); } ?> - + + - - */ +echo $pagination; form_add_button($g_scriptname); elseif ($action == ACT_ADD): // ========== VARIANT: add record ============================================= + +// filter used to preselect fields +$flt = db_get_filter($user->id, 200); ?>

@@ -311,8 +373,8 @@ elseif ($action == ACT_ADD): '--- none ---'] + $opt_ecat, $flt->cat); +form_create_select('manufacturer', _('Manufacturer'), $opt_manufacturer, $flt->manuf); ?>
@@ -446,7 +508,7 @@ $equipment = $sth->fetch(PDO::FETCH_OBJ);
supplier); -form_create_select('category', _('Category'), $opt_ecat, $equipment->ecat); +form_create_select('category', _('Category'), [-1 => _('--- unknown ---')] + $opt_ecat, $equipment->ecat); ?>
diff --git a/webgui/index.php b/webgui/index.php index d2e471c..f80f2ea 100644 --- a/webgui/index.php +++ b/webgui/index.php @@ -41,16 +41,7 @@ switch ($submit = form_get_action()) { $p[':vesselname'] = gpc_get_string($_POST, 'vesselname'); $p[':model'] = gpc_get_string($_POST, 'model'); $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); - $keys = array_keys($p); - $fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys)); - $pnames = join(',', $keys); - $sth = $pdo->prepare("INSERT INTO vessel ($fields) VALUES ($pnames)"); - try { - $sth->execute($p); - } catch (PDOException $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } - $id = $pdo->LastInsertId(); + $id = db_exec_insert('vessel', $p); // autoselect newly created vessel $sql = "UPDATE settings SET valint=? WHERE userid=? AND sno=1"; $sth = $pdo->prepare($sql); @@ -59,7 +50,7 @@ switch ($submit = form_get_action()) { } catch (PDOException $e) { $g_error->Add('SQL-Error: '. $e->getMessage()); } - $g_message->Add(sprintf(_('Selected new vessel %d'), $vid)); + $g_message->Add(sprintf(_('Selected new vessel %d'), $id)); $user->load_vessel(); break; @@ -68,6 +59,7 @@ switch ($submit = form_get_action()) { $g_error->Add(_('Access denied. You are not the captain.')); break; } + $p[':vid'] = gpc_get_int($_POST, 'id'); // $p[':vtype'] = gpc_get_string($_POST, 'vtype'); $p[':vesselname'] = gpc_get_string($_POST, 'vesselname'); $p[':model'] = gpc_get_string($_POST, 'model'); @@ -82,14 +74,7 @@ switch ($submit = form_get_action()) { $p[':beltpos_bow'] = gpc_get_float($_POST, 'beltpos_bow'); $p[':shapefile'] = gpc_get_string($_POST, 'shapefile'); $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); - $fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p))); - $sth = $pdo->prepare("UPDATE vessel SET $fields WHERE vid=:vid"); - $p[':vid'] = gpc_get_int($_POST, 'id'); - try { - $sth->execute($p); - } catch (PDOException $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } + db_exec_update('vessel', $p, 'vid'); $action = ACT_DEFAULT; break; @@ -153,38 +138,19 @@ $sth->execute([$vid]); $vessel = $sth->fetch(); // get vessel shape -// TODO predefine base shapes for different vessels +// test for predefined base shape $shapefilepath = dirname(__FILE__).'/'.$g_shapedir.'/'.$vessel['shapefile']; if (isset($vessel['shapefile']) and file_exists($shapefilepath)) { $baseshape = file_get_contents($shapefilepath); } else { // use internal default shape $baseshape = << - - - - - + + + + + + EOT; } @@ -198,17 +164,17 @@ $line = $g->addChild('line'); $line->addAttribute('x1', '100'); $line->addAttribute('y1', '0'); $line->addAttribute('x2', '100'); -$line->addAttribute('y2', '100'); -$line->addAttribute('style', 'stroke:#ff0000;stroke-width:0.25px'); +$line->addAttribute('y2', '350'); +$line->addAttribute('style', 'stroke:#ff0000;stroke-width:1px'); // rectangle for storage $rect = $g->addChild('rect'); -$rect->addAttribute('x', '2'); -$rect->addAttribute('y', '14'); -$rect->addAttribute('width', '20'); -$rect->addAttribute('height', '26'); +$rect->addAttribute('x', '10'); +$rect->addAttribute('y', '80'); +$rect->addAttribute('width', '40'); +$rect->addAttribute('height', '60'); $rect->addAttribute('stroke', '#000'); -$rect->addAttribute('stroke-width', '0.25px'); +$rect->addAttribute('stroke-width', '1px'); $rect->addAttribute('fill', '#57E389'); $rect->addAttribute('fill-opacity', '0.4'); @@ -216,9 +182,9 @@ $rect->addAttribute('fill-opacity', '0.4'); $link = $g->addChild('a'); $link->addAttribute('xlink:href', 'storage.php?f=view&id=1'); $text = $link->addChild('text', 'Box1'); -$text->addAttribute('font-size', '3.5'); -$text->addAttribute('x', '4'); -$text->addAttribute('y', '18'); +$text->addAttribute('font-size', '10'); +$text->addAttribute('x', '14'); +$text->addAttribute('y', '95'); ?>
@@ -369,6 +335,13 @@ echo '

', _('Add additional yacht'), "

\n"; elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== +// get list of shapefiles +$opt_shapefiles = array('' => _('--- none ---')); +foreach (glob($g_shapedir.'/*.svg') as $f) { + $f = basename($f); + $opt_shapefiles[$f] = $f; +} + $sql = "SELECT vesselname, vtype, model, loa, lwl, beam, draught, draught_min," . " displacement, ballast, beltpos_aft, beltpos_bow, shapefile," . " remarks " @@ -425,10 +398,13 @@ $vessel = $sth->fetch(PDO::FETCH_OBJ);
+ -
+ */ +form_create_select('shapefile', _('Shape file'), $opt_shapefiles, $vessel->shapefile); +?>
diff --git a/webgui/inventory.php b/webgui/inventory.php index ef9370e..bf68f48 100644 --- a/webgui/inventory.php +++ b/webgui/inventory.php @@ -25,6 +25,10 @@ switch ($submit = form_get_action()) { case 'edit': $action = ACT_EDIT; break; case 'del': $action = ACT_DELETE; break; + case 'filter': + $action = ACT_DEFAULT; + break; + case 'insert': $p[':invname'] = gpc_get_string($_POST, 'invname'); $p[':number'] = gpc_get_int($_POST, 'number'); @@ -47,6 +51,7 @@ switch ($submit = form_get_action()) { $p[':price'] = gpc_get_currency($_POST, 'price'); $p[':purchdate'] = gpc_get_date($_POST, 'purchdate'); $p[':invcond'] = gpc_get_string($_POST, 'invcond'); + $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); db_exec_update('inventory', $p, 'invid'); $action = ACT_VIEW; break; @@ -80,6 +85,8 @@ require 'header.php'; if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= +$flt = db_get_filter($user->id, 201); + /* The only way to find out whether the inventory is on the current boat is to use the box assignment. But this is also intentional to allow easy rearrangement. @@ -161,7 +168,8 @@ form_create_select('boxid', _('Box'), $opt_box); elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== -$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate, invcond " +$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate," + . " invcond,remarks " . "FROM inventory " . "WHERE invid=?"; $sth = $pdo->prepare($sql); @@ -210,6 +218,7 @@ echo "", _('Weight'), "", format_float($inventory->weight, 2, ' echo "", _('Price'), "", format_currency($inventory->price), "\n"; echo "", _('Purchase date'), "", $inventory->purchdate, "\n"; echo "", _('Condition'), "", $inventory->invcond, "\n"; +echo "", _('Remarks'), "", $inventory->remarks, "\n"; echo "\n"; form_view_buttons($g_scriptname, $id); @@ -217,7 +226,8 @@ form_view_buttons($g_scriptname, $id); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== -$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate, invcond " +$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate, " + . " invcond, remarks " . "FROM inventory " . "WHERE invid=?"; $sth = $pdo->prepare($sql); @@ -281,6 +291,10 @@ foreach ($cond as $k => $v) { ?>
+
+ + +

Die Yachtdaten können nur mit de Berechtigungsebene captain verändert werden.

+

Es kann eine Aufsicht für die betreffende Yacht eingerichtet werden. +Diese ist als SVG-Zeichnung zu hinterlegen, der Stauraum kann dann +an der passenden Position angezeigt werden.

+

Bei Neuanlage eines Datensatzes werden nur die wichtigsten Felder angezeigt. Weitere Felder können im Anschluß über die Bearbeiten-Funktion ausgefüllt werden.

@@ -66,7 +70,9 @@ z.B. neu, laufend oder erledigt.

Firmen

Es können verschiedene Arten von Firmen hinterlegt werden, wie -beispielsweise Hersteller, Lieferanten oder Dienstleister.

+beispielsweise Hersteller, Lieferanten, Werften oder Dienstleister.

+

Hersteller und Lieferanten sind immer vorhanden, sie werden als +Auswahl an anderen Stellen im Programm benötigt.

Dokumente

Ein Dokument kann mehrfach zugeordnet werden. Z.B. einem diff --git a/webgui/projects.php b/webgui/projects.php index 92eba70..fb13fe6 100644 --- a/webgui/projects.php +++ b/webgui/projects.php @@ -213,9 +213,10 @@ $sth->execute([$id]); -fetchAll() as $row):?> +fetchAll() as $row): ?> + diff --git a/webgui/provisions.php b/webgui/provisions.php index 917ffb2..7dc5623 100644 --- a/webgui/provisions.php +++ b/webgui/provisions.php @@ -32,34 +32,19 @@ switch ($submit = form_get_action()) { $p[':unit'] = gpc_get_int($_POST, 'unit'); $p[':storedate'] = gpc_get_string($_POST, 'storedate'); $p[':shelflife'] = gpc_get_string($_POST, 'shelflife'); - $keys = array_keys($p); - $fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys)); - $pnames = join(',', $keys); - $sth = $pdo->prepare("INSERT INTO provisions ($fields) VALUES ($pnames)"); - try { - $sth->execute($p); - } catch (PDOexception $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } - $id = $pdo->LastInsertId(); + $id = db_exec_insert('provisions', $p); $action = ACT_VIEW; break; case 'update': + $p[':provid'] = $id; $p[':provname'] = gpc_get_string($_POST, 'provname'); $p[':number'] = gpc_get_int($_POST, 'number'); $p[':unit'] = gpc_get_int($_POST, 'unit'); $p[':storedate'] = gpc_get_string($_POST, 'storedate'); $p[':shelflife'] = gpc_get_string($_POST, 'shelflife'); $p[':sid'] = gpc_get_int($_POST, 'sid'); - $fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p))); - $sth = $pdo->prepare("UPDATE provisions SET $fields WHERE provid=:provid"); - $p[':provid'] = $id; - try { - $sth->execute($p); - } catch (PDOexception $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } + db_exec_update('provisions', $p, 'provid'); $action = ACT_VIEW; break; diff --git a/webgui/storage.php b/webgui/storage.php index 1084505..abdb098 100644 --- a/webgui/storage.php +++ b/webgui/storage.php @@ -158,7 +158,7 @@ echo "\n"; foreach ($res as $row) { echo "\n"; echo "". $row['label'] ."\n"; - echo ''. $row['color'] ."\n"; + echo '', format_color($row['color']), "\n"; echo "". $row['content'] ."\n"; form_action_buttons('box.php', $row['boxid']); echo "\n"; diff --git a/webgui/task.php b/webgui/task.php index 70c9e1a..d8c27b2 100644 --- a/webgui/task.php +++ b/webgui/task.php @@ -30,34 +30,24 @@ switch ($submit = form_get_action()) { $p[':projid'] = NULL; } $p[':taskname'] = gpc_get_string($_POST, 'taskname'); - $keys = array_keys($p); - $fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys)); - $pnames = join(',', $keys); - $sth = $pdo->prepare("INSERT INTO task ($fields) VALUES ($pnames)"); - try { - $sth->execute($p); - } catch (PDOexception $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } + $id = db_exec_insert('task', $p); + $action = ACT_VIEW; break; case 'update': - $p[':taskname'] = gpc_get_string($_POST, 'taskname'); + $p[':taskid'] = $id; $p[':projid'] = gpc_get_int($_POST, 'projid'); if ($p[':projid'] == -1) { $p[':projid'] = NULL; } - $fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p))); - $sth = $pdo->prepare("UPDATE task SET $fields WHERE taskid=:taskid"); - $p[':taskid'] = $id; - try { - $sth->execute($p); - } catch (PDOexception $e) { - $g_error->Add('SQL-Error: '. $e->getMessage()); - } + $p[':taskname'] = gpc_get_string($_POST, 'taskname'); + db_exec_update('task', $p, 'taskid'); $action = ACT_VIEW; break; + case 'delete': + break; + default: $g_error->Add(sprintf(_("Unknown function '%s'!"), $submit)); $valid = FALSE; @@ -155,7 +145,7 @@ form_view_buttons($g_scriptname, $id); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== -$sql = "SELECT taskname " +$sql = "SELECT taskname, projid " . "FROM task " . "WHERE taskid=?"; $sth = $pdo->prepare($sql); @@ -172,7 +162,7 @@ echo '

', _('Edit Task'), "

\n"; projid); form_edit_buttons($g_scriptname, $id); echo "
\n";