mirror of
https://github.com/jakejarvis/spoons.git
synced 2025-09-15 04:35:34 -04:00
2014 changes
This commit is contained in:
4
add.php
4
add.php
@@ -55,7 +55,7 @@ include('header.php');
|
||||
<tr>
|
||||
<th class="span1"> </th>
|
||||
<th class="span3"><strong>Last name</strong></th>
|
||||
<th class="span3"><strong>First name</strong></th>
|
||||
<th class="span3"><strong>First name (or nickname)</strong></th>
|
||||
<th class="span5"><strong>Staff?</strong> <small>(Last name optional if staff.)</small></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -71,7 +71,7 @@ include('header.php');
|
||||
<input type="text" name="last-<?php echo $i ?>" placeholder="Last name">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="first-<?php echo $i ?>" placeholder="First name">
|
||||
<input type="text" name="first-<?php echo $i ?>" placeholder="First name (or nickname)">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="staff-<?php echo $i ?>" value="1" tabindex="-1">
|
||||
|
@@ -14,6 +14,16 @@ function getNumActiveSpooners() {
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function getNumActiveCamperSpooners() {
|
||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 0");
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function getNumActiveStaffSpooners() {
|
||||
$result = mysql_query("SELECT id FROM spooners WHERE spooned = 0 AND staff = 1");
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function getLowestOrderNum() {
|
||||
$result = mysql_query("SELECT order_num FROM spooners WHERE spooned = 0 ORDER BY order_num ASC LIMIT 1");
|
||||
$spooner = mysql_fetch_array($result);
|
||||
@@ -90,7 +100,9 @@ function getIDByLooseName($subject) {
|
||||
$subject = trim($subject);
|
||||
$subject = strtolower($subject);
|
||||
$subject = str_replace(".", "", $subject); // remove periods
|
||||
if(substr_count($subject, " ") == 0) { // subject only contains one name
|
||||
|
||||
// subject only contains one word
|
||||
if(substr_count($subject, " ") == 0) {
|
||||
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $subject . '"');
|
||||
if(mysql_num_rows($result) == 1) {
|
||||
$spooner = mysql_fetch_array($result);
|
||||
@@ -99,8 +111,8 @@ function getIDByLooseName($subject) {
|
||||
return "multiple"; // more than one found
|
||||
}
|
||||
} else if(substr_count($subject, " ") == 1) { // one space, let's assume first space last
|
||||
$first = substr($subject, 0, strpos($subject, " "));
|
||||
$last = substr($subject, strpos($subject, " ") + 1);
|
||||
$first = substr($subject, 0, strpos($subject, " "));
|
||||
$last = substr($subject, strpos($subject, " ") + 1);
|
||||
if(strlen($last) == 1) { // last initial
|
||||
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(first) = "' . $first . '" AND LOWER(SUBSTRING(last, 1, 1)) = "' . $last . '"');
|
||||
if(mysql_num_rows($result) > 0) {
|
||||
@@ -114,6 +126,13 @@ function getIDByLooseName($subject) {
|
||||
return $spooner['id']; // MATCH!
|
||||
}
|
||||
}
|
||||
|
||||
// still not found, take whole subject and compare to concatenated first + last in database
|
||||
$result = mysql_query('SELECT id FROM spooners WHERE LOWER(CONCAT_WS(" ", first, last)) = "' . $subject . '"');
|
||||
if(mysql_num_rows($result) > 0) {
|
||||
$spooner = mysql_fetch_array($result);
|
||||
return $spooner['id'];
|
||||
}
|
||||
}
|
||||
|
||||
return "none";
|
||||
|
@@ -60,7 +60,7 @@ $html = '
|
||||
}
|
||||
div#container td {
|
||||
padding: 8px 25px;
|
||||
border: 3px dotted black;
|
||||
border: 3px solid black;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
@@ -37,7 +37,7 @@ if($subject && $subject_id == "multiple") {
|
||||
$response = getNameByID($subject_id) . ' has not been spooned. ' . getFirstNameByID($subject_id) . '\'s target is ' . getNameByID(getTargetByID($subject_id)) . ' and is targeted by ' . getNameByID(getReverseTargetByID($subject_id)) . '.';
|
||||
}
|
||||
} else if(strcasecmp($command, "remaining") == 0) {
|
||||
$response = "There are " . getNumActiveSpooners() . " of " . getNumTotalSpooners() . " spooners remaining.";
|
||||
$response = "There are " . getNumActiveSpooners() . " of " . getNumTotalSpooners() . " spooners remaining. (" . getNumActiveCamperSpooners() . " campers, " . getNumActiveStaffSpooners() . " staff)";
|
||||
} else if(strcasecmp($command, "commands") == 0 || strcasecmp($command, "command") == 0) {
|
||||
$response = $help;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user