

 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">All Admitted Student</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">Student</a></li>
              <li class="breadcrumb-item active">All Admitted Student</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">View All Student <strong><small>( AP = Admission Panding && AC = Admission Complete )</small></strong></h3>
          </div>
            <!-- /.card-header -->
            <div class="card-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Name & Photo</th>
                  <th>Details</th>
                  <th>Course</th>
                  <th>Status</th>
                  <th></th>
                </tr>
                </thead>
                <tbody>
                <?php $i=1; foreach ($all_students as $student):?>
                <tr>
                  <td><?php echo $student->user_name ?>
                    <br/>
                    <img src="<?php echo check_image($student->user_photo); ?>" width="50px">
                  </td>
                  <td>
                    Reg. No. : <b><?php echo $student->user_reg_id ?></b>
                    <br/>
                    Mob. : <b><?php echo $student->user_mobile ?></b>
                    <?php if($student->user_email): ?>
                      <br/>
                      Email : <b><?php echo $student->user_email ?></b>
                    <?php endif;?>
                    <br/>
                    Gender : <b><?php echo $student->user_gender ?></b>
                    <?php if($student->user_dob != '0000-00-00'): ?>
                      <br/>
                      DOB : <b><?php echo date('d-m-Y', strtotime($student->user_dob)); ?></b>
                    <?php endif; ?>
                    <?php if($student->user_qualification): ?>
                      <br/>
                      Qulification : <b><?php echo $student->user_qualification ?></b>
                    <?php endif; ?>
                    <?php if($student->user_pin_code): ?>
                      <br/>
                      Address : <b>
                      <?php echo $student->user_village ?>, <?php echo $student->user_taluka ?>, <?php echo $student->user_dist ?>, <?php echo $student->user_state ?> - <?php echo $student->user_pin_code ?></b>
                    <?php endif;?>
                  </td>
                  <td>
                    <?php 
                    $pay_amount = 0;
                    $this->db->select('a.*, b.title');
                    $this->db->from('student_course a');
                    $this->db->join('course b', 'b.id = a.st_course_course_id', 'left');
                    $this->db->where('a.st_course_student_id', $student->user_id);
                    $all_course = $this->db->get()->result();
                    foreach ($all_course as $course) 
                    {
                    //   $pay_amount += $course->atp_course_price;
                    ?>
                    <span style="font-size: 14px" class="badge badge-warning mt-2"><?php echo $course->title; ?> 
                    <?php if($course->st_course_status == 0): ?>
                      <span class="badge badge-danger">AP</span>
                    <?php else: ?>
                      <span class="badge badge-success">AC</span>
                    <?php endif;?>
                    </span>
                    <?php if($course->st_course_batch == 0): ?>
                    <br/>
                    <span class="badge badge-danger">Batch Not Assign</span>
                    <br/>
                    <?php endif; ?>
                  <?php }?>

                  </td>
                  <td>
                    <?php if($student->user_status == 0): ?>
                      <span class="badge badge-warning">Admission Pending</span>
                      <br/>
                      <small>Reson : <span style="color:red">Rs. <?php echo $pay_amount; ?> Payment Due</span></small>
                      <br/>
                      <a onclick="return confirm('Are you sure?')" href="<?php echo base_url(); ?>admin/students/pay_student_admission_fee/<?php echo $student->user_id; ?>" class="btn btn-info btn-xs">Pay Now!</a>
                    <?php elseif($student->user_status == 1): ?>
                      <span class="badge badge-success">Admitted</span>
                    <?php elseif($student->user_status == 2): ?>
                      <span class="badge badge-success">Admitted</span>
                    <?php elseif($student->user_status == 3): ?> 
                      <span class="badge badge-danger">Lost</span>
                    <?php endif;?>
                  </td>
                  <td class="text-left py-0 align-middle">
                    <div class="input-group mb-3">
                      <div class="input-group-prepend">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        Action
                        </button>
                        <div class="dropdown-menu dropdown-menu-right">
                            <a class="dropdown-item" href="<?php echo base_url(); ?>admin/students/take_admission/<?php echo $student->user_id; ?>"><i class="fas fa-edit"></i>&nbsp;&nbsp;Take Admission</a>
                          <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="javascript:void(0)" onclick="openWhatsApp('<?php echo $student->user_mobile ?>')"><i class="fa fa-whatsapp"></i>&nbsp;&nbsp;Whatsapp</a>
                          <?php if($student->user_status == 1): ?>
                            <div class="dropdown-divider"></div>
                              <a class="dropdown-item" href="javascript:void(0)" onclick="print_admission_form(<?php echo $student->user_id; ?>)"><i class="fa fa-print"></i>&nbsp;&nbsp;Print Admission Form</a>
                          <?php endif; ?>
                          <div class="dropdown-divider"></div>
                              <a class="dropdown-item" href="<?php echo base_url(); ?>admin/students/re_admission/<?php echo $student->user_id; ?>"><i class="fa fa-plus"></i>&nbsp;&nbsp;Re-Admission</a>
                        </div>
                      </div>
                    </div>
                  </td>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
                </tbody>
              </table>
            </div>
          </div>
      </div><!--/. container-fluid -->
    </section>
    <!-- /.content -->
  </div>

<div class="modal fade" id="print_admission_form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">
          <button onclick="printtable()" class="btn btn-success" id="print_btn"><i class="fa fa-print"></i>&nbsp; Print</button>
        </h5>
        <button onClick="window.location.reload();" type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label for="recipient-name" class="col-form-label">Select Course</label>
          <select type="text" class="form-control" id="course_details" onchange="get_student_admission_form_data(this.value)">
            <option value="">Select</option>
          </select>
        </div>
        <input type="hidden" id="student_id" >
        <div id="printformdata"> 
          <page size="A4">
             <table class="table table-bordered">
                <tr>
                   <td colspan="3">
                      <h1 class="text-info text-center">Admission Form</h1>
                   </td>
                </tr>
                <tr>
                   <td> <span class="required">Student Full Name</span></td>
                   <td><span class="required" id="sname">Student Full Name</span></td>
                   <td rowspan="2">
                      <div class="image view view-first img-thumbnail">
                         <img height="80" width="80" id="photo" alt="photo" />
                      </div>
                   </td>
                </tr>
                <tr>
                   <td> <span class="required">Registration No</span></td>
                   <td> <span class="required" id="regno">Student Full Name</span></td>
                </tr>
                <tr>
                   <td>   <span class="required">Mobile No</span></td>
                   <td colspan="2">  <span class="required" id="mobile">Student Full Name</span></td>
                </tr>
                <tr>
                   <td>      <span class="required">Email</span></td>
                   <td colspan="2"> <span class="required" id="email">Student Full Name</span></td>
                </tr>
                <tr>
                   <td> <span class="required">Admission Date</span></td>
                   <td colspan="2">   <span class="required" id="adate">Student Full Name</span></td>
                </tr>
                <tr>
                   <td> <span class="required">Date of birth</span></td>
                   <td colspan="2"> <span class="required" id="dob">Student Full Name</span></td>
                </tr>
                <tr>
                   <td>    <span class="required">Course</span></td>
                   <td colspan="2">  <span class="required" id="crse">Student Full Name</span></td>
                </tr>
                <tr>
                   <td>  <span class="required">Course Duration</span></td>
                   <td colspan="2"> <span class="required" id="duration">Student Full Name</span></td>
                </tr>
                <tr>
                   <td>      <span class="required">ATP Name & Address</span></td>
                   <td colspan="2">
                      <p><?=strtoupper(user()->user_business_name);?> ,</p>
                      <p><?=strtoupper(user()->user_village);?> ,
                         <?=strtoupper(user()->user_taluka);?> ,
                         <?=strtoupper(user()->user_dist);?> ,
                      </p>
                      <p><?=strtoupper(user()->user_state);?> - <?=strtoupper(user()->user_pin_code);?></p>
                   </td>
                </tr>
                <tr>
                   <td> <span class="required">ATP Code</span></td>
                   <td colspan="2"><?php echo user()->user_reg_id; ?></td>
                </tr>
             </table>
             <br><br><br><br><br>
             Student Signature
             <p style="text-align:right;">For <?php echo user()->user_business_name; ?></p>
          </page>

        </div>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
function print_admission_form(e) 
{
    $.ajax({
      beforeSend: function() {
         $(".loader").show();
      },
      type: "GET",
      dataType:"JSON",
      async: true,
      url: '<?php echo base_url(); ?>/admin/students/get_course_by_student_id_for_admission_form_print/'+e,
      success: function (data) 
      {
        $('#print_admission_form').modal('show');
        $('#course_details').html(data.option);
        $('#student_id').val(e);
        $(".loader").hide();
      },
      error: function () {
        $(".loader").hide();
      }
    });
}

function get_student_admission_form_data(e) 
{
  var student_id = $('#student_id').val();
  $.ajax({
      beforeSend: function() {
         $(".loader").show();
      },
      type: "GET",
      dataType:"JSON",
      async: true,
      url: '<?php echo base_url(); ?>/admin/students/get_student_admission_form_data/'+e+'/'+student_id,
      success: function (data) 
      {
        $('#printformdata').show();
        $('#sname').html(data.sname)
        $("#photo").attr('src',"<?php echo base_url(); ?>"+data.photo);
        $('#regno').html(data.regno)
        $('#mobile').html(data.mobile)
        $('#email').html(data.email)
        $('#adate').html(data.adate)
        $('#dob').html(data.dob)
        $('#crse').html(data.crse)
        $('#duration').html(data.duration+" Months")
        $('#print_btn').show()
        $(".loader").hide();
      },
      error: function (e) {
        $(".loader").hide();
        // console.log(e.responseText)
      }
    });
}
function printtable()
{
  var table=document.getElementById("printformdata");
  var htmltoprint=''+'<style type="text/css">table {border-spacing: 0;border-collapse: collapse; width:100%; } tbody>tr>td{padding: 8px;line-height: 1.42857143;vertical-align: top; border:1px solid #ddd;}'+ 
  'thead>tr>th{padding: 8px;line-height: 1.42857143;vertical-align: top; border:1px solid #ddd;}'+
  '</style>';
  htmltoprint+=table.outerHTML;  
  newWin=window.open("");
  newWin.document.write(htmltoprint);
  newWin.print();
  newWin.close();
}
</script>
<style type="text/css">
#printformdata, #print_btn
{
  display: none;
}
</style>
