110 lines
4.5 KiB
PHP
110 lines
4.5 KiB
PHP
<?php
|
||
ini_set('display_errors', 0 );
|
||
//@mkdir(MYDIR . '/img/tovar', 0700);
|
||
//проверяем авторизацию
|
||
|
||
if ( $_SESSION['dostup'] !=='a' && $_SESSION['dostup'] !== 'e' ) header( 'Location: /403/' );
|
||
|
||
/* ----------------------------------------------------------------------
|
||
17.02.2023
|
||
Перемещаем товар
|
||
---------------------------------------------------------------------- */
|
||
if ($_POST['move']) \DB::set ("UPDATE `tovar` SET `category`=? WHERE `title` LIKE '" . $_POST['txt'] . "'", $_POST['category']);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
$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`=? LIMIT 1000", $_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 ORDER BY `title`");
|
||
$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 );
|
||
?>
|