Switch to mpack
[misc/hallinta-metro] / artikel.php
index e987852..aa135b0 100644 (file)
@@ -22,7 +22,7 @@ $form = '
 <label for="form_preis">Preis</label><br>
 <input id="form_preis" name="preis" size="10">
 <div class="buttons" style="margin-top: 15px;">
-<button onclick="return add_price(this);">Hinzufügen</button>
+<button class="custom" onclick="return add_price(this);">Hinzufügen</button>
 </div>
 </form>
 </div>
@@ -38,7 +38,10 @@ function price_popup_open()
 
        price_popup = new Rico.Popup(options, false, false);
        price_popup.createWindow('<strong>Verbinden</strong>',content,'auto','130px');
-    }
+
+       price_popup.openPopup(100,300);
+    } else
+       price_popup.openPopup();
 
     price_popup.titleDiv.childNodes[0].innerHTML = 'Preis hinzufügen';
 
@@ -46,10 +49,12 @@ function price_popup_open()
     var artikel = document.getElementById('form_artikel');
     artikel.value = form_id.value;
 
-    price_popup.openPopup(100,300);
-
     var datum = document.getElementById('form_datum');
-    datum.activate();
+    var preis = document.getElementById('form_preis');
+    if (datum.value.length)
+      preis.activate();
+    else
+      datum.activate();
 }
 
 function open_popup()
@@ -108,7 +113,7 @@ $jscode[] = str_replace('CONTENT_FORM', str_replace(array("\n"),
 
 $buttons = <<<EOC
 <p style="margin-top: 5px; margin-bottom: 4px; text-align: center;">
-<button onclick="return open_popup()">Preis hinzufügen</button>
+<button class="custom" onclick="return open_popup()">Preis hinzufügen</button>
 </p>
 EOC;
 
@@ -125,11 +130,13 @@ $mask = array(
                              'artnr' => array(
                                            'name' => 'ArtNr',
                                            'width' => 60,
+                                           'type' => 'number',
+                                           'specs' => "decPlaces: 0, thouSep: '', filterUI: 't='",
                                            ),
                              'menge' => array(
                                            'name' => 'Menge',
                                            'width' => 60,
-                                           'specs' => "ClassName: 'alignrightpad'",
+                                           'specs' => "ClassName: 'alignrightpad', filterUI: 't3'",
                                            ),
                              'bezeichnung' => array(
                                            'name' => 'Bezeichnung',
@@ -152,6 +159,14 @@ $mask = array(
                                            'sql' => '(SELECT preis * ((100 + steuersatz)/100) FROM metro_artikel_preis ' .
                                                     'WHERE artikel = metro_artikel.id ORDER BY datum DESC LIMIT 1)',
                                            ),
+                             'datum' => array(
+                                           'name' => 'Datum',
+                                           'width' => 85,
+                                           'type' => 'text',
+                                           'sql' => '(SELECT datum FROM metro_artikel_preis ' .
+                                                    'WHERE artikel = metro_artikel.id ORDER BY datum DESC LIMIT 1)',
+                                           'visible' => false,
+                                           ),
                              'hersteller' => array(
                                            'name' => 'Hersteller',
                                            'width' => 100,
@@ -162,6 +177,7 @@ $mask = array(
                                            'width' => 200,
                                            'specs' => "filterUI: 's'",
                                            'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_abteilung','id','name').", 0, '')",
+                                           'distinct' => "SELECT DISTINCT abteilung,metro_abteilung.name FROM metro_artikel JOIN metro_abteilung ON abteilung = metro_abteilung.id ORDER BY name",
                                            'visible' => false,
                                            ),
                              'gang' => array(
@@ -175,6 +191,7 @@ $mask = array(
                                            'width' => 70,
                                            'specs' => "ClassName: 'aligncenter', filterUI: 's'",
                                            'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_vpe','id','name').", 0, '')",
+                                           'distinct' => "SELECT DISTINCT vpe,metro_vpe.name FROM metro_artikel JOIN metro_vpe ON vpe = metro_vpe.id ORDER BY name",
                                            ),
                              ),
              'edit' => array(
@@ -210,6 +227,12 @@ $mask = array(
                                            'size' => 21,
                                            'required' => true,
                                            ),
+                             'hinweis' => array(
+                                           'name' => 'Hinweis',
+                                           'type' => 'text',
+                                           'size' => 21,
+                                           'null' => true,
+                                           ),
                              'hersteller' => array(
                                            'name' => 'Hersteller',
                                            'type' => 'text',
@@ -222,6 +245,46 @@ $mask = array(
                                            'sql' => false,
                                            ),
                              ),
+             'second' => array(
+                               'title' => 'Preisverlauf',
+                               'rows' => 5,
+                               'table' => 'metro_artikel_preis',
+                               'where' => 'artikel = {id} ORDER BY datum DESC',
+                               'list' => array(
+                                               'id' => array(
+                                                             'name' => 'ID',
+                                                             'visible' => false,
+                                                             ),
+                                               'datum' => array(
+                                                             'name' => 'Datum',
+                                                             'width' => 180,
+                                                             ),
+                                               'steuersatz' => array(
+                                                             'name' => 'Steuer',
+                                                             'width' => 60,
+                                                             'type' => 'number',
+                                                             'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                                             ),
+                                               'preis' => array(
+                                                             'name' => 'netto',
+                                                             'width' => 60,
+                                                             'type' => 'number',
+                                                             'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                                             ),
+                                               'brutto' => array(
+                                                             'name' => 'Preis',
+                                                             'width' => 60,
+                                                             'type' => 'number',
+                                                             'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                                             'sql' => 'preis * ((100 + steuersatz)/100)',
+                                                             ),
+                                               'empty' => array(
+                                                             'name' => '',
+                                                             'width' => 10,
+                                                             'sql' => "''",
+                                                             ),
+                                               ),
+                               ),
              'callbacks' => array(
                                   'price' => cb_price,
                                ),