<?php
	include 'db_Connection.php'; // load file db_Connection.php
	//include 'session_validate.php'; // cek session validate	
	
	$userID = $_SESSION['username'];
	$Level = $_SESSION['level'];
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Master Product</title>
    <!-- plugins:css -->
    <link rel="stylesheet" href="../../assets/vendors/mdi/css/materialdesignicons.min.css">
    <link rel="stylesheet" href="../../assets/vendors/ti-icons/css/themify-icons.css">
    <link rel="stylesheet" href="../../assets/vendors/css/vendor.bundle.base.css">
    <link rel="stylesheet" href="../../assets/vendors/font-awesome/css/font-awesome.min.css">
    <!-- endinject -->
    <!-- Plugin css for this page -->
    <link rel="stylesheet" href="../../assets/vendors/select2/select2.min.css">
    <link rel="stylesheet" href="../../assets/vendors/select2-bootstrap-theme/select2-bootstrap.min.css">
    <!-- End plugin css for this page -->
    <!-- inject:css -->
    <!-- endinject -->
    <!-- Layout styles -->
    <link rel="stylesheet" href="../../assets/css/style.css">
    <!-- End layout styles -->
    <link rel="shortcut icon" href="../../assets/images/favicon.png" />
	<!--get jquery -->
	<script src="../js/jquery-3.4.1.min.js"></script>
	
