<style>
    body{background:#EAEDED;}
    h1{font-weight:600;font-size:18px;}
</style>

<div class="container-fluid bg-white mb-3 mt-3 p-3" >
    <div class="row" >
        <div class="col-sm-12">
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Welcome">Home</a></li> 
                <li class="breadcrumb-item">Enquiry</li> 

            </ul>    
    

            <div id="content">
                <a href="<?php echo base_url();?>Enquiry/new_enquiry" class="btn btn-success mt-3 mb-3">New Enquiry</a>

                <div class="table-responsive">
                    <table class="table table-striped table-bordered" id="mytable">
                        <thead>
                            <tr>
                                <th> S.No. </th>
                                <!--<th>Enquiry No.</th>-->
                                <th> First Name </th>
                                <!--<th> Last Name </th>-->
                                <!--<th> Gender</th>-->
                                <!--<th> Aadhar Number</th>-->
                                <th> Mobile </th>
                                <!--<th> Email </th>-->
                                <!--<th> Payment Status</th>-->
                                <!--<th> Father Name </th>-->
                                <!--<th>Father Qualification</th>-->
                                <!--<th>Father Occupation</th>-->
                                <!--<th> Mother Name</th>-->
                                <!--<th>Mother Qualification</th>-->
                                <!--<th>Mother Occupation</th>-->
                                <!--<th> D.O.B. </th>-->
                                <th> Class</th>
                                <th> Section</th>
                                <!--<th> Branch </th>-->
                                <!--<th> Enquiry Date</th>-->
                                <!--<th>Address</th>-->
                                <!--<th>Profile Pic</th>-->
                                <!--<th>DOB Certificate</th>-->

                                <!--<th>Shedule For Exam</th>-->
                                <th>Prospectus Fee</th>
                                <th>Admission Fee</th>
                                <th>Status</th>
                                <th>Approve for admission</th>
                                <th>Convert Admission</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>

                        <?php        
                        if($fetch_student_data){
                            $count = 0;
                            foreach($fetch_student_data as $records){
                                $count=$count + 1;
                        ?>
                            <tr>
                                <td><?php echo $count;?></td>
                                <td><?php echo $records['first_name']; echo " "; echo $records['last_name'];?></td>
                                <!--<td><?php echo $records['last_name'];?></td>-->
                                <!--<td><?php echo $records['gender'];?></td>-->
                                <!--<td><?php echo $records['aadhar_no'];?></td>-->
                                <td><?php echo $records['mobile_number'];?></td>
                                <!--<td><?php echo $records['email'];?></td>-->
                                <!--<td style="color:green;font-weight:600;"><?php if($records['enquiry_payment_status'] ==1){echo "Success";}?></td>-->
                                <!--<td><?php echo $records['father_name'];?></td>-->
                                <!--<td><?php echo $records['father_qualification'];?></td>-->
                                <!--<td><?php echo $records['father_occupation'];?></td>-->
                                <!--<td><?php echo $records['mother_name'];?></td>-->
                                <!--<td><?php echo $records['mother_qualification'];?></td>-->
                                <!--<td><?php echo $records['mother_occupation'];?></td>-->
                                <!--<td><?php echo $records['dob'];?></td>-->
                                <td><?php echo $records['class'];?></td>
                                <td><?php echo $records['section'];?></td>
                                <!--<td><?php echo $records['branch'];?></td>-->

                                <!--  echo $records['payment_status']; -->
                                <!--<td><?php echo $records['c_at'];?></td>-->
                                <!--<td><?php echo $records['address'];?></td>-->
                                <!--<td><?php if($records['student_profile']==''){echo "No Image";}else{?>-->
                                <!--<a class="thumbnail" href="#" data-image-id="" data-toggle="modal" data-title="" data-image="<?php echo $records['student_profile']; ?>" data-target="#image-gallery">-->
                                <!--<img class="img-thumbnail galleryff" src="<?php echo $records['student_profile']; ?>" alt="" height="70px"></a>    <?php }?>-->
                                <!--</td>-->
                                <!--<td><?php if($records['student_profile']==''){echo "No Image";}else{?>-->
                                <!--<a class="thumbnail" href="#" data-image-id="" data-toggle="modal" data-title="" data-image="<?php echo $records['student_dob_cert']; ?>" data-target="#image-gallery">-->
                                <!--<img class="img-thumbnail galleryff" src="<?php echo $records['student_dob_cert']; ?>" alt="" height="70px"></a><?php }?>-->
                                <!--</td>-->

                                <!--<td>-->
                                <!--<button id="<?php echo $records['id']; ?>" class="btn btn-sm btn-info shedule">Shedule</button>-->
                                <!--</td>-->

                                <td><a href="<?php echo base_url();?>Enquiry/fee/<?php echo $records['id']; ?>" class="btn btn-sm btn-warning text-white">Pay Fee</a></td>
                                <td><a href="<?php echo base_url();?>Enquiry/fee/<?php echo $records['id']; ?>"  class="btn btn-sm btn-warning text-white">Pay Fee</a></td>
                                <td>
                                <?php
                                if($records['shedule_sms'] ==1){
                                ?>
                                <button class="btn btn-sm btn-success">Sheduled</button>
                                <?php
                                } 
                                ?>
                                </td>

                                <td>
                                <?php
                                if($records['admission_status'] ==1){
    
                                $student_table='student';

                                $check_student_admission=$this->WelcomeModel->get_admission_refrence_data($records['id'],$student_table);
                                if($check_student_admission){
                                ?>
                                <button class="btn btn-sm btn-success">Admission Taken</button>
                                <?php
                                }else{
                                ?>
                                <button class="btn btn-sm btn-success">Approved</button>
                                <?php
                                }
                                ?>

                                <?php
                                }else{
                                ?>
                                <button id="<?php echo $records['id']; ?>" class="btn btn-sm btn-info grant_admission">Approve Admission</button>
                                <?php
                                }
                                ?>


                                </td>
                                <td>
                                <?php
                                if($records['admission_status'] ==1){
    
                                $student_table='student';

                                $check_student_admission=$this->WelcomeModel->get_admission_refrence_data($records['id'],$student_table);
                                if($check_student_admission){
                                ?>
                                <button class="btn btn-sm btn-success">Admission Taken</button>
                                <?php
                                }else{
                                ?>
                                <a href="<?php echo base_url();?>Enquiry/convert_to_admission/<?php echo $records['id']; ?>" class="btn btn-sm btn-warning text-white font-weight-bold">Convert to admission</a>
                                <?php
                                }
                                ?>

                                <?php
                                }else{
                                ?>
                                <button id="<?php echo $records['id']; ?>" class="btn btn-sm btn-info">Pending</button>
                                <?php
                                }
                                ?>
                                </td>
                                <td>
                                <form method="post" action="<?php echo base_url();?>Enquiry/new_enquiry">
                                <button class="btn btn-sm btn-warning" name="edit" value="<?php echo $records['id']; ?>" type="submit">Edit</button>
                                </form>  

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

            </div>

        </div>
    </div>
</div>


<script>
$(document).ready(function(){

    $(document).on("click",".shedule",function(){
        var id = $(this).attr("id");
        var table = 'enquiry';
        var val=1;
        $.ajax({
            url: '<?php echo base_url() ?>Admin/shedule_sms',
            type: 'POST',
            data: { val:val,id:id,table:table},
            success: function(data){
                location.reload();
            }
        });
    });


    $(document).on("click",".grant_admission",function(){
        var id = $(this).attr("id");
        var table = 'enquiry';
        var val=1;
        $.ajax({
            url: '<?php echo base_url() ?>Enquiry/grant_admission',
            type: 'POST',
            data: { val:val,id:id,table:table},
            success: function(data){
                location.reload();
            }
        });
    });
});
</script>