示例#1
0
<?php

if ($_POST['op'] == 'add' and !empty($_POST['product_id'])) {
    $inventory = new inventory();
    $inventory->domain_id = domain_id::get();
    $inventory->product_id = $_POST['product_id'];
    $inventory->quantity = $_POST['quantity'];
    $inventory->cost = $_POST['cost'];
    $inventory->date = $_POST['date'];
    $inventory->note = $_POST['note'];
    $result = $inventory->insert();
    $saved = !empty($result) ? "true" : "false";
}
$productobj = new product();
$product_all = $productobj->get_all();
$smarty->assign('product_all', $product_all);
$smarty->assign('saved', $saved);
$smarty->assign('pageActive', 'inventory');
$smarty->assign('subPageActive', 'inventory_add');
$smarty->assign('active_tab', '#product');
if (isset($_POST['update'])) {
    $itNo = $_POST['itNo'];
    $title1 = $_POST['title1'];
    $stats1 = $_POST['stats1'];
    $type1 = $_POST['type1'];
    if (strlen($title1) < 1) {
        $addError[] = "Enter Title";
    } elseif (strlen($itNo) < 1) {
        $addError[] = "Enter No.";
    } elseif (!isset($stats1)) {
        $addError[] = "Enter status";
    } elseif (!isset($type1)) {
        $addError[] = "Enter type";
    } else {
        $add = new inventory($type1, $itNo, $title1, $stats1);
        $add->insert();
    }
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Add Inventory</title>

    <!-- Bootstrap core CSS -->