database.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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. $queries = $pluginSchema->toSql($platform);
  203. foreach ($queries as $query) {
  204. Database::query($query);
  205. }
  206. //Insert data
  207. $paypalTable = Database::get_main_table(BuyCoursesPlugin::TABLE_PAYPAL);
  208. $currencyTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CURRENCY);
  209. $itemTable = Database::get_main_table(BuyCoursesPlugin::TABLE_ITEM);
  210. $saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE);
  211. $commissionTable = Database::get_main_table(BuyCoursesPlugin::TABLE_COMMISSION);
  212. $extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD);
  213. $paypalExtraField = Database::select(
  214. "*",
  215. $extraFieldTable,
  216. [
  217. 'where' => ['variable = ?' => 'paypal']
  218. ],
  219. 'first'
  220. );
  221. if (!$paypalExtraField) {
  222. Database::insert(
  223. $extraFieldTable,
  224. [
  225. 'extra_field_type' => 1,
  226. 'field_type' => 1,
  227. 'variable' => 'paypal',
  228. 'display_text' => 'Paypal',
  229. 'default_value' => '',
  230. 'field_order' => 0,
  231. 'visible' => 1,
  232. 'changeable' => 1,
  233. 'filter' => 0,
  234. 'created_at' => getdate()
  235. ]
  236. );
  237. }
  238. Database::insert(
  239. $paypalTable,
  240. [
  241. 'username' => '',
  242. 'password' => '',
  243. 'signature' => '',
  244. 'sandbox' => true
  245. ]
  246. );
  247. Database::insert(
  248. $commissionTable,
  249. [
  250. 'commission' => 0
  251. ]
  252. );
  253. $currencies = [
  254. ['AD', 'Andorra', 'EUR', 'AND'],
  255. ['AE', 'United Arab Emirates', 'AED', 'ARE'],
  256. ['AF', 'Afghanistan', 'AFN', 'AFG'],
  257. ['AG', 'Antigua and Barbuda', 'XCD', 'ATG'],
  258. ['AI', 'Anguilla', 'XCD', 'AIA'],
  259. ['AL', 'Albania', 'ALL', 'ALB'],
  260. ['AM', 'Armenia', 'AMD', 'ARM'],
  261. ['AO', 'Angola', 'AOA', 'AGO'],
  262. ['AR', 'Argentina', 'ARS', 'ARG'],
  263. ['AS', 'American Samoa', 'USD', 'ASM'],
  264. ['AT', 'Austria', 'EUR', 'AUT'],
  265. ['AU', 'Australia', 'AUD', 'AUS'],
  266. ['AW', 'Aruba', 'AWG', 'ABW'],
  267. ['AX', '&Aring;land', 'EUR', 'ALA'],
  268. ['AZ', 'Azerbaijan', 'AZN', 'AZE'],
  269. ['BA', 'Bosnia and Herzegovina', 'BAM', 'BIH'],
  270. ['BB', 'Barbados', 'BBD', 'BRB'],
  271. ['BD', 'Bangladesh', 'BDT', 'BGD'],
  272. ['BE', 'Belgium', 'EUR', 'BEL'],
  273. ['BF', 'Burkina Faso', 'XOF', 'BFA'],
  274. ['BG', 'Bulgaria', 'BGN', 'BGR'],
  275. ['BH', 'Bahrain', 'BHD', 'BHR'],
  276. ['BI', 'Burundi', 'BIF', 'BDI'],
  277. ['BJ', 'Benin', 'XOF', 'BEN'],
  278. ['BL', 'Saint Barth&eacute;lemy', 'EUR', 'BLM'],
  279. ['BM', 'Bermuda', 'BMD', 'BMU'],
  280. ['BN', 'Brunei', 'BND', 'BRN'],
  281. ['BO', 'Bolivia', 'BOB', 'BOL'],
  282. ['BQ', 'Bonaire', 'USD', 'BES'],
  283. ['BR', 'Brazil', 'BRL', 'BRA'],
  284. ['BS', 'Bahamas', 'BSD', 'BHS'],
  285. ['BT', 'Bhutan', 'BTN', 'BTN'],
  286. ['BV', 'Bouvet Island', 'NOK', 'BVT'],
  287. ['BW', 'Botswana', 'BWP', 'BWA'],
  288. ['BY', 'Belarus', 'BYR', 'BLR'],
  289. ['BZ', 'Belize', 'BZD', 'BLZ'],
  290. ['CA', 'Canada', 'CAD', 'CAN'],
  291. ['CC', 'Cocos [Keeling] Islands', 'AUD', 'CCK'],
  292. ['CD', 'Congo', 'CDF', 'COD'],
  293. ['CF', 'Central African Republic', 'XAF', 'CAF'],
  294. ['CG', 'Republic of the Congo', 'XAF', 'COG'],
  295. ['CH', 'Switzerland', 'CHF', 'CHE'],
  296. ['CI', 'Ivory Coast', 'XOF', 'CIV'],
  297. ['CK', 'Cook Islands', 'NZD', 'COK'],
  298. ['CL', 'Chile', 'CLP', 'CHL'],
  299. ['CM', 'Cameroon', 'XAF', 'CMR'],
  300. ['CN', 'China', 'CNY', 'CHN'],
  301. ['CO', 'Colombia', 'COP', 'COL'],
  302. ['CR', 'Costa Rica', 'CRC', 'CRI'],
  303. ['CU', 'Cuba', 'CUP', 'CUB'],
  304. ['CV', 'Cape Verde', 'CVE', 'CPV'],
  305. ['CW', 'Curacao', 'ANG', 'CUW'],
  306. ['CX', 'Christmas Island', 'AUD', 'CXR'],
  307. ['CY', 'Cyprus', 'EUR', 'CYP'],
  308. ['CZ', 'Czechia', 'CZK', 'CZE'],
  309. ['DE', 'Germany', 'EUR', 'DEU'],
  310. ['DJ', 'Djibouti', 'DJF', 'DJI'],
  311. ['DK', 'Denmark', 'DKK', 'DNK'],
  312. ['DM', 'Dominica', 'XCD', 'DMA'],
  313. ['DO', 'Dominican Republic', 'DOP', 'DOM'],
  314. ['DZ', 'Algeria', 'DZD', 'DZA'],
  315. ['EC', 'Ecuador', 'USD', 'ECU'],
  316. ['EE', 'Estonia', 'EUR', 'EST'],
  317. ['EG', 'Egypt', 'EGP', 'EGY'],
  318. ['EH', 'Western Sahara', 'MAD', 'ESH'],
  319. ['ER', 'Eritrea', 'ERN', 'ERI'],
  320. ['ES', 'Spain', 'EUR', 'ESP'],
  321. ['ET', 'Ethiopia', 'ETB', 'ETH'],
  322. ['FI', 'Finland', 'EUR', 'FIN'],
  323. ['FJ', 'Fiji', 'FJD', 'FJI'],
  324. ['FK', 'Falkland Islands', 'FKP', 'FLK'],
  325. ['FM', 'Micronesia', 'USD', 'FSM'],
  326. ['FO', 'Faroe Islands', 'DKK', 'FRO'],
  327. ['FR', 'France', 'EUR', 'FRA'],
  328. ['GA', 'Gabon', 'XAF', 'GAB'],
  329. ['GB', 'United Kingdom', 'GBP', 'GBR'],
  330. ['GD', 'Grenada', 'XCD', 'GRD'],
  331. ['GE', 'Georgia', 'GEL', 'GEO'],
  332. ['GF', 'French Guiana', 'EUR', 'GUF'],
  333. ['GG', 'Guernsey', 'GBP', 'GGY'],
  334. ['GH', 'Ghana', 'GHS', 'GHA'],
  335. ['GI', 'Gibraltar', 'GIP', 'GIB'],
  336. ['GL', 'Greenland', 'DKK', 'GRL'],
  337. ['GM', 'Gambia', 'GMD', 'GMB'],
  338. ['GN', 'Guinea', 'GNF', 'GIN'],
  339. ['GP', 'Guadeloupe', 'EUR', 'GLP'],
  340. ['GQ', 'Equatorial Guinea', 'XAF', 'GNQ'],
  341. ['GR', 'Greece', 'EUR', 'GRC'],
  342. ['GS', 'South Georgia and the South Sandwich Islands', 'GBP', 'SGS'],
  343. ['GT', 'Guatemala', 'GTQ', 'GTM'],
  344. ['GU', 'Guam', 'USD', 'GUM'],
  345. ['GW', 'Guinea-Bissau', 'XOF', 'GNB'],
  346. ['GY', 'Guyana', 'GYD', 'GUY'],
  347. ['HK', 'Hong Kong', 'HKD', 'HKG'],
  348. ['HM', 'Heard Island and McDonald Islands', 'AUD', 'HMD'],
  349. ['HN', 'Honduras', 'HNL', 'HND'],
  350. ['HR', 'Croatia', 'HRK', 'HRV'],
  351. ['HT', 'Haiti', 'HTG', 'HTI'],
  352. ['HU', 'Hungary', 'HUF', 'HUN'],
  353. ['ID', 'Indonesia', 'IDR', 'IDN'],
  354. ['IE', 'Ireland', 'EUR', 'IRL'],
  355. ['IL', 'Israel', 'ILS', 'ISR'],
  356. ['IM', 'Isle of Man', 'GBP', 'IMN'],
  357. ['IN', 'India', 'INR', 'IND'],
  358. ['IO', 'British Indian Ocean Territory', 'USD', 'IOT'],
  359. ['IQ', 'Iraq', 'IQD', 'IRQ'],
  360. ['IR', 'Iran', 'IRR', 'IRN'],
  361. ['IS', 'Iceland', 'ISK', 'ISL'],
  362. ['IT', 'Italy', 'EUR', 'ITA'],
  363. ['JE', 'Jersey', 'GBP', 'JEY'],
  364. ['JM', 'Jamaica', 'JMD', 'JAM'],
  365. ['JO', 'Jordan', 'JOD', 'JOR'],
  366. ['JP', 'Japan', 'JPY', 'JPN'],
  367. ['KE', 'Kenya', 'KES', 'KEN'],
  368. ['KG', 'Kyrgyzstan', 'KGS', 'KGZ'],
  369. ['KH', 'Cambodia', 'KHR', 'KHM'],
  370. ['KI', 'Kiribati', 'AUD', 'KIR'],
  371. ['KM', 'Comoros', 'KMF', 'COM'],
  372. ['KN', 'Saint Kitts and Nevis', 'XCD', 'KNA'],
  373. ['KP', 'North Korea', 'KPW', 'PRK'],
  374. ['KR', 'South Korea', 'KRW', 'KOR'],
  375. ['KW', 'Kuwait', 'KWD', 'KWT'],
  376. ['KY', 'Cayman Islands', 'KYD', 'CYM'],
  377. ['KZ', 'Kazakhstan', 'KZT', 'KAZ'],
  378. ['LA', 'Laos', 'LAK', 'LAO'],
  379. ['LB', 'Lebanon', 'LBP', 'LBN'],
  380. ['LC', 'Saint Lucia', 'XCD', 'LCA'],
  381. ['LI', 'Liechtenstein', 'CHF', 'LIE'],
  382. ['LK', 'Sri Lanka', 'LKR', 'LKA'],
  383. ['LR', 'Liberia', 'LRD', 'LBR'],
  384. ['LS', 'Lesotho', 'LSL', 'LSO'],
  385. ['LT', 'Lithuania', 'LTL', 'LTU'],
  386. ['LU', 'Luxembourg', 'EUR', 'LUX'],
  387. ['LV', 'Latvia', 'LVL', 'LVA'],
  388. ['LY', 'Libya', 'LYD', 'LBY'],
  389. ['MA', 'Morocco', 'MAD', 'MAR'],
  390. ['MC', 'Monaco', 'EUR', 'MCO'],
  391. ['MD', 'Moldova', 'MDL', 'MDA'],
  392. ['ME', 'Montenegro', 'EUR', 'MNE'],
  393. ['MF', 'Saint Martin', 'EUR', 'MAF'],
  394. ['MG', 'Madagascar', 'MGA', 'MDG'],
  395. ['MH', 'Marshall Islands', 'USD', 'MHL'],
  396. ['MK', 'Macedonia', 'MKD', 'MKD'],
  397. ['ML', 'Mali', 'XOF', 'MLI'],
  398. ['MM', 'Myanmar [Burma]', 'MMK', 'MMR'],
  399. ['MN', 'Mongolia', 'MNT', 'MNG'],
  400. ['MO', 'Macao', 'MOP', 'MAC'],
  401. ['MP', 'Northern Mariana Islands', 'USD', 'MNP'],
  402. ['MQ', 'Martinique', 'EUR', 'MTQ'],
  403. ['MR', 'Mauritania', 'MRO', 'MRT'],
  404. ['MS', 'Montserrat', 'XCD', 'MSR'],
  405. ['MT', 'Malta', 'EUR', 'MLT'],
  406. ['MU', 'Mauritius', 'MUR', 'MUS'],
  407. ['MV', 'Maldives', 'MVR', 'MDV'],
  408. ['MW', 'Malawi', 'MWK', 'MWI'],
  409. ['MX', 'Mexico', 'MXN', 'MEX'],
  410. ['MY', 'Malaysia', 'MYR', 'MYS'],
  411. ['MZ', 'Mozambique', 'MZN', 'MOZ'],
  412. ['NA', 'Namibia', 'NAD', 'NAM'],
  413. ['NC', 'New Caledonia', 'XPF', 'NCL'],
  414. ['NE', 'Niger', 'XOF', 'NER'],
  415. ['NF', 'Norfolk Island', 'AUD', 'NFK'],
  416. ['NG', 'Nigeria', 'NGN', 'NGA'],
  417. ['NI', 'Nicaragua', 'NIO', 'NIC'],
  418. ['NL', 'Netherlands', 'EUR', 'NLD'],
  419. ['NO', 'Norway', 'NOK', 'NOR'],
  420. ['NP', 'Nepal', 'NPR', 'NPL'],
  421. ['NR', 'Nauru', 'AUD', 'NRU'],
  422. ['NU', 'Niue', 'NZD', 'NIU'],
  423. ['NZ', 'New Zealand', 'NZD', 'NZL'],
  424. ['OM', 'Oman', 'OMR', 'OMN'],
  425. ['PA', 'Panama', 'PAB', 'PAN'],
  426. ['PE', 'Peru', 'PEN', 'PER'],
  427. ['PF', 'French Polynesia', 'XPF', 'PYF'],
  428. ['PG', 'Papua New Guinea', 'PGK', 'PNG'],
  429. ['PH', 'Philippines', 'PHP', 'PHL'],
  430. ['PK', 'Pakistan', 'PKR', 'PAK'],
  431. ['PL', 'Poland', 'PLN', 'POL'],
  432. ['PM', 'Saint Pierre and Miquelon', 'EUR', 'SPM'],
  433. ['PN', 'Pitcairn Islands', 'NZD', 'PCN'],
  434. ['PR', 'Puerto Rico', 'USD', 'PRI'],
  435. ['PS', 'Palestine', 'ILS', 'PSE'],
  436. ['PT', 'Portugal', 'EUR', 'PRT'],
  437. ['PW', 'Palau', 'USD', 'PLW'],
  438. ['PY', 'Paraguay', 'PYG', 'PRY'],
  439. ['QA', 'Qatar', 'QAR', 'QAT'],
  440. ['RE', 'R&eacute;union', 'EUR', 'REU'],
  441. ['RO', 'Romania', 'RON', 'ROU'],
  442. ['RS', 'Serbia', 'RSD', 'SRB'],
  443. ['RU', 'Russia', 'RUB', 'RUS'],
  444. ['RW', 'Rwanda', 'RWF', 'RWA'],
  445. ['SA', 'Saudi Arabia', 'SAR', 'SAU'],
  446. ['SB', 'Solomon Islands', 'SBD', 'SLB'],
  447. ['SC', 'Seychelles', 'SCR', 'SYC'],
  448. ['SD', 'Sudan', 'SDG', 'SDN'],
  449. ['SE', 'Sweden', 'SEK', 'SWE'],
  450. ['SG', 'Singapore', 'SGD', 'SGP'],
  451. ['SH', 'Saint Helena', 'SHP', 'SHN'],
  452. ['SI', 'Slovenia', 'EUR', 'SVN'],
  453. ['SJ', 'Svalbard and Jan Mayen', 'NOK', 'SJM'],
  454. ['SK', 'Slovakia', 'EUR', 'SVK'],
  455. ['SL', 'Sierra Leone', 'SLL', 'SLE'],
  456. ['SM', 'San Marino', 'EUR', 'SMR'],
  457. ['SN', 'Senegal', 'XOF', 'SEN'],
  458. ['SO', 'Somalia', 'SOS', 'SOM'],
  459. ['SR', 'Suriname', 'SRD', 'SUR'],
  460. ['SS', 'South Sudan', 'SSP', 'SSD'],
  461. ['ST', 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'STD', 'STP'],
  462. ['SV', 'El Salvador', 'USD', 'SLV'],
  463. ['SX', 'Sint Maarten', 'ANG', 'SXM'],
  464. ['SY', 'Syria', 'SYP', 'SYR'],
  465. ['SZ', 'Swaziland', 'SZL', 'SWZ'],
  466. ['TC', 'Turks and Caicos Islands', 'USD', 'TCA'],
  467. ['TD', 'Chad', 'XAF', 'TCD'],
  468. ['TF', 'French Southern Territories', 'EUR', 'ATF'],
  469. ['TG', 'Togo', 'XOF', 'TGO'],
  470. ['TH', 'Thailand', 'THB', 'THA'],
  471. ['TJ', 'Tajikistan', 'TJS', 'TJK'],
  472. ['TK', 'Tokelau', 'NZD', 'TKL'],
  473. ['TL', 'East Timor', 'USD', 'TLS'],
  474. ['TM', 'Turkmenistan', 'TMT', 'TKM'],
  475. ['TN', 'Tunisia', 'TND', 'TUN'],
  476. ['TO', 'Tonga', 'TOP', 'TON'],
  477. ['TR', 'Turkey', 'TRY', 'TUR'],
  478. ['TT', 'Trinidad and Tobago', 'TTD', 'TTO'],
  479. ['TV', 'Tuvalu', 'AUD', 'TUV'],
  480. ['TW', 'Taiwan', 'TWD', 'TWN'],
  481. ['TZ', 'Tanzania', 'TZS', 'TZA'],
  482. ['UA', 'Ukraine', 'UAH', 'UKR'],
  483. ['UG', 'Uganda', 'UGX', 'UGA'],
  484. ['UM', 'U.S. Minor Outlying Islands', 'USD', 'UMI'],
  485. ['US', 'United States', 'USD', 'USA'],
  486. ['UY', 'Uruguay', 'UYU', 'URY'],
  487. ['UZ', 'Uzbekistan', 'UZS', 'UZB'],
  488. ['VA', 'Vatican City', 'EUR', 'VAT'],
  489. ['VC', 'Saint Vincent and the Grenadines', 'XCD', 'VCT'],
  490. ['VE', 'Venezuela', 'VEF', 'VEN'],
  491. ['VG', 'British Virgin Islands', 'USD', 'VGB'],
  492. ['VI', 'U.S. Virgin Islands', 'USD', 'VIR'],
  493. ['VN', 'Vietnam', 'VND', 'VNM'],
  494. ['VU', 'Vanuatu', 'VUV', 'VUT'],
  495. ['WF', 'Wallis and Futuna', 'XPF', 'WLF'],
  496. ['WS', 'Samoa', 'WST', 'WSM'],
  497. ['XK', 'Kosovo', 'EUR', 'XKX'],
  498. ['YE', 'Yemen', 'YER', 'YEM'],
  499. ['YT', 'Mayotte', 'EUR', 'MYT'],
  500. ['ZA', 'South Africa', 'ZAR', 'ZAF'],
  501. ['ZM', 'Zambia', 'ZMK', 'ZMB'],
  502. ['ZW', 'Zimbabwe', 'ZWL', 'ZWE']
  503. ];
  504. foreach ($currencies as $currency) {
  505. Database::insert(
  506. $currencyTable,
  507. [
  508. 'country_code' => $currency[0],
  509. 'country_name' => $currency[1],
  510. 'iso_code' => $currency[2]
  511. ]
  512. );
  513. }