_('*** unassigned ***')); $sql = "SELECT eid, ename FROM equipment WHERE vid=? ORDER BY ename"; $sth = $pdo->prepare($sql); $sth->execute([$user->vid]); foreach ($sth->fetchAll() as $row) { $opt_equipment[$row['eid']] = $row['ename']; } // ========== ACTIONS START =================================================== switch ($submit = form_get_action()) { case NULL: break; case 'add': $action = ACT_ADD; break; case 'view': $action = ACT_VIEW; break; case 'edit': $action = ACT_EDIT; break; case 'del': $action = ACT_DELETE; break; case 'insert': $eid = gpc_get_int($_POST, 'eid'); $activities = gpc_get_string($_POST, 'activities', 80); $sql = "INSERT INTO maintenance " . " (vid, eid, activities) " . "VALUES " . " (:vid, :eid, :activities)"; $sth = $pdo->prepare($sql); $sth->bindValue(':vid', $user->vid, PDO::PARAM_INT); $sth->bindValue(':eid', $eid, PDO::PARAM_INT); $sth->bindValue(':activities', $activities, PDO::PARAM_STR); $sth->execute(); $id = $pdo->LastInsertId(); $action = ACT_VIEW; break; case 'update': $eid = gpc_get_int($_POST, 'eid'); $activities = gpc_get_string($_POST, 'activities', 80); $remarks = gpc_get_string($_POST, 'remarks', 150); $sql = "UPDATE maintenance " . "SET activities=:activities," . " eid=:eid," . " remarks=:remarks " . "WHERE maintid=:maintid"; $sth = $pdo->prepare($sql); $sth->bindValue(':maintid', $id, PDO::PARAM_INT); $sth->bindValue(':eid', $eid, PDO::PARAM_INT); $sth->bindValue(':activities', $activities, PDO::PARAM_STR); $sth->bindValue(':remarks', $remarks, PDO::PARAM_STR); $sth->execute(); $action = ACT_VIEW; break; default: $g_error->Add(sprintf(_("Unknown function '%s'!"), $submit)); $valid = FALSE; } // ========== ACTIONS END ===================================================== require 'header.php'; // ========== PAGE CONTENT ==================================================== if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= echo '