database.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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. $entityManager = Database::getManager();
  15. $pluginSchema = new \Doctrine\DBAL\Schema\Schema();
  16. $connection = $entityManager->getConnection();
  17. $platform = $connection->getDatabasePlatform();
  18. //Create tables
  19. $paypalTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_PAYPAL);
  20. $paypalTable->addColumn(
  21. 'id',
  22. \Doctrine\DBAL\Types\Type::INTEGER,
  23. ['autoincrement' => true, 'unsigned' => true]
  24. );
  25. $paypalTable->addColumn('username', \Doctrine\DBAL\Types\Type::STRING);
  26. $paypalTable->addColumn('password', \Doctrine\DBAL\Types\Type::STRING);
  27. $paypalTable->addColumn('signature', \Doctrine\DBAL\Types\Type::STRING);
  28. $paypalTable->addColumn('sandbox', \Doctrine\DBAL\Types\Type::BOOLEAN);
  29. $paypalTable->setPrimaryKey(['id']);
  30. $transferTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_TRANSFER);
  31. $transferTable->addColumn(
  32. 'id',
  33. \Doctrine\DBAL\Types\Type::INTEGER,
  34. ['autoincrement' => true, 'unsigned' => true]
  35. );
  36. $transferTable->addColumn('name', \Doctrine\DBAL\Types\Type::STRING);
  37. $transferTable->addColumn('account', \Doctrine\DBAL\Types\Type::STRING);
  38. $transferTable->addColumn('swift', \Doctrine\DBAL\Types\Type::STRING);
  39. $transferTable->setPrimaryKey(['id']);
  40. $currencyTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_CURRENCY);
  41. $currencyTable->addColumn(
  42. 'id',
  43. \Doctrine\DBAL\Types\Type::INTEGER,
  44. ['autoincrement' => true, 'unsigned' => true]
  45. );
  46. $currencyTable->addColumn(
  47. 'country_code',
  48. \Doctrine\DBAL\Types\Type::STRING,
  49. ['length' => 2]
  50. );
  51. $currencyTable->addColumn(
  52. 'country_name',
  53. \Doctrine\DBAL\Types\Type::STRING,
  54. ['length' => 255]
  55. );
  56. $currencyTable->addColumn(
  57. 'iso_code',
  58. \Doctrine\DBAL\Types\Type::STRING,
  59. ['length' => 3]
  60. );
  61. $currencyTable->addColumn('status', \Doctrine\DBAL\Types\Type::BOOLEAN);
  62. $currencyTable->addUniqueIndex(['country_code']);
  63. $currencyTable->addIndex(['iso_code']);
  64. $currencyTable->setPrimaryKey(['id']);
  65. $itemTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_ITEM);
  66. $itemTable->addColumn(
  67. 'id',
  68. \Doctrine\DBAL\Types\Type::INTEGER,
  69. ['autoincrement' => true, 'unsigned' => true]
  70. );
  71. $itemTable->addColumn('product_type', \Doctrine\DBAL\Types\Type::INTEGER);
  72. $itemTable->addColumn(
  73. 'product_id',
  74. \Doctrine\DBAL\Types\Type::INTEGER,
  75. ['unsigned' => true]
  76. );
  77. $itemTable->addColumn(
  78. 'price',
  79. \Doctrine\DBAL\Types\Type::DECIMAL,
  80. ['scale' => 2]
  81. );
  82. $itemTable->addColumn(
  83. 'currency_id',
  84. \Doctrine\DBAL\Types\Type::INTEGER,
  85. ['unsigned' => true]
  86. );
  87. $itemTable->setPrimaryKey(['id']);
  88. $itemTable->addForeignKeyConstraint(
  89. $currencyTable,
  90. ['currency_id'],
  91. ['id'],
  92. ['onDelete' => 'CASCADE']
  93. );
  94. $itemBeneficiary = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_ITEM_BENEFICIARY);
  95. $itemBeneficiary->addColumn(
  96. 'id',
  97. \Doctrine\DBAL\Types\Type::INTEGER,
  98. ['autoincrement' => true, 'unsigned' => true]
  99. );
  100. $itemBeneficiary->addColumn(
  101. 'item_id',
  102. \Doctrine\DBAL\Types\Type::INTEGER,
  103. ['unsigned' => true]
  104. );
  105. $itemBeneficiary->addColumn(
  106. 'user_id',
  107. \Doctrine\DBAL\Types\Type::INTEGER,
  108. ['unsigned' => true]
  109. );
  110. $itemBeneficiary->addColumn(
  111. 'commissions',
  112. \Doctrine\DBAL\Types\Type::INTEGER,
  113. ['unsigned' => true]
  114. );
  115. $itemBeneficiary->setPrimaryKey(['id']);
  116. $itemBeneficiary->addForeignKeyConstraint(
  117. $itemTable,
  118. ['item_id'],
  119. ['id'],
  120. ['onDelete' => 'CASCADE']
  121. );
  122. $commissions = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_COMMISSION);
  123. $commissions->addColumn(
  124. 'id',
  125. \Doctrine\DBAL\Types\Type::INTEGER,
  126. ['autoincrement' => true, 'unsigned' => true]
  127. );
  128. $commissions->addColumn(
  129. 'commission',
  130. \Doctrine\DBAL\Types\Type::INTEGER,
  131. ['unsigned' => true]
  132. );
  133. $commissions->setPrimaryKey(['id']);
  134. $saleCommissions = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_PAYPAL_PAYOUTS);
  135. $saleCommissions->addColumn(
  136. 'id',
  137. \Doctrine\DBAL\Types\Type::INTEGER,
  138. ['autoincrement' => true, 'unsigned' => true]
  139. );
  140. $saleCommissions->addColumn('date', \Doctrine\DBAL\Types\Type::DATETIME);
  141. $saleCommissions->addColumn('payout_date', \Doctrine\DBAL\Types\Type::DATETIME);
  142. $saleCommissions->addColumn(
  143. 'sale_id',
  144. \Doctrine\DBAL\Types\Type::INTEGER,
  145. ['unsigned' => true]
  146. );
  147. $saleCommissions->addColumn(
  148. 'user_id',
  149. \Doctrine\DBAL\Types\Type::INTEGER,
  150. ['unsigned' => true]
  151. );
  152. $saleCommissions->addColumn(
  153. 'commission',
  154. \Doctrine\DBAL\Types\Type::DECIMAL,
  155. ['scale' => 2]
  156. );
  157. $saleCommissions->addColumn(
  158. 'status',
  159. \Doctrine\DBAL\Types\Type::INTEGER,
  160. ['unsigned' => true]
  161. );
  162. $saleCommissions->setPrimaryKey(['id']);
  163. $saleTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SALE);
  164. $saleTable->addColumn(
  165. 'id',
  166. \Doctrine\DBAL\Types\Type::INTEGER,
  167. ['autoincrement' => true, 'unsigned' => true]
  168. );
  169. $saleTable->addColumn('reference', \Doctrine\DBAL\Types\Type::STRING);
  170. $saleTable->addColumn('date', \Doctrine\DBAL\Types\Type::DATETIME);
  171. $saleTable->addColumn(
  172. 'user_id',
  173. \Doctrine\DBAL\Types\Type::INTEGER,
  174. ['unsigned' => true]
  175. );
  176. $saleTable->addColumn('product_type', \Doctrine\DBAL\Types\Type::INTEGER);
  177. $saleTable->addColumn('product_name', \Doctrine\DBAL\Types\Type::STRING);
  178. $saleTable->addColumn(
  179. 'product_id',
  180. \Doctrine\DBAL\Types\Type::INTEGER,
  181. ['unsigned' => true]
  182. );
  183. $saleTable->addColumn(
  184. 'price',
  185. \Doctrine\DBAL\Types\Type::DECIMAL,
  186. ['scale' => 2]
  187. );
  188. $saleTable->addColumn(
  189. 'currency_id',
  190. \Doctrine\DBAL\Types\Type::INTEGER,
  191. ['unsigned' => true]
  192. );
  193. $saleTable->addColumn('status', \Doctrine\DBAL\Types\Type::INTEGER);
  194. $saleTable->addColumn('payment_type', \Doctrine\DBAL\Types\Type::INTEGER);
  195. $saleTable->setPrimaryKey(['id']);
  196. $saleTable->addForeignKeyConstraint(
  197. $currencyTable,
  198. ['currency_id'],
  199. ['id'],
  200. ['onDelete' => 'CASCADE']
  201. );
  202. $servicesTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SERVICES);
  203. $servicesTable->addColumn(
  204. 'id',
  205. \Doctrine\DBAL\Types\Type::INTEGER,
  206. ['autoincrement' => true, 'unsigned' => true]
  207. );
  208. $servicesTable->addColumn('name', \Doctrine\DBAL\Types\Type::STRING);
  209. $servicesTable->addColumn('description', \Doctrine\DBAL\Types\Type::TEXT);
  210. $servicesTable->addColumn(
  211. 'price',
  212. \Doctrine\DBAL\Types\Type::DECIMAL,
  213. ['scale' => 2]
  214. );
  215. $servicesTable->addColumn('duration_days', \Doctrine\DBAL\Types\Type::INTEGER);
  216. $servicesTable->addColumn('applies_to', \Doctrine\DBAL\Types\Type::INTEGER);
  217. $servicesTable->addColumn('owner_id', \Doctrine\DBAL\Types\Type::INTEGER);
  218. $servicesTable->addColumn('visibility', \Doctrine\DBAL\Types\Type::INTEGER);
  219. $servicesTable->addColumn('video_url', \Doctrine\DBAL\Types\Type::STRING);
  220. $servicesTable->addColumn('image', \Doctrine\DBAL\Types\Type::STRING);
  221. $servicesTable->addColumn('service_information', \Doctrine\DBAL\Types\Type::TEXT);
  222. $servicesTable->setPrimaryKey(['id']);
  223. $servicesNodeTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_SERVICES_SALE);
  224. $servicesNodeTable->addColumn(
  225. 'id',
  226. \Doctrine\DBAL\Types\Type::INTEGER,
  227. ['autoincrement' => true, 'unsigned' => true]
  228. );
  229. $servicesNodeTable->addColumn(
  230. 'service_id',
  231. \Doctrine\DBAL\Types\Type::INTEGER,
  232. ['unsigned' => true]
  233. );
  234. $servicesNodeTable->addColumn('reference', \Doctrine\DBAL\Types\Type::STRING);
  235. $servicesNodeTable->addColumn('currency_id', \Doctrine\DBAL\Types\Type::INTEGER);
  236. $servicesNodeTable->addColumn(
  237. 'price',
  238. \Doctrine\DBAL\Types\Type::DECIMAL,
  239. ['scale' => 2]
  240. );
  241. $servicesNodeTable->addColumn('node_type', \Doctrine\DBAL\Types\Type::INTEGER);
  242. $servicesNodeTable->addColumn('node_id', \Doctrine\DBAL\Types\Type::INTEGER);
  243. $servicesNodeTable->addColumn('buyer_id', \Doctrine\DBAL\Types\Type::INTEGER);
  244. $servicesNodeTable->addColumn('buy_date', \Doctrine\DBAL\Types\Type::DATETIME);
  245. $servicesNodeTable->addColumn(
  246. 'date_start',
  247. \Doctrine\DBAL\Types\Type::DATETIME,
  248. ['notnull' => false]
  249. );
  250. $servicesNodeTable->addColumn(
  251. 'date_end',
  252. \Doctrine\DBAL\Types\Type::DATETIME
  253. );
  254. $servicesNodeTable->addColumn('status', \Doctrine\DBAL\Types\Type::INTEGER);
  255. $servicesNodeTable->addColumn('payment_type', \Doctrine\DBAL\Types\Type::INTEGER);
  256. $servicesNodeTable->setPrimaryKey(['id']);
  257. $servicesNodeTable->addForeignKeyConstraint(
  258. $servicesTable,
  259. ['service_id'],
  260. ['id'],
  261. ['onDelete' => 'CASCADE']
  262. );
  263. $culqiTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_CULQI);
  264. $culqiTable->addColumn(
  265. 'id',
  266. \Doctrine\DBAL\Types\Type::INTEGER,
  267. ['autoincrement' => true, 'unsigned' => true]
  268. );
  269. $culqiTable->addColumn('commerce_code', \Doctrine\DBAL\Types\Type::STRING);
  270. $culqiTable->addColumn('api_key', \Doctrine\DBAL\Types\Type::STRING);
  271. $culqiTable->addColumn('integration', \Doctrine\DBAL\Types\Type::INTEGER);
  272. $culqiTable->setPrimaryKey(['id']);
  273. $globalTable = $pluginSchema->createTable(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG);
  274. $globalTable->addColumn(
  275. 'id',
  276. \Doctrine\DBAL\Types\Type::INTEGER,
  277. ['autoincrement' => true, 'unsigned' => true]
  278. );
  279. $globalTable->addColumn('terms_and_conditions', \Doctrine\DBAL\Types\Type::TEXT);
  280. $globalTable->setPrimaryKey(['id']);
  281. $queries = $pluginSchema->toSql($platform);
  282. foreach ($queries as $query) {
  283. Database::query($query);
  284. }
  285. //Insert data
  286. $paypalTable = Database::get_main_table(BuyCoursesPlugin::TABLE_PAYPAL);
  287. $currencyTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CURRENCY);
  288. $itemTable = Database::get_main_table(BuyCoursesPlugin::TABLE_ITEM);
  289. $saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE);
  290. $commissionTable = Database::get_main_table(BuyCoursesPlugin::TABLE_COMMISSION);
  291. $extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD);
  292. $culqiTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CULQI);
  293. $globalTable = Database::get_main_table(BuyCoursesPlugin::TABLE_GLOBAL_CONFIG);
  294. $paypalExtraField = Database::select(
  295. "*",
  296. $extraFieldTable,
  297. [
  298. 'where' => ['variable = ?' => 'paypal']
  299. ],
  300. 'first'
  301. );
  302. if (!$paypalExtraField) {
  303. Database::insert(
  304. $extraFieldTable,
  305. [
  306. 'extra_field_type' => 1,
  307. 'field_type' => 1,
  308. 'variable' => 'paypal',
  309. 'display_text' => 'Paypal',
  310. 'default_value' => '',
  311. 'field_order' => 0,
  312. 'visible_to_self' => 1,
  313. 'changeable' => 1,
  314. 'filter' => 0,
  315. 'created_at' => api_get_utc_datetime()
  316. ]
  317. );
  318. }
  319. Database::insert(
  320. $paypalTable,
  321. [
  322. 'username' => '',
  323. 'password' => '',
  324. 'signature' => '',
  325. 'sandbox' => true
  326. ]
  327. );
  328. Database::insert(
  329. $culqiTable,
  330. [
  331. 'commerce_code' => '',
  332. 'api_key' => '',
  333. 'integration' => 1
  334. ]
  335. );
  336. Database::insert(
  337. $globalTable,
  338. [
  339. 'terms_and_conditions' => ''
  340. ]
  341. );
  342. Database::insert(
  343. $commissionTable,
  344. [
  345. 'commission' => 0
  346. ]
  347. );
  348. $currencies = [
  349. ['AD', 'Andorra', 'EUR', 'AND'],
  350. ['AE', 'United Arab Emirates', 'AED', 'ARE'],
  351. ['AF', 'Afghanistan', 'AFN', 'AFG'],
  352. ['AG', 'Antigua and Barbuda', 'XCD', 'ATG'],
  353. ['AI', 'Anguilla', 'XCD', 'AIA'],
  354. ['AL', 'Albania', 'ALL', 'ALB'],
  355. ['AM', 'Armenia', 'AMD', 'ARM'],
  356. ['AO', 'Angola', 'AOA', 'AGO'],
  357. ['AR', 'Argentina', 'ARS', 'ARG'],
  358. ['AS', 'American Samoa', 'USD', 'ASM'],
  359. ['AT', 'Austria', 'EUR', 'AUT'],
  360. ['AU', 'Australia', 'AUD', 'AUS'],
  361. ['AW', 'Aruba', 'AWG', 'ABW'],
  362. ['AX', '&Aring;land', 'EUR', 'ALA'],
  363. ['AZ', 'Azerbaijan', 'AZN', 'AZE'],
  364. ['BA', 'Bosnia and Herzegovina', 'BAM', 'BIH'],
  365. ['BB', 'Barbados', 'BBD', 'BRB'],
  366. ['BD', 'Bangladesh', 'BDT', 'BGD'],
  367. ['BE', 'Belgium', 'EUR', 'BEL'],
  368. ['BF', 'Burkina Faso', 'XOF', 'BFA'],
  369. ['BG', 'Bulgaria', 'BGN', 'BGR'],
  370. ['BH', 'Bahrain', 'BHD', 'BHR'],
  371. ['BI', 'Burundi', 'BIF', 'BDI'],
  372. ['BJ', 'Benin', 'XOF', 'BEN'],
  373. ['BL', 'Saint Barth&eacute;lemy', 'EUR', 'BLM'],
  374. ['BM', 'Bermuda', 'BMD', 'BMU'],
  375. ['BN', 'Brunei', 'BND', 'BRN'],
  376. ['BO', 'Bolivia', 'BOB', 'BOL'],
  377. ['BQ', 'Bonaire', 'USD', 'BES'],
  378. ['BR', 'Brazil', 'BRL', 'BRA'],
  379. ['BS', 'Bahamas', 'BSD', 'BHS'],
  380. ['BT', 'Bhutan', 'BTN', 'BTN'],
  381. ['BV', 'Bouvet Island', 'NOK', 'BVT'],
  382. ['BW', 'Botswana', 'BWP', 'BWA'],
  383. ['BY', 'Belarus', 'BYR', 'BLR'],
  384. ['BZ', 'Belize', 'BZD', 'BLZ'],
  385. ['CA', 'Canada', 'CAD', 'CAN'],
  386. ['CC', 'Cocos [Keeling] Islands', 'AUD', 'CCK'],
  387. ['CD', 'Congo', 'CDF', 'COD'],
  388. ['CF', 'Central African Republic', 'XAF', 'CAF'],
  389. ['CG', 'Republic of the Congo', 'XAF', 'COG'],
  390. ['CH', 'Switzerland', 'CHF', 'CHE'],
  391. ['CI', 'Ivory Coast', 'XOF', 'CIV'],
  392. ['CK', 'Cook Islands', 'NZD', 'COK'],
  393. ['CL', 'Chile', 'CLP', 'CHL'],
  394. ['CM', 'Cameroon', 'XAF', 'CMR'],
  395. ['CN', 'China', 'CNY', 'CHN'],
  396. ['CO', 'Colombia', 'COP', 'COL'],
  397. ['CR', 'Costa Rica', 'CRC', 'CRI'],
  398. ['CU', 'Cuba', 'CUP', 'CUB'],
  399. ['CV', 'Cape Verde', 'CVE', 'CPV'],
  400. ['CW', 'Curacao', 'ANG', 'CUW'],
  401. ['CX', 'Christmas Island', 'AUD', 'CXR'],
  402. ['CY', 'Cyprus', 'EUR', 'CYP'],
  403. ['CZ', 'Czechia', 'CZK', 'CZE'],
  404. ['DE', 'Germany', 'EUR', 'DEU'],
  405. ['DJ', 'Djibouti', 'DJF', 'DJI'],
  406. ['DK', 'Denmark', 'DKK', 'DNK'],
  407. ['DM', 'Dominica', 'XCD', 'DMA'],
  408. ['DO', 'Dominican Republic', 'DOP', 'DOM'],
  409. ['DZ', 'Algeria', 'DZD', 'DZA'],
  410. ['EC', 'Ecuador', 'USD', 'ECU'],
  411. ['EE', 'Estonia', 'EUR', 'EST'],
  412. ['EG', 'Egypt', 'EGP', 'EGY'],
  413. ['EH', 'Western Sahara', 'MAD', 'ESH'],
  414. ['ER', 'Eritrea', 'ERN', 'ERI'],
  415. ['ES', 'Spain', 'EUR', 'ESP'],
  416. ['ET', 'Ethiopia', 'ETB', 'ETH'],
  417. ['FI', 'Finland', 'EUR', 'FIN'],
  418. ['FJ', 'Fiji', 'FJD', 'FJI'],
  419. ['FK', 'Falkland Islands', 'FKP', 'FLK'],
  420. ['FM', 'Micronesia', 'USD', 'FSM'],
  421. ['FO', 'Faroe Islands', 'DKK', 'FRO'],
  422. ['FR', 'France', 'EUR', 'FRA'],
  423. ['GA', 'Gabon', 'XAF', 'GAB'],
  424. ['GB', 'United Kingdom', 'GBP', 'GBR'],
  425. ['GD', 'Grenada', 'XCD', 'GRD'],
  426. ['GE', 'Georgia', 'GEL', 'GEO'],
  427. ['GF', 'French Guiana', 'EUR', 'GUF'],
  428. ['GG', 'Guernsey', 'GBP', 'GGY'],
  429. ['GH', 'Ghana', 'GHS', 'GHA'],
  430. ['GI', 'Gibraltar', 'GIP', 'GIB'],
  431. ['GL', 'Greenland', 'DKK', 'GRL'],
  432. ['GM', 'Gambia', 'GMD', 'GMB'],
  433. ['GN', 'Guinea', 'GNF', 'GIN'],
  434. ['GP', 'Guadeloupe', 'EUR', 'GLP'],
  435. ['GQ', 'Equatorial Guinea', 'XAF', 'GNQ'],
  436. ['GR', 'Greece', 'EUR', 'GRC'],
  437. ['GS', 'South Georgia and the South Sandwich Islands', 'GBP', 'SGS'],
  438. ['GT', 'Guatemala', 'GTQ', 'GTM'],
  439. ['GU', 'Guam', 'USD', 'GUM'],
  440. ['GW', 'Guinea-Bissau', 'XOF', 'GNB'],
  441. ['GY', 'Guyana', 'GYD', 'GUY'],
  442. ['HK', 'Hong Kong', 'HKD', 'HKG'],
  443. ['HM', 'Heard Island and McDonald Islands', 'AUD', 'HMD'],
  444. ['HN', 'Honduras', 'HNL', 'HND'],
  445. ['HR', 'Croatia', 'HRK', 'HRV'],
  446. ['HT', 'Haiti', 'HTG', 'HTI'],
  447. ['HU', 'Hungary', 'HUF', 'HUN'],
  448. ['ID', 'Indonesia', 'IDR', 'IDN'],
  449. ['IE', 'Ireland', 'EUR', 'IRL'],
  450. ['IL', 'Israel', 'ILS', 'ISR'],
  451. ['IM', 'Isle of Man', 'GBP', 'IMN'],
  452. ['IN', 'India', 'INR', 'IND'],
  453. ['IO', 'British Indian Ocean Territory', 'USD', 'IOT'],
  454. ['IQ', 'Iraq', 'IQD', 'IRQ'],
  455. ['IR', 'Iran', 'IRR', 'IRN'],
  456. ['IS', 'Iceland', 'ISK', 'ISL'],
  457. ['IT', 'Italy', 'EUR', 'ITA'],
  458. ['JE', 'Jersey', 'GBP', 'JEY'],
  459. ['JM', 'Jamaica', 'JMD', 'JAM'],
  460. ['JO', 'Jordan', 'JOD', 'JOR'],
  461. ['JP', 'Japan', 'JPY', 'JPN'],
  462. ['KE', 'Kenya', 'KES', 'KEN'],
  463. ['KG', 'Kyrgyzstan', 'KGS', 'KGZ'],
  464. ['KH', 'Cambodia', 'KHR', 'KHM'],
  465. ['KI', 'Kiribati', 'AUD', 'KIR'],
  466. ['KM', 'Comoros', 'KMF', 'COM'],
  467. ['KN', 'Saint Kitts and Nevis', 'XCD', 'KNA'],
  468. ['KP', 'North Korea', 'KPW', 'PRK'],
  469. ['KR', 'South Korea', 'KRW', 'KOR'],
  470. ['KW', 'Kuwait', 'KWD', 'KWT'],
  471. ['KY', 'Cayman Islands', 'KYD', 'CYM'],
  472. ['KZ', 'Kazakhstan', 'KZT', 'KAZ'],
  473. ['LA', 'Laos', 'LAK', 'LAO'],
  474. ['LB', 'Lebanon', 'LBP', 'LBN'],
  475. ['LC', 'Saint Lucia', 'XCD', 'LCA'],
  476. ['LI', 'Liechtenstein', 'CHF', 'LIE'],
  477. ['LK', 'Sri Lanka', 'LKR', 'LKA'],
  478. ['LR', 'Liberia', 'LRD', 'LBR'],
  479. ['LS', 'Lesotho', 'LSL', 'LSO'],
  480. ['LT', 'Lithuania', 'LTL', 'LTU'],
  481. ['LU', 'Luxembourg', 'EUR', 'LUX'],
  482. ['LV', 'Latvia', 'LVL', 'LVA'],
  483. ['LY', 'Libya', 'LYD', 'LBY'],
  484. ['MA', 'Morocco', 'MAD', 'MAR'],
  485. ['MC', 'Monaco', 'EUR', 'MCO'],
  486. ['MD', 'Moldova', 'MDL', 'MDA'],
  487. ['ME', 'Montenegro', 'EUR', 'MNE'],
  488. ['MF', 'Saint Martin', 'EUR', 'MAF'],
  489. ['MG', 'Madagascar', 'MGA', 'MDG'],
  490. ['MH', 'Marshall Islands', 'USD', 'MHL'],
  491. ['MK', 'Macedonia', 'MKD', 'MKD'],
  492. ['ML', 'Mali', 'XOF', 'MLI'],
  493. ['MM', 'Myanmar [Burma]', 'MMK', 'MMR'],
  494. ['MN', 'Mongolia', 'MNT', 'MNG'],
  495. ['MO', 'Macao', 'MOP', 'MAC'],
  496. ['MP', 'Northern Mariana Islands', 'USD', 'MNP'],
  497. ['MQ', 'Martinique', 'EUR', 'MTQ'],
  498. ['MR', 'Mauritania', 'MRO', 'MRT'],
  499. ['MS', 'Montserrat', 'XCD', 'MSR'],
  500. ['MT', 'Malta', 'EUR', 'MLT'],
  501. ['MU', 'Mauritius', 'MUR', 'MUS'],
  502. ['MV', 'Maldives', 'MVR', 'MDV'],
  503. ['MW', 'Malawi', 'MWK', 'MWI'],
  504. ['MX', 'Mexico', 'MXN', 'MEX'],
  505. ['MY', 'Malaysia', 'MYR', 'MYS'],
  506. ['MZ', 'Mozambique', 'MZN', 'MOZ'],
  507. ['NA', 'Namibia', 'NAD', 'NAM'],
  508. ['NC', 'New Caledonia', 'XPF', 'NCL'],
  509. ['NE', 'Niger', 'XOF', 'NER'],
  510. ['NF', 'Norfolk Island', 'AUD', 'NFK'],
  511. ['NG', 'Nigeria', 'NGN', 'NGA'],
  512. ['NI', 'Nicaragua', 'NIO', 'NIC'],
  513. ['NL', 'Netherlands', 'EUR', 'NLD'],
  514. ['NO', 'Norway', 'NOK', 'NOR'],
  515. ['NP', 'Nepal', 'NPR', 'NPL'],
  516. ['NR', 'Nauru', 'AUD', 'NRU'],
  517. ['NU', 'Niue', 'NZD', 'NIU'],
  518. ['NZ', 'New Zealand', 'NZD', 'NZL'],
  519. ['OM', 'Oman', 'OMR', 'OMN'],
  520. ['PA', 'Panama', 'PAB', 'PAN'],
  521. ['PE', 'Peru', 'PEN', 'PER'],
  522. ['PF', 'French Polynesia', 'XPF', 'PYF'],
  523. ['PG', 'Papua New Guinea', 'PGK', 'PNG'],
  524. ['PH', 'Philippines', 'PHP', 'PHL'],
  525. ['PK', 'Pakistan', 'PKR', 'PAK'],
  526. ['PL', 'Poland', 'PLN', 'POL'],
  527. ['PM', 'Saint Pierre and Miquelon', 'EUR', 'SPM'],
  528. ['PN', 'Pitcairn Islands', 'NZD', 'PCN'],
  529. ['PR', 'Puerto Rico', 'USD', 'PRI'],
  530. ['PS', 'Palestine', 'ILS', 'PSE'],
  531. ['PT', 'Portugal', 'EUR', 'PRT'],
  532. ['PW', 'Palau', 'USD', 'PLW'],
  533. ['PY', 'Paraguay', 'PYG', 'PRY'],
  534. ['QA', 'Qatar', 'QAR', 'QAT'],
  535. ['RE', 'R&eacute;union', 'EUR', 'REU'],
  536. ['RO', 'Romania', 'RON', 'ROU'],
  537. ['RS', 'Serbia', 'RSD', 'SRB'],
  538. ['RU', 'Russia', 'RUB', 'RUS'],
  539. ['RW', 'Rwanda', 'RWF', 'RWA'],
  540. ['SA', 'Saudi Arabia', 'SAR', 'SAU'],
  541. ['SB', 'Solomon Islands', 'SBD', 'SLB'],
  542. ['SC', 'Seychelles', 'SCR', 'SYC'],
  543. ['SD', 'Sudan', 'SDG', 'SDN'],
  544. ['SE', 'Sweden', 'SEK', 'SWE'],
  545. ['SG', 'Singapore', 'SGD', 'SGP'],
  546. ['SH', 'Saint Helena', 'SHP', 'SHN'],
  547. ['SI', 'Slovenia', 'EUR', 'SVN'],
  548. ['SJ', 'Svalbard and Jan Mayen', 'NOK', 'SJM'],
  549. ['SK', 'Slovakia', 'EUR', 'SVK'],
  550. ['SL', 'Sierra Leone', 'SLL', 'SLE'],
  551. ['SM', 'San Marino', 'EUR', 'SMR'],
  552. ['SN', 'Senegal', 'XOF', 'SEN'],
  553. ['SO', 'Somalia', 'SOS', 'SOM'],
  554. ['SR', 'Suriname', 'SRD', 'SUR'],
  555. ['SS', 'South Sudan', 'SSP', 'SSD'],
  556. ['ST', 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'STD', 'STP'],
  557. ['SV', 'El Salvador', 'USD', 'SLV'],
  558. ['SX', 'Sint Maarten', 'ANG', 'SXM'],
  559. ['SY', 'Syria', 'SYP', 'SYR'],
  560. ['SZ', 'Swaziland', 'SZL', 'SWZ'],
  561. ['TC', 'Turks and Caicos Islands', 'USD', 'TCA'],
  562. ['TD', 'Chad', 'XAF', 'TCD'],
  563. ['TF', 'French Southern Territories', 'EUR', 'ATF'],
  564. ['TG', 'Togo', 'XOF', 'TGO'],
  565. ['TH', 'Thailand', 'THB', 'THA'],
  566. ['TJ', 'Tajikistan', 'TJS', 'TJK'],
  567. ['TK', 'Tokelau', 'NZD', 'TKL'],
  568. ['TL', 'East Timor', 'USD', 'TLS'],
  569. ['TM', 'Turkmenistan', 'TMT', 'TKM'],
  570. ['TN', 'Tunisia', 'TND', 'TUN'],
  571. ['TO', 'Tonga', 'TOP', 'TON'],
  572. ['TR', 'Turkey', 'TRY', 'TUR'],
  573. ['TT', 'Trinidad and Tobago', 'TTD', 'TTO'],
  574. ['TV', 'Tuvalu', 'AUD', 'TUV'],
  575. ['TW', 'Taiwan', 'TWD', 'TWN'],
  576. ['TZ', 'Tanzania', 'TZS', 'TZA'],
  577. ['UA', 'Ukraine', 'UAH', 'UKR'],
  578. ['UG', 'Uganda', 'UGX', 'UGA'],
  579. ['UM', 'U.S. Minor Outlying Islands', 'USD', 'UMI'],
  580. ['US', 'United States', 'USD', 'USA'],
  581. ['UY', 'Uruguay', 'UYU', 'URY'],
  582. ['UZ', 'Uzbekistan', 'UZS', 'UZB'],
  583. ['VA', 'Vatican City', 'EUR', 'VAT'],
  584. ['VC', 'Saint Vincent and the Grenadines', 'XCD', 'VCT'],
  585. ['VE', 'Venezuela', 'VEF', 'VEN'],
  586. ['VG', 'British Virgin Islands', 'USD', 'VGB'],
  587. ['VI', 'U.S. Virgin Islands', 'USD', 'VIR'],
  588. ['VN', 'Vietnam', 'VND', 'VNM'],
  589. ['VU', 'Vanuatu', 'VUV', 'VUT'],
  590. ['WF', 'Wallis and Futuna', 'XPF', 'WLF'],
  591. ['WS', 'Samoa', 'WST', 'WSM'],
  592. ['XK', 'Kosovo', 'EUR', 'XKX'],
  593. ['YE', 'Yemen', 'YER', 'YEM'],
  594. ['YT', 'Mayotte', 'EUR', 'MYT'],
  595. ['ZA', 'South Africa', 'ZAR', 'ZAF'],
  596. ['ZM', 'Zambia', 'ZMK', 'ZMB'],
  597. ['ZW', 'Zimbabwe', 'ZWL', 'ZWE']
  598. ];
  599. foreach ($currencies as $currency) {
  600. Database::insert(
  601. $currencyTable,
  602. [
  603. 'country_code' => $currency[0],
  604. 'country_name' => $currency[1],
  605. 'iso_code' => $currency[2]
  606. ]
  607. );
  608. }