summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--system/init.php2
-rw-r--r--system/ma.dbbin4096 -> 0 bytes
6 files changed, 104 insertions, 42 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');
diff --git a/system/init.php b/system/init.php
index aa9672a..193a05b 100644
--- a/system/init.php
+++ b/system/init.php
@@ -13,6 +13,6 @@
$_SESSION['user'] = 'filipp';
$basedir = realpath(__FILE__ . '/../../');
- $db = new PDO("sqlite:{$basedir}/system/ma.db");
+ $db = new PDO("sqlite:{$basedir}/system/atwork.db");
?>
diff --git a/system/ma.db b/system/ma.db
deleted file mode 100644
index 4ae2dd2..0000000
--- a/system/ma.db
+++ /dev/null
Binary files differ