..." while (!(strpos($textToParse, "") === FALSE)) { $beginTagPosBegin = strpos($textToParse, ""); $beginTagPosEnd = $beginTagPosBegin + 12; $endTagPosBegin = strpos($textToParse, ""); $endTagPosEnd = $endTagPosBegin + 13; if ($beginTagPosEnd < $endTagPosBegin) : $tagContent = substr($textToParse, $beginTagPosEnd, $endTagPosBegin - $beginTagPosEnd); if ($tagContent != "") : // $tagContent = "" . $tagContent . ""; endif; // Substitute text fragment $textToParse = substr_replace($textToParse, $tagContent, $beginTagPosBegin, $endTagPosEnd - $beginTagPosBegin); endif; } endif; return $textToParse; } function getDistinctValuesOfTimeInterval ($mode = "days") { global $db, $PHP_SELF; global $f_hq_id, $f_usr_id, $f_grp_id, $fromDateRange, $toDateRange; $retArray = array(); $whereClause = " AND usr.hq_id = '" . $f_hq_id . "' "; if ($f_usr_id != "") : $whereClause .= " AND usr.usr_id = '" . $f_usr_id . "' "; // Filter by user endif; $whereClause = "tt.tt_datetime >= '" . $fromDateRange . "' AND tt.tt_datetime <= '" . $toDateRange . "' AND tt.usr_id = usr.usr_id" . $whereClause; if ($mode == "days") : $retArray = getColVectorFromDB2ArrayByClause("phoenix_group.timetracking AS tt, phoenix.user AS usr", "LEFT(tt.tt_datetime,10) AS tt_date", $whereClause, "", "tt_date", "DISTINCT"); elseif ($mode == "users") : $retArray = getColVectorFromDB2ArrayByClause("phoenix_group.timetracking AS tt, phoenix.user AS usr", "usr.usr_id", $whereClause, "", "usr.usr_id", "DISTINCT"); else : // Default mode "days" $retArray = getColVectorFromDB2ArrayByClause("phoenix_group.timetracking AS tt, phoenix.user AS usr", "LEFT(tt.tt_datetime,10) AS tt_date", $whereClause, "", "tt_date", "DISTINCT"); endif; return $retArray; } function getTimeTrackingData ($orderByClause = "") { global $db, $PHP_SELF; global $f_statistic, $f_hq_id, $f_usr_id, $f_grp_id, $fromDateRange, $toDateRange; global $f_filter_01, $f_filter_02, $f_filter_03, $f_filter_04; // echo $fromDateRange . "
" . $toDateRange . "
" . $f_statistic . "
"; $retArray = array(); if ($f_statistic != "" && $f_statistic > "0") : $fromClause = ""; $whereClause = " AND usr.hq_id = '" . $f_hq_id . "' "; if ($f_usr_id != "") : $whereClause .= " AND usr.usr_id = '" . $f_usr_id . "' "; // Filter by user endif; if ($f_grp_id != "") : $fromClause .= ", phoenix.courier AS couier"; $whereClause .= " AND usr.usr_id = cr.usr_id AND cr.group LIKE '%," . $f_grp_id . ",%' "; // Filter by group endif; if ($orderByClause == "") : $orderByClause = "usr.usr_id, tt.tt_datetime"; endif; $sqlquery = "SELECT tt.tt_datetime, UNIX_TIMESTAMP(tt.tt_datetime) AS tt_unixtime, tt.tt_id, tt.tt_gps_long, tt.tt_gps_lat, tt.tt_description, usr.usr_id" . " FROM phoenix_group.timetracking AS tt, phoenix.user AS usr" . " WHERE tt.tt_datetime >= '" . $fromDateRange . "' AND tt.tt_datetime <= '" . $toDateRange . "' AND tt.usr_id = usr.usr_id" . $whereClause . " ORDER BY " . $orderByClause; // echo $sqlquery . "
"; $result = $db->query($sqlquery); while ($row = $result->fetch_assoc()): $retArray[] = $row; endwhile; $result->free(); endif; return $retArray; } // Gets the worktime of all users inside the time interval function getWorktimePerTimeInterval ($statArray, $days, $users) { global $db, $PHP_SELF; global $f_statistic, $f_hq_id, $f_usr_id, $f_grp_id, $fromDateRange, $toDateRange; global $currentTimestamp, $currentDate, $startEndClockTimeArray; global $f_filter_01, $f_filter_02, $f_filter_03, $f_filter_04; $workTimePerUserArray = array(); // Minutes only (e.g. 375 minutes) $startEndClockTimeArray = array(); // Start and end time of the user of the day if (is_array($statArray)) : // Get all days inside the time interval if (!is_array($days)) : $days = getDistinctValuesOfTimeInterval("days"); endif; $daysLen = count($days); // Get all users inside the time interval if (!is_array($users)) : $users = getDistinctValuesOfTimeInterval("users"); endif; $usersLen = count($users); // **** Init **** $statArrayLen = count($statArray); $remUsrId = $statArray[0]["usr_id"]; $remDateTime = $statArray[0]["tt_datetime"]; $remLastEventArray = array(); for ($k = 0; $k < $usersLen; $k++) : $remLastEventArray[$users[$k]] = "2"; endfor; $remLastEvent = "2"; // Init with first time for first user $tmpHourMinute = substr($remDateTime,11,5); $startEndClockTimeArray[$remUsrId][$days[0]][0] = $tmpHourMinute; // echo "START : " . $remUsrId . " " . $days[0] . " " . $tmpHourMinute . "
"; $startEndClockTimeArray[$remUsrId][$days[0]][1] = $tmpHourMinute; // echo "END : " . $remUsrId . " " . $days[0] . " " . $tmpHourMinute . "
"; for ($j = 0; $j < $daysLen; $j++) : $currentDayBeginUnixTimestamp = mktime(0, 0, 0, intval(substr($days[$j],5,2)), intval(substr($days[$j],8,2)), intval(substr($days[$j],0,4))); if (substr($days[$j],0,10) == $currentDate) : $currentDayEndUnixTimestamp = mktime(intval(substr($currentTimestamp,11,2)), intval(substr($currentTimestamp,14,2)), intval(substr($currentTimestamp,17,2)), intval(substr($currentTimestamp,5,2)), intval(substr($currentTimestamp,8,2)), intval(substr($currentTimestamp,0,4))); else : $currentDayEndUnixTimestamp = mktime(23, 59, 59, intval(substr($days[$j],5,2)), intval(substr($days[$j],8,2)), intval(substr($days[$j],0,4))); endif; $lastUnixTimestamp = $currentDayBeginUnixTimestamp; if ($remLastEventArray[$statArray[$i]["usr_id"]] != "") : $remLastEvent = $remLastEventArray[$statArray[$i]["usr_id"]]; // Init with last event from last day would be possible !!!! endif; for ($i = 0; $i < $statArrayLen; $i++) : if (substr($statArray[$i]["tt_datetime"],0,10) == $days[$j]): // Set start time if ($remUsrId == $statArray[$i]["usr_id"]) : $tmpRemHourMinute = substr($remDateTime,11,5); if ($startEndClockTimeArray[$remUsrId][$days[$j]][0] == "") : $startEndClockTimeArray[$remUsrId][$days[$j]][0] = $tmpRemHourMinute; // echo "START : " . $remUsrId . " " . $days[$j] . " " . $tmpRemHourMinute . "
"; endif; // Set end time $tmpHourMinute = substr($statArray[$i]["tt_datetime"],11,5); if ($startEndClockTimeArray[$remUsrId][$days[$j]][1] == "" || $startEndClockTimeArray[$remUsrId][$days[$j]][1] < $tmpHourMinute) : $startEndClockTimeArray[$remUsrId][$days[$j]][1] = $tmpHourMinute; // echo "END : " . $remUsrId . " " . $days[$j] . " " . $tmpHourMinute . "
"; endif; endif; // Check for next user if ($remUsrId != $statArray[$i]["usr_id"]) : // Compute difference to end of the selected day if ($currentDayEndUnixTimestamp > $lastUnixTimestamp) : $tmpMinutesBetweenEvents = ($currentDayEndUnixTimestamp - $lastUnixTimestamp) / 60; // echo "usr_id : " . $remUsrId . "    remLastEvent : " . $remLastEvent . "    tmpMinutesBetweenEvents : " . $tmpMinutesBetweenEvents . " = (" . $statArray[$i]["tt_unixtime"] . " - " . $lastUnixTimestamp . ") / 60" . "    "; if (count($workTimePerUserArray[$remUsrId][$days[$j]]) == 0) : $workTimePerUserArray[$remUsrId][$days[$j]] = 0; endif; if ($remLastEvent == "1") : $workTimePerUserArray[$remUsrId][$days[$j]] += round($tmpMinutesBetweenEvents); endif; // echo "workTimePerUserArray[" . $remUsrId . "][" . $days[$j] . "] = " . $workTimePerUserArray[$remUsrId][$days[$j]] . "
"; endif; // Set values for the next user !!!! $remUsrId = $statArray[$i]["usr_id"]; $remDateTime = $statArray[$i]["tt_datetime"]; $remLastEvent = $remLastEvent[$statArray[$i]["usr_id"]]; $lastUnixTimestamp = $currentDayBeginUnixTimestamp; $count++; endif; $tmpMinutesBetweenEvents = ($statArray[$i]["tt_unixtime"] - $lastUnixTimestamp) / 60; // echo "usr_id : " . $remUsrId . "    remLastEvent : " . $remLastEvent . "    tmpMinutesBetweenEvents : " . $tmpMinutesBetweenEvents . " = (" . $statArray[$i]["tt_unixtime"] . " - " . $lastUnixTimestamp . ") / 60" . "    "; if (count($workTimePerUserArray[$remUsrId][$days[$j]]) == 0) : $workTimePerUserArray[$remUsrId][$days[$j]] = 0; endif; if ($remLastEvent == "1") : $workTimePerUserArray[$remUsrId][$days[$j]] += round($tmpMinutesBetweenEvents); endif; $lastUnixTimestamp = $statArray[$i]["tt_unixtime"]; $remLastEvent[$statArray[$i]["usr_id"]] = $statArray[$i]["tt_id"]; $remLastEvent = $remLastEvent[$statArray[$i]["usr_id"]]; // echo "workTimePerUserArray[" . $remUsrId . "][" . $days[$j] . "] = " . $workTimePerUserArray[$remUsrId][$days[$j]] . "
"; endif; endfor; // Compute difference to end of the selected day of the last user displayed if ($currentDayEndUnixTimestamp > $lastUnixTimestamp) : $tmpMinutesBetweenEvents = ($currentDayEndUnixTimestamp - $lastUnixTimestamp) / 60; // echo "usr_id : " . $remUsrId . "    remLastEvent : " . $remLastEvent . "    tmpMinutesBetweenEvents : " . $tmpMinutesBetweenEvents . " = (" . $statArray[$i]["tt_unixtime"] . " - " . $lastUnixTimestamp . ") / 60" . "    "; if (count($workTimePerUserArray[$remUsrId][$days[$j]]) == 0) : $workTimePerUserArray[$remUsrId][$days[$j]] = 0; endif; if ($remLastEvent == "1") : $workTimePerUserArray[$remUsrId][$days[$j]] += round($tmpMinutesBetweenEvents); endif; // echo "workTimePerUserArray[" . $remUsrId . "][" . $days[$j] . "] = " . $workTimePerUserArray[$remUsrId][$days[$j]] . "
"; endif; // echo "

