resource_sequence.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Entity\Sequence;
  4. $cidReset = true;
  5. require_once '../inc/global.inc.php';
  6. api_protect_global_admin_script();
  7. // setting breadcrumbs
  8. $interbreadcrumb[] = array('url' => 'index.php', '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('save_resource', get_lang('SaveSettings'), 'floppy-o', 'success', null, null, ['cols-size' => [1, 10, 1]]);
  64. $tpl->assign('create_sequence', $formSequence->returnForm());
  65. $tpl->assign('select_sequence', $selectSequence->returnForm());
  66. $tpl->assign('configure_sequence', $form->returnForm());
  67. $tpl->assign('save_sequence', $formSave->returnForm());
  68. $layout = $tpl->get_template('admin/resource_sequence.tpl');
  69. $tpl->display($layout);