Commit 5e7e3798 authored by Iswahyudi's avatar Iswahyudi
Browse files

Revisi userview di branch terakhir karena proses merge yang kurang sempurna

parent acacca8c
Pipeline #23483 passed with stages
in 6 minutes and 36 seconds
......@@ -79,6 +79,7 @@ $route['default_controller'] = 'Main';
$route['users/role/roledelete/(:any)']= 'Users/role_delete/$1';
$route['users/role/roleput']= 'Users/role_put';
$route['users/userview'] = 'Users/user_view';
$route['users/user/id/(:any)']= 'Users/user_id/$1';
$route['users/user/usersave'] = 'Users/user_save';
$route['users/user/userdelete/(:any)']= 'Users/user_delete/$1';
$route['users/user/userput']= 'Users/user_put';
......
......@@ -229,6 +229,26 @@ class Users extends CI_Controller {
return $data;
}
function user_id($id){
//create a new cURL resource
$ch = curl_init($this->urluser."id/".$id);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the POST request
$result = curl_exec($ch);
//close cURL resource
curl_close($ch);
// echo 'HTTP code: ' . $httpcode;
echo $result;
}
function user_view(){
$data = $this->user_get();
$this->load->view('menu/header-menu.php');
......
......@@ -26,7 +26,7 @@
<!-- Flash Notifikasi -->
<?php echo $this->session->flashdata('notifikasi');?>
<a data-toggle="modal" data-backdrop='static' data-keyboard='false' data-target="#modal_tambah_user" class="btn btn-success btn-sm" href="#"><i class="fa fa-plus"></i> Add User</a>
<a class="btn btn-success btn-sm" onclick = "function_add()" href="#"><i class="fa fa-plus"></i>Add User</a>
</div>
<div class="box-body">
<div style="max-width: auto; overflow-x: auto;">
......@@ -54,74 +54,10 @@
<td><?php echo $value->email;?></td>
<td><?php echo $userrole->name;?></td>
<td>
<a data-toggle="modal" data-backdrop='static' data-keyboard='false' data-target="#<?php echo $value->id;?>" class="btn btn-warning btn-xs" href="#"><i class="fa fa-edit"></i></a>
<a class="btn btn-warning btn-xs" href="#" onclick="function_edit('<?= $value->id;?>')"><i class="fa fa-edit"></i></a>
<!--<a href="<?php echo base_url('users/user/userdelete')?>/<?php echo $value->id?>" onclick="javascript: return confirm('Anda yakin hapus ?')" class="btn btn-danger btn-xs "><i class="fa fa-trash"></i>-->
<a href="<?php echo base_url('users/user/userdelete')?>/<?php echo $value->id?>" onclick="javascript: return confirm('Data akan dihapus ?')" class="btn btn-danger btn-xs "><i class="fa fa-trash"></i>
</td>
<!-- MODAL EDIT USER -->
<div class="modal fade" id="<?php echo $value->id;?>" role="dialog" aria-labelledby="largeModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 class="modal-title" id="myModalLabel">Edit User</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<!--<form action="<?php echo base_url()?>users/user/userput" enctype="multipart/form-data" method="POST">-->
<form action="#" enctype="multipart/form-data" method="POST">
<div class="form-group col-md-12">
<label>ID</label>
<input readonly type="text" class="form-control" name="id" value="<?php echo $value->id;?>" id="id">
</div>
<div class="form-group col-md-12">
<label>Name</label>
<input type="text" class="form-control" name="name" value="<?php echo $value->name;?>" id="name">
</div>
<div class="form-group col-md-12">
<label>Email</label>
<input type="text" class="form-control" name="email" value="" id="email">
</div>
<div class="form-group col-md-12">
<label>Password</label>
<input type="password" class="form-control" name="password" value="" id="password">
</div>
<div class="form-group col-md-12">
<label>User Role</label>
<select class="form-control" name="userRole">
<?php
foreach ($roles['result'] as $opsirole) {
?>
<option value = "<?php echo $opsirole->id;?>"> <?php echo $opsirole->name;?>
</option>
<?php
}
?>
</select>
</div>
<div class="form-group col-md-12">
<br>
<button type="submit" id="btn_simpan_arsip" name="btn_simpan_arsip" class="btn btn-sm btn-primary"><i class="fa fa-check"></i> Simpan Data</button>
</div>
</form>
</div>
</div>
<!-- -->
<br>
</div>
</div>
</div>
</div>
</tr>
<?php
}
......@@ -145,37 +81,41 @@
</section>
<!-- /.content -->
<!-- ============ MODAL TAMBAH USER =============== -->
<div class="modal fade" id="modal_tambah_user" role="dialog" aria-labelledby="largeModal" aria-hidden="true">
<!-- MODAL USER -->
<div class="modal fade" id="modal_user" role="dialog" aria-labelledby="largeModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 class="modal-title" id="myModalLabel">Add User</h3>
</div>
<div class="modal-body">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 class="modal-title" id="myModalLabel">Edit User</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<form action="<?php echo base_url()?>users/user/usersave" enctype="multipart/form-data" method="POST">
<form id="form_user" action="#" enctype="multipart/form-data" method="POST">
<div class="form-group col-md-12">
<div class="form-group col-md-12" id="labelId">
<label>ID</label>
<input readonly type="text" class="form-control" name="id" id="id">
</div>
<div class="form-group col-md-12" id="labelName">
<label>Name</label>
<input type="text" class="form-control" name="name" value="" id="name">
<input type="text" class="form-control" name="name" id="name">
</div>
<div class="form-group col-md-12">
<div class="form-group col-md-12" id="labelEmail">
<label>Email</label>
<input type="text" class="form-control" name="email" value="" id="email">
<input type="text" class="form-control" name="email" id="email">
</div>
<div class="form-group col-md-12">
<div class="form-group col-md-12" id="labelPassword">
<label>Password</label>
<input type="password" class="form-control" name="password" value="" id="password">
<input type="password" class="form-control" name="password" id="password">
</div>
<div class="form-group col-md-12">
<div class="form-group col-md-12" id="labelRole">
<label>User Role</label>
<select class="form-control" name="userRole">
<?php
......@@ -188,19 +128,19 @@
?>
</select>
</div>
<div class="form-group col-md-12">
<br>
<button type="submit" id="btn_simpan_arsip" name="btn_simpan_arsip" class="btn btn-sm btn-primary"><i class="fa fa-check"></i> Simpan Data</button>
<button type="submit" id="btn_simpan_arsip" name="btn_simpan_arsip" class="btn btn-sm btn-primary"><i class="fa fa-check"></i>Simpan Data</button>
</div>
</form>
</div>
</div>
<!-- -->
<br>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END MODAL -->
......@@ -218,3 +158,31 @@
</div>
</body>
</html>
<script>
function function_add(){
$('#modal_user').modal('show');
$('#form_user')[0].reset();
$('#form_user').attr('action',"<?php echo base_url()?>users/user/usersave");
$('#myModalLabel').text('Add User');
$('#labelId').hide();
$('#labelEmail').show();
$('#labelPassword').show();
}
function function_edit(id){
$('#form_user').attr('action',"<?php echo base_url()?>users/user/userput");
$('#myModalLabel').text('Edit User');
$('#labelId').show();
$('#labelEmail').hide();
$('#labelPassword').hide();
$.get("<?php echo site_url('users/user/id');?>/"+id).done(function(response){
$('#modal_user').modal('show');
response=JSON.parse(response);
$('#id').val(response.id);
$('#name').val(response.name);
$('#email').val(response.email);
$('[name="userRole"]>[value="'+response.userRole.id+'"]').attr("selected",true);
});
}
</script>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment