}
function render_barcode($barcode,$opts=false) {
- return $this->img_link($this->internal_url("barcode/$barcode"),$this->internal_url("barcode/$barcode"),$barcode,false,false,$opts);
+ return $this->img_link($this->internal_url("barcodeimg/$barcode"),$this->internal_url("barcodeimg/$barcode"),$barcode,false,false,$opts);
}
function table_add_barcodes(&$table) {
- $image = array('model_barcode', 'item_serial');
+ $image = array('barcode_name', 'model_barcode', 'item_serial');
foreach($table as $id => $row) {
foreach($image as $column) if(isset($table[$id][$column])) {
$table[$id][$column]=$this->render_barcode($table[$id][$column]);
'model' => array(
'model_id' => array(array('item',$where_url),array('edit','model/%v/edit/')),
'model_barcode' => array(array('store','assistant/%d?barcode=%v')),
+ '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
),
'item' => array(
function table_hide_columns(&$table, $class) { //TODO: Move to build_query_select() !!! :-)))
$fields_hide = array(
- 'item' => array('model_descript','model_price_in','model_price_out','model_barcode','model_countable','model_reserve','model_eshop_hide','room_descript','room_author','producer_name','producer_note','vendor_note','location_author','location_gps','location_description')
+ 'item' => array('model_descript','model_price_in','model_price_out','barcode_name','model_barcode','model_countable','model_reserve','model_eshop_hide','room_descript','room_author','producer_name','producer_note','vendor_note','location_author','location_gps','location_description')
);
//print_r($table); die();
if(isset($fields_hide[$class])) foreach($table as $id => $row) {
function build_query_select($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $order=false, $suffix_id='_id') {
//Configuration
$join = array(
- 'item' => array('model', 'category', 'producer', 'vendor', 'room', 'location', 'status'),
+ 'barcode' => array('model', 'category', 'producer'),
+ 'item' => array('barcode', 'model', 'category', 'producer', 'vendor', 'room', 'location', 'status'),
'model' => array('category', 'producer')
); //TODO Autodetect using foreign keys?
$fields_search = array(
- 'item' => array('item_id','item_serial','model_name','model_barcode','model_descript','producer_name','vendor_name'),
- 'model' => array('model_id','model_name','model_barcode','model_descript','producer_name')
+ 'item' => array('item_id','item_serial','model_name','barcode_name','model_barcode','model_descript','producer_name','vendor_name'),
+ 'model' => array('model_id','model_name','barcode_name','model_barcode','model_descript','producer_name')
); //TODO Autodetect
//Init
//ORDER
if(!$order) $order = $class.$suffix_id.' DESC';
if($this->contains_history($class)) $order .= ",${class}_valid_from DESC";
- $sql .= "ORDER BY $order\n";
+ //$sql .= "ORDER BY $order\n"; //TODO: fixnout az budou opraveny vicenasobny carovy kody
//LIMIT/OFFSET
if($limit) {
$limit = $this->escape((int)$limit);
function check_input_validity($field, $value='', $ruleset=0) {
$rules = array(0 => array(
'model_barcode' => '/./',
+ 'barcode_name' => '/./',
'item_serial' => '/./',
'vendor_id' => '/^[0-9]*$/'
));
$PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
//Sephirot:
if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]='';
- if($_SERVER['REQUEST_METHOD'] != 'POST' && $PATH_CHUNKS[1]!='barcode' && $PATH_CHUNKS[1]!='api') //TODO: tyhle podminky naznacujou, ze je v navrhu nejaka drobna nedomyslenost...
+ if($_SERVER['REQUEST_METHOD'] != 'POST' && $PATH_CHUNKS[1]!='barcodeimg' && $PATH_CHUNKS[1]!='api') //TODO: tyhle podminky naznacujou, ze je v navrhu nejaka drobna nedomyslenost...
echo $this->html->header($PATH_INFO,$this->db->auth->get_user());
switch($PATH_CHUNKS[1]) { //TODO: Move some branches to plugins if possible
case 'test': //test
$assistant_vars['ASSISTANT'] = $PATH_CHUNKS[2];
echo $this->safe_include($incdirs[$PATH_CHUNKS[1]],$PATH_CHUNKS[2],$assistant_vars);
break;
- case 'barcode': //barcode
+ case 'barcodeimg': //barcode
Barcode::download_barcode(implode('/',array_slice($PATH_CHUNKS, 2)));
break;
default: //?
--- MySQL dump 10.13 Distrib 5.1.49, for debian-linux-gnu (x86_64)
+-- MySQL dump 10.13 Distrib 5.1.61, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: sklad
-- ------------------------------------------------------
--- Server version 5.1.49-3
+-- Server version 5.1.61-0+squeeze1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
PRIMARY KEY (`location_id`),
UNIQUE KEY `location_name` (`location_name`),
KEY `location_author` (`location_author`)
-) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
LOCK TABLES `location` WRITE;
/*!40000 ALTER TABLE `location` DISABLE KEYS */;
-INSERT INTO `location` VALUES (0,'UNIVERSE',14,'Tady je všechno co nikde neni :-)');
+INSERT INTO `location` VALUES (0,'UNIVERSE',14,'Tady je všechno co nikde neni :-)'),(4,'aaatest',0,'');
/*!40000 ALTER TABLE `location` ENABLE KEYS */;
UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2012-04-11 19:25:14
+-- Dump completed on 2012-07-24 15:03:20
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `item` (
`item_id` int(11) NOT NULL AUTO_INCREMENT,
- `model_id` int(11) NOT NULL,
+ `barcode_id` int(11) NOT NULL,
`vendor_id` int(11) NOT NULL,
`item_serial` varchar(128) COLLATE utf8_czech_ci NOT NULL,
`item_quantity` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`item_id`,`item_valid_till`),
UNIQUE KEY `item_serial_item_valid_till` (`item_serial`,`item_valid_till`),
KEY `vendor_id` (`vendor_id`),
- KEY `model_id` (`model_id`),
KEY `status_id` (`status_id`),
KEY `room_id` (`room_id`),
KEY `location_id` (`location_id`),
CONSTRAINT `item_ibfk_10` FOREIGN KEY (`location_id`) REFERENCES `location` (`location_id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `item_ibfk_6` FOREIGN KEY (`vendor_id`) REFERENCES `vendor` (`vendor_id`),
- 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=43 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=45 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 */;
CONSTRAINT `model_ibfk_2` FOREIGN KEY (`producer_id`) REFERENCES `producer` (`producer_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE IF EXISTS `barcode`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `barcode` (
+ `barcode_id` int(11) NOT NULL AUTO_INCREMENT,
+ `model_id` int(11) NOT NULL,
+ `barcode_name` varchar(128) COLLATE utf8_czech_ci NOT NULL,
+ PRIMARY KEY (`barcode_id`),
+ KEY `model_id` (`model_id`),
+ CONSTRAINT `barcode_ibfk_1` FOREIGN KEY (`model_id`) REFERENCES `model` (`model_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;