<?php
$this_file = str_replace( '\\', '/', __FILE__ );
$this_file = explode( 'wp-content', $this_file );
$this_file = $this_file[ 0 ];
		
// required for making tables easier
require_once( $this_file . 'wp-admin/install-helper.php' );
		
// alternative
// require_once( '../../../wp-admin/install-helper.php' );

global $wpdb;
$responded = '';

// deposit history table
// id - increment, order number
// trans_date - date of purchase
// unique_code - unique ID returned by PayPal
// trans_status - approved or declined (returned by PayPal)
// user_name, user_email, user_phone, user_address, user_zip, user_city, user_country - user details
// trans_basket - purchased items
// currency - currency code
$sql_purchases_history = "CREATE TABLE `" . $wpdb->prefix . "purchases_history` (
  `id` int(11) NOT NULL auto_increment,
  `trans_date` datetime NOT NULL,
  `unique_code` varchar(150) NOT NULL,
  `trans_status` varchar(100) NOT NULL,
  `trans_basket` varchar(1500) NOT NULL,
  `user_name` varchar(250) NOT NULL,
  `user_email` varchar(250) NOT NULL,
  `user_phone` varchar(50) NOT NULL,
  `user_address` varchar(250) NOT NULL,
  `user_zip` varchar(50) NOT NULL,
  `user_city` varchar(100) NOT NULL,
  `user_country` varchar(50) NOT NULL,
  `currency` varchar(20) NOT NULL,
  `gross` varchar(20) NOT NULL,
  `flag_shipped` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";

$create_table_purchases_history = maybe_create_table( $wpdb->prefix . 'purchases_history', $sql_purchases_history );

if( $create_table_purchases_history ) $responded .= 'Table "' . $wpdb->prefix . 'purchases_history" successfully installed!<br />';
else $responded .= 'Table "' . $wpdb->prefix . 'purchases_history" NOT installed yet!<br />';

echo $responded;
?>