"; endfor; endif; return $workTimePerUserArray; } // *************************** // * Calculate the statistic * // *************************** if ($f_act == "calculate") : // **** DAILY OUTPUT: Display timeline of one or more users **** if ($f_statistic == "10"): // Get statistic array $statArray = getTimeTrackingData(); // ORDER BY usr.usr_id, tt.tt_datetime !!!! $statArrayLen = count($statArray); $outputLinesArray = array(); $outputMatrixArray = array(); // Number of minutes $outputMatrixArray2 = array(); // Start- and endtime of the day if ($statArrayLen > 0) : // **** Init **** $workTimePerUserArray = array(); // Minutes only (e.g. 375 minutes) $workTimeHoursPerUserArray = array(); // Hours from $workTimePerUserArray[] (e.g. 6 hours (eq. 360 minutes)) $workTimeMinutesPerUserArray = array(); // Minutes remaining from $workTimePerUserArray[] (e.g. 15 minutes) $remUsrId = $statArray[0]["usr_id"]; $workTimePerUserArray[$remUsrId] = 0; $currentDayBeginUnixTimestamp = mktime(0, 0, 0, intval(substr($statArray[0]["tt_datetime"],5,2)), intval(substr($statArray[0]["tt_datetime"],8,2)), intval(substr($statArray[0]["tt_datetime"],0,4))); if (substr($statArray[0]["tt_datetime"],0,10) == $currentDate) : $currentDayEndUnixTimestamp = mktime(intval(substr($currentTimestamp,11,2)), intval(substr($currentTimestamp,14,2)), intval(substr($currentTimestamp,17,2)), intval(substr($currentTimestamp,5,2)), intval(substr($currentTimestamp,8,2)), intval(substr($currentTimestamp,0,4))); else : $currentDayEndUnixTimestamp = mktime(23, 59, 59, intval(substr($statArray[0]["tt_datetime"],5,2)), intval(substr($statArray[0]["tt_datetime"],8,2)), intval(substr($statArray[0]["tt_datetime"],0,4))); endif; $lastUnixTimestamp = $currentDayBeginUnixTimestamp; $remLastEvent = "2"; // Init with last event from last day would be possible !!!! // $coordLong = $statArray[0]["tt_gps_long"]; // $coordLat = $statArray[0]["tt_gps_lat"]; $coordLong = ""; $coordLat = ""; // **** Timeline header **** $screenOutput .= "\n"; $screenOutput .= "\n"; $screenOutput .= "\n"; $imgFilename = "../images/timetracking_hour_" . pad($i, 2); if (!file_exists($imgFilename)) : $im = imagecreate(60, $timelineHeight) or die ("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate ($im, 255, 255, 255); $lineCol = imagecolorallocate ($im, 0, 0, 0); imagettftext ($im, 8, 0, 5, 10, $lineCol, "../include/arial.ttf", pad($i, 2)); imagepng ($im, $imgFilename); imagedestroy ($im); endif; $screenOutput .= ""; $screenOutput .= ""; endfor; $screenOutput .= ""; $screenOutput .= "\n"; // $screenOutput .= "
" . getLngt("Mitarbeiter") . "\n"; for ($i = 0; $i <= 23; $i++) : // $screenOutput .= "" . pad($i, 2) . "" . getLngt("Nettoarbeitszeit") . "\n"; $screenOutput .= "
\n"; $outUser = $remUsrId; if (!$userAnonymised) : $tmpUsrName = getFieldValueFromId("user", "usr_id", $remUsrId, "usr_name"); $tmpUsrFirstname = getFieldValueFromId("user", "usr_id", $remUsrId, "usr_firstname"); $outUser = substr($tmpUsrName . ", " . substr($tmpUsrFirstname, 0, 1) . ".", 0, 15); endif; // **** Timelines **** // $screenOutput .= "\n"; $screenOutput .= ""; // Set values for the next user !!!! $remUsrId = $statArray[$i]["usr_id"]; $workTimePerUserArray[$remUsrId] = 0; $outUser = $remUsrId; if (!$userAnonymised) : $tmpUsrName = getFieldValueFromId("user", "usr_id", $remUsrId, "usr_name"); $tmpUsrFirstname = getFieldValueFromId("user", "usr_id", $remUsrId, "usr_firstname"); $outUser = substr($tmpUsrName . ", " . substr($tmpUsrFirstname, 0, 1) . ".", 0, 15); endif; $screenOutput .= ""; $screenOutput .= "
" . $outUser . "    \n"; for ($i = 0; $i < $statArrayLen; $i++) : // Check for next user if ($remUsrId != $statArray[$i]["usr_id"]) : // Compute difference to end of the selected day if ($currentDayEndUnixTimestamp > $lastUnixTimestamp) : $tmpMinutesBetweenEvents = (($currentDayEndUnixTimestamp - $lastUnixTimestamp) * $pixelWidthPerMinute) / 60; $tmpColorImage = "spacer_red.jpg"; if ($remLastEvent == "1") : $workTimePerUserArray[$remUsrId] += round($tmpMinutesBetweenEvents); $tmpColorImage = "spacer_green.jpg"; endif; $tmpWidthOfImage = round($tmpMinutesBetweenEvents * $pixelWidthPerMinute); // Hour and minutes $tmpTimeHours = floor(($currentDayEndUnixTimestamp - $lastUnixTimestamp) / 3600); $tmpTimeMinutes = round(((($currentDayEndUnixTimestamp - $lastUnixTimestamp) / 3600) - $tmpTimeHours) * 60); $tmpTimeDiff = pad($tmpTimeHours,2) . " " . getLngt("Std.") . " " . pad($tmpTimeMinutes,2) . " " . getLngt("Min."); $screenOutput .= ""; $screenOutput .= ""; $screenOutput .= ""; endif; $workTimeHoursPerUserArray[$remUsrId] = floor(($workTimePerUserArray[$remUsrId]) / 60); $workTimeMinutesPerUserArray[$remUsrId] = round((($workTimePerUserArray[$remUsrId] / 60) - $workTimeHoursPerUserArray[$remUsrId]) * 60); $screenOutput .= "" . pad($workTimeHoursPerUserArray[$remUsrId],2) . " " . getLngt("Std.") . " " . pad($workTimeMinutesPerUserArray[$remUsrId],2) . " " . getLngt("Min.") . "
" . $outUser . "    \n"; $lastUnixTimestamp = $currentDayBeginUnixTimestamp; $remBeforeLastEvent = $remLastEvent; // For the last entry ONLY $remLastEvent = "2"; // Init with last event from last day would be possible !!!! $count++; endif; $tmpColorImage = "spacer_red.jpg"; // if ($statArray[$i]["tt_id"] == "2") : $tmpColorImage = "spacer_green.jpg"; endif; if ($remLastEvent == "1") : $tmpColorImage = "spacer_green.jpg"; endif; $tmpMinutesBetweenEvents = (($statArray[$i]["tt_unixtime"] - $lastUnixTimestamp) * $pixelWidthPerMinute) / 60; if ($remLastEvent == "1") : $workTimePerUserArray[$remUsrId] += round($tmpMinutesBetweenEvents); endif; $tmpWidthOfImage = round($tmpMinutesBetweenEvents * $pixelWidthPerMinute); // Hour and minutes $tmpTimeHours = floor(($statArray[$i]["tt_unixtime"] - $lastUnixTimestamp) / 3600); $tmpTimeMinutes = round(((($statArray[$i]["tt_unixtime"] - $lastUnixTimestamp) / 3600) - $tmpTimeHours) * 60); $tmpTimeDiff = pad($tmpTimeHours,2) . " " . getLngt("Std.") . " " . pad($tmpTimeMinutes,2) . " " . getLngt("Min."); $screenOutput .= ""; $screenOutput .= ""; $screenOutput .= ""; // Write working time only into file if ($statArray[$i]["tt_id"] == "2") : if (!$userAnonymised) : $tmpUsrName = getFieldValueFromId("user", "usr_id", $statArray[$i]["usr_id"], "usr_name"); $tmpUsrFirstname = getFieldValueFromId("user", "usr_id", $statArray[$i]["usr_id"], "usr_firstname"); endif; $outputLinesArray[] = substr($statArray[$i]["tt_datetime"], 0, 10) . ";" . (!$userAnonymised ? $tmpUsrName . ";" . $tmpUsrFirstname : $statArray[$i]["usr_id"]) . ";" . date("H:i:s", $lastUnixTimestamp) . ";" . date("H:i:s", $statArray[$i]["tt_unixtime"]) . ";" . $tmpTimeDiff . ";" . $workTimePerUserArray[$statArray[$i]["usr_id"]] . ";"; endif; $lastUnixTimestamp = $statArray[$i]["tt_unixtime"]; $remLastEvent = $statArray[$i]["tt_id"]; $remBeforeLastEvent = $remLastEvent; // For the last entry ONLY $coordLong = $statArray[$i]["tt_gps_long"]; $coordLat = $statArray[$i]["tt_gps_lat"]; endfor; // Compute difference to end of the selected day of the last user displayed if ($currentDayEndUnixTimestamp > $lastUnixTimestamp) : $tmpMinutesBetweenEvents = (($currentDayEndUnixTimestamp - $lastUnixTimestamp) * $pixelWidthPerMinute) / 60; $tmpColorImage = "spacer_red.jpg"; if ($remBeforeLastEvent == "1") : $workTimePerUserArray[$remUsrId] += round($tmpMinutesBetweenEvents); $tmpColorImage = "spacer_green.jpg"; endif; $tmpWidthOfImage = round($tmpMinutesBetweenEvents * $pixelWidthPerMinute); // Hour and minutes $tmpTimeHours = floor(($currentDayEndUnixTimestamp - $lastUnixTimestamp) / 3600); $tmpTimeMinutes = round(((($currentDayEndUnixTimestamp - $lastUnixTimestamp) / 3600) - $tmpTimeHours) * 60); $tmpTimeDiff = pad($tmpTimeHours,2) . " " . getLngt("Std.") . " " . pad($tmpTimeMinutes,2) . " " . getLngt("Min."); $screenOutput .= ""; $screenOutput .= ""; $screenOutput .= ""; endif; $workTimeHoursPerUserArray[$remUsrId] = floor(($workTimePerUserArray[$remUsrId]) / 60); $workTimeMinutesPerUserArray[$remUsrId] = round((($workTimePerUserArray[$remUsrId] / 60) - $workTimeHoursPerUserArray[$remUsrId]) * 60); $screenOutput .= "" . pad($workTimeHoursPerUserArray[$remUsrId],2) . " " . getLngt("Std.") . " " . pad($workTimeMinutesPerUserArray[$remUsrId],2) . " " . getLngt("Min.") . "
\n"; endif; endif; // **** MONTHLY OUTPUT: Display timeline of one or more users **** if ($f_statistic == "11"): // Get statistic array of raw data $statArray = getTimeTrackingData("LEFT(tt.tt_datetime,10), usr.usr_id, tt.tt_datetime"); // ORDER BY usr.usr_id, tt.tt_datetime !!!! // Get days (DISTINCT) of raw data $users = getDistinctValuesOfTimeInterval("users"); $usersLen = count($users); // Get name, firstname, etc. of the user $userData = array(); if (!$userAnonymised) : for ($i = 0; $i < $usersLen; $i++) : $tmpUsrName = getFieldValueFromId("user", "usr_id", $users[$i], "usr_name"); $tmpUsrFirstname = getFieldValueFromId("user", "usr_id", $users[$i], "usr_firstname"); $userData[$users[$i]] = array($tmpUsrName, $tmpUsrFirstname); endfor; endif; // Get days (DISTINCT) of raw data $days = getDistinctValuesOfTimeInterval("days"); $daysLen = count($days); $workTimePerUserArray = getWorktimePerTimeInterval($statArray, $days, $users); $colorImageArray = array("spacer_green.jpg", "spacer_purple.jpg", "spacer_blue_menu_01.jpg", "spacer_white.jpg", "spacer_black.jpg", "spacer_red.jpg", "spacer_green.jpg", "spacer_purple.jpg", "spacer_blue_menu_01.jpg", "spacer_white.jpg", "spacer_black.jpg", "spacer_red.jpg", "spacer_green.jpg", "spacer_purple.jpg", "spacer_blue_menu_01.jpg", "spacer_white.jpg", "spacer_black.jpg", "spacer_red.jpg", "spacer_green.jpg", "spacer_purple.jpg", "spacer_blue_menu_01.jpg", "spacer_white.jpg", "spacer_black.jpg", "spacer_red.jpg", "spacer_green.jpg", "spacer_purple.jpg", "spacer_blue_menu_01.jpg", "spacer_white.jpg", "spacer_black.jpg", "spacer_red.jpg", "spacer_green.jpg", "spacer_purple.jpg", "spacer_blue_menu_01.jpg", "spacer_white.jpg", "spacer_black.jpg", "spacer_red.jpg"); $height = "5"; $screenOutput = "\n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; // File matrix output if ($writeHeader == "1") : $headline = ""; for ($i = 0; $i < $usersLen; $i++) : $headline .= $delimiter . $userData[$users[$i]][0] . ", " . $userData[$users[$i]][1]; endfor; $outputMatrixArray[] = getLngt("Datum") . $headline; $outputMatrixArray2[] = getLngt("Datum") . $headline; endif; $count = 0; $numOfDaysOfTheMonth = $calMonthDays[$selMonth - 1]; for ($j = 1; $j <= $numOfDaysOfTheMonth; $j++) : $tmpDay = $selYear . "-" . pad($selMonth,2) . "-" . pad($j,2); // File matrix output $bodyLine = $tmpDay; $bodyLine2 = $tmpDay; $tmpNumOfTheDay = date("w", mktime(0, 0, 0, $selMonth, $j, $selYear)); // 0 = Sunday, 1 = Monday, etc. if ($tmpNumOfTheDay == 0) : $tmpNumOfTheDay = "7"; endif; // Reformat to 1 = Monday, ... , 7 = Sunday $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; // File matrix output $outputMatrixArray[] = $bodyLine; $outputMatrixArray2[] = $bodyLine2; endfor; $screenOutput .= "
\n"; $screenOutput .= $calMonthNames[$selMonth - 1] . " " . $selYear . "

