Beispiel #1
0
}
Add_Item("My List", "mylist.php");
Add_Item("Open Tickets", "list.php");
Add_Item("Ticket Lookup (by ID)", "lookup.php");
Add_Item("New Ticket", "new.php");
Add_Item("Search Ticket", "search.php");
Add_ItemRed("Check User", "check_user.php");
if (IsKarnafAdminSession()) {
    Add_Itemx("Edit types", "mng_cat.php?table=cat1");
    Add_Itemx("Edit catagories", "mng_cat.php?table=cat2");
    Add_Itemx("Edit subjects", "mng_cat.php?table=cat3");
    Add_Itemx("Edit templates", "mng_templates.php");
    Add_Itemx("View Logs", "mng_viewlogs.php");
    Add_Itemx("Edit SQL", "mng_editsql.php");
    Add_Itemx("Stats", "stats.php");
    Add_Item("Logout", "logout.php");
}
?>
<tr><td>
<br>
<u>Tickets:</u>
<br>
<?php 
$tickets = 0;
$query = squery("SELECT count(*) FROM karnaf_tickets");
if ($result = sql_fetch_array($query)) {
    $tickets = $result[0];
}
sql_free_result($query);
echo $tickets;
?>
Beispiel #2
0
function Module_JSON($db)
{
    $report_id = Functions::Post_Int('report_id');
    $project_id = Functions::Post_Int('project_id');
    $action = Functions::Post('action');
    $date_input = Functions::Post('date');
    $employee_id = Functions::Post_Int('employee_id');
    $hours = Functions::Post('time');
    $description = Functions::Post('description');
    $billable = Functions::Post_Active('billable');
    $custom_rate = Functions::Post_Active('custom_rate');
    if (!Functions::Report_Load($db, $report_id, $loaded_report)) {
        return JSON_Response_Error('#Error#', 'Report not found');
    }
    if (!Functions::Project_Load($db, $project_id, $loaded_project)) {
        return JSON_Response_Error('#Error#', 'Project not found');
    }
    if (!Functions::ReportProject_Load_ReportProject($db, $report_id, $project_id, $loaded_report_project)) {
        return JSON_Response_Error('#Error#', 'Report project not found');
    }
    if ($custom_rate === 1 && $loaded_report_project['custom_rate_id'] === 1) {
        return JSON_Response_Error('#Error#', 'You cannot set this item to have a custom rate, until you select a custom rate type');
    }
    if ($date_input == '') {
        return JSON_Response_Error('#Error#', 'Please select a date');
    }
    $item_date = new DateTime($date_input);
    $date_from = new DateTime($loaded_report['date_from']);
    $date_to = new DateTime($loaded_report['date_to']);
    if ($item_date < $date_from || $item_date > $date_to) {
        return JSON_Response_Error('#Error#', 'The date range of the item does not fall within the date range of the report');
    }
    if (!is_numeric($hours) || $hours < 0) {
        return JSON_Response_Error('#Error#', 'Hours must be positive');
    }
    if ($description == '') {
        return JSON_Response_Error('#Error#', 'Description cannot be blank');
    }
    switch ($employee_id) {
        case 0:
            // fee
            $type = 1;
            $employee_id = 0;
            $hours = number_format($hours, 2);
            break;
        case 1:
            // credit - web
            $type = 2;
            $employee_id = 0;
            $hours = Functions::format_hour($hours);
            break;
        case 2:
            // credit - junior
            $type = 3;
            $employee_id = 0;
            $hours = Functions::format_hour($hours);
            break;
        case 3:
            // credit - cust
            $type = 4;
            $employee_id = 0;
            $hours = Functions::format_hour($hours);
            break;
        default:
            $type = 0;
            $hours = Functions::format_hour($hours);
            break;
    }
    if ($type == 0 && !Functions::Employee_Load($db, $employee_id, $null)) {
        return JSON_Response_Error('#Error#', 'Employee could not be found');
    }
    if ($action === 'add') {
        return Add_Item($db, $type, $date_input, $employee_id, $hours, $description, $billable, $custom_rate, $loaded_report_project['id']);
    } else {
        if ($action === 'update') {
            return Update_Item($db, $type, $date_input, $employee_id, $hours, $description, $billable, $custom_rate);
        }
    }
    return JSON_Response_Error('#Error#', 'Invalid action');
}