<style>
hr {
    height: 5px;
    color: #028482;
    background: #028482;
    font-size: 0;
    border: 0;
}
</style>
              <!--Select2 css-->
    <link href="<?php echo base_url();?>assets/css/select2.min.css" rel="stylesheet" />
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
                <div class="title_left">
                </div>
            </div>
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Edit Teacher</h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">

            
                    <form class="form-horizontal form-label-left" action="<?php echo $base_url;?>teacher/update" id="routePermit" method="post" enctype="multipart/form-data">

                      <?php if($this->user_model->is_super()){ ?>
             <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Branch <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="branch" class="form-control col-md-7 col-xs-12" name="branch" >
                            <option value=''>Select Branch</option>
                      <?php
                            foreach ($branch as $value) {
                      ?>
                            <option value="<?php echo $value['id']; ?>"><?php echo $value['name']?></option>

                      <?php } ?>
                          </select>
                        </div>
                      </div>
                      <?php  }else{$branch=$this->user_model->getbranch();?>
                          <input id="branch" name="branch" type="hidden" value="<?= $branch ?>">
                      <?php  } ?>
                      
                       <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Department 
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="dpt" class="form-control col-md-7 col-xs-12" name="dpt">
                              <option value="">Select Department</option>
                              <?php 
                                  foreach ($department as $key => $val) {?>
                                     <option value="<?php echo $val['id']?>" <?php if($val['id']==$values['dpt']){ echo "selected";}?>><?php echo $val['name'];?></option>
                               <?php }?>
                          </select>
                        </div>
                      </div>
                      
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">First Name <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="firstname" class="form-control col-md-7 col-xs-12 abc" value="<?php echo $values['firstname'];?>"   name="firstname" placeholder="First Name"  type="text">
                        </div>
                      </div>
                      
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Last Name <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="lastname" class="form-control col-md-7 col-xs-12 abc" value="<?php echo $values['lastname'];?>" name="lastname" placeholder="Last Name"  type="text">
                        </div>
                      </div>
                      
                      
                   <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Incharge
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="incharge" class="form-control col-md-7 col-xs-12" name="incharge">
                              <option value="">Select Class</option>
                             <?php
                                  foreach ($class  as $key => $value) {?>
                                    <option value="<?php echo $value['class_id']?>" <?php if($value['class_id']==$values['class_incharge']){ echo "selected";}?>><?php echo $value['class_name'];?></option>
                               <?php   }
                               ?>
                          </select>
                        </div>
                      </div>
                      
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Picture
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
	                  <!--  <?php
	                        $pic = array(
	                        'name' => 'img',
	                        'id' => 'pic', 
	                        'required' => 'false', 
	                        'class'=> 'form-control col-md-7 col-xs-12',
	                        );

	                        echo form_upload($pic);  
	                    ?> -->
	                   <td> <img src="<?php echo base_url().$values['img']; ?>" width="70px" height="70px"> </td>
	                    <input id="img" name="img" class="form-control col-md-7 col-xs-12" type="file">
	                    
	                    <input id="img" name="id" class="form-control col-md-7 col-xs-12" type="hidden">
	                    
                      </div>
                      </div> 
                      
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="contact">ID No
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="cnic" name="cnic" value="<?php echo $values['cnic'];?>"  class="form-control col-md-7 col-xs-12 num" placeholder="Contact Number" pattern="\d{4}\d{4}" title="12345678 (8 numbers)">
                        </div>
                      </div>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="contact">Contact No
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="contact" name="contact"  value="<?php echo $values['contact'];?>"  class="form-control col-md-7 col-xs-12" placeholder="Contact Number" pattern="[\+]\d{2}\d{4}\d{6}" title='Phone Number Format:+2543027566364'>
                        </div>
                      </div>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_head">Gross Salary<span class="required">(Salary can be edited)</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="salery" max="1000000" class="form-control col-md-7 col-xs-12 num" value="<?php echo $values['salery'];?>" data-validate-length-range="6" data-validate-words="2" name="salery" placeholder="Salery"  type="number">
                        </div>
                      </div>
                     <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_head">Increments
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input  class="form-control col-md-7 col-xs-12 num" value="<?php echo $increment;?>"  placeholder="Salery" type="number">
                        </div>
                      </div>
                        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_head">Security
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="security" class="form-control col-md-7 col-xs-12 num"  max="100000" name="security" value="<?php echo $values['security'];?>" placeholder="Security" type="number">
                        </div>
                      </div>
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_h_contact">Designation <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="designation" name="designation" value="<?php echo $values['designation'];?>"   class="form-control col-md-7 col-xs-12 abc" placeholder="Designation" title="Only alphatatic character">
                        </div>
                      </div>

                        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="b_h_contact">Qualification<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="qualification" name="qualification"  value="<?php echo $values['qualification'];?>" data-validate-minmax="10,100" class="form-control col-md-7 col-xs-12 abc" placeholder="Qualification">
                        </div>
                      </div>

                      <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Specialization<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="specialization" type="text" name="specialization" placeholder="Specialization" value="<?php echo $values['specialization'];?>" class="form-control col-md-7 col-xs-12 abc"   title="Only alphatatic character">
                        </div>
                      </div>
                        <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Seniority Level<span class="text-danger">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="sen_lev" type="number" name="sen_lev" placeholder="Seniority Level" min=0 class="form-control col-md-7 col-xs-12  num"  value="<?php echo $values['s_level'];?>">
                        </div>
                      </div>
                      
                      <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Date of Birth<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="dob" type="text" name="dob"  placeholder="Date of Birth"  value="<?php echo date('d-m-Y',strtotime($values['dob']));?>" class="form-control col-md-7 col-xs-12 datepicker">
                        </div>
                      </div>
                      <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Date of joining<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="doj" type="text" name="doj" placeholder="Date of joining" value="<?php echo date('d-m-Y',strtotime($values['doj']));?>" class="form-control col-md-7 col-xs-12 datepicker">
                        </div>
                      </div>
                      <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Address</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <textarea id="address"  name="address" placeholder="Address" class="form-control col-md-7 col-xs-12"><?php echo  $values['address'];?></textarea>
                        </div>
                      </div>
                         <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Bank Name</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="bank" type="text" name="bank" placeholder="Bank Name" value="<?php echo $values['bank'];?>" class="form-control col-md-7 col-xs-12 abc"   title="Only alphatatic character">
                        </div>
                      </div>
                       <div class="item form-group">
                        <label for="account" class="control-label col-md-3"> Account Number</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="account" type="text" name="account" onkeypress="return ((event.charCode > 47 && event.charCode < 58) || event.charCode == 45  );" placeholder="999-9999999999999-99" class="form-control col-md-7 col-xs-12" value="<?php echo $values['account'];?>" >
                        </div>
                      </div>


                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          <input id="id" class="form-control col-md-7 col-xs-12" value="<?php echo $values['id'];?>" data-validate-length-range="6" data-validate-words="2" name="id" value="<?php echo $values['id'];?>" required="required" type="hidden">

                          <button id="send" type="submit" class="btn btn-success pull-right">Update</button>
                        </div>
                      </div>
                    </form>
                    <br>
                    <h2>Update Profile</h2>
                    <hr>
                    <form class="form-horizontal form-label-left" action="<?php echo $base_url;?>teacher/update_profile" method="post" enctype="multipart/form-data">
                      
                       <?php if($this->user_model->is_super()){ ?>
             <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Branch <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select id="branch" class="form-control col-md-7 col-xs-12" name="branch" required="required">
                            <option value=''>Select Branch</option>
                      <?php
                            foreach ($branch as $value) {
                      ?>
                            <option value="<?php echo $value['id']; ?>"><?php echo $value['name']?></option>

                      <?php } ?>
                          </select>
                        </div>
                      </div>
                      <?php  }else{$branch=$this->user_model->getbranch();?>
                          <input id="branch" name="branch" type="hidden" value="<?= $branch ?>">
                      <?php  } ?>
                      
                     <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">First Name <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 abc" value="<?php echo $values['firstname'];?>"   name="firstname" placeholder="First Name" required="required" type="text">
                        </div>
                      </div>
                      
                      <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Last Name <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 abc" value="<?php echo $values['lastname'];?>" name="lastname" placeholder="Last Name" required="required" type="text">
                        </div>
                      </div>
                      
                         <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">User Name <span class="text-danger">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="u_name" class="form-control col-md-7 col-xs-12"  name="u_name" placeholder="User Name" required="required"  value="<?php echo $admin['username'];?>" type="text" >
                        </div>
                        <p id="status"></p>
                      </div>
                      
                       <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Password <span class="text-danger">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="u_pass" class="form-control col-md-7 col-xs-12"  name="u_pass" placeholder="Password" required="required" type="password" >
                        </div>
                      </div>
                      
                       <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Email<span class="text-danger">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input id="u_mail" class="form-control col-md-7 col-xs-12"  name="u_mail" placeholder="User Email" required="required" value="<?php echo $admin['email'];?>"  type="email" >
                        </div>
                      </div>
                      
                        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="contact">Contact No <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text"  name="contact" required="required" value="<?php echo $values['contact'];?>"  class="form-control col-md-7 col-xs-12" placeholder="Contact Number" pattern="[\+]\d{2}\d{4}\d{6}" title='Phone Number Format:+923027566364'>
                        </div>
                      </div>
                    
                      
                        <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                          <input id="id" class="form-control col-md-7 col-xs-12" value="<?php echo $values['id'];?>" data-validate-length-range="6" data-validate-words="2" name="id" value="<?php echo $values['id'];?>" required="required" type="hidden">

                          <button id="send2" type="submit" class="btn btn-success pull-right">Update</button>
                        </div>
                      </div>
                     </form> 
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

        

    <!-- jQuery -->
    <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/select/js/select2.min.js"></script>
        <script src="<?php echo base_url(); ?>assets/js/datepicker/daterangepicker.js"></script>
 
