$wd = $kga['lang']['weekdays_short'][date("w", time())]; $dp_start = 0; if ($kga['calender_start'] != "") { $dp_start = $kga['calender_start']; } else { if (isset($kga['usr'])) { $dp_start = date("d/m/Y", getjointime($kga['usr']['usr_ID'])); } } $dp_today = date("d/m/Y", time()); $tpl->assign('dp_start', $dp_start); $tpl->assign('dp_today', $dp_today); if (isset($kga['customer'])) { $tpl->assign('total', formatDuration(get_zef_time($in, $out, null, array($kga['customer']['knd_ID'])))); } else { $tpl->assign('total', formatDuration(get_zef_time($in, $out, $kga['usr']['usr_ID']))); } // =========================== // = DatePicker localization = // =========================== $localized_DatePicker = ""; $tpl->assign('weekdays_array', sprintf("['%s','%s','%s','%s','%s','%s','%s']\n", $kga['lang']['weekdays'][0], $kga['lang']['weekdays'][1], $kga['lang']['weekdays'][2], $kga['lang']['weekdays'][3], $kga['lang']['weekdays'][4], $kga['lang']['weekdays'][5], $kga['lang']['weekdays'][6])); $tpl->assign('weekdays_short_array', sprintf("['%s','%s','%s','%s','%s','%s','%s']\n", $kga['lang']['weekdays_short'][0], $kga['lang']['weekdays_short'][1], $kga['lang']['weekdays_short'][2], $kga['lang']['weekdays_short'][3], $kga['lang']['weekdays_short'][4], $kga['lang']['weekdays_short'][5], $kga['lang']['weekdays_short'][6])); $tpl->assign('months_array', sprintf("['%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s']\n", $kga['lang']['months'][0], $kga['lang']['months'][1], $kga['lang']['months'][2], $kga['lang']['months'][3], $kga['lang']['months'][4], $kga['lang']['months'][5], $kga['lang']['months'][6], $kga['lang']['months'][7], $kga['lang']['months'][8], $kga['lang']['months'][9], $kga['lang']['months'][10], $kga['lang']['months'][11])); $tpl->assign('months_short_array', sprintf("['%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s']", $kga['lang']['months_short'][0], $kga['lang']['months_short'][1], $kga['lang']['months_short'][2], $kga['lang']['months_short'][3], $kga['lang']['months_short'][4], $kga['lang']['months_short'][5], $kga['lang']['months_short'][6], $kga['lang']['months_short'][7], $kga['lang']['months_short'][8], $kga['lang']['months_short'][9], $kga['lang']['months_short'][10], $kga['lang']['months_short'][11])); // ============================== // = assign smarty placeholders = // ============================== $tpl->assign('current_timer_hour', $current_timer['hour']); $tpl->assign('current_timer_min', $current_timer['min']); $tpl->assign('current_timer_sec', $current_timer['sec']);
if (isset($row['did']) and strlen($row['did'])) { formatDst($row['did'], $row['dcontext'] . ' # ' . $row['dst']); } else { formatDst($row['dst'], $row['dcontext']); } if (isset($display_column['extension']) and $display_column['extension'] == 1) { formatDst($row['dst'], $row['dcontext']); } formatApp($row['lastapp'], $row['lastdata']); formatChannel($row['channel']); if (isset($display_column['clid']) and $display_column['clid'] == 1) { formatClid($row['clid']); } formatChannel($row['dstchannel']); formatDisposition($row['disposition'], $row['amaflags']); formatDuration($row['duration'], $row['billsec']); if (isset($display_column['billsec']) and $display_column['billsec'] == 1) { formatBillSec($row['billsec']); } formatUserField($row['userfield']); if (isset($display_column['accountcode']) and $display_column['accountcode'] == 1) { formatAccountCode($row['accountcode']); } if (isset($_REQUEST['use_callrates']) && $_REQUEST['use_callrates'] == 'true') { $rates = callrates($row['dst'], $row['billsec'], $callrate_csv_file); $rate_total += $rates[4]; formatMoney($rates[4]); echo "<td>" . htmlspecialchars($rates[2]) . "</td>\n"; } echo " <td></td>\n"; echo " <td></td>\n";
// set smarty config require_once '../../libraries/smarty/Smarty.class.php'; $tpl = new Smarty(); $tpl->template_dir = 'templates/'; $tpl->compile_dir = 'compile/'; $tpl->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"); // Get the total time displayed in the table. if (isset($kga['customer'])) { $total = formatDuration(get_zef_time($in, $out, null, array($kga['customer']['knd_ID']), null)); } else { $total = formatDuration(get_zef_time($in, $out, array($kga['usr']['usr_ID']), null, null)); } $tpl->assign('total', $total); // Get the array of timesheet entries. if (isset($kga['customer'])) { $arr_zef = get_arr_zef($in, $out, null, array($kga['customer']['knd_ID']), null, 1); } else { $arr_zef = get_arr_zef($in, $out, array($kga['usr']['usr_ID']), null, null, 1); } if (count($arr_zef) > 0) { $tpl->assign('arr_zef', $arr_zef); } else { $tpl->assign('arr_zef', 0); } // Get the annotations for the user sub list. if (isset($kga['customer'])) {
function get_arr_knd_with_time($group, $user, $in, $out) { global $kga, $conn; $arr_knds = get_arr_knd($group); $arr_time = get_arr_time_knd($user, $in, $out); $arr = array(); $i = 0; foreach ($arr_knds as $knd) { $arr[$i]['knd_ID'] = $knd['knd_ID']; $arr[$i]['knd_name'] = $knd['knd_name']; $arr[$i]['knd_visible'] = $knd['knd_visible']; if (isset($arr_time[$knd['knd_ID']])) { $arr[$i]['zeit'] = formatDuration($arr_time[$knd['knd_ID']]); } else { $arr[$i]['zeit'] = formatDuration(0); } $i++; } return $arr; }
$filterEvt = explode(':', $filters[3]); } // if no userfilter is set, set it to current user if (isset($kga['usr']) && count($filterUsr) == 0) { array_push($filterUsr, $kga['usr']['usr_ID']); } if (isset($kga['customer'])) { $filterKnd = array($kga['customer']['knd_ID']); } $arr_zef = get_arr_zef($in, $out, $filterUsr, $filterKnd, $filterPct, $filterEvt, 1); if (count($arr_zef) > 0) { $tpl->assign('arr_zef', $arr_zef); } else { $tpl->assign('arr_zef', 0); } $tpl->assign('total', formatDuration(get_zef_time($in, $out, $filterUsr, $filterKnd, $filterPct, $filterEvt))); $ann = get_arr_time_usr($in, $out, $filterUsr, $filterKnd, $filterPct, $filterEvt); formatAnnotations($ann); $tpl->assign('usr_ann', $ann); $ann = get_arr_time_knd($in, $out, $filterUsr, $filterKnd, $filterPct, $filterEvt); formatAnnotations($ann); $tpl->assign('knd_ann', $ann); $ann = get_arr_time_pct($in, $out, $filterUsr, $filterKnd, $filterPct, $filterEvt); formatAnnotations($ann); $tpl->assign('pct_ann', $ann); $ann = get_arr_time_evt($in, $out, $filterUsr, $filterKnd, $filterPct, $filterEvt); formatAnnotations($ann); $tpl->assign('evt_ann', $ann); $tpl->display("zef.tpl"); break; // =========================
/** * returns list of projects and their time summary within zef_entry timespace as array * * OLD VERSION THAT MERGES TWO QUERYS - bad bad stuff ... * TODO: [tom] revise with join query! * * @param integer $group ID of group in table grp * @param integer $user ID of user in table usr * @param integer $in start time in unix seconds * @param integer $out end time in unix seconds * @global array $kga kimai-global-array * @return array * @author th */ function get_arr_pct_with_time($group, $user, $in, $out) { global $kga; //TODO: [tom] Functions results with 1 query $arr_pcts = get_arr_pct($group); $arr_time = get_arr_time_pct($user, $in, $out); //TODO END $arr = array(); $i = 0; foreach ($arr_pcts as $pct) { $arr[$i]['pct_ID'] = $pct['pct_ID']; $arr[$i]['knd_ID'] = $pct['knd_ID']; $arr[$i]['pct_name'] = $pct['pct_name']; $arr[$i]['pct_comment'] = $pct['pct_comment']; $arr[$i]['knd_name'] = $pct['knd_name']; $arr[$i]['pct_visible'] = $pct['pct_visible']; $arr[$i]['zeit'] = @formatDuration($arr_time[$pct['pct_ID']]); $i++; } return $arr; }
} elseif ($period === "monthly") { $analytics = EmployeeAnalytics::getMonthlyAnalytics($connection, $city); } else { $analytics = EmployeeAnalytics::getTodayAnalytics($connection, $city); } //No business collected by any employee if (empty($analytics) === TRUE) { $output_json = array("status" => "success", "count" => 0, "date" => getFormattedDate($period), "total_business_collected" => 0); echo json_encode($output_json); return; } $total_business_collected = calculateTotalBusinessCollected($analytics); //Add formatted duration to each analytic record foreach ($analytics as $index => $analytic_data) { $duration = $analytic_data["duration"]; $analytic_data["formatted_duration"] = formatDuration($duration); $analytics[$index] = $analytic_data; } echo json_encode(array("status" => "success", "count" => count($analytics), "date" => getFormattedDate($period), "analytics" => $analytics, "total_business_collected" => $total_business_collected)); } catch (DatabaseConnectionException $e) { $failure_json = array("status" => "error", "error" => "Database Unavailable"); echo json_encode($failure_json); return; } catch (QueryFailedException $e) { error_log(mysqli_error($connection)); $failure_json = array("status" => "error", "error" => "Query Failed"); echo json_encode($failure_json); return; } mysqli_close($connection); function calculateTotalBusinessCollected($analytics)