resource_sequence.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Entity\Sequence;
  4. use Chamilo\CoreBundle\Framework\Container;
  5. $cidReset = true;
  6. api_protect_global_admin_script();
  7. // setting breadcrumbs
  8. $interbreadcrumb[] = array('url' => Container::getRouter()->generate('administration'), 'name' => get_lang('PlatformAdmin'));
  9. $tpl = new Template(get_lang('ResourcesSequencing'));
  10. $sessionListFromDatabase = SessionManager::get_sessions_list();
  11. $sessionList = [];
  12. if (!empty($sessionListFromDatabase)) {
  13. foreach ($sessionListFromDatabase as $sessionItem) {
  14. $sessionList[$sessionItem['id']] = $sessionItem['name'].' ('.$sessionItem['id'].')';
  15. }
  16. }
  17. $formSequence = new FormValidator('sequence_form', 'post', api_get_self(),null,null,'inline');
  18. $formSequence->addText('name', get_lang('Sequence'), true, ['cols-size' => [3, 8, 1]]);
  19. $formSequence->addButtonCreate(get_lang('AddSequence'), 'submit_sequence', false, ['cols-size' => [3, 8, 1]]);
  20. $em = Database::getManager();
  21. // Add sequence
  22. if ($formSequence->validate()) {
  23. $values = $formSequence->exportValues();
  24. $sequence = new Sequence();
  25. $sequence->setName($values['name']);
  26. $em->persist($sequence);
  27. $em->flush();
  28. header('Location: '.api_get_self());
  29. exit;
  30. }
  31. $selectSequence = new FormValidator('');
  32. $selectSequence ->addHidden('sequence_type', 'session');
  33. $em = Database::getManager();
  34. $sequenceList = $em->getRepository('ChamiloCoreBundle:Sequence')->findAll();
  35. $selectSequence->addSelect(
  36. 'sequence',
  37. get_lang('Sequence'),
  38. $sequenceList,
  39. ['id' => 'sequence_id', 'cols-size' => [3, 7, 2]]
  40. );
  41. $form = new FormValidator('');
  42. $form->addHtml("<div class='col-md-6'>");
  43. $form->addHidden('sequence_type', 'session');
  44. $form->addSelect(
  45. 'sessions',
  46. get_lang('Sessions'),
  47. $sessionList,
  48. ['id' => 'item', 'cols-size' => [4, 7, 1]]
  49. );
  50. $form->addButtonNext(get_lang('UseAsReference'), 'use_as_reference', ['cols-size' => [4, 7, 1]]);
  51. $form->addHtml("</div>");
  52. $form->addHtml("<div class='col-md-6'>");
  53. $form->addSelect(
  54. 'requirements',
  55. get_lang('Requirements'),
  56. $sessionList,
  57. ['id' => 'requirements', 'cols-size' => [3, 7, 2]]
  58. );
  59. $form->addButtonCreate(get_lang('SetAsRequirement'), 'set_requirement', false, ['cols-size' => [3, 7, 2]]);
  60. $form->addHtml("</div>");
  61. $formSave = new FormValidator('');
  62. $formSave->addHidden('sequence_type', 'session');
  63. $formSave->addButton(
  64. 'save_resource',
  65. get_lang('SaveSettings'),
  66. 'floppy-o',
  67. 'success',
  68. null,
  69. null,
  70. ['cols-size' => [1, 10, 1]]
  71. );
  72. $tpl->assign('create_sequence', $formSequence->returnForm());
  73. $tpl->assign('select_sequence', $selectSequence->returnForm());
  74. $tpl->assign('configure_sequence', $form->returnForm());
  75. $tpl->assign('save_sequence', $formSave->returnForm());
  76. $layout = $tpl->get_template('admin/resource_sequence.tpl');
  77. $tpl->display($layout);