parent
899444041a
commit
6fd28e210c
@ -0,0 +1,92 @@ |
||||
<?php |
||||
/* For license terms, see /license.txt */ |
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
$tool = 'justification'; |
||||
$plugin = Justification::create(); |
||||
|
||||
$tpl = new Template($tool); |
||||
$fields = []; |
||||
|
||||
$form = new FormValidator('search', 'get'); |
||||
$form->addHeader('Search'); |
||||
$form->addSelectAjax( |
||||
'user_id', |
||||
get_lang('User'), |
||||
[], |
||||
[ |
||||
'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_like', |
||||
] |
||||
); |
||||
$form->addButtonSearch(get_lang('Search')); |
||||
$tpl->assign('form', $form->returnForm()); |
||||
|
||||
$userId = isset($_REQUEST['user_id']) ? (int) $_REQUEST['user_id'] : 0; |
||||
|
||||
if ($form->validate()) { |
||||
$userId = $form->getSubmitValue('user_id'); |
||||
} |
||||
|
||||
if ($userId) { |
||||
$tpl->assign('user_info', api_get_user_info($userId)); |
||||
$list = $plugin->getUserJustificationList($userId); |
||||
if ($list) { |
||||
foreach ($list as &$item) { |
||||
$item['justification'] = $plugin->getJustification($item['justification_document_id']); |
||||
|
||||
$item['file_path'] = Display::url( |
||||
$item['file_path'], |
||||
api_get_uploaded_web_url('justification', $item['id'], $item['file_path']), |
||||
['target' => '_blank'] |
||||
); |
||||
} |
||||
} |
||||
if (empty($list)) { |
||||
Display::addFlash(Display::return_message($plugin->get_lang('NoJustificationFound'))); |
||||
} |
||||
$tpl->assign('list', $list); |
||||
} |
||||
|
||||
|
||||
$tpl->assign('user_id', $userId); |
||||
$content = $tpl->fetch('justification/view/justification_user_list.tpl'); |
||||
|
||||
$actionLinks = ''; |
||||
|
||||
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; |
||||
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
||||
|
||||
switch ($action) { |
||||
case 'delete': |
||||
$userJustification = $plugin->getUserJustification($id); |
||||
if ($userJustification) { |
||||
api_remove_uploaded_file_by_id('justification', $id, $userJustification['file_path']); |
||||
|
||||
$sql = "DELETE FROM justification_document_rel_users WHERE id = $id"; |
||||
Database::query($sql); |
||||
|
||||
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
||||
} |
||||
header('Location: '.api_get_self().'?user_id='.$userId); |
||||
exit; |
||||
break; |
||||
} |
||||
|
||||
$actionLinks .= Display::toolbarButton( |
||||
$plugin->get_lang('Back'), |
||||
api_get_path(WEB_PLUGIN_PATH).'justification/list.php', |
||||
'arrow-left', |
||||
'primary' |
||||
); |
||||
|
||||
$tpl->assign( |
||||
'actions', |
||||
Display::toolbarAction('toolbar', [$actionLinks]) |
||||
); |
||||
|
||||
|
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
@ -0,0 +1,34 @@ |
||||
{{ form }} |
||||
|
||||
{% if list %} |
||||
<div class ="row"> |
||||
<div class ="col-md-12"> |
||||
<div class="page-header"> |
||||
<h2>{{ 'List'| get_lang }}</h2> |
||||
</div> |
||||
<table class="table"> |
||||
<tr> |
||||
|
||||
<th>{{ 'Justification'| get_plugin_lang('Justification') }}</th> |
||||
<th>{{ 'File'| get_lang }}</th> |
||||
<th>{{ 'Date'| get_lang('Date') }}</th> |
||||
<th>{{ 'Actions'| get_lang }}</th> |
||||
</tr> |
||||
|
||||
{% for item in list %} |
||||
<tr> |
||||
|
||||
<td >{{ item.justification.name }} </td> |
||||
<td >{{ item.file_path }} </td> |
||||
<td >{{ item.date_validity }} </td> |
||||
<td> |
||||
<a href="{{_p.web_plugin }}justification/justification_by_user.php?a=delete&user_id={{ user_id }}&id={{ item.id }}" class="btn btn-danger"> |
||||
{{'Delete' | get_lang}} |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
</div> |
||||
</div> |
||||
{% endif %} |
||||
Loading…
Reference in new issue