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

						<div class="card-body">
							<div class="row">
								<div class="col-md-6">
									<div class="form-group">
										<label>Money Receipt No</label>
										<input type="text" name="mr_no" id="mr_no" class="form-control" value="<?php if ( count( $mr ) > 0 ): echo $mr['mr_no'];else:echo $mr_no;endif;?>">
									</div>
									<div class="form-group">
										<label for="mr-date">Money Receipt Date</label>
										<div class="input-group date datepicker" id="mr-date" data-target-input="nearest">
											<input type="text" name="mr_date" class="form-control" data-target="#mr-date" value="<?php if ( count( $mr ) > 0 ): echo date_to_ui( $mr['mr_date'] );else:echo date( 'd/m/Y' );endif;?>" />
											<div class="input-group-append" data-target="#mr-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 Customer</label>
										<select name="customer_id" id="customer_id" class="form-control select2">
											<?php foreach ( $customers as $customer ): ?>
												<option value="<?php echo $customer['id']; ?>"<?php if ( count( $mr ) > 0 ): if ( $mr['customer_id'] == $customer['id'] ): echo 'selected';endif;endif;?>><?php echo $customer['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( $mr ) > 0 ): if ( $mr['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( $mr ) > 0 ): echo $mr['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( $mr ) > 0 ): if ( $mr['payment_type'] == 'cash' ): echo 'selected';endif;endif;?>>Cash</option>
											<option value="cheque" <?php if ( count( $mr ) > 0 ): if ( $mr['payment_type'] == 'cheque' ): echo 'selected';endif;endif;?>>Cheque
											</option>
										</select>
									</div>
									<div class="form-group">
										<label>Memo</label>
										<textarea name="memo" id="memo" class="form-control" placeholder="Memo"><?php if ( count( $mr ) > 0 ): echo $mr['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( $mr ) > 0 ): ?>
							<input type="hidden" name="id" value="<?php echo $mr['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>