2022-12-11 13:55:49 +05:00
< ? php
2023-07-12 20:02:20 +05:00
ini_set ( 'display_errors' , 0 );
if ( ! $_SESSION [ 'user_id' ])
header ( 'Location: /login/' );
2022-12-24 21:12:23 +05:00
2023-08-28 22:47:07 +05:00
/* ----------------------------------------------------------------------
27.08 . 2023
Мои статьи
---------------------------------------------------------------------- */
$blogs = \DB :: getAll ( " SELECT `id`, `title`, `see`, `reyt`, `user_id`, `status`, `alias` FROM `pages` WHERE `user_id`=? ORDER BY `id` DESC " , $_SESSION [ 'user_id' ]);
for ( $i = 0 ; $i < count ( $blogs ); $i ++ ){
$blogs [ $i ][ 'filename' ] = \DB :: getValue ( " SELECT `filename` FROM `img` WHERE `content_type`=? AND `content_id`=? " , array ( 'pages' , $blogs [ $i ][ 'id' ]));
$blogs [ $i ][ 'link' ] = ( $blogs [ $i ][ 'alias' ]) ? '/' . $blogs [ $i ][ 'alias' ] . '.html' : '/page/' . $blogs [ $i ][ 'id' ];
}
$smarty -> assign ( 'blogs' , $blogs );
2023-07-12 20:02:20 +05:00
/* ----------------------------------------------------------------------
25.06 . 2022
Получаем список заказов
---------------------------------------------------------------------- */
$orders = \DB :: getAll ( " SELECT * FROM `orders` WHERE `user_id`=? ORDER BY `t` DESC LIMIT 100 " , $_SESSION [ 'user_id' ]);
2023-08-14 09:15:58 +05:00
//print_r($orders);
2023-07-12 20:02:20 +05:00
for ( $i = 0 ; $i < count ( $orders ); $i ++ ) {
//Считаем итог корзины:
$cart = \DB :: getAll ( " SELECT `id`, `kolvo`, `tovar_id` FROM `cart` WHERE `order`=? " , $orders [ $i ][ 'id' ]);
//print_r($cart);
for ( $j = 0 ; $j < count ( $cart ); $j ++ ) {
$itog = $cart [ $j ][ 'kolvo' ] * \core :: GetLostPrice ( $cart [ $j ][ 'tovar_id' ]);
$orders [ $i ][ 'itog' ] = $orders [ $i ][ 'itog' ] + $itog ;
}
$orders [ $i ][ 'list' ] = \DB :: getAll ( "
2023-08-14 09:15:58 +05:00
SELECT cart . id , cart . kolvo , tovar . id AS tovar_id , tovar . title , tovar . artikul , tovar . cena FROM cart
2023-07-12 20:02:20 +05:00
JOIN `tovar`
ON tovar . id = cart . tovar_id
2023-08-14 09:15:58 +05:00
WHERE cart . order = ?
2023-07-12 20:02:20 +05:00
" , $orders[$i] ['id']);
if ( $orders [ $i ][ 'status' ] == 0 )
$orders [ $i ][ 'status' ] = " Новый " ;
if ( $orders [ $i ][ 'status' ] == 1 )
$orders [ $i ][ 'status' ] = " В обработке" ;
if ( $orders [ $i ][ 'status' ] == 2 )
$orders [ $i ][ 'status' ] = " Завершен " ;
if ( $orders [ $i ][ 'status' ] == 3 )
$orders [ $i ][ 'status' ] = " Отменен " ;
}
2023-04-09 19:52:26 +05:00
2023-07-12 20:02:20 +05:00
//print_r($orders);
$smarty -> assign ( 'orders' , $orders );
/* ----------------------------------------------------------------------
24.06 . 2022
Получаем список своих организаций
---------------------------------------------------------------------- */
$myOrgs = \DB :: getAll ( " SELECT * FROM `org` WHERE `id` IN (SELECT `org` FROM `users_orgs` WHERE `user`=?) " , $_SESSION [ 'user_id' ]);
//print_r($myOrgs);
2023-04-09 19:52:26 +05:00
2023-07-12 20:02:20 +05:00
$smarty -> assign ( 'myOrgs' , $myOrgs );
2023-04-09 19:52:26 +05:00
2022-12-11 13:55:49 +05:00
/* ----------------------------------------------------------------------
15.10 . 2022
Получаем список регионов
---------------------------------------------------------------------- */
2023-07-12 20:02:20 +05:00
$strana_id = \core :: getSettings ( 'strana' );
$region = \DB :: getAll ( 'SELECT * FROM `region` WHERE `strana_id` = ' . $strana_id );
$smarty -> assign ( 'region' , $region );
2022-12-11 13:55:49 +05:00
/* ----------------------------------------------------------------------
15.10 . 2022
Получаем список городов
---------------------------------------------------------------------- */
2023-07-12 20:02:20 +05:00
$city = \DB :: getAll ( 'SELECT * FROM `city` WHERE `strana_id` = ' . $strana_id );
$smarty -> assign ( 'city' , $city );
2022-12-11 13:55:49 +05:00
/* ----------------------------------------------------------------------
14.10 . 2022
Меню личного кабинета
---------------------------------------------------------------------- */
2023-07-12 20:02:20 +05:00
$smarty -> assign ( 'mnulk' , 'skin/inc/mnulk.html' );
2022-12-11 13:55:49 +05:00
/* ----------------------------------------------------------------------
02.06 . 2022
Получаем информацию о пользователе
---------------------------------------------------------------------- */
2023-07-12 20:02:20 +05:00
$user_info = \DB :: getAll ( 'SELECT * FROM `users` WHERE `id` = ? LIMIT 1' , $_SESSION [ 'user_id' ]);
$smarty -> assign ( 'user_info' , $user_info );
2022-12-11 13:55:49 +05:00
$userOption = \DB :: getAll ( 'SELECT * FROM `userOption` WHERE `user_id` = ' . $_SESSION [ 'user_id' ] . ' LIMIT 1' );
2023-07-12 20:02:20 +05:00
$smarty -> assign ( 'userOption' , $userOption );
2023-08-28 22:47:07 +05:00
/* ----------------------------------------------------------------------
24.08 . 2023
Получаем аву
---------------------------------------------------------------------- */
$filename = \DB :: getValue ( 'SELECT `filename` FROM `img` WHERE `content_type`="user" AND `content_id` = ? LIMIT 1' , $_SESSION [ 'user_id' ]);
$smarty -> assign ( 'filename' , $filename );
2022-12-11 13:55:49 +05:00
?>