core/api/modules/lk/index.php

128 lines
4.6 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);
if (!$_SESSION['user_id'])
header('Location: /login/');
/* ----------------------------------------------------------------------
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);
/* ----------------------------------------------------------------------
25.06.2022
Получаем список заказов
---------------------------------------------------------------------- */
$orders = \DB::getAll("SELECT * FROM `orders` WHERE `user_id`=? ORDER BY `t` DESC LIMIT 100", $_SESSION['user_id']);
//print_r($orders);
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("
SELECT cart.id, cart.kolvo, tovar.id AS tovar_id, tovar.title, tovar.artikul, tovar.cena FROM cart
JOIN `tovar`
ON tovar.id=cart.tovar_id
WHERE cart.order=?
", $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'] = "Отменен";
}
//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);
$smarty->assign('myOrgs', $myOrgs);
/* ----------------------------------------------------------------------
15.10.2022
Получаем список регионов
---------------------------------------------------------------------- */
$strana_id = \core::getSettings('strana');
$region = \DB::getAll('SELECT * FROM `region` WHERE `strana_id` = ' . $strana_id);
$smarty->assign('region', $region);
/* ----------------------------------------------------------------------
15.10.2022
Получаем список городов
---------------------------------------------------------------------- */
$city = \DB::getAll('SELECT * FROM `city` WHERE `strana_id` = ' . $strana_id);
$smarty->assign('city', $city);
/* ----------------------------------------------------------------------
14.10.2022
Меню личного кабинета
---------------------------------------------------------------------- */
$smarty->assign('mnulk', 'skin/inc/mnulk.html');
/* ----------------------------------------------------------------------
02.06.2022
Получаем информацию о пользователе
---------------------------------------------------------------------- */
$user_info = \DB::getAll('SELECT * FROM `users` WHERE `id` = ? LIMIT 1', $_SESSION['user_id']);
$smarty->assign('user_info', $user_info);
$userOption = \DB::getAll('SELECT * FROM `userOption` WHERE `user_id` = ' . $_SESSION['user_id'] . ' LIMIT 1');
$smarty->assign('userOption', $userOption);
/* ----------------------------------------------------------------------
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);
?>