Advertisement
Guest User

a

a guest
Dec 22nd, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.89 KB | None | 0 0
  1.  
  2.  
  3.  
  4. <div class="wrapper">
  5. <div class="container-fluid">
  6.  
  7. <!-- Page-Title -->
  8. <div class="row">
  9. <div class="col-sm-12">
  10. <div class="page-title-box">
  11. <div class="btn-group pull-right">
  12. <ol class="breadcrumb hide-phone p-0 m-0">
  13. <li class="breadcrumb-item"><a href="#"><?=$this->config->item('title');?></a></li>
  14. <li class="breadcrumb-item active">Instagram</li>
  15. <li class="breadcrumb-item active">Kelola Akun</li>
  16. </ol>
  17. </div>
  18. <h4 class="page-title">Kelola Akun</h4>
  19. </div>
  20. </div>
  21. </div>
  22. <!-- end page title end breadcrumb -->
  23. <button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-animation="bounce" data-target=".tambah-akun-modal">Tambah Akun</button>
  24.  
  25. <div class="modal fade tambah-akun-modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  26. <div class="modal-dialog modal-dialog-centered">
  27. <div class="modal-content">
  28. <div class="modal-header">
  29. <h5 class="modal-title" id="tambahAkun">Tambah Akun Instagram</h5>
  30. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  31. <span aria-hidden="true">&times;</span>
  32. </button>
  33. </div>
  34. <div class="modal-body">
  35. <div class="form" role="form">
  36. <div class="alert alert-danger"><b>PERINGATAN</b>!! Akun anda akan tersimpan di database. Akan tetapi kami akan mengenskripsi password anda, yang membuat akun kalian tetap aman!</div>
  37. <div class="alert alert-danger">Akun anda yang tadinya di private, akan kami rubah menjadi public.</div>
  38. <div class="form-group row">
  39. <label for="example-text-input" class="col-sm-2 col-form-label">Username</label>
  40. <div class="col-sm-10">
  41. <input class="form-control" type="text" placeholder="Username Instagram" id="username">
  42. </div>
  43. </div>
  44.  
  45. <div class="form-group row">
  46. <label for="example-text-input" class="col-sm-2 col-form-label">Password</label>
  47. <div class="col-sm-10">
  48. <input class="form-control" type="password" placeholder="Password Instagram" id="password">
  49. </div>
  50. </div>
  51.  
  52. <div class="form-group row">
  53. <div class="col-12">
  54. <div class="custom-control custom-checkbox">
  55. <input type="checkbox" class="custom-control-input" id="customCheck1" name='accept' value='truee'>
  56. <label class="custom-control-label font-weight-normal" for="customCheck1">Saya setuju dengan peringatan diatas</label>
  57. </div>
  58. </div>
  59. </div>
  60.  
  61. <button class="btn btn-primary waves-effect waves-light" onclick="addAkun();" id="btn_login">Login</button>
  62. </div>
  63. </div>
  64. </div><!-- /.modal-content -->
  65. </div><!-- /.modal-dialog -->
  66. </div>
  67. <br><br>
  68.  
  69. <div class="row">
  70.  
  71. <!-- akun -->
  72. <?php
  73. $petik = "'";
  74. if($data == 0){
  75. echo '<h5>Belum ada akun yang terdaftar</h5>';
  76. } else {
  77. foreach ($data as $key) {
  78. $username_ig = $key['akun_instagram_username'];
  79. $picture = $key['akun_instagram_pict'];
  80. echo '
  81. <div class="col-md-4 col-lg-4 col-xl-4">
  82. <div class="card m-b-30">
  83. <div class="card-body">
  84. <div class="d-flex flex-row">
  85. <div class="col-3 align-self-center">
  86. <div class="round">
  87. <img src="'.$picture.'" alt="" height="55" class="round">
  88. </div>
  89. </div>
  90. <div class="col-6 align-self-center text-center">
  91. <div class="m-l-10">
  92. <h6 class="mt-0 round-inner">'.$username_ig.'</h6>
  93. </div>
  94. </div>
  95. <div class="col-3 align-self-end align-self-center">
  96. <button type="button" class="btn btn-light dropdown-toggle waves-effect" data-toggle="dropdown" aria-expanded="false"> Aksi <span class="caret"></span> </button>
  97. <div class="dropdown-menu">
  98. <a class="dropdown-item" href="#">Edit</a>
  99. <a href="#" onclick="hapusUser('.$petik.$username_ig.$petik.')" class="dropdown-item btn_hapus">Hapus</a>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>';
  106. }
  107. }
  108. ?>
  109. <!-- End Akun -->
  110. </div>
  111.  
  112. </div> <!-- end container -->
  113. </div>
  114. <!-- end wrapper -->
  115.  
  116. <script type="text/javascript">
  117. function addAkun(){
  118. var username = $("#username").val();
  119. var password = $("#password").val();
  120. var check = $('#customCheck1').is(":checked");
  121. if(username == "" || password == ""){
  122. swal({
  123. title: "Gagal!",
  124. text: "Input tidak boleh kosong!",
  125. type: "error"
  126. });
  127.  
  128. } else if(check == false){
  129. swal({
  130. title: "Gagal!",
  131. text: "Anda belum menyetujui peringatan diatas!",
  132. type: "error"
  133. });
  134. } else {
  135. $.ajax({
  136. url : '<?=base_url();?>ajax/addAkunInstagram',
  137. data : 'username='+username+'&password='+password,
  138. type : 'POST',
  139. dataType: 'html',
  140. beforeSend: function(){
  141. $('#btn_login').attr("disabled", "disabled");
  142. },
  143. success : function(msg){
  144. if(msg == 'noValue'){
  145. $('#btn_login').removeAttr("disabled");
  146. swal({
  147. title: "Gagal!",
  148. text: "Masih ada data yang kosong!",
  149. type: "error"
  150. });
  151. } else if(msg == '200'){
  152. swal({
  153. title: "Success!",
  154. text: "Berhasil menambahkan akun!",
  155. type: "success"
  156. });
  157. $('.tambah-akun-modal').modal('hide');
  158. setTimeout(function(){
  159. location.reload();
  160. }, 1500);
  161. } else if(msg == "update"){
  162. swal({
  163. title: "Success!",
  164. text: "Akun telah berhasil di update!",
  165. type: "success"
  166. });
  167. $('.tambah-akun-modal').modal('hide');
  168. setTimeout(function(){
  169. location.reload();
  170. }, 1500);
  171. } else {
  172. if(msg == ""){
  173. msg = "Jaringan terlalu lambat, silahkan coba lagi";
  174. }
  175. $('#btn_login').removeAttr("disabled");
  176. swal({
  177. title: "Gagal!",
  178. type: "error",
  179. html: msg
  180. });
  181. }
  182. }
  183. });
  184. }
  185.  
  186. }
  187.  
  188. function hapusUser(username){
  189. const swalWithBootstrapButtons = Swal.mixin({
  190. confirmButtonClass: 'btn btn-success',
  191. cancelButtonClass: 'btn btn-danger',
  192. buttonsStyling: false,
  193. })
  194.  
  195. swalWithBootstrapButtons({
  196. title: 'Anda Yakin ?',
  197. text: "Anda yakin ingin menghapus "+username+" ?",
  198. type: 'warning',
  199. showCancelButton: true,
  200. confirmButtonText: 'Ya',
  201. cancelButtonText: 'Tidak',
  202. reverseButtons: true
  203. }).then((result) => {
  204. if (result.value) {
  205. $.ajax({
  206. url : '<?=base_url();?>ajax/hapusUserIG',
  207. data : 'username='+username,
  208. type : 'POST',
  209. dataType: 'html',
  210. success : function(msg){
  211. setTimeout(function(){
  212. location.reload();
  213. }, 1000);
  214. }
  215. });
  216. swalWithBootstrapButtons(
  217. 'Deleted!',
  218. 'Your file has been deleted.',
  219. 'success'
  220. )
  221. } else if (
  222. // Read more about handling dismissals
  223. result.dismiss === Swal.DismissReason.cancel
  224. ) {
  225. swalWithBootstrapButtons(
  226. 'Cancelled',
  227. 'Anda membatalkan untuk menghapus akun!',
  228. 'error'
  229. )
  230. }
  231. })
  232. }
  233.  
  234. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement