summaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2010-04-13 13:33:26 +0300
committerFilipp Lepalaan <filipp@mac.com>2010-04-13 13:33:26 +0300
commit63822bacd44d964df3596f928f44a56ab5625d4f (patch)
tree2629dfc3af9e1b67fbc0b7efa8cf4913ab4b40a6 /public
parent6f2e6899cc404f314648782920e343c8529885d3 (diff)
downloadatwork-63822bacd44d964df3596f928f44a56ab5625d4f.tar.gz
atwork-63822bacd44d964df3596f928f44a56ab5625d4f.tar.bz2
atwork-63822bacd44d964df3596f928f44a56ab5625d4f.zip
Better everything
Diffstat (limited to 'public')
-rw-r--r--public/css/screen.css7
-rw-r--r--public/day.php121
-rw-r--r--public/index.php3
-rw-r--r--public/js/atwork.js13
4 files changed, 103 insertions, 41 deletions
diff --git a/public/css/screen.css b/public/css/screen.css
index 38fef4b..3240d3b 100644
--- a/public/css/screen.css
+++ b/public/css/screen.css
@@ -1,4 +1,5 @@
/**
+ * atwork/css/screen.css
*
*/
body {
@@ -21,7 +22,6 @@ body {
.day {
width:110px;
height:110px;
- background-color:#cacaca;
float:left;
margin:2px;
padding:5px;
@@ -30,6 +30,7 @@ body {
-webkit-border-radius:5px;
color:#000;
font-weight:bold;
+ background-color:#cdcdcd;
}
.day:hover {
cursor:pointer;
@@ -72,8 +73,8 @@ h2 {
color:#999;
}
textarea {
- width:360px;
+ width:358px;
resize:none;
padding:3px;
height:80px;
-} \ No newline at end of file
+}
diff --git a/public/day.php b/public/day.php
index 1c21f1b..9dd5377 100644
--- a/public/day.php
+++ b/public/day.php
@@ -5,14 +5,21 @@
require_once '../system/init.php';
- $sql = 'SELECT * FROM atwork WHERE user = ? AND start <= ? AND finish >= ?';
+ $tmp = explode('.', $_POST['d']);
+ $date = sprintf('%d-%02d-%02d', $tmp[2], $tmp[1], $tmp[0]);
+
+ // Find this day
+ $sql = "SELECT * FROM atwork WHERE user = ?
+ AND date(?) BETWEEN date(start) AND date(finish);";
$stmt = $db->prepare($sql);
- $stmt->execute(array($_SESSION['user'], $_POST['d'], $_POST['d']));
-// print_r($stmt->fetchAll());
+ $stmt->execute(array($_SESSION['user'], $date));
+ $day = $stmt->fetchAll();
+ $day = array_pad($day, 5, array());
?>
+
<form action="#" method="post" id="timeform">
- <input type="hidden" id="date" name="date" value="<?= $_POST['d']; ?>"/>
+ <input id="date" name="date" type="hidden" value="<?= $_POST['d']; ?>"/>
<table>
<thead>
<tr>
@@ -22,50 +29,83 @@
</thead>
<tbody>
-<?php foreach(range(0, 4) as $r): ?>
+<?php
+
+ foreach(range(0, 4) as $r):
+
+ $start = @date_parse($day[$r]['start']);
+ $finish = @date_parse($day[$r]['finish']);
+
+?>
-<tr>
- <td>
- <select name="start-h[<?= $r; ?>]" class="start_h">
- <option>--</option>
+ <tr>
+ <td>
+ <select name="start-h[<?= $r; ?>]" class="start_h">
+ <option>--</option>
-<?php foreach(range(8, 23) as $h): ?>
+<?php
+
+ foreach(range(8, 23) as $h):
+
+ $selected = ($h == $start['hour']) ? 'selected="selected"' : '';
+
+?>
- <option><?= sprintf('%02d', $h); ?></option>
+ <option <?= $selected; ?>><?= sprintf('%02d', $h); ?></option>
<?php endforeach ?>
- </select>
- :
- <select name="start-m[<?= $r; ?>]" class="start_m">
- <option>--</option>
+ </select>
+ :
+ <select name="start-m[<?= $r; ?>]" class="start_m">
+ <option>--</option>
-<?php foreach(range(0, 3) as $m): ?>
+<?php
+
+ foreach(range(0, 3) as $m):
+
+ $min = sprintf('%02d', $m*15);
+ $selected = ($min == $start['minute']) ? 'selected="selected"' : '';
+
+?>
- <option><?= sprintf('%02d', $m*15); ?></option>
+ <option <?= $selected; ?>><?= $min; ?></option>
<?php endforeach ?>
- </select>
- </td>
- <td>
- <select name="finish-h[<?= $r; ?>]" class="finish_h">
- <option>--</option>
+ </select>
+ </td>
+ <td>
+ <select name="finish-h[<?= $r; ?>]" class="finish_h">
+ <option>--</option>
-<?php foreach(range(8, 23) as $h): ?>
-
- <option><?= sprintf('%02d', $h); ?></option>
+<?php
+
+ foreach(range(8, 23) as $h):
+
+ $selected = ($h == $finish['hour']) ? 'selected="selected"' : '';
+
+?>
+ <option <?= $selected; ?>><?= sprintf('%02d', $h); ?></option>
+
<?php endforeach ?>
-
+
</select>
:
<select name="finish-m[<?= $r; ?>]" class="finish_m">
<option>--</option>
-<?php foreach(range(0, 3) as $m): ?>
+<?php
- <option><?= sprintf('%02d', $m*15); ?></option>
+ foreach(range(0, 3) as $m):
+
+ $min = sprintf('%02d', $m*15);
+ $selected = ($min == $finish['minute']) ? 'selected="selected"' : '';
+
+?>
+
+ <option <?= $selected; ?>><?= $min; ?></option>
<?php endforeach ?>
@@ -75,11 +115,28 @@
<?php endforeach ?>
<tr>
- <td colspan="2"><strong>Merkinnät</strong>
- <br/>
- <textarea name="notes" rows="8" cols="40"></textarea></td>
+ <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>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">Merkinnät<br/>
+ <textarea name="notes" rows="2" cols="40"></textarea></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="checkbox" id="lunch" name="lunch" value="1"/> Lounastauko
+ </td>
</tr>
-
</tbody>
</table>
</form> \ No newline at end of file
diff --git a/public/index.php b/public/index.php
index 2886540..8ca60a6 100644
--- a/public/index.php
+++ b/public/index.php
@@ -2,12 +2,15 @@
////
// atwork/index.php
+
require_once '../system/init.php';
if (!empty($_POST['date']))
{
$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 (?, ?, ?)';
$stmt = $db->prepare($sql);
diff --git a/public/js/atwork.js b/public/js/atwork.js
index f4a306b..145636a 100644
--- a/public/js/atwork.js
+++ b/public/js/atwork.js
@@ -1,6 +1,5 @@
-/**
- * atwork/js/atwork.js
- */
+////
+// atwork/js/atwork.js
function lpad(str, pad, len)
{
@@ -37,9 +36,9 @@ $(function()
$('#dialog').dialog({
autoOpen: false,
- height:340,
- width:400,
- modal:true,
+ height:380,
+ width:395,
+ modal:false,
draggable:false,
resizable:false,
buttons: {
@@ -48,6 +47,8 @@ $(function()
},
'Oletus': function() {
// Sets default hours
+ $('#type').val('1');
+ $('#lunch').attr('checked', 'checked');
$('.start_h:first').val('10');
$('.start_m:first').val('00');
$('.finish_h:first').val('18');