Skip to content

Commit

Permalink
Basic display and form inputs for recording hours
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Migurski committed Jun 8, 2011
1 parent 2676a97 commit 4d4a949
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 5 deletions.
19 changes: 19 additions & 0 deletions lib.php
Expand Up @@ -173,6 +173,25 @@ function recent_clients(&$dbh)
return $names;
}

function recent_people(&$dbh)
{
$people = array('ER', 'SA', 'MM', 'ASC', 'GS', 'JE', 'SC', 'RB', 'DM');
$time = time() - 6 * 7 * 86400;
$week = date('Y-', $time).'W'.date('W', $time);

$q = "SELECT DISTINCT person
FROM utilization
WHERE week >= '{$week}'";

$res = mysql_query($q, $dbh);

while($row = mysql_fetch_array($res, MYSQL_NUM))
if(!in_array($row[0], $people))
$people[] = $row[0];

return $people;
}

function nice_int($int)
{
$str = sprintf('%d', $int);
Expand Down
61 changes: 57 additions & 4 deletions record.php
Expand Up @@ -6,6 +6,14 @@
mysql_select_db('timetracking', $dbh);

$clients = recent_clients($dbh);
$people = recent_people($dbh);

// pad some
$people[] = '';
$people[] = '';
$people[] = '';

$rows = 20;

mysql_close($dbh);

Expand All @@ -15,22 +23,67 @@
<head>
<title>Record Week</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?3.3.0/build/widget/assets/skins/sam/widget.css&3.3.0/build/widget/assets/skins/sam/widget-stack.css&3.3.0/build/autocomplete/assets/skins/sam/autocomplete.css">
<script type="text/javascript" src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
<style type="text/css" title="text/css">
<!--
input { border: none; }

table tr td
{
border-top: 1px solid #ddd;
border-left: 1px solid #ddd;
}

table { border-collapse: collapse; }
table tr td:first-child { border-left: none; }

.yui3-aclist-list .yui3-aclist-item
{
color: #999;
background-color: white;
border-top: 0 #bbb none;
border-right: 1px #bbb solid;
border-bottom: 1px #bbb solid;
border-left: 1px #bbb solid;
}

.yui3-aclist-list .yui3-aclist-item:first-child,
.yui3-aclist-list .yui3-aclist-item-active { color: black; }

.yui3-aclist-list .yui3-aclist-item-active { background-color: yellow; }
-->
</style>
</head>
<body>
<h1></h1>

<table>
<tr>
<th> </th>
<? foreach($people as $person => $name) { ?>
<th><input type="text" size="3" tabindex="<?= 1 + ($person + 1) * ($rows + 1) ?>" value="<?= htmlspecialchars($name) ?>"></th>
<? } ?>
</tr>
<? for($row = 0; $row < $rows; $row++) { ?>
<tr>
<td><input type="text" size="20" tabindex="<?= 1 + $row ?>" class="client"></td>
<? foreach($people as $person => $name) { ?>
<td><input type="text" size="3" tabindex="<?= 2 + $row + ($person + 1) * ($rows + 1) ?>"></td>
<? } ?>
</tr>
<? } ?>
</table>

<p>
<input id="client-name" type="text" size="32">
<script type="text/javascript">
<!--

var clients = <?=json_encode($clients)?>;

YUI().use('autocomplete', 'autocomplete-filters', 'autocomplete-highlighters', function(Y)
{
Y.one('#client-name').plug(Y.Plugin.AutoComplete, {
Y.all('input.client').plug(Y.Plugin.AutoComplete, {
resultFilters: 'phraseMatch',
resultHighlighter: 'phraseMatch',
source: clients
Expand All @@ -39,6 +92,6 @@

//-->
</script>
</p>

</body>
</html>
2 changes: 1 addition & 1 deletion style.css
@@ -1,2 +1,2 @@
h1, h2 { font: 25px Georgia; }
h3, body { font: 18px Georgia; }
h3, body, input { font: 18px Georgia; }

0 comments on commit 4d4a949

Please sign in to comment.