$output = '<h3 class="serendipity_date">breakfast</h3>
<p>For some time, I have been going out for weekly Sunday breakfast with a group of people that ranges somewhere between 5 and 10 in number. After awhile, we decided we needed some sort of rating system. Since I already sometimes <a href="http://she.geek.nz/archives/198-breakfast-with-mischief-bad-group.html">write</a> <a href="http://she.geek.nz/archives/228-aro-cafe.html">about</a> <a href="http://she.geek.nz/archives/240-highlights-of-the-weekend.html">breakfast</a> here already, I thought I would make it more official and write a s9y plugin for it.</p>
<p>So here it is:</p>
-<p>So far, you can check out the most recent breakfast only</p>';
+<p>(So far, you can check out the most recent breakfast only)</p>';
/*
<p><form action="?" method="post">Filter by: '.breakfast_cafe_dropdown($cafe).', '.breakfast_people_dropdown($person).', '.breakfast_meal_dropdown($meal).', '.breakfast_date_dropdown($date).'<input type="submit" value="Go!" /></form></p>
<p><a href="?">Or, just the most recent breakfast</a></p>';
}
$output .= '<td>Total</td></tr></tr>'.$tabledata.'</table>';
+$output .= '<p>Minimum: '.$latest['totals']['min'].'%, Maximum: '.$latest['totals']['max'].'%, Average: '
+.ceil($latest['totals']['scores']/$latest['totals']['num']).'%</p>';
$serendipity['smarty']->assign('content_message',$output);
?>
<select name="cafe">
<option value="0">-- Cafe --</option>';
$results = serendipity_db_query('SELECT * FROM mbg_cafe');
- foreach ($results as $r) {
- $s = '';
- if ($r['id'] == $selected) {
- $s = 'selected="selected"';
- }
- $output .='<option value="'.$r['id'].'" '.$s.'>'.$r['name'].'</option>';
- }
+ if (is_array($results)) {
+ foreach ($results as $r) {
+ $s = '';
+ if ($r['id'] == $selected) {
+ $s = 'selected="selected"';
+ }
+ $output .='<option value="'.$r['id'].'" '.$s.'>'.$r['name'].'</option>';
+ }
+ }
$output .= '</select>';
return $output;
}
$output = '
<select name="person'.$count.'">
<option value="0">-- Person --</option>';
- foreach ($people as $person) {
- $output .= '<option value="'.$person['id'].'">'.$person['name'].((!empty($person['alias'])) ? '('.$person['alias'].')' : '').'</option>';
- }
+ if (is_array($people)) {
+ foreach ($people as $person) {
+ $output .= '<option value="'.$person['id'].'">'.$person['name'].((!empty($person['alias'])) ? '('.$person['alias'].')' : '').'</option>';
+ }
+ }
$output .= '</select>';
return $output;
}
$output = '
<select name="person">
<option value="0">-- Person --</option>';
- foreach ($people as $person) {
- $s = '';
- if ($person['id'] == $selected) {
- $s = 'selected="selected"';
- }
- $output .= '<option value="'.$person['id'].'" '.$s.'>'.((!empty($person['alias'])) ? $person['alias'] : $person['name']).'</option>';
- }
+ if (is_array($people)) {
+ foreach ($people as $person) {
+ $s = '';
+ if ($person['id'] == $selected) {
+ $s = 'selected="selected"';
+ }
+ $output .= '<option value="'.$person['id'].'" '.$s.'>'.((!empty($person['alias'])) ? $person['alias'] : $person['name']).'</option>';
+ }
+ }
$output .= '</select>';
return $output;
}
$output = '
<select name="meal'.$count.'">
<option value="0">-- Meal --</option>';
- foreach ($menu as $item) {
- $output .= '<option value="'.$item['id'].'">'.$item['name'].'</option>';
- }
+ if (is_array($menu)) {
+ foreach ($menu as $item) {
+ $output .= '<option value="'.$item['id'].'">'.$item['name'].'</option>';
+ }
+ }
$output .= '</select>';
return $output;
}
$output = '
<select name="meal'.$count.'">
<option value="0">-- Meal --</option>';
- foreach ($menu as $item) {
- $s = '';
- if ($item['id'] == $selected) {
- $s = 'selected="selected"';
+ if (is_array($menu)) {
+ foreach ($menu as $item) {
+ $s = '';
+ if ($item['id'] == $selected) {
+ $s = 'selected="selected"';
+ }
+ $output .= '<option value="'.$item['id'].'" '.$s.'>'.$item['name'].'</option>';
}
- $output .= '<option value="'.$item['id'].'" '.$s.'>'.$item['name'].'</option>';
}
$output .= '</select>';
return $output;
$categories = serendipity_db_query('SELECT * FROM mbg_category');
}
$output = '';
- foreach ($categories as $i => $c) {
- $output .= $c['category'].' ('.$c['weight'].') : <input size="2" maxlength="2" type="text" name="score-'.$c['id'].'-'.$count.'" /> ';
- if ($i == 3) {
- $output .= '<br />';
+ if (is_array($categories)) {
+ foreach ($categories as $i => $c) {
+ $output .= $c['category'].' ('.$c['weight'].') : <input size="2" maxlength="2" type="text" name="score-'.$c['id'].'-'.$count.'" /> ';
+ if ($i == 3) {
+ $output .= '<br />';
+ }
}
}
return $output;
$output = '
<select name="date">
<option value="0">-- Date --</option>';
- foreach ($dates as $date) {
- $s = '';
- if ($date['date'] == $selected) {
- $s = 'selected="selected"';
+ if (is_array($dates)) {
+ foreach ($dates as $date) {
+ $s = '';
+ if ($date['date'] == $selected) {
+ $s = 'selected="selected"';
+ }
+ $output .= '<option value="'.$date['date'].'">'.date('j F Y',$date['date']).' ('.$date['name'].')</option>';
}
- $output .= '<option value="'.$date['date'].'">'.date('j F Y',$date['date']).' ('.$date['name'].')</option>';
}
$output .= '</select>';
return $output;
.' had \''.$attendee['meal'].'\':</b></td>
</tr>';
foreach ($attendee['scores'] as $category => $score) {
+ if (empty($score)) {
+ continue;
+ }
echo ' <tr>
- <td>'.$category.':</td><td>'.$score['score'].'/'.$score['weight'].'</td>
+ <td>'.$category.':</td><td align="right">'.$score['score'].'/'.$score['weight'].'</td>
</tr>';
}
echo ' <tr>
- <td>Total</td><td>'.$attendee['totals']['scores'].'%</td>
+ <td>Total</td><td align="right">'.$attendee['totals']['scores'].'%</td>
</tr>
<tr>
<td colspan="2"><b>The group gave:</td>
</tr>
<tr>
- <td>Min:</td><td>'.$latest['totals']['min'].'%</td>
+ <td>Min:</td><td align="right">'.$latest['totals']['min'].'%</td>
</tr>
<tr>
- <td>Max:</td><td>'.$latest['totals']['max'].'%</td>
+ <td>Max:</td><td align="right">'.$latest['totals']['max'].'%</td>
</tr>
<tr>
- <td>Avergage:</td><td>'.ceil($latest['totals']['scores']/$latest['totals']['num']).'%</td>
+ <td>Avergage:</td><td align="right">'.ceil($latest['totals']['scores']/$latest['totals']['num']).'%</td>
</tr>
<tr>
- <td nowrap="nowrap" colspan="2"><a href="/breakfast/">What the hell is this?</a></td>
+ <td nowrap="nowrap" colspan="2"><br /><br /><a href="/breakfast/">What the hell is this?</a></td>
</tr>
</table>';
return;
}
/* vim: set sts=4 ts=4 expandtab : */
+/**
+TODO!
+finish query builder page
+make sure there is no collision of saving same name of new breakfasts in admin page
+**/