
 <section class="content">
      <div class="row">
        <!-- left column -->
        <div class="col-md-6">
          <!-- general form elements -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Profile</h3>
            </div>
            <form role="form" enctype="multipart/form-data" id="profile">
              <div class="box-body">
              <div class="form-group">
                <input type="hidden" class="form-control"  name="id_kar"  value="<?php echo $query->id_kar?>"></input><span class="help-block"></span>
                </div>
                <div class="form-group">
                  <label for="exampleInputPassword1">NIK</label>
                  <input type="text" class="form-control"  name="nik" value="<?php echo $query->nik?>" placeholder="Nama"></input>
                   <span class="help-block"></span>
                </div>
                <div class="form-group">
                  <label for="exampleInputPassword1">Nama</label>
                  <input type="text" class="form-control"  name="nama" value="<?php echo $query->nama?>" placeholder="Nama"></input>
                   <span class="help-block"></span>
                </div>
                <div class="form-group">
                  <label for="exampleInputPassword1">Jenis Kelamin</label>
				   <select class="form-control" name="jk">
                                    <option value="">-----Pilih-----</option>
									<?php if ($query->jk=='Laki-Laki'){?>
                                    <option selected='selected' value="Laki-Laki">Laki-Laki</option>
									<option value="Perempuan">Perempuan</option>
									<?php } else{ ?> 
                                    <option selected='selected' value="Perempuan">Perempuan</option>
									<option value="Laki-Laki">Laki-Laki</option>
									<?php } ?>
                                  </select>
                   <span class="help-block"></span>
                </div>
                 <div class="form-group">
                  <label for="exampleInputPassword1">Jabatan</label>
                  <input type="text" class="form-control"  name=jabatan value="<?php echo $query->jabatan?>" placeholder="Jabatan"></input>
                   <span class="help-block"></span>
                </div>
                 </div>
              <!-- /.box-body -->
            </form>
            <div class="box-footer">
                <button type="submit" class="pull-right btn btn-large blue" id="btnSave" onclick="saveprofile()" >Update</button>
              </div>
          </div>
          <!-- /.box -->
        </div><!-- /.colmd -->
        <div class="col-md-6">
          <!-- general form elements -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Akun</h3>
            </div>
            <form role="form" enctype="multipart/form-data" id="akun">
              <div class="box-body">
              <div class="form-group">
                <input type="hidden" class="form-control"  name="id_kar"  value="<?php echo $query->id_kar?>"></input><span class="help-block"></span>
                </div>
                <div class="form-group">
                  <label for="exampleInputPassword1">Username</label>
                  <input type="text" class="form-control"  name="username" value="<?php echo $query->username?>" placeholder="Username"></input>
                   <span class="help-block"></span>
                </div>
                <div class="form-group">
                  <label for="exampleInputPassword1">Password</label>
                  <input type="Password" class="form-control"  name="password" value="" placeholder="Password "></input>
                   <span class="help-block"></span>
                </div>
               
                 </div>
              <!-- /.box-body -->
            </form>
            <div class="box-footer">
                <button type="submit" class="pull-right btn btn-large blue" id="btnSaveakun" onclick="saveakun()" >Update</button>
              </div>
          </div>
          <!-- /.box -->
        </div><!-- /.colmd -->
        </div>
        </section>
<script>
function saveprofile()
{
    $('#btnSave').text('saving...'); //change button text
    $('#btnSave').attr('disabled',true); //set button disable 

    var url= "<?php echo site_url('karyawan/updateprofile')?>";

    $.ajax({
        url : url,
        type: "POST",
        data: $('#profile').serialize(),
        dataType: "JSON",
        success: function(data)
        {

            if(data.status) //if success close modal 
            {
              $('#profile')[0].reset(); // reset form on modals
              $('.form-group').removeClass('has-error'); // clear error class
              $('.help-block').empty(); // clear error string
              alert("update Berhasil");
              window.location.reload(true)    
            }
            else
            {
                for (var i = 0; i < data.inputerror.length; i++) 
                {
                    $('[name="'+data.inputerror[i]+'"]').parent().parent().addClass('has-error'); //select parent twice to select div form-group class and add has-error class
                    $('[name="'+data.inputerror[i]+'"]').next().text(data.error_string[i]); //select span help-block class set text error string
                }
            }
            $('#btnSave').text('save'); //change button text
            $('#btnSave').attr('disabled',false); //set button enable 


        },
        error: function (jqXHR, textStatus, errorThrown)
        {
            alert('Error adding / update data');
            $('#btnSave').text('save'); //change button text
            $('#btnSave').attr('disabled',false); //set button enable 

        }
    });
}
function saveakun()
{
    $('#btnSaveakun').text('saving...'); //change button text
    $('#btnSaveakun').attr('disabled',true); //set button disable 

    var url= "<?php echo site_url('karyawan/updateakun')?>";

    $.ajax({
        url : url,
        type: "POST",
        data: $('#akun').serialize(),
        dataType: "JSON",
        success: function(data)
        {

            if(data.status) //if success close modal 
            {
              $('#akun')[0].reset(); // reset form 
              $('.form-group').removeClass('has-error'); // clear error class
              $('.help-block').empty(); // clear error string
              alert("update Berhasil");
              window.location.reload(true)    
            }
            else
            {
                for (var i = 0; i < data.inputerror.length; i++) 
                {
                    $('[name="'+data.inputerror[i]+'"]').parent().parent().addClass('has-error'); //select parent twice to select div form-group class and add has-error class
                    $('[name="'+data.inputerror[i]+'"]').next().text(data.error_string[i]); //select span help-block class set text error string
                }
            }
            $('#btnSaveakun').text('save'); //change button text
            $('#btnSaveakun').attr('disabled',false); //set button enable 


        },
        error: function (jqXHR, textStatus, errorThrown)
        {
            alert('Error adding / update data');
            $('#btnSaveakun').text('save'); //change button text
            $('#btnSaveakun').attr('disabled',false); //set button enable 

        }
    });
}
</script>