diff options
author | Filipp Lepalaan <filipp@mac.com> | 2010-04-14 14:29:15 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2010-04-14 14:29:15 +0300 |
commit | 8760de2115c322cf49906a2e24e8228f5d0763c5 (patch) | |
tree | c010b6a4360d85f07ba839623a3551e9dd4f8ca1 /public | |
parent | 63822bacd44d964df3596f928f44a56ab5625d4f (diff) | |
download | atwork-master.tar.gz atwork-master.tar.bz2 atwork-master.zip |
Diffstat (limited to 'public')
-rw-r--r-- | public/day.php | 38 | ||||
-rw-r--r-- | public/index.php | 8 | ||||
-rw-r--r-- | public/js/atwork.js | 10 | ||||
-rw-r--r-- | public/month.php | 21 |
4 files changed, 43 insertions, 34 deletions
diff --git a/public/day.php b/public/day.php index 9dd5377..137535e 100644 --- a/public/day.php +++ b/public/day.php @@ -5,17 +5,16 @@ require_once '../system/init.php'; - $tmp = explode('.', $_POST['d']); - $date = sprintf('%d-%02d-%02d', $tmp[2], $tmp[1], $tmp[0]); + $date = $_POST['d']; // Find this day $sql = "SELECT * FROM atwork WHERE user = ? - AND date(?) BETWEEN date(start) AND date(finish);"; + AND date(?) BETWEEN date(start) AND date(finish)"; $stmt = $db->prepare($sql); $stmt->execute(array($_SESSION['user'], $date)); - $day = $stmt->fetchAll(); + $day = $stmt->fetchAll(PDO::FETCH_ASSOC); $day = array_pad($day, 5, array()); - + ?> <form action="#" method="post" id="timeform"> @@ -33,6 +32,7 @@ foreach(range(0, 4) as $r): + // These are typically empty $start = @date_parse($day[$r]['start']); $finish = @date_parse($day[$r]['finish']); @@ -41,7 +41,7 @@ <tr> <td> <select name="start-h[<?= $r; ?>]" class="start_h"> - <option>--</option> + <option value="0000-00-00 00:00">--</option> <?php @@ -58,7 +58,7 @@ </select> : <select name="start-m[<?= $r; ?>]" class="start_m"> - <option>--</option> + <option value="0000-00-00 00:00">--</option> <?php @@ -77,7 +77,7 @@ </td> <td> <select name="finish-h[<?= $r; ?>]" class="finish_h"> - <option>--</option> + <option value="0000-00-00 00:00">--</option> <?php @@ -94,7 +94,7 @@ </select> : <select name="finish-m[<?= $r; ?>]" class="finish_m"> - <option>--</option> + <option value="0000-00-00 00:00">--</option> <?php @@ -117,14 +117,18 @@ <tr> <td colspan="2"> <select style="width:368px" name="type" id="type"> - <option>--</option> - <option value="1">Töissä</option> - <option value="2">Etätöissä</option> - <option value="3">Sairaana</option> - <option value="4">Ylityövapaalla</option> - <option value="5">Koulutuksessa</option> - <option value="6">Vuosilomalla</option> - <option value="7">Isyys/äitiyslomalla</option> + +<?php + + foreach ($day_types as $k => $v): + + $selected = ($k == $day[0]['type']) ? 'selected="selected"' : ''; + +?> + <option value="<?= $k; ?>" <?= $selected; ?>><?= $v; ?></option> + +<?php endforeach ?> + </select> </td> </tr> diff --git a/public/index.php b/public/index.php index 8ca60a6..f9c6160 100644 --- a/public/index.php +++ b/public/index.php @@ -9,9 +9,11 @@ { $format = '%d-%02d-%02d %02d:%02d'; $date = explode('.', $_POST['date']); - // First we check if we insert or update - $sql = 'INSERT INTO atwork (user, start, finish) VALUES (?, ?, ?)'; + // First we check if we insert or update + $sql = 'SELECT id FROM atwork WHERE '; + $sql = 'INSERT INTO atwork (user, start, finish, type, notes) + VALUES (?, ?, ?, ?, ?)'; $stmt = $db->prepare($sql); foreach($_POST['start-h'] as $k => $h_start) @@ -44,7 +46,7 @@ @import url('css/screen.css'); </style> - <title>@work</title> + <title>atwork v0.1</title> </head> diff --git a/public/js/atwork.js b/public/js/atwork.js index 145636a..dffcc3b 100644 --- a/public/js/atwork.js +++ b/public/js/atwork.js @@ -10,11 +10,11 @@ function lpad(str, pad, len) return str; } -function load_day(day) +function load_day(day, str) { $('#dialog').load('day.php', {d: day}, function() { - $('#dialog').dialog('option', 'title', day); + $('#dialog').dialog('option', 'title', str); $('#dialog').dialog('open'); }); } @@ -25,7 +25,7 @@ function load_month(month) $('#month').load('month.php', {m: month}, function() { $('.day').click(function() { - load_day($(this).attr('title')); + load_day($(this).attr('id'), $(this).attr('title')); }); }); } @@ -35,7 +35,7 @@ $(function() load_month(0); $('#dialog').dialog({ - autoOpen: false, + autoOpen:false, height:380, width:395, modal:false, @@ -47,7 +47,7 @@ $(function() }, 'Oletus': function() { // Sets default hours - $('#type').val('1'); + $('#type').val('0'); $('#lunch').attr('checked', 'checked'); $('.start_h:first').val('10'); $('.start_m:first').val('00'); diff --git a/public/month.php b/public/month.php index a3cd47e..07325aa 100644 --- a/public/month.php +++ b/public/month.php @@ -32,7 +32,7 @@ $first = mktime(0, 0, 0, $_SESSION['m'], 0); $last = mktime(0, 0, 0, $_SESSION['m']+1, 0); $days = ($last-$first)/3600/24; - + ?> <img src="images/cal_16.png" class="icon" alt=""/> @@ -40,17 +40,20 @@ <?php - foreach(range(1, $days) as $d): - - $current = $first+3600*24*$d; - $txt = date('D, d', $current); - $stmt->execute(array($_SESSION['user'], date('Y-m-d', $current))); - $tmp = current($stmt->fetchAll()); - $work = $tmp['done']/3600; + foreach(range(1, $days) as $d): + + $current = $first+3600*24*$d; + $txt = date('D, d', $current); + $stmt->execute(array($_SESSION['user'], date('Y-m-d', $current))); + $tmp = current($stmt->fetchAll()); + $work = $tmp['done']/3600; ?> - <div class="day" title="<?= date('d.m.Y', $current); ?>"> + <div + class="day" + id="<?= date('Y-m-d', $current); ?>" + title="<?= date('d.m.Y', $current); ?>"> <?= $txt; ?> <div class="hours"><?= $work; ?>h</div> </div> |