Support PDF export of past orders as well
[misc/hallinta-metro] / ordersatz_pos.php
index 0c9cbdd..70a4c1f 100644 (file)
@@ -13,6 +13,7 @@
 include_once($_SESSION['sys']['basedir'].'masks/metro/utils.php');
 include_once($_SESSION['sys']['basedir'].'lib/mail.php');
 
 include_once($_SESSION['sys']['basedir'].'masks/metro/utils.php');
 include_once($_SESSION['sys']['basedir'].'lib/mail.php');
 
+$done = true;
 if (substr($_SERVER["SCRIPT_FILENAME"],-10) == '/index.php' &&
     !empty($_GET['id'])) {
   $_SESSION['ordersatz'] = $_GET['id'];
 if (substr($_SERVER["SCRIPT_FILENAME"],-10) == '/index.php' &&
     !empty($_GET['id'])) {
   $_SESSION['ordersatz'] = $_GET['id'];
@@ -24,16 +25,23 @@ if (!$done) {
                                                'icon' => 'masks/metro/import.png',
                                                'title' => 'Neue Artikel importieren',
                                                'function' => 'import_articles')));
                                                'icon' => 'masks/metro/import.png',
                                                'title' => 'Neue Artikel importieren',
                                                'function' => 'import_articles')));
-  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_pdf',
+                                           'icon' => 'masks/metro/pdf_document.png',
+                                           'title' => 'PDF Vorschau',
+                                           'function' => 'build_pdf')));
+
+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_finish',
                                                'icon' => 'masks/metro/hp_folder_finished.png',
                                                'title' => 'Ordersatz Abschließen und Versenden',
                                                'function' => 'confirm_finish')));
+}
 
 
-  $jscode = <<<EOC
+$jscode = '';
+if (!$done) {
+  $jscode .= <<<EOC
 Hallinta.registerGridMenu('main', 1, {
     defaultMenu: false,
     width: '9em',
 Hallinta.registerGridMenu('main', 1, {
     defaultMenu: false,
     width: '9em',
@@ -52,6 +60,10 @@ Hallinta.registerGridMenu('main', 1, {
             ['Wert eingeben', 'Bitte geben Sie die gewünschte Menge ein', 'prompt']
             ]
       });
             ['Wert eingeben', 'Bitte geben Sie die gewünschte Menge ein', 'prompt']
             ]
       });
+EOC;
+}
+
+$jscode .= <<<EOC
 
 function build_pdf_callback(data)
 {
 
 function build_pdf_callback(data)
 {
@@ -101,8 +113,8 @@ function import_articles()
 }
 
 EOC;
 }
 
 EOC;
-  JavaScript::instance()->add($jscode);
-}
+
+JavaScript::instance()->add($jscode);
 
 function get_title($id)
 {
 
 function get_title($id)
 {
@@ -136,8 +148,12 @@ $mask = array(
                                            'specs' => array('ClassName' => 'alignrightpad'),
                                            ),
                              'artnr' => array(
                                            'specs' => array('ClassName' => 'alignrightpad'),
                                            ),
                              'artnr' => array(
-                                           'name' => 'Artnr',
+                                           'name' => 'ArtNr',
+                                           'sqltype' => 'int',
                                            'width' => 60,
                                            'width' => 60,
+                                           'type' => 'number',
+                                           'filter' => 't=3',
+                                           'specs' => array('decPlaces' => 0, 'thouSep' => ''),
                                            'visible' => false,
                                            ),
                              'menge' => array(
                                            'visible' => false,
                                            ),
                              'menge' => array(
@@ -189,7 +205,6 @@ $mask = array(
                                            '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",
                                            '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,
                                            ),
                              'gang' => array(
                                            'name' => 'Gang',
                                            ),
                              'gang' => array(
                                            'name' => 'Gang',