core/api/modules/doc-upd/index.php

53 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2023-04-09 19:52:26 +05:00
<?php
ini_set( 'display_errors', 0 );
//Узнаем ИД основной организации
$org_id=\core::getSettings("main_org");
//echo $org_id;
$org=\DB::getAll("SELECT * FROM `org` WHERE `id`=?", $org_id);
//print_r($org);
//Получаем банковские реквизиты
$bank=\DB::getAll("SELECT * FROM `bic` WHERE `id`=?", $org[0]['bic']);
//print_r($bank);
$smarty -> assign( 'org', $org );
$smarty -> assign( 'bank', $bank );
//получаем содержимое корзины
$user_id=\core::checkMe();
//echo $user_id;
$cart=\DB::getAll("SELECT * FROM `cart` WHERE `user_id`=? AND `order`=?", array($user_id, $_GET['id']));
for ($i=0; $i<count($cart); $i++){
$cart[$i]['title'] = \DB::getValue("SELECT `title` FROM `tovar` WHERE `id`=?", $cart[$i]['tovar_id']);
$cart[$i]['num'] = $i + 1;
$cart[$i]['cena'] = \DB::getValue("SELECT `cena` FROM `tovar_price_history` WHERE `tovar_id`=? AND `status`=1 ORDER BY `t` DESC LIMIT 1", $cart[$i]['tovar_id']);
$cart[$i]['nds']=$cart[$i]['cena']/100*20;
$cart[$i]['cena_s_nds']=$cart[$i]['cena']/100*20 + $cart[$i]['cena'];
$cart[$i]['cena_itog']=$cart[$i]['cena_s_nds']*$cart[$i]['kolvo'];
$itog_bez_nds=$itog_bez_nds+($cart[$i]['cena']*$cart[$i]['kolvo']);
$itog_nds=$itog_nds+($cart[$i]['nds']*$cart[$i]['kolvo']);
$itog_s_nds=$itog_s_nds+$cart[$i]['cena_itog'];
}
//print_r($cart);
$smarty -> assign( 'tovar', $cart );
$smarty -> assign( 'itog_bez_nds', $itog_bez_nds );
$smarty -> assign( 'itog_nds', $itog_nds );
$smarty -> assign( 'itog_s_nds', $itog_s_nds );
$smarty -> assign( 'num', count($cart) );
//print_r($cart);
//$userOption = \DB::getAll('SELECT * FROM `userOption` WHERE `user_id` = ' . $_SESSION['user_id'] . ' LIMIT 1');
//$smarty -> assign( 'userOption', $userOption );
?>