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

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

if(!empty($_REQUEST['num'])) {
    $session->set('cmsEventId', $_REQUEST['num']);
} else if(!empty($_REQUEST['org_id'])) {
    $session->set('cmsOrgId', $_REQUEST['org_id']);
}

$cmsOrgId = $session->get('cmsOrgId');

$getUserDetails = $database->getRecord("manage_users", "num='".$session->get('userAdminID')."'");
$getUsers = $database->getRecords("manage_users", "role='4'", "created_on ASC");
$getLobby = $database->getRecords("manage_lobby_images", "1", "created_on ASC");
$getLounge = $database->getRecords("manage_lounge_images", "1", "created_on ASC");
$getAudi = $database->getRecords("manage_auditorium_images", "1", "created_on ASC");
if($getUserDetails['role']=="4") {
$eventDetails = $database->getRecords("manage_events", "user_id='".$session->get('userAdminID')."'", "created_on ASC");
} else {
    if(!empty($_REQUEST['org_id']) && $_REQUEST['org_id']>0) {
        $eventDetails = $database->getRecords("manage_events", "user_id='".$session->get('cmsOrgId')."'", "created_on ASC");
    } else {
        $eventDetails = $database->getRecords("manage_events", "1", "created_on ASC");
    }
}

$formFields = $database->getRecords("manage_reg_form", "1", "num 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">Events</h4>
                                    <p class="sub-title">One stop solution for perfect admin dashboard!</p>
                                </div>
                                
                                <div class="col-md-6" style="text-align:right;">
                                    <ul class="nav navbar-nav navbar-right" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut">
                                        <?php if($getUserDetails['role']=="3") {?>
                                        <li style="margin-right:10px; margin-top:15px;">
                                    <select name="org_id" id="org_id">
                                        <option value="-1">Please Select</option>
                                        <?php foreach($getUsers as $record):
                                        if(($record['num']==$cmsOrgId)) {
                                            $selected = "selected";
                                        } else {
                                            $selected = "";
                                        }
                                        ?>
                                        <option value="<?php echo $record['num'];?>" <?php echo $selected;?>><?php echo $record['company_name'];?></option>
                                        <?php endforeach;?>
                                    </select>
                                    </li>
                                    <?php }?>
                                        <li>
                                    <a href="javascript:void(0);" class="dropdown-toggle bg-primary" data-toggle="modal" data-target="#modal2"><i class="fa fa-plus-circle"></i> Add New</a>
                                    </li>
                                    </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">Events</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 width="200">Event Name</th>
                                                            <th width="200">Event Url</th>
                                                            <th width="250">Logo</th>
                                                            <th width="100">Created On</th>
                                                            <th width="250">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php foreach($eventDetails as $record):
                                                        $getOrgUrl = $database->getRecord("manage_org_baseurl", "user_id='".$record['user_id']."'");
                                        
                                                        ?>
                                                        <tr>
                                                            <td><?php echo $record['event_name'];?></td>
                                                            <td><a href="<?php echo $getOrgUrl['url'].$record['event_uri'];?>/" title="<?php echo $getOrgUrl['url'].$record['event_uri'];?>/" target="_blank"><?php echo $getOrgUrl['url'].$record['event_uri'];?></a></td>
                                                            <td><img src="<?php echo $record['logo'];?>"></td>
                                                            <td><?php echo date("d-m-Y", strtotime($record['created_on']));?></td>
                                                            <td><button type="button" class="btn btn-success icon-only edit-record" data-userid="<?php echo $record['user_id'];?>" data-firstname="<?php echo $record['first_name'];?>" data-lastname="<?php echo $record['last_name'];?>" data-eventname="<?php echo $record['event_name'];?>" data-eventuri="<?php echo $record['event_uri'];?>" data-email="<?php echo $record['email'];?>" data-logo="<?php echo $record['logo'];?>" data-logintitle="<?php echo $record['login_title'];?>" data-loginimage="<?php echo $record['login_image'];?>" data-loginimagetitle="<?php echo $record['login_image_title'];?>" data-loginimagetext="<?php echo $record['login_image_text'];?>" data-videourl="<?php echo $record['video_url'];?>" data-hallimage="<?php echo $record['exibition_hall_img'];?>" data-lobby="<?php echo $record['lobby_id'];?>" data-lounge="<?php echo $record['lounge_id'];?>" data-audi="<?php echo $record['audi_id'];?>" data-primcolor="<?php echo $record['prim_color'];?>" data-seccolor="<?php echo $record['sec_color'];?>" data-formtoptext='<?php echo $record['form_top_text'];?>' data-formbottomtext='<?php echo $record['form_bottom_text'];?>' data-id="<?php echo $record['num'];?>" data-toggle="modal" data-target="#modal2"><i class="fa fa-pencil"></i></button> <button type="button"  onClick="location.href='<?php echo CMS_ROOT;?>events.php?num=<?php echo $record['num'];?>'" class="btn bg-primary-500 icon-only"><i class="fa fa-eye"></i></button> <button type="button" data-id="delete-<?php echo $record['num'];?>" data-type="deleteeventallrecord" class="btn btn-danger del_url icon-only"><i class="fa fa-trash-o"></i></button></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 -->
        
        <!-- Modal -->
        <div class="modal fade event draggable" id="modal2" tabindex="-1" role="dialog" aria-labelledby="modal2Label">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <form name="add_update_record" id="add_update_record" action=""  method="post">
                    <div class="modal-header draggable-handle">
                        <h4 class="modal-title" id="modal2Label"><i class="fa fa-arrows"></i> Add Event <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></h4>
                    </div>
                    <div class="modal-body">
                        
                            <input type="hidden" name="action" value="updateEvents">
                            <input type="hidden" name="tablename" id="tablename" value="manage_events">
                            <input type="hidden" name="record_id" id="recordId">
                            <!-- Nav tabs -->
                        	<ul class="nav nav-tabs" role="tablist">
                        		<li role="presentation" class="active"><a href="#general" aria-controls="general" role="tab" data-toggle="tab">Home</a></li>
                        		<li role="presentation" id="tabhide" style="display:none;"><a href="#registration" aria-controls="registration" role="tab" data-toggle="tab">Registration</a></li>
                        	</ul>
                        	<div class="tab-content bg-white p-15">
                            <div role="tabpanel" class="tab-pane active" id="general">
                            <div class="col-md-6">
                                <?php if($getUserDetails['role']=="3") {?>
                                <div class="form-group">
                            		<label>Organiser</label>
                            		<select id="user_id"  required name="user_id" class="chosen-select no-search-select" style="width:100%;" onClick="this.select()">
                            		    <option value="">Please Select</option>
                            		    <?php foreach($getUsers as $record):
                            		    if($cmsOrgId==$record['num']) {
                            		        $selected = "selected";
                            		    } else {
                            		        $selected = "";
                            		    }
                            		    ?>
                            		    <option value="<?php echo $record['num'];?>" <?php echo $selected;?>><?php echo $record['company_name'];?></option>
                            		    <?php endforeach;?>
                            		</select>
                            	</div>
                            	<?php } else { ?>
                            	<input type="hidden" name="user_id" id="user_id" value="<?php echo $session->get('userAdminID');?>">
                            	<?php } ?>
                                <div class="form-group">
                            		<label>First Name</label>
                            		<input type="text" class="form-control" id="firstName" name="first_name" placeholder="First Name">
                            	</div>
                            	<div class="form-group">
                            		<label>Last Name</label>
                            		<input type="text" class="form-control" id="lastName" name="last_name" placeholder="Last Name">
                            	</div>
                            	<div class="form-group">
                            		<label>Event Name</label>
                            		<input type="text" class="form-control" id="eventName" name="event_name" placeholder="Event Name">
                            	</div>
                            	<div class="form-group">
                            		<label>Event URL</label>
                            		<input type="text" class="form-control" id="eventUri" name="event_uri" placeholder="Event URI">
                            	</div>
                            	<div class="form-group">
                            		<label>Email</label>
                            		<input type="text" class="form-control" id="email" name="email" placeholder="Email">
                            	</div>
                            	<div class="form-group">
                            		<label>Logo</label>
                            		<input type="file" class="form-control" id="logo" name="logo" placeholder="Logo"><br><br>
                            		<img src="" id="logourl" style="width:200px;">
                            	</div>
                            	<div class="form-group">
                            		<label>Login Title</label>
                            		<input type="text" class="form-control" id="loginTitle" name="login_title" placeholder="Login Title">
                            	</div>
                            	<div class="form-group">
                            		<label>Login Image</label>
                            		<input type="file" class="form-control" id="loginImage" name="login_image" placeholder="Login Image"><br><br>
                            		<img src="" id="loginImageurl" style="width:200px;">
                            	</div>
                            	<div class="form-group">
                            		<label>Login Image Title</label>
                            		<input type="text" class="form-control" id="loginImageTitle" name="login_image_title" placeholder="Login Image Title">
                            	</div>
                            	<div class="form-group">
                            		<label>Login Image Text</label>
                            		<input type="text" class="form-control" id="loginImageText" name="login_image_text" placeholder="Login Image Text">
                            	</div>
                            </div>
                        	
                        	<div class="col-md-6">
                            	<div class="form-group">
                            		<label>Video Url</label>
                            		<input type="text" class="form-control" id="videoUrl" name="video_url" placeholder="Video Url">
                            	</div>
                            	<div class="form-group" style="display:none;">
                            		<label>Exibition Hall Image</label>
                            		<input type="file" class="form-control" id="exHallImage" name="exibition_hall_img" placeholder="Login Image"><br><br>
                            		<img src="" id="exHallImageurl" style="width:200px;">
                            	</div>
                            	<div class="form-group">
                            		<label>Select Lobby</label>
                            		<!--<select id="lobby_id" name="lobby_id" class="chosen-select showimg no-search-select" style="width:100%; margin-bottom:10px;" onClick="this.select()">
                            		    <option value="">Please Select</option>
                            		    <?php foreach($getLobby as $record):?>
                            		    <option data-image="<?php echo $record['url'];?>" value="<?php echo $record['num'];?>"><?php echo $record['title'];?></option>
                            		    <?php endforeach;?>
                            		</select>-->
                            		<?php foreach($getLobby as $record):?>
                            		<div style="float:left; margin-right:10px;">
                            		<input type="radio" name="lobby_id" class="lobby_id" value="<?php echo $record['num'];?>"> <?php echo $record['title'];?><br>
                            		    <a data-url="<?php echo $record['url'];?>" data-title="<?php echo $record['title'];?>" data-toggle="modal" class="modalpopup" href="#stack2"><img src="<?php echo $record['url'];?>" style="width:100px;"></a>
                            		    </div>
                            		<?php endforeach;?>
                            		<br clear="all">
                            	</div>
                            	<div class="form-group">
                            		<label>Select Lounge</label>
                            		<!--<select id="lounge_id" name="lounge_id" class="chosen-select showimg no-search-select" style="width:100%; margin-bottom:10px;" onClick="this.select()">
                            		    <option value="">Please Select</option>
                            		    <?php foreach($getLounge as $record):?>
                            		    <option data-image="<?php echo $record['url'];?>" value="<?php echo $record['num'];?>"><?php echo $record['title'];?></option>
                            		    <?php endforeach;?>
                            		</select>
                            		<img src="" id="loungeImg" style="width:200px;">-->
                            		<?php foreach($getLounge as $record):?>
                            		<div style="float:left; margin-right:10px;">
                            		<input type="radio" name="lounge_id" class="lounge_id" value="<?php echo $record['num'];?>"> <?php echo $record['title'];?><br>
                            		    <a data-url="<?php echo $record['url'];?>" data-title="<?php echo $record['title'];?>" data-toggle="modal" class="modalpopup" href="#stack2"><img src="<?php echo $record['url'];?>" style="width:100px;"></a>
                            		    </div>
                            		<?php endforeach;?>
                            		<br clear="all">
                            	</div>
                            	<div class="form-group">
                            		<label>Select Auditorium</label>
                            		<!--<select id="audi_id" name="audi_id" class="chosen-select showimg no-search-select" style="width:100%; margin-bottom:10px;" onClick="this.select()">
                            		    <option value="">Please Select</option>
                            		    <?php foreach($getAudi as $record):?>
                            		    <option data-image="<?php echo $record['url'];?>" value="<?php echo $record['num'];?>"><?php echo $record['title'];?></option>
                            		    <?php endforeach;?>
                            		</select>
                            		<img src="" id="audiImg" style="width:200px;">-->
                            		<?php foreach($getLounge as $record):?>
                            		<div style="float:left; margin-right:10px;">
                            		<input type="radio" name="audi_id" class="audi_id" value="<?php echo $record['num'];?>"> <?php echo $record['title'];?><br>
                            		    <a data-url="<?php echo $record['url'];?>" data-title="<?php echo $record['title'];?>" data-toggle="modal" class="modalpopup" href="#stack2"><img src="<?php echo $record['url'];?>" style="width:100px;"></a>
                            		    </div>
                            		<?php endforeach;?>
                            		<br clear="all">
                            	</div>
                            	<div class="form-group">
                            		<label>Primary Color</label>
                            		<input type="color" class="form-control" id="primColor" name="prim_color" placeholder="Primary Color">
                            	</div>
                            	<div class="form-group">
                            		<label>Secondary Color</label>
                            		<input type="color" class="form-control" id="secColor" name="sec_color" placeholder="Secondary Color">
                            	</div>
                            	
                            </div>
                            <br clear="all">
                    </div>
                    <div  role="tabpanel" class="tab-pane" id="registration">
                        <div class="col-md-6">
                            	<div class="form-group" id="attendeeForm" style="display:none;">
                            		<label>Attendees Form Fields</label>
                            		<?php foreach($formFields as $record):
                            		$getFieldsStatus = $database->getRecord("manage_form_fields", "field_id='".$record['num']."'");
                            		?>
                            		<input type="checkbox" name="formfields[]" id="formfields_<?php echo $record['num'];?>" value="<?php echo $getFieldsStatus['num'];?>_<?php echo $getFieldsStatus['event_id'];?>"> <?php echo $record['field_name'];?><br>
                            		<?php if($record['field_name']=="checkbox_1") {?>
                            		    <textarea name="<?php echo $record['field_name'];?>_text" id="<?php echo $record['field_name'];?>_text" style="width:100%;"></textarea>
                            		<?php } if($record['field_name']=="checkbox_2") {?>
                            		    <textarea name="<?php echo $record['field_name'];?>_text"  id="<?php echo $record['field_name'];?>_text" style="width:100%;"></textarea>
                            		<?php } endforeach;?>
                            	</div>
                            	
                            </div>
                            <br clear="all">
                            
                            <div class="col-md-12">
                                <div class="form-group col-md-6">
                            	    <label>Form Top Text</label>
                            	    <div id="summernote">
                            	        
                            	    </div>
                            	    <textarea id="formtoptext" style="display:none;" name="formtoptext"></textarea>
                            	</div>
                            	<div class="form-group col-md-6">
                            	    <label>Form Bottom Text</label>
                            	    <div id="summernote2">
                            	        
                            	    </div>
                            	    <textarea id="formbottomtext" style="display:none;" name="formbottomtext"></textarea>
                            	</div>
                            	<br clear="all">
                            </div>
                    </div>
                    
                    	<br clear="all">
                    </div>
                    <div class="modal-footer">
                        <div class="btn-group" role="group">
                            <button type="button" class="btn btn-gray btn-wide btn-rounded" id="closePopup" data-dismiss="modal"><i class="fa fa-times"></i>Close</button>
                            <button type="submit" class="btn bg-success btn-wide btn-rounded"><i class="fa fa-check"></i>Save</button>
                        </div>
                        <!-- /.btn-group -->
                    </div>
                    </form>
                </div>
            </div>
        </div>
        
        <div id="stack2" class="modal fade" tabindex="-1">
            <div class="modal-dialog">
                <div class="modal-content">
          <div class="modal-header">
              <h4 class="modal-title" id="modal2Label"><span class="title">Add Event</span> <button type="button" data-dismiss="modal" aria-label="Close" style="float:right; border:0; background:none;"><span aria-hidden="true">×</span></button></h4>
          </div>
          <div class="modal-body">
            <img src="" style="width:100%;">
          </div>
        </div>
        </div>
        </div>

        <!-- ========== 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/iziModal/iziModal.min.js"></script>
        <script src="<?php echo CMS_ROOT;?>js/sweet-alert/sweetalert.min.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 src="<?php echo CMS_ROOT;?>js/summernote/summernote.min.js"></script>
        <script>
        $(document).ready(function() {
                $("#modal12").iziModal();
                $('.modal-12-trigger').on('click', function(){
                    $('#modal12').iziModal('open', this);
                });
                
                $("#closePopup").click(function(){
                   location.reload(); 
                });
                
                $(".close").click(function(){
                   location.reload(); 
                });
                
                $("#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;
                });
                
                $("#add_update_record").submit(function() {
                    var recordId = $("#recordId").val();
                    if(recordId>0) {
                        var summercode1 = $('#summernote').summernote("code");
                        var summercode2 = $('#summernote2').summernote("code");
                        $('textarea[name="formtoptext"]').html(summercode1);
                        $('textarea[name="formbottomtext"]').html(summercode2);
                    }
                    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){
                        console.log(data);
                        if(data=="v") {
                            $(".modal-body").append("<div style='color:#fff; background:#5ECFB1; padding:5px;'>Data updated successfully</div>");
                        }
                    }
                  }); 
                  return false;
                });
                
                $(".edit-record").click(function() {
                    var inputRecordIda = $(this).attr("data-id");
                    var inputUserId = $(this).attr("data-userid");
                    var inputFirstName = $(this).attr("data-firstname");
                    var inputLastName = $(this).attr("data-lastname");
                    var inputEventName = $(this).attr("data-eventname");
                    var inputEventUri = $(this).attr("data-eventuri");
                    var inputEmail = $(this).attr("data-email");
                    var inputLogo = $(this).attr("data-logo");
                    var inputLoginTitle = $(this).attr("data-logintitle");
                    var inputLoginImage = $(this).attr("data-loginimage");
                    var inputLoginImageTitle = $(this).attr("data-loginimagetitle");
                    var inputLoginImageText = $(this).attr("data-loginimagetext");
                    var inputDataLobby = $(this).attr("data-lobby");
                    var inputDataAudi = $(this).attr("data-audi");
                    var inputDataLounge = $(this).attr("data-lounge");
                    var inputVideoUrl = $(this).attr("data-videourl");
                    var inputHallImage = $(this).attr("data-hallimage");
                    var inputPrimColor = $(this).attr("data-primcolor");
                    var inputSecColor = $(this).attr("data-seccolor");
                    var formbottomtext = $(this).attr("data-formbottomtext");
                    var formtoptext = $(this).attr("data-formtoptext");
                    $("#attendeeForm").show();
                    $("#tabhide").show();
                    
                    <?php foreach($formFields as $record):
            		$getFieldsStatus = $database->getRecord("manage_form_fields", "field_id='".$record['num']."'");
            		if($getFieldsStatus['active']=="1") {
            		?>
            		$("#formfields_<?php echo $record['num'];?>").attr("checked", true);
            		<?php } else {?>
            		$("#formfields_<?php echo $record['num'];?>").attr("checked", false);
            		<?php } ?>
            		$("#<?php echo $record['field_name'];?>_text").val('<?php echo $getFieldsStatus['field_text'];?>');
            		<?php endforeach;?>
                    $("#recordId").val(inputRecordIda);
                    $("#firstName").val(inputFirstName);
                    $("#lastName").val(inputLastName);
                    $("#eventName").val(inputEventName);
                    $("#eventUri").val(inputEventUri);
                    $("#email").val(inputEmail);
                    $("#loginTitle").val(inputLoginTitle);
                    $("#loginImageTitle").val(inputLoginImageTitle);
                    $("#loginImageText").val(inputLoginImageText);
                    $("#videoUrl").val(inputVideoUrl);
                    <?php if($getUserDetails['role']=="3") {?>
                    $("#user_id option").each(function() {
                        var vala = $(this).val();
                        if(vala==inputUserId) {
                            $(this).attr("selected", true);
                        } else {
                            $(this).attr("selected", false);
                        }
                    });
                    <?php }?>
                    $(".lobby_id").each(function() {
                        var vala = $(this).val();
                        if(vala==inputDataLobby) {
                            $(this).attr("checked", true);
                        } else {
                            $(this).attr("checked", false);
                        }
                    });
                   $(".lounge_id").each(function() {
                        var vala = $(this).val();
                        if(vala==inputDataLounge) {
                            $(this).attr("checked", true);
                        } else {
                            $(this).attr("checked", false);
                        }
                    });
                    $(".audi_id").each(function() {
                        var vala = $(this).val();
                        if(vala==inputDataAudi) {
                            $(this).attr("checked", true);
                        } else {
                            $(this).attr("checked", false);
                        }
                    });
                   
                    $("#primColor").val(inputPrimColor);
                    $("#secColor").val(inputSecColor);
                    $("#summernote").summernote("code", formtoptext);
                    $("#summernote2").summernote("code", formbottomtext);
                    $('textarea[name="formtoptext"]').html(formtoptext);
                    $('textarea[name="formbottomtext"]').html(formbottomtext);
                    $("#logourl").attr("src", inputLogo);
                    $("#loginImageurl").attr("src", inputLoginImage);
                    $("#exHallImageurl").attr("src", inputHallImage);
                });
                
                $(".del_url").on("click", function() {
                    var videoId = $(this).attr("data-id");
                    var dataString = "recordId="+videoId+"&tablename=manage_events&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();
                        }
                      }); 
                    }
                });
                
                $("#org_id").change(function(){
                    var orgId = $(this).val();
                    if(orgId!="") {
                        $(location).attr('href', 'https://platform.xibitrs.net/cms/events.php?org_id='+orgId); 
                    }
                });
                
                $(".modalpopup").click(function() {
                    var imgURL = $(this).attr("data-url");
                    var imgTitle = $(this).attr("data-title");
                   $("#stack2 h4 span.title").html(imgTitle); 
                   $("#stack2").find("img").attr("src", imgURL); 
                });
                
                $(".showimg").change(function() {
                   var option = $(this).find('option:selected', this).attr('data-image');
                   $(this).next().attr("src", option);
                });
                
                $('#summernote').summernote({
                    height: 300,                 // set editor height
                    minHeight: null,             // set minimum height of editor
                    maxHeight: null,             // set maximum height of editor
                    focus: true                  // set focus to editable area after initializing summernote
                });
                
                $('#summernote2').summernote({
                    height: 300,                 // set editor height
                    minHeight: null,             // set minimum height of editor
                    maxHeight: null,             // set maximum height of editor
                    focus: true                  // set focus to editable area after initializing summernote
                });
                
                $('#example').DataTable();
                $( ".draggable" ).draggable({ handle: ".draggable-handle" });
        });
        </script>

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