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


 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Add CV | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
  
<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();
  }
</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;}
}
</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">
          <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="">
            <div class="page-title">
              <div class="title_left">
                <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
                CV Bank &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; Add New CV
               <!--  (<?php echo $CV[0]['name'];?>) -->

                <br><br>
              </div>


            </div>
    <div class="clearfix"></div>
      <h3 style="margin-left: 15px;">Add New CV</h3>
            <div class="row">
          
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
            
                  <div class="x_content">
          
     
                    <form action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left" >
  <?php
  
  $month;
   if(!isset($_GET['cvID'])){?>
        <input type="hidden" name="action" value="add_CV" />

  <?php $month=date("m");}else {

          $query="select * from eduportal_cv_bank where cv_id =".$_GET['cvID'];
          $cvdata = $m->query($query);

          $month=$cvdata[0]['month'];
?>
              <input type="hidden" name="action" value="update_cv" />
              <input type="hidden" name="cv_id"  value="<?php echo $_GET['cvID'];?>">

  <?php } ?>        
          
        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email"> Name <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" name="name" value="<?php echo $cvdata[0]['name'];?>" class="form-control" placeholder="eg Ali ">
                        </div>

                      </div>

              <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Father Name <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">

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

                      </div>  

               <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Qualification <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">

                          <input type="text" name="qualification" value="<?php echo $cvdata[0]['qualification'];?>" class="form-control" placeholder="eg MSc Physics" >
                          
                        </div>

                      </div>

           <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Apply For Post <span class="required">*</span>
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" name="post" value="<?php echo $cvdata[0]['post'];?>" class="form-control" placeholder="eg Teaching" >
                        </div>

                      </div>            
                   

           <div class="item form-group">
                        
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Cell Number <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                         
                           <input class="form-control col-md-7 col-xs-12"  name="cell" placeholder="eg Repairing & Fixes " value="<?php echo $cvdata[0]['cell_no']; ?>">
                        </div>
                    </div>

           <?php

 
      if($cvdata[0]['expense_date']!="" && $cvdata[0]['expense_date']!=NULL ) {
        $dates=date("Y-m-d",strtotime($cvdata[0]['apply_date']));  

      }else {
        $dates=date("Y-m-d");  
      }
   
                  
                  ?>

                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email"> Apply Date <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12 ">
                          <input type="date" id="owner_email" name="Applydate" required class="form-control col-md-7 col-xs-12" value="<?php echo $dates; ?>">
                      
                    </div>
            
                      </div>


                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Month <span class="required">*</span> 
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select name="month" class="form-control" required>
                                <option>Select</option>

                  <?php
                  $query="select * from  eduportal_month_config";
                  $categories = $m->query($query);
                  foreach($categories as $category)
                  { ?>

                         <option <?php if($month==$category['Month_Id']){echo "selected";} ?>  value="<?php echo $category['Month_Id']; ?>"><?php echo $category['Month_Name']; ?></option>


                  <?php } ?>

                            </select>
                        </div>

                      </div>

                 <!-- Subject Wise Section -->


                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Subject
                          <span class="required">*</span> 
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                         <select name="subject_id" class="form-control" required>
                                <option>Select Subject</option>

                  <?php
                  $query="select * from  eduportal_subject_config where branch_id=".$_SESSION['branch'];
                  $subjects1 = $m->query($query);
                  foreach($subjects1 as $subject1)
                  { ?>

                         <option <?php if($cvdata[0]['subject_id']==$subject1['subject_id']){echo "selected";} ?>  value="<?php echo $subject1['subject_id']; ?>"><?php echo $subject1['subject']; ?></option>


                  <?php } ?>

                            </select>

                        </div>

                      </div>



                        <!-- Subject Wise Section end -->



                         <!-- Experience Wise Section  -->

                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Experience">Experience<span class="required">*</span> 
                        </label>
                        
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select name="teacher_experience" class="form-control" required>
                                <option>Select Experience</option>

                  <?php
                  $query="select * from  eduportal_teacher_experience";
                  $experiences = $m->query($query);
                  foreach($experiences as $experience)
                  { ?>

                         <option <?php if($cvdata[0]['teacher_experience']==$experience['experience_id']){echo "selected";} ?>  value="<?php echo $experience['experience_id']; ?>"><?php echo $experience['experience']; ?></option>


                  <?php } ?>

                            </select>
                        </div>

                      </div>


                        <!-- Experience Wise Section end -->

             <?php if(!isset($_GET['cvID'])){?>        
                      
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Upload CV  <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input class="form-control col-md-7 col-xs-12" name="img_file" required autocomplete="off" type="file" value="">

                        </div>
                    </div>
               <?php } else { ?>

               		<div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Upload CV  <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input class="form-control col-md-7 col-xs-12" name="img_file" autocomplete="off" type="file" value="">

                          <input type="hidden" name="old_img" value="<?php echo $cvdata[0]['upload_cv'];?>" />

                        </div>
                    </div>

              <?php } ?>


                      <div class="ln_solid" style="border-top:none;"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          
                          <button id="send" type="submit" class="btn btn-primary" >Submit</button>
                          <button type="submit" class="btn btn-primary" >Cancel</button>

                        </div>
                      </div>

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

        <!-- /page content -->



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

<?php

 $branchID=$_SESSION['branch'];
 $sql = " select * from  eduportal_cv_bank where branch_id='$branchID' ";

if (isset($_REQUEST['subject'])) {
 

 if($_REQUEST['subject']=="All"){
      $sql;
    } else {
    $sql .= " AND subject_id = '" .$_REQUEST['subject']. "' ";

    }

  if($_REQUEST['experience']=="All"){
      $sql;
    } else {
    $sql .= " AND teacher_experience = '" .$_REQUEST['experience']. "' ";

    }

    }

          
     $sql .= " order by cv_id desc ";
    //print_r($sql);

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


     ?>

     <div class="t col-md-12 col-sm-12 col-xs-12">
               <h3>Curriculum Vitae List<small> (<?php echo count($CVs);?> records)</small></h3>
     </div>              
          
      
<?php  if(isset($_SESSION['addsuccessexp'])){?>

<div id="snackbar"><script> toastFunction();</script> Your Recored is Sucessfully Added</div>

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


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


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


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

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


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Danger!</strong> Record is deleted successfully...
            </div>


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

            
<form action="cv_bank.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>">

          <div class="col-md-12">
                      
                        
            <div class="col-md-3 col-sm-12 col-xs-12">
                          <select name="subject" class="form-control"  >
                                <option value="All">All Subject</option>

                  <?php
                  $query="select * from  eduportal_subject_config where branch_id=".$_SESSION['branch'];
                  $subjects1 = $m->query($query);
                  foreach($subjects1 as $subject1)
                  { ?>

                         <option <?php if($cvdata[0]['subject_id']==$subject1['subject_id']){echo "selected";} ?>  value="<?php echo $subject1['subject_id']; ?>"><?php echo $subject1['subject']; ?></option>


                  <?php } ?>

              </select>
          </div>


          <div class="col-md-3 col-sm-2 col-xs-12">
                          <select name="experience" class="form-control"  >
                          <option value="All">All Experience</option>

                  <?php
                  $query="select * from  eduportal_teacher_experience";
                  $experiences = $m->query($query);
                  foreach($experiences as $experience)
                  { ?>

                         <option <?php if($cvdata[0]['teacher_experience']==$experience['experience_id']){echo "selected";} ?>  value="<?php echo $experience['experience_id']; ?>"><?php echo $experience['experience']; ?></option>


                  <?php } ?>

              </select>
          </div>

          
      

               <div class="col-md-4 " style="padding:20px;">
                
                    <input type="hidden" name="addaccountAdmin" value="1">

                  <button type="submit" class="btn btn-primary" style="margin-top: -21px;">Search</button>
                
                 
               
              </div> 

        </div>            
 </form>

<table id="datatable" class="table table-striped table-bordered"style="background-color: white;">
                      <thead>
                        <tr>
                          <th width="1%">S.No</th>
                          <th width="10%">Name </th>
                          <!-- <th width="10%">Father Name</th> -->
                          <th width="8%">Qualification</th>
                          <th width="10%">Apply For Post</th>
                          <th width="12%">Cell Number</th>
                          <th width="10%">Apply Date</th>
                          <th width="10%">Subject </th>
                          <th width="10%">Experience </th>
                          <th width="8%">Upload CV</th>
                          <!-- <th width="10%">Attach File</th> -->
                          <th width="20%">Action</th>
                         

                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;
$date= date("Y-m-d");

foreach($CVs as $CV){

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

  $m->where("experience_id", $CV['teacher_experience']);
  $experienceName=$m->get("eduportal_teacher_experience");


?>

<tr>

<td style="text-align:center;"><?php echo $count; $count++;?></td>

<td><?php echo $CV['name'];?></td>

<!-- <td><?php echo $CV['father_name'];?></td> -->

<td><?php echo $CV['qualification'];?></td>

<td><?php echo $CV['post'];?></td>

<td><?php echo $CV['cell_no'];?></td>

<td><?php echo date("d-M-Y",strtotime($CV['apply_date']));?></td>

<td><?php echo $subjectName[0]['subject'];?></td>

<td><?php echo $experienceName[0]['experience'];?></td>

<td>

<a class="btn btn-success" target="_blank" href="<?php echo DOMAIN.AgentDirectory;?>CV_Bank/<?php echo $CV['upload_cv'];?>">Download file</a>

</td>

<!--    <td><?php //echo $category['customer_phone'];?></td> -->
                         

          <td>

   

  <a href="cv_demo_video.php?cvID=<?php echo $CV['cv_id'];?>" style="padding: 0px 5px; font-size:14px;" class="btn btn-info">Demo Videos </a>

  <a style="padding: 0px 5px; font-size:14px;"  href="cv_bank.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&cvID=<?php echo $CV['cv_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?cvID=<?php echo $CV['cv_id'];?>&action=DeleteCv" 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>
        </div>

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

    
  <?php include('RootMe/js_linksscript.php');?>
  </body>
</html>
<script>
function toastFunction() {
  var x = document.getElementById("snackbar");
  x.className = "show";
  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>