Answer the question
In order to leave comments, you need to log in
How to display the employee's working hours in the time sheet, according to the date?
Tell me how to show the hours worked by an employee in the time sheet, in accordance with the date of the cell? The flight of fancy at this stage has completely turned off and I can’t find a solution how to show the data so that it was in accordance with Employee <=> Date <=> number of hours.
Now there is a database with 2 tables:
<table>
<tr>
<th>№</th>
<th>Фамилия</th>
<th>Имя</th>
<!-- Числа -->
<? foreach($calendar->getMonth() as $workDay):?>
<th><?= $workDay; ?></th>
<? endforeach; ?>
<!-- Числа -->
</tr>
<!-- Вывод всех пользователей -->
<? for($i = 0; count($usersList) > $i; $i++): ?>
<tr>
<td><?= $usersList[$i]['id']; ?></td>
<td><?= $usersList[$i]['last_name']; ?></td>
<td><?= $usersList[$i]['first_name']; ?></td>
<!-- Рабочие часы -->
<? foreach($calendar->getMonth() as $workDay):?>
<td><!-- рабочие часы или кнопка на запись--></td>
<? endforeach; ?>
<!-- Рабочие часы -->
</tr>
<? endfor; ?>
<!-- Вывод всех пользователей -->
</table>
public function getAllUserWorkTime(){
$db = Db::getConnect();
$sql = "SELECT id_user,wrk_date,wrk_time FROM working_time";
$result = $db->query($sql);
$list = [];
$i = 0;
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$list[$i]['id'] = $row['id_user'];
$list[$i]['wrk_date'] = $row['wrk_date'];
$list[$i]['wrk_time'] = $row['wrk_time'];
$i++;
}
return $list;
}
public function getUserWorkTime($id){
$db = Db::getConnect();
$sql = "SELECT wrk_time FROM working_time WHERE id_user = $id";
$result = $db->query($sql);
$list = [];
$i = 0;
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$list[$i] = $row['wrk_time'];
$i++;
}
return $list;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question