diff --git a/application/controllers/Items.php b/application/controllers/Items.php index 534166026..425d11466 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -63,21 +63,37 @@ class Items extends Secure_Controller foreach($items->result() as $item) { $data_rows[] = $this->xss_clean(get_item_data_row($item, $this)); + + // Guess whether file extension is not in the table field, + // if it isn't, then it's an old-format (formerly pic_id) field, + // so we guess the right filename and update the table + $ext = pathinfo($item->pic_filename, PATHINFO_EXTENSION); + if($ext == '') + { + $images = glob('./uploads/item_pics/' . $item->pic_filename . '.*'); + $new_pic_filename = pathinfo($images[0], PATHINFO_BASENAME); + $item_data = array('pic_filename' => $new_pic_filename); + $this->Item->save($item_data, $item->item_id); + } } echo json_encode(array('total' => $total_rows, 'rows' => $data_rows)); } - public function pic_thumb($pic_id) + public function pic_thumb($pic_filename) { $this->load->helper('file'); $this->load->library('image_lib'); - $base_path = './uploads/item_pics/' . $pic_id; - $images = glob($base_path . '.*'); + + // in this context, $pic_filename always has .ext + $ext = pathinfo($pic_filename, PATHINFO_EXTENSION); + $images = glob('./uploads/item_pics/' . $pic_filename); + + // make sure we pick only the file name, without extension + $base_path = './uploads/item_pics/' . pathinfo($pic_filename, PATHINFO_FILENAME); if(sizeof($images) > 0) { $image_path = $images[0]; - $ext = pathinfo($image_path, PATHINFO_EXTENSION); $thumb_path = $base_path . $this->image_lib->thumb_marker . '.' . $ext; if(sizeof($images) < 2) { @@ -191,13 +207,25 @@ class Items extends Secure_Controller $data['suppliers'] = $suppliers; $data['selected_supplier'] = $item_info->supplier_id; - $data['logo_exists'] = $item_info->pic_id != ''; - if (!empty($item_info->pic_id)) + $data['logo_exists'] = $item_info->pic_filename != ''; + $ext = pathinfo($item_info->pic_filename, PATHINFO_EXTENSION); + if($ext == '') { - $images = glob('./uploads/item_pics/' . $item_info->pic_id . '.*'); - $data['image_path'] = sizeof($images) > 0 ? base_url($images[0]) : ''; + // if file extension is not found guess it (legacy) + $images = glob('./uploads/item_pics/' . $item_info->pic_filename . '.*'); + // try to update pic_filename in db, following 3 lines might not be necessary + // after what I put in search(), feel free to remove it if you also think it's + // redundant. + $new_pic_filename = pathinfo($images[0], PATHINFO_BASENAME); + $item_data = array('pic_filename' => $new_pic_filename); + $this->Item->save($item_data, $item_id); } - + else + { + // else just pick that file + $images = glob('./uploads/item_pics/' . $item_info->pic_filename); + } + $data['image_path'] = sizeof($images) > 0 ? base_url($images[0]) : ''; $stock_locations = $this->Stock_location->get_undeleted_all()->result_array(); foreach($stock_locations as $location) { @@ -353,7 +381,7 @@ class Items extends Secure_Controller // XSS file image sanity check if($this->xss_clean($upload_data['raw_name'], TRUE) === TRUE) { - $item_data['pic_id'] = $upload_data['raw_name']; + $item_data['pic_filename'] = $upload_data['raw_name']; } } @@ -456,17 +484,14 @@ class Items extends Secure_Controller private function _handle_image_upload() { - $this->load->helper('directory'); - - $map = directory_map('./uploads/item_pics/', 1); - + /* Let files be uploaded with their original name */ + // load upload library $config = array('upload_path' => './uploads/item_pics/', 'allowed_types' => 'gif|jpg|png', 'max_size' => '100', 'max_width' => '640', - 'max_height' => '480', - 'file_name' => sizeof($map) + 1 + 'max_height' => '480' ); $this->load->library('upload', $config); $this->upload->do_upload('item_image'); @@ -476,7 +501,7 @@ class Items extends Secure_Controller public function remove_logo($item_id) { - $item_data = array('pic_id' => NULL); + $item_data = array('pic_filename' => NULL); $result = $this->Item->save($item_data, $item_id); echo json_encode(array('success' => $result)); @@ -620,6 +645,7 @@ class Items extends Secure_Controller // XSS file data sanity check $data = $this->xss_clean($data); + /* haven't touched this so old templates will work, or so I guess... */ if(sizeof($data) >= 23) { $item_data = array( @@ -643,6 +669,18 @@ class Items extends Secure_Controller 'custom9' => $data[22], 'custom10' => $data[23] ); + + /* we could do something like this, however, the effectiveness of + this is rather limited, since for now, you have to upload files manually + into that directory, so you really can do whatever you want, this probably + needs further discussion */ + + $pic_file = $data[26]; + /*if(strcmp('.htaccess', $pic_file)==0) { + $pic_file=''; + }*/ + $item_data['pic_filename']=$pic_file; + $item_number = $data[0]; $invalidated = FALSE; if($item_number != '') diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 0971ab624..944edf12c 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -269,13 +269,21 @@ function get_item_data_row($item, $controller) $tax_percents = substr($tax_percents, 0, -2); $controller_name = strtolower(get_class($CI)); - $image = ''; - if ($item->pic_id != '') + if ($item->pic_filename != '') { - $images = glob('./uploads/item_pics/' . $item->pic_id . '.*'); + $ext = pathinfo($item->pic_filename, PATHINFO_EXTENSION); + if($ext == '') + { + // legacy + $images = glob('./uploads/item_pics/' . $item->pic_filename . '.*'); + } + else { + // preferred + $images = glob('./uploads/item_pics/' . $item->pic_filename); + } if (sizeof($images) > 0) { - $image .= ''; + $image .= ''; } } diff --git a/application/views/partial/header.php b/application/views/partial/header.php index fd04831a5..6e1addb61 100644 --- a/application/views/partial/header.php +++ b/application/views/partial/header.php @@ -70,11 +70,11 @@ - + - + diff --git a/database/3.0.2_to_3.1.0.sql b/database/3.0.2_to_3.1.0.sql index 87226cdb7..f5c5b5992 100644 --- a/database/3.0.2_to_3.1.0.sql +++ b/database/3.0.2_to_3.1.0.sql @@ -19,3 +19,7 @@ ALTER TABLE `ospos_sales_items` ALTER TABLE `ospos_sales_suspended_items` ADD COLUMN `print_option` TINYINT(2) NOT NULL DEFAULT 0; + +-- alter pic_id field, to rather contain a file name + +ALTER TABLE `ospos_items` CHANGE `pic_id` `pic_filename` VARCHAR(255); diff --git a/database/database.sql b/database/database.sql index 1054f9b5a..891bcdda8 100644 --- a/database/database.sql +++ b/database/database.sql @@ -4,9 +4,9 @@ -- CREATE TABLE `ospos_app_config` ( - `key` varchar(50) NOT NULL, - `value` varchar(500) NOT NULL, - PRIMARY KEY (`key`) + `key` varchar(50) NOT NULL, + `value` varchar(500) NOT NULL, + PRIMARY KEY (`key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -92,14 +92,14 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES -- CREATE TABLE `ospos_customers` ( - `person_id` int(10) NOT NULL, - `company_name` varchar(255) DEFAULT NULL, - `account_number` varchar(255) DEFAULT NULL, - `taxable` int(1) NOT NULL DEFAULT '1', - `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', - `deleted` int(1) NOT NULL DEFAULT '0', - UNIQUE KEY `account_number` (`account_number`), - KEY `person_id` (`person_id`) + `person_id` int(10) NOT NULL, + `company_name` varchar(255) DEFAULT NULL, + `account_number` varchar(255) DEFAULT NULL, + `taxable` int(1) NOT NULL DEFAULT '1', + `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', + `deleted` int(1) NOT NULL DEFAULT '0', + UNIQUE KEY `account_number` (`account_number`), + KEY `person_id` (`person_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -114,13 +114,13 @@ CREATE TABLE `ospos_customers` ( -- CREATE TABLE `ospos_employees` ( - `username` varchar(255) NOT NULL, - `password` varchar(255) NOT NULL, - `person_id` int(10) NOT NULL, - `deleted` int(1) NOT NULL DEFAULT '0', - `hash_version` int(1) NOT NULL DEFAULT '2', - UNIQUE KEY `username` (`username`), - KEY `person_id` (`person_id`) + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `person_id` int(10) NOT NULL, + `deleted` int(1) NOT NULL DEFAULT '0', + `hash_version` int(1) NOT NULL DEFAULT '2', + UNIQUE KEY `username` (`username`), + KEY `person_id` (`person_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -137,15 +137,15 @@ INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`, ` -- CREATE TABLE `ospos_giftcards` ( - `record_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `giftcard_id` int(11) NOT NULL AUTO_INCREMENT, - `giftcard_number` int(10) NOT NULL, - `value` decimal(15,2) NOT NULL, - `deleted` int(1) NOT NULL DEFAULT '0', - `person_id` INT(10) DEFAULT NULL, - PRIMARY KEY (`giftcard_id`), - UNIQUE KEY `giftcard_number` (`giftcard_number`), - KEY `person_id` (`person_id`) + `record_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `giftcard_id` int(11) NOT NULL AUTO_INCREMENT, + `giftcard_number` int(10) NOT NULL, + `value` decimal(15,2) NOT NULL, + `deleted` int(1) NOT NULL DEFAULT '0', + `person_id` INT(10) DEFAULT NULL, + PRIMARY KEY (`giftcard_id`), + UNIQUE KEY `giftcard_number` (`giftcard_number`), + KEY `person_id` (`person_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -160,17 +160,17 @@ CREATE TABLE `ospos_giftcards` ( -- CREATE TABLE `ospos_inventory` ( - `trans_id` int(11) NOT NULL AUTO_INCREMENT, - `trans_items` int(11) NOT NULL DEFAULT '0', - `trans_user` int(11) NOT NULL DEFAULT '0', - `trans_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `trans_comment` text NOT NULL, - `trans_location` int(11) NOT NULL, - `trans_inventory` decimal(15,3) NOT NULL DEFAULT '0', - PRIMARY KEY (`trans_id`), - KEY `trans_items` (`trans_items`), - KEY `trans_user` (`trans_user`), - KEY `trans_location` (`trans_location`) + `trans_id` int(11) NOT NULL AUTO_INCREMENT, + `trans_items` int(11) NOT NULL DEFAULT '0', + `trans_user` int(11) NOT NULL DEFAULT '0', + `trans_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `trans_comment` text NOT NULL, + `trans_location` int(11) NOT NULL, + `trans_inventory` decimal(15,3) NOT NULL DEFAULT '0', + PRIMARY KEY (`trans_id`), + KEY `trans_items` (`trans_items`), + KEY `trans_user` (`trans_user`), + KEY `trans_location` (`trans_location`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -185,35 +185,35 @@ CREATE TABLE `ospos_inventory` ( -- CREATE TABLE `ospos_items` ( - `name` varchar(255) NOT NULL, - `category` varchar(255) NOT NULL, - `supplier_id` int(11) DEFAULT NULL, - `item_number` varchar(255) DEFAULT NULL, - `description` varchar(255) NOT NULL, - `cost_price` decimal(15,2) NOT NULL, - `unit_price` decimal(15,2) NOT NULL, - `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', - `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', - `item_id` int(10) NOT NULL AUTO_INCREMENT, - `pic_id` int(10) DEFAULT NULL, - `allow_alt_description` tinyint(1) NOT NULL, - `item_type` TINYINT(2) NOT NULL DEFAULT 0, - `stock_type` TINYINT(2) NOT NULL DEFAULT 0, - `is_serialized` tinyint(1) NOT NULL, - `deleted` int(1) NOT NULL DEFAULT '0', - `custom1` VARCHAR(25) NOT NULL, - `custom2` VARCHAR(25) NOT NULL, - `custom3` VARCHAR(25) NOT NULL, - `custom4` VARCHAR(25) NOT NULL, - `custom5` VARCHAR(25) NOT NULL, - `custom6` VARCHAR(25) NOT NULL, - `custom7` VARCHAR(25) NOT NULL, - `custom8` VARCHAR(25) NOT NULL, - `custom9` VARCHAR(25) NOT NULL, - `custom10` VARCHAR(25) NOT NULL, - PRIMARY KEY (`item_id`), - UNIQUE KEY `item_number` (`item_number`), - KEY `supplier_id` (`supplier_id`) + `name` varchar(255) NOT NULL, + `category` varchar(255) NOT NULL, + `supplier_id` int(11) DEFAULT NULL, + `item_number` varchar(255) DEFAULT NULL, + `description` varchar(255) NOT NULL, + `cost_price` decimal(15,2) NOT NULL, + `unit_price` decimal(15,2) NOT NULL, + `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', + `item_id` int(10) NOT NULL AUTO_INCREMENT, + `pic_filename` varchar(255) DEFAULT NULL, + `allow_alt_description` tinyint(1) NOT NULL, + `is_serialized` tinyint(1) NOT NULL, + `stock_type` TINYINT(2) NOT NULL DEFAULT 0, + `item_type` TINYINT(2) NOT NULL DEFAULT 0, + `deleted` int(1) NOT NULL DEFAULT '0', + `custom1` VARCHAR(25) NOT NULL, + `custom2` VARCHAR(25) NOT NULL, + `custom3` VARCHAR(25) NOT NULL, + `custom4` VARCHAR(25) NOT NULL, + `custom5` VARCHAR(25) NOT NULL, + `custom6` VARCHAR(25) NOT NULL, + `custom7` VARCHAR(25) NOT NULL, + `custom8` VARCHAR(25) NOT NULL, + `custom9` VARCHAR(25) NOT NULL, + `custom10` VARCHAR(25) NOT NULL, + PRIMARY KEY (`item_id`), + UNIQUE KEY `item_number` (`item_number`), + KEY `supplier_id` (`supplier_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -228,10 +228,10 @@ CREATE TABLE `ospos_items` ( -- CREATE TABLE `ospos_items_taxes` ( - `item_id` int(10) NOT NULL, - `name` varchar(255) NOT NULL, - `percent` decimal(15,3) NOT NULL, - PRIMARY KEY (`item_id`,`name`,`percent`) + `item_id` int(10) NOT NULL, + `name` varchar(255) NOT NULL, + `percent` decimal(15,3) NOT NULL, + PRIMARY KEY (`item_id`,`name`,`percent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -246,14 +246,14 @@ CREATE TABLE `ospos_items_taxes` ( -- CREATE TABLE `ospos_item_kits` ( - `item_kit_id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `description` varchar(255) NOT NULL, - `item_id` INT(10) NOT NULL DEFAULT 0, - `kit_discount_percent` DECIMAL(15,2) NOT NULL DEFAULT 0.00, - `price_option` TINYINT(2) NOT NULL DEFAULT 0, - `print_option` TINYINT(2) NOT NULL DEFAULT 0, - PRIMARY KEY (`item_kit_id`) + `item_kit_id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `item_id` INT(10) NOT NULL DEFAULT 0, + `kit_discount_percent` DECIMAL(15,2) NOT NULL DEFAULT 0.00, + `price_option` TINYINT(2) NOT NULL DEFAULT 0, + `print_option` TINYINT(2) NOT NULL DEFAULT 0, + `description` varchar(255) NOT NULL, + PRIMARY KEY (`item_kit_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -268,12 +268,12 @@ CREATE TABLE `ospos_item_kits` ( -- CREATE TABLE `ospos_item_kit_items` ( - `item_kit_id` int(11) NOT NULL, - `item_id` int(11) NOT NULL, - `quantity` decimal(15,3) NOT NULL, - `kit_sequence` INT(3) NOT NULL DEFAULT 0, - PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`), - KEY `ospos_item_kit_items_ibfk_2` (`item_id`) + `item_kit_id` int(11) NOT NULL, + `item_id` int(11) NOT NULL, + `quantity` decimal(15,3) NOT NULL, + `kit_sequence` INT(3) NOT NULL DEFAULT 0, + PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`), + KEY `ospos_item_kit_items_ibfk_2` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -287,12 +287,12 @@ CREATE TABLE `ospos_item_kit_items` ( -- CREATE TABLE IF NOT EXISTS `ospos_item_quantities` ( - `item_id` int(11) NOT NULL, - `location_id` int(11) NOT NULL, - `quantity` decimal(15,3) NOT NULL DEFAULT '0', - PRIMARY KEY (`item_id`,`location_id`), - KEY `item_id` (`item_id`), - KEY `location_id` (`location_id`) + `item_id` int(11) NOT NULL, + `location_id` int(11) NOT NULL, + `quantity` decimal(15,3) NOT NULL DEFAULT '0', + PRIMARY KEY (`item_id`,`location_id`), + KEY `item_id` (`item_id`), + KEY `location_id` (`location_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- -------------------------------------------------------- @@ -302,13 +302,13 @@ CREATE TABLE IF NOT EXISTS `ospos_item_quantities` ( -- CREATE TABLE `ospos_modules` ( - `name_lang_key` varchar(255) NOT NULL, - `desc_lang_key` varchar(255) NOT NULL, - `sort` int(10) NOT NULL, - `module_id` varchar(255) NOT NULL, - PRIMARY KEY (`module_id`), - UNIQUE KEY `desc_lang_key` (`desc_lang_key`), - UNIQUE KEY `name_lang_key` (`name_lang_key`) + `name_lang_key` varchar(255) NOT NULL, + `desc_lang_key` varchar(255) NOT NULL, + `sort` int(10) NOT NULL, + `module_id` varchar(255) NOT NULL, + PRIMARY KEY (`module_id`), + UNIQUE KEY `desc_lang_key` (`desc_lang_key`), + UNIQUE KEY `name_lang_key` (`name_lang_key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -335,20 +335,20 @@ INSERT INTO `ospos_modules` (`name_lang_key`, `desc_lang_key`, `sort`, `module_i -- CREATE TABLE `ospos_people` ( - `first_name` varchar(255) NOT NULL, - `last_name` varchar(255) NOT NULL, - `gender` int(1) DEFAULT NULL, - `phone_number` varchar(255) NOT NULL, - `email` varchar(255) NOT NULL, - `address_1` varchar(255) NOT NULL, - `address_2` varchar(255) NOT NULL, - `city` varchar(255) NOT NULL, - `state` varchar(255) NOT NULL, - `zip` varchar(255) NOT NULL, - `country` varchar(255) NOT NULL, - `comments` text NOT NULL, - `person_id` int(10) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`person_id`) + `first_name` varchar(255) NOT NULL, + `last_name` varchar(255) NOT NULL, + `gender` int(1) DEFAULT NULL, + `phone_number` varchar(255) NOT NULL, + `email` varchar(255) NOT NULL, + `address_1` varchar(255) NOT NULL, + `address_2` varchar(255) NOT NULL, + `city` varchar(255) NOT NULL, + `state` varchar(255) NOT NULL, + `zip` varchar(255) NOT NULL, + `country` varchar(255) NOT NULL, + `comments` text NOT NULL, + `person_id` int(10) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`person_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -365,11 +365,11 @@ INSERT INTO `ospos_people` (`first_name`, `last_name`, `phone_number`, `email`, -- CREATE TABLE `ospos_permissions` ( - `permission_id` varchar(255) NOT NULL, - `module_id` varchar(255) NOT NULL, - `location_id` int(10) DEFAULT NULL, - PRIMARY KEY (`permission_id`), - KEY `module_id` (`module_id`) + `permission_id` varchar(255) NOT NULL, + `module_id` varchar(255) NOT NULL, + `location_id` int(10) DEFAULT NULL, + PRIMARY KEY (`permission_id`), + KEY `module_id` (`module_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -412,9 +412,9 @@ INSERT INTO `ospos_permissions` (`permission_id`, `module_id`, `location_id`) VA -- CREATE TABLE `ospos_grants` ( - `permission_id` varchar(255) NOT NULL, - `person_id` int(10) NOT NULL, - PRIMARY KEY (`permission_id`,`person_id`) + `permission_id` varchar(255) NOT NULL, + `person_id` int(10) NOT NULL, + PRIMARY KEY (`permission_id`,`person_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -454,17 +454,17 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`) VALUES -- CREATE TABLE `ospos_receivings` ( - `receiving_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `supplier_id` int(10) DEFAULT NULL, - `employee_id` int(10) NOT NULL DEFAULT '0', - `comment` text NOT NULL, - `receiving_id` int(10) NOT NULL AUTO_INCREMENT, - `payment_type` varchar(20) DEFAULT NULL, - `reference` varchar(32) DEFAULT NULL, - PRIMARY KEY (`receiving_id`), - KEY `supplier_id` (`supplier_id`), - KEY `employee_id` (`employee_id`), - KEY `reference` (`reference`) + `receiving_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `supplier_id` int(10) DEFAULT NULL, + `employee_id` int(10) NOT NULL DEFAULT '0', + `comment` text NOT NULL, + `receiving_id` int(10) NOT NULL AUTO_INCREMENT, + `payment_type` varchar(20) DEFAULT NULL, + `reference` varchar(32) DEFAULT NULL, + PRIMARY KEY (`receiving_id`), + KEY `supplier_id` (`supplier_id`), + KEY `employee_id` (`employee_id`), + KEY `reference` (`reference`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -479,19 +479,19 @@ CREATE TABLE `ospos_receivings` ( -- CREATE TABLE `ospos_receivings_items` ( - `receiving_id` int(10) NOT NULL DEFAULT '0', - `item_id` int(10) NOT NULL DEFAULT '0', - `description` varchar(30) DEFAULT NULL, - `serialnumber` varchar(30) DEFAULT NULL, - `line` int(3) NOT NULL, - `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', - `item_cost_price` decimal(15,2) NOT NULL, - `item_unit_price` decimal(15,2) NOT NULL, - `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', - `item_location` int(11) NOT NULL, - `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', - PRIMARY KEY (`receiving_id`,`item_id`,`line`), - KEY `item_id` (`item_id`) + `receiving_id` int(10) NOT NULL DEFAULT '0', + `item_id` int(10) NOT NULL DEFAULT '0', + `description` varchar(30) DEFAULT NULL, + `serialnumber` varchar(30) DEFAULT NULL, + `line` int(3) NOT NULL, + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', + `item_cost_price` decimal(15,2) NOT NULL, + `item_unit_price` decimal(15,2) NOT NULL, + `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', + `item_location` int(11) NOT NULL, + `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', + PRIMARY KEY (`receiving_id`,`item_id`,`line`), + KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -506,17 +506,17 @@ CREATE TABLE `ospos_receivings_items` ( -- CREATE TABLE `ospos_sales` ( - `sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `customer_id` int(10) DEFAULT NULL, - `employee_id` int(10) NOT NULL DEFAULT '0', - `comment` text NOT NULL, - `invoice_number` varchar(32) DEFAULT NULL, - `sale_id` int(10) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`sale_id`), - KEY `customer_id` (`customer_id`), - KEY `employee_id` (`employee_id`), - KEY `sale_time` (`sale_time`), - UNIQUE KEY `invoice_number` (`invoice_number`) + `sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `customer_id` int(10) DEFAULT NULL, + `employee_id` int(10) NOT NULL DEFAULT '0', + `comment` text NOT NULL, + `invoice_number` varchar(32) DEFAULT NULL, + `sale_id` int(10) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`sale_id`), + KEY `customer_id` (`customer_id`), + KEY `employee_id` (`employee_id`), + KEY `sale_time` (`sale_time`), + UNIQUE KEY `invoice_number` (`invoice_number`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -531,21 +531,21 @@ CREATE TABLE `ospos_sales` ( -- CREATE TABLE `ospos_sales_items` ( - `sale_id` int(10) NOT NULL DEFAULT '0', - `item_id` int(10) NOT NULL DEFAULT '0', - `description` varchar(30) DEFAULT NULL, - `serialnumber` varchar(30) DEFAULT NULL, - `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', - `item_cost_price` decimal(15,2) NOT NULL, - `item_unit_price` decimal(15,2) NOT NULL, - `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', - `item_location` int(11) NOT NULL, - `print_option` tinyint(2) NOT NULL DEFAULT 0, - PRIMARY KEY (`sale_id`,`item_id`,`line`), - KEY `sale_id` (`sale_id`), - KEY `item_id` (`item_id`), - KEY `item_location` (`item_location`) + `sale_id` int(10) NOT NULL DEFAULT '0', + `item_id` int(10) NOT NULL DEFAULT '0', + `description` varchar(30) DEFAULT NULL, + `serialnumber` varchar(30) DEFAULT NULL, + `line` int(3) NOT NULL DEFAULT '0', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', + `item_cost_price` decimal(15,2) NOT NULL, + `item_unit_price` decimal(15,2) NOT NULL, + `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', + `item_location` int(11) NOT NULL, + `print_option` TINYINT(2) NOT NULL DEFAULT 0, + PRIMARY KEY (`sale_id`,`item_id`,`line`), + KEY `sale_id` (`sale_id`), + KEY `item_id` (`item_id`), + KEY `item_location` (`item_location`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -560,14 +560,14 @@ CREATE TABLE `ospos_sales_items` ( -- CREATE TABLE `ospos_sales_items_taxes` ( - `sale_id` int(10) NOT NULL, - `item_id` int(10) NOT NULL, - `line` int(3) NOT NULL DEFAULT '0', - `name` varchar(255) NOT NULL, - `percent` decimal(15,3) NOT NULL, - PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`), - KEY `sale_id` (`sale_id`), - KEY `item_id` (`item_id`) + `sale_id` int(10) NOT NULL, + `item_id` int(10) NOT NULL, + `line` int(3) NOT NULL DEFAULT '0', + `name` varchar(255) NOT NULL, + `percent` decimal(15,3) NOT NULL, + PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`), + KEY `sale_id` (`sale_id`), + KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -582,11 +582,11 @@ CREATE TABLE `ospos_sales_items_taxes` ( -- CREATE TABLE `ospos_sales_payments` ( - `sale_id` int(10) NOT NULL, - `payment_type` varchar(40) NOT NULL, - `payment_amount` decimal(15,2) NOT NULL, - PRIMARY KEY (`sale_id`,`payment_type`), - KEY `sale_id` (`sale_id`) + `sale_id` int(10) NOT NULL, + `payment_type` varchar(40) NOT NULL, + `payment_amount` decimal(15,2) NOT NULL, + PRIMARY KEY (`sale_id`,`payment_type`), + KEY `sale_id` (`sale_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -601,15 +601,15 @@ CREATE TABLE `ospos_sales_payments` ( -- CREATE TABLE `ospos_sales_suspended` ( - `sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `customer_id` int(10) DEFAULT NULL, - `employee_id` int(10) NOT NULL DEFAULT '0', - `comment` text NOT NULL, - `invoice_number` varchar(32) DEFAULT NULL, - `sale_id` int(10) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`sale_id`), - KEY `customer_id` (`customer_id`), - KEY `employee_id` (`employee_id`) + `sale_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `customer_id` int(10) DEFAULT NULL, + `employee_id` int(10) NOT NULL DEFAULT '0', + `comment` text NOT NULL, + `invoice_number` varchar(32) DEFAULT NULL, + `sale_id` int(10) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`sale_id`), + KEY `customer_id` (`customer_id`), + KEY `employee_id` (`employee_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -624,20 +624,20 @@ CREATE TABLE `ospos_sales_suspended` ( -- CREATE TABLE `ospos_sales_suspended_items` ( - `sale_id` int(10) NOT NULL DEFAULT '0', - `item_id` int(10) NOT NULL DEFAULT '0', - `description` varchar(30) DEFAULT NULL, - `serialnumber` varchar(30) DEFAULT NULL, - `line` int(3) NOT NULL DEFAULT '0', - `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', - `item_cost_price` decimal(15,2) NOT NULL, - `item_unit_price` decimal(15,2) NOT NULL, - `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', - `item_location` int(11) NOT NULL, - `print_option` tinyint(2) NOT NULL DEFAULT 0, - PRIMARY KEY (`sale_id`,`item_id`,`line`), - KEY `sale_id` (`sale_id`), - KEY `item_id` (`item_id`) + `sale_id` int(10) NOT NULL DEFAULT '0', + `item_id` int(10) NOT NULL DEFAULT '0', + `description` varchar(30) DEFAULT NULL, + `serialnumber` varchar(30) DEFAULT NULL, + `line` int(3) NOT NULL DEFAULT '0', + `quantity_purchased` decimal(15,3) NOT NULL DEFAULT '0', + `item_cost_price` decimal(15,2) NOT NULL, + `item_unit_price` decimal(15,2) NOT NULL, + `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', + `item_location` int(11) NOT NULL, + `print_option` TINYINT(2) NOT NULL DEFAULT 0, + PRIMARY KEY (`sale_id`,`item_id`,`line`), + KEY `sale_id` (`sale_id`), + KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -652,13 +652,13 @@ CREATE TABLE `ospos_sales_suspended_items` ( -- CREATE TABLE `ospos_sales_suspended_items_taxes` ( - `sale_id` int(10) NOT NULL, - `item_id` int(10) NOT NULL, - `line` int(3) NOT NULL DEFAULT '0', - `name` varchar(255) NOT NULL, - `percent` decimal(15,3) NOT NULL, - PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`), - KEY `item_id` (`item_id`) + `sale_id` int(10) NOT NULL, + `item_id` int(10) NOT NULL, + `line` int(3) NOT NULL DEFAULT '0', + `name` varchar(255) NOT NULL, + `percent` decimal(15,3) NOT NULL, + PRIMARY KEY (`sale_id`,`item_id`,`line`,`name`,`percent`), + KEY `item_id` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -673,10 +673,10 @@ CREATE TABLE `ospos_sales_suspended_items_taxes` ( -- CREATE TABLE `ospos_sales_suspended_payments` ( - `sale_id` int(10) NOT NULL, - `payment_type` varchar(40) NOT NULL, - `payment_amount` decimal(15,2) NOT NULL, - PRIMARY KEY (`sale_id`,`payment_type`) + `sale_id` int(10) NOT NULL, + `payment_type` varchar(40) NOT NULL, + `payment_amount` decimal(15,2) NOT NULL, + PRIMARY KEY (`sale_id`,`payment_type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -691,11 +691,11 @@ CREATE TABLE `ospos_sales_suspended_payments` ( -- CREATE TABLE `ospos_sessions` ( - `id` varchar(40) NOT NULL, - `ip_address` varchar(45) NOT NULL, - `timestamp` int(10) unsigned DEFAULT 0 NOT NULL, - `data` blob NOT NULL, - KEY `ci_sessions_timestamp` (`timestamp`) + `id` varchar(40) NOT NULL, + `ip_address` varchar(45) NOT NULL, + `timestamp` int(10) unsigned DEFAULT 0 NOT NULL, + `data` blob NOT NULL, + KEY `ci_sessions_timestamp` (`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -709,10 +709,10 @@ CREATE TABLE `ospos_sessions` ( -- CREATE TABLE `ospos_stock_locations` ( - `location_id` int(11) NOT NULL AUTO_INCREMENT, - `location_name` varchar(255) DEFAULT NULL, - `deleted` int(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`location_id`) + `location_id` int(11) NOT NULL AUTO_INCREMENT, + `location_name` varchar(255) DEFAULT NULL, + `deleted` int(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`location_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; -- @@ -728,13 +728,13 @@ INSERT INTO `ospos_stock_locations` ( `deleted`, `location_name` ) VALUES ('0', -- CREATE TABLE `ospos_suppliers` ( - `person_id` int(10) NOT NULL, - `company_name` varchar(255) NOT NULL, - `agency_name` varchar(255) NOT NULL, - `account_number` varchar(255) DEFAULT NULL, - `deleted` int(1) NOT NULL DEFAULT '0', - UNIQUE KEY `account_number` (`account_number`), - KEY `person_id` (`person_id`) + `person_id` int(10) NOT NULL, + `company_name` varchar(255) NOT NULL, + `agency_name` varchar(255) NOT NULL, + `account_number` varchar(255) DEFAULT NULL, + `deleted` int(1) NOT NULL DEFAULT '0', + UNIQUE KEY `account_number` (`account_number`), + KEY `person_id` (`person_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -750,141 +750,141 @@ CREATE TABLE `ospos_suppliers` ( -- Constraints for table `ospos_customers` -- ALTER TABLE `ospos_customers` - ADD CONSTRAINT `ospos_customers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); + ADD CONSTRAINT `ospos_customers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); -- -- Constraints for table `ospos_employees` -- ALTER TABLE `ospos_employees` - ADD CONSTRAINT `ospos_employees_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); + ADD CONSTRAINT `ospos_employees_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); -- -- Constraints for table `ospos_inventory` -- ALTER TABLE `ospos_inventory` - ADD CONSTRAINT `ospos_inventory_ibfk_1` FOREIGN KEY (`trans_items`) REFERENCES `ospos_items` (`item_id`), - ADD CONSTRAINT `ospos_inventory_ibfk_2` FOREIGN KEY (`trans_user`) REFERENCES `ospos_employees` (`person_id`), - ADD CONSTRAINT `ospos_inventory_ibfk_3` FOREIGN KEY (`trans_location`) REFERENCES `ospos_stock_locations` (`location_id`); + ADD CONSTRAINT `ospos_inventory_ibfk_1` FOREIGN KEY (`trans_items`) REFERENCES `ospos_items` (`item_id`), + ADD CONSTRAINT `ospos_inventory_ibfk_2` FOREIGN KEY (`trans_user`) REFERENCES `ospos_employees` (`person_id`), + ADD CONSTRAINT `ospos_inventory_ibfk_3` FOREIGN KEY (`trans_location`) REFERENCES `ospos_stock_locations` (`location_id`); -- -- Constraints for table `ospos_items` -- ALTER TABLE `ospos_items` - ADD CONSTRAINT `ospos_items_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`); + ADD CONSTRAINT `ospos_items_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`); -- -- Constraints for table `ospos_items_taxes` -- ALTER TABLE `ospos_items_taxes` - ADD CONSTRAINT `ospos_items_taxes_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE; + ADD CONSTRAINT `ospos_items_taxes_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE; -- -- Constraints for table `ospos_item_kit_items` -- ALTER TABLE `ospos_item_kit_items` - ADD CONSTRAINT `ospos_item_kit_items_ibfk_1` FOREIGN KEY (`item_kit_id`) REFERENCES `ospos_item_kits` (`item_kit_id`) ON DELETE CASCADE, - ADD CONSTRAINT `ospos_item_kit_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE; + ADD CONSTRAINT `ospos_item_kit_items_ibfk_1` FOREIGN KEY (`item_kit_id`) REFERENCES `ospos_item_kits` (`item_kit_id`) ON DELETE CASCADE, + ADD CONSTRAINT `ospos_item_kit_items_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`) ON DELETE CASCADE; -- -- Constraints for table `ospos_permissions` -- ALTER TABLE `ospos_permissions` - ADD CONSTRAINT `ospos_permissions_ibfk_1` FOREIGN KEY (`module_id`) REFERENCES `ospos_modules` (`module_id`) ON DELETE CASCADE, - ADD CONSTRAINT `ospos_permissions_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`) ON DELETE CASCADE; + ADD CONSTRAINT `ospos_permissions_ibfk_1` FOREIGN KEY (`module_id`) REFERENCES `ospos_modules` (`module_id`) ON DELETE CASCADE, + ADD CONSTRAINT `ospos_permissions_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`) ON DELETE CASCADE; -- -- Constraints for table `ospos_grants` -- ALTER TABLE `ospos_grants` - ADD CONSTRAINT `ospos_grants_ibfk_1` foreign key (`permission_id`) references `ospos_permissions` (`permission_id`) ON DELETE CASCADE, - ADD CONSTRAINT `ospos_grants_ibfk_2` foreign key (`person_id`) references `ospos_employees` (`person_id`) ON DELETE CASCADE; + ADD CONSTRAINT `ospos_grants_ibfk_1` foreign key (`permission_id`) references `ospos_permissions` (`permission_id`) ON DELETE CASCADE, + ADD CONSTRAINT `ospos_grants_ibfk_2` foreign key (`person_id`) references `ospos_employees` (`person_id`) ON DELETE CASCADE; -- -- Constraints for table `ospos_receivings` -- ALTER TABLE `ospos_receivings` - ADD CONSTRAINT `ospos_receivings_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`), - ADD CONSTRAINT `ospos_receivings_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`); + ADD CONSTRAINT `ospos_receivings_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`), + ADD CONSTRAINT `ospos_receivings_ibfk_2` FOREIGN KEY (`supplier_id`) REFERENCES `ospos_suppliers` (`person_id`); -- -- Constraints for table `ospos_receivings_items` -- ALTER TABLE `ospos_receivings_items` - ADD CONSTRAINT `ospos_receivings_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), - ADD CONSTRAINT `ospos_receivings_items_ibfk_2` FOREIGN KEY (`receiving_id`) REFERENCES `ospos_receivings` (`receiving_id`); + ADD CONSTRAINT `ospos_receivings_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), + ADD CONSTRAINT `ospos_receivings_items_ibfk_2` FOREIGN KEY (`receiving_id`) REFERENCES `ospos_receivings` (`receiving_id`); -- -- Constraints for table `ospos_sales` -- ALTER TABLE `ospos_sales` - ADD CONSTRAINT `ospos_sales_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`), - ADD CONSTRAINT `ospos_sales_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`); + ADD CONSTRAINT `ospos_sales_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`), + ADD CONSTRAINT `ospos_sales_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`); -- -- Constraints for table `ospos_sales_items` -- ALTER TABLE `ospos_sales_items` - ADD CONSTRAINT `ospos_sales_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), - ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`), - ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`); + ADD CONSTRAINT `ospos_sales_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), + ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`), + ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`); -- -- Constraints for table `ospos_sales_items_taxes` -- ALTER TABLE `ospos_sales_items_taxes` - ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_items` (`sale_id`), - ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`); + ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_items` (`sale_id`), + ADD CONSTRAINT `ospos_sales_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`); -- -- Constraints for table `ospos_sales_payments` -- ALTER TABLE `ospos_sales_payments` - ADD CONSTRAINT `ospos_sales_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`); + ADD CONSTRAINT `ospos_sales_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`); -- -- Constraints for table `ospos_sales_suspended` -- ALTER TABLE `ospos_sales_suspended` - ADD CONSTRAINT `ospos_sales_suspended_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`), - ADD CONSTRAINT `ospos_sales_suspended_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`); + ADD CONSTRAINT `ospos_sales_suspended_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `ospos_employees` (`person_id`), + ADD CONSTRAINT `ospos_sales_suspended_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `ospos_customers` (`person_id`); -- -- Constraints for table `ospos_sales_suspended_items` -- ALTER TABLE `ospos_sales_suspended_items` - ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), - ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`), - ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`); + ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), + ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`), + ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`); -- -- Constraints for table `ospos_sales_suspended_items_taxes` -- ALTER TABLE `ospos_sales_suspended_items_taxes` - ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended_items` (`sale_id`), - ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`); + ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended_items` (`sale_id`), + ADD CONSTRAINT `ospos_sales_suspended_items_taxes_ibfk_2` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`); -- -- Constraints for table `ospos_sales_suspended_payments` -- ALTER TABLE `ospos_sales_suspended_payments` - ADD CONSTRAINT `ospos_sales_suspended_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`); + ADD CONSTRAINT `ospos_sales_suspended_payments_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`); -- -- Constraints for table `ospos_item_quantities` -- ALTER TABLE `ospos_item_quantities` - ADD CONSTRAINT `ospos_item_quantities_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), - ADD CONSTRAINT `ospos_item_quantities_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`); + ADD CONSTRAINT `ospos_item_quantities_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `ospos_items` (`item_id`), + ADD CONSTRAINT `ospos_item_quantities_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `ospos_stock_locations` (`location_id`); -- -- Constraints for table `ospos_suppliers` -- ALTER TABLE `ospos_suppliers` - ADD CONSTRAINT `ospos_suppliers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); - + ADD CONSTRAINT `ospos_suppliers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); + -- -- Constraints for table `ospos_giftcards` -- ALTER TABLE `ospos_giftcards` - ADD CONSTRAINT `ospos_giftcards_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); + ADD CONSTRAINT `ospos_giftcards_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`); diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index dc5b4a4ce..ff21fc131 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -195,9 +195,11 @@ CREATE TABLE `ospos_items` ( `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', `item_id` int(10) NOT NULL AUTO_INCREMENT, - `pic_id` int(10) DEFAULT NULL, + `pic_filename` varchar(255) DEFAULT NULL, `allow_alt_description` tinyint(1) NOT NULL, `is_serialized` tinyint(1) NOT NULL, + `stock_type` TINYINT(2) NOT NULL DEFAULT 0, + `item_type` TINYINT(2) NOT NULL DEFAULT 0, `deleted` int(1) NOT NULL DEFAULT '0', `custom1` VARCHAR(25) NOT NULL, `custom2` VARCHAR(25) NOT NULL, @@ -246,6 +248,10 @@ CREATE TABLE `ospos_items_taxes` ( CREATE TABLE `ospos_item_kits` ( `item_kit_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, + `item_id` INT(10) NOT NULL DEFAULT 0, + `kit_discount_percent` DECIMAL(15,2) NOT NULL DEFAULT 0.00, + `price_option` TINYINT(2) NOT NULL DEFAULT 0, + `print_option` TINYINT(2) NOT NULL DEFAULT 0, `description` varchar(255) NOT NULL, PRIMARY KEY (`item_kit_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; @@ -265,6 +271,7 @@ CREATE TABLE `ospos_item_kit_items` ( `item_kit_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, `quantity` decimal(15,3) NOT NULL, + `kit_sequence` INT(3) NOT NULL DEFAULT 0, PRIMARY KEY (`item_kit_id`,`item_id`,`quantity`), KEY `ospos_item_kit_items_ibfk_2` (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -534,6 +541,7 @@ CREATE TABLE `ospos_sales_items` ( `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', `item_location` int(11) NOT NULL, + `print_option` TINYINT(2) NOT NULL DEFAULT 0, PRIMARY KEY (`sale_id`,`item_id`,`line`), KEY `sale_id` (`sale_id`), KEY `item_id` (`item_id`), @@ -626,6 +634,7 @@ CREATE TABLE `ospos_sales_suspended_items` ( `item_unit_price` decimal(15,2) NOT NULL, `discount_percent` decimal(15,2) NOT NULL DEFAULT '0', `item_location` int(11) NOT NULL, + `print_option` TINYINT(2) NOT NULL DEFAULT 0, PRIMARY KEY (`sale_id`,`item_id`,`line`), KEY `sale_id` (`sale_id`), KEY `item_id` (`item_id`) diff --git a/database/tables.sql b/database/tables.sql index 3aa32873b..bcc182bed 100644 --- a/database/tables.sql +++ b/database/tables.sql @@ -195,7 +195,7 @@ CREATE TABLE `ospos_items` ( `reorder_level` decimal(15,3) NOT NULL DEFAULT '0', `receiving_quantity` decimal(15,3) NOT NULL DEFAULT '1', `item_id` int(10) NOT NULL AUTO_INCREMENT, - `pic_id` int(10) DEFAULT NULL, + `pic_filename` varchar(255) DEFAULT NULL, `allow_alt_description` tinyint(1) NOT NULL, `is_serialized` tinyint(1) NOT NULL, `stock_type` TINYINT(2) NOT NULL DEFAULT 0, diff --git a/import_items.csv b/import_items.csv index 6aca1eb9e..1b0f7ed8c 100644 --- a/import_items.csv +++ b/import_items.csv @@ -1,2 +1,2 @@ -UPC/EAN/ISBN,Item Name,Category,Supplier ID,Cost Price,Unit Price,Tax 1 Name,Tax 1 Percent,Tax 2 Name ,Tax 2 Percent,Reorder Level,Description,Allow Alt Description,Item has Serial Number,custom1,custom2,custom3,custom4,custom5,custom6,custom7,custom8,custom9,custom10,location_id,quantity -33333333,Apple iMac,Computers,,800,1200,Tax 1,8,Tax 2,10,1,Best Computer ever,y,,"Oz, Frank",The Bunny and the Hill,"Monkeys,Giraffes,Gorillas",English,New,Apple,,1999,D3lk3jlkjs,Hardbound,1,100 +UPC/EAN/ISBN,Item Name,Category,Supplier ID,Cost Price,Unit Price,Tax 1 Name,Tax 1 Percent,Tax 2 Name ,Tax 2 Percent,Reorder Level,Description,Allow Alt Description,Item has Serial Number,custom1,custom2,custom3,custom4,custom5,custom6,custom7,custom8,custom9,custom10,location_id,quantity,picture filename with extension +33333333,Apple iMac,Computers,,800,1200,Tax 1,8,Tax 2,10,1,Best Computer ever,y,,"Oz, Frank",The Bunny and the Hill,"Monkeys,Giraffes,Gorillas",English,New,Apple,,1999,D3lk3jlkjs,Hardbound,1,100,picture file name (upload by hand)