<?php include("parent/callMe.php"); ?>
<?php include("sessioncheck.php"); ?>
<?php

$date;
if ($_REQUEST['date'] != NULL) {

    $date = date('Y-m-d', strtotime($_REQUEST['date']));
} else {

    $date = date('Y-m-d');
}


$branch = $_SESSION['branch'];

$classes = $m->query("select * from edu_class_config where branch_id=" . $branch . " order by class_id asc limit 1");
// print_r($classes);


// getting details to promote

if ($_REQUEST['class_id'] != NULL) {


    $m->where("class_id", $_REQUEST['class_id']);


    if ($_REQUEST['session'] != NULL) {

        $m->where("session_id", $_REQUEST['session']);
    }

    if ($_REQUEST['section'] != NULL) {

        $m->where("section_id", $_REQUEST['section']);
    }



    $m->where("status", '0');
    $m->where("branch_id", $_SESSION['branch']);

    $WorkAssignListings = $m->get("edu_student_details");
}



?>


<!DOCTYPE html>
<html lang="en">

<head>

    <title>Add Hostel | EduPortal</title>
    <?php include('RootMe/css_links.php'); ?>

    <!-- ckeditor -->
    <link href="autosearch_select/select2.css" rel="stylesheet">
    <link href="autosearch_select/select2-default.css" rel="stylesheet">
    <script src="autosearch_select/select2.min.js"></script>
    <script src="https://cdn.ckeditor.com/4.12.1/standard/ckeditor.js"></script>
    <!--/ckeditor -->

    <!--file dropify-->
    <link rel="stylesheet" href="https://demo.smart-school.in/backend/dist/css/dropify.min.css">
    <!--file nprogress-->
     <link href="https://demo.smart-school.in/backend/dist/css/nprogress.css" rel="stylesheet"> 
     
     <!-- ################### -->
     <!-- CSS files for table -->
   <!-- x-editor CSS
    ============================================ -->
        <link rel="stylesheet" href="css/editor/select2.css">
    <link rel="stylesheet" href="css/editor/datetimepicker.css">
    <link rel="stylesheet" href="css/editor/bootstrap-editable.css">
    <link rel="stylesheet" href="css/editor/x-editor-style.css">

    <!-- normalize CSS
    ============================================ -->
    <link rel="stylesheet" href="css/data-table/bootstrap-table.css">
    <link rel="stylesheet" href="css/data-table/bootstrap-editable.css">

     <!-- responsive CSS
    ============================================ -->
        <link rel="stylesheet" href="css/responsive.css">
    <!-- main CSS
    ============================================ -->
        <link rel="stylesheet" href="css/main.css">
    <!--###################  -->

    <script type="text/javascript">
        function getSubCat(id) {
            //alert(id);

            if (window.XMLHttpRequest) {
                // code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            } else { // code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function() {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

                    document.getElementById("subcatgory").innerHTML = xmlhttp.responseText;
                    //alert(xmlhttp.responseText);

                }

            }
            xmlhttp.open("GET", "get_exp_subcategory.php?id=" + id, true);
            xmlhttp.send();
        }


        function HideDate(str){
  
  if(str=="Teachers"){
    
    document.getElementById("classNone").style.display="none";
    document.getElementById("sectionNone").style.display="none";
  }
  else {
    
    document.getElementById("classNone").style.display="block";
    document.getElementById("sectionNone").style.display="block";
   
   
  }
}
    </script>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- <script>
$(document).ready(function(){
  
    $("#div1").fadeOut();
    $("#div2").fadeOut("slow");
    $("#div3").fadeOut(3000);
 
});
</script> -->
<style>
    #snackbar {
        visibility: hidden;
        min-width: 250px;
        margin-left: -125px;
        background-color: #1E90FF;
        color: #fff;
        text-align: right;
        border-radius: 2px;
        padding: 16px;
        position: fixed;
        z-index: 1;
        left: 80%;
        bottom: 30px;
        font-size: 17px;
    }

    #snackbar.show {
        visibility: visible;
        -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
        animation: fadein 0.5s, fadeout 0.5s 2.5s;
    }

    @-webkit-keyframes fadein {
        from {
            bottom: 0;
            opacity: 0;
        }

        to {
            bottom: 30px;
            opacity: 1;
        }
    }

    @keyframes fadein {
        from {
            bottom: 0;
            opacity: 0;
        }

        to {
            bottom: 30px;
            opacity: 1;
        }
    }

    @-webkit-keyframes fadeout {
        from {
            bottom: 30px;
            opacity: 1;
        }

        to {
            bottom: 0;
            opacity: 0;
        }
    }

    @keyframes fadeout {
        from {
            bottom: 30px;
            opacity: 1;
        }

        to {
            bottom: 0;
            opacity: 0;
        }
    }
    .active{
        color:aqua;
    }
</style>

<body class="nav-md">
    <div class="container body">
        <div class="main_container">
            <div class="col-md-3 left_col">

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

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

                <!-- page content -->
                <div class="right_col" role="main">

                    <a href="dashboard.php">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i> &nbsp;
                  Hostel <i style="" class="fa fa-angle-double-right"></i> &nbsp; <span class="active" style="color: #042954"> Add Hostel </span> 
                    <br><br>

<div class="row" style="background-color: white;">
<section class="add_sub_agent" id="table_sub_agent">
    <div class="container">
        <div class="" style="margin-top:10px;">
            <!-- page content -->
            <div class="">
                <h3 style="margin-left: 15px;">Add Hostel</h3>
                <div class="row">
                    <!-- <div class="col-md-12 col-sm-12 col-xs-12"> -->
                    <div class="x_panel">
                        <div class="x_content">
                            <form class="form-style-7" action="<?php echo DOMAIN . AgentDirectory; ?>parent/InsertMe.php" method="post" enctype="multipart/form-data">

                                <?php


                                if (!isset($_GET['addHostel'])) { ?>
                                    <input type="hidden" name="action" value="AddHostel" />

                                <?php } else {

                                    $query = "select * from eduportal_hostel_config where branch_id='$branch' and id =" . $_GET['addHostel'];
                                    $hostel_data = $m->query($query);

                                ?>
                                    <input type="hidden" name="action" value="updateHostel" />
                                    <input type="hidden" name="id" value="<?php echo $_GET['addHostel']; ?>">

                                <?php } ?>

                                    <!-- Main content -->


                                    <!-- <input type='hidden' name='ci_csrf_token' value='' /> -->
                <div class=" col-md-4 col-sm-12 col-xs-12 form-group">
                    <label for="exampleInputEmail1">Hostel Name</label><small class="req"> *</small>
                    <input name="hostel_name" placeholder="" type="text" class="form-control" value="<?php echo $hostel_data[0]['hostel_name']; ?>" />
                    <span class="text-danger"></span>
                </div>

                <div class=" col-md-4 col-sm-12 col-xs-12 form-group">
                    <label for="exampleInputEmail1">Hostel Type</label><small class="req"> *</small>

                    <select name="hostel_type" class="form-control">
                        <option value="">Select</option>
                        <option <?php if ($hostel_data[0]['hostel_type'] == "Girls") {
                                    echo "Selected";
                                } ?> value="Girls">Girls</option>
                        <option <?php if ($hostel_data[0]['hostel_type'] == "Boys") {
                                    echo "Selected";
                                } ?> value="Boys">Boys</option>
                        <option <?php if ($hostel_data[0]['hostel_type'] == "Combine") {
                                    echo "Selected";
                                } ?> value="Combine">Combine</option>
                       
                    </select>
                    <span class="text-danger"></span>
                </div>




                <div class=" col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="control-label">Intake</label><small class="req"> *</small>

                    <input name="intake" placeholder="" type="text" class="form-control" value="<?php echo $hostel_data[0]['intake']; ?>" />
                    <span class="text-danger"></span>
                </div>

              
                <div class="form-group">
                    <div class="col-md-12 col-xs-12" id="classNone" style="padding: 8px;">
                        <div class="form-group ">
                            <label class="required">Address</label>

                            <input name="address" placeholder="" type="text" class="form-control" value="<?php echo $hostel_data[0]['address']; ?>" />
                        </div>
                    </div>


                </div>


                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12 form-group">
                        <label for="exampleInputEmail1">Description</label>
                        <textarea id="textarea" name="description" class=" form-control"> <?php echo $hostel_data[0]['description']; ?></textarea>
                        <span class="text-danger"></span>
                    </div>
                </div>

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

                    <div>
                        <button type="submit" class="btn btn-info pull-right">Save</button>
                    </div>


                </form>

                                </div>
                            </div>



                        </div>
                    </div>
                </div>
            </div>
    </div>
                    <div class="clearfix"></div>
                    </section> <!--  -->



                    <h3 style="background-color:white; padding:8px;">Content List</h3>
                    
                    <div style="overflow-x:auto; background-color: white;">
 
                      
                        <table id="table" data-toggle="table" class="table-bordered" data-pagination="true" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="true" data-key-events="true" data-show-toggle="true" data-resizable="true" data-cookie="true"
                                        data-cookie-id-table="saveId" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar">
                           

                              <thead>
                                            <tr>
                                                <th data-field="id" class="text-center" width="2%"> Serial No.</th>
                                                <th data-field="name" class="text-center" width="20%"> Hostel Name</th>
                                                <th data-field="type" class="text-center"  width="15%">Type</th>
                                                <th data-field="availability"class="text-center" width="15%">Address </th>
                                                <th data-field="class" class="text-center"  width="20"> Intake</th>                                               
                                                <th data-field="action" width="10%">Action</th>
                                            </tr>
                                        </thead>

                             <tbody>

                                <?php $count = 1;

                                $m->where("branch_id", $_SESSION['branch']);
                                $m->orderBy("id", "desc");
                                $WorkAssignListings = $m->get("eduportal_hostel_config");

                                foreach ($WorkAssignListings as $WorkAssignListVal) {

                                    $m->where("class_id", $WorkAssignListVal['class_id']);
                                    $class = $m->get("edu_class_config");

                                    $m->where("section_id", $WorkAssignListVal['section_id']);
                                    $section = $m->get("edu_adm_section_detail");

                                ?>

                                    <tr>
                                        <td style="text-align:center;"> <?php echo $count;
                                                                        $count += 1; ?> </td>
                                        <td style=""> <?php echo $WorkAssignListVal['hostel_name']; ?> </td>
                                        <td style=""> <?php echo $WorkAssignListVal['hostel_type']; ?> </td>
                                        <td clas="text-center" style=""> <?php echo $WorkAssignListVal['address']; ?> </td>
                                        
                                        <td> <?php echo $WorkAssignListVal['intake']; ?> </td>
                                       
                                        <td>
                                           
                                                <a style="padding: 0px 5px; font-size:14px;"  href="hostel.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&addHostel=<?php echo $WorkAssignListVal['id'];?>" style="cursor:pointer;"  class="btn btn-success"> <i class="fa fa-pencil" aria-hidden="true"></i></a> 

                                            <a href="<?php echo DOMAIN . AgentDirectory; ?>parent/InsertMe.php?id=<?php echo $WorkAssignListVal['id']; ?>&action=DeleteHostel" style="padding: 0px 5px; font-size:14px;" onClick="return confirm('Are you sure you want to delete this record');" class="btn btn-danger"><i class="fa fa-remove"></i> </a>

                                        </td>

                                    </tr>
                                <?php
                                } ?>
                            </tbody>
                        </table>
                    </div>
                  
                    <br><br>
                </div>

            </div>


            <!--  -->
        </div>
    </div>

    </div>
    </div>
    </div>
    <!-- /page content -->

    <!--  -->




