Example #1
0
 public function initCustomer()
 {
     global $SQL_ANY_STRING;
     $query = "SELECT * FROM " . self::$tableName . " WHERE ";
     $lname_string = "";
     $fname_string = "";
     if ($this->lname) {
         $lname_string = self::$lnameStr . ' = "' . $this->lname . '"';
     } else {
         $lname_string = self::$lnameStr . " {$SQL_ANY_STRING}";
     }
     if ($this->fname) {
         $fname_string = " AND " . self::$fnameStr . " = " . '"' . $this->fname . '"';
     } else {
         $fname_string = " AND " . self::$fnameStr . " {$SQL_ANY_STRING}";
     }
     $query = $query . $lname_string . $fname_string;
     // echo "<br/>debug: $query";
     $result = $this->db_conn->query($query);
     if ($result == true) {
         if ($result->num_rows > 1) {
             $result->free();
             // more than one customer with the same name
             // display them in a table
             showSearchPanel();
             showSummary($query);
             showVersionInfo();
         } else {
             if ($result->num_rows == 1) {
                 $result->data_seek(0);
                 $row = $result->fetch_assoc();
                 $custId = $row[self::$custIdStr];
                 $result->free();
                 // single customer found, show the details
                 header("Location: showdetails.php?custId=" . $custId);
             } else {
                 $this->addNewCustomer();
             }
         }
         // adding new user
     } else {
         exit("<h1>Unable to connect to the database!</h1>");
     }
 }
Example #2
0
require_once "htmlUtil.php";
require_once "tcCustomer.php";
require_once "tcVisits.php";
global $db_conn;
$custId = $_GET["custId"];
$customer = tcCustomer::getCustomerById($db_conn, $custId);
echo "{$customer->fname} {$customer->lname}";
?>
  </title>
  </head>

  <body>

      <?php 
// display the search panel on the top
showSearchPanel();
// display detailed information about the customer
$customer->showDetailTable();
print '<br/>';
print '<br/>';
// this section outputs the drop down menu to add points for the visit
print '<table align="center">';
print ' <tr>';
print '   <form method="post" action="addpoint.php" >';
print '     <td>';
print '       <select name="intSign">';
print '         <option value="plus">plus</option>';
print '         <option value="minus">minus</option>';
print '       </select>';
print '     </td>';
// output the point range (1 .. 100 )