📄 get_csv.php
字号:
<?phpinclude '../config.inc.php';include '../functions.php';@$db = mysql_pconnect($db_hostname, $db_username, $db_password);if (!$db) {echo "Error: Could not connect to the database. Please try again later."; exit;}mysql_select_db($db_name);if (($_GET['rpt'] == 'timerpt') && (isset($_GET['display_ip'])) && (isset($_GET['csv'])) && (isset($_GET['office'])) && (isset($_GET['group'])) && (isset($_GET['fullname'])) && (isset($_GET['from'])) && (isset($_GET['to'])) && (isset($_GET['tzo']))) {$tmp_display_ip = $_GET['display_ip'];$tmp_csv = $_GET['csv'];$office_name = $_GET['office'];$group_name = $_GET['group'];$fullname = $_GET['fullname'];$from_timestamp = $_GET['from'];$to_timestamp = $_GET['to'];$tzo = $_GET['tzo'];$employees_cnt = 0;$employees_empfullname = array();$employees_displayname = array();$row_count = 0;$page_count = 0;// retrieve a list of users //$fullname = addslashes($fullname);if (strtolower($user_or_display) == "display") { if (($office_name == "All") && ($group_name == "All") && ($fullname == "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL order by displayname asc"; $result = mysql_query($query); } elseif ((empty($office_name)) && (empty($group_name)) && ($fullname == 'All')) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL order by displayname asc"; $result = mysql_query($query); } elseif ((empty($office_name)) && (empty($group_name)) && ($fullname != 'All')) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL and empfullname = '".$fullname."' order by displayname asc"; $result = mysql_query($query); } elseif (($office_name != "All") && ($group_name == "All") && ($fullname == "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees where office = '".$office_name."' and tstamp IS NOT NULL order by displayname asc"; $result = mysql_query($query); } elseif (($office_name != "All") && ($group_name != "All") && ($fullname == "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees where office = '".$office_name."' and groups = '".$group_name."' and tstamp IS NOT NULL order by displayname asc"; $result = mysql_query($query); } elseif (($office_name != "All") && ($group_name != "All") && ($fullname != "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees where office = '".$office_name."' and groups = '".$group_name."' and empfullname = '".$fullname."' and tstamp IS NOT NULL order by displayname asc"; $result = mysql_query($query); }} else { if (($office_name == "All") && ($group_name == "All") && ($fullname == "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL order by empfullname asc"; $result = mysql_query($query); } elseif ((empty($office_name)) && (empty($group_name)) && ($fullname == 'All')) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL order by empfullname asc"; $result = mysql_query($query); } elseif ((empty($office_name)) && (empty($group_name)) && ($fullname != 'All')) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL and empfullname = '".$fullname."' order by empfullname asc"; $result = mysql_query($query); } elseif (($office_name != "All") && ($group_name == "All") && ($fullname == "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees where office = '".$office_name."' and tstamp IS NOT NULL order by empfullname asc"; $result = mysql_query($query); } elseif (($office_name != "All") && ($group_name != "All") && ($fullname == "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees where office = '".$office_name."' and groups = '".$group_name."' and tstamp IS NOT NULL order by empfullname asc"; $result = mysql_query($query); } elseif (($office_name != "All") && ($group_name != "All") && ($fullname != "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees where office = '".$office_name."' and groups = '".$group_name."' and empfullname = '".$fullname."' and tstamp IS NOT NULL order by empfullname asc"; $result = mysql_query($query); }}while ($row=mysql_fetch_array($result)) { $employees_empfullname[] = stripslashes("".$row['empfullname'].""); $employees_displayname[] = stripslashes("".$row['displayname'].""); $employees_cnt++;}if (!empty($tmp_display_ip)) { $headings = "Name, In/Out, Time, Date, IP Address, Notes,\n";} else { $headings = "Name, In/Out, Time, Date, Notes,\n";}$string = "";for ($x=0;$x<$employees_cnt;$x++) { $fullname = stripslashes($fullname); if (($employees_empfullname[$x] == $fullname) || ($fullname == "All")) { $row_color = $color2; // Initial row color $employees_empfullname[$x] = addslashes($employees_empfullname[$x]); $employees_displayname[$x] = addslashes($employees_displayname[$x]); $query = "select ".$db_prefix."info.fullname, ".$db_prefix."info.`inout`, ".$db_prefix."info.timestamp, ".$db_prefix."info.notes, ".$db_prefix."info.ipaddress, ".$db_prefix."punchlist.in_or_out, ".$db_prefix."punchlist.punchitems, ".$db_prefix."punchlist.color from ".$db_prefix."info, ".$db_prefix."punchlist, ".$db_prefix."employees where ".$db_prefix."info.fullname like '".$employees_empfullname[$x]."' and ".$db_prefix."info.timestamp >= '".$from_timestamp."' and ".$db_prefix."info.timestamp <= '".$to_timestamp."' and ".$db_prefix."info.`inout` = ".$db_prefix."punchlist.punchitems and ".$db_prefix."employees.empfullname = '".$employees_empfullname[$x]."' order by ".$db_prefix."info.timestamp asc"; $result = mysql_query($query); while ($row=mysql_fetch_array($result)) { $display_stamp = "".$row["timestamp"].""; $time = date($timefmt, $display_stamp); $date = date($datefmt, $display_stamp); // display the query results // $display_stamp = $display_stamp + @$tzo; $time = date($timefmt, $display_stamp); $date = date($datefmt, $display_stamp); if (strtolower($user_or_display) == "display") { $displayname = stripslashes($employees_displayname[$x]); } else { $empfullname = stripslashes($employees_empfullname[$x]); } $inout = "".$row["inout"].""; if (!empty($tmp_display_ip)) { $ipaddress = "".$row["ipaddress"].""; } $notes = stripslashes("".$row["notes"].""); if (strtolower($user_or_display) == "display") { if (!empty($tmp_display_ip)) { $string .= "$displayname, $inout, $time, $date, $ipaddress, $notes,\n"; } else { $string .= "$displayname, $inout, $time, $date, $notes,\n"; } } else { if (!empty($tmp_display_ip)) { $string .= "$empfullname, $inout, $time, $date, $ipaddress, $notes,\n"; } else { $string .= "$empfullname, $inout, $time, $date, $notes,\n"; } } } }}header("Content-type: application/x-msdownload");header("Content-Disposition: attachment; filename=total_hours.csv");header("Pragma: no-cache");header("Expires: 0");echo "$headings$string";} elseif (($_GET['rpt'] == 'hrs_wkd') && (isset($_GET['display_ip'])) && (isset($_GET['csv'])) && (isset($_GET['office'])) && (isset($_GET['group'])) &&(isset($_GET['fullname'])) && (isset($_GET['from'])) && (isset($_GET['to'])) && (isset($_GET['tzo'])) && (isset($_GET['paginate'])) && (isset($_GET['round'])) && (isset($_GET['details'])) && (isset($_GET['rpt_run_on'])) && (isset($_GET['rpt_date'])) && (isset($_GET['from_date']))) {$tmp_display_ip = $_GET['display_ip'];$tmp_csv = $_GET['csv'];$office_name = $_GET['office'];$group_name = $_GET['group'];$fullname = $_GET['fullname'];$from_timestamp = $_GET['from'];$to_timestamp = $_GET['to'];$tzo = $_GET['tzo'];$tmp_paginate = $_GET['paginate'];$tmp_round_time = $_GET['round'];$tmp_show_details = $_GET['details'];$rpt_stamp = $_GET['rpt_run_on'];$rpt_date = $_GET['rpt_date'];$from_date = $_GET['from_date'];$employees_cnt = 0;$employees_empfullname = array();$employees_displayname = array();$info_cnt = 0;$info_fullname = array();$info_inout = array();$info_timestamp = array();$info_notes = array();$info_date = array();$info_start_time = array();$info_end_time = array();$punchlist_in_or_out = array();$punchlist_punchitems = array();$secs = 0;$total_hours = 0;$row_count = 0;$page_count = 0;$punch_cnt = 0;$tmp_z = 0;// retrieve a list of users //$fullname = addslashes($fullname);if (strtolower($user_or_display) == "display") { if (($office_name == "All") && ($group_name == "All") && ($fullname == "All")) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL order by displayname asc"; $result = mysql_query($query); } elseif ((empty($office_name)) && (empty($group_name)) && ($fullname == 'All')) { $query = "select empfullname, displayname from ".$db_prefix."employees WHERE tstamp IS NOT NULL order by displayname asc"; $result = mysql_query($query); } elseif ((empty($office_name)) && (empty($group_name)) && ($fullname != 'All')) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -