core/api/modules/a_tovar_cat/index.php

86 lines
4.1 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-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);
$c=\DB::getAll("SELECT count(*) FROM `tovar_category` WHERE `category`=?", $cats[$i]['id']);
$cats[$i]['count_cats']=$c[0]['count(*)'];
unset($c);
$c=\DB::getAll("SELECT count(*) FROM `tovar` WHERE `category`=?", $cats[$i]['id']);
$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
Получаем список товаров
---------------------------------------------------------------------- */
$tovars=\DB::getAll("SELECT * FROM `tovar` WHERE `category`=?", $_GET['id']);
for($i=0; $i<count($tovars); $i++) $tovars[$i]['img']=\DB::getValue("SELECT `filename` FROM `tovar_img` WHERE `tovar_id`=?", $tovars[$i]['id']);
$smarty -> assign( 'pages', $tovars );
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
2022-12-24 21:12:23 +05:00
$catList=\DB::getAll("SELECT `id`, `title` FROM `tovar_category` WHERE `status`=1");
$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
?>