$current[$item_id]['item_author'] = $this->db->auth->get_user_id();
$forked_item = $current;
- $model_id = $this->db->map_unique('item_serial', $item_serial, 'model_id', 'item');
+ $barcode_id = $this->db->map_unique('item_id', $item_id, 'barcode_id', 'item');
+ $model_id = $this->db->map_unique('barcode_id', $barcode_id, 'model_id', 'barcode');
$model_price_in = $this->db->map_unique('model_id', $model_id, 'model_price_in', 'model');
$model_price_out = $this->db->map_unique('model_id', $model_id, 'model_price_out', 'model');
<?php
$queries += array(
- "Nakoupit: Došlo úplně (Urgent WishList)"
+/*
+ "Nakoupit: Došlo úplně (Urgent WishList)" //TODO: Reinvent
=> 'SELECT model_id,model_name,model_barcode,model_reserve,model_reserve as item_quantity_to_buy'.
' FROM model'.
' WHERE model_reserve>0 AND NOT EXISTS'.
' (SELECT item_id FROM item WHERE model.model_id=item.model_id AND status_id=1 AND item_quantity>0 AND item_valid_till=0)',
+*/
"Nakoupit: Dochází (WishList)"
=> 'SELECT model_id,model_name,model_barcode,model_reserve,'.
' COUNT(item_id),SUM(item_quantity),model_reserve-SUM(item_quantity) as item_quantity_to_buy'.
- ' FROM item LEFT JOIN model USING(model_id)'.
+ ' FROM item LEFT JOIN barcode USING(barcode_id) LEFT JOIN model USING(model_id)'.
' WHERE item_valid_till=0 AND status_id=1'.
' GROUP BY model_id'.
' HAVING SUM(item_quantity)<model_reserve'.
<?php
$queries += array(
"Inventurni soupiska věcí se seriáky (Warehouse roster countable)"=>
- "select model_id, model_name, model_barcode, COUNT(item_serial), GROUP_CONCAT(item_serial separator ', ') from item LEFT JOIN model USING(model_id) WHERE item_valid_till=0 AND status_id=1 AND model_countable=1 GROUP BY model_id ORDER BY model_name",
+ "select model_id, model_name, barcode_name, COUNT(item_serial), GROUP_CONCAT(item_serial separator ', ') from item LEFT JOIN barcode USING(barcode_id) LEFT JOIN model USING(model_id) WHERE item_valid_till=0 AND status_id=1 AND model_countable=1 GROUP BY model_id ORDER BY model_name",
"Inventurni soupiska věcí na počet (Warehouse roster uncountable)"=>
- "select model_id, model_name, model_barcode, SUM(item_quantity) from item LEFT JOIN model USING(model_id) WHERE item_valid_till=0 AND status_id=1 AND model_countable=0 GROUP BY model_id ORDER BY model_name"
+ "select model_id, model_name, barcode_name, SUM(item_quantity) from item LEFT JOIN barcode USING(barcode_id) LEFT JOIN model USING(model_id) WHERE item_valid_till=0 AND status_id=1 AND model_countable=0 GROUP BY model_id ORDER BY model_name"
);
$queries += array(
"Ceník + Počet kusů skladem (PriceList + Stock)"
=> 'SELECT room_id,room_name,model_id,model_name,model_barcode,model_price_out,COUNT(item_id),SUM(item_quantity)'.
- ' FROM item LEFT JOIN model USING(model_id) LEFT JOIN room USING(room_id)'.
+ ' FROM item LEFT JOIN barcode USING(barcode_id) LEFT JOIN model USING(model_id) LEFT JOIN room USING(room_id)'.
' WHERE item_valid_till=0 AND status_id=1'.
' GROUP BY model_id,room_id'.
- ' ORDER BY room_id,model_id;',
+ ' ORDER BY room_id,model_id;'
);
echo $this->html->form("$URL/2", 'GET', array(
array('barcode',$barcode,'text',false,'autofocus','model_barcode:'),
array('quantity','1','text',false,false,'quantity:'),
- array('serials',$barcode,'textarea',false,'autofocus','serial(s):'),
+ array('serials','','textarea',false,'autofocus','serial(s):'),
array(false,'STORE','submit')
));
break;
case 2:
$barcode=$_GET['barcode'];
- $countable = $this->db->map_unique('model_barcode', $barcode, 'model_countable', 'model');
+
+ $barcode_id = $this->db->map_unique('barcode_name', $barcode, 'barcode_id', 'barcode');
+ $model_id = $this->db->map_unique('barcode_id', $barcode_id, 'model_id', 'barcode');
+ $model_price_in = $this->db->map_unique('model_id', $model_id, 'model_price_in', 'model');
+ $model_price_out = $this->db->map_unique('model_id', $model_id, 'model_price_out', 'model');
+ $item_price_in = $this->db->map_unique('item_serial', $barcode, 'item_price_in', 'item', false);
+ $item_price_out = $this->db->map_unique('item_serial', $barcode, 'item_price_out', 'item', false);
+
+ $countable = $this->db->map_unique('model_id', $model_id, 'model_countable', 'model');
$serials=explode("\n",trim($_GET['serials']));
if(!$countable || trim($_GET['serials']) == '') $serials = array('');
foreach($serials as $serial) {
$serial=trim($serial);
- $model_id = $this->db->map_unique('model_barcode', $barcode, 'model_id', 'model');
- $item_price_in = $this->db->map_unique('item_serial', $barcode, 'item_price_in', 'item', false);
- $item_price_out = $this->db->map_unique('item_serial', $barcode, 'item_price_out', 'item', false);
- $model_price_in = $this->db->map_unique('model_barcode', $barcode, 'model_price_in', 'model');
- $model_price_out = $this->db->map_unique('model_barcode', $barcode, 'model_price_out', 'model');
$disable_cols = array('status_id','item_price_out','item_customer', 'model_id','item_quantity','item_date_sold');
if($countable) {
//print_r(array('<pre>', $selectbox));
//foreach($selectbox['model_id'] as $id => $name) if($id != $model_id) unset($selectbox['model_id'][$id]);
$current = array(array(
- 'model_id' => $model_id,
+ 'barcode_id' => $barcode_id,
'item_serial' => $item_serial,
'item_quantity' => $item_quantity,
'status_id' => 1,
'barcode_name' => array(array('store','assistant/%d?barcode=%v')),
'model_name' => array(array('google','http://google.com/search?q=%v')) //TODO: add manufacturer to google query
),
+ 'barcode' => array(
+ 'model_id' => array(array('model',$where_url)),
+ 'barcode_id' => array(array('item',$where_url),array('edit','barcode/%v/edit/')),
+ 'barcode_name' => array(array('store','assistant/%d?barcode=%v')),
+ ),
'item' => array(
'item_serial' => array(array('dispose','assistant/%d?serial=%v','in_stock'),array('sell','assistant/%d?serial=%v','in_stock')),
'item_id' => array(array('edit','item/%v/edit/'))
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2012-07-24 15:03:20
+-- Dump completed on 2012-07-24 15:47:56
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
CONSTRAINT `item_ibfk_6` FOREIGN KEY (`vendor_id`) REFERENCES `vendor` (`vendor_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=45 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `model`;
/*!40101 SET @saved_cs_client = @@character_set_client */;