Adjust to new framework
authorJoey Schulze <joey@infodrom.org>
Wed, 11 Feb 2015 14:01:46 +0000 (15:01 +0100)
committerJoey Schulze <joey@infodrom.org>
Wed, 11 Feb 2015 14:01:46 +0000 (15:01 +0100)
artikel.php
ordersatz_pos.php

index 78cc256..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;">
@@ -312,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',
index 8bb8cd1..a131d0f 100644 (file)
@@ -19,8 +19,8 @@ if (substr($_SERVER["SCRIPT_FILENAME"],-10) == '/index.php' &&
   $done = is_done($_GET['id']);
 }
 
-if (!$done)
-$jscode[] = <<<EOC
+if (!$done) {
+  $jscode = <<<EOC
 grid_column_edit[1] = {
     default_menu: false,
     width: '9em',
@@ -99,6 +99,8 @@ function import_articles()
 }
 
 EOC;
+  $javascript->add($jscode);
+}
 
 $buttons = <<<EOC
 <p style="margin-top: 0px; margin-bottom: 4px; text-align: center;">