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

						<div class="card-body">
							<div class="row">
								<div class="col-md-6">
									<div class="form-group">
										<label>Payment Receipt No</label>
										<input type="text" name="payment_no" id="payment_no" class="form-control" value="<?php if ( count( $payment ) > 0 ): echo $payment['payment_no'];else:echo $payment_no;endif;?>">
									</div>
									<div class="form-group">
										<label for="payment-date">Payment Receipt Date</label>
										<div class="input-group date datepicker" id="payment-date" data-target-input="nearest">
											<input type="text" name="payment_date" class="form-control" data-target="#payment-date" value="<?php if ( count( $payment ) > 0 ): echo date_to_ui( $payment['payment_date'] );else:echo date( 'd/m/Y' );endif;?>" />
											<div class="input-group-append" data-target="#payment-date" data-toggle="datetimepicker">
												<div class="input-group-text"><i class="fa fa-calendar"></i></div>
											</div>
										</div>
									</div>
									<div class="form-group">
										<label>Select Supplier</label>
										<select name="supplier_id" id="supplier_id" class="form-control select2">
											<?php foreach ( $suppliers as $supplier ): ?>
												<option value="<?php echo $supplier['id']; ?>"<?php if ( count( $payment ) > 0 ): if ( $payment['supplier_id'] == $supplier['id'] ): echo 'selected';endif;endif;?>><?php echo $supplier['name']; ?></option>
											<?php endforeach;?>
										</select>
									</div>
									<div class="form-group">
										<label>Ref. Employee</label>
										<select name="emp_id" id="emp_id" class="form-control select2">
											<?php foreach ( $emps as $emp ): ?>
												<option value="<?php echo $emp['id']; ?>"<?php if ( count( $payment ) > 0 ): if ( $payment['emp_id'] == $emp['id'] ): echo 'selected';endif;endif;?>><?php echo $emp['name']; ?></option>
											<?php endforeach;?>
										</select>
									</div>
								</div>

								<div class="col-md-6">
									<div class="form-group">
										<label>Amount</label>
										<input type="text" name="amount" id="amount" class="form-control" placeholder="00.00" value="<?php if ( count( $payment ) > 0 ): echo $payment['amount'];endif;?>">
									</div>
									<div class="form-group">
										<label>Payment Type</label>
										<select name="payment_type" id="payment_type" class="form-control select2">
											<option value="cash" <?php if ( count( $payment ) > 0 ): if ( $payment['payment_type'] == 'cash' ): echo 'selected';endif;endif;?>>Cash</option>
											<option value="cheque" <?php if ( count( $payment ) > 0 ): if ( $payment['payment_type'] == 'cheque' ): echo 'selected';endif;endif;?>>Cheque</option>
										</select>
									</div>
									<div class="form-group">
										<label>Memo</label>
										<textarea name="memo" id="memo" placeholder="Memo" class="form-control"><?php if ( count( $payment ) > 0 ): echo $payment['memo'];endif;?></textarea>
									</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( $payment ) > 0 ): ?>
							<input type="hidden" name="id" value="<?php echo $payment['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>