<div class="collapse" id="collapseRecurring">
	<div class="card">
		<div class="card-header text-center" role="tablist">
			<div class="nav nav-tabs nav-fill card-header-tabs">
				<a class="nav-item nav-link active" data-toggle="tab" href="#nav-pay" role="tab" aria-selected="false">Recurring Pay</a>
				<a class="nav-item nav-link" data-toggle="tab" href="#nav-deduct" role="tab" aria-selected="false">Recurring Deduct</a>
			</div>
		</div>
		<div class="card-body">
			<div class="tab-content" id="nav-tabContent">
				<div class="tab-pane fade show active" id="nav-pay" role="tabpanel" aria-labelledby="nav-account-tab">
					<h4 class="card-title">Recurring Pay</h4>
					<hr>
					
					<div class="container">
						<?php if ($role == 'admin'): ?>
							<div class="row">
								<div class="btn-group ml-auto">
									<a class="btn btn-info btn-sm" style="margin-bottom:15px; width: 200px;" href="<?php echo base_url('hr/StaffProfile/actionReport/'.$staff_id.'/13'); ?>" target="_blank">
										<i class="fa fa-print"></i> Print
									</a>
								</div>
							</div>
						<?php endif ?>
					</div>
					
					<div class="table-responsive">
						<table id="table_pcb_employee" class="table table-hover table-bordered">
							<thead>
								<tr>
									<th>Action Type</th>
									<th>Type</th>
									<th>Start Date</th>
									<th>End Date</th>
									<th>Amount (RM)</th>
									<th>Status</th>
									<th>Created At</th>
									<!-- <?php if ($role == 'admin'): ?>
									<th>Action</th>
									<?php endif ?> -->
								</tr>
							</thead>
							<tbody>

								<?php if($recurring_payments) foreach ($recurring_payments as $key => $payment): ?>
									
									<tr class="link-row" data-id="">
										<td scope="row">
											<?php echo ($payment->action_type)?$payment->action_type:'N/A'; ?>
											<br>
											<?php echo ($payment->action_efective_date)?date('d-F-Y',strtotime($payment->action_efective_date)):'N/A'; ?>
										</td>
										<td><?php echo $payment->type; ?></td>
										<td><?php echo mysql_to_date_format((!empty($payment->date_start))?$payment->date_start:null); ?></td>
										<td><?php echo mysql_to_date_format((!empty($payment->date_end))?$payment->date_end:null); ?></td>
										<td><?php echo number_format($payment->amount,2); ?></td>
										<td><?php echo ($payment->status == 0)?'Ongoing':'End'; ?></td>
										<td><?php echo $payment->created_at; ?></td>
										<?php if ($role == 'admin'): ?>
										<!-- <td class="text-center">
											<div class="btn-group">
												<button onclick="btnEditRecurringPayment(this)" class="btn btn-success btn-sm" data-content="<?php //echo base64_encode(json_encode($payment)); ?>" data-toggle="modal" data-target="#recurringPayModal"><i class="fas fa-edit"></i></button>
												<button onclick="btnRemovePayment(<?php //echo $payment->id; ?>)" class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></button>
											</div>
										</td> -->
										<?php endif ?>
										
									</tr>
								<?php endforeach ?>

							</tbody>
						</table>
					</div>
				</div>
				<div class="tab-pane fade" id="nav-deduct" role="tabpanel" aria-labelledby="nav-audit-tab">
					<h4 class="card-title">Recurring Deduct</h4>
					<hr>
					
					<div class="container">

						<?php if ($role == 'admin'): ?>
							<div class="row">
								<div class="btn-group ml-auto">
									<a class="btn btn-info btn-sm" style="margin-bottom:15px; width: 200px;" href="<?php echo base_url('hr/StaffProfile/actionReport/'.$staff_id.'/14'); ?>" target="_blank">
										<i class="fa fa-print"></i> Print
									</a>
								</div>
							</div>
						<?php endif ?>

					</div>
				
					<div class="table-responsive">
						<table class="table table-hover table-bordered">
							<thead>
								<tr>
									<th>Action Type</th>
									<th>Type</th>
									<th>Start Date</th>
									<th>End Date</th>
									<th>Amount (RM)</th>
									<th>Status</th>
									<th>Created At</th>
									<!-- <?php if ($role == 'admin'): ?>
									<th>Action</th>
									<?php endif ?> -->
									
								</tr>
							</thead>
							<tbody>
								
								<?php if($recurring_deductions) foreach ($recurring_deductions as $key => $deduct): ?>
									
								<tr class="link-row" data-id="">
									<td scope="row">
										<?php echo ($deduct->action_type)?$deduct->action_type:'N/A';?>
										<br>
										<?php echo ($deduct->action_efective_date)?date('d-F-Y',strtotime($deduct->action_efective_date)):'N/A'; ?>
									</td>
									<td><?php echo $deduct->type;?></td>
									<!-- <td><?php echo $deduct->date_start; ?></td>
									<td><?php echo $deduct->date_end; ?></td> -->
									<td><?php echo mysql_to_date_format((!empty($deduct->date_start))?$deduct->date_start:null); ?></td>
									<td><?php echo mysql_to_date_format((!empty($deduct->date_end))?$deduct->date_end:null); ?></td>
									<td><?php echo number_format($deduct->amount,2); ?></td>
									<td><?php echo ($deduct->status == '0')?'Ongoing':'End'; ?></td>
									<td><?php echo $payment->created_at; ?></td>
									<?php if ($role == 'admin'): ?>
									<!-- <td class="text-center">
										<div class="btn-group">
											<button onclick="btnEditRecurringDeduction(this)" class="btn btn-success btn-sm" data-content="<?php //echo base64_encode(json_encode($deduct)); ?>" data-toggle="modal" data-target="#recurringDeductModal"><i class="fas fa-edit"></i></button>
											<button onclick="btnRemoveDeduction(<?php //echo $deduct->id; ?>)" class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></button>
										</div>
									</td> -->
									<?php endif ?>
								</tr>

								<?php endforeach ?>

							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div><br>
</div>

<div class="modal fade" id="recurringDeductModal">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title">Edit Recurring Deduct</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<form action="<?php echo base_url('/hr/StaffProfile/createRecurringDeduct/'.$staff_id); ?>" method="POST" class="form-horizontal" enctype="multipart/form-data" id="mdl-recurring-deduct-form">
				<div class="modal-body">
					<input type="hidden" class="form-control" name="id" id="mdl-recurring-deduct-id">
					<div class="row">
						<div class="col">
							<label>Date From</label>
							<input type="text" class="datepicker form-control" placeholder="dd-mm-YYYY" name="date_start" autocomplete="off" id="mdl-recurring-deduct-date_start">
						</div>
						<div class="col">
							<label>Date To</label>
							<input type="text" class="datepicker form-control" placeholder="dd-mm-YYYY" name="date_end" autocomplete="off" id="mdl-recurring-deduct-date_end">
						</div>
					</div>

					<div class="form-group">
						<label>Deduct Type</label>
						<input type="text" class=" form-control" placeholder="Enter Deduct Type" name="type" id="mdl-recurring-deduct-type">
					</div>	
					
					<div class="form-group">
						<label>Amount</label>
						<div class="input-group">
						  <div class="input-group-prepend">
						    <span class="input-group-text">RM</span>
						  </div>
						  <input type="number" class=" form-control" placeholder="Enter Amount" name="amount" id="mdl-recurring-deduct-amount">
						</div>
					</div>

					<div class="form-group">
						<label>Status</label>
						<select class="form-control" name="status" id="mdl-recurring-deduct-status">
							<option value="0">Ongoing</option>
							<option value="1">End</option>
						</select>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger btn-sm" style="margin-bottom:15px; width: 200px;" data-dismiss="modal"><i class="fa fa-ban"></i> Cancel</button>
					<button type="submit" class="btn btn-success btn-sm" style="margin-bottom:15px; width: 200px;"><i class="fa fa-save"></i> Submit</button>
				</div>
			</form>
		</div>
	</div>
</div>

<div class="modal fade" id="recurringPayModal">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="racks-modal-title">Edit Recurring Pay</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<form action="<?php echo base_url('hr/StaffProfile/createRecurringPay/'.$staff_id); ?>" method="POST" class="form-horizontal" id="mdl-recurring-payment-form">
				<div class="modal-body">

					<input type="hidden" class="form-control" name="id" id="mdl-recurring-payment-id">
					<div class="row">
						<div class="col">
							<label>Date Start</label>
							<input type="text" class="datepicker form-control" placeholder="dd-mm-YYYY" autocomplete="off" name="date_start" id="mdl-recurring-payment-date_start">
						</div>
						<div class="col">
							<label>Date End</label>
							<input type="text" class="datepicker form-control" placeholder="dd-mm-YYYY" autocomplete="off" name="date_end" id="mdl-recurring-payment-date_end">
						</div>
					</div>

					<div class="form-group">
						<label>Pay Type</label>
						<input type="text" class="form-control" placeholder="Enter Pay Type" name="type" id="mdl-recurpay-type">
					</div>	
					
					<div class="form-group">
						<label>Amount</label>
						<div class="input-group">
						  <div class="input-group-prepend">
						    <span class="input-group-text">RM</span>
						  </div>
						  <input type="number" class=" form-control" placeholder="Enter Amount" name="amount" id="mdl-recurpay-amount">
						</div>
					</div>

					<div class="form-group">
						<label>Status</label>
						<select class="form-control" name="status" id="mdl-recurpay-status">
							<option value="0">Ongoing</option>
							<option value="1">End</option>
						</select>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger btn-sm" style="margin-bottom:15px; width: 200px;" data-dismiss="modal"><i class="fa fa-ban"></i> Cancel</button>
					<button type="submit" id="saveButtonBank" class="btn btn-success btn-sm" style="margin-bottom:15px; width: 200px;"><i class="fa fa-save"></i> Submit</button>
				</div>
			</form>
		</div>
	</div>
</div>