core/api/modules/print-zakaz/index.php

61 lines
3.5 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
if ($_SESSION['dostup'] != 'a' && $_SESSION['dostup'] != 'e') die('403');
$order = \DB::getRow("SELECT * FROM `orders` WHERE `id`=? LIMIT 1", $_GET['id']);
$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=?
", $_GET['id']);
for ($i = 0; $i < count($list); $i++) {
$list[$i]['n'] = $i + 1;
$list[$i]['summ'] = $list[$i]['kolvo'] * $list[$i]['cena'];
$itog = $itog + $list[$i]['summ'];
}
$order['auth'] = ($order['fio']) ? 0 : 1;
$order['tip'] = ($order['org_id'] == 0) ? 0 : 1; // 0 - фл, 1 - юл
//Если авторизован и физ лицо
if ($order['auth'] == 1 && $order['tip'] == 0) {
//получаем статус доставки:
$order['dostavka'] = ($order['adres_dostavki'] == 0) ? 'Сомовывоз' : implode(', ', \DB::getRow("SELECT `gorod`, `street`, `dom` FROM `adres_dostavki` WHERE `id` IN (SELECT `adres_dostavki` FROM `orders` WHERE `user_id`=?)", $order['user_id']));
//получаем контактное лицо:
$order['kl'] = implode('<br>', \DB::getRow("SELECT `fio`, `tel`, `email` FROM `users` WHERE `id`=? LIMIT 1", $order['user_id']));
}
//Если авторизован и организация
if ($order['auth'] == 1 && $order['tip'] == 1) {
//получаем статус доставки:
$order['dostavka'] = ($order['adres_dostavki'] == 0) ? 'Сомовывоз' : implode(', ', \DB::getRow("SELECT `gorod`, `street`, `dom` FROM `adres_dostavki` WHERE `id` IN (SELECT `adres_dostavki` FROM `orders` WHERE `user_id`=?)", $order['user_id']));
//Получаем данные об организации
$order['org'] = \DB::getValue("SELECT `txt` FROM `org` WHERE `id`=?", $order['org_id']);
$order['inn'] = \DB::getValue("SELECT `inn` FROM `org` WHERE `id`=?", $order['org_id']);
$order['kpp'] = \DB::getValue("SELECT `kpp` FROM `org` WHERE `id`=?", $order['org_id']);
//получаем контактное лицо:
$order['kl'] = implode('<br>', \DB::getRow("SELECT `fio`, `tel`, `email` FROM `users` WHERE `id`=? LIMIT 1", $order['user_id']));
}
// Если не авторизован и физ лицо
if ($order['auth'] == 0 && $order['tip'] == 0) {
//получаем статус доставки:
$order['dostavka'] = ($order['dostavka']) ? $order['dostavka'] : 'Сомовывоз';
//получаем контактное лицо:
$order['kl'] = $order['fio'] . '<br>' . $order['tel'] . '<br>' . $order['email'];
}
// Если не авторизован и организация
if ($order['auth'] == 0 && $order['tip'] == 1) {
//получаем статус доставки:
$order['dostavka'] = ($order['dostavka']) ? $order['dostavka'] : 'Сомовывоз';
//Получаем данные об организации
$order['org'] = \DB::getValue("SELECT `txt` FROM `org` WHERE `id`=?", $order['org_id']);
$order['inn'] = \DB::getValue("SELECT `inn` FROM `org` WHERE `id`=?", $order['org_id']);
$order['kpp'] = \DB::getValue("SELECT `kpp` FROM `org` WHERE `id`=?", $order['org_id']);
//получаем контактное лицо:
$order['kl'] = $order['fio'] . '<br>' . $order['tel'] . '<br>' . $order['email'];
}
$smarty->assign('order', $order);
$smarty->assign('list', $list);
$smarty->assign('itog', $itog);
?>