Skip to content

Instantly share code, notes, and snippets.

@hackimov
Created June 21, 2019 13:02
Show Gist options
  • Save hackimov/25dd19510e0f2424a4fea3ddaaafca83 to your computer and use it in GitHub Desktop.
Save hackimov/25dd19510e0f2424a4fea3ddaaafca83 to your computer and use it in GitHub Desktop.
Собственный грид в битриксе , для работы с СКУД ЭРА 500
<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">
<?php require_once $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php";
$APPLICATION->SetTitle("Отчет посещаемости");
unset($_REQUEST["Детальный_отчет"]);
$VISIT = COption::GetOptionString("micros.visit", "groupid");
# 1 Пользователи с Админкой, 9 Руководство, 50 отдельная группа доступа СКУД.
$arGroupAvalaible = array(1, 9, $VISIT);
# массив групп, в которых состоит пользователь
$arGroups = CUser::GetUserGroup($USER->GetID());
# далее проверяем, если пользователь вошёл хотя бы в одну из групп, то позволяем ему что-либо делать
$result_intersect = array_intersect($arGroupAvalaible, $arGroups);
if(!empty($result_intersect))
{
$list_id = 'FIRE_GRID_REPORT';
$ui_filter =
[
['id' => 'DATE', 'name' => 'Дата', 'type'=>'date', 'default' => true],
['id' => 'LNAME', 'name' => 'Фамилия', 'type'=>'text', 'default' => true],
['id' => 'FNAME', 'name' => 'Имя', 'type'=>'text', 'default' => true],
['id' => 'SNAME', 'name' => 'Отчество', 'type'=>'text', 'default' => true],
['id' => 'DEPARTMENT', 'name' => 'Отдел', 'type'=>'list', 'default' => true, 'params' => ['multiple' => 'N']],
['id' => 'POSITION', 'name' => 'Должность', 'type'=>'list', 'default' => true, 'params' => ['multiple' => 'N']],
];
/** Коннект к БД */
require_once $_SERVER["DOCUMENT_ROOT"]."/visit/dbconn.php";
$dbh = new \PDO($dsn, $username, $password,
[\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
$sql = "SELECT NAME FROM FB_POD WHERE NAME IS NOT NULL;";
$query = $dbh->query($sql);
$ui_filter["4"]["items"][""] = "Все отделы";
while ($row = $query->fetch(\PDO::FETCH_OBJ))
{
$array = (array)$row;
$ui_filter["4"]["items"][$array["NAME"]] = $array["NAME"];
}
unset($array);
unset($sql);
$sql = "SELECT NAME FROM FB_DOL WHERE NAME IS NOT NULL;";
$query = $dbh->query($sql);
$ui_filter["5"]["items"][""] = "Все должности";
while ($row = $query->fetch(\PDO::FETCH_OBJ))
{
$array = (array)$row;
$ui_filter["5"]["items"][$array["NAME"]] = $array["NAME"];
}
$query->closeCursor();
$this->SetViewTarget("inside_pagetitle", 100);
?>
<div class="pagetitle-container pagetitle-flexible-space job-filter">
<?
$APPLICATION->IncludeComponent('bitrix:main.ui.filter', '', [
'FILTER_ID' => $list_id,
'GRID_ID' => $list_id,
'FILTER' => $ui_filter,
'ENABLE_LIVE_SEARCH' => false,
'ENABLE_LABEL' => true
]);
?>
</div>
<?
$this->EndViewTarget();
$filterOption = new Bitrix\Main\UI\Filter\Options($list_id);
$filterData = $filterOption->getFilter([]);
foreach ($filterData as $k => $v)
{
$filter_grid[$k] = $v;
$str_find = "%".$filterData['FIND']."%";
}
$filter_department = $filter_grid["DEPARTMENT"];
$filter_position = $filter_grid["POSITION"];
if (!empty($filter_grid["DATE_from"]))
{
$dateSTART = $filter_grid["DATE_from"];
}
if (!empty($filter_grid["DATE_to"]))
{
$dateEND = $filter_grid["DATE_to"];
}
if (!empty($filter_grid["DATE_from"]))
{
$dateSTART = $filter_grid["DATE_from"];
}
if (!empty($filter_grid["FNAME"]))
{
$FNAME = $filter_grid["FNAME"];;
}
if (!empty($filter_grid["SNAME"]))
{
$SNAME = $filter_grid["SNAME"];;
}
if (!empty($filter_grid["LNAME"]))
{
$LNAME = $filter_grid["LNAME"];
}
if (!empty($filter_grid["FIND"]))
{
$FIND = $filter_grid["FIND"];;
}
$dateSTARTecho = substr($dateSTART, 0, strpos($dateSTART, " "));
$dateENDecho = substr($dateEND, 0, strpos($dateEND, " "));
?>
<?
# Connect to database
$dbh = new \PDO($dsn, $username, $password,
[\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
if(empty($dateSTART))
{
$dateSTART = date('Y-m-01');
}
if(empty($dateEND))
{
$endtime = " 23:59:59";
$dateEND = date('Y-m-d').$endtime;
}
/* # ппц долгий запрос
$sql = "SELECT
evn.D, evn.USR, usr.TABNUM, usr.FNAME, usr.LNAME, usr.SNAME, usr.FIO, enter.ENTER_MIN, exit.EXIT_MAX,
dol.NAME as DOL_NAME,
pod.NAME as POD_NAME
FROM (SELECT
d,
USR,
COUNT(*) AS cnt,
MIN(DT) AS enter_d
FROM
(SELECT EXTRACT(DAY FROM env.DT) AS d,
env.USR,
env.DT,
env.EVN
FROM FB_EVN env
WHERE env.DT >= '$dateSTART'
AND env.DT <= '$dateEND'
AND env.EVN IN (5)) t1
GROUP BY USR, d
) evn
LEFT JOIN FB_USR usr ON evn.USR = usr.ID
LEFT JOIN FB_DOL dol ON usr.DOLZ = dol.ID
LEFT JOIN FB_POD pod ON usr.PODR = pod.ID
LEFT JOIN
(SELECT
d AS exit_d,
USR AS exit_usr,
MAX(DT) AS exit_max
FROM
(SELECT
EXTRACT(DAY FROM env.DT) as d,
env.USR,
env.DT,
env.EVN
FROM FB_EVN env
WHERE env.DT >= '$dateSTART'
AND env.DT <= '$dateEND'
AND env.EVN IN (3)) t1
GROUP BY USR, d
) exit ON exit.exit_usr = evn.USR AND exit.exit_d = evn.d
LEFT JOIN
(SELECT
d AS enter_d,
USR AS exit_usr,
MIN(DT) AS enter_min
FROM
(SELECT
EXTRACT(DAY FROM env.DT) as d,
env.USR,
env.DT,
env.EVN
FROM FB_EVN env
WHERE env.DT >= '$dateSTART'
AND env.DT <= '$dateEND'
AND env.EVN IN (5)) t1
GROUP BY USR, d
)
enter ON enter.exit_usr = evn.USR AND enter.enter_d = evn.d
WHERE
('$filter_department' = '' OR pod.NAME = '$filter_department')
AND ('$filter_position' = '' OR dol.NAME = '$filter_position')
AND ('$FNAME' LIKE '' OR usr.FNAME LIKE '%$FNAME%')
AND ('$SNAME' LIKE '' OR usr.SNAME LIKE '%$SNAME%')
AND ('$LNAME' LIKE '' OR usr.LNAME LIKE '%$LNAME%')
ORDER BY enter.ENTER_MIN DESC
";
*/
$sql="
SELECT
usr.ID,
usr.TABNUM,
usr.FNAME,
usr.LNAME,
usr.SNAME,
usr.FIO,
dol.NAME as DOL_NAME,
pod.NAME as POD_NAME,
EXTRACT(DAY FROM event.DT) as D,
MIN(iif(event.EVN = 5, event.DT, null )) AS enter_min,
MAX(iif(event.EVN = 3, event.DT, null )) AS exit_max,
count(*) as total
FROM FB_USR usr
LEFT JOIN FB_EVN event on usr.ID = event.USR
LEFT JOIN FB_DOL dol ON usr.DOLZ = dol.ID
LEFT JOIN FB_POD pod ON usr.PODR = pod.ID
WHERE event.EVN in (3,5)
AND event.DT >= '$dateSTART'
AND event.DT <= '$dateEND'
AND ('$filter_department' = '' OR pod.NAME = '$filter_department')
AND ('$filter_position' = '' OR dol.NAME = '$filter_position')
AND ('$FNAME' LIKE '' OR usr.FNAME LIKE '%$FNAME%')
AND ('$SNAME' LIKE '' OR usr.SNAME LIKE '%$SNAME%')
AND ('$LNAME' LIKE '' OR usr.LNAME LIKE '%$LNAME%')
GROUP BY
usr.ID, usr.TABNUM, usr.FNAME, usr.LNAME, usr.SNAME, usr.FIO, dol.NAME, pod.NAME,
EXTRACT(DAY FROM event.DT)
ORDER BY enter_min DESC
";
# Execute query
$query = $dbh->query($sql);
while ($row = $query->fetch(\PDO::FETCH_OBJ))
{
$array = (array)$row;
# преобразование числового события в ЧПС
if($array["EVN"] == 3)
{
$array["EVENT"] = "Выход";
}
if($array["EVN"] == 2)
{
$array["EVENT"] = "выход доступ разрешен";
}
if($array["EVN"] == 5)
{
$array["EVENT"] = "Вход";
}
if($array["EVN"] == 4)
{
$array["EVENT"] = "вход доступ разрешен";
}
$megaarr[] = $array;
# данное условие считает рабочие часы
if(!empty($array["EXIT_MAX"]) & !empty($array["ENTER_MIN"]))
{
$diff = strtotime ($array["EXIT_MAX"])-strtotime($array["ENTER_MIN"]);
$array["WORKTIME"] = sprintf('%02d:%02d:%02d', $diff / 3600, ($diff % 3600) / 60, $diff % 60);
}
# подменяем значения даты , в формат даты
if(isset($array["ENTER_MIN"]))
{
$array["D"] = date('d.m.Y', strtotime($array["ENTER_MIN"]));
}
if(isset($array["EXIT_MAX"]))
{
$array["D"] = date('d.m.Y', strtotime($array["EXIT_MAX"]));
}
if(!empty($array["ENTER_MIN"]))
{
$array["ENTER_MIN"] = date('H:i:s', strtotime($array["ENTER_MIN"]));
}
if(!empty($array["EXIT_MAX"]))
{
$array["EXIT_MAX"] = date('H:i:s', strtotime($array["EXIT_MAX"]));
}
}
$query->closeCursor();
# foreach by person
foreach ($megaarr as $person)
{
if(!empty($person["FIO"]))
{
$m = explode(' ', $person["FIO"]);
if(!empty($m[2])){
$person["FIO"] = $m[0] . ' ' . substr($m[1],0,1) . '.' . substr($m[2],0,1) . '.' ;
}
if(empty($m[2])){
$person["FIO"] = $m[0] . ' ' . substr($m[1],0,1) . '.' ;
}
if($arperson[$person["FIO"]] != $person["FIO"] )
{
$arperson[$person["POD_NAME"]][$person["FIO"]]["NAME"] = $person["FIO"];
$arperson[$person["POD_NAME"]][$person["FIO"]]["NAME"] = $person["FIO"];
$arperson[$person["POD_NAME"]][$person["FIO"]]["DOL_NAME"] = $person["DOL_NAME"];
$arperson[$person["POD_NAME"]][$person["FIO"]]["POD_NAME"] = $person["POD_NAME"];
if($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]] != $person["D"])
{
$arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["ENTER_MIN"] = $person["ENTER_MIN"];
$arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["EXIT_MAX"] = $person["EXIT_MAX"];
if(!empty($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["ENTER_MIN"]) & !empty($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["EXIT_MAX"]))
{
$diff = strtotime ($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["EXIT_MAX"])-strtotime($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["ENTER_MIN"]);
$arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["WORKTIME"] = sprintf('%02d:%02d:%02d', $diff / 3600, ($diff % 3600) / 60, $diff % 60);
}
if(!empty($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["ENTER_MIN"]))
{
$arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["ENTER_MIN"] = date('H:i:s', strtotime($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["ENTER_MIN"]));
}
if(!empty($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["EXIT_MAX"]))
{
$arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["EXIT_MAX"] = date('H:i:s', strtotime($arperson[$person["POD_NAME"]][$person["FIO"]][$person["D"]]["EXIT_MAX"]));
}
}
}
}
}
?>
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;border-color:#9ABAD9; text-align: center;}
.tg td{font-family:Arial, sans-serif;font-size:11px;padding:0px 0px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#9ABAD9;color:#444;background-color:#EBF5FF; text-align: center; }
.tg th{font-family:Arial, sans-serif;font-size:11px;font-weight:normal;padding:0px 0px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#9ABAD9;color:#fff;background-color:#409cff; text-align: center;}
.tg .tg-xldj{border-color:inherit;text-align:left; text-align: center;}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top; text-align: center;}
.tg .stylebg{background-color: #D6EAF8;}
</style>
<?
# styles block
$style_tg = " border-collapse: collapse; border-spacing: 0; border-color: #9ABAD9; text-align: center;";
$style_td = " background-color:#EBF5FF; font-family:Arial, sans-serif;font-size:11px;padding:0px 0px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#9ABAD9;color:#444; text-align: center;";
$style_th = " background-color:#409cff;font-family:Arial, sans-serif;font-size:11px;font-weight:normal;padding:0px 0px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#9ABAD9;color:#fff; text-align: center;";
$style_xldj = " text-align: left; text-align: center;";
$style_0pky = " text-align: left; vertical-align: top; text-align: center;";
$style_bg = " background-color: #D6EAF8;";
$left = " text-align: left;";
$style_open = "style=\"";
$style_close = "\"";
$tg = $style_open . $style_tg . $style_close;
$xldj = $style_open . $style_tg . $style_xldj . $style_close;
$pky = $style_open . $style_tg . $style_0pky . $style_close;
$td = $style_open . $style_tg . $style_td . $style_close;
$th = $style_open . $style_tg . $style_th . $style_close;
$bg = $style_open . $style_tg . $style_td . $style_bg . $style_close;
$thxldj = $style_open . $style_tg . $style_th . $style_xldj . $style_close;
$thpky = $style_open . $style_tg . $style_th . $style_0pky . $style_close;
$tdxldj = $style_open . $style_tg . $style_td . $style_xldj . $style_close;
$tdpky = $style_open . $style_tg . $style_td . $style_0pky . $style_close;
$leftth = $style_open . $style_tg . $style_th . $style_0pky . $left . $style_close;
?>
<!-- class="tg" -->
<table <?=$tg?> width="100%" id="report">
<thead <?=$th?>>
<?if(!empty($dateSTARTecho) & !empty($dateENDecho) & !empty($filter_department)){?>
<tr>
<th colspan="21" <?=$leftth?> >
Отчет с <?=$dateSTARTecho?> по <?=$dateENDecho?>
<?=$filter_department?>
</th>
</tr>
<?}?>
<tr>
<th <?=$thxldj?> rowspan="3" width="90px">Фамилия</th>
<th <?=$thxldj?> rowspan="3" width="90px">Должность</th>
<th <?=$thpky?> colspan="16">Отработанное время по числам месяца</th>
<th <?=$thxldj?> rowspan="3" width="30px">Кол-во часов</th>
<th <?=$thxldj?> rowspan="3" width="15px">Кол-во дней</th>
<th <?=$thxldj?> rowspan="3" width="90px">Подпись</th>
</tr>
<tr>
<th <?=$thpky?> width="30px">1</th>
<th <?=$thpky?> width="30px">2</th>
<th <?=$thpky?> width="30px">3</th>
<th <?=$thpky?> width="30px">4</th>
<th <?=$thpky?> width="30px">5</th>
<th <?=$thpky?> width="30px">6</th>
<th <?=$thpky?> width="30px">7</th>
<th <?=$thpky?> width="30px">8</th>
<th <?=$thpky?> width="30px">9</th>
<th <?=$thpky?> width="30px">10</th>
<th <?=$thpky?> width="30px">11</th>
<th <?=$thpky?> width="30px">12</th>
<th <?=$thpky?> width="30px">13</th>
<th <?=$thpky?> width="30px">14</th>
<th <?=$thpky?> width="30px">15</th>
<th <?=$thpky?> width="30px"> </th>
</tr>
<tr>
<th <?=$thpky?> width="30px">16</th>
<th <?=$thpky?> width="30px">17</th>
<th <?=$thpky?> width="30px">18</th>
<th <?=$thpky?> width="30px">19</th>
<th <?=$thpky?> width="30px">20</th>
<th <?=$thpky?> width="30px">21</th>
<th <?=$thpky?> width="30px">22</th>
<th <?=$thpky?> width="30px">23</th>
<th <?=$thpky?> width="30px">24</th>
<th <?=$thpky?> width="30px">25</th>
<th <?=$thpky?> width="30px">26</th>
<th <?=$thpky?> width="30px">27</th>
<th <?=$thpky?> width="30px">28</th>
<th <?=$thpky?> width="30px">29</th>
<th <?=$thpky?> width="30px">30</th>
<th <?=$thpky?> width="30px">31</th>
</tr>
</thead>
<tbody>
<?
foreach ($arperson as $podname => $personsarr)
{
if(empty($filter_department))
{
?>
<tr>
<th <?=$leftth?> colspan="21" style="text-align: left;">
<?=$podname;?>
</th>
</tr>
<?
}
foreach ($personsarr as $person)
{
$persondays = $person;
unset($persondays["NAME"]);
unset($persondays["DOL_NAME"]);
unset($persondays["POD_NAME"]);
$persondaycount = count($persondays);
unset($totaltme);
unset($overhours);
unset($allhours);
unset($allminuts);
unset($allseconds);
foreach ($persondays as $time)
{
if(!empty($time["WORKTIME"]))
{
$his = explode(":", $time["WORKTIME"]);
$allhours = $allhours + $his[0];
$allminuts = $allminuts + $his[1];
}
}
if($allminuts > 60)
{
$overhours = $allminuts / 60;
$allhours + $overhours;
$allminuts = $allminuts % 60;
}
$lencount = strlen($allminuts);
if($lencount === 1)
{
$allminuts = "0".$allminuts;
}
$totaltme = "$allhours:$allminuts";
unset($day);
unset($persontrim);
foreach ($person as $day => $persontrim)
{
$person["$day"]["ENTER_MIN"] = substr($persontrim["ENTER_MIN"], 0, -3);
$person["$day"]["EXIT_MAX"] = substr($persontrim["EXIT_MAX"], 0, -3);
$person["$day"]["WORKTIME"] = substr($persontrim["WORKTIME"], 0, -3);
}
if(is_array($person["DOL_NAME"]))
{
$person["DOL_NAME"] = "";
}
if(is_array($person["POD_NAME"]))
{
$person["POD_NAME"] = "";
}
$style = " stylebg";
?>
<tr>
<td <?=$tdxldj?> rowspan="2"><?=$person["NAME"]?></td>
<td <?=$tdxldj?> rowspan="2"><?=$person["DOL_NAME"]?></td>
<td <?if(empty($person["1"])){echo $bg;}else{echo $tdpky;}?>><?=$person["1"]["ENTER_MIN"]?><br><?=$person["1"]["EXIT_MAX"]?><br><b><?=$person["1"]["WORKTIME"]?></b></td>
<td <?if(empty($person["2"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["2"]["ENTER_MIN"]?><br><?=$person["2"]["EXIT_MAX"]?><br><b><?=$person["2"]["WORKTIME"]?></b></td>
<td <?if(empty($person["3"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["3"]["ENTER_MIN"]?><br><?=$person["3"]["EXIT_MAX"]?><br><b><?=$person["3"]["WORKTIME"]?></b></td>
<td <?if(empty($person["4"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["4"]["ENTER_MIN"]?><br><?=$person["4"]["EXIT_MAX"]?><br><b><?=$person["4"]["WORKTIME"]?></b></td>
<td <?if(empty($person["5"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["5"]["ENTER_MIN"]?><br><?=$person["5"]["EXIT_MAX"]?><br><b><?=$person["5"]["WORKTIME"]?></b></td>
<td <?if(empty($person["6"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["6"]["ENTER_MIN"]?><br><?=$person["6"]["EXIT_MAX"]?><br><b><?=$person["6"]["WORKTIME"]?></b></td>
<td <?if(empty($person["7"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["7"]["ENTER_MIN"]?><br><?=$person["7"]["EXIT_MAX"]?><br><b><?=$person["7"]["WORKTIME"]?></b></td>
<td <?if(empty($person["8"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["8"]["ENTER_MIN"]?><br><?=$person["8"]["EXIT_MAX"]?><br><b><?=$person["8"]["WORKTIME"]?></b></td>
<td <?if(empty($person["9"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["9"]["ENTER_MIN"]?><br><?=$person["9"]["EXIT_MAX"]?><br><b><?=$person["9"]["WORKTIME"]?></b></td>
<td <?if(empty($person["10"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["10"]["ENTER_MIN"]?><br><?=$person["10"]["EXIT_MAX"]?><br><b><?=$person["10"]["WORKTIME"]?></b></td>
<td <?if(empty($person["11"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["11"]["ENTER_MIN"]?><br><?=$person["11"]["EXIT_MAX"]?><br><b><?=$person["11"]["WORKTIME"]?></b></td>
<td <?if(empty($person["12"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["12"]["ENTER_MIN"]?><br><?=$person["12"]["EXIT_MAX"]?><br><b><?=$person["12"]["WORKTIME"]?></b></td>
<td <?if(empty($person["13"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["13"]["ENTER_MIN"]?><br><?=$person["13"]["EXIT_MAX"]?><br><b><?=$person["13"]["WORKTIME"]?></b></td>
<td <?if(empty($person["14"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["14"]["ENTER_MIN"]?><br><?=$person["14"]["EXIT_MAX"]?><br><b><?=$person["14"]["WORKTIME"]?></b></td>
<td <?if(empty($person["15"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["15"]["ENTER_MIN"]?><br><?=$person["15"]["EXIT_MAX"]?><br><b><?=$person["15"]["WORKTIME"]?></b></td>
<td <?=$bg?> > </td>
<td <?=$tdpky?> rowspan="2"><?if($totaltme != ":"){echo $totaltme;}?></td>
<td <?=$tdpky?> rowspan="2"><?=$persondaycount?></td>
<td <?=$tdpky?> rowspan="2"> </td>
</tr>
<td <?if(empty($person["16"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["16"]["ENTER_MIN"]?><br><?=$person["16"]["EXIT_MAX"]?><br><b><?=$person["16"]["WORKTIME"]?></b></td>
<td <?if(empty($person["17"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["17"]["ENTER_MIN"]?><br><?=$person["17"]["EXIT_MAX"]?><br><b><?=$person["17"]["WORKTIME"]?></b></td>
<td <?if(empty($person["18"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["18"]["ENTER_MIN"]?><br><?=$person["18"]["EXIT_MAX"]?><br><b><?=$person["18"]["WORKTIME"]?></b></td>
<td <?if(empty($person["19"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["19"]["ENTER_MIN"]?><br><?=$person["19"]["EXIT_MAX"]?><br><b><?=$person["19"]["WORKTIME"]?></b></td>
<td <?if(empty($person["20"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["20"]["ENTER_MIN"]?><br><?=$person["20"]["EXIT_MAX"]?><br><b><?=$person["20"]["WORKTIME"]?></b></td>
<td <?if(empty($person["21"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["21"]["ENTER_MIN"]?><br><?=$person["21"]["EXIT_MAX"]?><br><b><?=$person["21"]["WORKTIME"]?></b></td>
<td <?if(empty($person["22"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["22"]["ENTER_MIN"]?><br><?=$person["22"]["EXIT_MAX"]?><br><b><?=$person["22"]["WORKTIME"]?></b></td>
<td <?if(empty($person["23"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["23"]["ENTER_MIN"]?><br><?=$person["23"]["EXIT_MAX"]?><br><b><?=$person["23"]["WORKTIME"]?></b></td>
<td <?if(empty($person["24"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["24"]["ENTER_MIN"]?><br><?=$person["24"]["EXIT_MAX"]?><br><b><?=$person["24"]["WORKTIME"]?></b></td>
<td <?if(empty($person["25"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["25"]["ENTER_MIN"]?><br><?=$person["25"]["EXIT_MAX"]?><br><b><?=$person["25"]["WORKTIME"]?></b></td>
<td <?if(empty($person["26"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["26"]["ENTER_MIN"]?><br><?=$person["26"]["EXIT_MAX"]?><br><b><?=$person["26"]["WORKTIME"]?></b></td>
<td <?if(empty($person["27"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["27"]["ENTER_MIN"]?><br><?=$person["27"]["EXIT_MAX"]?><br><b><?=$person["27"]["WORKTIME"]?></b></td>
<td <?if(empty($person["28"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["28"]["ENTER_MIN"]?><br><?=$person["28"]["EXIT_MAX"]?><br><b><?=$person["28"]["WORKTIME"]?></b></td>
<td <?if(empty($person["29"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["29"]["ENTER_MIN"]?><br><?=$person["29"]["EXIT_MAX"]?><br><b><?=$person["29"]["WORKTIME"]?></b></td>
<td <?if(empty($person["30"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["30"]["ENTER_MIN"]?><br><?=$person["30"]["EXIT_MAX"]?><br><b><?=$person["30"]["WORKTIME"]?></b></td>
<td <?if(empty($person["31"])){echo $bg;}else{echo $tdpky;}?> ><?=$person["31"]["ENTER_MIN"]?><br><?=$person["31"]["EXIT_MAX"]?><br><b><?=$person["31"]["WORKTIME"]?></b></td>
<?}?>
<?}?>
</tbody>
</table>
<?$this->SetViewTarget("pagetitle", 100); #inside_pagetitle #?>
<a class="ui-btn ui-btn-success" id="excel" href="javascript:tableToExcel();">Экспорт в Excel</a>
<?$this->EndViewTarget();?>
<script src="/visit/jquery.min.js"></script>
<?
$dateSTART = strtok($dateSTART, ' ');
$dateEND = strtok($dateEND, ' ');
?>
<script>
// функция преобразования в JS
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
table = document.getElementById('report')
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
var filename = '<?if(!empty($dateSTART) & !empty($dateEND)){echo "Отчет c $dateSTART по $dateEND ";}else{echo"Отчет ";} if(!empty($filter_department)){echo $filter_department;}?>.xls';
var link = document.createElement('a');
link.download = filename;
link.href = uri + base64(format(template, ctx));
link.click();
}
})()
// функция перезагрузки по клику пиктограммы поиска
$(".main-ui-search").click(function() {
location.reload();
});
//функция перезагрузки по клику кнопки поиска
$(document).on('click', '.main-ui-filter-find', function() {
setTimeout("location.reload()", 100);
});
</script>
<?}else{?>
<p style="color:#ff0000">
<br>
Доступ Запрещен!
</p>
<?}?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment