From bda4a4becc889f5acd8d6a4736cad0e57d0f3bfc Mon Sep 17 00:00:00 2001 From: Thomas Mudrunka Date: Mon, 22 Aug 2011 21:08:38 +0200 Subject: [PATCH] Novy assistent pro jednorazove naskladneni, status "deleted" presunut na id 0 --- assistants/new-item.inc.php | 4 ---- assistants/store-single.inc.php | 22 ++++++++++++++++++++++ index.php | 11 ++++++----- install.sql | 10 +++++----- 4 files changed, 33 insertions(+), 14 deletions(-) delete mode 100644 assistants/new-item.inc.php create mode 100644 assistants/store-single.inc.php diff --git a/assistants/new-item.inc.php b/assistants/new-item.inc.php deleted file mode 100644 index 01036ba..0000000 --- a/assistants/new-item.inc.php +++ /dev/null @@ -1,4 +0,0 @@ -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 index 0000000..04bf684 --- /dev/null +++ b/assistants/store-single.inc.php @@ -0,0 +1,22 @@ +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; +} diff --git a/index.php b/index.php index 63633b0..6036ac0 100755 --- a/index.php +++ b/index.php @@ -150,10 +150,10 @@ class Sklad_HTML extends HTML {
  • stats
  • store
  • +
  • store-single
  • dispose
  • sell
  • ↓↓ BETA ↓↓
  • -
  • new-item
  • List @@ -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.=''; 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('
    '); //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 :-)');
    diff --git a/install.sql b/install.sql
    index 271f28f..d02c881 100644
    --- a/install.sql
    +++ b/install.sql
    @@ -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
    -- 
    2.30.2