<link rel="stylesheet"
	  href="<?= base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
<link rel="stylesheet"
	  href="<?= base_url('<link rel="stylesheet" 
	href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap.min.css">') ?>">
<link rel="stylesheet"
	  href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
<link rel="stylesheet"
	  href="<?= base_url('bower_components/jquery-ui/themes/base/jquery-ui.css') ?>">

<link rel="stylesheet" href="<?= base_url('bower_components/toastr/toastr.css') ?>">
<style>
	#details tr > td:nth-child(even) {
		text-align: center;
	}
</style>
<div class="content-wrapper">
	<section class="content-header">

		<h1 style="margin-bottom: 20px">
			<?= $this->lang->line('customer_account_opening_request'). ' - ' . $request->unique_id; ?>

			<div class="pull-right">
				<?php if(in_array($request->status,['UNDER_VALIDATION','AWAITING_FURTHER_INFORMATION'])) { ?>
					<button id="accept-subscription" class="btn btn-success" >
						<?= $this->lang->line('accept') ?>
					</button>
					<?php if($request->status == 'UNDER_VALIDATION') { ?>
						<button class="btn btn-warning" data-toggle="modal" data-target="#more-information-modal">
							<?= $this->lang->line('more_information') ?>
						</button>
					<?php } ?>
					<button class="btn btn-danger" data-toggle="modal" data-target="#reject-modal">
						<?= $this->lang->line('reject') ?>
					</button>
				<?php } ?>
			</div>
		</h1>

		<?php

		use Brick\Money\Context\AutoContext;
		use Brick\Money\CurrencyConverter;
		use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
		use Brick\Money\ExchangeRateProvider\PDOProvider;
		use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
		use Brick\Money\Money;

		// set to whatever your rates are relative to
		$baseCurrency = 'USD';

		// use your own credentials, or re-use your existing PDO connection
		$pdo = new PDO('mysql:host=' . $this->db->hostname . ';dbname=' . $this->db->database, $this->db->username, $this->db->password);

		$configuration = new PDOProviderConfiguration();

		$configuration->tableName = 'exchange_rate';
		$configuration->exchangeRateColumnName = 'exchange_rate';
		$configuration->targetCurrencyColumnName = 'target_currency';
		$configuration->sourceCurrencyCode = $baseCurrency;

		// this provider loads exchange rates from your database
		$provider = new PDOProvider($pdo, $configuration);

		// this provider calculates exchange rates relative to the base currency
		$provider = new BaseCurrencyProvider($provider, $baseCurrency);

		// this currency converter can now handle any currency pair
		$this->converter = new CurrencyConverter($provider);
		$this->context = new AutoContext();
		$fmt = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);

		$context = new AutoContext();
		?>
	</section>

	<section class="content">

		<div class="row">
			<div class="col-lg-4 col-xs-6">
				<div class="small-box bg-blue-active">
					<div class="inner">
						<h3 style="white-space: pre-wrap; font-size: 1.9em;"><?=$request->customer_account_type_name?> </h3>
						<p>Type </p>
					</div>
					<div class="icon">
						<i class="fa fa-info"></i>
					</div>
				</div>
			</div>

			<div class="col-lg-4 col-xs-6">
				<div class="small-box bg-blue-active">
					<div class="inner">
						<h3 style="white-space: pre-wrap; font-size: 1.9em;"><?= $this->lang->line($request->status)?> </h3>
						<p><?= $this->lang->line('Statut') ?></p>
					</div>
					<div class="icon">
						<i class="fa fa-info"></i>
					</div>
				</div>
			</div>

			<?php if(!empty($request->opening_amount)) { ?>
				<div class="col-lg-4 col-xs-6">
					<div class="small-box bg-blue-active">
						<div class="inner">
							<h3 style="white-space: pre-wrap; font-size: 1.9em;"><?= Money::of(round($request->opening_amount, 2), $request->currency_code ?? 'XAF', $context)->formatTo('fr_FR') ?> </h3>
							<p><?= $this->lang->line('opening_amount') ?></p>
						</div>
						<div class="icon">
							<i class="fa fa-money"></i>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>


		<?php if(in_array($request->status, ['REJECTED','MORE_INFORMATION'])) { ?>
		<div class="row">
			<div class="col-lg-12">
				<div class="small-box bg-blue-active">
					<div class="inner">
						<p style="white-space: pre-wrap;"><?= $request->reject_reason ?> </p>
						<p><?= $this->lang->line('reject_reason') ?></p>
					</div>
					<div class="icon">
						<i class="fa fa-info"></i>
					</div>
				</div>
			</div>
		</div>
		<?php } ?>

		<!-- Personal details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('personal_details') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('title'); ?></td>
							<td align="center"><strong><?= $request->title; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('Nom'); ?></td>
							<td align="center"><strong><?= $request->lastname; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('Prénom'); ?></td>
							<td align="center"><strong><?= $request->firstname; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('spouse_name'); ?></td>
							<td align="center"><strong><?= $request->spouse_name; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('nationality'); ?></td>
							<td align="center"><strong><?= $request->nationality; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('birth_date'); ?> </td>
							<td align="center"><strong><?= $request->birth_date; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('birth_city'); ?></td>
							<td align="center"><strong><?= $request->birth_city; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('birth_country') ?></td>
							<td align="center"><strong><?= $request->birth_country ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>

		<!-- Marital status -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('marital_status') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('marital_status'); ?></td>
							<td align="center"><strong><?= $request->marital_status; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('spouse_lastname'); ?></td>
							<td align="center"><strong><?= $request->spouse_name; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Employment details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('employment_details') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('profession'); ?></td>
							<td align="center"><strong><?= $request->profession; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('business_activity'); ?></td>
							<td align="center"><strong><?= $request->business_activity; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('sub_sector_business_activity'); ?></td>
							<td align="center"><strong><?= $request->sub_sector_business_activity; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('tax_number'); ?></td>
							<td align="center"><strong><?= $request->tax_number; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('security_number'); ?></td>
							<td align="center"><strong><?= $request->security_number; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('employee_number'); ?> </td>
							<td align="center"><strong><?= $request->employee_number; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('function'); ?></td>
							<td align="center"><strong><?= $request->function; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('employee_name') ?></td>
							<td align="center"><strong><?= $request->employee_name ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('employee_address'); ?></td>
							<td align="center"><strong><?= $request->employee_address ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Residential details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('residential_details') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('residential_status'); ?></td>
							<td align="center"><strong><?= $request->residential_status; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('residential_country'); ?></td>
							<td align="center"><strong><?= $request->residential_country; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('residence_permit_number'); ?></td>
							<td align="center"><strong><?= $request->residence_permit_number; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('issued_date'); ?></td>
							<td align="center"><strong><?= $request->residence_permit_issued_date; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('expiry_date'); ?></td>
							<td align="center"><strong><?= $request->residence_permit_expiry_date; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Address details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('Adresse') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('address_justification_doc'); ?></td>
							<td align="center"><strong><?= $request->address_justification_doc; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('geographic_address'); ?></td>
							<td align="center"><strong><?= $request->address; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('po_box'); ?></td>
							<td align="center"><strong><?= $request->po_box; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('phone_number'); ?></td>
							<td align="center"><strong><?= $request->phone_number; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('Email').' 1'; ?> </td>
							<td align="center"><strong><?= $request->email_1; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('Email').' 2'; ?></td>
							<td align="center"><strong><?= $request->email_2; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('person_to_contact_in_case_of_needs_name') ?></td>
							<td align="center"><strong><?= $request->person_to_contact_in_case_of_needs_name ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('phone_number'); ?></td>
							<td align="center"><strong><?= $request->person_to_contact_in_case_of_needs_phone_number ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Identification details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('identification') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('identification_document_type'); ?></td>
							<td align="center"><strong><?= $request->identification_document_type; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('identification_document_number'); ?></td>
							<td align="center"><strong><?= $request->identification_document_number; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('issued_date'); ?></td>
							<td align="center"><strong><?= $request->identification_document_issued_date; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('expiry_date'); ?></td>
							<td align="center"><strong><?= $request->identification_document_expiry_date; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('issuance_city'); ?> </td>
							<td align="center"><strong><?= $request->identification_document_issuance_city; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('issuance_country'); ?></td>
							<td align="center"><strong><?= $request->identification_document_issuance_country; ?></strong></td>
						</tr>

						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Guardianship details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('guardianship') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('customer_under_guardianship'); ?></td>
							<td align="center"><strong><?= $this->lang->line( $request->customer_under_guardianship ? 'Oui' : 'Non'); ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('guardian_fullname'); ?></td>
							<td align="center"><strong><?= $request->guardian_fullname; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('phone_number'); ?></td>
							<td align="center"><strong><?= $request->guardian_fullname_phone_number; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Recommendation details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('recommendation') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('how_did_you_know_company'); ?></td>
							<td align="center"><strong><?= $request->how_did_you_know_company ; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('introducer_fullname'); ?></td>
							<td align="center"><strong><?= $request->introducer_fullname; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('Adresse'); ?></td>
							<td align="center"><strong><?= $request->introducer_address; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Know your customer details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('know_your_customer') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('expected_service'); ?></td>
							<td align="center"><strong><?= $request->expected_service; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('income_sources_and_frequency'); ?></td>
							<td align="center"><strong><?= $request->income_sources_and_frequency; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('business_partners'); ?></td>
							<td align="center"><strong><?= $request->business_partners; ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('bank_references'); ?></td>
							<td align="center"><strong><?= $request->bank_references; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('has_account_with_other_bank'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->has_account_with_other_bank ? 'Oui' : 'Non'); ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('has_operative_other_bank_account'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->has_operative_other_bank_account ? 'Oui' : 'Non'); ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('has_engagement_with_other_banks'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->has_engagement_with_other_banks ? 'Oui' : 'Non'); ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Exposed person details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('exposed_person') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('is_politically_exposed_person'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->is_politically_exposed_person ? 'Oui' : 'Non'); ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('is_politically_exposed_person_in_service'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->is_politically_exposed_person_in_service ? 'Oui' : 'Non'); ?></strong></td>
						</tr>

						</tbody>
					</table>
				</div>
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('has_relationship_with_politically_exposed_person'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->has_relationship_with_politically_exposed_person ? 'Oui' : 'Non'); ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('relationship_with_politically_exposed_person'); ?></td>
							<td align="center"><strong><?= $request->relationship_with_politically_exposed_person; ?></strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<!-- Electronic products details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title"><?= $this->lang->line('electronic_products') ?></h3>
			</div>
			<div class="box-body row" style="overflow-x:auto;">
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('email_alerts'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->email_alerts ? 'Oui' : 'Non'); ?></strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('e_statement_frequency'); ?></td>
							<td align="center"><strong><?= $request->e_statement_frequency ?> </strong></td>
						</tr>
						<tr>
							<td><?= $this->lang->line('e_package'); ?></td>
							<td align="center"><strong><?= $this->lang->line($request->e_package ? 'Oui' : 'Non'); ?></strong></td>
						</tr>

						</tbody>
					</table>
				</div>
				<div class="col-lg-6" style="padding-left: 25px;">
					<table style="width: 100%">
						<colgroup>
							<col span="1" style="width: 30%;">
							<col span="1" style="width: 70%;">
						</colgroup>
						<thead>
						<tr>
							<th></th>
							<th></th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td><?= $this->lang->line('debit_card_type'); ?></td>
							<td align="center"><strong><?= $request->debit_card_type ?> </strong></td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>
		</div>

		<!-- Documents details -->
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title">Documents</h3>
			</div>
			<div class="box-body" style="overflow-x:auto;">
				<table id="documents-table" class="table table-bordered table-hover">
					<thead>
					<tr>
						<th>#</th>
						<th><?= $this->lang->line('Nom') ?></th>
						<th>Description</th>
						<th>Actions</th>
					</tr>
					</thead>
					<tbody>
					<?php
					foreach ($documents as $i => $document) {
						?>
						<tr>
							<td><?= $i + 1 ?></td>
							<td><?= $document->name ?></td>
							<td><?= $document->description ?></td>
							<td>
								<a target='_blank' href="<?= $document->url ?>" class='btn btn-primary btn-block'>
									<b><?= $this->lang->line('display') ?></b>
								</a>
							</td>
						</tr>
						<?php
					}
					?>

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

		<?php $this->load->view('include/loader') ?>
	</section>

	<div class="modal fade" id="reject-modal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title"><?= $this->lang->line('reject_subscription_account_opening_request') ?></h4>
				</div>
				<div class="modal-body">
					<form id="reject-form">
						<div class="row">
							<div class="col-lg-12">
								<div class="form-group">
									<label class="col-form-label"><?= $this->lang->line('reject_reason'); ?></label>
									<textarea required class="form-control" rows="5" name="reason"></textarea>
								</div>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button class="btn btn-danger pull-left"
							id="reject-subscription"><?= $this->lang->line('Confirmer'); ?></button>
					<button type="button" class="btn btn-default pull-right"
							data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="more-information-modal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title"><?= $this->lang->line('more_information_account_opening_request') ?></h4>
				</div>
				<div class="modal-body">
					<form id="more-information-form">
						<div class="row">
							<div class="col-lg-12">
								<div class="form-group">
									<label class="col-form-label">Message</label>
									<textarea required class="form-control" rows="5" name="message"></textarea>
								</div>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button class="btn btn-danger pull-left"
							id="more-information-subscription"><?= $this->lang->line('Confirmer'); ?></button>
					<button type="button" class="btn btn-default pull-right"
							data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- jQuery 2.2.4 -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>

<!-- Bootstrap 3.3.7 -->
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
<!-- FastClick -->
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
<!-- AdminLTE App -->
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?= base_url('dist/js/demo.js') ?>"></script>

<script src="<?= base_url('bower_components/jquery-ui/jquery-ui.js') ?>"></script>

<script src="<?= base_url('bower_components/moment/min/moment.min.js') ?>"></script>
<script src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
<script src="<?= base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="<?= base_url('dist/js/sweetalert2.js') ?>"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment-with-locales.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.10.20/dataRender/datetime.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.colVis.min.js"></script>

<script type="text/javascript">
	toastr.options.closeButton = true;
	toastr.options.closeMethod = 'fadeOut';
	toastr.options.closeDuration = 5000;
	toastr.options.closeEasing = 'swing';

	const format = "<?=$this->session->userdata('site_lang')?>" === 'french' ? 'fr' : 'en';
	moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date

	$('#documents-table').DataTable();

	$('#accept-subscription').click(function() {
		$.ajax({
			url: '<?= base_url('OpeningAccountAgent/treatRequest/'.$request->id)?>',
			type: 'POST',
			dataType: 'json',
			data: {
				<?php if(isset($category) && $category == 'OPENING_ACCOUNT_AGENT') { ?>
				"nh_validating_agent_id": "<?= $this->session->userdata('agent_i  ?>d') ?>",
				<?php } else { ?>
				"agent_id": "<?= $this->session->userdata('agent_id') ?>",
				<?php } ?>
				"  ?>type" : "ACCEPT"
			},
			success: function (data) {
				// console.log('data',data);
				if(data.status === 200){
					Swal.fire({
						icon: 'success',
						title: "<?= $thi  ?>s->lang->line('opening_account_request_accepted')?>",
						text:"<?= $thi  ?>s->lang->line('informations_updated')?>",
						timer: 3000
					}).then(()=>{
						location.reload();
					});
					// alert("Les informations ont été mises à jour.") ? "" :
				}else{
					toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
				}
			},

			error: function (resultat, statut, error) {
				console.log(resultat + " " + error);
				toastr.error("<?= $thi  ?>s->lang->line('error_message')?>" , "<?= $thi  ?>s->lang->line('request_error')?>");
			}
		});
	});

	$('#reject-subscription').click(function () {
		if ($('#reject-form')[0].checkValidity()) {
			let reason = $("textarea[name=reason]").val();
			if(reason.length > 500 ){
				toastr.warning( "<?= $this->lang->line('reason_rule')?>", "<?= $this->lang->line('management_rule')?>");
			}else{
				$.ajax({
					url: '<?= base_url('OpeningAccountAgent/treatRequest/'.$request->id)?>',
					type: 'POST',
					dataType: 'json',
					data: {
						<?php if(isset($category) && $category == 'OPENING_ACCOUNT_AGENT') { ?>
						"nh_validating_agent_id": "<?= $this->session->userdata('agent_id') ?>",
						<?php } else { ?>
						"agent_id": "<?= $this->session->userdata('agent_id') ?>",
						<?php } ?>
						"reason": reason,
						"type" : "REJECT"
					},
					success: function (data) {
						if (data.status === 200) {
							Swal.fire({
								icon: 'success',
								title: "<?= $this->lang->line('opening_account_request_rejected')?>",
								text: "<?= $this->lang->line('informations_updated')?>",
								timer: 3000
							}).then(() => {
								location.reload();
							});
						} else {
							toastr.error(data.error, "<?= $this->lang->line('request_error')?>");
						}
					},
					error: function (resultat, statut, error) {
						console.log(resultat + " " + error);
						toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
					}
				});
			}
		} else {
			$('#reject-form')[0].reportValidity();
		}
	});

	$('#more-information-subscription').click(function () {
		if ($('#more-information-form')[0].checkValidity()) {
			let message = $("textarea[name=message]").val();
			if(message.length > 500 ){
				toastr.warning( "<?= $this->lang->line('message_rule')?>", "<?= $this->lang->line('management_rule')?>");
			}else{
				$.ajax({
					url: '<?= base_url('OpeningAccountAgent/treatRequest/'.$request->id)?>',
					type: 'POST',
					dataType: 'json',
					data: {
						<?php if(isset($category) && $category == 'OPENING_ACCOUNT_AGENT') { ?>
						"nh_validating_agent_id": "<?= $this->session->userdata('agent_id') ?>",
						<?php } else { ?>
						"agent_id": "<?= $this->session->userdata('agent_id') ?>",
						<?php } ?>
						"reason": message,
						"type" : "MORE_INFORMATION"
					},
					success: function (data) {
						if (data.status === 200) {
							Swal.fire({
								icon: 'success',
								title: "<?= $this->lang->line('opening_account_request_more_information')?>",
								text: "<?= $this->lang->line('informations_updated')?>",
								timer: 3000
							}).then(() => {
								location.reload();
							});
						} else {
							toastr.error(data.error, "<?= $this->lang->line('request_error')?>");
						}
					},
					error: function (resultat, statut, error) {
						console.log(resultat + " " + error);
						toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
					}
				});
			}
		} else {
			$('#more-information-form')[0].reportValidity();
		}
	});
</script>
