85 lines
3.9 KiB
PHP
85 lines
3.9 KiB
PHP
<?php
|
||
|
||
if ($_SESSION['dostup'] != 'a' && $_SESSION['dostup'] != 'e')
|
||
die('403');
|
||
//\DB::set("ALTER TABLE `orders` CHANGE `adres_dostavki` `adres_dostavki` varchar(255) NULL AFTER `email`");
|
||
/* ----------------------------------------------------------------------
|
||
06.03.2023
|
||
Получаем список новый заказов
|
||
---------------------------------------------------------------------- */
|
||
$new_orders = \DB::getAll("SELECT * FROM `orders` WHERE `status`=0 ORDER BY `id` DESC");
|
||
|
||
//получаем данные о пользователе
|
||
for ($i = 0; $i < count($new_orders); $i++) {
|
||
|
||
/*
|
||
if (!$new_orders[$i]['fio']){
|
||
|
||
}
|
||
*/
|
||
$new_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=?
|
||
|
||
|
||
", $new_orders[$i]['id']);
|
||
|
||
|
||
|
||
$new_orders[$i]['auth']=($new_orders[$i]['fio'])?0:1;
|
||
//echo $new_orders[$i]['auth'];
|
||
|
||
$new_orders[$i]['tip']=($new_orders[$i]['org_id'] == 0)?0:1;// 0 - фл, 1 - юл
|
||
|
||
|
||
|
||
//Если авторизован и физ лицо
|
||
if ($new_orders[$i]['auth']==1 && $new_orders[$i]['tip']==0){
|
||
//получаем статус доставки:
|
||
$new_orders[$i]['dostavka']=( $new_orders[$i]['adres_dostavki']==0 )?'Сомовывоз':implode(', ', \DB::getRow("SELECT `gorod`, `street`, `dom` FROM `adres_dostavki` WHERE `id` IN (SELECT `adres_dostavki` FROM `orders` WHERE `user_id`=?)", $new_orders[$i]['user_id']));
|
||
//получаем контактное лицо:
|
||
$new_orders[$i]['kl'] = implode('<br>', \DB::getRow("SELECT `fio`, `tel`, `email` FROM `users` WHERE `id`=? LIMIT 1", $new_orders[$i]['user_id']));
|
||
}
|
||
|
||
//Если авторизован и организация
|
||
if ($new_orders[$i]['auth']==1 && $new_orders[$i]['tip']==1){
|
||
//получаем статус доставки:
|
||
$new_orders[$i]['dostavka']=( $new_orders[$i]['adres_dostavki']==0 )?'Сомовывоз':implode(', ', \DB::getRow("SELECT `gorod`, `street`, `dom` FROM `adres_dostavki` WHERE `id` IN (SELECT `adres_dostavki` FROM `orders` WHERE `user_id`=?)", $new_orders[$i]['user_id']));
|
||
//Получаем данные об организации
|
||
$new_orders[$i]['org']=\DB::getValue("SELECT `txt` FROM `org` WHERE `id`=?", $new_orders[$i]['org_id']);
|
||
//получаем контактное лицо:
|
||
$new_orders[$i]['kl'] = implode('<br>', \DB::getRow("SELECT `fio`, `tel`, `email` FROM `users` WHERE `id`=? LIMIT 1", $new_orders[$i]['user_id']));
|
||
}
|
||
// Если не авторизован и физ лицо
|
||
if ($new_orders[$i]['auth']==0 && $new_orders[$i]['tip']==0){
|
||
//получаем статус доставки:
|
||
$new_orders[$i]['dostavka']=( $new_orders[$i]['dostavka'] )?$new_orders[$i]['dostavka']:'Сомовывоз';
|
||
//получаем контактное лицо:
|
||
$new_orders[$i]['kl']=$new_orders[$i]['fio'] . '<br>' . $new_orders[$i]['tel'] . '<br>' . $new_orders[$i]['email'];
|
||
}
|
||
// Если не авторизован и организация
|
||
if ($new_orders[$i]['auth']==0 && $new_orders[$i]['tip']==1){
|
||
//получаем статус доставки:
|
||
$new_orders[$i]['dostavka']=( $new_orders[$i]['dostavka'] )?$new_orders[$i]['dostavka']:'Сомовывоз';
|
||
//Получаем данные об организации
|
||
$new_orders[$i]['org']=\DB::getValue("SELECT `txt` FROM `org` WHERE `id`=?", $new_orders[$i]['org_id']);
|
||
//получаем контактное лицо:
|
||
$new_orders[$i]['kl']=$new_orders[$i]['fio'] . '<br>' . $new_orders[$i]['tel'] . '<br>' . $new_orders[$i]['email'];
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
$smarty->assign('new_orders', $new_orders);
|
||
|
||
|
||
|
||
|
||
?>
|