<?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."'");
$getFormDetails = $database->getRecord("manage_matchmaking", "org_id='".$adminUserId."' AND event_id='".$adminEventId."'");

include("includes/header.php");
?>
<!-- CSS -->

<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo CMS_ROOT;?>css/form_builder.css">
    <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"><?php echo $getEventDetails['event_name'];?> - Matchmaking Form</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">
                                        <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">Matchmaking Form</li>
            						</ul>
                                </div>
                                
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- /.container-fluid -->

                        <section id="formbuildera" class="section pt-10">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="form_builder" style="margin-top: 25px">
                                          <div class="row">
                                            <div class="col-sm-2">
                                              <nav class="nav-sidebar">
                                                <ul class="nav">
                                                  <li class="form_bal_textfield"> <a href="javascript:;">Text Field <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_textarea"> <a href="javascript:;">Text Area <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_select"> <a href="javascript:;">Select <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_radio"> <a href="javascript:;">Radio Button <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_checkbox"> <a href="javascript:;">Checkbox <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_email"> <a href="javascript:;">Email <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_number"> <a href="javascript:;">Number <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_password"> <a href="javascript:;">Password <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_date"> <a href="javascript:;">Date <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                  <li class="form_bal_button"> <a href="javascript:;">Button <i class="fa fa-plus-circle pull-right"></i></a> </li>
                                                </ul>
                                              </nav>
                                            </div>
                                            <div class="col-md-5 bal_builder">
                                              <div class="form_builder_area"></div>
                                            </div>
                                            <div class="col-md-5">
                                              <div class="col-md-12">
                                                <form class="form-horizontal">
                                                  <div class="preview"><?php echo $getFormDetails['form'];?></div>
                                                  <div style="display: none" class="form-group plain_html">
                                                    <textarea rows="50" class="form-control"><?php echo $getFormDetails['form'];?></textarea>
                                                  </div>
                                                </form>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                        <button style="cursor: pointer;display: block" class="btn save-form btn-info mt-2 pull-right">Save Form</button>
                                    
                                    </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/iziModal/iziModal.min.js"></script>
        <script src="<?php echo CMS_ROOT;?>js/sweet-alert/sweetalert.min.js"></script>
        
        <!-- JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script src="<?php echo CMS_ROOT;?>js/form_builder.js"></script>

        <!-- ========== THEME JS ========== -->
        <script src="<?php echo CMS_ROOT;?>js/main.js"></script>
        <script>
        $(document).ready(function() {
                $("#modal12").iziModal();
                $('.modal-12-trigger').on('click', function(){
                    $('#modal12').iziModal('open', this);
                });
                
                $("#close_popup").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;
                });
                
                $(".close").click(function(){
                   location.reload(); 
                });
                
                $("#add_update_record").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=="v") {
                            $(".modal-body").append("<div style='color:#fff; background:#5ECFB1; padding:5px;'>Data updated successfully</div>");
                        }
                    }
                  }); 
                  return false;
                });
                
                $(".edit-record").click(function() {
                    var inputVideoId = $(this).attr("data-id");
                    var inputVideoTitle = $(this).attr("data-title");
                    var inputVideoUrl = $(this).attr("data-url");
                    $("#doc_record_id").val(inputVideoId);
                    $("#inputVideoTitle").val(inputVideoTitle);
                    $("#inputVideoUrl").val(inputVideoUrl);
                    $("#docurl").attr("src", inputVideoUrl);
                });
                
                $(".del_url").on("click", function() {
                    var videoId = $(this).attr("data-id");
                    var dataString = "recordId="+videoId+"&tablename=manage_org_videos&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();
                        }
                      }); 
                    }
                });
                
                $(".save-form").click(function() {
                    var dataString = 'data='+$(".preview").html()+'&orgId=<?php echo $adminUserId;?>&eventId=<?php echo $adminEventId;?>&tablename=manage_matchmaking&action=formbuilder';
                    alert(dataString);
                    $.ajax({
                    type: "POST",
                    url: "/includes/process.php",
                    data: dataString,
                    success: function(data){
                        console.log(data);
                        if(data=="v") {
                            $("#formbuildera").append("<div style='color:#fff; background:#5ECFB1; padding:5px;'>Data updated successfully</div>");
                        }
                    }
                    });
                });
        });
        </script>

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