Пример #1
0
    if ($purchase->deletePurchase($id)) {
        header('Location: ' . FRONTEND . 'purchasebills.php');
        exit;
    }
} elseif (isset($_GET['action']) && $_GET['action'] == 'viewpurchase') {
    $id = $_GET['id'];
    $purchasebill = $purchase->getPurchase($id);
    $purchaseitems = $purchase->getPurchaseItems($id);
    $smarty->assign('purchase', $purchasebill);
    $smarty->assign('purchaseitem', $purchaseitems);
    $smarty->assign('content', $smarty->fetch('purchaseview.tpl'));
} elseif (isset($_GET['action']) && $_GET['action'] == 'search') {
    $keyword = $_POST['keywords'];
    $purchasebills = $purchase->getSearchPurchase($keyword);
    $smarty->assign('purchasebills', $purchasebills);
    $smarty->assign('content', $smarty->fetch('purchase.tpl'));
} else {
    $page = 1;
    if (isset($_GET['page'])) {
        $page = $_GET['page'];
    }
    $purchasebills = $purchase->getPurchaseBills($page, $offset = 10);
    $smarty->assign('page', $page);
    $smarty->assign('pagecount', ceil(count($purchasebills) / $offset));
    $smarty->assign('purchasebills', $purchasebills);
    $smarty->assign('purchasecount', count($purchasebills));
    $smarty->assign('content', $smarty->fetch('purchase.tpl'));
}
$smarty->assign('action', 'purchase');
$smarty->assign('toolbar', $smarty->fetch('toolbar.tpl'));
$smarty->display('two-column-left.html');