<script>
    $(document).ready(function() {
        $('.dropify').dropify();
    });
</script>
<!--nprogress-->
<script src="https://demo.smart-school.in/backend/dist/js/nprogress.js"></script>
<!--file dropify-->
<script src="https://demo.smart-school.in/backend/dist/js/dropify.min.js"></script>

<script src="vendor/jquery-1.12.4.min.js"></script> 

<!-- jQuery -->
 <script src="js/ajax_functions.js"></script> 

   <!-- ################## -->
   <!-- JS files for table -->
      <!-- bootstrap JS
    ============================================ -->
        <!-- <script src="js/bootstrap.min.js"></script> -->
  <!-- data table JS
    ============================================ -->
        <script src="js/data-table/bootstrap-table.js"></script>
    <script src="js/data-table/tableExport.js"></script>
    <script src="js/data-table/data-table-active.js"></script>
    <script src="js/data-table/bootstrap-table-editable.js"></script>
    <script src="js/data-table/bootstrap-editable.js"></script>
    <script src="js/data-table/bootstrap-table-resizable.js"></script>
    <script src="js/data-table/colResizable-1.5.source.js"></script>
    <script src="js/data-table/bootstrap-table-export.js"></script>
    <!--  editable JS
    ============================================ -->
    <script src="js/editable/jquery.mockjax.js"></script>
    <script src="js/editable/mock-active.js"></script>
    <script src="js/editable/select2.js"></script>
    <script src="js/editable/moment.min.js"></script>
    <script src="js/editable/bootstrap-datetimepicker.js"></script>
    <script src="js/editable/bootstrap-editable.js"></script>
    <script src="js/editable/xediable-active.js"></script>

    <script src="js/tab.js"></script>
    <!-- plugins JS
    ============================================ -->
    <script src="js/plugins.js"></script>
    <!-- main JS
    ============================================ -->
    <script src="js/main.js"></script>
    <!--###############  -->

<?php include('RootMe/js_linksscript.php'); ?>
</body>

</html>
