Fill detail box with Einsatz details
authorJoey Schulze <joey@infodrom.org>
Thu, 4 Mar 2010 23:09:14 +0000 (00:09 +0100)
committerJoey Schulze <joey@infodrom.org>
Thu, 4 Mar 2010 23:09:14 +0000 (00:09 +0100)
masks/materialverbrauch.php

index c80d67f..fda62df 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"><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(