<!-- 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">Supplier</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/supplier-list">Supplier</a></li>
					<li class="breadcrumb-item active"><?php if ( count( $supplier ) > 0 ): ?>Edit<?php else: ?>Add New<?php endif;?> Supplier</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="frmSupplier" action="inventory/supplier-save" method="post">
					<div class="card card-primary">
						<div class="card-header">
							<h3 class="card-title"><?php if ( count( $supplier ) > 0 ): ?>Edit<?php else: ?>Add New<?php endif;?> Supplier</h3>
						</div>

						<div class="card-body">
							<div class="row">
								<div class="col-md-6">
									<div class="form-group">
										<label for="code">Supplier Code</label>
										<input type="text" name="code" id="code" class="form-control" placeholder="Supplier Code" value="<?php if ( count( $supplier ) > 0 ) {echo $supplier['code'];} else {echo $code;}?>"> Digit Only
									</div>
									<div class="form-group">
										<label for="name">Supplier Name</label>
										<input type="text" name="name" id="name" class="form-control" placeholder="Supplier Name" value="<?php if ( count( $supplier ) > 0 ) {echo $supplier['name'];}?>">
									</div>
									<div class="form-group">
										<label for="phone_no">Phone No</label>
										<input type="text" name="phone_no" id="phone_no" class="form-control" placeholder="Phone No" value="<?php if ( count( $supplier ) > 0 ) {echo $supplier['phone_no'];}?>">
									</div>
									<div class="form-group">
										<label for="address">Address</label>
										<textarea type="text" name="address" id="address" class="form-control" placeholder="Supplier Address"><?php if ( count( $supplier ) > 0 ) {echo $supplier['address'];}?></textarea>
									</div>
								</div>

								<div class="col-md-6">
									<div class="form-group">
										<label for="contact_person">Contact Person</label>
										<input type="text" name="contact_person" id="contact_person" class="form-control" placeholder="Contact Person" value="<?php if ( count( $supplier ) > 0 ) {echo $supplier['contact_person'];}?>">
									</div>
									<div class="form-group">
										<label for="notes">Notes</label>
										<textarea type="text" name="notes" id="notes" class="form-control" placeholder="Supplier Notes"><?php if ( count( $supplier ) > 0 ) {echo $supplier['notes'];}?></textarea>
									</div>
									<div class="form-group">
										<label for="status">Select Status</label>
										<select name="status" id="status" data-placeholder="Select Status" class="form-control select2">
											<option value="Active" <?php if ( count( $supplier ) > 0 && $supplier['status'] == 'Active' ) {echo 'selected';}?>>Active</option>
											<option value="Inactive" <?php if ( count( $supplier ) > 0 && $supplier['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( $supplier ) > 0 ): ?>
							<input type="hidden" name="id" value="<?php echo $supplier['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>