<!-- Content Header (Page header) -->
<section class="content-header">
	<div class="container-fluid">
		<div class="row mb-2">
			<div class="col-sm-6">
				<h1 class="m-0">Item</h1>
			</div>

			<div class="col-sm-6">
				<ol class="breadcrumb float-sm-right">
					<li class="breadcrumb-item"><a href="dashboard">Dashboard</a></li>
					<li class="breadcrumb-item"><a href="inventory">Inventory</a></li>
					<li class="breadcrumb-item"><a href="inventory/item-list">Item</a></li>
					<li class="breadcrumb-item active"><?php if ( count( $item ) > 0 ): ?>Edit<?php else: ?>Add New<?php endif;?> Item</li>
				</ol>
			</div>
		</div>
	</div>
</section>

<!-- Main content -->
<section class="content">
	<div class="container-fluid">
		<!-- Small boxes (Stat box) -->
		<div class="row">
			<div class="col-md-12">
				<form id="frmItem" action="inventory/item-save" enctype="multipart/form-data" method="post">
					<div class="card card-primary">
						<div class="card-header">
							<h3 class="card-title"><?php if ( count( $item ) > 0 ): ?>Edit<?php else: ?>Add New<?php endif;?> Item</h3>
						</div>

						<div class="card-body">
							<div class="row">
								<div class="col-md-6">
									<div class="form-group">
										<label for="code">Item Code</label>
										<input type="text" name="code" id="code" class="form-control" placeholder="Give your Custom Item/Product Code" value="<?php if ( count( $item ) > 0 ) {echo $item['code'];} else {echo set_value( 'code' );}?>"<?php if ( count( $item ) > 0 ) {echo 'readonly';}?>>
									</div>
									<div class="form-group">
										<label for="name">Item Name</label>
										<input type="text" name="name" id="name" class="form-control" placeholder="Item Name" value="<?php if ( count( $item ) > 0 ) {echo $item['name'];} else {echo set_value( 'name' );}?>">
									</div>
									<div class="form-group">
										<label for="name">Item Picture</label>
										<input type="file" name="picture" id="picture" class="form-control" placeholder="Item Picture">
									</div>
									<div class="form-group">
										<label for="description">Description</label>
										<textarea name="description" id="description" rows="3" placeholder="Description" class="form-control"><?php if ( count( $item ) > 0 ) {echo $item['description'];} else {echo set_value( 'description' );}?></textarea>
									</div>
								</div>

								<div class="col-md-6">
									<div class="form-group">
										<label for="min_sale_price">Min. Sale Price</label>
										<input type="text" name="min_sale_price" id="min_sale_price" class="form-control" placeholder="Min. Sale Price" value="<?php if ( count( $item ) > 0 ) {echo $item['min_sale_price'];} else {echo set_value( 'min_sale_price' );}?>">
									</div>
									<div class="form-group">
										<label for="re_order">Re-Order Level</label>
										<input type="text" name="re_order" id="re_order" class="form-control" placeholder="Re-Order Level" value="<?php if ( count( $item ) > 0 ) {echo $item['re_order'];} else {echo set_value( 're_order' );}?>">
									</div>
									<div class="form-group">
										<label for="status">Select Status</label>
										<select name="status" id="status" class="form-control select2" data-placeholder="Select Status">
											<option value="Active" <?php if ( count( $item ) > 0 && $item['status'] == 'Active' ) {echo 'selected';}?>>Active</option>
											<option value="Inactive" <?php if ( count( $item ) > 0 && $item['status'] == 'Inactive' ) {echo 'selected';}?>>Inactive</option>
										</select>
									</div>
								</div>
							</div>
						</div>

						<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
						<?php if ( count( $item ) > 0 ): ?>
							<input type="hidden" name="id" value="<?php echo $item['id']; ?>">
						<?php endif;?>

						<div class="card-footer">
							<input type="submit" class="btn bg-gradient-primary" value="Save Changes">
							<input type="reset" class="btn bg-gradient-danger" value="Cancel">
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</section>