Revize 357
Přidáno uživatelem Michal Kliment před více než 15 roky(ů)
freenetis/trunk/kohana/application/models/job.php | ||
---|---|---|
}
|
||
|
||
if ($where=='') $where.='WHERE j.confirmed_by_id IS NOT NULL';
|
||
else $where.='j.confirmed_by_id IS NOT NULL';
|
||
else $where.=' AND j.confirmed_by_id IS NOT NULL';
|
||
|
||
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
|
||
... | ... | |
}
|
||
|
||
if ($where=='') $where.='WHERE j.confirmed_by_id IS NULL';
|
||
else $where.='j.confirmed_by_id IS NULL';
|
||
else $where.=' AND j.confirmed_by_id IS NULL';
|
||
|
||
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);
|
||
}
|
||
|
||
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())
|
||
{
|
||
|
||
|
||
$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;
|
||
|
||
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);
|
||
}
|
||
|
||
/**
|
||
* @author Michal Kliment
|
||
* Counts all work depending on filter values
|
||
... | ... | |
}
|
||
|
||
if ($where=='') $where.='WHERE j.confirmed_by_id IS NOT NULL';
|
||
else $where.='j.confirmed_by_id IS NOT NULL';
|
||
else $where.=' AND j.confirmed_by_id IS NOT NULL';
|
||
|
||
$works = self::$db->query('SELECT j.id, concat(u.name,\' \',u.surname) as user_name, j.description, j.date, j.hours, j.km FROM jobs j
|
||
LEFT JOIN users u ON j.user_id = u.id '.$where);
|
||
... | ... | |
}
|
||
|
||
if ($where=='') $where.='WHERE j.confirmed_by_id IS NULL';
|
||
else $where.='j.confirmed_by_id IS NULL';
|
||
else $where.=' AND j.confirmed_by_id IS NULL';
|
||
|
||
$works = self::$db->query('SELECT j.id, concat(u.name,\' \',u.surname) as user_name, j.description, j.date, j.hours, j.km FROM jobs j
|
||
LEFT JOIN users u ON j.user_id = u.id '.$where);
|
freenetis/trunk/kohana/application/controllers/works.php | ||
---|---|---|
$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
|
Také k dispozici: Unified diff
Pridana funkce show_by_member pro zobrazeni praci clena, zatim pouzee pocatky....