1
0
Fork 0
mirror of https://github.com/Oreolek/kangana.git synced 2024-05-04 18:18:17 +03:00

Interface update

This commit is contained in:
Alexander Yakovlev 2016-11-13 20:30:39 +07:00
parent 63710bd167
commit 487f869c94
7 changed files with 77 additions and 8 deletions

View file

@ -17,13 +17,8 @@ class Controller_Group extends Controller_Layout {
);
public function action_index()
{
$this->template = new View_Index;
$this->template = new View_Group_Index;
$this->template->title = I18n::translate('Groups');
$this->template->header = [
I18n::translate('Group name'),
I18n::translate('Edit'),
I18n::translate('Delete'),
];
$this->template->items = ORM::factory('Group')
->filter_by_page($this->request->param('page'))
->find_all();

View file

@ -93,7 +93,11 @@ class Model_Course extends ORM {
**/
public function count_clients()
{
return DB::select(array(DB::expr('COUNT(client_id)'), 'cnt'))->from('clients_courses')->where('course_id', '=', $this->id)->execute()->get('cnt');
$use_groups = Kohana::$config->load('common.groupmode');
if( ! $use_groups)
return DB::select(array(DB::expr('COUNT(client_id)'), 'cnt'))->from('clients_courses')->where('course_id', '=', $this->id)->execute()->get('cnt');
else
return $this->group->count_clients();
}
public static function exists($id)

View file

@ -0,0 +1,40 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Group index view controller.
* @package Views
* @author Oreolek
**/
class View_Group_Index extends View_Index {
protected $is_admin = TRUE; // admin only view
public $show_date = FALSE;
public $content;
public function get_header()
{
return array(
I18n::translate('Group name'),
I18n::translate('Subscribers'),
I18n::translate('Edit'),
I18n::translate('Delete'),
);
}
/**
* An internal function to prepare item data.
**/
protected function show_item($item)
{
if ( ! $item instanceof ORM)
{
return FALSE;
}
$output = array(
'name' => $item->name,
'edit_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'edit','id' => $item->id)), I18n::translate('Edit'), array('class' => 'link_edit')),
'delete_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'delete','id' => $item->id)), I18n::translate('Delete'), array('class' => 'link_delete')),
'client_count' => $item->count_clients(),
);
return $output;
}
}

View file

@ -38,6 +38,6 @@ class View_Letter_Index extends View_Index {
public function link_new()
{
return HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'create', 'id' => $this->course_id)), I18n::translate('Add'), array('class' => 'link_new'));
return HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'create', 'id' => $this->course_id)), I18n::translate('Add letter'), array('class' => 'btn btn-default link_new'));
}
}

View file

@ -6,4 +6,5 @@ return array(
'thumbnail_width' => 200,
'thumbnail_height' => 150,
'page_size' => 20, // pagination
'groupmode' => TRUE // use groups
);

View file

@ -96,4 +96,5 @@ return array(
'City' => 'Город',
'Groups' => 'Группы',
'Courses' => 'Курсы',
'Add letter' => 'Добавить сообщение',
);

View file

@ -0,0 +1,28 @@
{{#show_create}}
{{{link_new}}}
{{/show_create}}
{{#content}}
<div class="hyphenate">
{{{.}}}
</div>
{{/content}}
<table class="table">
<thead>
{{#get_header}}
<th>{{.}}</th>
{{/get_header}}
</thead>
<tbody>
{{#get_items}}
<tr>
<td>{{name}}</td>
<td>{{client_count}}</td>
{{#edit_link}}
<td>{{{edit_link}}}</td>
<td>{{{delete_link}}}</td>
{{/edit_link}}
</tr>
{{/get_items}}
</tbody>
</table>
{{{get_paging}}}