core/api/modules/a_tovar_cat/index.php

86 lines
4.1 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.

<?php
ini_set('display_errors', 0 );
//@mkdir(MYDIR . '/img/tovar', 0700);
//проверяем авторизацию
if ( $_SESSION['dostup'] !=='a' && $_SESSION['dostup'] !== 'e' ) header( 'Location: /403/' );
$smarty -> assign( 'uploadimg', 'api/modules/a_tovar_cat/uploadimg.html' );
$_SESSION['tmp']=$_GET['id'];
/* ----------------------------------------------------------------------
14.12.2022
Получаем инфу о пользователе
---------------------------------------------------------------------- */
$smarty -> assign( 'userInfo', \core::getUserInfo( $_SESSION['user_id'] ) );
$set['showNoPublic']=\core::getSettings('showNoPublic', 'a_tovar_cat');
/* ----------------------------------------------------------------------
15.12.2022
Получаем список категорий
---------------------------------------------------------------------- */
$_GET['id'] = ($_GET['id']) ? $_GET['id'] : 0;
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(*)'];
}
$smarty -> assign( 'cats', $cats );
/* ----------------------------------------------------------------------
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 );
/* ----------------------------------------------------------------------
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 );
/* ----------------------------------------------------------------------
02.01.2023
Получаем обложек
---------------------------------------------------------------------- */
$imgs=\DB::getAll("SELECT * FROM `tovar_category_img` WHERE `tovar_category_id`=?", $_GET['id']);
$smarty -> assign( 'imgs', $imgs );
/* ----------------------------------------------------------------------
21.12.2022
Получаем список категорий
---------------------------------------------------------------------- */
$catList=\DB::getAll("SELECT `id`, `title` FROM `tovar_category` WHERE `status`=1");
$smarty -> assign( 'catList', $catList );
}
//получаем список страниц
//echo ("test1");
//$pages = $mod -> get_pages('page', ID);
//$smarty -> assign( 'pages', $pages );//список страниц
//$smarty -> assign( 'cat_id', ID );//ИД категории
//$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 ) );//Эта категория
$smarty -> assign( 'set', $set );
?>