<?php

$smarty = createSmarty(true, true);

if (empty($ID_ITEM)) {
    $ID_ITEM = getVal('ID');
}

global $adminName;

$order = new Order($ID_ITEM);
$order->createFromDB($ID_ITEM);
$order->fetchItems();

if (!empty($order->admin)) {
    $adminName = returnSQLResult('SELECT login FROM admins WHERE id=:id', ['id' => $order->admin]);
}

$smarty->assign([
    'order' => $order,
    'adminName' => $adminName,
]);

$template_name = getVal('template');

$template = 'printCenter/'.$template_name.'.tpl';

if ($smarty->templateExists($template)) {
    $smarty->display($template);
} else {
    $smarty->display('printCenter/invoiceForeign.tpl');
}
