From 8760de2115c322cf49906a2e24e8228f5d0763c5 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 14 Apr 2010 14:29:15 +0300 Subject: More fixes --- public/day.php | 38 +++++++++++++++++++++----------------- public/index.php | 8 +++++--- public/js/atwork.js | 10 +++++----- public/month.php | 21 ++++++++++++--------- system/atwork.db | Bin 0 -> 6144 bytes system/init.php | 11 +++++++++++ 6 files changed, 54 insertions(+), 34 deletions(-) create mode 100644 system/atwork.db 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()); - + ?>
@@ -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 @@ - + - + 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'); - @work + atwork v0.1 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; - + ?> @@ -40,17 +40,20 @@ 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; ?> -
+
h
diff --git a/system/atwork.db b/system/atwork.db new file mode 100644 index 0000000..e7f909a Binary files /dev/null and b/system/atwork.db differ diff --git a/system/init.php b/system/init.php index 193a05b..250ee16 100644 --- a/system/init.php +++ b/system/init.php @@ -14,5 +14,16 @@ $basedir = realpath(__FILE__ . '/../../'); $db = new PDO("sqlite:{$basedir}/system/atwork.db"); + + $day_types = array( + '--', + 'Töissä', + 'Etätöissä', + 'Sairaana', + 'Ylityövapaalla', + 'Koulutuksessa', + 'Vuosilomalla', + 'Isyys/äitiyslomalla' + ); ?> -- cgit v1.2.3