<div class="row" id="itemform" style="display:none">
	<div class="spinner" id="grid-loader" style="display:none">
	  <div class="rect1"></div>
	  <div class="rect2"></div>
	  <div class="rect3"></div>
	</div>
	
	<div class="col-md-12">
		<form action="" id="customer_form" class="form-horizontal" enctype="multipart/form-data" method="post" accept-charset="utf-8" novalidate="novalidate" autocomplete="off">
			<div class="col-md-12">
	<div class="panel panel-piluku">
		<div class="panel-heading">
                <h3 class="panel-title">
                     <i class="ion-edit"></i> 
                    	Item Information						<small>(Fields in red are required)</small>
                    	<i class="ion-close" id="closeitemform" style="float: right; background: #dc1919; color: white; padding: 4px; border-radius: 3px;"></i>
                </h3>
        </div>

			<div class="panel-body">
				<?php
                    if (isset($_POST['submitf'])) {
                    ?>
                    <div class="alert alert-<?php echo ($success) ? "success" : "danger"; ?>"> 
                            <?php echo ($success) ? $success : $danger; ?>                          
                    </div>
                 <?php } ?>
                <?php /* 
                <div class="form-group">
					<label for="date" class="col-sm-3 col-md-3 col-lg-2 control-label required">Date :</label>			<div class="col-sm-9 col-md-9 col-lg-10">
					<input type="text" name="date" autofocus value="" class="form-control datepicker" id="date3">
					</div>
				</div>
				*/ ?>
				<?php
					$p_id = $db->query("SELECT MAX(id) AS maxid FROM itemsetup");
					$row = $p_id->fetchArray();
					$prID = $row['maxid'] + 1;
				?>	
				<div class="form-group">
					<label for="item_number" class="col-sm-3 col-md-3 col-lg-2 control-label wide">UPC/EAN/ISBN :</label>					<div class="col-sm-9 col-md-9 col-lg-10">
						<input type="text" name="item_number" value="<?php echo $prID; ?>" id="item_number3" class="form-control form-inps">
					</div>
				</div>
				<?php
					$p_id = $db->query("SELECT MAX(id) AS maxid FROM itemsetup");
					$row = $p_id->fetchArray();
					$prID = $row['maxid'] + 1;
				?>	
				<div class="form-group" style="display: none;">
					<label for="product_id" class="col-sm-3 col-md-3 col-lg-2 control-label wide">Product ID :</label>					<div class="col-sm-9 col-md-9 col-lg-10">
						<input type="hidden" value="<?php echo $prID; ?>" name="product_id" value=""  id="product_id3" class="form-control form-inps">
						
					</div>
				</div>

				<div class="form-group">
					<label for="name" class="col-sm-3 col-md-3 col-lg-2 control-label required wide">Item Name:</label>					<div class="col-sm-9 col-md-9 col-lg-10">
						<input type="text" name="name" value="" id="name3" list="listItems" class="form-control form-inps">
						<datalist id="listItems">
						<?php
							$listItems = $db->query("SELECT * FROM itemsetup");

							while($listrow = $listItems->fetchArray()){
						?>
							<option value="<?php echo $listrow['item_name']; ?>"><?php echo $listrow['item_name']; ?>
						<?php } ?>	
						</datalist>
					</div>
				</div>

				<div class="form-group">	
					<label for="unit" class="col-sm-3 col-md-3 col-lg-2 control-label required">Unit :</label>			<div class="col-sm-9 col-md-9 col-lg-10">
					<select name="unit" class="ui search selection dropdown form-control" id="add_unit">
					  <option value="">Unit</option>
					  <?php
						$unitNames = $db->query("SELECT * FROM units");
						while($rowNames = $unitNames->fetchArray()){
							$selected = "";
							if (isset($_POST["unit"])) {
							 	$unit_id = $_POST["unit"];
							 	if ($unit_id == $rowNames['id']) {
							 		$selected = "selected";
							 	}
							}    
					?>
						<option value="<?php echo $rowNames['id']; ?>" <?php echo $selected; ?>><?php echo $rowNames['unit']; ?></option>
					<?php } ?>
					</select>


					<a href="#" id="manageunit" target="_blank"><input type="button"  value="Add Unit" class=" submit_button btn btn-success"></a>
					</div>
				</div>


				<div class="form-group">
					<label for="category_id" class="col-sm-3 col-md-3 col-lg-2 control-label  required wide">Category :</label>					
					<div class="col-sm-9 col-md-9 col-lg-10">
					<select name="category_id" class="ui search selection dropdown form-control" id="category_id">
					  <option value="">Category</option>
					  <?php
						$catNames = $db->query("SELECT * FROM categories");
						while($rowNames = $catNames->fetchArray()){
							$selected = "";
							if (isset($_POST["category_id"])) {
							 	$unit_id = $_POST["category_id"];
							 	if ($unit_id == $rowNames['id']) {
							 		$selected = "selected";
							 	}
							}    
					?>
						<option value="<?php echo $rowNames['id']; ?>" <?php echo $selected; ?>><?php echo $rowNames['name']; ?></option>
					<?php } ?>
					</select>
						<div>
									<a href="categories.php" target="_blank" id="manage_cat" title="Manage Category" class=" submit_button btn btn-success">>Add Category</a>								</div>
					</div>
				</div>
							</div><!--/panel-body -->
		</div><!-- /panel-piluku -->


		<div class="panel panel-piluku">
			<div class="panel-heading pricing-widget">
			ricing and Inventory			</div>
			<div class="panel-body">
					<div class="form-group">
						<label for="cost_price" class="col-sm-3 col-md-3 col-lg-2 control-label required wide">Cost Price :</label>						<div class="col-sm-9 col-md-9 col-lg-10">
							<input type="text" name="cost_price" value="" size="8" id="cost_price3" class="form-control form-inps">
						</div>
					</div>

					<div class="form-group">
						<label for="cost_price" class="col-sm-3 col-md-3 col-lg-2 control-label required wide">Selling Price :</label>						<div class="col-sm-9 col-md-9 col-lg-10">
							<input type="text" name="selling_price" value="" size="8" id="selling_price3" class="form-control form-inps">
						</div>
					</div>

					<div class="form-group">
						<label for="stock_qty" class="col-sm-3 col-md-3 col-lg-2 control-label required wide">Stock Quantity:</label>						<div class="col-sm-9 col-md-9 col-lg-10">
							<input type="text" name="quantity" value="" size="8" id="quantity3" class="form-control form-inps">
						</div>
					</div>

					<div class="form-group">
						<label for="open_qty" class="col-sm-3 col-md-3 col-lg-2 control-label required wide">Opening Quantity :</label>						<div class="col-sm-9 col-md-9 col-lg-10">
							<input type="text" name="opening" value="" size="8" id="opening3" class="form-control form-inps">
						</div>
					</div>

					<div class="form-group reorder-input ">
					<label for="reorder_level" class="col-sm-3 col-md-3 col-lg-2 control-label wide">Reorder Level :</label>					<div class="col-sm-9 col-md-9 col-lg-10">
						<input type="text" name="reorder_level" value="" id="reorder_level3" class="form-control form-inps">
					</div>
				</div>

						<div class="form-actions pull-right">
										&nbsp;
					<input type="submit" name="submitf" value="Submit" id="itemsubmit" class="submit_button btn btn-primary">
				</div>

			</div><!-- /panel-body-->
		</div><!--/panel-piluku-->

	</div>
			
		</form>
			</div>
		</div><!-- /row -->
