database.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <?php
  2. /* For license terms, see /license.txt */
  3. /**
  4. * Plugin database installation script. Can only be executed if included
  5. * inside another script loading global.inc.php
  6. * @package chamilo.plugin.buycourses
  7. */
  8. /**
  9. * Check if script can be called
  10. */
  11. if (!function_exists('api_get_path')) {
  12. die('This script must be loaded through the Chamilo plugin installer sequence');
  13. }
  14. /**
  15. * Create the script context, then execute database queries to enable
  16. */
  17. $table = Database::get_main_table(TABLE_BUY_SESSION);
  18. $sql = "CREATE TABLE IF NOT EXISTS $table (
  19. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  20. session_id INT unsigned NOT NULL DEFAULT '0',
  21. name VARCHAR(250),
  22. date_start VARCHAR(40),
  23. date_end VARCHAR(40),
  24. visible int,
  25. price FLOAT(11,2) NOT NULL DEFAULT '0',
  26. sync int)";
  27. Database::query($sql);
  28. $tableSession = Database::get_main_table(TABLE_MAIN_SESSION);
  29. $sql = "SELECT id, name, date_start, date_end FROM $tableSession";
  30. $res = Database::query($sql);
  31. while ($row = Database::fetch_assoc($res)) {
  32. $presql = "INSERT INTO $table (session_id, name, date_start, date_end, visible)
  33. VALUES ('" . $row['id'] . "','" . $row['name'] . "','" . $row['date_start'] . "','" . $row['date_end'] . "','NO')";
  34. Database::query($presql);
  35. }
  36. $table = Database::get_main_table(TABLE_BUY_COURSE);
  37. $sql = "CREATE TABLE IF NOT EXISTS $table (
  38. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  39. session_id INT unsigned NOT NULL DEFAULT 0,
  40. course_id INT unsigned NOT NULL DEFAULT '0',
  41. code VARCHAR(40),
  42. title VARCHAR(250),
  43. visible int,
  44. price FLOAT(11,2) NOT NULL DEFAULT '0',
  45. sync int)";
  46. Database::query($sql);
  47. $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
  48. $sql = "SELECT id, code, title FROM $tableCourse";
  49. $res = Database::query($sql);
  50. while ($row = Database::fetch_assoc($res)) {
  51. $presql = "INSERT INTO $table (course_id, code, title, visible) VALUES ('" . $row['id'] . "','" . $row['code'] . "','" . $row['title'] . "','NO')";
  52. Database::query($presql);
  53. }
  54. $table = Database::get_main_table(TABLE_BUY_SESSION_COURSE);
  55. $sql = "CREATE TABLE IF NOT EXISTS $table (
  56. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  57. id_session SMALLINT(5) unsigned DEFAULT '0',
  58. course_code VARCHAR(40),
  59. nbr_users SMALLINT(5) unsigned DEFAULT '0',
  60. sync int)";
  61. Database::query($sql);
  62. $tableSessionCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
  63. $sql = "SELECT * FROM $tableSessionCourse";
  64. $res = Database::query($sql);
  65. while ($row = Database::fetch_assoc($res)) {
  66. $presql = "INSERT INTO $table (id_session, course_code, nbr_users)
  67. VALUES ('" . $row['id_session'] . "','" . $row['course_code'] . "','" . $row['nbr_users'] . "')";
  68. Database::query($presql);
  69. }
  70. $table = Database::get_main_table(TABLE_BUY_COURSE_COUNTRY);
  71. $sql = "CREATE TABLE IF NOT EXISTS $table (
  72. country_id int NOT NULL AUTO_INCREMENT,
  73. country_code char(2) NOT NULL DEFAULT '',
  74. country_name varchar(45) NOT NULL DEFAULT '',
  75. currency_code char(3) DEFAULT NULL,
  76. iso_alpha3 char(3) DEFAULT NULL,
  77. status int DEFAULT '0',
  78. PRIMARY KEY (country_id)
  79. ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;";
  80. Database::query($sql);
  81. $sql = "CREATE UNIQUE INDEX index_country ON $table (country_code)";
  82. Database::query($sql);
  83. $sql = "INSERT INTO $table (country_code, country_name, currency_code, iso_alpha3) VALUES
  84. ('AD', 'Andorra', 'EUR', 'AND'),
  85. ('AE', 'United Arab Emirates', 'AED', 'ARE'),
  86. ('AF', 'Afghanistan', 'AFN', 'AFG'),
  87. ('AG', 'Antigua and Barbuda', 'XCD', 'ATG'),
  88. ('AI', 'Anguilla', 'XCD', 'AIA'),
  89. ('AL', 'Albania', 'ALL', 'ALB'),
  90. ('AM', 'Armenia', 'AMD', 'ARM'),
  91. ('AO', 'Angola', 'AOA', 'AGO'),
  92. ('AR', 'Argentina', 'ARS', 'ARG'),
  93. ('AS', 'American Samoa', 'USD', 'ASM'),
  94. ('AT', 'Austria', 'EUR', 'AUT'),
  95. ('AU', 'Australia', 'AUD', 'AUS'),
  96. ('AW', 'Aruba', 'AWG', 'ABW'),
  97. ('AX', '&Aring;land', 'EUR', 'ALA'),
  98. ('AZ', 'Azerbaijan', 'AZN', 'AZE'),
  99. ('BA', 'Bosnia and Herzegovina', 'BAM', 'BIH'),
  100. ('BB', 'Barbados', 'BBD', 'BRB'),
  101. ('BD', 'Bangladesh', 'BDT', 'BGD'),
  102. ('BE', 'Belgium', 'EUR', 'BEL'),
  103. ('BF', 'Burkina Faso', 'XOF', 'BFA'),
  104. ('BG', 'Bulgaria', 'BGN', 'BGR'),
  105. ('BH', 'Bahrain', 'BHD', 'BHR'),
  106. ('BI', 'Burundi', 'BIF', 'BDI'),
  107. ('BJ', 'Benin', 'XOF', 'BEN'),
  108. ('BL', 'Saint Barth&eacute;lemy', 'EUR', 'BLM'),
  109. ('BM', 'Bermuda', 'BMD', 'BMU'),
  110. ('BN', 'Brunei', 'BND', 'BRN'),
  111. ('BO', 'Bolivia', 'BOB', 'BOL'),
  112. ('BQ', 'Bonaire', 'USD', 'BES'),
  113. ('BR', 'Brazil', 'BRL', 'BRA'),
  114. ('BS', 'Bahamas', 'BSD', 'BHS'),
  115. ('BT', 'Bhutan', 'BTN', 'BTN'),
  116. ('BV', 'Bouvet Island', 'NOK', 'BVT'),
  117. ('BW', 'Botswana', 'BWP', 'BWA'),
  118. ('BY', 'Belarus', 'BYR', 'BLR'),
  119. ('BZ', 'Belize', 'BZD', 'BLZ'),
  120. ('CA', 'Canada', 'CAD', 'CAN'),
  121. ('CC', 'Cocos [Keeling] Islands', 'AUD', 'CCK'),
  122. ('CD', 'Congo', 'CDF', 'COD'),
  123. ('CF', 'Central African Republic', 'XAF', 'CAF'),
  124. ('CG', 'Republic of the Congo', 'XAF', 'COG'),
  125. ('CH', 'Switzerland', 'CHF', 'CHE'),
  126. ('CI', 'Ivory Coast', 'XOF', 'CIV'),
  127. ('CK', 'Cook Islands', 'NZD', 'COK'),
  128. ('CL', 'Chile', 'CLP', 'CHL'),
  129. ('CM', 'Cameroon', 'XAF', 'CMR'),
  130. ('CN', 'China', 'CNY', 'CHN'),
  131. ('CO', 'Colombia', 'COP', 'COL'),
  132. ('CR', 'Costa Rica', 'CRC', 'CRI'),
  133. ('CU', 'Cuba', 'CUP', 'CUB'),
  134. ('CV', 'Cape Verde', 'CVE', 'CPV'),
  135. ('CW', 'Curacao', 'ANG', 'CUW'),
  136. ('CX', 'Christmas Island', 'AUD', 'CXR'),
  137. ('CY', 'Cyprus', 'EUR', 'CYP'),
  138. ('CZ', 'Czechia', 'CZK', 'CZE'),
  139. ('DE', 'Germany', 'EUR', 'DEU'),
  140. ('DJ', 'Djibouti', 'DJF', 'DJI'),
  141. ('DK', 'Denmark', 'DKK', 'DNK'),
  142. ('DM', 'Dominica', 'XCD', 'DMA'),
  143. ('DO', 'Dominican Republic', 'DOP', 'DOM'),
  144. ('DZ', 'Algeria', 'DZD', 'DZA'),
  145. ('EC', 'Ecuador', 'USD', 'ECU'),
  146. ('EE', 'Estonia', 'EUR', 'EST'),
  147. ('EG', 'Egypt', 'EGP', 'EGY'),
  148. ('EH', 'Western Sahara', 'MAD', 'ESH'),
  149. ('ER', 'Eritrea', 'ERN', 'ERI'),
  150. ('ES', 'Spain', 'EUR', 'ESP'),
  151. ('ET', 'Ethiopia', 'ETB', 'ETH'),
  152. ('FI', 'Finland', 'EUR', 'FIN'),
  153. ('FJ', 'Fiji', 'FJD', 'FJI'),
  154. ('FK', 'Falkland Islands', 'FKP', 'FLK'),
  155. ('FM', 'Micronesia', 'USD', 'FSM'),
  156. ('FO', 'Faroe Islands', 'DKK', 'FRO'),
  157. ('FR', 'France', 'EUR', 'FRA'),
  158. ('GA', 'Gabon', 'XAF', 'GAB'),
  159. ('GB', 'United Kingdom', 'GBP', 'GBR'),
  160. ('GD', 'Grenada', 'XCD', 'GRD'),
  161. ('GE', 'Georgia', 'GEL', 'GEO'),
  162. ('GF', 'French Guiana', 'EUR', 'GUF'),
  163. ('GG', 'Guernsey', 'GBP', 'GGY'),
  164. ('GH', 'Ghana', 'GHS', 'GHA'),
  165. ('GI', 'Gibraltar', 'GIP', 'GIB'),
  166. ('GL', 'Greenland', 'DKK', 'GRL'),
  167. ('GM', 'Gambia', 'GMD', 'GMB'),
  168. ('GN', 'Guinea', 'GNF', 'GIN'),
  169. ('GP', 'Guadeloupe', 'EUR', 'GLP'),
  170. ('GQ', 'Equatorial Guinea', 'XAF', 'GNQ'),
  171. ('GR', 'Greece', 'EUR', 'GRC'),
  172. ('GS', 'South Georgia and the South Sandwich Islands', 'GBP', 'SGS'),
  173. ('GT', 'Guatemala', 'GTQ', 'GTM'),
  174. ('GU', 'Guam', 'USD', 'GUM'),
  175. ('GW', 'Guinea-Bissau', 'XOF', 'GNB'),
  176. ('GY', 'Guyana', 'GYD', 'GUY'),
  177. ('HK', 'Hong Kong', 'HKD', 'HKG'),
  178. ('HM', 'Heard Island and McDonald Islands', 'AUD', 'HMD'),
  179. ('HN', 'Honduras', 'HNL', 'HND'),
  180. ('HR', 'Croatia', 'HRK', 'HRV'),
  181. ('HT', 'Haiti', 'HTG', 'HTI'),
  182. ('HU', 'Hungary', 'HUF', 'HUN'),
  183. ('ID', 'Indonesia', 'IDR', 'IDN'),
  184. ('IE', 'Ireland', 'EUR', 'IRL'),
  185. ('IL', 'Israel', 'ILS', 'ISR'),
  186. ('IM', 'Isle of Man', 'GBP', 'IMN'),
  187. ('IN', 'India', 'INR', 'IND'),
  188. ('IO', 'British Indian Ocean Territory', 'USD', 'IOT'),
  189. ('IQ', 'Iraq', 'IQD', 'IRQ'),
  190. ('IR', 'Iran', 'IRR', 'IRN'),
  191. ('IS', 'Iceland', 'ISK', 'ISL'),
  192. ('IT', 'Italy', 'EUR', 'ITA'),
  193. ('JE', 'Jersey', 'GBP', 'JEY'),
  194. ('JM', 'Jamaica', 'JMD', 'JAM'),
  195. ('JO', 'Jordan', 'JOD', 'JOR'),
  196. ('JP', 'Japan', 'JPY', 'JPN'),
  197. ('KE', 'Kenya', 'KES', 'KEN'),
  198. ('KG', 'Kyrgyzstan', 'KGS', 'KGZ'),
  199. ('KH', 'Cambodia', 'KHR', 'KHM'),
  200. ('KI', 'Kiribati', 'AUD', 'KIR'),
  201. ('KM', 'Comoros', 'KMF', 'COM'),
  202. ('KN', 'Saint Kitts and Nevis', 'XCD', 'KNA'),
  203. ('KP', 'North Korea', 'KPW', 'PRK'),
  204. ('KR', 'South Korea', 'KRW', 'KOR'),
  205. ('KW', 'Kuwait', 'KWD', 'KWT'),
  206. ('KY', 'Cayman Islands', 'KYD', 'CYM'),
  207. ('KZ', 'Kazakhstan', 'KZT', 'KAZ'),
  208. ('LA', 'Laos', 'LAK', 'LAO'),
  209. ('LB', 'Lebanon', 'LBP', 'LBN'),
  210. ('LC', 'Saint Lucia', 'XCD', 'LCA'),
  211. ('LI', 'Liechtenstein', 'CHF', 'LIE'),
  212. ('LK', 'Sri Lanka', 'LKR', 'LKA'),
  213. ('LR', 'Liberia', 'LRD', 'LBR'),
  214. ('LS', 'Lesotho', 'LSL', 'LSO'),
  215. ('LT', 'Lithuania', 'LTL', 'LTU'),
  216. ('LU', 'Luxembourg', 'EUR', 'LUX'),
  217. ('LV', 'Latvia', 'LVL', 'LVA'),
  218. ('LY', 'Libya', 'LYD', 'LBY'),
  219. ('MA', 'Morocco', 'MAD', 'MAR'),
  220. ('MC', 'Monaco', 'EUR', 'MCO'),
  221. ('MD', 'Moldova', 'MDL', 'MDA'),
  222. ('ME', 'Montenegro', 'EUR', 'MNE'),
  223. ('MF', 'Saint Martin', 'EUR', 'MAF'),
  224. ('MG', 'Madagascar', 'MGA', 'MDG'),
  225. ('MH', 'Marshall Islands', 'USD', 'MHL'),
  226. ('MK', 'Macedonia', 'MKD', 'MKD'),
  227. ('ML', 'Mali', 'XOF', 'MLI'),
  228. ('MM', 'Myanmar [Burma]', 'MMK', 'MMR'),
  229. ('MN', 'Mongolia', 'MNT', 'MNG'),
  230. ('MO', 'Macao', 'MOP', 'MAC'),
  231. ('MP', 'Northern Mariana Islands', 'USD', 'MNP'),
  232. ('MQ', 'Martinique', 'EUR', 'MTQ'),
  233. ('MR', 'Mauritania', 'MRO', 'MRT'),
  234. ('MS', 'Montserrat', 'XCD', 'MSR'),
  235. ('MT', 'Malta', 'EUR', 'MLT'),
  236. ('MU', 'Mauritius', 'MUR', 'MUS'),
  237. ('MV', 'Maldives', 'MVR', 'MDV'),
  238. ('MW', 'Malawi', 'MWK', 'MWI'),
  239. ('MX', 'Mexico', 'MXN', 'MEX'),
  240. ('MY', 'Malaysia', 'MYR', 'MYS'),
  241. ('MZ', 'Mozambique', 'MZN', 'MOZ'),
  242. ('NA', 'Namibia', 'NAD', 'NAM'),
  243. ('NC', 'New Caledonia', 'XPF', 'NCL'),
  244. ('NE', 'Niger', 'XOF', 'NER'),
  245. ('NF', 'Norfolk Island', 'AUD', 'NFK'),
  246. ('NG', 'Nigeria', 'NGN', 'NGA'),
  247. ('NI', 'Nicaragua', 'NIO', 'NIC'),
  248. ('NL', 'Netherlands', 'EUR', 'NLD'),
  249. ('NO', 'Norway', 'NOK', 'NOR'),
  250. ('NP', 'Nepal', 'NPR', 'NPL'),
  251. ('NR', 'Nauru', 'AUD', 'NRU'),
  252. ('NU', 'Niue', 'NZD', 'NIU'),
  253. ('NZ', 'New Zealand', 'NZD', 'NZL'),
  254. ('OM', 'Oman', 'OMR', 'OMN'),
  255. ('PA', 'Panama', 'PAB', 'PAN'),
  256. ('PE', 'Peru', 'PEN', 'PER'),
  257. ('PF', 'French Polynesia', 'XPF', 'PYF'),
  258. ('PG', 'Papua New Guinea', 'PGK', 'PNG'),
  259. ('PH', 'Philippines', 'PHP', 'PHL'),
  260. ('PK', 'Pakistan', 'PKR', 'PAK'),
  261. ('PL', 'Poland', 'PLN', 'POL'),
  262. ('PM', 'Saint Pierre and Miquelon', 'EUR', 'SPM'),
  263. ('PN', 'Pitcairn Islands', 'NZD', 'PCN'),
  264. ('PR', 'Puerto Rico', 'USD', 'PRI'),
  265. ('PS', 'Palestine', 'ILS', 'PSE'),
  266. ('PT', 'Portugal', 'EUR', 'PRT'),
  267. ('PW', 'Palau', 'USD', 'PLW'),
  268. ('PY', 'Paraguay', 'PYG', 'PRY'),
  269. ('QA', 'Qatar', 'QAR', 'QAT'),
  270. ('RE', 'R&eacute;union', 'EUR', 'REU'),
  271. ('RO', 'Romania', 'RON', 'ROU'),
  272. ('RS', 'Serbia', 'RSD', 'SRB'),
  273. ('RU', 'Russia', 'RUB', 'RUS'),
  274. ('RW', 'Rwanda', 'RWF', 'RWA'),
  275. ('SA', 'Saudi Arabia', 'SAR', 'SAU'),
  276. ('SB', 'Solomon Islands', 'SBD', 'SLB'),
  277. ('SC', 'Seychelles', 'SCR', 'SYC'),
  278. ('SD', 'Sudan', 'SDG', 'SDN'),
  279. ('SE', 'Sweden', 'SEK', 'SWE'),
  280. ('SG', 'Singapore', 'SGD', 'SGP'),
  281. ('SH', 'Saint Helena', 'SHP', 'SHN'),
  282. ('SI', 'Slovenia', 'EUR', 'SVN'),
  283. ('SJ', 'Svalbard and Jan Mayen', 'NOK', 'SJM'),
  284. ('SK', 'Slovakia', 'EUR', 'SVK'),
  285. ('SL', 'Sierra Leone', 'SLL', 'SLE'),
  286. ('SM', 'San Marino', 'EUR', 'SMR'),
  287. ('SN', 'Senegal', 'XOF', 'SEN'),
  288. ('SO', 'Somalia', 'SOS', 'SOM'),
  289. ('SR', 'Suriname', 'SRD', 'SUR'),
  290. ('SS', 'South Sudan', 'SSP', 'SSD'),
  291. ('ST', 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'STD', 'STP'),
  292. ('SV', 'El Salvador', 'USD', 'SLV'),
  293. ('SX', 'Sint Maarten', 'ANG', 'SXM'),
  294. ('SY', 'Syria', 'SYP', 'SYR'),
  295. ('SZ', 'Swaziland', 'SZL', 'SWZ'),
  296. ('TC', 'Turks and Caicos Islands', 'USD', 'TCA'),
  297. ('TD', 'Chad', 'XAF', 'TCD'),
  298. ('TF', 'French Southern Territories', 'EUR', 'ATF'),
  299. ('TG', 'Togo', 'XOF', 'TGO'),
  300. ('TH', 'Thailand', 'THB', 'THA'),
  301. ('TJ', 'Tajikistan', 'TJS', 'TJK'),
  302. ('TK', 'Tokelau', 'NZD', 'TKL'),
  303. ('TL', 'East Timor', 'USD', 'TLS'),
  304. ('TM', 'Turkmenistan', 'TMT', 'TKM'),
  305. ('TN', 'Tunisia', 'TND', 'TUN'),
  306. ('TO', 'Tonga', 'TOP', 'TON'),
  307. ('TR', 'Turkey', 'TRY', 'TUR'),
  308. ('TT', 'Trinidad and Tobago', 'TTD', 'TTO'),
  309. ('TV', 'Tuvalu', 'AUD', 'TUV'),
  310. ('TW', 'Taiwan', 'TWD', 'TWN'),
  311. ('TZ', 'Tanzania', 'TZS', 'TZA'),
  312. ('UA', 'Ukraine', 'UAH', 'UKR'),
  313. ('UG', 'Uganda', 'UGX', 'UGA'),
  314. ('UM', 'U.S. Minor Outlying Islands', 'USD', 'UMI'),
  315. ('US', 'United States', 'USD', 'USA'),
  316. ('UY', 'Uruguay', 'UYU', 'URY'),
  317. ('UZ', 'Uzbekistan', 'UZS', 'UZB'),
  318. ('VA', 'Vatican City', 'EUR', 'VAT'),
  319. ('VC', 'Saint Vincent and the Grenadines', 'XCD', 'VCT'),
  320. ('VE', 'Venezuela', 'VEF', 'VEN'),
  321. ('VG', 'British Virgin Islands', 'USD', 'VGB'),
  322. ('VI', 'U.S. Virgin Islands', 'USD', 'VIR'),
  323. ('VN', 'Vietnam', 'VND', 'VNM'),
  324. ('VU', 'Vanuatu', 'VUV', 'VUT'),
  325. ('WF', 'Wallis and Futuna', 'XPF', 'WLF'),
  326. ('WS', 'Samoa', 'WST', 'WSM'),
  327. ('XK', 'Kosovo', 'EUR', 'XKX'),
  328. ('YE', 'Yemen', 'YER', 'YEM'),
  329. ('YT', 'Mayotte', 'EUR', 'MYT'),
  330. ('ZA', 'South Africa', 'ZAR', 'ZAF'),
  331. ('ZM', 'Zambia', 'ZMK', 'ZMB'),
  332. ('ZW', 'Zimbabwe', 'ZWL', 'ZWE')";
  333. Database::query($sql);
  334. $table = Database::get_main_table(TABLE_BUY_COURSE_PAYPAL);
  335. $sql = "CREATE TABLE IF NOT EXISTS $table (
  336. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  337. sandbox VARCHAR(5) NOT NULL DEFAULT 'YES',
  338. username VARCHAR(100) NOT NULL DEFAULT '',
  339. password VARCHAR(100) NOT NULL DEFAULT '',
  340. signature VARCHAR(100) NOT NULL DEFAULT '')";
  341. Database::query($sql);
  342. $sql = "INSERT INTO $table (id,username,password,signature) VALUES ('1', 'API_UserName', 'API_Password', 'API_Signature')";
  343. Database::query($sql);
  344. $table = Database::get_main_table(TABLE_BUY_COURSE_TRANSFER);
  345. $sql = "CREATE TABLE IF NOT EXISTS $table (
  346. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  347. name VARCHAR(100) NOT NULL DEFAULT '',
  348. account VARCHAR(100) NOT NULL DEFAULT '',
  349. swift VARCHAR(100) NOT NULL DEFAULT '')";
  350. Database::query($sql);
  351. $table = Database::get_main_table(TABLE_BUY_SESSION_TEMPORARY);
  352. $sql = "CREATE TABLE IF NOT EXISTS $table (
  353. cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
  354. user_id INT unsigned NOT NULL,
  355. name VARCHAR(255) NOT NULL DEFAULT '',
  356. session_id INT unsigned NOT NULL DEFAULT '0',
  357. title VARCHAR(200) NOT NULL DEFAULT '',
  358. reference VARCHAR(20) NOT NULL DEFAULT '',
  359. price FLOAT(11,2) NOT NULL DEFAULT '0',
  360. date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
  361. Database::query($sql);
  362. $table = Database::get_main_table(TABLE_BUY_COURSE_TEMPORAL);
  363. $sql = "CREATE TABLE IF NOT EXISTS $table (
  364. cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
  365. user_id INT unsigned NOT NULL,
  366. name VARCHAR(255) NOT NULL DEFAULT '',
  367. course_code VARCHAR(200) NOT NULL DEFAULT '',
  368. title VARCHAR(200) NOT NULL DEFAULT '',
  369. reference VARCHAR(20) NOT NULL DEFAULT '',
  370. price FLOAT(11,2) NOT NULL DEFAULT '0',
  371. date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
  372. Database::query($sql);
  373. $table = Database::get_main_table(TABLE_BUY_SESSION_SALE);
  374. $sql = "CREATE TABLE IF NOT EXISTS $table (
  375. cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
  376. user_id INT unsigned NOT NULL,
  377. session_id INT unsigned NOT NULL DEFAULT '0',
  378. price FLOAT(11,2) NOT NULL DEFAULT '0',
  379. payment_type VARCHAR(100) NOT NULL DEFAULT '',
  380. status VARCHAR(20) NOT NULL DEFAULT '',
  381. date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
  382. Database::query($sql);
  383. $table = Database::get_main_table(TABLE_BUY_COURSE_SALE);
  384. $sql = "CREATE TABLE IF NOT EXISTS $table (
  385. cod INT unsigned NOT NULL auto_increment PRIMARY KEY,
  386. user_id INT unsigned NOT NULL,
  387. course_code VARCHAR(200) NOT NULL DEFAULT '',
  388. price FLOAT(11,2) NOT NULL DEFAULT '0',
  389. payment_type VARCHAR(100) NOT NULL DEFAULT '',
  390. status VARCHAR(20) NOT NULL DEFAULT '',
  391. date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)";
  392. Database::query($sql);