Пример #1
0
function add()
{
    $pid = $_REQUEST["pid"];
    $pname = $_REQUEST["pname"];
    $price = $_REQUEST["price"];
    $qty = $_REQUEST["qty"];
    include "product.php";
    $obj = new product();
    if ($obj->addProduct($pid, $pname, $price, $qty)) {
        echo '{"result":1}';
    } else {
        echo "{'result':0}";
    }
}
Пример #2
0
function addproduct_action()
{
    $name = $_POST['name'];
    $type = $_POST['type'];
    $price = $_POST['price'];
    $product = new product($name, $type, $price);
    $result = $product->addProduct();
    $list_url = 'http://' . HOST . '/' . APPLICATION . '/index.php?page=home';
    $add_url = 'http://' . HOST . '/' . APPLICATION . '/index.php?page=addProduct';
    if ($result) {
        header("Location: {$list_url}");
    } else {
        header("Location: {$add_url}");
    }
}
Пример #3
0
<?php

include '../product.php';
$productAction = new product();
$scatID = $_POST['scat'];
$productAction->addProduct($scatID);
header("location:addProduct.php");
Пример #4
0
    $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') {
    $file = $_FILES;
    $data = $_POST['data']['Item'];
    if (isset($file['name'])) {
        $data['image'] = $file['name'];
    } else {
        $data['image'] = '';
    }
    if ($product->updateProduct($data)) {
        $_SESSION['message'] = 'Product has been updated successfully.';
        header('Location: ' . FRONTEND . 'inventory.php');