| Server IP : 188.114.96.3 / Your IP : 216.73.216.143 Web Server : Apache System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64 User : ( 3194769) PHP Version : 8.5.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /polana/admin/ |
Upload File : |
<?php
declare(strict_types=1);require_once dirname(__DIR__).'/includes/functions.php';require_login();$user=admin_user();if(!$user||!in_array((string)$user['role'],operations_manager_roles(),true)){http_response_code(403);exit('Brak dostępu.');}ensure_operations_schema();ensure_schedule_schema();ensure_tips_schema();$date=trim((string)($_GET['date']??$_POST['date']??date('Y-m-d')));$d=DateTimeImmutable::createFromFormat('!Y-m-d',$date);if(!$d)$date=date('Y-m-d');
if($_SERVER['REQUEST_METHOD']==='POST'){verify_csrf();try{daily_shift_note_save($date,(string)($_POST['note']??''),(int)$user['id']);admin_log('daily_note','Notatka dnia '.$date);flash('success','Notatka dnia zapisana.');redirect('/admin/today.php?date='.$date);}catch(Throwable $e){flash('error',$e->getMessage());redirect('/admin/today.php?date='.$date);}}
$people=schedule_entries_for_date($date);$staffing=schedule_staffing_status($people,0);$stmt=db()->prepare("SELECT r.*,u.name AS waiter_name,u.username AS waiter_username FROM reservations r LEFT JOIN users u ON u.id=r.assigned_waiter_user_id WHERE r.reservation_date=? AND r.status NOT IN ('rejected','cancelled') ORDER BY r.reservation_time");$stmt->execute([$date]);$reservations=$stmt->fetchAll();$reservationCount=count(array_filter($reservations,static fn($r)=>$r['status']!=='no_show'));$guestCount=array_sum(array_map(static fn($r)=>(int)$r['guests'],array_filter($reservations,static fn($r)=>$r['status']!=='no_show')));$unassigned=count(array_filter($reservations,static fn($r)=>empty($r['assigned_waiter_user_id'])&&$r['status']!=='no_show'));$noShow=count(array_filter($reservations,static fn($r)=>$r['status']==='no_show'));
$pool=tip_pool_by_date($date,'all_day');$tipTotal=$pool?tip_pool_total($pool):0.0;$tipAckPending=0;if($pool){$q=db()->prepare("SELECT COUNT(*) FROM tip_pool_participants WHERE pool_id=? AND payout_status='paid' AND acknowledged_at IS NULL");$q->execute([(int)$pool['id']]);$tipAckPending=(int)$q->fetchColumn();}$note=daily_shift_note($date);$tablesTotal=max(0,(int)setting('restaurant_tables_total','0'));$freeTables=$tablesTotal>0?max(0,$tablesTotal-$reservationCount):null;render_admin_header('Dzisiaj'); ?>
<div class="admin-title-row"><div><h1>Dzisiaj</h1><p><?= e((new DateTimeImmutable($date))->format('d.m.Y')) ?> · obsada, rezerwacje i rozliczenie dnia.</p></div><form method="get"><input type="date" name="date" value="<?= e($date) ?>" onchange="this.form.submit()"></form></div>
<div class="grid-cards manager-today-stats"><div class="card"><h3>Obsada</h3><div class="stat"><?= count($people) ?></div><p class="muted"><?= (int)$staffing['waiters'] ?> kelnerów · <?= (int)$staffing['kitchen'] ?> kuchnia</p></div><div class="card"><h3>Rezerwacje</h3><div class="stat"><?= $reservationCount ?></div><p class="muted"><?= $guestCount ?> gości · <?= $unassigned ?> bez kelnera</p></div><div class="card"><h3>Napiwki</h3><div class="stat tip-stat-money"><?= e(tip_money($tipTotal)) ?></div><a class="btn btn-small btn-light" href="/admin/tips.php?month=<?= e(substr($date,0,7)) ?><?= $pool?'&edit='.(int)$pool['id']:'' ?>">Otwórz</a></div><div class="card"><h3>Odbiór tipów</h3><div class="stat"><?= $tipAckPending ?></div><p class="muted">czeka na potwierdzenie</p></div><?php if($tablesTotal>0): ?><div class="card"><h3>Stoliki wg rezerwacji</h3><div class="stat"><?= $freeTables ?></div><p class="muted">wolnych z <?= $tablesTotal ?></p></div><?php endif; ?><div class="card"><h3>No-show</h3><div class="stat"><?= $noShow ?></div></div></div>
<div class="two-col" style="margin-top:20px"><section class="card"><div class="admin-section-title"><h2>Obsada</h2><a class="btn btn-small btn-light" href="/admin/schedule.php?day=<?= e($date) ?>">Edytuj grafik</a></div><?php if(!$people): ?><p class="muted">Brak obsady.</p><?php endif; ?><?php foreach($people as $p): ?><div class="manager-person"><strong><?= e($p['name']?:$p['username']) ?></strong><span><?= e($p['role']==='kitchen'?'Kuchnia':'Kelner') ?> · <?= e(schedule_time_label($p['start_time'],$p['end_time'])) ?></span></div><?php endforeach; ?></section><section class="card"><h2>Notatka dnia</h2><form method="post"><?= csrf_field() ?><input type="hidden" name="date" value="<?= e($date) ?>"><textarea name="note" rows="7" style="width:100%" placeholder="np. urodziny, braki, dostawa, ważne informacje"><?= e($note['note']??'') ?></textarea><div style="margin-top:10px"><button class="btn btn-primary">Zapisz notatkę</button></div></form></section></div>
<section class="card" style="margin-top:20px"><div class="admin-section-title"><h2>Rezerwacje</h2><a class="btn btn-small btn-light" href="/admin/reservations.php?from=<?= e($date) ?>&to=<?= e($date) ?>">Wszystkie</a></div><div class="table-wrap"><table class="admin-table"><thead><tr><th>Godzina</th><th>Gość</th><th>Os.</th><th>Kelner</th><th>Stolik</th><th>Status</th><th></th></tr></thead><tbody><?php if(!$reservations): ?><tr><td colspan="7" class="muted">Brak rezerwacji.</td></tr><?php endif; ?><?php foreach($reservations as $r): ?><tr><td><strong><?= e(substr((string)$r['reservation_time'],0,5)) ?></strong></td><td><?= e($r['guest_name']) ?></td><td><?= (int)$r['guests'] ?></td><td><?= !empty($r['assigned_waiter_user_id'])?e($r['waiter_name']?:$r['waiter_username']):'<span class="muted">—</span>' ?></td><td><?= e($r['table_label']??'') ?></td><td><?= e(reservation_status_label((string)$r['status'])) ?></td><td><a class="btn btn-small btn-light" href="/admin/reservation.php?id=<?= (int)$r['id'] ?>">Otwórz</a></td></tr><?php endforeach; ?></tbody></table></div></section>
<?php render_admin_footer(); ?>