Advertisement
atysaa

view_user.slice.php

Aug 29th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.41 KB | None | 0 0
  1. @extends('layout.mainlayout')
  2.  
  3. @section('title')
  4. User
  5. @endsection
  6.  
  7.  
  8. @section('stylesheet')<!-- kalau ada tambahan style masukkan disini -->
  9. <link rel="stylesheet" href="<?php echo base_url()."assets/adminlte/";?>bower_components/bootstrap-daterangepicker/daterangepicker.css">
  10. <!-- bootstrap datepicker -->
  11. <link rel="stylesheet" href="<?php echo base_url()."assets/adminlte/";?>bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  12.  
  13. <link rel="stylesheet" href="{{ base_url('assets/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css')}}">
  14.  
  15. <link rel="stylesheet" type="text/css" href="{{ base_url('plugins/sweetalert/sweetalert.css') }}">
  16. @endsection
  17.  
  18. @section('breadcrumb')
  19. Daftar User
  20. @endsection
  21.  
  22. @section('h1')
  23. USER
  24. @endsection
  25.  
  26. @section('content')
  27.  
  28. <div class="row">
  29. <div class="col-md-12">
  30. <div class="panel panel-success">
  31. <div class="box-header with-border">
  32. <h3 class="box-title">user</h3>
  33. </div>
  34. <div class="row" style="padding: 10px;">
  35. <div class="col-md-10"></div>
  36. <div class="col-md-2">
  37. <a data-toggle="modal" data-target="#insertuser" class="btn btn-info" style="margin-left: 60px;" >
  38. <span class="glyphicon glyphicon-plus">Tambah</span></a>
  39. </div>
  40. </div>
  41. <!-- /.box-header -->
  42. <div class="box-body table-responsive">
  43. <table id="tabel1" class="table table-bordered">
  44. <thead>
  45.  
  46.  
  47. <tr style="background: #3c8dbc; height: 30px; text-align: center; color: #ffffff;">
  48. <th style="width: 5px; text-align: center;">ID</th>
  49. <th style="text-align: center;">FullName</th>
  50. <th style="text-align: center;">Username</th>
  51. <th style="text-align: center;">Email</th>
  52. <th style="text-align: center;">Password</th>
  53. <th style="text-align: center;">Date</th>
  54. <th style="text-align: center;">Tipe</th>
  55. <th style="text-align: center;">Foto</th>
  56. <th style="width: 140px; text-align: center;">Operasi</th>
  57. </tr>
  58. </thead>
  59.  
  60. <tbody>
  61. <?php foreach ($getdata as $key => $db): ?>
  62. <!-- data user database -->
  63. <tr>
  64. <td style="text-align: center;">{{ $db->id_user}}</td>
  65. <td style="text-align: center;">{{ $db->fullname}}</td>
  66. <td style="text-align: center;">{{ $db->nama}}</td>
  67. <td style="text-align: center;">{{ $db->email}}</td>
  68. <td style="text-align: center;">{{ $db->password}}</td>
  69. <td style="text-align: center;">{{ $db->tgl_daftar}}</td>
  70. <td style="text-align: center;">{{ $db->tipe}}</td>
  71. <td style="text-align: center;"><{{ $db->foto}}</td>
  72. <td style="text-align: center;">
  73.  
  74. <!-- <a data-toggle="modal" data-id="{{ $db->id_user }}" data-fnamauser="{{ $db->fullname}}" data-nama="{{ $db->nama}}" data-email="{{ $db->email}}" data-password="{{ $db->password}}" data-tgl_daftar="{{ $db->tgl_daftar}}" data-tipe="{{ $db->tipe}}" data-foto="{{ $db->foto}}" class="btn btn-warning user-edit" > -->
  75.  
  76. <a class="btn btn-warning" href="{{base_url('user/edit_user/').$db->id_user}}">
  77. <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
  78.  
  79. <a data-toggle="modal" data-id="{{ $db->id_user }}" class="btn btn-danger user-delete">
  80. <span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
  81.  
  82. </td>
  83. </tr>
  84. <?php endforeach ?>
  85. </tbody>
  86. </table>
  87. </div>
  88. <!-- /.box-body -->
  89. </div>
  90. </div>
  91. </div>
  92. <!-- modal insert user -->
  93. <div class="modal fade" id="insertuser">
  94. <form method="post" id="form_insertuser" onsubmit="return false">
  95. <div class="modal-dialog">
  96. <div class="modal-content">
  97. <div class="modal-header">
  98. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  99. <span aria-hidden="true">&times;</span></button>
  100. <h4 class="modal-title">Insert User</h4>
  101. </div>
  102. <div class="modal-body">
  103. <div class="form-horizontal">
  104.  
  105. <div class="form-group">
  106. <label class="col-sm-2 control-label">Full Name</label>
  107. <div class="col-sm-10">
  108. <input type="text" name="fnamauser" class="form-control" placeholder="Full Name">
  109. </div>
  110. </div>
  111.  
  112.  
  113. <div class="form-group">
  114. <label class="col-sm-2 control-label">Nama user</label>
  115. <div class="col-sm-10">
  116. <input type="text" name="namauser" class="form-control" placeholder="Username">
  117. </div>
  118. </div>
  119.  
  120. <div class="form-group">
  121. <label class="col-sm-2 control-label">Email</label>
  122. <div class="col-sm-10">
  123. <input type="text" class="form-control" name="emailuser" placeholder="Email">
  124. </div>
  125. </div>
  126.  
  127. <div class="form-group">
  128. <label class="col-sm-2 control-label">Password</label>
  129. <div class="col-sm-10">
  130. <input type="password" class="form-control" name="passworduser" >
  131. </div>
  132. </div>
  133.  
  134. <div class="form-group">
  135. <label class="col-sm-2 control-label">Re-type Password</label>
  136. <div class="col-sm-10">
  137. <input type="password" class="form-control" name="passworduser2">
  138. </div>
  139. </div>
  140.  
  141. <div class="form-group">
  142. <label class="col-sm-2 control-label" style="text-align: left;">Tanggal</label>
  143. <div class="col-sm-10">
  144. <div class="input-group date">
  145. <div class="input-group-addon">
  146. <i class="fa fa-calendar"></i>
  147. </div>
  148. <input type="text" class="form-control pull-right" id="datepicker1" placeholder="Tanggal Daftar" name="datepicker1">
  149. </div>
  150. </div>
  151. </div>
  152.  
  153. <div class="form-group">
  154. <label class="col-sm-2 control-label">Tipe</label>
  155. <div class="col-sm-10">
  156. <select class="form-control" name="tipeuser">
  157. <option>Admin</option>
  158. <option>User</option>
  159. </select>
  160. </div>
  161. </div>
  162.  
  163. <div class="form-group">
  164. <label class="col-sm-2 control-label">Foto</label>
  165. <div class="col-sm-10">
  166. <input type="file" class="form-control" name="fotouser" >
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. <div class="modal-footer">
  172. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  173. <button type="submit" class="btn btn-primary">Save</button>
  174. </div>
  175. </div>
  176. </div>
  177. </form>
  178. </div>
  179.  
  180. @endsection
  181.  
  182.  
  183. @section('script')
  184. <!-- bootstrap datepicker -->
  185. <script src="<?php echo base_url()."assets/adminlte/";?>bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
  186. <!-- DataTables -->
  187. <script src="<?php echo base_url("assets/adminlte/bower_components/datatables.net/js/jquery.dataTables.min.js");?>"></script>
  188. <script src="<?php echo base_url('assets/adminlte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
  189. <script type="text/javascript" src="{{ base_url('plugins/sweetalert/sweetalert.min.js') }}"></script>
  190.  
  191. <!-- date picker -->
  192. <script>
  193.  
  194. $(function () {
  195. $('#tabel1').DataTable();
  196. //Date picker
  197. $('#datepicker1').datepicker({
  198. autoclose: true
  199. });
  200. $('#datepicker2').datepicker({
  201. autoclose: true
  202. });
  203. })
  204. </script>
  205. <script type="text/javascript">
  206. jQuery(function($) {
  207. $("#tabel1").DataTable();
  208. // Form Insert User
  209. $('#form_insertuser').on('submit', function(e) {
  210. e.preventDefault();
  211. // alert("jalan");
  212. // return;
  213. swal({
  214. title: "Pemberitahuan!",
  215. text: "Apa anda sudah yakin?",
  216. type: "info",
  217. confirmButtonText: "Simpan",
  218. cancelButtonText: "Batal",
  219. showCancelButton: true,
  220. closeOnConfirm: false,
  221. showLoaderOnConfirm: true,
  222. }, function()
  223. {
  224. var form = $('#form_insertuser')[0]; // You need to use standard javascript object here
  225. var formData = new FormData(form);
  226. $.ajax({
  227. url: "{{ base_url('user/tambah') }}",
  228. method: 'POST',
  229. data:formData,
  230. contentType:false,
  231. catch:false,
  232. processData:false,
  233. dataType: 'json',
  234. success: function(json) {
  235. if (json.status == 'success') {
  236. swal({
  237. title: json.title,
  238. text: json.text,
  239. type: json.status,
  240. closeOnConfirm: false
  241. }, function(){
  242. location.reload();
  243. });
  244. } else {
  245. swal(json.title, json.text, json.status);
  246. }
  247. },
  248. error:function(json){
  249. console.log(json.responseText);
  250. }
  251. });
  252. });
  253. });
  254. // Form Delete
  255. $('.user-delete').on('click', function() {
  256. var id = $(this).data('id');
  257. swal({
  258. title: "Pemberitahuan!",
  259. text: "Apa anda sudah yakin?",
  260. type: "info",
  261. confirmButtonText: "Hapus",
  262. cancelButtonText: "Batal",
  263. showCancelButton: true,
  264. closeOnConfirm: false,
  265. showLoaderOnConfirm: true,
  266. }, function() {
  267. $.ajax({
  268. url: "{{ base_url('user/delete') }}",
  269. method: 'POST',
  270. data: {id: id},
  271. dataType: 'json',
  272. success: function(json) {
  273. if (json.status == 'success') {
  274. swal({
  275. title: json.title,
  276. text: json.text,
  277. type: json.status,
  278. closeOnConfirm: false
  279. }, function(){
  280. location.reload();
  281. });
  282. } else {
  283. swal(json.title, json.text, json.status);
  284. }
  285. }
  286. });
  287. });
  288. });
  289. // Form Edit
  290. $('.user-edit').on('click',function(){
  291. var id = $(this).data('id');
  292. var fullname = $(this).data('fnama');
  293. var nama = $(this).data('nama');
  294. var email = $(this).data('email');
  295. var password = $(this).data('password');
  296. var tgl_daftar = $(this).data('datepicker2');
  297. var tipe = $(this).data('tipe');
  298. var foto = $(this).data('foto');
  299.  
  300.  
  301. $('#edit-id').val(id);
  302. $('#edit-fnama').val(fullname);
  303. $('#edit-nama').val(nama);
  304. $('#edit-email').val(email);
  305. $('#edit-password').val(password);
  306. $('#edit-tgl_daftar').val(datepicker2);
  307. $('#edit-tipe').val(tipe);
  308. $('#edit-foto').val(foto);
  309. $('#edituser').modal();
  310. });
  311. // Form Edit
  312. $('#form_edituser').on('submit', function(e) {
  313. e.preventDefault();
  314. // alert($('#edit-fnama').val());
  315. swal({
  316. title: "Pemberitahuan!",
  317. text: "Apa anda sudah yakin?",
  318. type: "info",
  319. confirmButtonText: "Simpan",
  320. cancelButtonText: "Batal",
  321. showCancelButton: true,
  322. closeOnConfirm: false,
  323. showLoaderOnConfirm: true,
  324.  
  325. }, function() {
  326. var form = $('#edit_user')[0]; // You need to use standard javascript object here
  327. var formData = new FormData(form);
  328.  
  329. $.ajax({
  330. url: "{{ base_url('user/edit') }}",
  331. method: 'POST',
  332. data:formData,
  333. contentType:false,
  334. catch:false,
  335. processData:false,
  336. dataType: 'json',
  337. success: function(json) {
  338. if (json.status == 'success') {
  339. swal({
  340. title: json.title,
  341. text: json.text,
  342. type: json.status,
  343. closeOnConfirm: false
  344. }, function(){
  345. location.reload();
  346. });
  347. } else {
  348. swal(json.title, json.text, json.status);
  349. }
  350. },
  351. error:function(json){
  352. console.log(json.responseText);
  353. }
  354. });
  355. });
  356. });
  357. });
  358.  
  359. </script>
  360.  
  361. @endsection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement