<?php 
include("../includes/config.php");
include("../includes/function.php");
include("../includes/session.php");

$session = new Session();
$database = new Database();

$adminUserId = $session->get('userAdminID');
$adminEventId = $session->get('cmsEventId');
$getUserDetails = $database->getRecord("manage_users", "num='".$adminUserId."'");
$getEventDetails = $database->getRecord("manage_events", "num='".$adminEventId."'");
if($getUserDetails['role']=="4") {
$viewAttendees = $database->getRecords("manage_users", "org_id='".$adminUserId."' AND event_id='".$adminEventId."' AND role='1'", "created_on ASC");
} else {
    $viewAttendees = $database->getRecords("manage_users", "role='1'", "created_on ASC");
}


include("includes/header.php");
?>
    <body class="top-navbar-fixed">
        <div class="main-wrapper">

            <?php echo include("includes/menu.php");?>

            <!-- ========== WRAPPER FOR BOTH SIDEBARS & MAIN CONTENT ========== -->
            <div class="content-wrapper">
                <div class="content-container">

                    <?php include("includes/sidebar.php");?>
                    <div class="main-page">
                        <div class="container-fluid">
                            <div class="row page-title-div">
                                <div class="col-md-6">
                                    <h4 class="title">View Exhibitors</h4>
                                    <p class="sub-title">One stop solution for perfect admin dashboard!</p>
                                </div>
                                
                            </div>
                            <!-- /.row -->
                            <div class="row breadcrumb-div">
                                <div class="col-md-6">
                                    <ul class="breadcrumb">
            							<li><a href="<?php echo CMS_ROOT;?>dashboard.php"><i class="fa fa-home"></i> Home</a></li>
            							<li class="active">Exhibitors</li>
            						</ul>
                                </div>
                                
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- /.container-fluid -->

                        <section class="section pt-10">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-md-12">
                                    <table id="example" class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                        <tr>
                                                            <th>Name</th>
                                                            <th>Position</th>
                                                            <th>Company</th>
                                                            <th>Email</th>
                                                            <th>Country</th>
                                                            <th>Status</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php foreach($viewAttendees as $record):
                                                        $manageStatus = $database->getRecord("manage_user_status", "user_id='".$record['num']."'");?>
                                                        <tr>
                                                            <td><?php echo $record['first_name']." ".$record['last_name'];?></td>
                                                            <td><?php echo $record['job_title'];?></td>
                                                            <td><?php echo $record['company_name'];?></td>
                                                            <td><?php echo $record['email'];?></td>
                                                            <td><?php echo $record['country'];?></td>
                                                            <td><?php if($manageStatus['active']=="1") {?><button type="button" data-id="status-<?php echo $record['num'];?>-ex-0" class="btn btn-success status_urlaa icon-only"><i class="fa fa-check-square-o"></i></button><?php } else { ?><button type="button" data-id="status-<?php echo $record['num'];?>-ex-1" class="btn btn-danger status_urlaa icon-only"><i class="fa fa-remove"></i></button><?php } ?></td>
                                                        </tr>
                                                        <?php endforeach;?>
                                                    </tbody>
                                                </table>
                                                </div>
                                </div>
                                <!-- /.row -->
                            </div>
                            <!-- /.container-fluid -->
                        </section>
                        <!-- /.section -->

                        
                    </div>
                    <!-- /.main-page -->

                </div>
                <!-- /.content-container -->
            </div>
            <!-- /.content-wrapper -->

        </div>
        <!-- /.main-wrapper -->

        <!-- ========== COMMON JS FILES ========== -->
        <script src="<?php echo CMS_ROOT;?>js/jquery/jquery-2.2.4.min.js"></script>
        <script src="<?php echo CMS_ROOT;?>js/bootstrap/bootstrap.min.js"></script>
        <script src="<?php echo CMS_ROOT;?>js/pace/pace.min.js"></script>
        <script src="<?php echo CMS_ROOT;?>js/lobipanel/lobipanel.min.js"></script>
        <script src="<?php echo CMS_ROOT;?>js/iscroll/iscroll.js"></script>

        <!-- ========== PAGE JS FILES ========== -->
        <script src="<?php echo CMS_ROOT;?>js/prism/prism.js"></script>
        <script src="<?php echo CMS_ROOT;?>js/DataTables/datatables.min.js"></script>

        <!-- ========== THEME JS ========== -->
        <script src="<?php echo CMS_ROOT;?>js/main.js"></script>
        <script>
            $(function($) {
                
                $("#add_update_recorda").submit(function() {
                    var dataString = $(this).serialize();
                   $.ajax({
                    type: "POST",
                    url: "/includes/process.php",
                    async: true,
        			contentType: false,
            	    cache: false,
        			processData:false,
                    data: new FormData(this),
                    success: function(data){
                        if(data=="1") {
                            $(".modal-body").append("<div style='color:#fff; background:#5ECFB1; padding:5px;'>Data updated successfully</div>");
                        }
                    }
                  }); 
                  return false;
                });
                
                $("#close_popup").click(function(){
                   location.reload(); 
                });
                
                $(".close").click(function(){
                   location.reload(); 
                });
                
                $(".status_urlaa").click(function() {
                   var recordId = $(this).attr("data-id");
                    var dataString = "recordId="+recordId+"&tablename=manage_user_status&action=ajaxRecord";
                    if (confirm("OK to submit?")) {
                        $.ajax({
                            type: "POST",
                            url: "/includes/process.php",
                            data: dataString,
                            success: function(data){
                                location.reload();
                                $(this).parent().parent().hide();
                            }
                          }); 
                    }
                });
                $('#example').DataTable();
            });
        </script>

        <!-- ========== ADD custom.js FILE BELOW WITH YOUR CHANGES ========== -->
    </body>
</html>
