Novy assistent pro jednorazove naskladneni, status "deleted" presunut na id 0
authorThomas Mudrunka <tomas@mudrunka.cz>
Mon, 22 Aug 2011 19:08:38 +0000 (21:08 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Mon, 22 Aug 2011 19:08:38 +0000 (21:08 +0200)
assistants/new-item.inc.php [deleted file]
assistants/store-single.inc.php [new file with mode: 0644]
index.php
install.sql

diff --git a/assistants/new-item.inc.php b/assistants/new-item.inc.php
deleted file mode 100644 (file)
index 01036ba..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-echo $step;
-echo $this->render_form_add('model');
-echo $this->render_form_add('item');
diff --git a/assistants/store-single.inc.php b/assistants/store-single.inc.php
new file mode 100644 (file)
index 0000000..04bf684
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+$script = $_SERVER['SCRIPT_NAME'].'/assistant/store-single';
+$this->process_http_request_post('new', false, false, 'assistant/store-single/2');
+switch($step) {
+       default: case 1:
+               echo $this->render_form_add('model');
+               break;
+       case 2:
+               $model_id = trim($_GET['last']);
+               $columns = $this->db->get_columns('item');
+    $selectbox = $this->db->columns_get_selectbox($columns, 'item');
+
+               $current = array(array(
+                       'model_id' => $model_id,
+                       'item_quantity' => 1,
+                       'status_id' => 1
+               ));
+
+               $action = $_SERVER['SCRIPT_NAME'].'/item/new';
+    echo $this->html->render_insert_form('item', $columns, $selectbox, $current, false, $action);
+               break;
+}
index 63633b022bcbb411401e5a2e02bc86e89d66af45..6036ac0535b603a39b69f0b2eb5f789f536f50b7 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -150,10 +150,10 @@ class Sklad_HTML extends HTML {
                        <menu>
                                <li><a href="$script/assistant/stats">stats</a></li>
                                <li><a href="$script/assistant/store">store</a></li>
+                               <li><a href="$script/assistant/store-single">store-single</a></li>
                                <li><a href="$script/assistant/dispose">dispose</a></li>
                                <li><a href="$script/assistant/sell">sell</a></li>
                                <li>&darr;&darr; BETA &darr;&darr;</li>
-                               <li><a href="$script/assistant/new-item">new-item</a></li>
                        </menu>
                </li>
                <li><a href="#">List</a>
@@ -309,7 +309,7 @@ EOF;
 EOF;
                }
 
-               $btn = is_array($current) ? 'UPDATE' : 'INSERT';
+               $btn = is_array($current) ? 'UPDATE' : 'INSERT'; //TODO: $current may be set even when inserting...
                $html.=$this->input(false, $btn, 'submit');
                $html.='</form>';
                return $html;
@@ -649,7 +649,7 @@ class Sklad_UI {
                return $out;
        }
 
-       function process_http_request_post($action=false, $class=false, $id=false) {
+       function process_http_request_post($action=false, $class=false, $id=false, $force_redirect=false) {
                if($_SERVER['REQUEST_METHOD'] != 'POST') return;
                //echo('<pre>'); //DEBUG (maybe todo remove), HEADERS ALREADY SENT!!!!
 
@@ -677,9 +677,10 @@ class Sklad_UI {
                                $table = $class ? $class : 'item';
                                //print_r($values); //debug
                                $last = $this->db->insert_or_update_multitab($values, $replace);
-                               $last = "$table/$last/";
+                               $last = $force_redirect ? $force_redirect."?last=$last" : "$table/$last/";
                                $next = "$table/new/";
-                               $this->post_redirect_get($last, 'Hotovo. Další záznam přidáte '.$this->html->link('zde', $next).'.');
+                               $message = $force_redirect ? '' : 'Hotovo. Další záznam přidáte '.$this->html->link('zde', $next).'.';
+                               $this->post_redirect_get($last, $message);
                                break;
                        case 'delete':
                                if(!isset($_POST['sure']) || !$_POST['sure']) $this->post_redirect_get("$class/$id/edit", 'Sure user expected :-)');
index 271f28f77433ae398b22ac5b04edad9e133ce8ed..d02c881585504acfd0e375351fcdca1f7bc41989 100644 (file)
@@ -72,7 +72,7 @@ CREATE TABLE `item` (
   CONSTRAINT `item_ibfk_7` FOREIGN KEY (`model_id`) REFERENCES `model` (`model_id`),
   CONSTRAINT `item_ibfk_8` FOREIGN KEY (`status_id`) REFERENCES `status` (`status_id`),
   CONSTRAINT `item_ibfk_9` FOREIGN KEY (`room_id`) REFERENCES `room` (`room_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
 SET character_set_client = @saved_cs_client;
 
 --
@@ -81,7 +81,7 @@ SET character_set_client = @saved_cs_client;
 
 LOCK TABLES `item` WRITE;
 /*!40000 ALTER TABLE `item` DISABLE KEYS */;
-INSERT INTO `item` VALUES (9,3,2,'SATAN',0,1,1,'0.10','0.00',NULL,NULL,0,'0000-00-00 00:00:00','2011-08-06 02:37:43'),(25,1,1,'sdaTEST3',3,1,3,'0.00','0.00',NULL,NULL,23,'0000-00-00 00:00:00','2011-08-06 03:07:37'),(26,2,1,'ABC123',900,1,3,'0.00','0.00',NULL,NULL,23,'0000-00-00 00:00:00','2011-08-08 03:57:55'),(27,2,1,'deleteme8',900,1,1,'0.00','0.00',NULL,NULL,23,'0000-00-00 00:00:00','2011-08-09 01:51:43'),(27,2,1,'deleteme',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:01:10','2011-08-09 00:01:10'),(27,2,1,'deleteme2',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:01:23','2011-08-09 00:01:23'),(27,2,1,'deleteme3',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:02:04','2011-08-09 00:02:04'),(27,2,1,'deleteme4',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:26:07','2011-08-09 00:02:04'),(27,2,1,'deleteme5',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:29:09','2011-08-09 00:26:07'),(27,2,1,'deleteme6',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:31:04','2011-08-09 00:29:09'),(27,2,1,'deleteme7',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:31:50','2011-08-09 00:31:04'),(27,2,1,'deleteme8',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 01:39:17','2011-08-09 00:31:50'),(27,3,1,'deleteme8',0,1,1,'0.00','0.00',NULL,NULL,23,'2011-08-09 01:51:13','2011-08-09 01:40:07'),(27,2,1,'deleteme8',0,1,1,'0.00','0.00',NULL,NULL,23,'2011-08-09 01:51:43','2011-08-09 01:51:13'),(31,2,1,'seriáál',1,1,1,'0.00','0.00',NULL,NULL,23,'0000-00-00 00:00:00','2011-08-09 02:36:26');
+INSERT INTO `item` VALUES (9,3,2,'SATAN',0,1,1,'0.10','0.00',NULL,NULL,0,'0000-00-00 00:00:00','2011-08-06 02:37:43'),(25,1,1,'sdaTEST3',3,1,3,'23.00','0.00',0,'',23,'0000-00-00 00:00:00','2011-08-20 00:13:26'),(25,1,1,'sdaTEST3',3,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-20 00:13:26','2011-08-06 03:07:37'),(26,2,1,'ABC123',900,1,3,'0.00','0.00',NULL,NULL,23,'0000-00-00 00:00:00','2011-08-08 03:57:55'),(27,2,1,'deleteme8',900,1,1,'0.00','0.00',NULL,NULL,23,'0000-00-00 00:00:00','2011-08-09 01:51:43'),(27,2,1,'deleteme',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:01:10','2011-08-09 00:01:10'),(27,2,1,'deleteme2',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:01:23','2011-08-09 00:01:23'),(27,2,1,'deleteme3',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:02:04','2011-08-09 00:02:04'),(27,2,1,'deleteme4',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:26:07','2011-08-09 00:02:04'),(27,2,1,'deleteme5',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:29:09','2011-08-09 00:26:07'),(27,2,1,'deleteme6',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:31:04','2011-08-09 00:29:09'),(27,2,1,'deleteme7',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 00:31:50','2011-08-09 00:31:04'),(27,2,1,'deleteme8',900,1,3,'0.00','0.00',NULL,NULL,23,'2011-08-09 01:39:17','2011-08-09 00:31:50'),(27,3,1,'deleteme8',0,1,1,'0.00','0.00',NULL,NULL,23,'2011-08-09 01:51:13','2011-08-09 01:40:07'),(27,2,1,'deleteme8',0,1,1,'0.00','0.00',NULL,NULL,23,'2011-08-09 01:51:43','2011-08-09 01:51:13'),(31,2,1,'seriáál',1,1,1,'0.00','0.00',NULL,NULL,23,'0000-00-00 00:00:00','2011-08-09 02:36:26');
 /*!40000 ALTER TABLE `item` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -106,7 +106,7 @@ CREATE TABLE `model` (
   KEY `producer_id` (`producer_id`),
   CONSTRAINT `model_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `category` (`category_id`),
   CONSTRAINT `model_ibfk_2` FOREIGN KEY (`producer_id`) REFERENCES `producer` (`producer_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
 SET character_set_client = @saved_cs_client;
 
 --
@@ -194,7 +194,7 @@ SET character_set_client = @saved_cs_client;
 
 LOCK TABLES `status` WRITE;
 /*!40000 ALTER TABLE `status` DISABLE KEYS */;
-INSERT INTO `status` VALUES (5,'DELETED'),(4,'destroyed'),(2,'placed'),(3,'saled'),(1,'stored');
+INSERT INTO `status` VALUES (0,'deleted'),(4,'destroyed'),(2,'placed'),(3,'saled'),(1,'stored');
 /*!40000 ALTER TABLE `status` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -256,4 +256,4 @@ UNLOCK TABLES;
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
--- Dump completed on 2011-08-19 22:31:33
+-- Dump completed on 2011-08-22 19:08:25
This page took 0.270056 seconds and 4 git commands to generate.