Update filter select elements after selecting a new year
[misc/kostenrechnung] / masks / materialverbrauch.php
index c80d67f..e068a95 100644 (file)
@@ -2,9 +2,6 @@
 
 $jscode[] = <<<EOC
 
-Rico.moduleDependencies['checkboxDB'] = ['+LiveGrid', '../ricoTableColumnDB.js'];
-Rico.loadModule('checkboxDB');
-
 function einheit_callback(data)
 {
   var einheit = document.getElementById('edit_einheit');
@@ -22,6 +19,23 @@ function select_material(obj)
 
 EOC;
 
+function fetch_tbody()
+{
+  $sql = 'SELECT materialien.material,menge,einheiten.einheit FROM materialverbrauch '
+    . 'JOIN materialien ON materialverbrauch.material = materialien.id '
+    . 'JOIN einheiten ON materialien.einheit = einheiten.id '
+    . 'WHERE einsatz = ' . intval($_POST['id']);
+
+  $data = query_db($sql);
+
+  $ret = '';
+  foreach ($data as $row)
+    $ret .= sprintf('<tr><td>%s</td><td align="right">%.2f %s</td></tr>',
+                   $row['material'], $row['menge'], $row['einheit']);
+
+  return $ret;
+}
+
 $mask = array(
              'table' => 'einsatz',
              'title' => 'Materialverbrauch zu Arbeitsberichten',
@@ -51,6 +65,19 @@ $mask = array(
                                            ),
                              ),
              'rows' => 20,
+             'details' => array(
+                                'html' => '<table id="materialverbrauch_table" cellspacing="0" style="margin-top: -13px;" border="0" width="100%">'.
+                                '<thead>'.
+                                '<tr bgcolor="#ffd76d" style="color: #444;"><th>Material</th><th>Menge</th></tr>'.
+                                '</thead>'.
+                                '<tbody id="detail_materialverbrauch_tbody"></tbody>'.
+                                '</table>',
+                                'list' => array(
+                                                'materialverbrauch_tbody' => array(
+                                                                                   'fetch' => fetch_tbody,
+                                                                                   ),
+                                                ),
+                                ),
              'edit_title' => 'Materialverbrauch vermerken',
              'edit_table' => 'materialverbrauch',
              'edit' => array(
@@ -76,6 +103,10 @@ $mask = array(
                                            'required' => true,
                                            ),
                              ),
+             'buttons' => array(
+                                'save' => false,
+                                'delete' => false,
+                                ),
              'info' => array(
                              'einheit' => array(
                                            'sql' => 'SELECT einheiten.einheit FROM einheiten ' .