More work an webgui

This commit is contained in:
2024-04-10 20:13:37 +02:00
parent 4b5ba85a77
commit aaa452cbb5
20 changed files with 842 additions and 359 deletions
+19 -56
View File
@@ -24,65 +24,28 @@ switch ($submit = form_get_action()) {
case 'del': $action = ACT_DELETE; break;
case 'insert':
$compname = gpc_get_string($_POST, 'compname');
$comptype = gpc_get_int($_POST, 'comptype');
$sql = "INSERT INTO company "
. " (compname, comptype) "
. "VALUES "
. " (:compname, :comptype)";
$sth = $pdo->prepare($sql);
$sth->bindValue(':compname', $compname, PDO::PARAM_STR);
$sth->bindValue(':comptype', $comptype, PDO::PARAM_INT);
$sth->execute();
$id = $pdo->lastInsertId();
$p[':compname'] = gpc_get_string($_POST, 'compname');
$p[':comptype'] = gpc_get_int($_POST, 'comptype');
$id = db_exec_insert('company', $p);
$action = ACT_VIEW;
break;
case 'update':
$compname = gpc_get_string($_POST, 'compname');
$comptype = gpc_get_int($_POST, 'comptype');
$street = gpc_get_string($_POST, 'street', 30);
$zip = gpc_get_string($_POST, 'zip', 10);
$city = gpc_get_string($_POST, 'city', 30);
$country = gpc_get_string($_POST, 'country', 30);
$contact = gpc_get_string($_POST, 'contact', 30);
$phone = gpc_get_string($_POST, 'phone', 30);
$email = gpc_get_string($_POST, 'email', 50);
$web = gpc_get_string($_POST, 'web', 40);
$customerno = gpc_get_string($_POST, 'customerno', 20);
$contractno = gpc_get_string($_POST, 'contractno', 20);
$remarks = gpc_get_string($_POST, 'remarks', 150);
$sql = "UPDATE company "
. "SET compname=:compname,"
. " comptype=:comptype,"
. " street=:street,"
. " zip=:zip,"
. " city=:city,"
. " country=:country,"
. " contact=:contact,"
. " phone=:phone,"
. " email=:email,"
. " web=:web,"
. " customerno=:customerno,"
. " contractno=:contractno,"
. " remarks=:remarks "
. "WHERE compid=:compid";
$sth = $pdo->prepare($sql);
$sth->bindValue(':compid', $id, PDO::PARAM_INT);
$sth->bindValue(':compname', $compname, PDO::PARAM_STR);
$sth->bindValue(':comptype', $comptype, PDO::PARAM_INT);
$sth->bindValue(':street', $street, PDO::PARAM_STR);
$sth->bindValue(':zip', $zip, PDO::PARAM_STR);
$sth->bindValue(':city', $city, PDO::PARAM_STR);
$sth->bindValue(':country', $country, PDO::PARAM_STR);
$sth->bindValue(':contact', $contact, PDO::PARAM_STR);
$sth->bindValue(':phone', $phone, PDO::PARAM_STR);
$sth->bindValue(':email', $email, PDO::PARAM_STR);
$sth->bindValue(':web', $web, PDO::PARAM_STR);
$sth->bindValue(':customerno', $customerno, PDO::PARAM_STR);
$sth->bindValue(':contractno', $contractno, PDO::PARAM_STR);
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
$sth->execute();
$p[':compid'] = $id;
$p[':compname'] = gpc_get_string($_POST, 'compname');
$p[':comptype'] = gpc_get_int($_POST, 'comptype');
$p[':street'] = gpc_get_string($_POST, 'street', 30);
$p[':zip'] = gpc_get_string($_POST, 'zip', 10);
$p[':city'] = gpc_get_string($_POST, 'city', 30);
$p[':country'] = gpc_get_string($_POST, 'country', 30);
$p[':contact'] = gpc_get_string($_POST, 'contact', 30);
$p[':phone'] = gpc_get_string($_POST, 'phone', 30);
$p[':email'] = gpc_get_string($_POST, 'email', 50);
$p[':web'] = gpc_get_string($_POST, 'web', 40);
$p[':customerno'] = gpc_get_string($_POST, 'customerno', 20);
$p[':contractno'] = gpc_get_string($_POST, 'contractno', 20);
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
db_exec_update('company', $p, 'compid');
$action = ACT_VIEW;
break;
@@ -157,7 +120,7 @@ elseif ($action == ACT_ADD):
echo '<h2>', _('Add Company'), "</h2>\n";
?>
<form method="post">
<form method="post" action="<?=$g_scriptname?>">
<div class="mb-3">
<label for="compname" class="form-label"><?=_('Name')?></label>
<input type="text" class="form-control" id="compname" name="compname">