Exemple #1
0
/**
 * Sum up expenses for the project.
 *
 * @param int $projectId
 * @return int
 */
function calculate_expenses_sum($projectId)
{
    $expenseSum = 0;
    $expenses = get_expenses(0, time(), null, null, array($projectId));
    foreach ($expenses as $expense) {
        $expenseSum += $expense['value'];
    }
    return $expenseSum;
}
Exemple #2
0
     $filterCustomers = array_intersect($filterCustomers, explode(':', $filters[1]));
 }
 $filterProjects = array_map(function ($project) {
     return $project['projectID'];
 }, $database->get_projects($kga['user']['groups']));
 if (!empty($filters[2])) {
     $filterProjects = array_intersect($filterProjects, explode(':', $filters[2]));
 }
 // if no userfilter is set, set it to current user
 if (isset($kga['user']) && count($filterUsers) == 0) {
     array_push($filterUsers, $kga['user']['userID']);
 }
 if (isset($kga['customer'])) {
     $filterCustomers = array($kga['customer']['customerID']);
 }
 $view->assign('expenses', get_expenses($in, $out, $filterUsers, $filterCustomers, $filterProjects, 1));
 $view->assign('total', Kimai_Format::formatCurrency(array_reduce($view->expenses, function ($sum, $expense) {
     return $sum + $expense['multiplier'] * $expense['value'];
 }, 0)));
 $ann = expenses_by_user($in, $out, $filterUsers, $filterCustomers, $filterProjects);
 $ann = Kimai_Format::formatCurrency($ann);
 $view->assign('user_annotations', $ann);
 // TODO: function for loops or convert it in template with new function
 $ann = expenses_by_customer($in, $out, $filterUsers, $filterCustomers, $filterProjects);
 $ann = Kimai_Format::formatCurrency($ann);
 $view->assign('customer_annotations', $ann);
 $ann = expenses_by_project($in, $out, $filterUsers, $filterCustomers, $filterProjects);
 $ann = Kimai_Format::formatCurrency($ann);
 $view->assign('project_annotations', $ann);
 $view->assign('activity_annotations', array());
 if (isset($kga['user'])) {
Exemple #3
0
     $filterCustomers = array_intersect($filterCustomers, explode(':', $filters[1]));
 }
 $filterProjects = array_map(function ($project) {
     return $project['projectID'];
 }, $database->get_projects($kga['user']['groups']));
 if ($filters[2] != "") {
     $filterProjects = array_intersect($filterProjects, explode(':', $filters[2]));
 }
 // if no userfilter is set, set it to current user
 if (isset($kga['user']) && count($filterUsers) == 0) {
     array_push($filterUsers, $kga['user']['userID']);
 }
 if (isset($kga['customer'])) {
     $filterCustomers = array($kga['customer']['customerID']);
 }
 $view->expenses = get_expenses($in, $out, $filterUsers, $filterCustomers, $filterProjects, 1);
 $view->total = Format::formatCurrency(array_reduce($view->expenses, function ($sum, $expense) {
     return $sum + $expense['multiplier'] * $expense['value'];
 }, 0));
 $ann = expenses_by_user($in, $out, $filterUsers, $filterCustomers, $filterProjects);
 $ann = Format::formatCurrency($ann);
 $view->user_annotations = $ann;
 // TODO: function for loops or convert it in template with new function
 $ann = expenses_by_customer($in, $out, $filterUsers, $filterCustomers, $filterProjects);
 $ann = Format::formatCurrency($ann);
 $view->customer_annotations = $ann;
 $ann = expenses_by_project($in, $out, $filterUsers, $filterCustomers, $filterProjects);
 $ann = Format::formatCurrency($ann);
 $view->project_annotations = $ann;
 $view->activity_annotations = array();
 if (isset($kga['user'])) {
Exemple #4
0
/**
 * Get a combined array with time recordings and expenses to export.
 *
 * @param int $start Time from which to take entries into account.
 * @param int $end Time until which to take entries into account.
 * @param array $projects Array of project IDs to filter by.
 * @param int $filter_cleared (-1: show all, 0:only cleared 1: only not cleared) entries
 * @param bool $short_form should the short form be created
 * @return array with time recordings and expenses chronologically sorted
 */
function invoice_get_data($start, $end, $projects, $filter_cleared, $short_form)
{
    global $database;
    $limitCommentSize = true;
    $results = array();
    // --------------------------------------------------------------------------------
    // timesheet entries
    $timeSheetEntries = $database->get_timeSheet($start, $end, null, null, $projects, null, false, false, $filter_cleared);
    foreach ($timeSheetEntries as $entry) {
        // active recordings will be omitted
        if ($entry['end'] == 0) {
            continue;
        }
        $arr = ext_invoice_empty_entry();
        $arr['type'] = 'timeSheet';
        $arr['desc'] = $entry['activityName'];
        $arr['start'] = $entry['start'];
        $arr['end'] = $entry['end'];
        $arr['hour'] = $entry['duration'] / 3600;
        $arr['fDuration'] = $entry['formattedDuration'];
        // @deprecated use duration instead
        $arr['duration'] = $entry['duration'];
        $arr['timestamp'] = $entry['start'];
        $arr['amount'] = $entry['wage'];
        $arr['description'] = $entry['description'];
        $arr['rate'] = $entry['rate'];
        $arr['comment'] = $entry['comment'];
        $arr['username'] = $entry['userName'];
        $arr['useralias'] = $entry['userAlias'];
        $arr['location'] = $entry['location'];
        $arr['trackingNr'] = $entry['trackingNumber'];
        $arr['projectID'] = $entry['projectID'];
        $arr['projectName'] = $entry['projectName'];
        $arr['projectComment'] = $entry['projectComment'];
        invoice_add_to_array($results, $arr, $short_form);
    }
    // --------------------------------------------------------------------------------
    // if expenses extension is used, load expenses as well
    if (file_exists('../ki_expenses/private_db_layer_mysql.php')) {
        include_once '../ki_expenses/private_db_layer_mysql.php';
        $expenses = get_expenses($start, $end, null, null, $projects, false, false, -1, $filter_cleared);
        foreach ($expenses as $entry) {
            $arr = ext_invoice_empty_entry();
            $arr['type'] = 'expense';
            $arr['desc'] = $entry['designation'];
            $arr['start'] = $entry['timestamp'];
            $arr['end'] = $entry['timestamp'];
            $arr['hour'] = null;
            $arr['fDuration'] = $entry['multiplier'];
            // @deprecated use duration instead
            $arr['duration'] = $entry['multiplier'];
            $arr['timestamp'] = $entry['timestamp'];
            $arr['amount'] = sprintf("%01.2f", $entry['value'] * $entry['multiplier']);
            $arr['description'] = $entry['designation'];
            $arr['rate'] = $entry['value'];
            $arr['comment'] = $entry['comment'];
            $arr['username'] = $entry['userName'];
            $arr['useralias'] = $entry['userAlias'];
            $arr['location'] = null;
            $arr['trackingNr'] = null;
            $arr['projectID'] = $entry['projectID'];
            $arr['projectName'] = $entry['projectName'];
            $arr['projectComment'] = $entry['projectComment'];
            // @deprecated expenses only: will be removed in the future, can be fetched otherwise
            $arr['activityName'] = $entry['designation'];
            // @deprecated expenses only: will be removed in the future, can be fetched otherwise
            $arr['multiplier'] = $entry['multiplier'];
            // @deprecated expenses only: will be removed in the future, can be fetched otherwise
            $arr['value'] = $entry['value'];
            invoice_add_to_array($results, $arr, $short_form);
        }
    }
    $allEntries = array();
    foreach ($results as $entry) {
        if ($limitCommentSize) {
            $entry['comment'] = Kimai_Format::addEllipsis($entry['comment'], 150);
        }
        // FIXME use date_format_3 instead
        $entry['date'] = date("m/d/Y", $entry['timestamp']);
        $allEntries[] = $entry;
    }
    return $allEntries;
}
Exemple #5
0
/**
 * Get a combined array with time recordings and expenses to export.
 *
 * FIXME this method is the worst nightmare i have seen in month - kevin
 *
 * @param int $start Time from which to take entries into account.
 * @param int $end Time until which to take entries into account.
 * @param array $projects Array of project IDs to filter by.
 * @param int $filter_cleared (-1: show all, 0:only cleared 1: only not cleared) entries
 * @param bool $short_form should the short form be created
 * @return array with time recordings and expenses chronologically sorted
 */
function invoice_get_data($start, $end, $projects, $filter_cleared, $short_form)
{
    global $expense_ext_available, $database;
    $limit = false;
    $reverse_order = false;
    $limitCommentSize = true;
    $filter_refundable = -1;
    $timeSheetEntries = array();
    $expenses = array();
    $timeSheetEntries = $database->get_timeSheet($start, $end, null, null, $projects, null, $limit, $reverse_order, $filter_cleared);
    if ($expense_ext_available) {
        $expenses = get_expenses($start, $end, null, null, $projects, $limit, $reverse_order, $filter_refundable, $filter_cleared);
    }
    $result_arr = array();
    $timeSheetEntries_index = 0;
    $expenses_index = 0;
    $keys = array('type', 'desc', 'hour', 'fduration', 'amount', 'date', 'description', 'rate', 'comment', 'username', 'useralias', 'location');
    while ($timeSheetEntries_index < count($timeSheetEntries) && $expenses_index < count($expenses)) {
        $arr = array();
        foreach ($keys as $key) {
            $arr[$key] = null;
        }
        if (!$reverse_order && $timeSheetEntries[$timeSheetEntries_index]['start'] > $expenses[$expenses_index]['timestamp'] || $reverse_order && $timeSheetEntries[$timeSheetEntries_index]['start'] < $expenses[$expenses_index]['timestamp']) {
            if ($timeSheetEntries[$timeSheetEntries_index]['end'] != 0) {
                // active recordings will be omitted
                $arr['type'] = 'timeSheet';
                $arr['location'] = $timeSheetEntries[$timeSheetEntries_index]['location'];
                $arr['desc'] = $timeSheetEntries[$timeSheetEntries_index]['activityName'];
                $arr['hour'] = $timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600;
                $arr['fDuration'] = $timeSheetEntries[$timeSheetEntries_index]['formattedDuration'];
                $arr['amount'] = $timeSheetEntries[$timeSheetEntries_index]['wage'];
                $arr['date'] = date("m/d/Y", $timeSheetEntries[$timeSheetEntries_index]['start']);
                $arr['description'] = $timeSheetEntries[$timeSheetEntries_index]['description'];
                $arr['rate'] = $timeSheetEntries[$timeSheetEntries_index]['rate'];
                $arr['trackingNr'] = $timeSheetEntries[$timeSheetEntries_index]['trackingNumber'];
                if ($limitCommentSize) {
                    $arr['comment'] = Format::addEllipsis($timeSheetEntries[$timeSheetEntries_index]['comment'], 150);
                } else {
                    $arr['comment'] = $timeSheetEntries[$timeSheetEntries_index]['comment'];
                }
                $arr['username'] = $timeSheetEntries[$timeSheetEntries_index]['userName'];
                $arr['useralias'] = $timeSheetEntries[$timeSheetEntries_index]['userAlias'];
            }
            $timeSheetEntries_index++;
        } else {
            $arr['type'] = 'expense';
            $arr['desc'] = $expenses[$expenses_index]['designation'];
            $arr['multiplier'] = $expenses[$expenses_index]['multiplier'];
            $arr['value'] = $expenses[$expenses_index]['value'];
            $arr['fDuration'] = $expenses[$expenses_index]['multiplier'];
            $arr['amount'] = sprintf("%01.2f", $expenses[$expenses_index]['value'] * $expenses[$expenses_index]['multiplier']);
            $arr['date'] = date("m/d/Y", $expenses[$expenses_index]['timestamp']);
            $arr['rate'] = $expenses[$expenses_index]['value'];
            if ($limitCommentSize) {
                $arr['comment'] = Format::addEllipsis($expenses[$expenses_index]['comment'], 150);
            } else {
                $arr['comment'] = $expenses[$expenses_index]['comment'];
            }
            $arr['activityName'] = $expenses[$expenses_index]['designation'];
            $arr['username'] = $expenses[$expenses_index]['userName'];
            $arr['useralias'] = $expenses[$expenses_index]['userAlias'];
            $expenses_index++;
        }
        invoice_add_to_array($result_arr, $arr, $short_form);
    }
    // timesheet entries
    while ($timeSheetEntries_index < count($timeSheetEntries)) {
        if ($timeSheetEntries[$timeSheetEntries_index]['end'] != 0) {
            // active recordings will be omitted
            $arr = array();
            foreach ($keys as $key) {
                $arr[$key] = null;
            }
            $arr['type'] = 'timeSheet';
            $arr['location'] = $timeSheetEntries[$timeSheetEntries_index]['location'];
            $arr['desc'] = $timeSheetEntries[$timeSheetEntries_index]['activityName'];
            $arr['hour'] = $timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600;
            $arr['fDuration'] = $timeSheetEntries[$timeSheetEntries_index]['formattedDuration'];
            $arr['amount'] = $timeSheetEntries[$timeSheetEntries_index]['wage'];
            $arr['date'] = date("m/d/Y", $timeSheetEntries[$timeSheetEntries_index]['start']);
            $arr['description'] = $timeSheetEntries[$timeSheetEntries_index]['description'];
            $arr['rate'] = $timeSheetEntries[$timeSheetEntries_index]['rate'];
            $arr['trackingNr'] = $timeSheetEntries[$timeSheetEntries_index]['trackingNumber'];
            if ($limitCommentSize) {
                $arr['comment'] = Format::addEllipsis($timeSheetEntries[$timeSheetEntries_index]['comment'], 150);
            } else {
                $arr['comment'] = $timeSheetEntries[$timeSheetEntries_index]['comment'];
            }
            $arr['username'] = $timeSheetEntries[$timeSheetEntries_index]['userName'];
            $arr['useralias'] = $timeSheetEntries[$timeSheetEntries_index]['userAlias'];
            invoice_add_to_array($result_arr, $arr, $short_form);
        }
        $timeSheetEntries_index++;
    }
    // expenses entries
    while ($expenses_index < count($expenses)) {
        $arr = array();
        foreach ($keys as $key) {
            $arr[$key] = null;
        }
        $arr['type'] = 'expense';
        $arr['desc'] = $expenses[$expenses_index]['designation'];
        $arr['multiplier'] = $expenses[$expenses_index]['multiplier'];
        $arr['value'] = $expenses[$expenses_index]['value'];
        $arr['fDuration'] = $expenses[$expenses_index]['multiplier'];
        $arr['amount'] = sprintf("%01.2f", $expenses[$expenses_index]['value'] * $expenses[$expenses_index]['multiplier']);
        $arr['date'] = date("m/d/Y", $expenses[$expenses_index]['timestamp']);
        $arr['rate'] = $expenses[$expenses_index]['value'];
        if ($limitCommentSize) {
            $arr['comment'] = Format::addEllipsis($expenses[$expenses_index]['comment'], 150);
        } else {
            $arr['comment'] = $expenses[$expenses_index]['comment'];
        }
        $arr['activityName'] = $expenses[$expenses_index]['designation'];
        $arr['username'] = $expenses[$expenses_index]['userName'];
        $arr['useralias'] = $expenses[$expenses_index]['userAlias'];
        $expenses_index++;
        invoice_add_to_array($result_arr, $arr, $short_form);
    }
    return $result_arr;
}
Exemple #6
0
/**
 * Get a combined array with time recordings and expenses to export.
 *
 * @param int $start Time from which to take entries into account.
 * @param int $end Time until which to take entries into account.
 * @param array $users Array of user IDs to filter by.
 * @param array $customers Array of customer IDs to filter by.
 * @param array $projects Array of project IDs to filter by.
 * @param array $activities Array of activity IDs to filter by.
 * @param bool $limit sbould the amount of entries be limited
 * @param bool $reverse_order should the entries be put out in reverse order
 * @param string $default_location use this string if no location is set for the entry
 * @param int $filter_cleared (-1: show all, 0:only cleared 1: only not cleared) entries
 * @param int $filter_type (-1 show time and expenses, 0: only show time entries, 1: only show expenses)
 * @param int $limitCommentSize should comments be cut off, when they are too long
 * @return array with time recordings and expenses chronologically sorted
 */
function export_get_data($start, $end, $users = null, $customers = null, $projects = null, $activities = null, $limit = false, $reverse_order = false, $default_location = '', $filter_cleared = -1, $filter_type = -1, $limitCommentSize = true, $filter_refundable = -1)
{
    global $expense_ext_available, $database;
    $timeSheetEntries = array();
    $expenses = array();
    if ($filter_type != 1) {
        $timeSheetEntries = $database->get_timeSheet($start, $end, $users, $customers, $projects, $activities, $limit, $reverse_order, $filter_cleared);
    }
    if ($filter_type != 0 && $expense_ext_available) {
        $expenses = get_expenses($start, $end, $users, $customers, $projects, $limit, $reverse_order, $filter_refundable, $filter_cleared);
    }
    $result_arr = array();
    $timeSheetEntries_index = 0;
    $expenses_index = 0;
    $keys = array('type', 'id', 'time_in', 'time_out', 'duration', 'formattedDuration', 'decimalDuration', 'rate', 'wage', 'wage_decimal', 'budget', 'approved', 'statusID', 'status', 'billable', 'customerID', 'customerName', 'projectID', 'projectName', 'description', 'projectComment', 'activityID', 'activityName', 'comment', 'commentType', 'location', 'trackingNumber', 'username', 'cleared');
    while ($timeSheetEntries_index < count($timeSheetEntries) && $expenses_index < count($expenses)) {
        $arr = array();
        foreach ($keys as $key) {
            $arr[$key] = null;
        }
        $arr['location'] = $default_location;
        if (!$reverse_order && $timeSheetEntries[$timeSheetEntries_index]['start'] > $expenses[$expenses_index]['timestamp'] || $reverse_order && $timeSheetEntries[$timeSheetEntries_index]['start'] < $expenses[$expenses_index]['timestamp']) {
            if ($timeSheetEntries[$timeSheetEntries_index]['end'] != 0) {
                // active recordings will be omitted
                $arr['type'] = 'timeSheet';
                $arr['id'] = $timeSheetEntries[$timeSheetEntries_index]['timeEntryID'];
                $arr['time_in'] = $timeSheetEntries[$timeSheetEntries_index]['start'];
                $arr['time_out'] = $timeSheetEntries[$timeSheetEntries_index]['end'];
                $arr['duration'] = $timeSheetEntries[$timeSheetEntries_index]['duration'];
                $arr['formattedDuration'] = $timeSheetEntries[$timeSheetEntries_index]['formattedDuration'];
                $arr['decimalDuration'] = sprintf("%01.2f", $timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600);
                $arr['rate'] = $timeSheetEntries[$timeSheetEntries_index]['rate'];
                $arr['wage'] = $timeSheetEntries[$timeSheetEntries_index]['wage'];
                $arr['wage_decimal'] = $timeSheetEntries[$timeSheetEntries_index]['wage_decimal'];
                $arr['budget'] = $timeSheetEntries[$timeSheetEntries_index]['budget'];
                $arr['approved'] = $timeSheetEntries[$timeSheetEntries_index]['approved'];
                $arr['statusID'] = $timeSheetEntries[$timeSheetEntries_index]['statusID'];
                $arr['status'] = $timeSheetEntries[$timeSheetEntries_index]['status'];
                $arr['billable'] = $timeSheetEntries[$timeSheetEntries_index]['billable'];
                $arr['customerID'] = $timeSheetEntries[$timeSheetEntries_index]['customerID'];
                $arr['customerName'] = $timeSheetEntries[$timeSheetEntries_index]['customerName'];
                $arr['projectID'] = $timeSheetEntries[$timeSheetEntries_index]['projectID'];
                $arr['projectName'] = $timeSheetEntries[$timeSheetEntries_index]['projectName'];
                $arr['description'] = $timeSheetEntries[$timeSheetEntries_index]['description'];
                $arr['projectComment'] = $timeSheetEntries[$timeSheetEntries_index]['projectComment'];
                $arr['activityID'] = $timeSheetEntries[$timeSheetEntries_index]['activityID'];
                $arr['activityName'] = $timeSheetEntries[$timeSheetEntries_index]['activityName'];
                if ($limitCommentSize) {
                    $arr['comment'] = Kimai_Format::addEllipsis($timeSheetEntries[$timeSheetEntries_index]['comment'], 150);
                } else {
                    $arr['comment'] = $timeSheetEntries[$timeSheetEntries_index]['comment'];
                }
                $arr['commentType'] = $timeSheetEntries[$timeSheetEntries_index]['commentType'];
                $arr['location'] = $timeSheetEntries[$timeSheetEntries_index]['location'];
                $arr['trackingNumber'] = $timeSheetEntries[$timeSheetEntries_index]['trackingNumber'];
                $arr['username'] = $timeSheetEntries[$timeSheetEntries_index]['userName'];
                $arr['cleared'] = $timeSheetEntries[$timeSheetEntries_index]['cleared'];
                $result_arr[] = $arr;
            }
            $timeSheetEntries_index++;
        } else {
            $arr['type'] = 'expense';
            $arr['id'] = $expenses[$expenses_index]['expenseID'];
            $arr['time_in'] = $expenses[$expenses_index]['timestamp'];
            $arr['time_out'] = $expenses[$expenses_index]['timestamp'];
            $arr['wage'] = sprintf("%01.2f", $expenses[$expenses_index]['value'] * $expenses[$expenses_index]['multiplier']);
            $arr['customerID'] = $expenses[$expenses_index]['customerID'];
            $arr['customerName'] = $expenses[$expenses_index]['customerName'];
            $arr['projectID'] = $expenses[$expenses_index]['projectID'];
            $arr['projectName'] = $expenses[$expenses_index]['projectName'];
            $arr['description'] = $expenses[$expenses_index]['designation'];
            $arr['projectComment'] = $expenses[$expenses_index]['projectComment'];
            if ($limitCommentSize) {
                $arr['comment'] = Kimai_Format::addEllipsis($expenses[$expenses_index]['comment'], 150);
            } else {
                $arr['comment'] = $expenses[$expenses_index]['comment'];
            }
            $arr['activityName'] = $expenses[$expenses_index]['designation'];
            $arr['comment'] = $expenses[$expenses_index]['comment'];
            $arr['commentType'] = $expenses[$expenses_index]['commentType'];
            $arr['username'] = $expenses[$expenses_index]['userName'];
            $arr['cleared'] = $expenses[$expenses_index]['cleared'];
            $result_arr[] = $arr;
            $expenses_index++;
        }
    }
    while ($timeSheetEntries_index < count($timeSheetEntries)) {
        if ($timeSheetEntries[$timeSheetEntries_index]['end'] != 0) {
            // active recordings will be omitted
            $arr = array();
            foreach ($keys as $key) {
                $arr[$key] = null;
            }
            $arr['location'] = $default_location;
            $arr['type'] = 'timeSheet';
            $arr['id'] = $timeSheetEntries[$timeSheetEntries_index]['timeEntryID'];
            $arr['time_in'] = $timeSheetEntries[$timeSheetEntries_index]['start'];
            $arr['time_out'] = $timeSheetEntries[$timeSheetEntries_index]['end'];
            $arr['duration'] = $timeSheetEntries[$timeSheetEntries_index]['duration'];
            $arr['formattedDuration'] = $timeSheetEntries[$timeSheetEntries_index]['formattedDuration'];
            $arr['decimalDuration'] = sprintf("%01.2f", $timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600);
            $arr['rate'] = $timeSheetEntries[$timeSheetEntries_index]['rate'];
            $arr['wage'] = $timeSheetEntries[$timeSheetEntries_index]['wage'];
            $arr['wage_decimal'] = $timeSheetEntries[$timeSheetEntries_index]['wage_decimal'];
            $arr['budget'] = $timeSheetEntries[$timeSheetEntries_index]['budget'];
            $arr['approved'] = $timeSheetEntries[$timeSheetEntries_index]['approved'];
            $arr['statusID'] = $timeSheetEntries[$timeSheetEntries_index]['statusID'];
            $arr['status'] = $timeSheetEntries[$timeSheetEntries_index]['status'];
            $arr['billable'] = $timeSheetEntries[$timeSheetEntries_index]['billable'];
            $arr['customerID'] = $timeSheetEntries[$timeSheetEntries_index]['customerID'];
            $arr['customerName'] = $timeSheetEntries[$timeSheetEntries_index]['customerName'];
            $arr['projectID'] = $timeSheetEntries[$timeSheetEntries_index]['projectID'];
            $arr['projectName'] = $timeSheetEntries[$timeSheetEntries_index]['projectName'];
            $arr['projectComment'] = $timeSheetEntries[$timeSheetEntries_index]['projectComment'];
            $arr['activityID'] = $timeSheetEntries[$timeSheetEntries_index]['activityID'];
            $arr['activityName'] = $timeSheetEntries[$timeSheetEntries_index]['activityName'];
            $arr['description'] = $timeSheetEntries[$timeSheetEntries_index]['description'];
            if ($limitCommentSize) {
                $arr['comment'] = Kimai_Format::addEllipsis($timeSheetEntries[$timeSheetEntries_index]['comment'], 150);
            } else {
                $arr['comment'] = $timeSheetEntries[$timeSheetEntries_index]['comment'];
            }
            $arr['commentType'] = $timeSheetEntries[$timeSheetEntries_index]['commentType'];
            $arr['location'] = $timeSheetEntries[$timeSheetEntries_index]['location'];
            $arr['trackingNumber'] = $timeSheetEntries[$timeSheetEntries_index]['trackingNumber'];
            $arr['username'] = $timeSheetEntries[$timeSheetEntries_index]['userName'];
            $arr['cleared'] = $timeSheetEntries[$timeSheetEntries_index]['cleared'];
            $result_arr[] = $arr;
        }
        $timeSheetEntries_index++;
    }
    while ($expenses_index < count($expenses)) {
        $arr = array();
        foreach ($keys as $key) {
            $arr[$key] = null;
        }
        $arr['location'] = $default_location;
        $arr['type'] = 'expense';
        $arr['id'] = $expenses[$expenses_index]['expenseID'];
        $arr['time_in'] = $expenses[$expenses_index]['timestamp'];
        $arr['time_out'] = $expenses[$expenses_index]['timestamp'];
        $arr['wage'] = sprintf("%01.2f", $expenses[$expenses_index]['value'] * $expenses[$expenses_index]['multiplier']);
        $arr['customerID'] = $expenses[$expenses_index]['customerID'];
        $arr['customerName'] = $expenses[$expenses_index]['customerName'];
        $arr['projectID'] = $expenses[$expenses_index]['projectID'];
        $arr['projectName'] = $expenses[$expenses_index]['projectName'];
        $arr['description'] = $expenses[$expenses_index]['designation'];
        $arr['projectComment'] = $expenses[$expenses_index]['projectComment'];
        if ($limitCommentSize) {
            $arr['comment'] = Kimai_Format::addEllipsis($expenses[$expenses_index]['comment'], 150);
        } else {
            $arr['comment'] = $expenses[$expenses_index]['comment'];
        }
        $arr['commentType'] = $expenses[$expenses_index]['commentType'];
        $arr['username'] = $expenses[$expenses_index]['userName'];
        $arr['cleared'] = $expenses[$expenses_index]['cleared'];
        $expenses_index++;
        $result_arr[] = $arr;
    }
    return $result_arr;
}
Exemple #7
0
$out = $timeframe[1];
$view = new Zend_View();
$view->setBasePath(WEBROOT . 'extensions/' . $dir_ext . '/' . $dir_templates);
$view->addHelperPath(WEBROOT . '/templates/helpers', 'Zend_View_Helper');
$view->kga = $kga;
// prevent IE from caching the response
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (isset($kga['user'])) {
    // user logged in
    $view->expenses = get_expenses($in, $out, array($kga['user']['userID']), null, null, 1);
} else {
    // customer logged in
    $view->expenses = get_expenses($in, $out, null, array($kga['customer']['customerID']), null, 1);
}
$view->total = Format::formatCurrency(array_reduce($view->expenses, function ($sum, $expense) {
    return $sum + $expense['multiplier'] * $expense['value'];
}, 0));
if (isset($kga['user'])) {
    // user logged in
    $ann = expenses_by_user($in, $out, array($kga['user']['userID']));
} else {
    // customer logged in
    $ann = expenses_by_user($in, $out, null, array($kga['customer']['customerID']));
}
$ann = Format::formatCurrency($ann);
$view->user_annotations = $ann;
// TODO: function for loops or convert it in template with new function
if (isset($kga['user'])) {
Exemple #8
0
$out = $timeframe[1];
$view = new Zend_View();
$view->setBasePath(WEBROOT . 'extensions/' . $dir_ext . '/' . $dir_templates);
$view->addHelperPath(WEBROOT . '/templates/helpers', 'Zend_View_Helper');
$view->assign('kga', $kga);
// prevent IE from caching the response
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (isset($kga['user'])) {
    // user logged in
    $view->assign('expenses', get_expenses($in, $out, [$kga['user']['userID']], null, null, 1));
} else {
    // customer logged in
    $view->assign('expenses', get_expenses($in, $out, null, [$kga['customer']['customerID']], null, 1));
}
$view->assign('total', Kimai_Format::formatCurrency(array_reduce($view->expenses, function ($sum, $expense) {
    return $sum + $expense['multiplier'] * $expense['value'];
}, 0)));
if (isset($kga['user'])) {
    // user logged in
    $ann = expenses_by_user($in, $out, array($kga['user']['userID']));
} else {
    // customer logged in
    $ann = expenses_by_user($in, $out, null, array($kga['customer']['customerID']));
}
$ann = Kimai_Format::formatCurrency($ann);
$view->assign('user_annotations', $ann);
// TODO: function for loops or convert it in template with new function
if (isset($kga['user'])) {