mirror of
https://github.com/Oreolek/kangana.git
synced 2024-05-04 18:18:17 +03:00
Interface update
This commit is contained in:
parent
63710bd167
commit
487f869c94
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
40
application/classes/View/Group/Index.php
Normal file
40
application/classes/View/Group/Index.php
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ return array(
|
|||
'thumbnail_width' => 200,
|
||||
'thumbnail_height' => 150,
|
||||
'page_size' => 20, // pagination
|
||||
'groupmode' => TRUE // use groups
|
||||
);
|
||||
|
|
|
@ -96,4 +96,5 @@ return array(
|
|||
'City' => 'Город',
|
||||
'Groups' => 'Группы',
|
||||
'Courses' => 'Курсы',
|
||||
'Add letter' => 'Добавить сообщение',
|
||||
);
|
||||
|
|
28
application/templates/group/index.mustache
Normal file
28
application/templates/group/index.mustache
Normal 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}}}
|
Loading…
Reference in a new issue