<?php include('header.php');?>

<?php include('sidebar.php');?>

<?php 
 
include('includes/class.usertype.php');

$usertype = new Usertype();

?>

<?php

$maintitle="Hotels Visited";

$page="visited-hotels.php";

$table="tbl_visitors";

$field_id="visitorid";

$mode=$_REQUEST['mode'];

$content_id=$_REQUEST['content_id'];

if(isset($_REQUEST['start'])){

$start=$_REQUEST['start']-1;

}

else {

$start=0;

}

?>

<div class="content-wrapper">

    <!-- Content Header (Page header) -->

    <section class="content-header">

      <h1><?php echo $maintitle;?></h1>

      <ol class="breadcrumb">

        <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> <?php echo AL_DASHBOARD;?></a></li>

        <li class="active"><?php echo $maintitle;?></li>

      </ol>

    </section>



    <!-- Main content -->

    <section class="content">

    <?php

	if($mode=="add" || $mode=="edit"){ 

	    }

		else {

	    ?>

        <?php

		//if(isset($user_id)){

		if($mode=="delete"){

			 $message=$helper->delete($table, array($field_id=>$_REQUEST['contentid']));

		}

		?>

          <?php

		if($mode=="approve"){
			$helper->update($table, array("status"=>1),array($field_id=>$_REQUEST['contentid']), array());
                        $helper->approveemail($_REQUEST['contentid'],$table);

		}

		?>

         <?php

		if($mode=="pending"){

			$helper->update($table, array("status"=>2),array($field_id=>$_REQUEST['contentid']), array());

		}

		//}

		?>

        <div class="row">

        <div class="col-xs-12">

          <div class="box">

            <div class="box-header">

              <i class="fa fa-building-o"></i>



              <h3 class="box-title"><?php echo $maintitle;?></h3>



              <div class="box-tools pull-right" data-toggle="tooltip" title="">

                <div class="btn-group">


                </div>

              </div>

            </div>

                      <?php
                       
                      $listtypes=$helper->visitedhotels($table,"*",array("userid"=>$content_id),$start,$limit,array("visitorid"=>"DESC"));
                       
                     /* if($_REQUEST['plan']==2){
                         
                       $listtypes=$helper->selectlimit($table,"*",array("plan"=>2),$start,$limit,array("int_user_id"=>"DESC"));	
                      }
                       elseif($_REQUEST['status']==0){
                         
                       $listtypes=$helper->selectlimit($table,"*",array("status"=>0),$start,$limit,array("int_user_id"=>"DESC"));	
                      }
                       elseif($_REQUEST['plan']==1 && $_REQUEST['status']==1){
                         
                       $listtypes=$helper->selectlimit($table,"*",array("plan"=>1,"status"=>1),$start,$limit,array("int_user_id"=>"DESC"));	
                      }
                      elseif($_REQUEST['expire']==1){
                       $listtypes=$helper->selectexpireusers($table,"*",array(),$start,$limit,array("int_user_id"=>"DESC"));
                      }
                      elseif($_REQUEST['expire']==30){
                       $listtypes=$helper->selectexpireusersin30days($table,"*",array(),$start,$limit,array("int_user_id"=>"DESC"));
                      }
                      else {                          
			$listtypes=$helper->selectlimit($table,"*",array(),$start,$limit,array("int_user_id"=>"DESC"));	
                      }*/

			?>

            <!-- /.box-header -->

            <div class="box-body table-responsive no-padding">

            <?php

			if($message!=""){

			?>

            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message['message'];?></button>

			<?php	

			}

			?>

              <table class="table table-hover">

                <tr>
                  <th>Hotel ID</th>
                  <th>Date</th>
                  <th>Visited Hotel</th>
                  <th>Ip Address</th>
                </tr>

                <?php

				$i=($start*$limit)+1;

				foreach($listtypes as $type){

				?>

                <tr>
                  <td><?php echo $type['hotelid'];?></td>
                  <td><?php echo $type['visitdate'];?></td> 
                  <td><a href="<?php echo $type['pageurl'];?>" target="_blank"><?php echo $type['hotelname'];?></a></td>
                  <td><?php echo $type['ipaddress'];?></td>
                  <?php

				  if($_REQUEST['start']>0){

					  $limitpage=$_REQUEST['start'];

				  }

				  else {

					  $limitpage=1;

				  }

				  ?>


                  <td> 

                  

                   

                </tr>

               

                <?php

				$i=$i+1;

				}

				?>

                

                

              </table>

              <?php
                     
			  $counter_list= $helper->countofdata($table,array("salesid"=>$userdetails[0]['staffid']),$limit,array("status"=>"ASC"));
			  include('pagination/pagination.php');
                       
			  ?>

            </div>

            <!-- /.box-body -->

          </div>

          <!-- /.box -->

        </div>

      </div>

      <?php

		}

		?>



    </section>

    <!-- /.content -->

  </div>

<?php include('footer.php');  ?>