Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 359

Přidáno uživatelem Michal Kliment před asi 15 roky(ů)

Takrka dokoncen kontroler pro praci s pracemi, zbyva dokoncit pouze potvrzovani praci...

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'back to list of groups' => 'Zpět na seznam skupin',
'back to list of members' => 'Zpět na seznam členů',
'back to list of translations' => 'Zpět na seznam překladů',
'back to list of works of member' => 'Zpět na seznam prací člena',
'back to login' => 'Zpět na přihlášení',
'back to ports list' => 'Zpět na seznam portů',
'back to segments list' => 'Zpět na seznam segmentů',
......
'confirm work' => 'Potvrdit práci',
'confirmed' => 'Potvrzeno',
'confirmed by' => 'Potvrzeno od',
'confirmed works' => 'Potvrzené práce',
'constant symbol' => 'Konstantní symbol',
'contact data' => 'Kontaktní údaje',
'contact information' => 'Kontaktní informace',
......
'list of all unconfirmed works' => 'Seznam všech nepotvrzených prací',
'list of all users' => 'Seznam všech uživatelů',
'list of users of member' => 'Seznam uživatelů člena',
'list of works of member' => 'Seznam prací člena',
'location address' => 'Adresa umístění',
'location details' => 'Detaily umístění',
'logged user' => 'Přihlášený uživatel',
......
'wireless setting has been successfully updated' => 'Bezdrátové nastavení bylo úspěšně upraveno.',
'work confirmation' => 'Potvrzení práce',
'work has been successfully added' => 'Práce byla úspěšně přidána',
'work successfully deleted' => 'Práce úspěšně smazána',
'work successfully updated' => 'Práce úspěšně uložena',
'work has been successfully deleted' => 'Práce byla úspěšně smazána',
'work has been successfully updated' => 'Práce byla úspěšně akutualizována',
'works' => 'Práce',
'write email' => 'Napsat e-mail',
'wrong password' => 'Špatné heslo',
freenetis/trunk/kohana/application/models/job.php
LEFT JOIN users c ON j.confirmed_by_id = c.id '.$where.' ORDER BY '.$order_by.' '.$order_by_direction);
}
public function get_all_confirmed_works_by_member_id($member_id, $limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $filter_values = array())
public function get_all_confirmed_works_by_member_id($member_id)
{
return self::$db->query('SELECT j.id, concat(u.name,\' \',u.surname) as user_name, j.description, j.date, j.hours, j.km, concat(c.name,\' \',c.surname) as confirm_user FROM jobs j
LEFT JOIN users u ON j.user_id = u.id
LEFT JOIN users c ON j.confirmed_by_id = c.id WHERE j.confirmed_by_id IS NOT NULL AND u.member_id = '.$member_id);
}
$where = (count($filter_values)) ? 'WHERE ' : '';
if (isset($filter_values['description'])) $where .= ($where!='WHERE ') ? ' AND j.description LIKE \'%'.$filter_values['description'].'%\'' : 'j.description LIKE \'%'.$filter_values['description'].'%\'';
if (isset($filter_values['day']))
{
$day = ($filter_values['day']>9) ? $filter_values['day'] : '0'.$filter_values['day'];
$where .= ($where!='WHERE ') ? ' AND j.date LIKE \'%-'.$day.'\'' : 'j.date LIKE \'%-'.$day.'\'';
}
if (isset($filter_values['month']))
{
$month = ($filter_values['month']>9) ? $filter_values['month'] : '0'.$filter_values['month'];
$where .= ($where!='WHERE ') ? ' AND j.date LIKE \'%-'.$month.'-%\'' : 'j.date LIKE \'%-'.$month.'-%\'';
}
if (isset($filter_values['year']))
{
$year = $filter_values['year'];
$where .= ($where!='WHERE ') ? ' AND j.date LIKE \''.$year.'-%\'' : 'j.date LIKE \''.$year.'-%\'';
}
if ($where=='') $where.='WHERE j.confirmed_by_id IS NOT NULL AND u.member_id = '.$member_id;
else $where.=' AND j.confirmed_by_id IS NOT NULL AND u.member_id = '.$member_id;
public function get_all_unconfirmed_works_by_member_id($member_id)
{
return self::$db->query('SELECT j.id, concat(u.name,\' \',u.surname) as user_name, j.description, j.date, j.hours, j.km, concat(c.name,\' \',c.surname) as confirm_user FROM jobs j
LEFT JOIN users u ON j.user_id = u.id
LEFT JOIN users c ON j.confirmed_by_id = c.id '.$where.' ORDER BY '.$order_by.' '.$order_by_direction);
LEFT JOIN users c ON j.confirmed_by_id = c.id WHERE j.confirmed_by_id IS NULL AND u.member_id = '.$member_id);
}
/**
freenetis/trunk/kohana/application/models/user.php
{
return self::$db->query('SELECT id, CONCAT(name,\' \',surname) as name FROM users ORDER BY surname');
}
public function get_user_name($user_id)
{
return self::$db->query('SELECT id, CONCAT(name,\' \',surname) as name FROM users WHERE id = '.$user_id.' ORDER BY surname');
}
public function login_request($username = '', $password = '')
{
freenetis/trunk/kohana/application/controllers/works.php
*/
function show_all($limit_results = 200, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
{
$this->session->del('ssMember_id');
// acccess control
if (!$this->acl_check_view('Users_Controller','work'))
Controller::error(1);
......
$work_model = new Job_Model();
// gets all users with any works
$users = $work_model->get_all_users();
// transforms array of objects to classic array
$arr_users = arr::from_objects($users);
$arr_users[0] = '---';
asort($arr_users);
......
$grid->order_field('km')->label(url_lang::lang('texts.Km'));
$grid->order_field('confirm_user')->label(url_lang::lang('texts.Confirmed by'));
// access control
if ($this->acl_check_view('Users_Controller','work'))
$grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'works/show') ->action(url_lang::lang('texts.Show'))->class('center');
......
$view->footer = new View('base/footer');
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Shows all unconfirmed works with filter
* @param $limit_results
* @param $order_by
* @param $order_by_direction
* @param $page_word
* @param $page number of page
*/
function show_all_unconfirmed($limit_results = 200, $order_by = 'id', $order_by_direction = 'ASC', $page_word = null, $page = 1)
{
$this->session->del('ssMember_id');
if (!$this->acl_check_view('Users_Controller','work'))
Controller::error(1);
......
/**
* @author Michal Kliment
* Shows works of member
* @param $member_id id of member to shos his works
*/
function show_by_member($member_id = NULL)
{
$member = new Member_Model($member_id);
if (!$member_id || !$member->id) url::redirect(url_lang::base().'works');
// access control
if (!$this->acl_check_view('Users_Controller','work',$member_id))
Controller::error(1);
$this->session->set('ssMember_id',$member_id);
$work_model = new Job_Model();
$confirmed_works = $work_model->get_all_confirmed_works_by_member_id($member_id);
$total_confirmed_works = count($confirmed_works);
// create grid
$confirmed_grid = new Grid(url_lang::base().'works/show_by_member', '', array(
//'separator' => '',
'use_paginator' => false,
'use_selector' => false,
'current' => 500, //current selected 'records_per_page' value
'selector_increace' => 200, // increace
'selector_min' => 200, // minimum where selector start
'selector_max_multiplier' => 10,
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
'total_items' => $total_confirmed_works, // use db count query here of course
'items_per_page' => 500, // it may be handy to set defaults for stuff like this in config/pagination.php
'style' => 'classic',
'limit_results' => 500,
'url_array_ofset' => 1
));
$confirmed_grid->field('id')->label(url_lang::lang('texts.Id'));
$confirmed_grid->field('user_name')->label(url_lang::lang('texts.User'));
$confirmed_grid->field('description')->label(url_lang::lang('texts.Description'));
$confirmed_grid->field('date')->label(url_lang::lang('texts.Date'));
$confirmed_grid->field('hours')->label(url_lang::lang('texts.Hours'));
$confirmed_grid->field('km')->label(url_lang::lang('texts.Km'));
$confirmed_grid->field('confirm_user')->label(url_lang::lang('texts.Confirmed by'));
// access control
if ($this->acl_check_view('Users_Controller','work',$member_id))
$confirmed_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'works/show') ->action(url_lang::lang('texts.Show'))->class('center');
$confirmed_grid->datasource($confirmed_works);
$unconfirmed_works = $work_model->get_all_unconfirmed_works_by_member_id($member_id);
$total_unconfirmed_works = count($unconfirmed_works);
// create grid
$unconfirmed_grid = new Grid(url_lang::base().'works/show_by_member', '', array(
//'separator' => '',
'use_paginator' => false,
'use_selector' => false,
'current' => 500, //current selected 'records_per_page' value
'selector_increace' => 200, // increace
'selector_min' => 200, // minimum where selector start
'selector_max_multiplier' => 10,
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
'total_items' => $total_unconfirmed_works, // use db count query here of course
'items_per_page' => 500, // it may be handy to set defaults for stuff like this in config/pagination.php
'style' => 'classic',
'limit_results' => 500,
'url_array_ofset' => 1
));
$unconfirmed_grid->field('id')->label(url_lang::lang('texts.Id'));
$unconfirmed_grid->field('user_name')->label(url_lang::lang('texts.User'));
$unconfirmed_grid->field('description')->label(url_lang::lang('texts.Description'));
$unconfirmed_grid->field('date')->label(url_lang::lang('texts.Date'));
$unconfirmed_grid->field('hours')->label(url_lang::lang('texts.Hours'));
$unconfirmed_grid->field('km')->label(url_lang::lang('texts.Km'));
// access control
if ($this->acl_check_view('Users_Controller','work',$member_id))
$unconfirmed_grid->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'works/show') ->action(url_lang::lang('texts.Show'))->class('center');
// access control
if ($this->acl_check_edit('Users_Controller','work',$member_id))
$unconfirmed_grid->action_field('id')->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'works/edit') ->action(url_lang::lang('texts.Edit'))->class('center');
// access control
if ($this->acl_check_edit('Users_Controller','work',$member_id))
$unconfirmed_grid->action_field('id')->label(url_lang::lang('texts.Delete')) ->url(url_lang::base().'works/delete') ->action(url_lang::lang('texts.Delete'))->class('center');
$unconfirmed_grid->datasource($unconfirmed_works);
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.List of works of member').' '.$member->name;
$view->header->menu = Controller::render_menu();
$view->content= new View('works/show_by_member');
$view->content->member = $member;
$view->content->confirmed_grid = $confirmed_grid;
$view->content->unconfirmed_grid = $unconfirmed_grid;
$view->footer = new View('base/footer');
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Shows one work
* @param $work_id id off work to show
*/
......
$view->render(TRUE);
}
function show_by_member($member_id = NULL)
{
$member = new Member_Model($member_id);
if (!$member_id || !$member->id) url::redirect(url_lang::base().'works');
// access control
if (!$this->acl_check_view('Users_Controller','work',$member_id))
Controller::error(1);
$work_model = new Job_Model();
$confirmed_works = $work_model->get_all_confirmed_works_by_member_id($member_id);
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.List of works of member').' '.$member->name;
$view->header->menu = Controller::render_menu();
$view->content= new View('works/show_by_member');
$view->footer = new View('base/footer');
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Adds new work to some user
*/
function add()
{
$ssMember_id = $this->session->get('ssMember_id');
// access control
if (!$this->acl_check_new('Users_Controller','work'))
if (!$this->acl_check_new('Users_Controller','work',$ssMember_id))
Controller::error(1);
$user_model = new User_Model();
// gets all user's names
$users = $user_model->get_all_user_names();
// check if user has access right to add work to all users
if ($this->acl_check_new('Users_Controller','work'))
{
// gets all user's names
$users = $user_model->get_all_user_names();
}
else
{
$users = $user_model->get_user_name($this->session->get('user_id'));
}
// transforms array of objects to classic array
$arr_users = arr::from_objects($users);
......
{
$this->session->set_flash('message', url_lang::lang('texts.Work has been successfully added').'.');
}
url::redirect(url_lang::base().'works/show_all');
if ($ssMember_id)
{
url::redirect(url_lang::base().'works/show_by_member/'.$ssMember_id);
}
else
{
url::redirect(url_lang::base().'works/show_all_unconfirmed');
}
}
$link_back = ($ssMember_id) ? html::anchor(url_lang::base().'works/show_by_member/'.$ssMember_id,url_lang::lang('texts.Back to list of works of member')) : html::anchor(url_lang::base().'works/show_all_unconfirmed',url_lang::lang('texts.Back to list of all unconfirmed works'));
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.Add new work');
$view->header->menu = Controller::render_menu();
$view->content = new View('works/add');
$view->content->link_back = $link_back;
$view->content->form = $this->form->html();
$view->footer = new View('base/footer');
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Edits work
* @param $work_id id of work to edit
*/
function edit($work_id = NULL)
{
$ssMember_id = $this->session->get('ssMember_id');
$work = new Job_Model($work_id);
if (!$work_id || !$work->id || $work->confirmed_by_id) url::redirect(url_lang::base().'works');
......
Controller::error(1);
$user_model = new User_Model();
// gets all user's names
$users = $user_model->get_all_user_names();
// check iif user has access rights to edit work of all users
if ($this->acl_check_edit('Users_Controller','work'))
{
// gets all user's names
$users = $user_model->get_all_user_names();
}
else
{
$users = $user_model->get_user_name($work->user_id);
}
// transforms array of objects to classic array
$arr_users = arr::from_objects($users);
......
{
$this->session->set_flash('message', url_lang::lang('texts.Work has been successfully updated').'.');
}
url::redirect(url_lang::base().'works/show_all');
if ($ssMember_id)
{
url::redirect(url_lang::base().'works/show_by_member/'.$ssMember_id);
}
else
{
url::redirect(url_lang::base().'works/show_all_unconfirmed');
}
}
$link_back = ($ssMember_id) ? html::anchor(url_lang::base().'works/show_by_member/'.$ssMember_id,url_lang::lang('texts.Back to list of works of member')) : html::anchor(url_lang::base().'works/show_all_unconfirmed',url_lang::lang('texts.Back to list of all unconfirmed works'));
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.Edit the work');
$view->header->menu = Controller::render_menu();
$view->content = new View('works/edit');
$view->content->link_back = $link_back;
$view->content->form = $this->form->html();
$view->footer = new View('base/footer');
$view->render(TRUE);
}
/**
* @author Michal Kliment
* Confirms work
* @param $work_id id of work to confirm
*/
function confirm($work_id)
{
$work = new Job_Model($work_id);
......
if (!$this->acl_check_confirm('Users_Controller','work',$work->user->member_id))
Controller::error(1);
/**
* @todo finish confirm + transfer
*/
}
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_358.php
<?php
$upgrade_sql[358] = array(
"ALTER TABLE `members` ADD `urban_neighbourhood` VARCHAR( 50 ) NULL DEFAULT NULL AFTER `town`;",
"INSERT INTO `axo` (`id`, `section_value`, `value`, `order_value`, `name`, `hidden`)
VALUES (132, 'Members_Controller', 'organization_id', 0, 'ICO', 0);",
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES
(38, 'Members_Controller', 'organization_id');"
);
?>
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php
}
$upgrade_sql[get_SVN_rev()] = array(
"ALTER TABLE `members` ADD `urban_neighbourhood` VARCHAR( 50 ) NULL DEFAULT NULL AFTER `town`;",
"INSERT INTO `axo` (`id`, `section_value`, `value`, `order_value`, `name`, `hidden`)
VALUES (132, 'Members_Controller', 'organization_id', 0, 'ICO', 0);",
"INSERT INTO `acl` (`id`, `section_value`, `allow`, `enabled`, `return_value`, `note`, `updated_date`) VALUES
(64, 'user', 1, 1, '', 'Radni clenove si mohou vytvaret, editovat a mazat sve prace.', 1248160179);",
"INSERT INTO `aco` (`id`, `section_value`, `value`, `order_value`, `name`, `hidden`) VALUES
(36, 'menu', 'my_works', 1, 'My works', 0);",
"INSERT INTO `aco_map` (`acl_id`, `section_value`, `value`) VALUES
(34, 'menu', 'my_works'),
(64, 'freenetis', 'delete_own'),
(64, 'freenetis', 'edit_own'),
(64, 'freenetis', 'new_own'),
(64, 'freenetis', 'view_own');",
"UPDATE `acl_seq` SET `id` = '64' WHERE `acl_seq`.`id` = 63 LIMIT 1;",
"UPDATE `aco_seq` SET `id` = '36' WHERE `aco_seq`.`id` = 35 LIMIT 1;",
"INSERT INTO `aro_groups_map` (`acl_id`, `group_id`) VALUES
(64, 22);",
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES
(38, 'Members_Controller', 'organization_id');"
(64, 'Users_Controller', 'work');"
);
?>
freenetis/trunk/kohana/application/libraries/MY_Controller.php
if ($this->acl_check_2D('menu', 'my_transfers')) $myMenu .= '<li>'.html::anchor(url_lang::base().'transfers/show_by_member/'.$this->session->get('member_id'), url_lang::lang('texts.My transfers')).'</li>';
if ($this->acl_check_2D('menu', 'my_devices')) $myMenu .= ' <li>'.html::anchor(url_lang::base().'devices/show_by_member/'.$this->session->get('member_id'), url_lang::lang('texts.My devices')).'</li>';
if ($this->acl_check_2D('menu', 'my_works')) $myMenu .= ' <li>'.html::anchor(url_lang::base().'works/show_by_member/'.$this->session->get('member_id'), url_lang::lang('texts.My works')).'</li>';
$myMenu .= ' </ul>
freenetis/trunk/kohana/application/views/works/show_by_member.php
<h2><?php echo url_lang::lang('texts.List of works of member').' '.$member->name ?></h2>
<?php echo ($message = $this->session->get('message')) ? '<div class="message">'.$message.'</div>' : '' ?>
<?php
if ($this->acl_check_new('Users_Controller','work',$member->id))
echo '<br />'.html::anchor(url_lang::base().'works/add',url_lang::lang('texts.Add new work')).'<br />';
?>
<br />
<h3><?php echo url_lang::lang('texts.Confirmed works') ?></h3>
<?php echo $confirmed_grid ?>
<br /><br />
<h3><?php echo url_lang::lang('texts.Unconfirmed works') ?></h3>
<?php echo $unconfirmed_grid ?>
freenetis/trunk/kohana/application/views/works/edit.php
<h2><?php echo url_lang::lang('texts.Edit the work') ?></h2><br />
<?php echo html::anchor(url_lang::base().'works/show_all_unconfirmed', url_lang::lang('texts.Back to list of all unconfirmed works')) ?>
<?php echo $link_back ?>
<br /><br />
<?php echo $form ?>
freenetis/trunk/kohana/application/views/works/add.php
<h2><?php echo url_lang::lang('texts.Add new work') ?></h2><br />
<?php echo html::anchor(url_lang::base().'works/show_all', url_lang::lang('texts.Back to list of all works')) ?>
<?php echo $link_back ?>
<br /><br />
<?php echo $form ?>

Také k dispozici: Unified diff