<?php
if (self::$db_alter->fetch_table_info('dbtech_vbshop_item'))
{
	self::$db_alter->add_field(array(
		'name'       => 'nodisplay',
		'type'       => 'tinyint',
		'length'	 => '1',
		'attributes' => 'unsigned',
		'null'       => false,	// True = NULL, false = NOT NULL
		'default'    => '0'
	));
	self::report('Altered Table', 'dbtech_vbshop_item');
}

if (self::$db_alter->fetch_table_info('dbtech_vbshop_shop'))
{
	self::$db_alter->add_field(array(
		'name'       => 'beneficiary',
		'type'       => 'int',
		'length'	 => '10',
		'null'       => false,	// True = NULL, false = NOT NULL
		'default'    => '-1'
	));
	self::$db_alter->add_field(array(
		'name'       => 'beneficiary_split',
		'type'       => 'tinyint',
		'length'	 => '1',
		'attributes' => 'unsigned',
		'null'       => false,	// True = NULL, false = NOT NULL
		'default'    => '100'
	));
	self::report('Altered Table', 'dbtech_vbshop_shop');
}

if (self::$db_alter->fetch_table_info('dbtech_vbshop_shopinventory'))
{
	self::$db_alter->add_field(array(
		'name'       => 'active',
		'type'       => 'tinyint',
		'length'	 => '1',
		'attributes' => 'unsigned',
		'null'       => false,	// True = NULL, false = NOT NULL
		'default'    => '1'
	));
	self::report('Altered Table', 'dbtech_vbshop_shopinventory');
}

/*
// Add itemtype table
self::$db->query_write("
	CREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX . "dbtech_vbshop_lotteryticket`
	(
		`lotteryticketid` int(10) unsigned NOT NULL AUTO_INCREMENT,
		`lotteryid` int(10) unsigned NOT NULL DEFAULT '0',
		`userid` int(10) unsigned NOT NULL DEFAULT '0',
		`lotterydraw` int(10) unsigned NOT NULL DEFAULT '0',
		`numbers` mediumtext,
		`prizeid` int(10) unsigned NOT NULL DEFAULT '0',
		PRIMARY KEY (`lotteryticketid`),
		KEY `lotteryid` (`lotteryid`,`userid`),
		KEY `lotteryid_2` (`lotteryid`,`lotterydraw`)
	) ENGINE=MyISAM
");
self::report('Created Table', 'dbtech_vbshop_lotteryticket');
 */

if (self::$db_alter->fetch_table_info('dbtech_vbshop_itemtype'))
{
	$lite = array(
		'sticky' 			=> array(
			'title' 		=> 'Sticky Thread',
			'description' 	=> 'Purchase a sticky thread.',
		),
	);
	foreach ($lite as $filename => $info)
	{
		self::$db->query_write("
			REPLACE INTO `" . TABLE_PREFIX . "dbtech_vbshop_itemtype`
				(`itemtypeid`, `title`, `description`, `filename`)
			VALUES (
				" . self::$db->sql_prepare($filename) . ",
				" . self::$db->sql_prepare($info['title']) . ",
				" . self::$db->sql_prepare($info['description']) . ",
				'/dbtech/vbshop/items/" . $filename . ".php'
			)
		");
	}
	
	$pro = array(
		'profilemusic' 	=> array(
			'title' 		=> 'Profile Music',
			'description' 	=> 'Purchase an MP3 player with a custom MP3 file.',
		),
	);
	foreach ($pro as $filename => $info)
	{
		self::$db->query_write("
			REPLACE INTO `" . TABLE_PREFIX . "dbtech_vbshop_itemtype`
				(`itemtypeid`, `title`, `description`, `filename`)
			VALUES (
				" . self::$db->sql_prepare($filename) . ",
				" . self::$db->sql_prepare($info['title']) . ",
				" . self::$db->sql_prepare($info['description']) . ",
				'/dbtech/vbshop_pro/items/" . $filename . ".php'
			)
		");
	}
	self::report('Populated Table', 'dbtech_vbshop_itemtype');
}

if (class_exists('VBSHOP_CACHE'))
{
	VBSHOP_CACHE::build('itemtype');
}