- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
<?php
if($_POST["phones_csv_load"]) {
if(is_uploaded_file($_FILES["phones_csv"]["tmp_name"])) {
if (($handle = fopen($_FILES["phones_csv"]["tmp_name"], "r")) !== FALSE) {
$linecount = (exec('perl -pe \'s/\r\n|\n|\r/\n/g\' ' . escapeshellarg($_FILES["phones_csv"]["tmp_name"]) . ' | wc -l')) - 1;
for($i = 0; $i <= $linecount; $i++) {
$data = str_getcsv(iconv("cp1251", "utf8", stream_get_line($handle, 8000, "\n")), "\t");
$datetime = explode(" ", $data[28]);
$datetime["date"] = explode(".", $datetime[0]);
$datetime["time"] = explode(":", $datetime[1]);
$datetime["unix_time"] = mktime($datetime["time"][0], $datetime["time"][1], 0, $datetime["date"][1], $datetime["date"][0], "20".$datetime["date"][2]);
$datetime["unix_time_ar"] = mktime($datetime["time"][0], $datetime["time"][1], 0, 0, 0, 0);
$datetime["unix_day"] = mktime(0, 0, 0, $datetime["date"][1], $datetime["date"][0], "20".$datetime["date"][2]);
sort($fullmassive[$datetime["unix_day"]][$data[20]][] = array($data[17]." ".$data[18], $datetime["unix_time"], $data[20], $datetime["unix_day"], $datetime["unix_time_ar"], "inout" => checkInOut($data[3]), md5($data[20]." ".$data[18].$datetime["unix_time"].$datetime["unix_time"]), date("d.m.Y H:i", $datetime["unix_time"]), date("H:i", $datetime["unix_time_ar"])), SORT_NATURAL);
}
foreach($fullmassive as $fullmassive_day) {
foreach($fullmassive_day as $fullmassive_employee) {
usort($fullmassive_employee, 'invenDescSort');
$employee["uid"] = $fullmassive_employee[0][2];
$employee["in"] = $fullmassive_employee[0][1];
$employee["in_date"] = $fullmassive_employee[0][3];
$employee["in_time"] = $fullmassive_employee[0][4];
$employee["out"] = end($fullmassive_employee)[1];
$employee["out_date"] = mktime(0, 0, 0, date("n", end($fullmassive_employee)[1]), date("j", end($fullmassive_employee)[1]), date("Y", end($fullmassive_employee)[1]));
$employee["out_time"] = mktime(date("H", end($fullmassive_employee)[1]), date("i", end($fullmassive_employee)[1]), 0, 0, 0, 0);
$employee["name"] = $fullmassive_employee[0][0];
if($employee["in"] >= end($fullmassive_employee)[1]) $employee["in"] = mktime(10, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
else if(end($fullmassive_employee)[1] <= $employee["in"]) $employee["out"] = mktime(18, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
else
{
if(mktime(date("H", $employee["in"]), 0, 0, 0, 0, 0) < mktime(12, 0, 0, 0, 0, 0)) {
$employee["out"] = mktime(18, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
}
else {
$employee["in"] = mktime(10, 0, 0, date("n", $employee["in"]), date("j", $employee["in"]), date("Y", $employee["in"]));
}
}
if($employee["in_time"] >= end($fullmassive_employee)[4]) $employee["in_time"] = mktime(10, 0, 0, date("n", $employee["in_time"]), date("j", $employee["in_time"]), date("Y", $employee["in_time"]));
else if(end($fullmassive_employee)[4] <= $employee["in_time"]) $employee["out_time"] = mktime(18, 0, 0, date("n", $employee["in_time"]), date("j", $employee["in_time"]), date("Y", $employee["in_time"]));
$employee["worktime"] = $employee["out"] - $employee["in"];
mysql_query("INSERT INTO `skud_stat` SET `name` = '".$employee["name"]."',
`uid` = '".$employee["uid"]."',
`arrival` = '".$employee["in"]."',
`arrival_date` = '".$employee["in_date"]."',
`arrival_time` = '".$employee["in_time"]."',
`leaving` = '".$employee["out"]."',
`leaving_date` = '".$employee["out_date"]."',
`leaving_time` = '".$employee["out_time"]."',
`worktime` = '".($employee["worktime"])."'");
}
}
fclose($handle);
}
}
}
?>
Корпоративная Статистика (!). Читаю из CSV
scriptin 24.01.2013 17:04 # 0
Ну и массивы с датами, конечно. Кроссплатформенность.
bormand 24.01.2013 18:55 # +1
Для внутрикорпоративной странички сойдет. Никто там не будет перетаскивать ее с линуксового сервера на виндовый. Да и обратно, впрочем, тоже. К тому же perl и wc под виндой прекрасно себя чувствуют...
scriptin 24.01.2013 20:08 # +1
Да вы же оптимист!