Update module to new Hallinta system
authorJoey Schulze <joey@infodrom.org>
Thu, 12 Nov 2015 15:16:23 +0000 (16:16 +0100)
committerJoey Schulze <joey@infodrom.org>
Thu, 12 Nov 2015 15:16:23 +0000 (16:16 +0100)
abteilung.php
artikel.php
hp_folder_finished.png [new file with mode: 0644]
import.png [new file with mode: 0644]
ordersatz.php
ordersatz_history.php
ordersatz_pos.php
pdf_document.png [new file with mode: 0644]

index ee27287..1bcbb0e 100644 (file)
@@ -14,12 +14,12 @@ $mask = array(
                                            ),
                              'gang' => array(
                                            'name' => 'Gang',
-                                           'specs' => "filterUI: 't1'",
+                                           'filter' => 't1',
                                            'width' => 50,
                                            ),
                              'name' => array(
                                            'name' => 'Name',
-                                           'specs' => "filterUI: 't'",
+                                           'filter' => 't',
                                            'width' => 200,
                                            ),
                              ),
index 93360fc..a29a751 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 
-$styles->add("
+JavaScript::instance()->file('lib/rico3/minsrc/ricoLiveGridControls.js');
+
+Styles::instance()->add("
 div#form_price {
   padding-left: 10px;
   padding-right: 10px;
@@ -18,7 +20,7 @@ $form = '
 <label for="form_steuer">Steuersatz</label><br>
 <input id="form_steuer" name="steuer" size="10">
 <br>
-<label for="form_preis">Preis</label><br>
+<label for="form_preis">Nettopreis</label><br>
 <input id="form_preis" name="preis" size="10">
 <div class="buttons" style="margin-top: 15px;">
 <button class="custom" onclick="return add_price(this);">Hinzufügen</button>
@@ -52,7 +54,7 @@ function custom_save(obj)
  
     if (artnr.value == 0) return form_save(custom_this);
 
-    var parms = 'source=' + source.innerHTML + '&callback=artnr';
+    var parms = 'callback=artnr';
     parms += '&artnr=' + artnr.value;
     parms += '&artikel=' + id.value;
     ajax_request('function', parms, custom_save_callback);
@@ -78,7 +80,7 @@ function custom_insert(obj)
 
     if (artnr.value == 0) return form_insert(custom_this);
 
-    var parms = 'source=' + source.innerHTML + '&callback=artnr';
+    var parms = 'callback=artnr';
     parms += '&artnr=' + artnr.value;
     ajax_request('function', parms, custom_insert_callback);
 
@@ -92,31 +94,26 @@ function price_popup_open()
        var options = { hideOnClick: false, canDragFunc: true };
        var content = 'CONTENT_FORM';
 
-       price_popup = new Rico.Popup(options, false, false);
-       price_popup.createWindow('<strong>Verbinden</strong>',content,'auto','130px');
+       price_popup = new Rico.Window('Preis hinzufügen', options);
+       price_popup.contentDiv.innerHTML = content;
 
-       price_popup.openPopup(100,300);
+       price_popup.centerPopup();
     } else
        price_popup.openPopup();
 
-    price_popup.titleDiv.childNodes[0].innerHTML = 'Preis hinzufügen';
-
     var form_id = document.getElementById('edit_id');
     var artikel = document.getElementById('form_artikel');
     artikel.value = form_id.value;
 
-    var datum = document.getElementById('form_datum');
-    var preis = document.getElementById('form_preis');
-    if (datum.value.length)
-      preis.activate();
+    if ($('#form_datum').val().length)
+      $('#form_preis').select();
     else
-      datum.activate();
+      $('#form_datum').select();
 }
 
 function open_popup()
 {
-    var eid = document.getElementById('edit_id');
-    if (!eid || !eid.value.length) return false;
+  if (!$('#edit_id').val().length) return false;
 
     price_popup_open();
     return false;
@@ -125,13 +122,11 @@ function open_popup()
 function add_price_callback(data)
 {
     info('Preis gespeichert');
-    grid_update(grid);
+    grid_update(Hallinta.grid);
 }
 
 function add_price(obj)
 {
-    price_popup.closePopup();
-
     var datum = document.getElementById('form_datum');
     if (!datum.value.length) {
        error('Kein Rechnungsdatum angegeben');
@@ -150,12 +145,10 @@ function add_price(obj)
        return false;
     }
 
-    var source = document.getElementById('source');
-    if (!source) return false;
-
-    var parms = 'source=' + source.innerHTML + '&callback=price&';
-    ajax_request('function', parms+Form.serialize(obj.form), add_price_callback);
+    var parms = 'callback=price&' + $(obj.form).serialize();
+    ajax_request('function', parms, add_price_callback);
 
+    price_popup.closePopup();
     preis.value = '';
 
     return false;
@@ -164,9 +157,9 @@ EOC;
 
 $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);};");
+JavaScript::instance()->add($jscode);
+JavaScript::instance()->onLoad("\$('#button_save').click(function () {return custom_save(this);});");
+JavaScript::instance()->onLoad("\$('#button_insert').click(function () {return custom_insert(this);});");
 
 $buttons = <<<EOC
 <p style="margin-top: 5px; margin-bottom: 4px; text-align: center;">
@@ -188,23 +181,25 @@ $mask = array(
                                            'name' => 'ArtNr',
                                            'width' => 60,
                                            'type' => 'number',
-                                           'specs' => "decPlaces: 0, thouSep: '', filterUI: 't=3'",
+                                           'filter' => 't=3',
+                                           'specs' => array('decPlaces' => 0, 'thouSep' => ''),
                                            ),
                              'menge' => array(
                                            'name' => 'Menge',
                                            'width' => 60,
-                                           'specs' => "ClassName: 'alignrightpad', filterUI: 't3'",
+                                           'filter' => 't3',
+                                           'specs' => array('ClassName' => 'alignrightpad'),
                                            ),
                              'bezeichnung' => array(
                                            'name' => 'Bezeichnung',
                                            'width' => 300,
-                                           'specs' => "filterUI: 't'",
+                                           'filter' => 't',
                                            ),
                              'netto' => array(
                                            'name' => 'netto',
                                            'width' => 60,
                                            'type' => 'number',
-                                           'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                           'specs' => array('decPlaces' => 2, 'ClassName' => 'alignrightpad'),
                                            'sql' => '(SELECT preis FROM metro_artikel_preis ' .
                                                     'WHERE artikel = metro_artikel.id ORDER BY datum DESC LIMIT 1)',
                                            ),
@@ -212,7 +207,7 @@ $mask = array(
                                            'name' => 'Preis',
                                            'width' => 60,
                                            'type' => 'number',
-                                           'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                           'specs' => array('decPlaces' => 2, 'ClassName' => 'alignrightpad'),
                                            'sql' => '(SELECT preis * ((100 + steuersatz)/100) FROM metro_artikel_preis ' .
                                                     'WHERE artikel = metro_artikel.id ORDER BY datum DESC LIMIT 1)',
                                            ),
@@ -227,12 +222,12 @@ $mask = array(
                              'hersteller' => array(
                                            'name' => 'Hersteller',
                                            'width' => 100,
-                                           'specs' => "filterUI: 't4'",
+                                           'filter' => 't4',
                                            ),
                              'abteilung' => array(
                                            'name' => 'Abteilung',
                                            'width' => 200,
-                                           'specs' => "filterUI: 's'",
+                                           'filter' => '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,
@@ -240,13 +235,15 @@ $mask = array(
                              'gang' => array(
                                            'name' => 'Gang',
                                            'width' => 50,
-                                           'specs' => "ClassName: 'aligncenter', filterUI: 's'",
+                                           'filter' => 's',
+                                           'specs' => array('ClassName' => 'aligncenter'),
                                            'visible' => false,
                                            ),
                              'vpe' => array(
                                            'name' => 'Einheit',
                                            'width' => 70,
-                                           'specs' => "ClassName: 'aligncenter', filterUI: 's'",
+                                           'filter' => 's',
+                                           'specs' => array('ClassName' => 'aligncenter'),
                                            '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",
                                            ),
@@ -307,6 +304,7 @@ $mask = array(
                                            ),
                              ),
              'second' => array(
+                           'pricelist' => array(
                                'title' => 'Preisverlauf',
                                'rows' => 5,
                                'table' => 'metro_artikel_preis',
@@ -315,42 +313,43 @@ $mask = array(
                                'list' => array(
                                                'id' => array(
                                                              'name' => 'ID',
-                                                             'edit' => "Writeable:false, EntryType: 'H', Length: 4, isKey: true",
+                                                             'edit' => array('Writeable' => false, 'EntryType' => 'H', 'Length' => 4, 'isKey' => true),
                                                              'visible' => false,
                                                              ),
                                                'datum' => array(
                                                              'name' => 'Datum',
                                                              'width' => 180,
-                                                             'edit' => "EntryType: 'T', isNullable: false, Writeable: true",
+                                                             'edit' => array('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",
+                                                             'specs' => array('decPlaces' => 2, 'ClassName' => 'alignrightpad'),
+                                                             'edit' => array('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",
+                                                             'specs' => array('decPlaces' => 2, 'ClassName' => 'alignrightpad'),
+                                                             'edit' => array('EntryType' => 'T', 'isNullable' => false, 'Writeable' => true),
                                                              ),
                                                'brutto' => array(
                                                              'name' => 'Preis',
                                                              'width' => 60,
                                                              'type' => 'number',
-                                                             'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                                             'specs' => array('decPlaces' => 2, 'ClassName' => 'alignrightpad'),
                                                              'sql' => 'preis * ((100 + steuersatz)/100)',
                                                              ),
                                                'empty' => array(
                                                              'name' => '',
-                                                             'width' => 10,
+                                                             'width' => 20,
                                                              'sql' => "''",
                                                              ),
                                                ),
                                ),
+                           ),
              'callbacks' => array(
                                   'price' => cb_price,
                                   'artnr' => cb_artnr,
diff --git a/hp_folder_finished.png b/hp_folder_finished.png
new file mode 100644 (file)
index 0000000..dba9028
Binary files /dev/null and b/hp_folder_finished.png differ
diff --git a/import.png b/import.png
new file mode 100644 (file)
index 0000000..710385b
Binary files /dev/null and b/import.png differ
index b70b3f0..e099839 100644 (file)
@@ -31,12 +31,12 @@ $mask = array(
                              'name' => array(
                                            'name' => 'Name',
                                            'width' => 290,
-                                           'specs' => "filterUI: 't'",
+                                           'filter' => 't',
                                            ),
                              'koch' => array(
                                            'name' => 'Kochbetreuer',
                                            'width' => 100,
-                                           'specs' => "filterUI: 't'",
+                                           'filter' => 't',
                                            'visible' => false,
                                            ),
                              'datum' => array(
@@ -48,7 +48,7 @@ $mask = array(
                                            'name' => 'Aktion',
                                            'width' => 90,
                                            'control' => $href,
-                                           'specs' => "ClassName: 'aligncenter'",
+                                           'specs' => array('ClassName' => 'aligncenter'),
                                            'sql' => "'bearbeiten'",
                                            ),
                              ),
index 079be26..2f508b0 100644 (file)
@@ -31,12 +31,12 @@ $mask = array(
                              'name' => array(
                                            'name' => 'Name',
                                            'width' => 290,
-                                           'specs' => "filterUI: 't'",
+                                           'filter' => 't',
                                            ),
                              'koch' => array(
                                            'name' => 'Kochbetreuer',
                                            'width' => 100,
-                                           'specs' => "filterUI: 't'",
+                                           'filter' => 't',
                                            'visible' => false,
                                            ),
                              'done' => array(
@@ -52,7 +52,7 @@ $mask = array(
                                            'name' => 'Aktion',
                                            'width' => 90,
                                            'control' => $href,
-                                           'specs' => "ClassName: 'aligncenter'",
+                                           'specs' => array('ClassName' => 'aligncenter'),
                                            'sql' => "'anzeigen'",
                                            ),
                              ),
index 4820c6c..d5ce686 100644 (file)
@@ -20,9 +20,22 @@ if (substr($_SERVER["SCRIPT_FILENAME"],-10) == '/index.php' &&
 }
 
 if (!$done) {
+  Actions::instance()->addLink(new Link(array('id' => 'btn_finish',
+                                               'icon' => 'masks/metro/hp_folder_finished.png',
+                                               'title' => 'Ordersatz Abschließen und Versenden',
+                                               'function' => 'confirm_finish')));
+  Actions::instance()->addLink(new Link(array('id' => 'btn_pdf',
+                                               'icon' => 'masks/metro/pdf_document.png',
+                                               'title' => 'PDF Vorschau',
+                                               'function' => 'build_pdf')));
+  Actions::instance()->addLink(new Link(array('id' => 'btn_import',
+                                               'icon' => 'masks/metro/import.png',
+                                               'title' => 'Neue Artikel importieren',
+                                               'function' => 'import_articles')));
+
   $jscode = <<<EOC
-grid_column_edit[1] = {
-    default_menu: false,
+Hallinta.registerGridMenu('main', 1, {
+    defaultMenu: false,
     width: '9em',
     values: [
             ['löschen', '', 0],
@@ -38,21 +51,17 @@ grid_column_edit[1] = {
             ['12 mal bestellen', '12', 12],
             ['Wert eingeben', 'Bitte geben Sie die gewünschte Menge ein', 'prompt']
             ]
-};
+      });
 
 function build_pdf_callback(data)
 {
     info('PDF erstellt');
-    window.open('ajax/ajax.php?tmpdir='+data.tmpdir+'&source=metro__ordersatz_pos&func=file&name=download','_blank');
+    window.open('ajax/ajax.php?tmpdir='+data.tmpdir+'&source='+Hallinta.pageSource+'&func=file&name=download','_blank');
 }
 
 function build_pdf()
 {
-  var source = document.getElementById('source');
-  if (!source) return false;
-
-  var parms = 'source=' + source.innerHTML + '&callback=pdf';
-  ajax_request('function', parms, build_pdf_callback);
+  ajax_request('function', 'callback=pdf', build_pdf_callback);
   return false;
 }
 
@@ -66,13 +75,10 @@ function finish_callback(data)
   }
 }
 
-function finish()
+function confirm_finish()
 {
-  var source = document.getElementById('source');
-  if (!source) return false;
-
-  var parms = 'source=' + source.innerHTML + '&callback=send';
-  ajax_request('function', parms, finish_callback);
+  if (confirm("Bei Abschluß wird ein Fax zu Metro und eine Kopie per Mail an den Koch geschickt."))
+    ajax_request('function', 'callback=send', finish_callback);
   return false;
 }
 
@@ -82,7 +88,7 @@ function import_articles_callback(data)
     info('Ordersatz aktualisiert');
 
     if (data.count > 0)
-      grid_update(grid);
+      grid_update(Hallinta.grid);
 
     confirm(data.count + ' Artikel zum Ordersatz hinzugefügt.');
   }
@@ -90,29 +96,14 @@ function import_articles_callback(data)
 
 function import_articles()
 {
-  var source = document.getElementById('source');
-  if (!source) return false;
-
-  var parms = 'source=' + source.innerHTML + '&callback=import';
-  ajax_request('function', parms, import_articles_callback);
+  ajax_request('function', 'callback=import', import_articles_callback);
   return false;
 }
 
 EOC;
-  $javascript->add($jscode);
+  JavaScript::instance()->add($jscode);
 }
 
-$buttons = <<<EOC
-<p style="margin-top: 0px; margin-bottom: 4px; text-align: center;">
-<button class="custom" onclick="return import_articles()">Artikel importieren</button>
-&nbsp;
-<button class="custom" onclick="return build_pdf()">PDF erstellen</button>
-&nbsp;
-<button class="custom" onclick="return finish()">Abschließen</button>
-<br>Bei Abschluß wird ein Fax zu Metro und eine Kopie per Mail an den Koch geschickt.
-</p>
-EOC;
-
 function get_title($id)
 {
   global $db;
@@ -142,7 +133,7 @@ $mask = array(
                              'anzahl' => array(
                                            'name' => 'Anzahl',
                                            'width' => 60,
-                                           'specs' => "ClassName: 'alignrightpad'",
+                                           'specs' => array('ClassName' => 'alignrightpad'),
                                            ),
                              'artnr' => array(
                                            'name' => 'Artnr',
@@ -152,18 +143,19 @@ $mask = array(
                              'menge' => array(
                                            'name' => 'Menge',
                                            'width' => 60,
-                                           'specs' => "ClassName: 'alignrightpad', filterUI: 't2'",
+                                           'filter' => 't2',
+                                           'specs' => array('ClassName' => 'alignrightpad'),
                                            ),
                              'bezeichnung' => array(
                                            'name' => 'Bezeichnung',
                                            'width' => 300,
-                                           'specs' => "filterUI: 't'",
+                                           'filter' => 't',
                                            ),
                              'preis' => array(
                                            'name' => 'Preis',
                                            'width' => 60,
                                            'type' => 'number',
-                                           'specs' => "decPlaces: 2, ClassName: 'alignrightpad'",
+                                           'specs' => array('decPlaces' => 2, 'ClassName' => 'alignrightpad'),
                                            'sql' => '(SELECT preis * ((100 + steuersatz)/100) FROM metro_artikel_preis ' .
                                                     'WHERE artikel = metro_artikel.id ORDER BY datum DESC LIMIT 1)',
                                            ),
@@ -178,19 +170,21 @@ $mask = array(
                              'hersteller' => array(
                                            'name' => 'Hersteller',
                                            'width' => 80,
-                                           'specs' => "filterUI: 't4'",
+                                           'filter' => 't4',
                                            ),
                              'vpe' => array(
                                            'name' => 'Einheit',
                                            'width' => 70,
-                                           'specs' => "ClassName: 'aligncenter', filterUI: 's'",
+                                           'filter' => 's',
+                                           'specs' => array('ClassName' => 'aligncenter'),
                                            '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",
                                            ),
                              'abteilung' => array(
                                            'name' => 'Abteilung',
                                            'width' => 80,
-                                           'specs' => "ClassName: 'aligncenter', filterUI: 's'",
+                                           'filter' => 's',
+                                           'specs' => array('ClassName' => 'aligncenter'),
                                            '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,
@@ -199,19 +193,13 @@ $mask = array(
                                            'name' => 'Gang',
                                            'width' => 50,
                                            'sql' => 'abteilung',
-                                           'specs' => "ClassName: 'aligncenter', filterUI: 's'",
+                                           'filter' => 's',
+                                           'specs' => array('ClassName' => 'aligncenter'),
                                            'control' => "new Rico.TableColumn.lookup(".grid_lookup_sql('metro_abteilung','id','gang').", 0, '')",
                                            'distinct' => "SELECT DISTINCT abteilung,metro_abteilung.gang FROM metro_artikel JOIN metro_abteilung ON abteilung = metro_abteilung.id ORDER BY gang",
                                            'visible' => false,
                                            ),
                              ),
-             'edit' => array(
-                             'buttons' => array(
-                                           'type' => 'html',
-                                           'code' => $buttons,
-                                           'sql' => false,
-                                           ),
-                             ),
              'callbacks' => array(
                                   'cellsave' => cb_cellsave,
                                   'pdf' => cb_pdf,
diff --git a/pdf_document.png b/pdf_document.png
new file mode 100644 (file)
index 0000000..7cc7ff7
Binary files /dev/null and b/pdf_document.png differ