return sprintf("<br>%d records updated.", $count);
}
- function load_customers()
- {
- global $dbh;
- $info = array();
-
- $sth = pg_exec ($dbh, 'SELECT short,name FROM stempel_customer');
- while ($row = pg_fetch_array ($sth))
- $info[$row['short']] = $row['name'];
-
- return $info;
- }
-
$stati = false;
function display_tables()
{
$table_head = '<h3 class="bar">Kunde: %s</h3><script type="text/javascript">plant(%d);</script>
<form action="status.php" method="POST">
<table class="smallfont border" width="100%%" cellpadding=0 cellspacing=0>
- <tr class="head">
+ <tr class="head" onclick="edit_task_finish(this)">
<th width=15%%>Datum</th>
<th width=5%%>Dauer</th>
<th width=5%%>St.</th>
- <th width=75%% align=left>Verwendungszweck</th>
+ <th width=75%% align=left>Arbeitsbeschreibung</th>
</tr>';
if (!is_array($stati))
'<input type="hidden" name="fields" value="%d">'.
'</form>';
- $table_row = '<tr class=t%d><td>%s</td><td align="center">%s</td><td align="center">%s</td><td>%s</td></tr>';
+ $table_row = '<tr class="t%d"><td>%s</td><td align="center">%s</td><td align="center">%s</td><td onclick="edit_task(this)">%s</td></tr>';
$table_sum = '<tr class="t%d"><td> </td><td align="center">%s</td><td> </td><td>Summe</td></tr>';
$query = "SELECT stempel.oid,start,customer,time,task,kurz FROM stempel JOIN stempel_status ON (stempel.status = stempel_status.id) WHERE time IS NOT NULL ";
$sum += $row['time'];
$d = explode(' ', $row['start']);
- $check = sprintf('<input type="checkbox" class="checkbox" name="oid_'.$fieldnr++.'" value="'.$row['oid'].'" onclick="add_sum(%d,this)">',$form);
- printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['kurz'], $row['task']);
+ $check = sprintf('<input type="checkbox" class="checkbox" name="oid_%d" value="%d" onclick="add_sum(%d,this)">',
+ $fieldnr++,
+ $row['oid'],
+ $form);
+ printf($table_row, $color, $check.$d[0], min2hour($row['time']), $row['kurz'], htmlspecialchars($row['task']));
$color = !$color;
}
if (pg_num_rows($sth) > 0) {
}
?>
+<script src="<root_prefix>basics.js"></script>
<script type="text/javascript">
+var color_checked = '#c4ffc3';
function format_int(value, width)
{
var s = value.toString();
function strtime(time)
{
var a = time.split(':');
- return parseInt(a[0]) * 60 + parseInt(a[1]);
+ return parseInt(a[0],10) * 60 + parseInt(a[1],10);
}
function check(id, value)
form.elements[i].checked = value;
if (value) {
var ta = form.elements[i].parentNode.nextSibling.innerHTML.split(':');
- newval = newval + parseInt(ta[0]) * 60 + parseInt(ta[1]);
- }
+ newval = newval + parseInt(ta[0],10) * 60 + parseInt(ta[1],10);
+ form.elements[i].parentNode.parentNode.style.backgroundColor = color_checked;
+ } else
+ form.elements[i].parentNode.parentNode.style.backgroundColor = '';
}
}
var time = strtime(checkbox.parentNode.nextSibling.innerHTML);
var newval;
- if (checkbox.checked)
+ if (checkbox.checked) {
newval = strtime(sum.innerHTML) + time;
- else
+ checkbox.parentNode.parentNode.style.backgroundColor = color_checked;
+ } else {
newval = strtime(sum.innerHTML) - time;
+ checkbox.parentNode.parentNode.style.backgroundColor = '';
+ }
sum.innerHTML = timestr(newval);
}
+
+var task_parent = null;
+var task_title = '';
+var task_oid = 0;
+function edit_task(obj)
+{
+ if (task_oid) {
+ if (task_oid != obj.parentNode.children[0].children[0].value)
+ edit_task_save();
+ }
+
+ if (!task_oid) {
+ task_parent = obj;
+ task_title = obj.innerHTML;
+ task_oid = obj.parentNode.children[0].children[0].value;
+
+ var input = document.createElement('input');
+ input.value = obj.innerHTML
+ input.style.fontSize = '100%';
+ input.style.width = '100%';
+ input.style.background = 'yellow';
+
+ obj.innerHTML = '';
+ obj.appendChild(input);
+ input.focus();
+ }
+}
+
+function edit_task_save()
+{
+ if (!task_parent) return;
+
+ if (task_parent.children[0].value != task_title)
+ ajax_request('save','oid='+task_oid+'&task='+encodeURIComponent(task_parent.children[0].value));
+
+ task_parent.innerHTML = task_parent.children[0].value;
+ task_parent = null;
+ task_title = '';
+ task_oid = 0;
+}
+
+function edit_task_finish(obj)
+{
+ if (task_oid)
+ edit_task_save();
+}
+
</script>
<style type="text/css">
</page>
# Local variables:
-# mode: text
-# mode: auto-fill
+# mode: php
# end: