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

$pageName = basename($_SERVER['PHP_SELF']);

 $m->where("page_name", $pageName);
 $pageNameAccess=$m->get("eduportal_modules_pages_detail");


$m->where("user_id", $_SESSION['user_id']);
$m->where ("branch_id", $_SESSION['branch']);
$m->where("page_id", $pageNameAccess[0]['page_id']);
$access = $m->get("users_privilege_detail");


$sql = " select * from  eduportal_school_periods_details where branch_id=".$_SESSION['branch']." order by period_details_id asc";

$WorkAssignListings = $m->query($sql);




?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Period Details | EduPortal</title>
    <?php include('RootMe/css_links.php');?>



   
  </head>

  <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="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
            Manage Period 
          <br><br>
          
          <div class="row" style="background-color: white;">
           
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">


          
          <?php  if(isset($_SESSION['Upsuccess'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> One record is updated successfully...
            </div>


          <?php  unset($_SESSION['Upsuccess']); }?>

  

          
    
          <?php  if(isset($_SESSION['error_msg'])){?>

          <div class="col-md-10">

             <div id="error"  class="alert alert-warning alert-dismissible">
                      <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
                       <strong>Warning !</strong> You have already saved the challan of this month !!!
              </div>

           </div>

         <?php  unset($_SESSION['error_msg']); }?>

        





<div style="float:left;" class="col-md-6">

 
    <table  class="table table-striped table-bordered" style="width:100%">
          
          <thead>
            <tr>
                <th width="10%"   style="text-align:center;">S.No</th>
                <th width="20%">Period</th>
                <th width="20%">Period Title</th>
                <th width="15%">Start Time</th>
                <th width="15%">End Time</th>
                <th width="15%"> Action </th>

            </tr>
        </thead>
        <tbody>


   
     
     <?php 

     $count=1;

      foreach($WorkAssignListings as $WorkAssignListVal)
      { 

        $m->where("category_period_id", $WorkAssignListVal['period_id']);
        $period=$m->get("eduportal_periods_category");

        $m->where("subject_id", $WorkAssignListVal['subject_id']);
        $subject=$m->get("eduportal_subject_config");

        $m->where("session_id", $WorkAssignListVal['session_id']);
        $session=$m->get("edu_session_config");
        
      ?>

        <tr>
              <td  style="text-align:center;"><?php echo $count;  $count++;?></td>
              <td> <?php echo $period[0]['period_title'];?></td>
              <td> <?php echo $WorkAssignListVal['period_details_title'];?></td>
              <td> <?php echo $WorkAssignListVal['period_start'];?></td>
              <td> <?php echo $WorkAssignListVal['period_end'];?></td>

            

              <td>

                <?php if ($access[0]['edit_access']!=NULL) { ?>

              <a data-toggle="modal" data-target="#EditPeriodDetail<?php echo $WorkAssignListVal['period_details_id'];?>" style="padding: 0px 5px; font-size:14px;" href="#" class="btn btn-success">
                 <i class="fa fa-pencil" aria-hidden="true"></i>
                 </a>

               <?php } ?>


                  <?php if ($access[0]['delete_access']!=NULL) { ?>

            <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?PeriodCat=<?php echo $WorkAssignListVal['period_details_id'];?>&action=DeletePeriodDetails" 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>

          <?php } ?>
            

            <!-- Employee Edit Salary Popup start -->


      <div id="EditPeriodDetail<?php echo $WorkAssignListVal['period_details_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header" style="border-bottom:none;">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title" style="text-align:center;"> Edit (<?php echo $period[0]['period_title']." - ".$WorkAssignListVal['period_details_title']; ?>)  </h4>
            </div>

            <div class="modal-body">

<form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post"  enctype="multipart/form-data">

           <input type="hidden" name="action" value="EditCreatePeriodDetails"> 
           <input type="hidden" id="date"  name="month" value="<?php echo $_GET['month']; ?>" />
           <input type="hidden" id="date"  name="session" value="<?php echo $_GET['session']; ?>" />
           <input type="hidden" id="date"  name="period_details_id" value="<?php echo $WorkAssignListVal['period_details_id']; ?>" />
         
         
                         
                         

                <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  Period Title </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $WorkAssignListVal['period_details_title'];?>"  class="form-control field" id="" name="period_details_title"/>
                      </div>
                </div>

                 <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  Start Time </label>
                          <input style="height:40px;padding-left:1%;" type="text" value="<?php echo $WorkAssignListVal['period_start'];?>"  class="form-control field" id=""  name="period_start"/>
                      </div>
                </div>

                 <div class="col-md-12" >
                      <div class="form-group" >
                        
                        <label>  End Time </label>
                          <input style="height:40px;padding-left:1%;" type="text" id=""  value="<?php echo $WorkAssignListVal['period_end']; ?>"  class="form-control field" name="period_end" />
                      </div>
                  </div>



            <div class="modal-footer">

            <button type="submit" style="margin: 30px;" class="btn btn-primary" name="submit" >Submit </button>
              


            </div>


                 </form>

          </div>

          </div>

        </div>
      </div>

      <!-- Employee Edit Salary popup ending -->

         
                  </td>




              </tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>


</div>




<div style="float:left;" class="col-md-6">

    <table style="width:100%">
          
         <tr>
          <td width="100%" style="padding-left:2%; padding-right:2%;" >



        <form class="form-style-7" action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data">
              
              <input type="hidden" name="action" value="CreatePeriodDetails">
              <div class="form-group col-xs-12">

                  <div class="form-group" >
                            
                            <label> Period Categories </label>
                              <select name="Periodcat" class="form-control"  >
                                <option value="">Select</option>

                  <?php
                  $m->where("branch_id", $_SESSION['branch']);
                  $query="select * from eduportal_periods_category";
                  $WorkAssignList = $m->query($query);
                  foreach($WorkAssignList as $WorkAssignListVal)
                  { ?>

                         <option <?php if($contact[0]['cat_id']==$WorkAssignListVal['category_period_id']){echo "selected";} ?>  value="<?php echo $WorkAssignListVal['category_period_id']; ?>"><?php echo $WorkAssignListVal['period_title']; ?></option>


                  <?php } ?>

                            </select>
                         </div>

                          
<?php

for($j=0;$j<11;$j++)
{ 

?>
                <div class="row" style="padding: 0.5%;margin: 0.5%;" >   

                     <div class="col-md-4 col-sm-12 col-xs-12 marginm" style="padding: 0px 2px 0px 2px;">
                      <div class="form-group" id="c<?php echo $j; ?>">
                                
                      <input type="text" class="form-control" name="title[]"  autocomplete="off" id="ref" placeholder="Period Title" />
           
                    </div>
                     </div>


                    <div class="col-md-4 col-sm-12 col-xs-12 marginm" style="padding: 0px 2px 0px 2px;" >
                      <div class="form-group"  id="fname<?php echo $j; ?>">
                        
                       <input type="text" autofocus  autocomplete="off" placeholder="Period Start"  name="start[]" id="txt_first_name" onkeypress='return alpha(event);'  maxlength="100" class="form-control" />

                      </div>
                    </div>

                   <div class="col-md-4 col-sm-12 col-xs-12 marginm" style="padding: 0px 2px 0px 2px;">

                    <div class="form-group" >
                      
                    <input type="text" name="end[]"  autocomplete="off"  id="txt_last_name" value="" onkeypress='return alpha(event);'   maxlength="100" placeholder="Period End" class="form-control"/>

                      </div>
                    </div>
         
             
</div>
<?php } ?>
                  
                  <div class="clearfix"></div>
              
                  <input type="submit" class="btn btn-primary" value="Save Period" >
              
              </div>

        </form>



                </td>
                
          </tr>
        
  </table>


</div>



    <br><br>


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

           
          </div>
        </div>

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

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