Adjust to new framework
[misc/hallinta-metro] / artikel.php
index 577eae3..d7bcc76 100644 (file)
@@ -1,13 +1,12 @@
 <?php
 
-$style[] = <<<EOC
+$styles->add("
 div#form_price {
   padding-left: 10px;
   padding-right: 10px;
   font-size: 90%;
   color: #555;
-}
-EOC;
+}");
 
 $form = '
 <div id="form_price">
@@ -28,7 +27,7 @@ $form = '
 </div>
 ';
 
-$javascript = <<<EOC
+$jscode = <<<EOC
 var custom_this = false;
 function custom_save_callback(data)
 {
@@ -50,6 +49,8 @@ function custom_save(obj)
        return custom_insert(obj);
 
     var artnr = document.getElementById('edit_artnr');
+    if (artnr.value == 0) return form_save(custom_this);
 
     var parms = 'source=' + source.innerHTML + '&callback=artnr';
     parms += '&artnr=' + artnr.value;
@@ -75,6 +76,8 @@ function custom_insert(obj)
     custom_this = obj;
     var artnr = document.getElementById('edit_artnr');
 
+    if (artnr.value == 0) return form_insert(custom_this);
+
     var parms = 'source=' + source.innerHTML + '&callback=artnr';
     parms += '&artnr=' + artnr.value;
     ajax_request('function', parms, custom_insert_callback);
@@ -157,18 +160,13 @@ function add_price(obj)
 
     return false;
 }
-
-Rico.onLoad(function(){
-    var btn = document.getElementById('button_save');
-    btn.onclick = function () {return custom_save(this);};
-    var btn = document.getElementById('button_insert');
-    btn.onclick = function () {return custom_insert(this);};
-});
 EOC;
 
-$jscode[] = str_replace('CONTENT_FORM', str_replace(array("\n"),
-                                                   array("\\\n"), $form), $javascript);
-
+$jscode = str_replace('CONTENT_FORM', str_replace(array("\n"),
+                                                 array("\\\n"), $form), $jscode);
+$javascript->add($jscode);
+$javascript->onLoad("\$('button_save').onclick = function () {return custom_save(this);};");
+$javascript->onLoad("\$('button_insert').onclick = function () {return custom_insert(this);};");
 
 $buttons = <<<EOC
 <p style="margin-top: 5px; margin-bottom: 4px; text-align: center;">
@@ -298,6 +296,10 @@ $mask = array(
                                            'size' => 21,
                                            'null' => true,
                                            ),
+                             'removed' => array(
+                                           'name' => 'Artikel nicht mehr im Programm',
+                                           'type' => 'boolean',
+                                           ),
                              'buttons' => array(
                                            'type' => 'html',
                                            'code' => $buttons,
@@ -308,27 +310,32 @@ $mask = array(
                                'title' => 'Preisverlauf',
                                'rows' => 5,
                                'table' => 'metro_artikel_preis',
+                               'table_edit' => 'metro_artikel_preis',
                                'where' => 'artikel = {id} ORDER BY datum DESC',
                                'list' => array(
                                                'id' => array(
                                                              'name' => 'ID',
+                                                             'edit' => "Writeable:false, EntryType: 'H', Length: 4, isKey: true",
                                                              'visible' => false,
                                                              ),
                                                'datum' => array(
                                                              'name' => 'Datum',
                                                              'width' => 180,
+                                                             'edit' => "EntryType: 'T', isNullable: false, Writeable: true",
                                                              ),
                                                'steuersatz' => array(
                                                              'name' => 'Steuer',
                                                              'width' => 60,
                                                              'type' => 'number',
                                                              'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                                             'edit' => "EntryType: 'T', isNullable: false, Writeable: true",
                                                              ),
                                                'preis' => array(
                                                              'name' => 'netto',
                                                              'width' => 60,
                                                              'type' => 'number',
                                                              'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                                             'edit' => "EntryType: 'T', isNullable: false, Writeable: true",
                                                              ),
                                                'brutto' => array(
                                                              'name' => 'Preis',