<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
             <?php
               echo isset($title) ? $title : NULL;
             ?>
          </h1>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-lg-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                          <h3 class="box-title">Add a New Employee</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        
                        <?php
                        if(isset($message))
                        {
                            echo $message;
                        }
                        ?>
                        <form role="form" method="post" enctype="multipart/form-data">
                          <div class="box-body">
                            <div class="form-group">
                              <label for="exampleInputEmail1">Employee Name</label>
                              <input type="text" name="name" value="<?php if(isset($_POST['name'])){echo $_POST['name'];} ?>" class="form-control" id="" placeholder="Enter Employee Name">
                            </div>
                            
                            <div class="form-group">
                              <label for="exampleInputEmail1">Email Address</label>
                              <input type="email" name="email" value="<?php if(isset($_POST['email'])){echo $_POST['email'];} ?>" class="form-control" id="" placeholder="Enter Employee Email Address">
                            </div>
                            <div class="form-group">
                              <label for="exampleInputEmail1">Phone</label>
                              <input type="text" name="phone" value="<?php if(isset($_POST['phone'])){echo $_POST['phone'];} ?>" class="form-control" id="" placeholder="Enter Employee Phone">
                            </div>  
                            <div class="form-group">
                              <label for="">Employee Birth Date</label>
                              <input type="text" name="birth_date" value="<?php if(isset($_POST['birth_date'])){echo $_POST['birth_date'];} ?>" class="form-control datePickerInput" id="" placeholder="Enter Employee Birth Date">
                            </div> 
                               
                            <div class="form-group">
                              <label for="exampleInputEmail1">Address</label>
                              <input type="text" name="address" value="<?php if(isset($_POST['address'])){echo $_POST['address'];} ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Employee Address">
                            </div> 
                            <div class="form-group">
                              <label for="availability" class="set-block">Gender</label>
                              <div class="radio radio-info  radio-inline">
                                 <input type="radio" id="inlineRadio3" value="1" name="gender" checked="">
                                 <label for="inlineRadio3"> Male </label>
                              </div>
                              <div class="radio radio-info  radio-inline">
                                 <input type="radio" id="inlineRadio4" value="2" name="gender">
                                 <label for="inlineRadio4"> Female </label>
                              </div>
                           </div> 
                            <div class="form-group">
                              <label for="exampleInputEmail1">Fixed Salary</label>
                              <input type="text" name="fixed_salary" value="<?php if(isset($_POST['fixed_salary'])){echo $_POST['fixed_salary'];} ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Fixed Salary">
                            </div> 
                            <div class="form-group">
                              <label for="exampleInputEmail1">Fixed Commission</label>
                              <input type="text" name="fixed_commision" value="<?php if(isset($_POST['fixed_commision'])){echo $_POST['fixed_commision'];} ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Fixed Commission">
                            </div> 
                            <div class="form-group">
                              <label for="exampleInputFile">Profile Picture</label>
                              <input type="file" name="profile_picture" id="exampleInputFile">
                              <p class="help-block">Upload Profile Picture.</p>
                            </div> 
                             <div class="form-group">
                              <label for="exampleInputEmail1">Social Security Number</label>
                              <input type="text" name="ssn" value="<?php if(isset($_POST['ssn'])){echo $_POST['ssn'];} ?>" class="form-control" id="exampleInputEmail1" placeholder="Enter Ssn">
                            </div>
                            <div class="form-group">
                              <label for="exampleInputFile">Ssn image</label>
                              <input type="file" name="ssn_image" id="exampleInputFile">
                              <p class="help-block">Upload Ssn Picture.</p>
                            </div>  
                            <div class="form-group">
                              <label for="exampleInputEmail1">Snapshot</label>
                                <textarea name="snapshot" class="form-control"></textarea>
                            </div> 
                             
                            <div class="form-group">
                              <label for="exampleInputPassword1">Password</label>
                              <input type="password" name="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
                            </div>
                            <div class="form-group">
                              <label for="exampleInputPassword1">Confirm Password</label>
                              <input type="password" name="repassword" class="form-control" id="" placeholder="Re-Type Password">
                            </div>    
                             <div class="form-group">
                              <label for="exampleInputEmail1">Admin Type</label>
                                <select name="admin_type" id="admin_type" class="form-control">
                                    <option value="0">Select Admin Type</option>
                                    <?php
                                        if (is_array($adminTypes) && count($adminTypes)>0){
                                            foreach ($adminTypes as $type):
                                                echo '<option value="'.$type['id'].'">'.$type['type'].'</option>';
                                            endforeach;
                                        }else{
                                            echo '<option value="">There Is No Types</option>';
                                        }
                                    ?>
                                </select>    
                            </div>  
                              
                             
                            <div class="form-group">
                              <label for="availability" class="set-block">Status</label>
                              <div class="radio radio-info  radio-inline">
                                 <input type="radio" id="inlineRadio1" value="1" name="status" checked="">
                                 <label for="inlineRadio1"> Active </label>
                              </div>
                              <div class="radio radio-info  radio-inline">
                                 <input type="radio" id="inlineRadio2" value="2" name="status">
                                 <label for="inlineRadio2"> Not Active </label>
                              </div>
                           </div>  
                              
                              
                          </div>
                          <!-- /.box-body -->

                          <div class="box-footer">
                            <button type="submit" name="add" class="btn btn-primary">Add</button>
                          </div>
                        </form>
                      </div>
                      <!-- /.box -->
                </div>
            </div>
      </section><!-- /.content -->
</div><!-- /.content-wrapper -->
    <script type="text/javascript">
        $(document).ready(function(){
            // get all governate's
            $("#country").change(function(){
                // get country id
                var countryId  = $(this).val();
                $.ajax({
                    url:'<?php echo BASE_URL."governate/retreive_all_governates_by_country_id" ?>',
                    type: 'POST',
                    data:{country_id: countryId},
                    success:function(result){
                        if(result == null || result == "null" || result == false) {
                            $("#governate").html("<option value=''>there's no governates </option>");
                        }else{
                            // remove all childes 
                             $("#governate").empty();
                            var responseData = JSON.parse(result);
                            if(responseData['status'] == "success")
                            { 
                                var text = "<option value='0'>Select Governate</option>";
                                for(i = 0; i< responseData['governates'].length;i++)
                                {
                                    text += '<option value="'+responseData['governates'][i]['id']+'">'+responseData['governatesEn'][i]['name']+'</option>';	
                                }
                                $("#governate").html(text);
                            }else{
                                $("#governate").html("<option value='0'>No Data Found</option>");
                            }
                            
                        }
                    }
                });
            });
            
             // get all cites's
            $("#governate").change(function(){
                // get country id
                var governateId  = $(this).val();
                $.ajax({
                    url:'<?php echo BASE_URL."city/retreive_all_cities_by_governate_id" ?>',
                    type: 'POST',
                    data:{governate_id: governateId},
                    success:function(result){
                        if(result == null || result == "null" || result == false) {
                            $("#city").html("<option value=''>there's no Cities </option>");
                        }else{
                            // remove all childes 
                             $("#city").empty();
                            var responseData = JSON.parse(result);
                            if(responseData['status'] == "success")
                            { 
                                var text2 = "<option value='0'>Select Governate</option>";
                                for(i = 0; i< responseData['cities'].length;i++)
                                {
                                    text2 += '<option value="'+responseData['cities'][i]['id']+'">'+responseData['citiesEn'][i]['name']+'</option>';	
                                }
                                $("#city").html(text2);
                            }else{
                                $("#city").html("<option value='0'>No Data Found</option>");
                            }
                            
                        }
                    }
                });
            });
            
            
        });
    </script>
