This repository has been archived on 2024-10-16. You can view files and clone it, but cannot push or open issues or pull requests.
skillparts/mirzaev/skillparts/system/views/search/index.php

150 lines
7.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<link href="/css/pages/search.css" rel="stylesheet">
<div id="page_search" class="container h-100">
<div class="row py-3">
<section class="col">
<?php
if (isset($timer) && $timer > 0) {
echo <<<HTML
<div class="d-flex flex-column mx-auto">
<p class="px-2 mb-1 text-center d-flex justify-content-center">Слишком частые запросы, повторите попытку через: $timer секунд</p>
<small class="mb-3 text-center d-flex justify-content-center">Подождите или нажмите на кнопку вручную</small>
<a class="btn text-white button_clean button_blue mx-auto" onclick="window.location.reload();">Повторить</a>
</div>
<script type="text/javascript">
setTimeout('window.location.reload()', $timer + '000');
</script>
HTML;
} else {
if (isset($response) && is_array($response) && $response) {
$i = 0;
$amount = count($response);
foreach ($response as $row) {
// $name = $row['name'];
// $catn = $row['catn'];
// Инициализация
extract($row);
isset($name) ?: $name = 'Без названия';
isset($catg) ?: $catg = 'Категория';
isset($covr) ?: $covr = '/img/covers/h150/product.png';
$supplies_html = '';
foreach ($supplies as $supply) {
// Конкатенация HTML кода
// Инициализация артикула
$catn = $supply['catn'] ?? $supply['onec']['Артикул'];
// Инициализация цены
$price_raw = $supply['prce'] ?? $supply['onec']['Цены']['Цена']['ЦенаЗаЕдиницу'];
$price = $price_raw . ' ' . $supply['onec']['Цены']['Цена']['Валюта'];
// Инициализация количества
$amount_raw = $amount = $supply['amnt'] ?? $supply['onec']['Количество'];
if (empty($amount_raw) || $amount_raw < 1) {
$amount = 'Под заказ';
} else {
$amount .= ' шт';
}
if ($amount_raw < 1 || $price_raw < 1) {
// Нет в наличии или цена 0 рублей
$button_cart = <<<HTML
<div class="col-1 h-100 text-dark d-flex" title="Товар недоступен">
</div>
HTML;
} else {
$button_cart = <<<HTML
<a class="col-1 h-100 text-dark d-flex button_white rounded" title="Добавить $catn в корзину" href="/cart" role="button" onclick="return cart_write('$catn');">
<i class="fas fa-cart-arrow-down pr-1 m-auto"></i>
</a>
HTML;
}
$supplies_html .= <<<HTML
<div class="row my-auto m-0 h-100 text-right">
<small class="col-2 my-auto ml-auto">
$amount
</small>
<small class="col-2 my-auto ml-1">
Доставка
</small>
<b class="col-2 my-auto">
$price
</b>
$button_cart
</div>
HTML;
}
echo <<<HTML
<div class="col pb-2">
<div class="row p-2 rounded">
<img class="ml-0 h-100 img-fluid rounded" src="$covr"/>
<div class="col-3 ml-3 p-0 d-flex flex-column">
<a class="my-auto text-dark" href="/product/$catn">
<h5 class="m-0">$name</h5>
<h6 class="m-0"><small>$catn</small></h6>
</a>
</div>
<div class="col-1 ml-2 p-0 d-flex flex-column">
<a class="my-auto text-dark" href="/product/$catn">
<small>$catg</small>
</a>
</div>
<div class="col ml-2 p-0 d-flex flex-column">
$supplies_html
</div>
</div>
</div>
HTML;
// echo <<<HTML
// <div class="col-3 p-2 d-flex flex-column search_card rounded">
// <div class="col">
// <div class="row mb-2">
// <img class="w-100 img-fluid rounded" src="$covr"/>
// </div>
// <div class="row mb-2">
// <a class="mx-auto text-dark" href="/product/$catn"><h5 class="m-0">$catn</h5></a>
// </div>
// <div class="row px-2 mb-2">
// <small class="mt-auto">{$amnt}шт</small>
// <p class="mr-0">1000р</p>
// </div>
// <div class="row">
// <button class="btn button_grey button_clean w-100 text-white">В корзину</button>
// </div>
// </div>
// </div>
// HTML;
// if (++$i % 4 === 0 && $amount - $i !== 0) {
// echo <<<HTML
// <div class="dropdown-divider my-3 mx-4 w-100 "></div>
// HTML;
// }
}
} else {
echo <<<HTML
<div class="d-flex flex-column mx-auto">
<p class="m-0 py-2 d-flex justify-content-center">Ничего не найдено</p>
</div>
HTML;
}
}
?>
</section>
</div>
</div>
<script src="/js/cart.js" defer></script>