
<div class="page-content">
    
    
<div class="row">

    <div class="col-xs-12 col-sm-12">
        <div class="widget-box">
            <div class="widget-header" style="height:70px;">
                <h4  style="text-align:center; color:green;"><b> Edit Your Profile </b> </h4>
            </div>
            <h3 style="text-align:center; color:green;" id="hellow"></h3>
            
            <div class="widget-body ">
            
                 <?php
                                $message = $this->session->userdata('message');
                                if (!empty($message)) {
                                    ?>
                                    <div class="alert alert-block alert-success">
                                        <h6 class="lighter arial green" style="text-align:center;"><b>
                                                <?php echo $message;
                                                $this->session->unset_userdata('message');
                                                ?>
                                            </b></h6>
                                    </div>  
                                    <?php
                                }
                                $errormessage = $this->session->userdata('errormessage');
                                if (!empty($errormessage)) {
                                    ?>
                                    <div class="alert alert-block alert-danger">
                                        <h6 class="lighter arial red" style="text-align:center;"><b>
                                                <?php echo $errormessage;
                                                $this->session->unset_userdata('errormessage');
                                                ?>
                                            </b></h6>
                                    </div> 
                                    <?php
                                }
                                ?>
                <div class="widget-main no-padding ">
                    <form id="frmchange_profile" action="" method="post" enctype="multipart/form-data">
                        <!-- <legend><?php //echo admin_url()?>/employeesetup/update_employee</legend> -->
                        
                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> National Id </label>
                            <?php //echo form_error('data[nationalId]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <input type="text" id="nationalId" name="data[nationalId]" value="<?php if(!empty($employeeByid['nationalId'])) {echo $employeeByid['nationalId']; }?>" placeholder="nationalId" class="col-xs-4 col-sm-4" />
                           <input type="hidden" id="userId" name="data[userId]" value="<?php if(!empty($employeeByid['userId'])) {echo $employeeByid['userId']; }?>"  class="col-xs-4 col-sm-4" />
                           <span id="nationalId" style="color: rgb(255, 0, 0);"></span>
                        </fieldset>

                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> Mobile </label>
                             <div style="color: rgb(255, 0, 0);" id="mobile"></div> 
                            <?php //echo form_error('data[mobile]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <input  type="text" id="mobile" name="data[mobile]" value="<?php if(!empty($employeeByid['mobile'])) {echo $employeeByid['mobile']; }?>" placeholder="mobile" class="col-xs-4 col-sm-4" />
                           <span id="mobile" style="color: rgb(255, 0, 0);"></span>
                        </fieldset>
                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> Email </label>
                            <?php //echo form_error('data[email]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <input type="text" id="email" name="data[email]" value="<?php if(!empty($employeeByid['email'])) {echo $employeeByid['email']; }?>" placeholder="email" class="col-xs-4 col-sm-4" />
                           <span id="email" style="color: rgb(255, 0, 0);"></span>
                        </fieldset>

                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2">Gender </label>
                            <?php //echo form_error('data[gender]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <select name="data[gender]" id="gender" class="col-xs-3 col-sm-3">
                                    
                                <?php foreach(getGender() as $key=>$value){?>
                                    <option value="<?php echo $key?>" <?php echo ($employeeByid['gender'] == $key) ? "Selected" : ""; ?>>
                                        <?php echo $value;?>
                                    </option>
                                <?php }?>
                                 <span id="gender" style="color: rgb(255, 0, 0);"></span>
                            </select>
                           
                        </fieldset>

                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> Religion </label>
                            <?php echo form_error('data[religion]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <select name="data[religion]" id="religion" class="col-xs-3 col-sm-3">
                                    
                                <?php foreach(getReligion() as $key=>$value){?>
                                    <option value="<?php echo $key?>" <?php echo ($employeeByid['religion'] == $key) ? "Selected" : ""; ?>>
                                        <?php echo $value;?>
                                    </option>
                                <?php }?>
                            </select>
                           <span id="religion" style="color: rgb(255, 0, 0);"></span>
                        </fieldset>

                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> Father name </label>
                            <?php //echo form_error('data[fatherName]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <input type="text" id="fatherName" name="data[fatherName]" value="<?php if(!empty($employeeByid['fatherName'])) {echo $employeeByid['fatherName']; }?>" placeholder="fatherName" class="col-xs-4 col-sm-4" />
                           <span id="motherName" style="color: rgb(255, 0, 0);"></span>
                        </fieldset>

                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> Mother name </label>
                            <?php //echo form_error('data[motherName]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <input type="text" id="motherName" name="data[motherName]" value="<?php if(!empty($employeeByid['motherName'])) {echo $employeeByid['motherName']; }?>" placeholder="motherName" class="col-xs-4 col-sm-4" />
                           <span id="motherName" style="color: rgb(255, 0, 0);"></span>
                        </fieldset>
                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> Present Address </label>
                            <?php //echo form_error('data[presentAddress]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            
                           <textarea rows='5' cols="5" id="presentAddress" name="data[presentAddress]" class="col-xs-4 col-sm-4" ><?php if(!empty($employeeByid['presentAddress'])) {echo $employeeByid['presentAddress']; }?></textarea> 
                           <span id="presentAddress" style="color: rgb(255, 0, 0);"></span>
                        </fieldset>
                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-2 col-sm-2"> Parmanent Address </label>
                            <?php //echo form_error('data[parmanentAddress]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            
                           <textarea rows='5' cols="5" id="parmanentAddress" name="data[parmanentAddress]" class="col-xs-4 col-sm-4" ><?php if(!empty($employeeByid['parmanentAddress'])) {echo $employeeByid['parmanentAddress']; }?></textarea> 
                           <span style="color: rgb(255, 0, 0);" id="parmanentAddress"></span>
                        </fieldset>
                        
                        
                        
                        
                       
                       

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

                        <div class="form-actions center">
                            <button type="button" id="btnUpdate" name="btnUpdate" class="btn btn-sm btn-success">
                                 <i class="ace-icon fa fa-check bigger-110"></i>
                                Update
                                
                            </button>
                        </div>
                    </form>
                </div>

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

  <script type="text/javascript">


        $('#btnUpdate').click(function(){
            var formdata=$('#frmchange_profile'); 
            var contents = formdata.serialize();
            //alert();
            $.ajax({
                url: "<?php echo admin_url()?>/employeesetup/change_employee_profile",
                type: "POST",
                dataType: "json",
                data: contents,
                success:function(msg){

                    if(msg=="1"){
                        window.location="<?php echo admin_url()?>/home/index"; 
                    }else if(msg=="2"){
                        //$('#hellow').html("Your Personal Info Not Updated ");
                        alert("Your Personal Info Not Updated ");
                    }
                    else if(msg.status=="3") {
                        alert(msg.message);
                        //$('span#mobile').html(msg.mobile);
                        // alert(msg.mobile);
                        // $('span#parmanentAddress').html(msg.parmanentAddress);
                        // $('span#presentAddress').html(msg.presentAddress);
                        // $('span#motherName').html(msg.motherName);
                        // $('span#fatherName').html(msg.fatherName);
                        // $('span#religion').html(msg.religion);
                        // $('span#fatherName').html(msg.fatherName);
                        // $('span#gender').html(msg.gender);
                        // $('span#email').html(msg.email);
                        // $('span#nationalId').html(msg.nationalId);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.responseText);
                $("#confirmationMessage").html("");  
            }
            });
        });

    
        // $('#btnUpdate').click(function(){
        //      var nationalId = $('#nationalId').val();
        //      var userId = $('#userId').val();
        //      var mobile = $('#mobile').val();
        //     var email = $('#email').val();
        //     var gender = $('#gender').val();
        //     var religion = $('#religion').val();
        //      var fatherName = $('#fatherName').val();
        //     var motherName = $('#motherName').val();
        //     var parmanentAddress = $('#parmanentAddress').val();
        //     var presentAddress = $('#presentAddress').val();
           
        //     $.ajax({
        //         url: "<?php echo admin_url()?>/employeesetup/change_employee_profile",
        //         type: "POST",
        //         data: {'nationalId': nationalId, 'userId': userId, 'mobile': mobile, 'email': email, 'gender': gender, 'fatherName': fatherName, 'motherName': motherName, 'presentAddress': presentAddress, 'parmanentAddress': parmanentAddress},
        //         async: false,
        //         success: function(msg){
        //             //alert(msg);
        //             if(msg=="1"){
        //                 alert('Your Personal Info Updated Succesfully');
        //                 //$('#hellow').html("Your Personal Info Updated Succesfully");
        //             }else{
        //                 alert("Your Personal Info Not Updated ");
        //             }
        //         }
        //     });
    
        // });

    </script>

