<?php include_once('../header.php');
if(!check_login()){
	header("Location: " . WEB_URL . "logout.php");
	die();
}
?>
<?php
include_once(ROOT_PATH.'language/'.$lang_code_global.'/lang_visitor_list.php');
$delinfo = 'none';
$addinfo = 'none';
$msg = "";
if(isset($_GET['id']) && $_GET['id'] != '' && $_GET['id'] > 0){
	$sqlx= "DELETE FROM `tbl_visitor` WHERE vid = ".$_GET['id'];
	mysqli_query($link,$sqlx); 
	$delinfo = 'block';
}
if(isset($_GET['m']) && $_GET['m'] == 'add'){
	$addinfo = 'block';
	$msg = $_data['text_15'];
}
if(isset($_GET['m']) && $_GET['m'] == 'up'){
	$addinfo = 'block';
	$msg = $_data['text_17'];
}
?>
<!-- Content Header (Page header) -->

<section class="content-header">
  <h1><?= $_data['text_1_1'];?></h1>
  <ol class="breadcrumb">
    <li><a href="<?= WEB_URL?>dashboard.php"><i class="fa fa-dashboard"></i><?= $_data['home_breadcam'];?></a></li>
	<li class="active"><?= $_data['text_2'];?></li>
    <li class="active"><?= $_data['text_1_1'];?></li>
  </ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Full Width boxes (Stat box) -->
<div class="row">
  <div class="col-xs-12">
    <div id="me" class="alert alert-danger alert-dismissable" style="display:<?= $delinfo; ?>">
      <button aria-hidden="true" data-dismiss="alert" class="close" type="button"><i class="fa fa-close"></i></button>
      <h4><i class="icon fa fa-ban"></i> <?= $_data['delete_text'];?> !</h4>
      <?= $_data['text_18'];?> </div>
    <div id="you" class="alert alert-success alert-dismissable" style="display:<?= $addinfo; ?>">
      <button aria-hidden="true" data-dismiss="alert" class="close" type="button"><i class="fa fa-close"></i></button>
      <h4><i class="icon fa fa-check"></i> <?= $_data['success'];?> !</h4>
      <?= $msg; ?> </div>
    <div align="right" style="margin-bottom:1%;"> <a class="btn btn-success" data-toggle="tooltip" href="<?= WEB_URL; ?>visitor/addvisitor.php" data-original-title="<?= $_data['text_3'];?>"><i class="fa fa-plus"></i></a> <a class="btn btn-success" data-toggle="tooltip" href="<?= WEB_URL; ?>dashboard.php" data-original-title="<?= $_data['home_breadcam'];?>"><i class="fa fa-dashboard"></i></a> </div>
    <div class="box box-success">
      <div class="box-header">
        <h3 class="box-title"><?= $_data['text_1_1'];?></h3>
      </div>
      <!-- /.box-header -->
      <div class="box-body">
        <table class="table sakotable table-bordered table-striped dt-responsive">
          <thead>
            <tr>
              <th><?= $_data['text_5'];?></th>
              <th><?= $_data['text_6'];?></th>
              <th><?= $_data['text_7'];?></th>
              <th><?= $_data['text_8'];?></th>
              <th><?= $_data['text_9'];?></th>
              <th><?= $_data['text_11'];?></th>
              <th><?= $_data['text_13'];?></th>
              <th><?= $_data['text_14'];?></th>
			  <th>&nbsp;</th>
            </tr>
          </thead>
          <tbody>
            <?php
				$result = mysqli_query($link,"Select *,fr.b_name,u.unit_no from tbl_visitor v inner join blocks fr on fr.bid = v.floor_id inner join units u on u.uid = v.unit_id where v.branch_id = " . (int)$_SESSION['objLogin']['branch_id'] . " order by v.vid desc");
				while($row = mysqli_fetch_array($result)){?>
            <tr>
              <td><?= $row['issue_date']; ?></td>
              <td><?= $row['name']; ?></td>
              <td><?= $row['mobile']; ?></td>
              <td><?= $row['address']; ?></td>
              <td><?= $row['b_name']; ?></td>
              <td><label class="label label-warning ams_label"><?= $row['unit_no']; ?></label></td>
              <td><label class="label label-success ams_label"><?= $row['intime']; ?></label></td>
              <td><label class="label label-danger ams_label"><?= $row['outtime']; ?></label></td>
              <td><a class="btn btn-warning ams_btn_special" data-toggle="tooltip" href="<?= WEB_URL;?>visitor/addvisitor.php?id=<?= $row['vid']; ?>" data-original-title="<?= $_data['edit_text'];?>"><i class="fa fa-pencil"></i></a> <a class="btn btn-danger ams_btn_special" data-toggle="tooltip" onclick="deleteFloor(<?= $row['vid']; ?>);" href="javascript:;" data-original-title="<?= $_data['delete_text'];?>"><i class="fa fa-trash-o"></i></a> </td>
            </tr>
            <?php } mysqli_close($link);$link = NULL; ?>
          </tbody>
        </table>
      </div>
      <!-- /.box-body -->
    </div>
    <!-- /.box -->
  </div>
  <!-- /.col -->
</div>
<!-- /.row -->
<script type="text/javascript">
  function deleteFloor(Id){
    let myFunct = function(){
      window.location = '<?= WEB_URL; ?>visitor/visitorlist.php?id=' + Id;
    }
    sweetConfirmDelete(myFunct);  
  }
  
  $( document ).ready(function() {
	setTimeout(function() {
		  $("#me").hide(300);
		  $("#you").hide(300);
	}, 3000);
});
</script>
<?php include_once('../footer.php'); ?>
