Beispiel #1
0
<?php

$model = $_REQUEST['model'];
$action = $_REQUEST['action'];
include_once MODELS_ADMIN . "/" . $model . "_model.php";
switch (strtoupper($action)) {
    case 'ADD':
        if (isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'save') {
            $objProduct = new product();
            $objProduct->setProduct($_REQUEST);
            $objComm->redirect('index.php?model=' . $model);
        }
        break;
    case 'VIEW':
    case 'EDIT':
        if (isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'Update') {
            $objProduct = new product();
            $objProduct->setProduct($_REQUEST);
            $objComm->redirect('index.php?model=' . $model . '&action=edit&id=' . $_REQUEST['pk_id']);
        } else {
            $objProduct = new product();
            $datum = $objProduct->getProduct($_REQUEST['id']);
        }
        break;
    default:
        $objProduct = new product();
        $data = $objProduct->getAllproduct();
        break;
}
Beispiel #2
0
<?php

// Includng configuration file
include 'config/config.php';
//Check user is already login or not
checkAuthentication();
$product = new product();
$category = new category();
$smarty->assign('categories', $category->getCategories());
if (isset($_GET['action']) && $_GET['action'] == 'new') {
    $smarty->assign('content', $smarty->fetch('additem.tpl'));
} elseif (isset($_GET['action']) && $_GET['action'] == 'edit') {
    $id = $_GET['id'];
    $producted = $product->getProduct($id);
    $smarty->assign('product', $producted);
    $smarty->assign('content', $smarty->fetch('edititem.tpl'));
} elseif (isset($_POST['action']) && $_POST['action'] == 'add') {
    $file = $_FILES;
    $data = $_POST['data']['Item'];
    $data['image'] = $file['name'];
    if ($product->checkProduct($data)) {
        $_SESSION['message'] = 'Product with catalog no already exist. Please search with product sku and update details.';
        header('Location: ' . FRONTEND . 'inventory.php');
        exit;
    } else {
        if ($product->addProduct($data)) {
            header('Location: ' . FRONTEND . 'inventory.php');
            exit;
        }
    }
} elseif (isset($_POST['action']) && $_POST['action'] == 'update') {