<!-- Jquery UI-daterangepicker -->
    
<script src="<?php echo base_url(); ?>assets/vendors/datepicker/jquery-ui.min.js"></script>
    <!-- Form Validator -->
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/bootstrapValidator.js"></script>
<!-- Form Validator-->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/bootstrapValidator.css"/>
    
  <script>
    $('#dpt').select2({
        allowClear:true
    });
    $('#incharge').select2({
        allowClear:true
    });
</script>
 
<script type="text/javascript">
    $(document).ready(function() {
    $("#u_name").keyup(function(){
      var name = $(this).val();
      var id=$('#id').val();
      $.get("<?php echo $base_url; ?>Teacher/admin_nameids/"+name+"/"+id,{},function(ret){
            if(ret==1)
            {
                 $("#status").text("Username already exist.");
                 $("#send2").attr("disabled", "disabled");
            }else
            {
                 $("#status").text("");
                 $("#send2").removeAttr("disabled");
            }
          });
    });
    
        $('#routePermit')
            .on('init.form.bv', function(e, data) {
                //console.log(data);
            })
            .bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    firstname: {
                        trigger:'blur',
                        validators: {
                            notEmpty: {
                                message: 'The firstname is required'
                            }
                        }
                    },
                     designation: {
                        trigger:'blur',
                        validators: {
                            Empty: {
                                message: 'The designation is required'
                            }
                        }
                    },
                    qualification: {
                        trigger:'blur',
                    },
                    specialization: {
                        trigger:'blur',
                        validators: {
                            notEmpty: {
                                message: 'The specialization is required'
                            }
                        }
                    },
                    address: {
                        trigger:'blur',
                    },
                     security: {
                        trigger:'blur',
                    },
                      
                     password: {
                        trigger:'blur',
                        validators: {
                            notEmpty: {
                                message: 'The password is required'
                            }
                        }
                    },
                     lastname: {
                        trigger:'blur',
                        validators: {
                            notEmpty: {
                                message: 'The lastname is required'
                            }
                        }
                    },
                    salery: {
                        message: 'The salary is not valid',
                         trigger:'blur',
                        validators: 

                        {
                            notEmpty: {
                                message: 'The salary is required'
                            },
                         //      regexp: {
                         //    regexp: /^[0-9]{10}$/,
                         //     message: 'Plz Enter 10 Digit Number'
                         // },
                       
                            
                        }
                    },

                
                contact: {
                                    validators: {
                                        notEmpty: {
                                            message: 'The contact is required and cannot be empty'
                                        },
                                        
                                    }
                                },

                    'phone[]': {
                      
                    trigger:'blur',
                validators: {
                    
                         stringLength: {
                            min: 10,
                            max: 12,
                            message: 'The phone number must be  +254XXXXXXXX'
                        }
                    
                                  // callback: {
                    //     callback: function(value, validator, $field) {
                    //         var $phone          = validator.getFieldElements('phone[]'),
                    //             numphone        = $phone.length,
                    //             notEmptyCount    = 0,
                    //             obj              = {},
                    //             duplicateRemoved = [];

                    //         for (var i = 0; i < numphone; i++) {
                    //             var v = $phone.eq(i).val();
                    //             if (v !== '') {
                    //                 obj[v] = 0;
                    //                 notEmptyCount++;
                    //             }
                    //         }

                    //         for (i in obj) {
                    //             duplicateRemoved.push(obj[i]);
                    //         }

                    //         if (duplicateRemoved.length === 0) {
                    //             return {
                    //                 valid: false,
                    //                 message: 'Phone Number is required'
                    //             };
                    //         } else if (duplicateRemoved.length !== notEmptyCount) {
                    //             return {
                    //                 valid: false,
                    //                 message: 'The phone no must be unique, cannot duplicate'
                    //             };
                    //         }

                    //         validator.updateStatus('phone[]', validator.STATUS_VALID, 'callback');
                    //         return true;
                    //     }
                   
                       
                //  },
                   // remote: {
                    //     url: 'existphonecustomer',
                    //     // Send { email: 'its value', username: 'its value' } to the back-end
                    //     data: function(validator, $field, value) {
                    //         var phone=validator.getFieldElements('phone[]').val();
                    //         console.log(phone);
                    //         return {
                    //             phone: phone
                    //         };
                    //     },
                    //     message: 'This phone number is already exist',
                    //     type: 'POST'
                    // }
                }
            },

                     cnic: {
                    trigger:'blur',
                validators: {
                     notEmpty: {
                             message: 'The cnic is required'
                         },
                         stringLength: {
                            min: 8,
                            max: 8,
                            message: 'The id must be 8 digit'
                        },
                    
                }
            },

                    email: {
                                    validators: {
                                        notEmpty: {
                                            message: 'The email address is required and cannot be empty'
                                        },
                                        emailAddress: {
                                            message: 'The email address is not valid'
                                        }
                                    }
                                },
            
            
        

                    address: {
                         trigger:'blur',
                        validators: {
                            notEmpty: 
                        }
                    },

                    contactname: {
                         trigger:'blur',
                        validators: {
                            notEmpty: {
                                message: 'The Contact Person Name is required'
                            }
                        }
                    },


                   
                }
            });
    });
    
  
    
$("#zzz").click(function(){
   $('#routePermit').bootstrapValidator("resetForm",true);    
});

$( "#dob" ).keydown(function(e) {
  e.preventDefault();
});
$( "#doj" ).keydown(function(e) {
  e.preventDefault();
});
</script>


<script>
    
     
$(document).ready(function(){
  
           $('.DMY').daterangepicker({
    
  		format: 'DD-MM-YYYY'
    
	});
        // $("#myModal").modal({
  
          // backdrop: 'static',
         
   // keyboard: false
    // });
        });

 $( function() {
 
   $( ".datepicker" ).datepicker({
	 dateFormat: 'd-m-yy' 
	}).val();
  
	} );
  
</script>

<script>
$(".num").on("keypress", function (e) {
          
            var evt = (e) ? e : window.event;
            var charCode = (evt.keyCode) ? evt.keyCode : evt.which;
            if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                return false;
            }
            return true;
        });
</script>

    <?php
  $this->load->view('footer');
?>