"; $screenOutput .= "
Anzahl Stunden                            \n"; for ($h = 1; $h <= 24; $h++) : $screenOutput .= "  " . pad($h,2) . "      "; // $screenOutput .= "
" . pad($h,2) . "
"; endfor; $screenOutput .= "
\n"; $screenOutput .= "" . pad($j,2) . ".  "; if ($tmpNumOfTheDay == "7") : $screenOutput .= "(" . $calWeekDays[$tmpNumOfTheDay - 1] . ")"; else : $screenOutput .= "(" . $calWeekDays[$tmpNumOfTheDay - 1] . ")"; endif; $screenOutput .= "
\n"; $screenOutput .= " \n"; for ($i = 0; $i < $usersLen; $i++) : $minutesOfUserOfDay = $workTimePerUserArray[$users[$i]][$tmpDay]; if ($minutesOfUserOfDay == "") : $minutesOfUserOfDay = 0; endif; $tmpHours = floor(($minutesOfUserOfDay) / 60); $tmpMinutes = round((($minutesOfUserOfDay / 60) - $tmpHours) * 60); $outUser = $users[$i]; if (!$userAnonymised) : $outUser = substr($userData[$users[$i]][0] . ", " . substr($userData[$users[$i]][1], 0, 1) . ".", 0, 15); endif; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $screenOutput .= " \n"; $outputLinesArray[$count] = $users[$i] . ";" . (!$userAnonymised ? $userData[$users[$i]][0] . ";" . $userData[$users[$i]][1] . ";" : "") . $tmpDay . ";" . $minutesOfUserOfDay . ";" . $tmpHours . ";" . $tmpMinutes . ";"; // File matrix output $bodyLine .= $delimiter . $minutesOfUserOfDay; // echo $users[$i] . " => " . $tmpDay . " => " . $startEndClockTimeArray[$users[$i]][$tmpDay][0] . "-" . $startEndClockTimeArray[$users[$i]][$tmpDay][1] . "
"; $bodyLine2 .= $delimiter . $startEndClockTimeArray[$users[$i]][$tmpDay][0] . "-" . $startEndClockTimeArray[$users[$i]][$tmpDay][1]; $count++; endfor; $screenOutput .= "
" . $outUser . "" . pad($tmpHours,2) . " Std. " . pad($tmpMinutes,2) . " Min.\n"; $screenOutput .= " "; $screenOutput .= "
\n"; $screenOutput .= "
\n"; endif; $outputMatrixArrayLen = count($outputMatrixArray); $outputMatrixArray2Len = count($outputMatrixArray2); // **** Optional output to file **** $f_secretFileName = ""; if ($fileOutput) : // Remove old files /* foreach (glob("../temp/download/" . "*.tt.csv") as $fileNameToBoRemoved) { if ((time() - filemtime($fileNameToBoRemoved)) > 60) : if (file_exists($fileNameToBoRemoved)) : unlink($fileNameToBoRemoved); endif; endif; } */ $f_fileName = getLngt("ZEITERFASSUNG") . "_" . $selYear . pad($selMonth,2) . pad($selDay,2) . ".csv"; if ($f_statistic == "11"): $outputLinesArray = $outputMatrixArray; // HARDCODED SWITCH BETWEEN OUTPUT FILE FORMAT VERSION 1 AND 2 if ($outputMatrixArray2Len > 0) : for ($p = $outputMatrixArrayLen; $p < 35; $p++) : $outputLinesArray[] = "-------"; endfor; $outputLinesArray = array_merge($outputLinesArray, $outputMatrixArray2); endif; $f_fileName = getLngt("ZEITERFASSUNG") . "_" . $selYear . pad($selMonth,2) . ".csv"; endif; // Check for using secret filename $f_secretFileName = $f_fileName; if (false) : $f_secretFileName = md5($f_secretFileName) . ".csv"; endif; // Remove existing file if does exist if (file_exists("../temp/download/" . $f_secretFileName)) : unlink("../temp/download/" . $f_secretFileName); endif; // Define output parameters // include_once ("../include/inc_list_defineoutput2file.inc.php"); $outputLinesArrayLen = count($outputLinesArray); if ($outputLinesArrayLen > 0) : if ($outputHeader != "") : writeToFile("../temp/download/" . $f_secretFileName, $outputHeader); // Write header if requested endif; for ($i = 0; $i < $outputLinesArrayLen; $i++) : $outputLinesArray[$i] = str_replace(" ", " ", $outputLinesArray[$i]); // echo $i . " => " . $outputLinesArray[$i] . "
"; writeToFile("../temp/download/" . $f_secretFileName, $outputLinesArray[$i]); // Write timetracking data endfor; else : $statusMessage = "Es wurden keine Daten gefunden! Eine Datei wurde deshalb nicht generiert!"; $fileOutput = false; endif; endif; endif; // FOR SIMULATION ONLY if ($f_act == "simulator_start") : insertStmt("phoenix_group.timetracking", array("tt_datetime",$currentTimestamp,"tt_id","1","usr_id",$usr_id,"tt_gps_long","","tt_gps_lat","","tt_description","")); endif; if ($f_act == "simulator_finish") : insertStmt("phoenix_group.timetracking", array("tt_datetime",$currentTimestamp,"tt_id","2","usr_id",$usr_id,"tt_gps_long","","tt_gps_lat","","tt_description","")); endif; // * Generate new key * $generatedKey = ""; if ($f_act == "generateNewAppusrCode") : if ($f_usr_id != "") : $generatedKey = md5(strval(rand(1000,9999)) . strval($f_usr_id) . strval(rand(1000,9999))); endif; endif; // * Store registration key * $outputErrStoringRegisterCodeOfUser = ""; if ($f_act == "storeNewAppusrCode") : if ($f_usr_id != "" && $f_appusr_code != "") : $regCodeArray = setRegisterCode("1", "8", $f_usr_id, $f_appusr_code); $errCode = $regCodeArray[0]; $errMsg = $regCodeArray[2]; if ($errCode != "0") : $outputErrStoringRegisterCodeOfUser .= "" . getLngt("Der Registrierungsschlüssel konnte nicht eingetragen werden!") . ""; else : $outputErrStoringRegisterCodeOfUser .= "" . $errMsg . ""; endif; else : $outputErrStoringRegisterCodeOfUser .= "" . getLngt("Der Registrierungsschlüssel ist leer!") . ""; endif; endif; // * Association between selected user and timetracking APP * $outputRegisterCodeOfUser = ""; if ($f_usr_id != "") : $usrName = getFieldValueFromId("user", "usr_id", $f_usr_id, "usr_name"); $usrFirstname = getFieldValueFromId("user", "usr_id", $f_usr_id, "usr_firstname"); // Get registration code for current user $regCodeArray = getRegisterCode("1", "8", $f_usr_id); $errCode = $regCodeArray[0]; if ($errCode == "0") : $appusrCode = $regCodeArray[1]; $appusrActivated = $regCodeArray[2]; if ($generatedKey != "") : $appusrCode = $generatedKey; $appusrActivated = "0"; endif; $outputRegisterCodeOfUser .= "" . "    " . ($appusrActivated == "1" ? getLngt("Aktiviert") : getLngt("Nicht aktiviert")); elseif ($errCode == "301") : $outputRegisterCodeOfUser .= "" . getLngt("Derzeit kann nicht auf die Registrierungsstruktur zugegriffen werden! Bitte kontaktieren Sie den Support!") . ""; elseif ($errCode == "302") : $outputRegisterCodeOfUser .= ""; $outputRegisterCodeOfUser .= "  " . getLngt("Derzeit existiert kein Registrierungsschlüssel für den Mitarbeiter!") . ""; endif; endif; if ($outputErrStoringRegisterCodeOfUser != "") : $outputRegisterCodeOfUser .= " " . $outputErrStoringRegisterCodeOfUser; // Attach error message from storing the register code endif; // **** OUTPUT **** // Javascript-function as template only for categorie depending on date-filter (not status-filter) $onLoadCall = ""; // $onLoadCall .= "displayStatusMessage();"; $js_date = ""; $js_date .= "\n"; $js_date .= "\n"; $js_date .= "\n"; if ($fileOutput) : $onLoadCall .= "downloadFile();"; endif; $onLoadCall .= "initForm();"; // Date ranges if ($f_statistic != "10" && $f_statistic != "11") : $statisticDateFilter = "von:\n"; endif; if ($f_statistic == "11") : $statisticDateFilter .= ""; $statisticDateFilter .= " "; $statisticDateFilter .= ""; // $statisticDateFilter .= getLngt("(Monat/Jahr)"); else : $statisticDateFilter .= "\n"; $statisticDateFilter .= "\n"; $statisticDateFilter .= "\n"; if ($f_statistic != "10") : $statisticDateFilter .= "  bis:\n"; $statisticDateFilter .= "\n"; $statisticDateFilter .= "\n"; $statisticDateFilter .= "\n"; $statisticDateFilter .= " "; endif; $statisticDateFilter .= "[" . $calCurrentWeekName . " " . $calCurrentWeekNum . "] "; endif; // Time ranges $statisticTimeFilter = ""; /* $statisticTimeFilter .= "["; $statisticTimeFilter .= "Ohne|"; $statisticTimeFilter .= "Mit"; $statisticTimeFilter .= "Einschränkung auf Zeitintervall von:\n"; $statisticTimeFilter .= "\n"; $statisticTimeFilter .= "\n"; $statisticTimeFilter .= "Uhr  bis:\n"; $statisticTimeFilter .= "\n"; $statisticTimeFilter .= "\n"; $statisticTimeFilter .= "Uhr]\n"; */ ?> <?php echo $pageTitel ?>
Optionen
         > Zusätzlicher Download der Daten
>SIMULATOR: