<?php $this->load->view('header');?>

	<!-- BEGIN CONTENT -->
	<ul class="nav nav-tabs" id="myTab" role="tablist">
		<li class="nav-item">
			<a class="nav-link <?php echo (($this->uri->segment(2) == 'index' && $this->uri->segment(3) == 'claim') ? '': 'active');?>" id="tab1-tab" data-toggle="tab" href="#tab1" role="tab" aria-controls="tab1" aria-selected="true"><?php echo $this->lang->line('hf_buy_insurance_history');?></a>
		</li>
		<li class="nav-item">
			<a class="nav-link" id="tab2-tab" data-toggle="tab" href="#tab2" role="tab" aria-controls="tab2" aria-selected="false"><?php echo $this->lang->line('hf_claim_insurance');?></a>
		</li>
		<li class="nav-item">
			<a class="nav-link <?php echo (($this->uri->segment(2) == 'index' && $this->uri->segment(3) == 'claim') ? 'active': '');?>" id="tab3-tab" data-toggle="tab" href="#tab3" role="tab" aria-controls="tab3" aria-selected="false"><?php echo $this->lang->line('hf_claim_insurance_history');?></a>
		</li>
	</ul>
	<div class="tab-content" id="myTabContent">
		<div class="tab-pane fade <?php echo (($this->uri->segment(2) == 'index' && $this->uri->segment(3) == 'claim') ? '': 'show active');?>" id="tab1" role="tabpanel" aria-labelledby="tab1-tab">
			<div class="row no-gutters">
				<div class="col-12 bg-red rounded-lg rounded-top-0 p-3">
					<div class="row no-gutters">
						<div class="col-12 rounded-lg border-dark-blue bg-red p-3 text-white">
							<div class="d-flex justify-content-center mb-3">
								<h2><?php echo $this->lang->line('hf_buy_insurance_history');?></h2>
							</div>
							<?php 
							if($buy_list['query']->num_rows() > 0) {
								$i = 1;
								foreach($buy_list['query']->result() as $row) {
									$border = (($buy_list['query']->num_rows() > $i) ? 'border-bottom' : '');
							?>
							<div class="row no-gutters col-12 p-3 <?php echo $border;?>">
								<div class="col-6 text-left">
									<?php echo $this->lang->line('insurance_date');?>: <?php echo $row->insurance_date;?><br />
								</div>
								<div class="col-6 text-right">
									<?php echo $this->lang->line('insurance_amount');?> (<?php echo $this->lang->line('wallet_3');?>): <span class="-danger">-<?php echo number_format($row->credit_amount, 2, '.', ',');?></span><br />
									<?php echo $this->lang->line('insurance_status');?>: <?php echo (($row->status == 1) ? '<span class="badge badge-success">' . $this->lang->line('insurance_confirmed') . '</span>' : (($row->status == 2) ? '<span class="badge badge-danger">' . $this->lang->line('insurance_cancelled') . '</span>' : '<span class="badge badge-primary">' . $this->lang->line('insurance_pending') . '</span>'));?>
								</div>
							</div>
							<?php $i++; } } else {?>
							<div class="row no-gutters col-12 p-3">
								<div class="col-12 text-center"><?php echo $this->lang->line('message_no_data_found');?></div>
							</div>
							<?php }?>
							<div class="row no-gutters col-12 p-3">
								<div class="col-12 text-center pagination"><?php echo $buy_list['buy_list_pagination'];?></div>
							</div>
						</div>
					</div>
				</div>	
			</div>
		</div>
		<div class="tab-pane fade" id="tab2" role="tabpanel" aria-labelledby="tab2-tab">
			<div class="row no-gutters">
				<div class="col-12 bg-red rounded-lg rounded-top-0 p-3">
					<div class="row no-gutters">
						<div class="col-12 rounded-lg border-dark-blue bg-red p-3 text-white">
							<div class="d-flex justify-content-center mb-3">
								<h2><?php echo $this->lang->line('hf_claim_insurance');?></h2>
							</div>
							<div class="row">
								<div class="col-12">
									<p class="m-0"><?php echo $this->lang->line('insurance_notice');?></p>
								</div>
							</div>
							<!-- form -->
							<form id="insurance-form" enctype="multipart/form-data">
								<div class="form-group row pt-5">
									<label for="transaction_amount" class="col-sm-3 col-form-label"><?php echo $this->lang->line('insurance_claim_picture');?> 1</label>
									<div class="col-sm-9">
										<input type="file" class="form-control-file" id="claim_slip_1" name="claim_slip_1">
									</div>
								</div>
								<div class="form-group row pt-2">
									<label for="transaction_amount" class="col-sm-3 col-form-label"><?php echo $this->lang->line('insurance_claim_picture');?> 2</label>
									<div class="col-sm-9">
										<input type="file" class="form-control-file" id="claim_slip_2" name="claim_slip_2">
									</div>
								</div>
								<div class="form-group row pt-2">
									<label for="transaction_amount" class="col-sm-3 col-form-label"><?php echo $this->lang->line('insurance_claim_picture');?> 3</label>
									<div class="col-sm-9">
										<input type="file" class="form-control-file" id="claim_slip_3" name="claim_slip_3">
									</div>
								</div>
								<div class="form-group row pt-2">
									<label for="transaction_amount" class="col-sm-3 col-form-label"><?php echo $this->lang->line('insurance_claim_picture');?> 4</label>
									<div class="col-sm-9">
										<input type="file" class="form-control-file" id="claim_slip_4" name="claim_slip_4">
									</div>
								</div>
								<div class="form-group row pt-2">
									<label for="transaction_amount" class="col-sm-3 col-form-label"><?php echo $this->lang->line('insurance_claim_picture');?> 5</label>
									<div class="col-sm-9">
										<input type="file" class="form-control-file" id="claim_slip_5" name="claim_slip_5">
									</div>
								</div>
								<div class="form-group row pt-2">
									<label for="remark" class="col-sm-3 col-form-label"><?php echo $this->lang->line('insurance_remark');?></label>
									<div class="col-sm-9">
										<input type="text" class="form-control" id="remark" name="remark" placeholder="<?php echo $this->lang->line('insurance_remark_fill_in_message');?>">
									</div>
								</div>
								<div class="form-group row pt-2">
									<label for="security_password" class="col-sm-3 col-form-label"><?php echo $this->lang->line('insurance_security_password');?></label>
									<div class="col-sm-9">
										<input type="password" class="form-control" id="security_password" name="security_password" placeholder="<?php echo $this->lang->line('insurance_security_password_must_fill_in_message');?>">
									</div>
								</div>
								
								<div class="row pt-3">
									<div class="col-sm-4">&nbsp;</div>
									<div class="col-sm-4">
										<input type="hidden" id="<?php echo $this->security->get_csrf_token_name(); ?>" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />
										<button onclick="claim_insurance_submit()" type="button" class="col-12 btn btn-primary"><?php echo $this->lang->line('insurance_claim');?></button>
									</div>
									<div class="col-sm-4">&nbsp;</div>
								</div>
							</form>
						</div>
					</div>
				</div>	
			</div>
		</div>
		<div class="tab-pane fade <?php echo (($this->uri->segment(2) == 'index' && $this->uri->segment(3) == 'claim') ? 'show active': '');?>" id="tab3" role="tabpanel" aria-labelledby="tab3-tab">
			<div class="row no-gutters">
				<div class="col-12 bg-red rounded-lg rounded-top-0 p-3">
					<div class="row no-gutters">
						<div class="col-12 rounded-lg border-dark-blue bg-red p-3 text-white">
							<div class="d-flex justify-content-center mb-3">
								<h2><?php echo $this->lang->line('hf_claim_insurance_history');?></h2>
							</div>
							<?php 
							if($claim_list['query']->num_rows() > 0) {
								$i = 1;
								foreach($claim_list['query']->result() as $row) {
									$border = (($claim_list['query']->num_rows() > $i) ? 'border-bottom' : '');
									
									$claim_slip = '';
									$claim_slip .= ($row->claim_slip_1 != '') ? '<a href="' . base_url() . 'uploads/claims/' . $row->claim_slip_1 . '" target="_blank"><img src="' . base_url() . 'uploads/claims/' . $row->claim_slip_1 . '" border="0" width="36" /></a> &nbsp; ' : '';
									$claim_slip .= ($row->claim_slip_2 != '') ? '<a href="' . base_url() . 'uploads/claims/' . $row->claim_slip_2 . '" target="_blank"><img src="' . base_url() . 'uploads/claims/' . $row->claim_slip_2 . '" border="0" width="36" /></a> &nbsp; ' : '';
									$claim_slip .= ($row->claim_slip_3 != '') ? '<a href="' . base_url() . 'uploads/claims/' . $row->claim_slip_3 . '" target="_blank"><img src="' . base_url() . 'uploads/claims/' . $row->claim_slip_3 . '" border="0" width="36" /></a> &nbsp; ' : '';
									$claim_slip .= ($row->claim_slip_4 != '') ? '<a href="' . base_url() . 'uploads/claims/' . $row->claim_slip_4 . '" target="_blank"><img src="' . base_url() . 'uploads/claims/' . $row->claim_slip_4 . '" border="0" width="36" /></a> &nbsp; ' : '';
									$claim_slip .= ($row->claim_slip_5 != '') ? '<a href="' . base_url() . 'uploads/claims/' . $row->claim_slip_5 . '" target="_blank"><img src="' . base_url() . 'uploads/claims/' . $row->claim_slip_5 . '" border="0" width="36" /></a>' : '';
							?>
							<div class="row no-gutters col-12 p-3 <?php echo $border;?>">
								<div class="col-6 text-left">
									<?php echo $this->lang->line('insurance_date');?>: <?php echo date('Y-m-d H:i:s', $row->transaction_date);?><br />
									<?php echo $this->lang->line('insurance_claim_picture');?>: <?php echo $claim_slip;?><br />
									<?php echo $this->lang->line('insurance_remark');?>: <?php echo (($row->remark != '') ? $row->remark : '-');?><br />
								</div>
								<div class="col-6 text-right">
									<?php echo $this->lang->line('insurance_claim_amount');?>: <span class="-<?php echo (($row->status == 1) ? 'success' : (($row->status == 2) ? 'danger' : 'primary'));?>"><?php echo (($row->status == 1) ? '+' . number_format($row->claim_amount, 2, '.', ',') : number_format($row->claim_amount, 2, '.', ','));?></span><br />
									<?php echo $this->lang->line('insurance_status');?>: <?php echo (($row->status == 1) ? '<span class="badge badge-success">' . $this->lang->line('insurance_confirmed') . '</span>' : (($row->status == 2) ? '<span class="badge badge-danger">' . $this->lang->line('insurance_cancelled') . '</span>' : '<span class="badge badge-primary">' . $this->lang->line('insurance_pending') . '</span>'));?>
								</div>
							</div>
							<?php $i++; } } else {?>
							<div class="row no-gutters col-12 p-3">
								<div class="col-12 text-center"><?php echo $this->lang->line('message_no_data_found');?></div>
							</div>
							<?php }?>
							<div class="row no-gutters col-12 p-3">
								<div class="col-12 text-center pagination"><?php echo $claim_list['claim_list_pagination'];?></div>
							</div>
						</div>
					</div>
				</div>	
			</div>
		</div>
	</div>

	<div class="py-4">&nbsp;</div>
	<!-- END CONTENT -->

<?php $this->load->view('footer');?>