<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$errorMessage = $this->session->flashdata('error');
$title = 'Approve this device';

$authorized = $this->session->userdata('device_status');
?>
<div class="ui container" <?php echo $errorMessage ? "" : 'style="padding-top:1%"'; ?>>
<?php if (validation_errors() || $errorMessage) { ?>
	<div class="ui negative message"><i class="close icon"></i><p><?php echo $errorMessage ? $errorMessage : validation_errors(); ?></p></div>
<?php } ?>
	<div class="ui grid center aligned">
		<div class="row">
			<?php if (get_user_data('isAdmin')) { //get_company('isAprrovePin') ?>
				<div class="sixteen wide tablet four wide computer column">
					<div class="ui left aligned segment vertical-center">
						<?php echo form_open("authorized", 'class="ui form" id="approve-form" target="_parent"'); ?>
							<h3 class="ui header center aligned"><?php echo $title; ?></h3>
							<div class="required field">
								<label>Approval Pin</label>
								<div class="ui fluid input">
									<input name="approve_pin" id="approve_pin" type="password" required autocomplete="off" value="<?php echo set_value('approve_pin'); ?>"/>
									<input name="deviceId" id="deviceId" type="hidden" required autocomplete="off" value="<?php echo get_user_data('deviceId'); ?>"/>
									<input name="authorized" id="authorized" type="hidden" required autocomplete="off" value="A"/>
								</div>
							</div>
							<div class="field">
								<button type="submit" name="submit" class="ui teal right labeled icon button fluid">Approve</button>
							</div>
							<div class="field">
								<a href="<?php echo site_url('logout'); ?>"><i class="arrow left icon"></i>Logout</a>
							</div>
						</form>
					</div>
				</div>
			<?php } else {?>
				<div class="sixteen wide tablet six wide computer column">
					<div class="ui left aligned segment vertical-center">
						<div class="field">
							<h3>Only Authorized devices can able to login. Please check with your administrator.</h3>
						</div>
						<div class="field">
							<a href="<?php echo site_url('logout'); ?>"><i class="arrow left icon"></i>Logout</a>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</div>
</div>
<style>
body {
	overflow-y:auto;
}
.vertical-center {
  margin: 0 !important;
  position: absolute !important;
  top: 0 !important;
  -ms-transform: translateY(150%) !important;
  transform: translateY(150%) !important;
}
</style>
