Beispiel #1
0
   echo "  <table class=\"formtable\">";
   foreach ($formfields as $fname => $field) {
       if (array_key_exists($fname, $user_data)) {
           $field->SetValue($user_data[$fname]);
       }
       if ($fname != 'first_name' && $fname != 'middle_name' && $fname != 'last_name') {
           $value = htmlspecialchars($field->GetReadableValue());
           echo "   <tr>\n";
           echo "    <td class=\"{$labelclass}\">" . $field->getLabelElement() . "</td>\n";
           echo "    <td class=\"formfield\">" . htmlspecialchars($value) . "</td>\n";
           echo "   </tr>\n";
       }
   }
   $barcode = $user->barcode;
   if ($barcode == NULL || strlen($barcode) == 0) {
       $barcode = make_userid_barcode($userid);
   }
   echo "   <tr><td>&nbsp;</td><td><a href=\"history.php?userid={$userid}\">Sign-in history</a></td></tr>\n";
   echo "   <tr><td>&nbsp;</td><td><a href=\"edit.php?userid={$userid}\">Edit</a></td></tr>\n";
   echo "   <tr><td>&nbsp;</td><td><a href=\"barcode.php?userid={$userid}\">ID Card</a></td></tr>\n";
   echo "   <tr><td>&nbsp;</td><td><a href=\"javascript:printBarcode();\">Print barcode label</a></td></tr>\n";
   echo "  </table>\n";
   print <<<END_SCRIPT
 <script>
  function printBarcode() {
      \$.get("barcode.php?print={$barcode}")
          .fail(function() {
              alert("Unable to print barcode");
          });
  }
 </script>
Beispiel #2
0
    function create($dbh)
    {
        $q_createuser = $dbh->prepare(<<<END_Q_CREATEUSER
INSERT INTO t_customers (create_date, modify_date, first_name, middle_name, last_name, address1, address2, city, state, phone_home, phone_work, phone_mobile,
    num_adults, num_children, is_single_parent, is_veteran, dietary_needs)
VALUES (now(), now(), :first_name, :middle_name, :last_name, :address1, :address2, :city, :state, :phone_home, :phone_work, :phone_mobile,
    :num_adults, :num_children, :is_single_parent, :is_veteran, :dietary_needs);
END_Q_CREATEUSER
);
        $fields = $this->to_array();
        unset($fields['userid']);
        unset($fields['barcode']);
        unset($fields['create_date']);
        unset($fields['modify_date']);
        unset($fields['language']);
        unset($fields['bread']);
        foreach ($fields as $k => $v) {
            print "\n\"{$k}\"=\"{$v}\" <br>\n";
        }
        $q_createuser->execute($fields);
        # Retrieve the new user ID
        $q_getid = $dbh->query("SELECT currval('t_customers_id_seq');");
        $row = $q_getid->fetch();
        $this->userid = $row[0];
        $q_setbarcode = $dbh->prepare("UPDATE t_customers SET barcode = :barcode WHERE id = :userid");
        $q_setbarcode->execute(array('userid' => $this->userid, 'barcode' => make_userid_barcode($this->userid)));
        return $this->userid;
    }