<script>
$(document).ready(function(){       
    $(".postsubmit").click( function() {
	var Product_Code_val = document.getElementById("Product_Code");	
	var Product_Name_val = document.getElementById("Product_Name");
	var Product_Type_val = document.getElementById("Product_Type");
	var Description_val = document.getElementById("Description");	
	var Selling_Price_val = document.getElementById("Selling_Price");
	
	var Product_Code = Product_Code_val.value;		
	var Product_Name = Product_Name_val.value;	
	var Product_Type = Product_Type_val.value;	
	var Description = Description_val.value;		
	var Selling_Price = Selling_Price_val.value;	
	
	var dataPost = {
                "Product_Code": Product_Code,
                "Product_Name": Product_Name,
				"Product_Type": Product_Type,
                "Description": Description,                
                "Selling_Price": Selling_Price
                };
            var dataString = JSON.stringify(dataPost);
	
	if($("form")[0].checkValidity()) {	
	$.ajax({
                type: "POST",
                url: "..//forms/product_validate.php",
                dataType: "json",                        
                data: {data_post: dataString},
                async:false,
                success : function(data){                     
                    if(data.result == "duplicate"){
                       alert("Product Already Exist");                                  
                       // swal("Warning!", "Group Already Exist", "warning"); 
                       //flag = 1;                  
                   }                   
                   else{
					   alert("Product Has Been Created");
                      //swal("Warning!", "trap", "warning"); 
                      //flag = 1;  
                   }
                },
                error : function(data){ 
                    alert("Data Failed to send");
                    //alert(data.result);
                    //flag = 1;
                    //return false;
                }
            });
	}	
    });                   
});    
</script>
	
  </head>
  <body>
    <div class="container-scroller">
      <!-- partial:../../partials/_navbar.html -->
      <nav class="navbar default-layout-navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
        <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-start">
          <a class="navbar-brand brand-logo" href="../../index.php"><img src="../../assets/images/logo_IMS.svg" alt="logo" /></a>
          <a class="navbar-brand brand-logo-mini" href="../../index.php"><img src="../../assets/images/logo-mini.svg" alt="logo" /></a>
        </div>
        <div class="navbar-menu-wrapper d-flex align-items-stretch">
          <button class="navbar-toggler navbar-toggler align-self-center" type="button" data-toggle="minimize">
            <span class="mdi mdi-menu"></span>
          </button>		  
          <ul class="navbar-nav navbar-nav-right">
            <li class="nav-item nav-profile dropdown">
              <a class="nav-link dropdown-toggle" id="profileDropdown" href="#" data-bs-toggle="dropdown" aria-expanded="false">
                <div class="nav-profile-img">
                  <img src="../../assets/images/faces/blank.png" alt="image">
                  <span class="availability-status online"></span>
                </div>
                <div class="nav-profile-text">
                  <p class="mb-1 text-black"><?php echo $userID; ?></p>
                </div>
              </a>
              <div class="dropdown-menu navbar-dropdown" aria-labelledby="profileDropdown">
                <a class="dropdown-item" href="../../pages/forms/change_password.php">
                  <i class="mdi mdi-cached me-2 text-success"></i>Change Password</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="../../pages/forms/logout.php">
                  <i class="mdi mdi-logout me-2 text-primary"></i> Signout </a>
              </div>
            </li>
			
            </li>
			
            <li class="nav-item nav-settings d-none d-lg-block">
              <a class="nav-link" href="#">
                <i class="mdi mdi-format-line-spacing"></i>
              </a>
            </li>
			
          </ul>
          <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="offcanvas">
            <span class="mdi mdi-menu"></span>
          </button>
        </div>
      </nav>
      <!-- partial -->
      <div class="container-fluid page-body-wrapper">
        <!-- partial:../../partials/_sidebar.html -->
        <nav class="sidebar sidebar-offcanvas" id="sidebar">
          <ul class="nav">
            <li class="nav-item nav-profile">
              <a href="#" class="nav-link">
                <div class="nav-profile-image">
                  <img src="../../assets/images/faces/blank.png" alt="profile" />
                  <span class="login-status online"></span>
                  <!--change to offline or busy as needed-->
                </div>
                <div class="nav-profile-text d-flex flex-column">
                  <span class="font-weight-bold mb-2"><?php echo $userID; ?></span>
                  <span class="text-secondary text-small"><?php echo $Level; ?></span>
                </div>
                <i class="mdi mdi-bookmark-check text-success nav-profile-badge"></i>
              </a>
            </li>

            <li class="nav-item">
              <a class="nav-link" data-bs-toggle="collapse" href="#forms" aria-expanded="false" aria-controls="forms">
                <span class="menu-title">Manage</span>
                <i class="mdi mdi-format-list-bulleted menu-icon"></i>
              </a>
              <div class="collapse" id="forms">
                <ul class="nav flex-column sub-menu">
                  <li class="nav-item">
					<a class="nav-link" href="../../pages/forms/Users.php">Users</a>
                    <a class="nav-link" href="../../pages/forms/Principal.php">Principal</a>
					<a class="nav-link" href="../../pages/forms/Customer.php">Customer</a>
					<a class="nav-link" href="../../pages/forms/Product.php">Product</a>
                  </li>
                </ul>
              </div>
            </li>	

			<li class="nav-item">
              <a class="nav-link" data-bs-toggle="collapse" href="#maintance" aria-expanded="false" aria-controls="maintance">
                <span class="menu-title">Maintance</span>
                <i class="mdi mdi-table-large menu-icon"></i>
              </a>
              <div class="collapse" id="maintance">
                <ul class="nav flex-column sub-menu">
                  <li class="nav-item">
					<a class="nav-link" href="../../pages/forms/Users_Maintance.php">Users</a>
                    <a class="nav-link" href="Principal_Maintance.php">Principal</a>
					<a class="nav-link" href="Customer_Maintance.php">Customer</a>
					<a class="nav-link" href="Product_Maintance.php">Product</a>
                  </li>
                </ul>
              </div>
            </li>

			<li class="nav-item">
              <a class="nav-link" data-bs-toggle="collapse" href="#transaction" aria-expanded="false" aria-controls="transaction">
                <span class="menu-title">Transaction</span>
                <i class="mdi mdi-format-list-bulleted menu-icon"></i>
              </a>
              <div class="collapse" id="transaction">
                <ul class="nav flex-column sub-menu">
                  <li class="nav-item">
                    <a class="nav-link" href="Purchase_Order.php">Purchase Order</a>
					<a class="nav-link" href="Sales_Invoice.php">Sales Invoive</a>
                  </li>
                </ul>
              </div>
            </li>
			
			<li class="nav-item">
              <a class="nav-link" data-bs-toggle="collapse" href="#view" aria-expanded="false" aria-controls="view">
                <span class="menu-title">View</span>
                <i class="mdi mdi-table-large menu-icon"></i>
              </a>
              <div class="collapse" id="view">
                <ul class="nav flex-column sub-menu">
                  <li class="nav-item">
                    <a class="nav-link" href="Stock.php">Stock</a>
					<a class="nav-link" href="view_po.php">PO</a>
					<a class="nav-link" href="view_si.php">SI</a>	
                  </li>
                </ul>
              </div>
            </li>
			
          </ul>
        </nav>
        <!-- partial -->
        <div class="main-panel">
          <div class="content-wrapper">
            <div class="page-header">
              <h3 class="page-title"> Create Master Product </h3>
            </div>
            <div class="row">			
              <div class="col-12 grid-margin stretch-card">			  
                <div class="card">
                  <div class="card-body">				  
                    <form class="forms-sample" method="POST">
					  <div class="form-group">
                        <label for="exampleInputName1">Product Code</label>
                        <input type="text" class="form-control" id="Product_Code" placeholder="Product Code" required />
                      </div>
					  <div class="form-group">
                        <label for="exampleInputCity1">Product Name</label>
                        <input type="text" class="form-control" id="Product_Name" placeholder="Product Name" required />
                      </div>
                      <div class="form-group">
                        <label for="exampleInputName1">Product Type</label>
                        <input type="text" class="form-control" id="Product_Type" placeholder="Product Type" required />
                      </div>
					  <div class="form-group">
                        <label for="exampleInputEmail3">Description</label>
                        <textarea class="form-control" id="Description" placeholder="Description" rows="4"></textarea>
                      </div>					  				
					<div class="form-group">
					<label for="exampleInputName1">Selling Price</label>
                      <div class="input-group">
                        <div class="input-group-prepend">
                          <span class="input-group-text bg-gradient-primary text-white">Rp</span>
                        </div>						
                        <input type="number" min="1" class="form-control" id="Selling_Price" placeholder="Selling Price" aria-label="Amount (to the nearest dollar)" required />
                        <div class="input-group-append">
                          <span class="input-group-text">.00</span>
                        </div>
                      </div>
                    </div>
                      <button type="submit" class="btn btn-gradient-primary me-2 postsubmit">Submit</button>
                      <button class="btn btn-light">Cancel</button>
                    </form>
                  </div>
                </div>
              </div>
          </div>
          <!-- content-wrapper ends -->
          <!-- partial:../../partials/_footer.html -->
          <footer class="footer">		  
          </footer>
          <!-- partial -->
        </div>
        <!-- main-panel ends -->
      </div>
      <!-- page-body-wrapper ends -->
    </div>
    <!-- container-scroller -->
    <!-- plugins:js -->
    <script src="../../assets/vendors/js/vendor.bundle.base.js"></script>
    <!-- endinject -->
    <!-- Plugin js for this page -->
    <script src="../../assets/vendors/select2/select2.min.js"></script>
    <script src="../../assets/vendors/typeahead.js/typeahead.bundle.min.js"></script>
    <!-- End plugin js for this page -->
    <!-- inject:js -->
    <script src="../../assets/js/off-canvas.js"></script>
    <script src="../../assets/js/misc.js"></script>
    <script src="../../assets/js/settings.js"></script>
    <script src="../../assets/js/todolist.js"></script>
    <script src="../../assets/js/jquery.cookie.js"></script>
    <!-- endinject -->
    <!-- Custom js for this page -->
    <script src="../../assets/js/file-upload.js"></script>
    <script src="../../assets/js/typeahead.js"></script>
    <script src="../../assets/js/select2.js"></script>
    <!-- End custom js for this page -->
  </body>
</html>
<?php	
	include 'session_validate.php'; // cek session validate	
?>
