From dcd813884cee43fb86f30aae9227dc7924f3201a Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Thu, 27 Oct 2016 13:10:36 +0700 Subject: [PATCH] Course creation action --- application/classes/Controller/Course.php | 6 +++++- application/classes/Model/Course.php | 8 ++++++++ application/classes/View/Course/Edit.php | 2 ++ application/i18n/ru.php | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/application/classes/Controller/Course.php b/application/classes/Controller/Course.php index 5205889..d26d85c 100644 --- a/application/classes/Controller/Course.php +++ b/application/classes/Controller/Course.php @@ -54,7 +54,11 @@ class Controller_Course extends Controller_Layout { public function action_create() { - $this->template = new View_Edit; + $this->template = new View_Course_Edit; + $this->controls = [ + 'title' => 'input', + 'description' => 'textarea', + ]; $this->template->model = ORM::factory('Course'); $this->template->title = I18n::translate('New course'); $this->_edit($this->template->model); diff --git a/application/classes/Model/Course.php b/application/classes/Model/Course.php index 516d636..6cad1af 100644 --- a/application/classes/Model/Course.php +++ b/application/classes/Model/Course.php @@ -68,6 +68,14 @@ class Model_Course extends ORM { 'description' => 'Description (for the clients)' ); + public static function type_labels() + { + return [ + self::TYPE_IRREGULAR => I18n::translate('Subscription'), + self::TYPE_SCHEDULED => I18n::translate('Course'), + ]; + } + public function customize() { if ($this->period < 1) diff --git a/application/classes/View/Course/Edit.php b/application/classes/View/Course/Edit.php index 517bb4a..1f86de0 100644 --- a/application/classes/View/Course/Edit.php +++ b/application/classes/View/Course/Edit.php @@ -8,6 +8,8 @@ class View_Course_Edit extends View_Edit { { return Form::select('group_id', ORM::factory('Group')->find_all()->as_array('id', 'name'), NULL, [ 'label' => I18n::translate('Group') + ]).Form::select('type', Model_Course::type_labels(), $this->model->type, [ + 'label' => I18n::translate('Type') ]); } } diff --git a/application/i18n/ru.php b/application/i18n/ru.php index 2816dc7..3e35034 100644 --- a/application/i18n/ru.php +++ b/application/i18n/ru.php @@ -86,4 +86,5 @@ return array( "You can customize the delay (1 day by default) between the messages." => 'Вы можете настроить задержку (по умолчанию - один день) между сообщениями.', 'Group' => 'Группа', 'New group' => 'Новая группа', + 'Type' => 'Тип', );