예제 #1
0
<?php

use Respect\Validation\Validator as v;
include_once __DIR__ . '/templates/_header.php';
include_once __DIR__ . '/templates/_top_menu.php';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
} else {
    $id = 'error';
}
$category = \App\DB\Categories::get($id, $connection);
$flag = v::arr()->notEmpty()->validate($category);
include_once "category_validate.php";
?>

<section>
    <div class="container">
        <div class="row clearfix">
            <!-- боковое меню -->
            <?php 
include_once 'templates/_menu.php';
?>
            <div class="column column9">
                <div class="catalog">
                    <!-- хлебные крошки -->
                    <div class="breadcrumbs">
                        <a href="/">Магазин</a>
                        <p><?php 
if (!$flag) {
    echo "Список категорий";
} else {
<?php

if (isset($_GET['id'])) {
    $id = $_GET["id"];
}
include_once $src_path . 'autoload.php';
$getCatId = \App\DB\Categories::get($id, $connection);
?>

<form action="<?php 
echo App\Utilities\Options::URL;
?>
/edit-cat/?id=<?php 
echo $getCatId['id'];
?>
" method="post">
    <p style="margin-bottom:5px;">Введите название категории:</p>
    <input style="width: 50%;margin-bottom:5px;" type="text" name="category" value="<?php 
echo $getCatId['title'];
?>
" required>
    <input type="submit" value="Отправить">
</form>

<?php 
if (!empty($getCatId['updated_at']) && $getCatId['updated_at'] != "0000-00-00 00:00:00") {
    echo "<p style='margin-bottom: 5px, margin-top: 10px;'>Название категории изменено: " . $getCatId['updated_at'] . "</p>";
}
예제 #3
0
<?php

include_once __DIR__ . '/templates/_header.php';
include_once __DIR__ . '/templates/_top_menu.php';
if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    $product = \App\DB\Products::get($id, $connection);
    if (!$product) {
        die("Такой утки не обнаружено");
    }
    //получаем текущую категорию по id товара
    $category_by_prod = \App\DB\Categories::get($product['id_cat'], $connection);
    include_once __DIR__ . '/templates/_single_item.php';
    include_once __DIR__ . '/templates/_footer.php';
} else {
    die("Такой утки не обнаружено");
}
<?php

use Respect\Validation\Validator as v;
$category = \App\DB\Categories::get($products[$i]['category_id'], $connection);
?>
<table class="table-products">
<tbody>
<tr>
    <td><?php 
echo $products[$i]['id'];
?>
</td>
    <td><?php 
echo $products[$i]['title'];
?>
</td>
    <td><?php 
if (v::arr()->notEmpty()->validate($category)) {
    echo $category['title'];
} else {
    echo "Не указана";
}
?>
</td>
    <td><a href="<?php 
echo \App\Utilities\Options::URL;
?>
/edit/?id=<?php 
echo $products[$i]['id'];
?>
" class='edit adm-btn'>Изменить</a></td>