<?php  

include ('../includes/connection.php');  
if (isset($_POST['submit'])){
$program_name = $_POST['program_name'];    
$program_cost = $_POST['program_cost'];   
$category = $_POST['category'];  
$query=mysqli_query($conn,"INSERT INTO `program_larms`(`program_name`, `category`,`program_cost`) VALUES ('$program_name','$category','$program_cost')");
  
  if($query){ 
         ?>
         <script type="text/javascript">
             alert("Program Successed Added");
         </script>
        <?php  
      }  
      else{
        ?>  
        <script type="text/javascript">
         alert("Sorry Program not Added Try Again");
        </script>
        <?php
    }  
} 

if (isset($_POST['sub_1'])){
$program_name = $_POST['program_name'];    
$program_cost = $_POST['program_cost'];   
$category = $_POST['category'];  
$query=mysqli_query($conn,"INSERT INTO `other_expenses`(`program_name`, `category`,`program_cost`) VALUES ('$program_name','$category','$program_cost')");
  
  if($query){ 
         ?>
         <script type="text/javascript">
             alert("Program Successed Added");
         </script>
        <?php  
      }  
      else{
        ?>  
        <script type="text/javascript">
         alert("Sorry Program not Added Try Again");
        </script>
        <?php
    }  
} 
?>   
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header" style="background: url('../assets/img/ban.jpg') center center; color: white;">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <a><strong>Add Examination</strong></a>
          </div> 
        </div>
      </div><!-- /.container-fluid -->
    </section>
  <br><br>
   <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row"> 
          <!-- /.col -->
          <div class="col-md-12">
            <div class="card"> 

              <div class="card-header p-2">
                <ul class="nav nav-pills ">  
                  <li class="nav-item "><a class="nav-link active" href="#program" data-toggle="tab">Program</a></li> 
                  <li class="nav-item "><a class="nav-link" href="#expenses" data-toggle="tab">Other Expenses</a></li>
                </ul>
              </div>
              <!-- /.card-header --> 
              <div class="card-body"> 
              <div class="tab-content">
              <!-- /.tab-pane -->
              <div class="active tab-pane" id="program">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-sm-12">  
                    <div class="card">
                     <div class="card-header">
                      <h3 class="card-title">Program Record & Bills</h3>
                      <div class="float-right mb-2">
                        <a data-toggle="modal" href="#add" class="btn btn-secondary btn-xs float-right ml-2" >
                            <i class="fa fa-plus"></i>  Add Program Here
                        </a>
                        </div>
                         </div> 
                         <!-- /.card-header -->
                          <div class="card-body">
                           <div class="table-responsive">
                            <table id="example1" class="table table-striped display table-bordered" >
                            <thead>  
                            <tr>
                                <th>#</th>
                                <th>Program Name</th>
                                <th>Level</th>
                                <th>Fees Per Year</th>   
                                <th>Action</th>
                            </tr>
                            </thead>
                            <tbody>
                               <?php 
                                    $i = 1;
                                   $school_query = mysqli_query($conn,"SELECT * FROM program_larms");
                                while($row = mysqli_fetch_array($school_query)){  
                             ?>  
                            <tr>
                              <td class="text-center"><?php echo $i++ ?></td>
                              <td><?php echo $row['program_name']; ?></td>
                              <td><?php echo $row['category']; ?></td>
                              <td>Tsh. <?php echo $row['program_cost']; ?> /=</td>  
                          <td>
                             <div class="btn-group">
                            <a  data-id='<?php echo $row['program_id'] ?>' href="admin.php?page=update_bill&id=<?php echo $row['program_id']; ?>" class="btn btn-primary btn-flat manage_class">
                              <i class="fas fa-edit"></i>
                            </a>
                             <a href="delete_course.php?del=<?php echo $row['program_id']; ?>" onclick="return confirm('Are you sure you want to delete?');" class="btn btn-danger btn-flat delete_student">
                              <i class="fas fa-trash"></i>
                          </a>  
                        </div> </td>

                          </tr> 
                            <?php }?>
                            </tbody>
                            <tfoot>
                            <tr>
                              <th>#</th>
                              <th>Program Name</th>
                              <th>Level</th>
                              <th>Fees Per Year</th>   
                              <th>Action</th>
                            </tr>
                          </tfoot>
                        </table>
                        <div class="modal fade" id="add">
                          <div class="modal-dialog">
                            <form method="post" action="">
                                <div class="modal-content">
                                  <div class="modal-header">
                                      <h4 class="modal-title" id="modal_title">Add Program With Fees per year</h4>
                                      <button type="button" class="close" data-dismiss="modal">&times;</button>
                                  </div>
                                  <div class="modal-body">  
                                   <div class="form-group">
                                    <label>PROGRAM NAME <span style="color: red;">*</span></label>
                                     <input type="text" name="program_name" id="program_name" class="form-control" required data-parsley-pattern="/^[a-zA-Z0-9 \s]+$/" placeholder="Enter Program Name" data-parsley-trigger="keyup" />
                                   </div> 
                                      <div class="form-group">
                                        <label>Level <span style="color: red;">*</span></label>
                                        <div class="select2-purple"> 
                                          <select class="form-control select2" name="category" data-dropdown-css-class="Select a Program" style="width: 100%;" required>  
                                          <option value="Certificate">Certificate</option>
                                          <option value="Technician Certificate">Technician Certificate</option>
                                          <option value="Ordinary Diploma">Ordinary Diploma</option>
                                        </select>
                                        </div> 
                                      </div> 
                                   <div class="form-group">
                                    <label>AMOUNT <span style="color: red;">*</span></label>
                                     <input type="text" name="program_cost" id="program_cost" class="form-control" required data-parsley-max="10000000" required data-parsley-type="integer"  data-parsley-trigger="keyup"  placeholder="Enter amount per Year"/>
                                   </div>  
                                  </div> 
                                  <div class="modal-footer">  
                                      <button type="submit" name="submit" class="btn btn-secondary">ADD</button>
                                      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                  </div>
                                </div>
                            </form>
                            </div>
                       </div><!-- /.modal -->
                       </div>
                     </div>
                    </div> <!-- end card body-->
                    </div> <!-- end card --> 
                    </div>
                  <!-- /.card -->
                  </div>
                 </div> 

            <div class="tab-pane" id="expenses">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-sm-12">  
                    <div class="card">
                     <div class="card-header">
                      <h3 class="card-title">Other Expenses</h3>
                      <div class="float-right mb-2">
                        <a data-toggle="modal" href="#prog" class="btn btn-secondary btn-xs float-right ml-2" >
                            <i class="fa fa-plus"></i>  Add Program Here
                        </a>
                        </div>
                         </div> 
                         <!-- /.card-header -->
                          <div class="card-body">
                           <div class="table-responsive">
                            <table id="example2" class="table table-striped display table-bordered" >
                            <thead>  
                            <tr>
                                <th>#</th>
                                <th>Program Name</th>
                                <th>Level</th>
                                <th>Fees Per Year</th>   
                                <th>Action</th>
                            </tr>
                            </thead>
                            <tbody>
                               <?php 
                                    $i = 1;
                                   $school_query1 = mysqli_query($conn,"SELECT * FROM other_expenses");
                                while($row1 = mysqli_fetch_array($school_query1)){  
                             ?>  
                            <tr>
                              <td class="text-center"><?php echo $i++?></td>
                              <td><?php echo $row1['program_name']; ?></td>
                              <td><?php echo $row1['category']; ?></td>
                              <td>Tsh. <?php echo $row1['program_cost']; ?> /=</td>  
                          <td>
                             <div class="btn-group">
                            <a  data-id='<?php echo $row1['program_id'] ?>' href="admin.php?page=update_expenses&id=<?php echo $row1['program_id']; ?>" class="btn btn-primary btn-flat manage_class">
                              <i class="fas fa-edit"></i>
                            </a>
                             <a href="delete_expenses.php?id=<?php echo $row1['program_id']; ?>" onclick="return confirm('Are you sure you want to delete?');" class="btn btn-danger btn-flat delete_student">
                              <i class="fas fa-trash"></i>
                          </a>  
                        </div> </td>

                          </tr> 
                            <?php }?>
                            </tbody>
                            <tfoot>
                            <tr>
                              <th>#</th>
                              <th>Program Name</th>
                              <th>Level</th>
                              <th>Fees Per Year</th>   
                              <th>Action</th>
                            </tr>
                          </tfoot>
                        </table>
                        <div class="modal fade" id="prog">
                          <div class="modal-dialog">
                            <form method="post" action="">
                                <div class="modal-content">
                                  <div class="modal-header">
                                      <h4 class="modal-title" id="modal_title">Add Program With Fees per year</h4>
                                      <button type="button" class="close" data-dismiss="modal">&times;</button>
                                  </div>
                                  <div class="modal-body">  
                                   <div class="form-group">
                                    <label>PROGRAM NAME <span style="color: red;">*</span></label>
                                     <input type="text" name="program_name" id="program_name" class="form-control" required data-parsley-pattern="/^[a-zA-Z0-9 \s]+$/" placeholder="Enter Program Name" data-parsley-trigger="keyup" />
                                   </div> 
                                    <input type="hidden" name="category" value="BOS">
                                   <div class="form-group">
                                    <label>AMOUNT <span style="color: red;">*</span></label>
                                     <input type="text" name="program_cost" id="program_cost" class="form-control" required data-parsley-max="10000000" required data-parsley-type="integer"  data-parsley-trigger="keyup"  placeholder="Enter amount per Year"/>
                                   </div>  
                                  </div> 
                                  <div class="modal-footer">  
                                      <button type="submit" name="sub_1" class="btn btn-secondary">ADD</button>
                                      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                  </div>
                                </div>
                            </form>
                            </div>
                       </div><!-- /.modal -->
                       </div>
                     </div>
                    </div> <!-- end card body-->
                    </div> <!-- end card --> 
                    </div>
                  <!-- /.card -->
                  </div>
                 </div> 


                </div>
                <!-- /.tab-content -->
             </div><!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <script src="../stp_con/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../stp_con/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="../stp_con/datatables/jquery.dataTables.min.js"></script>
<script src="../stp_con/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../stp_con/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../stp_con/jszip/jszip.min.js"></script> 
<script src="../stp_con/pdfmake/pdfmake.min.js"></script>
<script src="../stp_con/pdfmake/vfs_fonts.js"></script> 
<script src="../stp_con/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.colVis.min.js"></script>
 
<script src="../assets/js/adminlte.min.js"></script>   
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": true, "paging": true, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)'); 
  });
</script>  
<script>
  $(function () {
    $("#example2").DataTable({
      "responsive": true, "lengthChange": true, "paging": true, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)'); 
  });
</script>