database.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  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. *
  7. * @package chamilo.plugin.sepe
  8. */
  9. /**
  10. * Check if script can be called.
  11. */
  12. if (!function_exists('api_get_path')) {
  13. die('This script must be loaded through the Chamilo plugin installer sequence');
  14. }
  15. $entityManager = Database::getManager();
  16. $pluginSchema = new \Doctrine\DBAL\Schema\Schema();
  17. $connection = $entityManager->getConnection();
  18. $platform = $connection->getDatabasePlatform();
  19. //Create tables
  20. /* ========== PLUGIN_SEPE_CENTER ========== */
  21. $sepeCenterTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_CENTER);
  22. $sepeCenterTable->addColumn(
  23. 'id',
  24. \Doctrine\DBAL\Types\Type::INTEGER,
  25. ['autoincrement' => true, 'unsigned' => true]
  26. );
  27. $sepeCenterTable->addColumn('center_origin', \Doctrine\DBAL\Types\Type::STRING);
  28. $sepeCenterTable->addColumn('center_code', \Doctrine\DBAL\Types\Type::STRING);
  29. $sepeCenterTable->addColumn('center_name', \Doctrine\DBAL\Types\Type::STRING);
  30. $sepeCenterTable->addColumn('url', \Doctrine\DBAL\Types\Type::STRING);
  31. $sepeCenterTable->addColumn('tracking_url', \Doctrine\DBAL\Types\Type::STRING);
  32. $sepeCenterTable->addColumn('phone', \Doctrine\DBAL\Types\Type::STRING);
  33. $sepeCenterTable->addColumn('mail', \Doctrine\DBAL\Types\Type::STRING);
  34. $sepeCenterTable->setPrimaryKey(['id']);
  35. /* ========== PLUGIN_SEPE_ACTIONS ========== */
  36. $sepeActionsTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_ACTIONS);
  37. $sepeActionsTable->addColumn(
  38. 'id',
  39. \Doctrine\DBAL\Types\Type::INTEGER,
  40. ['autoincrement' => true, 'unsigned' => true]
  41. );
  42. $sepeActionsTable->addColumn(
  43. 'action_origin',
  44. \Doctrine\DBAL\Types\Type::STRING,
  45. ['length' => 2]
  46. );
  47. $sepeActionsTable->addColumn(
  48. 'action_code',
  49. \Doctrine\DBAL\Types\Type::STRING,
  50. ['length' => 30]
  51. );
  52. $sepeActionsTable->addColumn(
  53. 'situation',
  54. \Doctrine\DBAL\Types\Type::STRING,
  55. ['length' => 2]
  56. );
  57. $sepeActionsTable->addColumn(
  58. 'specialty_origin',
  59. \Doctrine\DBAL\Types\Type::STRING,
  60. ['length' => 2]
  61. );
  62. $sepeActionsTable->addColumn(
  63. 'professional_area',
  64. \Doctrine\DBAL\Types\Type::STRING,
  65. ['length' => 4]
  66. );
  67. $sepeActionsTable->addColumn(
  68. 'specialty_code',
  69. \Doctrine\DBAL\Types\Type::STRING,
  70. ['length' => 14]
  71. );
  72. $sepeActionsTable->addColumn(
  73. 'duration',
  74. \Doctrine\DBAL\Types\Type::INTEGER,
  75. ['unsigned' => true]
  76. );
  77. $sepeActionsTable->addColumn('start_date', \Doctrine\DBAL\Types\Type::DATE);
  78. $sepeActionsTable->addColumn('end_date', \Doctrine\DBAL\Types\Type::DATE);
  79. $sepeActionsTable->addColumn(
  80. 'full_itinerary_indicator',
  81. \Doctrine\DBAL\Types\Type::STRING,
  82. ['length' => 2]
  83. );
  84. $sepeActionsTable->addColumn(
  85. 'financing_type',
  86. \Doctrine\DBAL\Types\Type::STRING,
  87. ['length' => 2]
  88. );
  89. $sepeActionsTable->addColumn(
  90. 'attendees_count',
  91. \Doctrine\DBAL\Types\Type::INTEGER,
  92. ['unsigned' => true]
  93. );
  94. $sepeActionsTable->addColumn(
  95. 'action_name',
  96. \Doctrine\DBAL\Types\Type::STRING,
  97. ['length' => 250]
  98. );
  99. $sepeActionsTable->addColumn('global_info', \Doctrine\DBAL\Types\Type::TEXT);
  100. $sepeActionsTable->addColumn('schedule', \Doctrine\DBAL\Types\Type::TEXT);
  101. $sepeActionsTable->addColumn('requirements', \Doctrine\DBAL\Types\Type::TEXT);
  102. $sepeActionsTable->addColumn('contact_action', \Doctrine\DBAL\Types\Type::TEXT);
  103. $sepeActionsTable->setPrimaryKey(['id']);
  104. /* ==========PLUGIN_SEPE_SPECIALTY========== */
  105. $sepeSpecialtyTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_SPECIALTY);
  106. $sepeSpecialtyTable->addColumn(
  107. 'id',
  108. \Doctrine\DBAL\Types\Type::INTEGER,
  109. ['autoincrement' => true, 'unsigned' => true]
  110. );
  111. $sepeSpecialtyTable->addColumn(
  112. 'action_id',
  113. \Doctrine\DBAL\Types\Type::INTEGER,
  114. ['unsigned' => true]
  115. );
  116. $sepeSpecialtyTable->addColumn(
  117. 'specialty_origin',
  118. \Doctrine\DBAL\Types\Type::STRING,
  119. ['length' => 2]
  120. );
  121. $sepeSpecialtyTable->addColumn(
  122. 'professional_area',
  123. \Doctrine\DBAL\Types\Type::STRING,
  124. ['length' => 4]
  125. );
  126. $sepeSpecialtyTable->addColumn(
  127. 'specialty_code',
  128. \Doctrine\DBAL\Types\Type::STRING,
  129. ['length' => 14]
  130. );
  131. $sepeSpecialtyTable->addColumn(
  132. 'center_origin',
  133. \Doctrine\DBAL\Types\Type::STRING,
  134. ['length' => 2]
  135. );
  136. $sepeSpecialtyTable->addColumn(
  137. 'center_code',
  138. \Doctrine\DBAL\Types\Type::STRING,
  139. ['length' => 16]
  140. );
  141. $sepeSpecialtyTable->addColumn('start_date', \Doctrine\DBAL\Types\Type::DATE);
  142. $sepeSpecialtyTable->addColumn('end_date', \Doctrine\DBAL\Types\Type::DATE);
  143. $sepeSpecialtyTable->addColumn(
  144. 'modality_impartition',
  145. \Doctrine\DBAL\Types\Type::STRING,
  146. ['length' => 2]
  147. );
  148. $sepeSpecialtyTable->addColumn(
  149. 'classroom_hours',
  150. \Doctrine\DBAL\Types\Type::INTEGER,
  151. ['unsigned' => true]
  152. );
  153. $sepeSpecialtyTable->addColumn(
  154. 'distance_hours',
  155. \Doctrine\DBAL\Types\Type::INTEGER,
  156. ['unsigned' => true]
  157. );
  158. $sepeSpecialtyTable->addColumn(
  159. 'mornings_participants_number',
  160. \Doctrine\DBAL\Types\Type::INTEGER,
  161. ['unsigned' => true, 'notnull' => false]
  162. );
  163. $sepeSpecialtyTable->addColumn(
  164. 'mornings_access_number',
  165. \Doctrine\DBAL\Types\Type::INTEGER,
  166. ['unsigned' => true, 'notnull' => false]
  167. );
  168. $sepeSpecialtyTable->addColumn(
  169. 'morning_total_duration',
  170. \Doctrine\DBAL\Types\Type::INTEGER,
  171. ['unsigned' => true, 'notnull' => false]
  172. );
  173. $sepeSpecialtyTable->addColumn(
  174. 'afternoon_participants_number',
  175. \Doctrine\DBAL\Types\Type::INTEGER,
  176. ['unsigned' => true, 'notnull' => false]
  177. );
  178. $sepeSpecialtyTable->addColumn(
  179. 'afternoon_access_number',
  180. \Doctrine\DBAL\Types\Type::INTEGER,
  181. ['unsigned' => true, 'notnull' => false]
  182. );
  183. $sepeSpecialtyTable->addColumn(
  184. 'afternoon_total_duration',
  185. \Doctrine\DBAL\Types\Type::INTEGER,
  186. ['unsigned' => true, 'notnull' => false]
  187. );
  188. $sepeSpecialtyTable->addColumn(
  189. 'night_participants_number',
  190. \Doctrine\DBAL\Types\Type::INTEGER,
  191. ['unsigned' => true, 'notnull' => false]
  192. );
  193. $sepeSpecialtyTable->addColumn(
  194. 'night_access_number',
  195. \Doctrine\DBAL\Types\Type::INTEGER,
  196. ['unsigned' => true, 'notnull' => false]
  197. );
  198. $sepeSpecialtyTable->addColumn(
  199. 'night_total_duration',
  200. \Doctrine\DBAL\Types\Type::INTEGER,
  201. ['unsigned' => true, 'notnull' => false]
  202. );
  203. $sepeSpecialtyTable->addColumn(
  204. 'attendees_count',
  205. \Doctrine\DBAL\Types\Type::INTEGER,
  206. ['unsigned' => true, 'notnull' => false]
  207. );
  208. $sepeSpecialtyTable->addColumn(
  209. 'learning_activity_count',
  210. \Doctrine\DBAL\Types\Type::INTEGER,
  211. ['unsigned' => true, 'notnull' => false]
  212. );
  213. $sepeSpecialtyTable->addColumn(
  214. 'attempt_count',
  215. \Doctrine\DBAL\Types\Type::INTEGER,
  216. ['unsigned' => true, 'notnull' => false]
  217. );
  218. $sepeSpecialtyTable->addColumn(
  219. 'evaluation_activity_count',
  220. \Doctrine\DBAL\Types\Type::INTEGER,
  221. ['unsigned' => true, 'notnull' => false]
  222. );
  223. $sepeSpecialtyTable->setPrimaryKey(['id']);
  224. $sepeSpecialtyTable->addForeignKeyConstraint(
  225. $sepeActionsTable,
  226. ['action_id'],
  227. ['id'],
  228. ['onDelete' => 'CASCADE']
  229. );
  230. /* ========== PLUGIN_SEPE_CENTROS ========== */
  231. $sepeCentrosTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_CENTERS);
  232. $sepeCentrosTable->addColumn(
  233. 'id',
  234. \Doctrine\DBAL\Types\Type::INTEGER,
  235. ['autoincrement' => true, 'unsigned' => true]
  236. );
  237. $sepeCentrosTable->addColumn(
  238. 'center_origin',
  239. \Doctrine\DBAL\Types\Type::STRING,
  240. ['length' => 2]
  241. );
  242. $sepeCentrosTable->addColumn(
  243. 'center_code',
  244. \Doctrine\DBAL\Types\Type::STRING,
  245. ['length' => 16]
  246. );
  247. $sepeCentrosTable->setPrimaryKey(['id']);
  248. /* ========== PLUGIN_SEPE_SPECIALTY_CLASSROOM ========== */
  249. $sepeSpecialtyClassroomTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_SPECIALTY_CLASSROOM);
  250. $sepeSpecialtyClassroomTable->addColumn(
  251. 'id',
  252. \Doctrine\DBAL\Types\Type::INTEGER,
  253. ['autoincrement' => true, 'unsigned' => true]
  254. );
  255. $sepeSpecialtyClassroomTable->addColumn(
  256. 'specialty_id',
  257. \Doctrine\DBAL\Types\Type::INTEGER,
  258. ['unsigned' => true]
  259. );
  260. $sepeSpecialtyClassroomTable->addColumn(
  261. 'center_id',
  262. \Doctrine\DBAL\Types\Type::INTEGER,
  263. ['unsigned' => true]
  264. );
  265. $sepeSpecialtyClassroomTable->setPrimaryKey(['id']);
  266. $sepeSpecialtyClassroomTable->addForeignKeyConstraint(
  267. $sepeSpecialtyTable,
  268. ['specialty_id'],
  269. ['id'],
  270. ['onDelete' => 'CASCADE']
  271. );
  272. /* ========== PLUGIN_SEPE_TUTORS ========== */
  273. $sepeTutorsTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_TUTORS);
  274. $sepeTutorsTable->addColumn(
  275. 'id',
  276. \Doctrine\DBAL\Types\Type::INTEGER,
  277. ['autoincrement' => true, 'unsigned' => true]
  278. );
  279. $sepeTutorsTable->addColumn(
  280. 'platform_user_id',
  281. \Doctrine\DBAL\Types\Type::INTEGER,
  282. ['unsigned' => true]
  283. );
  284. $sepeTutorsTable->addColumn(
  285. 'document_type',
  286. \Doctrine\DBAL\Types\Type::STRING,
  287. ['length' => 1]
  288. ); //enum('D','E','U','W','G','H')
  289. $sepeTutorsTable->addColumn(
  290. 'document_number',
  291. \Doctrine\DBAL\Types\Type::STRING,
  292. ['length' => 10]
  293. );
  294. $sepeTutorsTable->addColumn(
  295. 'document_letter',
  296. \Doctrine\DBAL\Types\Type::STRING,
  297. ['length' => 1]
  298. );
  299. $sepeTutorsTable->addColumn(
  300. 'tutor_accreditation',
  301. \Doctrine\DBAL\Types\Type::STRING,
  302. ['length' => 200]
  303. );
  304. $sepeTutorsTable->addColumn(
  305. 'professional_experience',
  306. \Doctrine\DBAL\Types\Type::INTEGER,
  307. ['unsigned' => true]
  308. );
  309. $sepeTutorsTable->addColumn(
  310. 'teaching_competence',
  311. \Doctrine\DBAL\Types\Type::STRING,
  312. ['length' => 2]
  313. );
  314. $sepeTutorsTable->addColumn(
  315. 'experience_teleforming',
  316. \Doctrine\DBAL\Types\Type::INTEGER,
  317. ['unsigned' => true]
  318. );
  319. $sepeTutorsTable->addColumn(
  320. 'training_teleforming',
  321. \Doctrine\DBAL\Types\Type::STRING,
  322. ['length' => 2]
  323. );
  324. $sepeTutorsTable->setPrimaryKey(['id']);
  325. /* ========== PLUGIN_SEPE_SPECIALTY_TUTORS ========== */
  326. $sepeSpecialtyTutorsTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_SPECIALTY_TUTORS);
  327. $sepeSpecialtyTutorsTable->addColumn(
  328. 'id',
  329. \Doctrine\DBAL\Types\Type::INTEGER,
  330. ['autoincrement' => true, 'unsigned' => true]
  331. );
  332. $sepeSpecialtyTutorsTable->addColumn(
  333. 'specialty_id',
  334. \Doctrine\DBAL\Types\Type::INTEGER,
  335. ['unsigned' => true]
  336. );
  337. $sepeSpecialtyTutorsTable->addColumn(
  338. 'tutor_id',
  339. \Doctrine\DBAL\Types\Type::INTEGER,
  340. ['unsigned' => true]
  341. );
  342. $sepeSpecialtyTutorsTable->addColumn(
  343. 'tutor_accreditation',
  344. \Doctrine\DBAL\Types\Type::STRING,
  345. ['length' => 200]
  346. );
  347. $sepeSpecialtyTutorsTable->addColumn(
  348. 'professional_experience',
  349. \Doctrine\DBAL\Types\Type::INTEGER,
  350. ['unsigned' => true]
  351. );
  352. $sepeSpecialtyTutorsTable->addColumn(
  353. 'teaching_competence',
  354. \Doctrine\DBAL\Types\Type::STRING,
  355. ['length' => 2]
  356. );
  357. $sepeSpecialtyTutorsTable->addColumn(
  358. 'experience_teleforming',
  359. \Doctrine\DBAL\Types\Type::INTEGER,
  360. ['unsigned' => true]
  361. );
  362. $sepeSpecialtyTutorsTable->addColumn(
  363. 'training_teleforming',
  364. \Doctrine\DBAL\Types\Type::STRING,
  365. ['length' => 2]
  366. );
  367. $sepeSpecialtyTutorsTable->setPrimaryKey(['id']);
  368. $sepeSpecialtyTutorsTable->addForeignKeyConstraint(
  369. $sepeSpecialtyTable,
  370. ['specialty_id'],
  371. ['id'],
  372. ['onDelete' => 'CASCADE']
  373. );
  374. /* ========== PLUGIN_SEPE_TUTORS_EMPRESA ========== */
  375. $sepeTutorsCompanyTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_TUTORS_COMPANY);
  376. $sepeTutorsCompanyTable->addColumn(
  377. 'id',
  378. \Doctrine\DBAL\Types\Type::INTEGER,
  379. ['autoincrement' => true, 'unsigned' => true]
  380. );
  381. $sepeTutorsCompanyTable->addColumn(
  382. 'alias',
  383. \Doctrine\DBAL\Types\Type::STRING,
  384. ['length' => 255]
  385. );
  386. $sepeTutorsCompanyTable->addColumn(
  387. 'document_type',
  388. \Doctrine\DBAL\Types\Type::STRING,
  389. ['length' => 1, 'notnull' => false]
  390. ); //enum('D','E','U','W','G','H')
  391. $sepeTutorsCompanyTable->addColumn(
  392. 'document_number',
  393. \Doctrine\DBAL\Types\Type::STRING,
  394. ['length' => 10, 'notnull' => false]
  395. );
  396. $sepeTutorsCompanyTable->addColumn(
  397. 'document_letter',
  398. \Doctrine\DBAL\Types\Type::STRING,
  399. ['length' => 1, 'notnull' => false]
  400. );
  401. $sepeTutorsCompanyTable->addColumn(
  402. 'company',
  403. \Doctrine\DBAL\Types\Type::STRING,
  404. ['length' => 2]
  405. );
  406. $sepeTutorsCompanyTable->addColumn(
  407. 'training',
  408. \Doctrine\DBAL\Types\Type::STRING,
  409. ['length' => 2]
  410. );
  411. $sepeTutorsCompanyTable->setPrimaryKey(['id']);
  412. /* ========== PLUGIN_SEPE_PARTICIPANTS ========== */
  413. $sepeParticipantsTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_PARTICIPANTS);
  414. $sepeParticipantsTable->addColumn(
  415. 'id',
  416. \Doctrine\DBAL\Types\Type::INTEGER,
  417. ['autoincrement' => true, 'unsigned' => true]
  418. );
  419. $sepeParticipantsTable->addColumn(
  420. 'action_id',
  421. \Doctrine\DBAL\Types\Type::INTEGER,
  422. ['unsigned' => true]
  423. );
  424. $sepeParticipantsTable->addColumn(
  425. 'platform_user_id',
  426. \Doctrine\DBAL\Types\Type::INTEGER,
  427. ['unsigned' => true]
  428. );
  429. $sepeParticipantsTable->addColumn(
  430. 'document_type',
  431. \Doctrine\DBAL\Types\Type::STRING,
  432. ['length' => 1]
  433. ); //enum('D','E','U','W','G','H')
  434. $sepeParticipantsTable->addColumn(
  435. 'document_number',
  436. \Doctrine\DBAL\Types\Type::STRING,
  437. ['length' => 10]
  438. );
  439. $sepeParticipantsTable->addColumn(
  440. 'document_letter',
  441. \Doctrine\DBAL\Types\Type::STRING,
  442. ['length' => 1]
  443. );
  444. $sepeParticipantsTable->addColumn(
  445. 'key_competence',
  446. \Doctrine\DBAL\Types\Type::STRING,
  447. ['length' => 2]
  448. );
  449. $sepeParticipantsTable->addColumn(
  450. 'contract_id',
  451. \Doctrine\DBAL\Types\Type::STRING,
  452. ['length' => 14, 'notnull' => false]
  453. );
  454. $sepeParticipantsTable->addColumn(
  455. 'company_fiscal_number',
  456. \Doctrine\DBAL\Types\Type::STRING,
  457. ['length' => 9, 'notnull' => false]
  458. );
  459. $sepeParticipantsTable->addColumn(
  460. 'company_tutor_id',
  461. \Doctrine\DBAL\Types\Type::INTEGER,
  462. ['unsigned' => true, 'notnull' => false]
  463. );
  464. $sepeParticipantsTable->addColumn(
  465. 'training_tutor_id',
  466. \Doctrine\DBAL\Types\Type::INTEGER,
  467. ['unsigned' => true, 'notnull' => false]
  468. );
  469. $sepeParticipantsTable->setPrimaryKey(['id']);
  470. $sepeParticipantsTable->addForeignKeyConstraint(
  471. $sepeActionsTable,
  472. ['action_id'],
  473. ['id'],
  474. ['onDelete' => 'CASCADE']
  475. );
  476. $sepeParticipantsTable->addForeignKeyConstraint(
  477. $sepeTutorsCompanyTable,
  478. ['company_tutor_id'],
  479. ['id'],
  480. ['onDelete' => 'CASCADE']
  481. );
  482. $sepeParticipantsTable->addForeignKeyConstraint(
  483. $sepeTutorsCompanyTable,
  484. ['training_tutor_id'],
  485. ['id'],
  486. ['onDelete' => 'CASCADE']
  487. );
  488. /* ========== PLUGIN_SEPE_PARTICIPANTS_SPECIALTY ========== */
  489. $sepeParticipantsSpecialtyTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_PARTICIPANTS_SPECIALTY);
  490. $sepeParticipantsSpecialtyTable->addColumn(
  491. 'id',
  492. \Doctrine\DBAL\Types\Type::INTEGER,
  493. ['autoincrement' => true, 'unsigned' => true]
  494. );
  495. $sepeParticipantsSpecialtyTable->addColumn(
  496. 'participant_id',
  497. \Doctrine\DBAL\Types\Type::INTEGER,
  498. ['unsigned' => true]
  499. );
  500. $sepeParticipantsSpecialtyTable->addColumn(
  501. 'specialty_origin',
  502. \Doctrine\DBAL\Types\Type::STRING,
  503. ['length' => 2, 'notnull' => false]
  504. );
  505. $sepeParticipantsSpecialtyTable->addColumn(
  506. 'professional_area',
  507. \Doctrine\DBAL\Types\Type::STRING,
  508. ['length' => 4, 'notnull' => false]
  509. );
  510. $sepeParticipantsSpecialtyTable->addColumn(
  511. 'specialty_code',
  512. \Doctrine\DBAL\Types\Type::STRING,
  513. ['length' => 14, 'notnull' => false]
  514. );
  515. $sepeParticipantsSpecialtyTable->addColumn(
  516. 'registration_date',
  517. \Doctrine\DBAL\Types\Type::DATE,
  518. ['notnull' => false]
  519. );
  520. $sepeParticipantsSpecialtyTable->addColumn(
  521. 'leaving_date',
  522. \Doctrine\DBAL\Types\Type::DATE,
  523. ['notnull' => false]
  524. );
  525. $sepeParticipantsSpecialtyTable->addColumn(
  526. 'center_origin',
  527. \Doctrine\DBAL\Types\Type::STRING,
  528. ['length' => 2, 'notnull' => false]
  529. );
  530. $sepeParticipantsSpecialtyTable->addColumn(
  531. 'center_code',
  532. \Doctrine\DBAL\Types\Type::STRING,
  533. ['length' => 16, 'notnull' => false]
  534. );
  535. $sepeParticipantsSpecialtyTable->addColumn(
  536. 'start_date',
  537. \Doctrine\DBAL\Types\Type::DATE,
  538. ['notnull' => false]
  539. );
  540. $sepeParticipantsSpecialtyTable->addColumn(
  541. 'end_date',
  542. \Doctrine\DBAL\Types\Type::DATE,
  543. ['notnull' => false]
  544. );
  545. $sepeParticipantsSpecialtyTable->addColumn(
  546. 'final_result',
  547. \Doctrine\DBAL\Types\Type::STRING,
  548. ['length' => 1, 'notnull' => false]
  549. );
  550. $sepeParticipantsSpecialtyTable->addColumn(
  551. 'final_qualification',
  552. \Doctrine\DBAL\Types\Type::STRING,
  553. ['length' => 4, 'notnull' => false]
  554. );
  555. $sepeParticipantsSpecialtyTable->addColumn(
  556. 'final_score',
  557. \Doctrine\DBAL\Types\Type::STRING,
  558. ['length' => 4, 'notnull' => false]
  559. );
  560. $sepeParticipantsSpecialtyTable->setPrimaryKey(['id']);
  561. $sepeParticipantsSpecialtyTable->addForeignKeyConstraint(
  562. $sepeParticipantsTable,
  563. ['participant_id'],
  564. ['id'],
  565. ['onDelete' => 'CASCADE']
  566. );
  567. /* ========== PLUGIN_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS ========== */
  568. $sepeParticipantsSpecialtyTutorialsTable = $pluginSchema->createTable(
  569. SepePlugin::TABLE_SEPE_PARTICIPANTS_SPECIALTY_TUTORIALS
  570. );
  571. $sepeParticipantsSpecialtyTutorialsTable->addColumn(
  572. 'id',
  573. \Doctrine\DBAL\Types\Type::INTEGER,
  574. ['autoincrement' => true, 'unsigned' => true]
  575. );
  576. $sepeParticipantsSpecialtyTutorialsTable->addColumn(
  577. 'participant_specialty_id',
  578. \Doctrine\DBAL\Types\Type::INTEGER,
  579. ['unsigned' => true]
  580. );
  581. $sepeParticipantsSpecialtyTutorialsTable->addColumn(
  582. 'center_origin',
  583. \Doctrine\DBAL\Types\Type::STRING,
  584. ['length' => 2]
  585. );
  586. $sepeParticipantsSpecialtyTutorialsTable->addColumn(
  587. 'center_code',
  588. \Doctrine\DBAL\Types\Type::STRING,
  589. ['length' => 16]
  590. );
  591. $sepeParticipantsSpecialtyTutorialsTable->addColumn('start_date', \Doctrine\DBAL\Types\Type::DATE);
  592. $sepeParticipantsSpecialtyTutorialsTable->addColumn('end_date', \Doctrine\DBAL\Types\Type::DATE);
  593. $sepeParticipantsSpecialtyTutorialsTable->setPrimaryKey(['id']);
  594. $sepeParticipantsSpecialtyTutorialsTable->addForeignKeyConstraint(
  595. $sepeParticipantsSpecialtyTable,
  596. ['participant_specialty_id'],
  597. ['id'],
  598. ['onDelete' => 'CASCADE']
  599. );
  600. /* ========== PLUGIN_SEPE_COURSE_ACTIONS ========== */
  601. $sepeCourseActionsTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_COURSE_ACTIONS);
  602. $sepeCourseActionsTable->addColumn(
  603. 'id',
  604. \Doctrine\DBAL\Types\Type::INTEGER,
  605. ['autoincrement' => true, 'unsigned' => true]
  606. );
  607. $sepeCourseActionsTable->addColumn(
  608. 'course_id',
  609. \Doctrine\DBAL\Types\Type::INTEGER,
  610. ['unsigned' => true]
  611. );
  612. $sepeCourseActionsTable->addColumn(
  613. 'action_id',
  614. \Doctrine\DBAL\Types\Type::INTEGER,
  615. ['unsigned' => true]
  616. );
  617. $sepeCourseActionsTable->setPrimaryKey(['id']);
  618. $sepeCourseActionsTable->addForeignKeyConstraint(
  619. $sepeActionsTable,
  620. ['action_id'],
  621. ['id'],
  622. ['onDelete' => 'CASCADE']
  623. );
  624. /* ========== PLUGIN_SEPE_TEACHING_COMPETENCE ========== */
  625. $sepeTeachingCompetenceTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_TEACHING_COMPETENCE);
  626. $sepeTeachingCompetenceTable->addColumn(
  627. 'id',
  628. \Doctrine\DBAL\Types\Type::INTEGER,
  629. ['autoincrement' => true, 'unsigned' => true]
  630. );
  631. $sepeTeachingCompetenceTable->addColumn(
  632. 'code',
  633. \Doctrine\DBAL\Types\Type::STRING,
  634. ['length' => 2]
  635. );
  636. $sepeTeachingCompetenceTable->addColumn('value', \Doctrine\DBAL\Types\Type::TEXT);
  637. $sepeTeachingCompetenceTable->setPrimaryKey(['id']);
  638. /* ========== PLUGIN_SEPE_LOG_PARTICIPANT ========== */
  639. $sepeLogParticipantTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_LOG_PARTICIPANT);
  640. $sepeLogParticipantTable->addColumn(
  641. 'id',
  642. \Doctrine\DBAL\Types\Type::INTEGER,
  643. ['autoincrement' => true, 'unsigned' => true]
  644. );
  645. $sepeLogParticipantTable->addColumn(
  646. 'platform_user_id',
  647. \Doctrine\DBAL\Types\Type::INTEGER,
  648. ['unsigned' => true]
  649. );
  650. $sepeLogParticipantTable->addColumn(
  651. 'action_id',
  652. \Doctrine\DBAL\Types\Type::INTEGER,
  653. ['unsigned' => true]
  654. );
  655. $sepeLogParticipantTable->addColumn('registration_date', \Doctrine\DBAL\Types\Type::DATETIME);
  656. $sepeLogParticipantTable->addColumn('leaving_date', \Doctrine\DBAL\Types\Type::DATETIME);
  657. $sepeLogParticipantTable->setPrimaryKey(['id']);
  658. /* ========== PLUGIN_SEPE_LOG_MOD_PARTICIPANT ========== */
  659. $sepeLogModParticipantTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_LOG_MOD_PARTICIPANT);
  660. $sepeLogModParticipantTable->addColumn(
  661. 'id',
  662. \Doctrine\DBAL\Types\Type::INTEGER,
  663. ['autoincrement' => true, 'unsigned' => true]
  664. );
  665. $sepeLogModParticipantTable->addColumn(
  666. 'platform_user_id',
  667. \Doctrine\DBAL\Types\Type::INTEGER,
  668. ['unsigned' => true]
  669. );
  670. $sepeLogModParticipantTable->addColumn(
  671. 'action_id',
  672. \Doctrine\DBAL\Types\Type::INTEGER,
  673. ['unsigned' => true]
  674. );
  675. $sepeLogModParticipantTable->addColumn('change_date', \Doctrine\DBAL\Types\Type::DATETIME);
  676. $sepeLogModParticipantTable->setPrimaryKey(['id']);
  677. /* ==========PLUGIN_SEPE_LOG ========== */
  678. $sepeLogTable = $pluginSchema->createTable(SepePlugin::TABLE_SEPE_LOG);
  679. $sepeLogTable->addColumn(
  680. 'id',
  681. \Doctrine\DBAL\Types\Type::INTEGER,
  682. ['autoincrement' => true, 'unsigned' => true]
  683. );
  684. $sepeLogTable->addColumn(
  685. 'ip',
  686. \Doctrine\DBAL\Types\Type::STRING,
  687. ['length' => 200]
  688. );
  689. $sepeLogTable->addColumn(
  690. 'action',
  691. \Doctrine\DBAL\Types\Type::STRING,
  692. ['length' => 255]
  693. );
  694. $sepeLogTable->addColumn('date', \Doctrine\DBAL\Types\Type::DATETIME);
  695. $sepeLogTable->setPrimaryKey(['id']);
  696. $queries = $pluginSchema->toSql($platform);
  697. foreach ($queries as $query) {
  698. Database::query($query);
  699. }
  700. //Insert data
  701. $sepeTeachingCompetenceTable = Database::get_main_table(SepePlugin::TABLE_SEPE_TEACHING_COMPETENCE);
  702. $competences = [
  703. [
  704. 1,
  705. '01',
  706. 'Certificado de profesionalidad de docencia de la formación profesional para el empleo regulado por Real Decreto 1697/2011, de 18 de noviembre.',
  707. ],
  708. [2, '02', 'Certificado de profesionalidad de formador ocupacional.'],
  709. [
  710. 3,
  711. '03',
  712. 'Certificado de Aptitud Pedagógica o título profesional de Especialización Didáctica o Certificado de Cualificación Pedagógica.',
  713. ],
  714. [
  715. 4,
  716. '04',
  717. 'Máster Universitario habilitante para el ejercicio de las Profesiones reguladas de Profesor de Educación Secundaria Obligatoria y Bachillerato, Formación Profesional y Escuelas Oficiales de Idiomas.',
  718. ],
  719. [
  720. 5,
  721. '05',
  722. 'Curso de formación equivalente a la formación pedagógica y didáctica exigida para aquellas personas que, estando en posesion de una titulación declarada equivalente a efectos de docencia, no pueden realizar los estudios de máster, establecida en la disposición adicional primera del Real Decreto 1834/2008, de 8 de noviembre.',
  723. ],
  724. [
  725. 6,
  726. '06',
  727. 'Experiencia docente contrastada de al menos 600 horas de impartición de acciones formativas de formación profesional para el empleo o del sistema educativo en modalidad presencial, en los últimos diez años.',
  728. ],
  729. ];
  730. foreach ($competences as $competence) {
  731. Database::insert(
  732. $sepeTeachingCompetenceTable,
  733. [
  734. 'id' => $competence[0],
  735. 'code' => $competence[1],
  736. 'value' => $competence[2],
  737. ]
  738. );
  739. }
  740. $sepeTutorsCompanyTable = Database::get_main_table(SepePlugin::TABLE_SEPE_TUTORS_COMPANY);
  741. Database::insert(
  742. $sepeTutorsCompanyTable,
  743. [
  744. 'id' => 1,
  745. 'alias' => 'Sin tutor',
  746. 'company' => 'SI',
  747. 'training' => 'SI',
  748. ]
  749. );
  750. /* Create extra fields for platform users */
  751. $fieldlabel = 'sexo';
  752. $fieldtype = '3';
  753. $fieldtitle = 'Género';
  754. $fielddefault = '';
  755. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  756. $sql = "INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES ('".$field_id."', 'Hombre', 'Hombre',1);";
  757. Database::query($sql);
  758. $sql = "INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES ('".$field_id."', 'Mujer', 'Mujer',2);";
  759. Database::query($sql);
  760. $sql = "INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES ('".$field_id."', 'Otros', 'Otros',3);";
  761. Database::query($sql);
  762. $fieldlabel = 'edad';
  763. $fieldtype = '6';
  764. $fieldtitle = 'Fecha de nacimiento';
  765. $fielddefault = '';
  766. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  767. $fieldlabel = 'nivel_formativo';
  768. $fieldtype = '1';
  769. $fieldtitle = 'Nivel formativo';
  770. $fielddefault = '';
  771. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  772. $fieldlabel = 'situacion_laboral';
  773. $fieldtype = '1';
  774. $fieldtitle = 'Situación Laboral';
  775. $fielddefault = '';
  776. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  777. $fieldlabel = 'provincia_residencia';
  778. $fieldtype = '4';
  779. $fieldtitle = 'Provincia Residencia';
  780. $fielddefault = '';
  781. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  782. $provinces = 'Albacete;Alicante/Alacant;Almería;Araba/Álava;Asturias;Ávila;Badajoz;Balears, Illes;Barcelona;Bizkaia;Burgos;Cáceres;Cádiz;Cantabria;Castellón/Castelló;Ciudad Real;Córdoba;Coruña, A;Cuenca;Gipuzkoa;Girona;Granada;Guadalajara;Huelva;Huesca;Jaén;León;Lleida;Lugo;Madrid;Málaga;Murcia;Navarra;Ourense;Palencia;Palmas, Las;Pontevedr;Rioja, La;Salamanca;Santa Cruz de Tenerife;Segovia;Sevilla;Soria;Tarragona;Teruel;Toledo;Valencia/Valéncia;Valladolid;Zamora;Zaragoza;Ceuta;Melilla';
  783. $list_provinces = explode(';', $provinces);
  784. $i = 1;
  785. foreach ($list_provinces as $value) {
  786. $sql = "INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES ('".$field_id."', '".$i."', '".$value."','".$i."');";
  787. Database::query($sql);
  788. $i++;
  789. }
  790. $fieldlabel = 'comunidad_residencia';
  791. $fieldtype = '4';
  792. $fieldtitle = 'Comunidad autonoma de residencia';
  793. $fielddefault = '';
  794. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  795. $ccaa = ';Andalucía;Aragón;Asturias, Principado de;Balears, Illes;Canarias;Cantabria;Castilla y León;Castilla - La Mancha;Cataluña;Comunitat Valenciana;Extremadura;Galicia;Madrid, Comunidad de;Murcia, Región de;Navarra, Comunidad Foral de;País Vasco;Rioja, La;Ceuta;Melilla';
  796. $list_ccaa = explode(';', $ccaa);
  797. $i = 1;
  798. foreach ($list_ccaa as $value) {
  799. $sql = "INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES ('".$field_id."', '".$i."', '".$value."','".$i."');";
  800. Database::query($sql);
  801. $i++;
  802. }
  803. $fieldlabel = 'provincia_trabajo';
  804. $fieldtype = '4';
  805. $fieldtitle = 'Provincia Trabajo';
  806. $fielddefault = '';
  807. //$fieldoptions = ';Albacete;Alicante/Alacant;Almería;Araba/Álava;Asturias;Ávila;Badajoz;Balears, Illes;Barcelona;Bizkaia;Burgos;Cáceres;Cádiz;Cantabria;Castellón/Castelló;Ciudad Real;Córdoba;Coruña, A;Cuenca;Gipuzkoa;Girona;Granada;Guadalajara;Huelva;Huesca;Jaén;León;Lleida;Lugo;Madrid;Málaga;Murcia;Navarra;Ourense;Palencia;Palmas, Las;Pontevedr;Rioja, La;Salamanca;Santa Cruz de Tenerife;Segovia;Sevilla;Soria;Tarragona;Teruel;Toledo;Valencia/Valéncia;Valladolid;Zamora;Zaragoza;Ceuta;Melilla';
  808. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  809. $i = 1;
  810. foreach ($list_provinces as $value) {
  811. $sql = "INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES ('".$field_id."', '".$i."', '".$value."','".$i."');";
  812. Database::query($sql);
  813. $i++;
  814. }
  815. $fieldlabel = 'comunidad_trabajo';
  816. $fieldtype = '4';
  817. $fieldtitle = 'Comunidad autonoma Trabajo';
  818. $fielddefault = '';
  819. //$fieldoptions = ';Andalucía;Aragón;Asturias, Principado de;Balears, Illes;Canarias;Cantabria;Castilla y León;Castilla - La Mancha;Cataluña;Comunitat Valenciana;Extremadura;Galicia;Madrid, Comunidad de;Murcia, Región de;Navarra, Comunidad Foral de;País Vasco;Rioja, La;Ceuta;Melilla';
  820. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  821. $i = 1;
  822. foreach ($list_ccaa as $value) {
  823. $sql = "INSERT INTO extra_field_options (field_id, option_value, display_text, option_order) VALUES ('".$field_id."', '".$i."', '".$value."','".$i."');";
  824. Database::query($sql);
  825. $i++;
  826. }
  827. $fieldlabel = 'medio_conocimiento';
  828. $fieldtype = '2';
  829. $fieldtitle = 'Medio de conocimiento Acción formativa';
  830. $fielddefault = '';
  831. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  832. $fieldlabel = 'experiencia_anterior';
  833. $fieldtype = '2';
  834. $fieldtitle = 'Experiencia anterior en la realización de cursos on-line';
  835. $fielddefault = '';
  836. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  837. $fieldlabel = 'razones_teleformacion';
  838. $fieldtype = '2';
  839. $fieldtitle = 'Razones por la modalidad teleformación';
  840. $fielddefault = '';
  841. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  842. $fieldlabel = 'valoracion_modalidad';
  843. $fieldtype = '2';
  844. $fieldtitle = 'Valoración general sobre la modalidad';
  845. $fielddefault = '';
  846. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  847. $fieldlabel = 'categoria_profesional';
  848. $fieldtype = '1';
  849. $fieldtitle = 'Categoría profesional';
  850. $fielddefault = '';
  851. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  852. $fieldlabel = 'tamano_empresa';
  853. $fieldtype = '1';
  854. $fieldtitle = 'Tamaño de la empresa';
  855. $fielddefault = '';
  856. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);
  857. $fieldlabel = 'horario_accion_formativa';
  858. $fieldtype = '1';
  859. $fieldtitle = 'Horario de la acción formativa';
  860. $fielddefault = '';
  861. $field_id = UserManager::create_extra_field($fieldlabel, $fieldtype, $fieldtitle, $fielddefault);