core/api/modules/a_tovar_cat/index.php

113 lines
5.2 KiB
PHP
Raw Normal View History

2022-12-11 13:55:49 +05:00
<?php
ini_set('display_errors', 0 );
2022-12-17 18:15:09 +05:00
//@mkdir(MYDIR . '/img/tovar', 0700);
2022-12-11 13:55:49 +05:00
//проверяем авторизацию
2022-12-24 21:12:23 +05:00
2022-12-11 13:55:49 +05:00
if ( $_SESSION['dostup'] !=='a' && $_SESSION['dostup'] !== 'e' ) header( 'Location: /403/' );
2023-07-12 20:02:20 +05:00
/* ----------------------------------------------------------------------
10.06.2023
выбираем правила сортировки
---------------------------------------------------------------------- */
$autofilter=\DB::getAll("SELECT * FROM `tovar_category_filter` WHERE `tovar_category`=?", $_GET['id']);
$smarty -> assign( 'autofilter', $autofilter );
2023-07-12 20:02:20 +05:00
/* ----------------------------------------------------------------------
17.02.2023
Перемещаем товар
---------------------------------------------------------------------- */
if ($_POST['move']) \DB::set ("UPDATE `tovar` SET `category`=? WHERE `title` LIKE '" . $_POST['txt'] . "'", $_POST['category']);
2023-01-07 18:55:55 +05:00
$smarty -> assign( 'uploadimg', 'api/modules/a_tovar_cat/uploadimg.html' );
$_SESSION['tmp']=$_GET['id'];
2023-01-02 21:33:36 +05:00
2022-12-24 21:12:23 +05:00
/* ----------------------------------------------------------------------
14.12.2022
Получаем инфу о пользователе
---------------------------------------------------------------------- */
$smarty -> assign( 'userInfo', \core::getUserInfo( $_SESSION['user_id'] ) );
$set['showNoPublic']=\core::getSettings('showNoPublic', 'a_tovar_cat');
2022-12-11 13:55:49 +05:00
/* ----------------------------------------------------------------------
2022-12-17 18:15:09 +05:00
15.12.2022
2022-12-11 13:55:49 +05:00
Получаем список категорий
---------------------------------------------------------------------- */
2022-12-17 18:15:09 +05:00
$_GET['id'] = ($_GET['id']) ? $_GET['id'] : 0;
2022-12-24 21:12:23 +05:00
if ($set['showNoPublic']==1)
$cats=\DB::getAll("SELECT * FROM `tovar_category` WHERE `category`=? ORDER BY `title`", $_GET['id']);
else
$cats=\DB::getAll("SELECT * FROM `tovar_category` WHERE `category`=? AND `status`=1 ORDER BY `title`", $_GET['id']);
for ( $i=0; $i<count($cats); $i++){
unset($c);
2023-07-12 20:02:20 +05:00
$c=\DB::getAll("SELECT count(*) FROM `tovar_category` WHERE `category`=? AND `status`=1" , $cats[$i]['id']);
2022-12-24 21:12:23 +05:00
$cats[$i]['count_cats']=$c[0]['count(*)'];
unset($c);
2023-07-12 20:02:20 +05:00
$c=\DB::getAll("SELECT count(*) FROM `tovar` WHERE `category`=? AND `status`=1", $cats[$i]['id']);
2022-12-24 21:12:23 +05:00
$cats[$i]['count_tovar']=$c[0]['count(*)'];
}
2022-12-11 13:55:49 +05:00
$smarty -> assign( 'cats', $cats );
2022-12-17 18:15:09 +05:00
/* ----------------------------------------------------------------------
15.12.2022
Получаем список товаров
---------------------------------------------------------------------- */
2023-07-12 20:02:20 +05:00
if ($set['showNoPublic']==1)
$tovars=\DB::getAll("SELECT tovar.id, tovar.title, tovar.cena, tovar_img.filename AS img FROM `tovar`
JOIN `tovar_img`
ON tovar_img.tovar_id=tovar.id
WHERE `category`=? ORDER BY `title` LIMIT 400", $_GET['id']);
else
$tovars=\DB::getAll("SELECT tovar.id, tovar.title, tovar.cena, tovar_img.filename AS img FROM `tovar`
JOIN `tovar_img`
ON tovar_img.tovar_id=tovar.id
WHERE `category`=? AND `status`=1 ORDER BY `title` LIMIT 400", $_GET['id']);
$smarty -> assign( 'pages', \core::array_unique_key($tovars, 'id') );
2022-12-11 13:55:49 +05:00
2022-12-24 21:12:23 +05:00
/* ----------------------------------------------------------------------
21.12.2022
Получаем информацию о категории
---------------------------------------------------------------------- */
if ( $_GET['id'] ){
$catInfo = \DB::getAll( "SELECT * FROM `tovar_category` WHERE `id`=? LIMIT 1", $_GET['id'] );
//print_r ( $catInfo );
$smarty -> assign( 'catInfo', $catInfo );
2022-12-11 13:55:49 +05:00
2023-01-07 18:55:55 +05:00
/* ----------------------------------------------------------------------
02.01.2023
Получаем обложек
---------------------------------------------------------------------- */
$imgs=\DB::getAll("SELECT * FROM `tovar_category_img` WHERE `tovar_category_id`=?", $_GET['id']);
$smarty -> assign( 'imgs', $imgs );
2022-12-11 13:55:49 +05:00
}
2022-12-24 21:12:23 +05:00
/* ----------------------------------------------------------------------
21.12.2022
Получаем список категорий
---------------------------------------------------------------------- */
2022-12-11 13:55:49 +05:00
2023-07-12 20:02:20 +05:00
$catList=\DB::getAll("SELECT `id`, `title` FROM `tovar_category` WHERE `status`=1 ORDER BY `title`", $_GET['id']);
$smarty -> assign( 'catList', $catList );
2022-12-11 13:55:49 +05:00
//получаем список страниц
//echo ("test1");
//$pages = $mod -> get_pages('page', ID);
//$smarty -> assign( 'pages', $pages );//список страниц
//$smarty -> assign( 'cat_id', ID );//ИД категории
2022-12-17 18:15:09 +05:00
//$smarty -> assign( 'all_cats', $mod->get_all_cats() );//Получаем все опубликованные категории для модалки добавления и изменения категорий
$smarty -> assign( 'cat_list', 'api/modules/' . MOD . '/cat_list.html' );
$smarty -> assign( 'pages_list', 'api/modules/' . MOD . '/pages_list.html' );
$smarty -> assign( 'modal_new_cat', 'api/modules/' . MOD . '/modal_new_cat.html' );
$smarty -> assign( 'modal_del_page', 'api/modules/' . MOD . '/modal_del_page.html' );
//if (ID) $smarty -> assign( 'this_cat', $mod -> get_this_cat( ID ) );//Эта категория
2022-12-24 21:12:23 +05:00
$smarty -> assign( 'set', $set );
2022-12-11 13:55:49 +05:00
?>