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 ++++++++++++--------- 4 files changed, 43 insertions(+), 34 deletions(-) (limited to 'public') 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
-- cgit v1.2.3