core/api/modules/lk/index.php

102 lines
3.6 KiB
PHP
Raw Normal View History

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-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']);
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_price_history.cena FROM cart
JOIN `tovar`
ON tovar.id=cart.tovar_id
JOIN `tovar_price_history`
ON tovar_price_history.tovar_id=cart.tovar_id
WHERE cart.order=? AND tovar_price_history.status=1 ORDER BY tovar_price_history.t DESC
", $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);
2022-12-11 13:55:49 +05:00
?>