コード例 #1
0
$tpl = new Template_Helper();
$tpl->setTemplate('manage/time_tracking.tpl.html');
Auth::checkAuthentication();
$role_id = Auth::getCurrentRole();
if ($role_id < User::ROLE_MANAGER) {
    Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
$prj_id = isset($_POST['prj_id']) ? (int) $_POST['prj_id'] : (int) $_GET['prj_id'];
$cat = isset($_POST['cat']) ? (string) $_POST['cat'] : null;
$tpl->assign('project', Project::getDetails($prj_id));
if ($cat == 'new') {
    $title = $_POST['title'];
    $res = Time_Tracking::insertCategory($prj_id, $title);
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the time tracking category was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new time tracking category.'), Misc::MSG_INFO), -2 => array(ev_gettext('Please enter the title for this new time tracking category.'), Misc::MSG_ERROR)));
} elseif ($cat == 'update') {
    $title = (string) $_POST['title'];
    $prj_id = (int) $_POST['prj_id'];
    $id = (int) $_POST['id'];
    $res = Time_Tracking::updateCategory($prj_id, $id, $title);
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the time tracking category was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the time tracking category information.'), Misc::MSG_INFO), -2 => array(ev_gettext('Please enter the title for this time tracking category.'), Misc::MSG_ERROR)));
} elseif ($cat == 'delete') {
    $items = (array) $_POST['items'];
    Time_Tracking::removeCategory($items);
}
if ($cat == 'edit') {
    $tpl->assign('info', Time_Tracking::getCategoryDetails($_GET['id']));
}
$tpl->assign('list', Time_Tracking::getCategoryList($prj_id));
$tpl->displayTemplate();