database.php 29 KB

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