Add view for old orders (readonly)
authorJoey Schulze <joey@infodrom.org>
Wed, 22 Jan 2014 10:19:04 +0000 (11:19 +0100)
committerJoey Schulze <joey@infodrom.org>
Wed, 22 Jan 2014 10:19:04 +0000 (11:19 +0100)
ordersatz_history.php [new file with mode: 0644]
ordersatz_pos.php
utils.php

diff --git a/ordersatz_history.php b/ordersatz_history.php
new file mode 100644 (file)
index 0000000..079be26
--- /dev/null
@@ -0,0 +1,122 @@
+<?php
+  /*
+   Küchenbetreuer:
+   E-Mail-Adresse für Kopie
+   Telefonnr für Rückfragen:
+   Abholung am:
+   Abholung um Uhrzeit:
+
+   - Ordersatz auswählen || neuen Ordersatz erstellen || Ordersatz kopieren
+   - Ordersatz abschließen = PDF-Datei erzeugen, archivieren, per Mail, per Fax
+   */
+
+
+$href = "new Rico.TableColumn.link('./?mask=metro__ordersatz_pos&id={0}')";
+
+# INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT ORDERID,id,'joey',now() FROM metro_artikel;
+# DELETE FROM metro_ordersatz_pos WHERE ordersatz = ORDERID AND anzahl IS NULL
+$mask = array(
+             'table' => 'metro_ordersatz',
+             'title' => 'Ordersatz auswählen / erstellen',
+             'where' => sprintf('owner = %d AND done IS NOT NULL', $_SESSION['sys']['uid']),
+             'list' => array(
+                             'id' => array(
+                                           'name' => 'ID',
+                                           'visible' => false,
+                                           ),
+                             'erstellt' => array(
+                                           'name' => 'Erstellt',
+                                           'width' => 85,
+                                           ),
+                             'name' => array(
+                                           'name' => 'Name',
+                                           'width' => 290,
+                                           'specs' => "filterUI: 't'",
+                                           ),
+                             'koch' => array(
+                                           'name' => 'Kochbetreuer',
+                                           'width' => 100,
+                                           'specs' => "filterUI: 't'",
+                                           'visible' => false,
+                                           ),
+                             'done' => array(
+                                           'name' => 'Abgeschlossen',
+                                           'width' => 90,
+                                           ),
+                             'datum' => array(
+                                           'name' => 'Einkauf am',
+                                           'width' => 130,
+                                           'sql' => "datum || ' ' || uhrzeit || ' Uhr'",
+                                           ),
+                             'link' => array(
+                                           'name' => 'Aktion',
+                                           'width' => 90,
+                                           'control' => $href,
+                                           'specs' => "ClassName: 'aligncenter'",
+                                           'sql' => "'anzeigen'",
+                                           ),
+                             ),
+             'edit' => array(
+                             'owner' => array(
+                                           'type' => 'hidden',
+                                           'default' => $_SESSION['sys']['uid'],
+                                           'required' => true,
+                                           ),
+                             'erstellt' => array(
+                                           'type' => 'hidden',
+                                           'subtype' => 'string',
+                                           'default' => date('Y-m-d'),
+                                           'required' => true,
+                                           ),
+                             'name' => array(
+                                           'name' => 'Name',
+                                           'type' => 'text',
+                                           'size' => 21,
+                                           'required' => true,
+                                           ),
+                             'koch' => array(
+                                           'name' => 'Kochbetreuer',
+                                           'type' => 'text',
+                                           'size' => 21,
+                                           'required' => true,
+                                           ),
+                             'email' => array(
+                                           'name' => 'E-Mail',
+                                           'type' => 'text',
+                                           'size' => 21,
+                                           'null' => true,
+                                           ),
+                             'telefon' => array(
+                                           'name' => 'Telefon für Rückfragen',
+                                           'type' => 'text',
+                                           'size' => 21,
+                                           'required' => true,
+                                           ),
+                             'datum' => array(
+                                           'name' => 'Abholdatum',
+                                           'type' => 'date',
+                                           'size' => 8,
+                                           'required' => true,
+                                           ),
+                             'uhrzeit' => array(
+                                           'name' => 'Ungefähre Uhrzeit der Abholung',
+                                           'type' => 'text',
+                                           'size' => 3,
+                                           'required' => true,
+                                           ),
+                             ),
+             'buttons' => array('delete' => false),
+             'postinsert' => ordersatz_insert,
+             );
+
+function ordersatz_insert($id)
+{
+  global $db;
+
+  $sql = sprintf("INSERT INTO metro_ordersatz_pos (ordersatz,artikel,sys_user,sys_edit) SELECT %d,id,%s,now() FROM metro_artikel",
+                $id, $db->quote($_SESSION['sys']['login']));
+
+  $sth = $db->query($sql);
+}
+
+?>
index b4743b7..942cae4 100644 (file)
@@ -14,9 +14,12 @@ include_once($_SESSION['sys']['basedir'].'masks/metro/utils.php');
 include_once($_SESSION['sys']['basedir'].'lib/mail.php');
 
 if (substr($_SERVER["SCRIPT_FILENAME"],-10) == '/index.php' &&
-    !empty($_GET['id']))
+    !empty($_GET['id'])) {
   $_SESSION['ordersatz'] = $_GET['id'];
+  $done = is_done($_GET['id']);
+}
 
+if (!$done)
 $jscode[] = <<<EOC
 grid_column_edit[1] = {
     default_menu: false,
@@ -127,7 +130,7 @@ $mask = array(
                              'metro_artikel ON artikel = metro_artikel.id'),
              'title' => get_title($_SESSION['ordersatz']),
              'edit_title' => 'Ordersatz',
-             'where' => sprintf('ordersatz = %d AND owner = %d AND done IS NULL', $_SESSION['ordersatz'], $_SESSION['sys']['uid']),
+             'where' => sprintf('ordersatz = %d AND owner = %d', $_SESSION['ordersatz'], $_SESSION['sys']['uid']),
              'list' => array(
                              'id' => array(
                                            'name' => 'ID',
@@ -224,6 +227,8 @@ $mask = array(
                                 ),
              );
 
+if ($done) unset($mask['edit']);
+
 function cb_cellsave()
 {
   global $db;
index 2afa57b..45b1c93 100644 (file)
--- a/utils.php
+++ b/utils.php
@@ -8,6 +8,16 @@ define('FAXNUMBER','2002-364');
 define('ERROR_SAFT','joey@finlandia');
 define('ERROR_MAIL','joey@finlandia.infodrom.org');
 
+function is_done($id)
+{
+  global $db;
+
+  $query = sprintf('SELECT count(*) AS count FROM metro_ordersatz WHERE id = %d AND done IS NULL', $id);
+  $sth = $db->query($query);
+  $row = $sth->fetch();
+  return $row['count'] == 0;
+}
+
 function mk_tempdir()
 {
   $tmpdir = sprintf("%sarchive/%s/%s",