Ongoing webgui work
This commit is contained in:
+42
-43
@@ -7,6 +7,8 @@
|
||||
******************************************************************************/
|
||||
|
||||
require 'globals.inc';
|
||||
require 'lib/fileutils.inc';
|
||||
|
||||
$pagetitle = _('Equipment');
|
||||
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
@@ -145,21 +147,23 @@ switch ($submit = form_get_action()) {
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute(['picture', $file_name, $file_ext, $file_hash, $file_timestamp, $file_size, $file_mimetype]);
|
||||
$docid = $pdo->lastInsertId();
|
||||
$file_techname = $g_doc_basepath . '/pic-'.$file_hash.'.'.$file_ext;
|
||||
move_uploaded_file($file_tmp, $file_techname);
|
||||
$file_techname = file_get_docname($docid, 'picture', $file_ext);
|
||||
move_uploaded_file($file_tmp, $g_doc_basepath . '/' . $file_techname);
|
||||
} else {
|
||||
// A document record definitely exists here, now just
|
||||
// connect it to the selected equipment
|
||||
$docid = $row['docid'];
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO docref (docid, refid) VALUES (?, ?)";
|
||||
$sql = "INSERT INTO docref (docid, refid, reftype) VALUES (?, ?, 'equipment')";
|
||||
$sth = $pdo->prepare($sql);
|
||||
// Reference may already exist!
|
||||
try {
|
||||
$sth->execute([$docid, $id]);
|
||||
} catch (PDOException $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
$g_error->Add($sql);
|
||||
// $g_error->Add(print_r($params, true));
|
||||
}
|
||||
|
||||
} // for
|
||||
@@ -180,7 +184,8 @@ require 'header.php';
|
||||
if ($action == ACT_DEFAULT):
|
||||
// ========== VARIANT: default behavior =======================================
|
||||
|
||||
// load filter from db
|
||||
page_caption_search($pagetitle);
|
||||
|
||||
$flt = db_get_filter($user->id, 200);
|
||||
|
||||
$sort = array(
|
||||
@@ -237,54 +242,22 @@ $sth = $pdo->prepare($sql);
|
||||
$sth->execute($p);
|
||||
$res = $sth->fetchAll();
|
||||
|
||||
echo "<h1>$pagetitle</h1>\n";
|
||||
|
||||
// Filter
|
||||
$opt_special = array(
|
||||
/*$opt_special = array(
|
||||
-2 => _('― all ―'),
|
||||
-1 => _('― none ―')
|
||||
);
|
||||
); */
|
||||
$opt_none_male = array(-1 => pgettext('male', '― none ―'));
|
||||
?>
|
||||
<form method="post" action="<?=$g_scriptname?>">
|
||||
<div id="filter" class="card">
|
||||
<div class="card-header">Filter</div>
|
||||
<div class="card-body">
|
||||
<label for="flt_category"><?=_('Category')?></label>
|
||||
<select id="flt_category" name="flt_category">
|
||||
<?php
|
||||
foreach ($opt_special + $opt_ecat as $k => $v) {
|
||||
echo '<option value="', $k, '"';
|
||||
if ($k == $flt->cat) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>', $v, '</option>';
|
||||
}
|
||||
filter_create_select('flt_category', _('Category'), $g_opt_all + $g_opt_none + $opt_ecat, $flt->cat);
|
||||
filter_create_select('flt_manuf', _('Manufacturer'), $g_opt_all + $opt_none_male + $opt_manufacturer, $flt->manuf);
|
||||
filter_create_select('flt_supp', _('Supplier'), $g_opt_all + $opt_none_male + $opt_supplier, $flt->supp);
|
||||
?>
|
||||
</select>
|
||||
<label for="flt_manuf"><?=_('Manufacturer')?></label>
|
||||
<select id="flt_manuf" name="flt_manuf">
|
||||
<?php
|
||||
foreach ($opt_special + $opt_manufacturer as $k => $v) {
|
||||
echo '<option value="', $k,'"';
|
||||
if ($k == $flt->manuf) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>', $v, '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<label for="flt_supp"><?=_('Supplier')?></label>
|
||||
<select id="flt_supp" name="flt_supp">
|
||||
<?php
|
||||
foreach ($opt_special + $opt_supplier as $k => $v) {
|
||||
echo '<option value="', $k,'"';
|
||||
if ($k == $flt->supp) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>', $v, '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<label for="flt_txt"><?=_('Text')?></label>
|
||||
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>">
|
||||
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
|
||||
@@ -394,7 +367,7 @@ echo '<tr><th>', _('Serial'),"</th><td>", $equipment->serial, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Weight'),"</th><td>", format_float($equipment->weight, 2, 'kg'), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Price'),"</th><td>", format_currency($equipment->price), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Purchase date'),"</th><td>", $equipment->purchdate, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Supplier'),"</th><td>", $opt_supplier[$equipment->supplier], "</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";
|
||||
echo '<tr><th>', _('Remarks'),"</th><td>", $equipment->remarks, "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
@@ -422,6 +395,14 @@ foreach ($res as $row) {
|
||||
echo '<img width="120" src="dl.php?id=', $row['docid'], '&t=s" alt="', $row['title'], '">';
|
||||
// echo $row['title'];
|
||||
echo "</a>\n";
|
||||
} elseif ($row['doctype'] == 'manual') {
|
||||
echo "Manual: ";
|
||||
echo '<a href="documents.php?f=view&id=', $row['docid'], '">';
|
||||
echo $row['title'];
|
||||
echo "</a>\n";
|
||||
} else {
|
||||
// unknown document type
|
||||
echo "<span>Unknown document type:", $row['doctype'], "</span>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -487,6 +468,24 @@ echo '<a href="measurement.php?f=add&id=', $id, '" class="btn btn-primary" role=
|
||||
echo _('Add measurement'), "</a>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
// Spare parts
|
||||
echo '<h3>', _('Spare parts'), "</h3>";
|
||||
|
||||
$sql = "SELECT invid, invname FROM inventory WHERE eid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$id]);
|
||||
if ($sth->rowCount() > 0) {
|
||||
echo "<ul>\n";
|
||||
foreach ($sth->fetchAll() as $row) {
|
||||
echo "<li>", $row['invname'], ': ';
|
||||
echo ' <a title="', _('View'), '" href="inventory.php?f=view&id=', $row['invid'], '"><i class="bi-eye"></i></a>';
|
||||
echo "</li>\n";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
} else {
|
||||
echo '<p>', _('No spare parts found.'), "<p>\n";
|
||||
}
|
||||
|
||||
elseif ($action == ACT_EDIT):
|
||||
// ========== VARIANT: edit single record =====================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user