<?php require_once 'config.php'; require_once 'lib.php'; header('Content-Type: application/json; charset=UTF-8'); header('Cache-Control: no-cache'); $s_title = "{$s_organization} Sign-In"; try { $dbh = new PDO($db_conn, $db_user, $db_pass, array(PDO::ATTR_PERSISTENT => TRUE, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } catch (PDOException $e) { print "Error connecting to database: " . $e->getMessage(); die; } $userid = "-1"; if (array_key_exists('userid', $_GET)) { $userid = $_GET['userid']; $result = do_signin($dbh, $userid); print $result; } else { print json_encode(array("status" => "Error: userid not specified")); }
\$("signin_" + id).replaceWith(textStatus + " " + errorThrown); }); } </script> <table class="searchresults"> <tr><th id="col_name">Name</th><th></th></tr> END_DOC1; if ($search !== "") { # Auto-signin if ($auto && $barcode != "") { try { $sth = $dbh->prepare("SELECT id FROM t_customers WHERE barcode = :barcode"); $sth->execute(array(':barcode' => $barcode)); if ($row = $sth->fetch()) { $id = $row['id']; do_signin($dbh, $id); } } catch (PDOException $e) { print "Database error: " . htmlspecialchars($e->getMessage()); die; } } try { if ($barcode == "") { $barcode = "__INVALID__"; } $sth = $dbh->prepare("SELECT c.id,c.first_name,c.middle_name,c.last_name,date_trunc('day',MAX(s.signin_date))=date_trunc('day',now()) FROM t_customers AS c LEFT OUTER JOIN t_signins AS s ON c.id = s.customer WHERE (concat_ws(' ', c.first_name, c.middle_name, c.last_name) ILIKE :search OR c.barcode = :barcode) GROUP BY c.id LIMIT 100;"); $sth->execute(array(':search' => "%{$search}%", ':barcode' => $barcode)); $count = 0; while ($row = $sth->fetch()) { $id = $row[0];