<?php defined('ALTUMCODE') || die() ?>

<?= $this->views['header'] ?>

<div class="container my-4">
    <div class="d-flex mb-3">
        <p class="text-black text-uppercase font-weight-bold mr-3 mb-0">
            <?= $data->store->name ?>
        </p>

        <?php if($data->store->details->hours->{$data->day}->is_enabled): ?>
            <?php if(!empty($data->store->details->hours->{$data->day}->hours)): ?>
                <div>
                    <div class="svg-sm mr-1 d-inline-block"><?= include_view(ASSETS_PATH . 'images/s/clock.svg') ?></div>

                    <?= $data->store->details->hours->{$data->day}->hours ?>
                </div>
            <?php endif ?>
        <?php else: ?>
            <div>
                <div class="svg-sm mr-1 d-inline-block"><?= include_view(ASSETS_PATH . 'images/s/lock-closed.svg') ?></div>

                <span class="text-danger">
                <?= l('s_store.closed') ?>
            </span>
            </div>
        <?php endif ?>
    </div>

    <div class="row m-n1">

        <?php if(!empty($data->store->details->address)): ?>
            <div class="col-12 col-md-6 col-lg-2 p-1">
                <a href="<?= 'https://www.google.com/maps/search/?api=1&query=' . $data->store->details->address ?>" target="_blank" class="text-truncate btn btn-sm btn-link btn-block bg-primary-100 text-decoration-none">
                    <div class="svg-sm mr-1 d-inline-block"><?= include_view(ASSETS_PATH . 'images/s/location-marker.svg') ?></div> <span><?= $data->store->details->address ?></span>
                </a>
            </div>
        <?php endif ?>

        <?php if(!empty($data->store->details->phone)): ?>
            <div class="col-12 col-md-6 col-lg-2 p-1">
                <a href="<?= 'tel:' . $data->store->details->phone ?>" target="_blank" class="text-truncate btn btn-sm btn-link btn-block bg-primary-100 text-decoration-none">
                    <div class="svg-sm mr-1 d-inline-block"><?= include_view(ASSETS_PATH . 'images/s/phone.svg') ?></div> <span><?= $data->store->details->phone ?></span>
                </a>
            </div>
        <?php endif ?>

        <?php if(!empty($data->store->details->email)): ?>
            <div class="col-12 col-md-6 col-lg-2 p-1">
                <a href="<?= 'mailto:' . $data->store->details->email ?>" target="_blank" class="text-truncate btn btn-sm btn-link btn-block bg-primary-100 text-decoration-none">
                    <div class="svg-sm mr-1 d-inline-block"><?= include_view(ASSETS_PATH . 'images/s/at-symbol.svg') ?></div> <span><?= l('s_store.email') ?></span>
                </a>
            </div>
        <?php endif ?>

        <?php if(!empty($data->store->details->website)): ?>
            <div class="col-12 col-md-6 col-lg-2 p-1">
                <a href="<?= $data->store->details->website ?>" target="_blank" class="text-truncate btn btn-sm btn-link btn-block bg-primary-100 text-decoration-none">
                    <div class="svg-sm mr-1 d-inline-block"><?= include_view(ASSETS_PATH . 'images/s/globe.svg') ?></div> <span><?= l('s_store.website') ?></span>
                </a>
            </div>
        <?php endif ?>

    </div>
</div>

<div class="container mt-5">

    <?php if (!empty($data->menus)): ?>
        <h2 class="h3 mb-3">
            <?= l('s_store.menus') ?>
        </h2>

        <div class="row">
            <?php foreach($data->menus as $row): ?>
                <div class="col-12 col-md-6 col-lg-4 p-3">
                    <div class="card border-0 bg-gray-50 h-100">
                        <?php if(!empty($row->image)): ?>
                            <div class="store-menu-image-wrapper">
                                <img src="<?= \Altum\Uploads::get_full_url('menu_images') . $row->image ?>" class="store-menu-image-background" loading="lazy" />
                            </div>
                        <?php endif ?>

                        <div class="card-body d-flex flex-column justify-content-between">
                            <div class="mb-4">
                                <h3 class="h4 card-title"><?= $row->name ?></h3>
                                <p class="card-subtitle mt-1 text-muted"><?= $row->description ?></p>
                            </div>

                            <a href="<?= $data->store->full_url . $row->url ?>" class="btn btn-sm btn-block btn-outline-primary stretched-link">
                                <?= l('s_store.view_menu') ?>
                            </a>
                        </div>
                    </div>
                </div>
            <?php endforeach ?>
        </div>
    <?php endif ?>

</div>

<?php if($data->store->settings->display_share_buttons): ?>
    <?= include_view(THEME_PATH . 'views/s/partials/share.php', ['external_url' => $data->store->full_url]) ?>
<?php endif ?>
