<?php

use Lab\Helpers;

require dirname(__DIR__) . '/partials/head.php';
require dirname(__DIR__) . '/partials/studio-nav.php';
?>
<main class="wrap studio">
    <div class="order-head">
        <div>
            <p class="kicker"><?= date('d/m/Y') ?></p>
            <h1>Ημερήσια αναφορά</h1>
        </div>
        <button class="btn" type="button" onclick="window.print()">Εκτύπωση</button>
    </div>
    <div class="stats">
        <div class="stat"><b><?= (int) $stats['today'] ?></b><span>Παραγγελίες</span></div>
        <div class="stat"><b><?= Helpers::e(Helpers::euro((int) $stats['revenue_cents'])) ?></b><span>Τζίρος</span></div>
        <div class="stat"><b><?= (int) $stats['open'] ?></b><span>Σε εκτέλεση</span></div>
        <div class="stat"><b><?= (int) $stats['ready'] ?></b><span>Έτοιμες</span></div>
    </div>
    <table class="orders">
        <thead>
            <tr><th>Κωδικός</th><th>Πελάτης</th><th>Χαρτί</th><th>Πληρωμή</th><th>Σύνολο</th><th>Κατάσταση</th></tr>
        </thead>
        <tbody>
        <?php foreach ($orders as $order): ?>
            <tr>
                <td><?= Helpers::e($order['code']) ?></td>
                <td><?= Helpers::e($order['customer_name']) ?> · <?= Helpers::e($order['customer_phone']) ?></td>
                <td><?= Helpers::e(Helpers::paperLabel((string) ($order['paper'] ?? 'glossy'))) ?><?= ! empty($order['rush']) ? ' · επείγον' : '' ?></td>
                <td><?= Helpers::e(Helpers::paymentLabel((string) ($order['payment'] ?? 'counter'))) ?></td>
                <td><?= Helpers::e(Helpers::euro((int) $order['total_cents'])) ?></td>
                <td><?= Helpers::e(Helpers::statusLabel($order['status'])) ?></td>
            </tr>
        <?php endforeach; ?>
        <?php if (! $orders): ?>
            <tr><td colspan="6" class="muted">Καμία παραγγελία σήμερα.</td></tr>
        <?php endif; ?>
        </tbody>
    </table>
</main>
</body>
</html>
