core/api/modules/lk/index.php

102 lines
3.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/');
/* ----------------------------------------------------------------------
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'] = "Отменен";
}
//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);
?>