diff --git a/media/js/button_groups.js b/media/js/button_groups.js new file mode 100644 index 0000000000000000000000000000000000000000..d229f996ce9ee04b14f782cdb7655f4058fb9fa2 --- /dev/null +++ b/media/js/button_groups.js @@ -0,0 +1,12 @@ +$(function () { + var button = $('#button'); + button.click(function () { + var num = ($('input').first().val()); + + // grade/~dev_rating + $.get(URLdir + '/studygroups/' + num, function (res) { + $('#container').html(res); + }); + }); + +}); \ No newline at end of file diff --git a/~dev_rating/application/bootstrap.php b/~dev_rating/application/bootstrap.php index 0e176b17debd41ac68ad831df7b6bb1269c71902..9e206801071b9f3199d6c9d35269881fc6628fe7 100644 --- a/~dev_rating/application/bootstrap.php +++ b/~dev_rating/application/bootstrap.php @@ -288,4 +288,11 @@ Route::set('departments:main', 'departments(/<id>)', ['id' => '[0-9]+']) ]); // bars.com/departments -// bars.com/departments/78 \ No newline at end of file +// bars.com/departments/78 + +Route::set('groups:main','studygroups(/<id>)', ['id' => '[0-9]+']) + ->defaults([ + 'controller' => 'StudyGroups', + 'action' => 'index', + 'id' => 1, + ]); \ No newline at end of file diff --git a/~dev_rating/application/classes/Controller/StudyGroups.php b/~dev_rating/application/classes/Controller/StudyGroups.php new file mode 100644 index 0000000000000000000000000000000000000000..aefd447e263a9132f6339a1855a7d071930a8702 --- /dev/null +++ b/~dev_rating/application/classes/Controller/StudyGroups.php @@ -0,0 +1,16 @@ +<?php defined('SYSPATH') or die('No direct script access.'); + +class Controller_StudyGroups extends Controller +{ + public function action_index() { + $id = (int) $this->request->param('id'); + + $name = $this->request->is_ajax() ? 'studygroups' : 'main_studygroups'; + + $twig = Twig::factory($name, [ + 'Groups' => Model_Students::ofGroup($id, 2) + ]); + + $this->response->body($twig); + } +} diff --git a/~dev_rating/application/views/main_studygroups.twig b/~dev_rating/application/views/main_studygroups.twig new file mode 100644 index 0000000000000000000000000000000000000000..40b28d58bcbdf347eeaae1a0e64e9b2869416dde --- /dev/null +++ b/~dev_rating/application/views/main_studygroups.twig @@ -0,0 +1,32 @@ +<html> +<head> + {{ HTML.script('static/js/libs/jquery-1.11.1.min.js') |raw }} + {{ HTML.script('static/js/button_groups.js')|raw }} + {{ HTML.script('static/js/config.js')|raw }} +</head> +<body> + +<p>РЎРїРёСЃРѕРє РіСЂСѓРїРї:</p> + +<div> + <select> + {% for g in Groups %} + {% if g.Name != '' %} + <option value="{{ g.ID }}">{{ g.Name }}</option> + {% endif %} + {% endfor %} + </select> +</div> + +<div> + <ul> + {% for s in Students %} + {% if s.Name != '' %} + <li value="{{ s.ID }}">{{ s.Name }}</li> + {% endif %} + {% endfor %} + </ul> +</div> + +</body> +</html> diff --git a/~dev_rating/application/views/studygroups b/~dev_rating/application/views/studygroups new file mode 100644 index 0000000000000000000000000000000000000000..32e3d0f1d2c7f526c04f75de48ad0364aa62fab7 --- /dev/null +++ b/~dev_rating/application/views/studygroups @@ -0,0 +1,7 @@ +<select> + {% for s in Students %} + {% if s.Name != '' %} + <option value="{{ s.ID }}">{{ s.Name }}</option> + {% endif %} + {% endfor %} +</select> \ No newline at end of file