Advertisement
punces

home.php

Jun 3rd, 2017
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.75 KB | None | 0 0
  1. <script>
  2. var chk_auto = "";
  3.  
  4. function once_load() {
  5.  
  6. }
  7.  
  8. function monitoring() {
  9. chk_auto = $("#chkAutoRefresh").is(':checked');
  10. if(chk_auto){
  11. $("#info_baru_saja").css('border-top', '5px solid #77bb77');
  12. } else {
  13. $("#info_baru_saja").css('border-top', 'none');
  14. }
  15. getBaruSaja();
  16. getRiwayatJam();
  17. getStatusTerbaru();
  18. getHotspotActive();
  19. getLogHotspot();
  20. }
  21.  
  22. var auto_refresh = setInterval(
  23. function() {
  24. if (chk_auto) {
  25. monitoring()
  26. }
  27. },
  28. <?php echo $this->mikrostator->get('interval'); ?> // Interval auto refresh 1000 = 1 Detik
  29. );
  30.  
  31. function getBaruSaja() {
  32. $.ajax({
  33. type: "POST",
  34. url: "<?php echo base_url() . 'home/get_baru_saja'; ?>",
  35. success: function(resp) {
  36. $("#info_baru_saja").html(resp);
  37. },
  38. error: function(event, textStatus, errorThrown) {
  39. $("#info_baru_saja").html('Error Message: ' + textStatus + ' , HTTP Error: ' + errorThrown);
  40. }
  41. });
  42. }
  43.  
  44. function getRiwayatJam() {
  45. $.ajax({
  46. type: "POST",
  47. url: "<?php echo base_url() . 'home/get_riwayat_jam'; ?>",
  48. success: function(resp) {
  49. $("#div_riwayat_jam").html(resp);
  50. },
  51. error: function(event, textStatus, errorThrown) {
  52. $("#div_riwayat_jam").html('Error Message: ' + textStatus + ' , HTTP Error: ' + errorThrown);
  53. }
  54. });
  55. }
  56.  
  57. function getStatusTerbaru() {
  58. $.ajax({
  59. type: "POST",
  60. url: "<?php echo base_url() . 'home/get_status_terbaru'; ?>",
  61. success: function(resp) {
  62. $("#container_status").html(resp);
  63. },
  64. error: function(event, textStatus, errorThrown) {
  65. $("#container_status").html('Error Message: ' + textStatus + ' , HTTP Error: ' + errorThrown);
  66. }
  67. });
  68. }
  69.  
  70. function getHotspotActive() {
  71. $.ajax({
  72. type: "POST",
  73. url: "<?php echo base_url() . 'home/get_hotspot_active'; ?>",
  74. success: function(resp) {
  75. $("#div_hotspot_active").html(resp);
  76. },
  77. error: function(event, textStatus, errorThrown) {
  78. $("#div_hotspot_active").html('Error Message: ' + textStatus + ' , HTTP Error: ' + errorThrown);
  79. }
  80. });
  81. }
  82.  
  83. function getLogHotspot() {
  84. $.ajax({
  85. type: "POST",
  86. url: "<?php echo base_url() . 'home/get_log_hotspot'; ?>",
  87. success: function(resp) {
  88. $("#div_log_hotspot").html(resp);
  89. },
  90. error: function(event, textStatus, errorThrown) {
  91. $("#div_log_hotspot").html('Error Message: ' + textStatus + ' , HTTP Error: ' + errorThrown);
  92. }
  93. });
  94. }
  95.  
  96. function konfirmasi() {
  97. var user = $('#txt_selectuser').val();
  98. var tambah = $('#txt_tambah').val();
  99. var tipe = $('#txt_selecttype').val();
  100. var tipejam = $('#txt_selectgadget').val();
  101. var msg2 = '';
  102.  
  103. if (tambah <= 0) {
  104. alert('PERHATIAN! *Tambah berapa* harus lebih dari 0');
  105. return false;
  106. }
  107.  
  108. if (tipejam == 'trf') {
  109. if ($('#txt_selectuser2').val() == '') {
  110. $('#txt_selectuser2').focus();
  111. alert('PERHATIAN! Sumber transfer belum dipilih.');
  112. return false;
  113. }
  114.  
  115. if ($('#txt_selectuser2').val() == $('#txt_selectuser').val()) {
  116. alert('PERHATIAN! Pengguna dan sumber transfer tidak boleh sama.');
  117. return false;
  118. }
  119.  
  120. if (tipe == 'rupiah') {
  121. alert('PERHATIAN! Jika tipenya TRANSFER, penambah harus berupa waktu.');
  122. return false;
  123. }
  124. user2 = $('#txt_selectuser2').val();
  125. msg2 = 'dan mengurangi ' + user2 + ' sebesar ' + tambah + ' ' + tipe + ' ';
  126. }
  127. return confirm('Apa kamu yakin ingin menambahkan ' + user + ' sebesar ' + tambah + ' ' + tipe + ' ' + msg2 + '(' + tipejam + ') ?');
  128. }
  129.  
  130. function cektrf(tipe) {
  131. if (tipe == 'trf') {
  132. $('#sel_trf').css({"display": "block"});
  133. } else {
  134. $('#sel_trf').css({"display": "none"});
  135. }
  136. }
  137.  
  138. function hitungrumus() {
  139. var str = $('#txt_tambah').val();
  140. var res = str.substring(0, 1);
  141. var rumus = str.substring(1);
  142. if (res == "=") {
  143. if (rumus != '') {
  144. $("#rumus_result").html('<center><span style="color:#b30000;">' + rumus + '=</span><span style="color:#009988;font-weight:bold;">' + eval(rumus) + '</span></center>');
  145. }
  146. } else {
  147. $("#rumus_result").html('');
  148. if (str != '') {
  149. if ($('#txt_selecttype').val() == "menit") {
  150. $("#detail_type").html(str + ' menit (' + $('#txt_selectgadget').val() + ')');
  151. } else {
  152. $("#detail_type").html(toRp(str) + ' (' + $('#txt_selectgadget').val() + ')');
  153. }
  154. } else {
  155. $("#detail_type").html('');
  156. }
  157. }
  158. }
  159.  
  160. function toRp(angka) {
  161. //https://faisalman.com/2012/02/27/konversi-angka-ke-format-rupiah-di-javascript/
  162. var rev = parseInt(angka, 10).toString().split('').reverse().join('');
  163. var rev2 = '';
  164. for (var i = 0; i < rev.length; i++) {
  165. rev2 += rev[i];
  166. if ((i + 1) % 3 === 0 && i !== (rev.length - 1)) {
  167. rev2 += '.';
  168. }
  169. }
  170. return 'Rp. ' + rev2.split('').reverse().join('') + ',-';
  171. }
  172.  
  173. function resetForm() {
  174. $('#txt_selectuser').selectpicker('deselectAll');
  175. $('#txt_selectgadget').selectpicker('deselectAll');
  176. $('#txt_selectuser2').selectpicker('deselectAll');
  177. $('#txt_selecttype').selectpicker('deselectAll');
  178. $('#txt_tambah').val('');
  179. $("#detail_type").html('');
  180. $('#btnTambah').prop('disabled', false);
  181. }
  182.  
  183. $(document).ready(function() {
  184. $('#frmTambahjam').submit(function() {
  185. if (konfirmasi()) {
  186. $('#luding').show();
  187. $('#lbl_msg').fadeOut('slow');
  188. $('#btnTambah').prop('disabled', true);
  189. $.ajax({
  190. type: 'POST',
  191. url: "<?php echo base_url('home/tambahJam') ?>",
  192. data: $(this).serialize(),
  193. success: function(data) {
  194. resetForm();
  195. $('#luding').hide();
  196. $('#lbl_msg').fadeIn('slow');
  197. $('#lbl_msg').html(data);
  198. getBaruSaja();
  199. getRiwayatJam();
  200. },
  201. error: function(event, textStatus, errorThrown) {
  202. resetForm();
  203. $('#luding').hide();
  204. $('#lbl_msg').fadeIn('slow');
  205. $('#lbl_msg').html('Terjadi kesalahan pada sistem ajax. Saran: Refresh halaman dan ulangi kembali. (Error Message: ' + textStatus + ' , HTTP Error: ' + errorThrown + ')');
  206. }
  207. })
  208. }
  209. return false;
  210. });
  211. });
  212.  
  213. once_load();
  214. monitoring();
  215.  
  216. function transaksiLain()
  217. {
  218. save_method = 'add';
  219. $('#form')[0].reset(); // reset form on modals
  220. $('.form-group').removeClass('has-error'); // clear error class
  221. $('.help-block').empty(); // clear error string
  222. //$('#modal_form').modal('show'); // show bootstrap modal
  223. $('.modal-title').text('Tambah Transaksi Lain'); // Set Title to Bootstrap modal title
  224. $('#modal_form').modal({
  225. backdrop: false
  226. });
  227. //https://silviomoreto.github.io/bootstrap-select/
  228. //$('.selectpicker').selectpicker({
  229. // size: 4
  230. // });
  231.  
  232. }
  233.  
  234. function save() {
  235. if (save_method == 'add') {
  236. url = "<?php echo site_url('home/simpan_tambah_transaksi_lain') ?>";
  237. konfirmasi = confirm('Apa kamu yakin ingin MENAMBAHKAN TRANSAKSI ' + $('[name="trx_username"]').val() + '?');
  238. } else {
  239. url = "<?php echo site_url('hotspot/simpan_update_transaksi_lain') ?>";
  240. konfirmasi = confirm('Apa kamu yakin ingin MENGUBAH data ' + $('[name="trx_username"]').val() + '?');
  241. }
  242. if (konfirmasi) {
  243. $('#luding').show();
  244. $('#lbl_msg').fadeOut('slow');
  245. $('#btnTambah').prop('disabled', true);
  246. user = $('[name="trx_username"]').val();
  247. nominal = $('[name="trx_nominal"]').val();
  248. transaksi = $('[name="trx_keterangan"]').val();
  249. $.ajax({
  250. type: 'POST',
  251. url: url,
  252. data: 'user=' + user + '&nominal=' + nominal + '&transaksi=' + transaksi,
  253. success: function(data) {
  254. //resetForm();
  255. $('#modal_form').modal('hide');
  256. $('#luding').hide();
  257. $('#lbl_msg').fadeIn('slow');
  258. $('#lbl_msg').html(data);
  259. getBaruSaja();
  260. getRiwayatJam();
  261. },
  262. error: function(event, textStatus, errorThrown) {
  263. //resetForm();
  264. $('#modal_form').modal('hide');
  265. $('#luding').hide();
  266. $('#lbl_msg').fadeIn('slow');
  267. $('#lbl_msg').html('Terjadi kesalahan pada sistem ajax. Saran: Refresh halaman dan ulangi kembali. (Error Message: ' + textStatus + ' , HTTP Error: ' + errorThrown + ')');
  268. }
  269. })
  270. }
  271. return false;
  272. }
  273.  
  274. </script>
  275. <!-- Bootstrap modal -->
  276. <div class="modal fade" id="modal_form" role="dialog">
  277. <div class="modal-dialog">
  278. <div class="modal-content">
  279. <div class="modal-header">
  280. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  281. <h3 class="modal-title">Formulir Hotspot User</h3>
  282. </div>
  283. <div class="modal-body form">
  284. <form action="#" id="form" class="form-horizontal">
  285. <input type="hidden" value="" name="id"/>
  286. <div class="form-body">
  287. <div class="form-group">
  288. <label class="control-label col-md-3">Nama</label>
  289. <div class="col-md-9">
  290. <input name="trx_username" placeholder="Nama" class="form-control" type="text" autocomplete="off">
  291. <span class="help-block"></span>
  292. </div>
  293. </div>
  294. <div class="form-group">
  295. <label class="control-label col-md-3">Transaksi</label>
  296. <div class="col-md-9">
  297. <input name="trx_keterangan" placeholder="Transaksi" class="form-control" type="text" autocomplete="off">
  298. <span class="help-block"></span>
  299. </div>
  300. </div>
  301. <div class="form-group">
  302. <label class="control-label col-md-3">Biaya</label>
  303. <div class="col-md-9">
  304. <input name="trx_nominal" placeholder="Harga" class="form-control" type="text" autocomplete="off">
  305. <span class="help-block"></span>
  306. </div>
  307. </div>
  308.  
  309. </div>
  310. </form>
  311. </div>
  312. <div class="modal-footer">
  313. <button type="button" id="btnSave" onclick="save()" class="btn btn-success">Simpan</button>
  314. <button type="button" class="btn btn-danger" data-dismiss="modal">Batal</button>
  315. </div>
  316. </div><!-- /.modal-content -->
  317. </div><!-- /.modal-dialog -->
  318. </div><!-- /.modal -->
  319. <!-- End Bootstrap modal -->
  320. <div id="kiri">
  321. <!--HEADER-->
  322. <div class="header">
  323. <!--TITLE--><center style="margin-bottom:-20px;"><h1><span style="font-family:Arial;font-weight:bold;"><span style="color:#009988;">TAMBAH</span> JAM</span></h1></center><!--END TITLE-->
  324. <!--DESCRIPTION--><!-- <center><h2><span style="font-size:11px;color:#008899;">..::: PENGGUNA RTPAPAT.NET :::...</span></h2></center> --><!--END DESCRIPTION-->
  325. </div>
  326. <form name="frm_tambah_jam" id="frmTambahjam" method="POST">
  327. <div class="content">
  328. <div class="form-group">
  329. <select id="txt_selectuser" name="selectuser" class="selectpicker" data-live-search="true" title="Pilih pengguna" data-width="100%" required data-style="btn-danger">
  330. <?php
  331. foreach ($hotspotuser as $row) {
  332. $name = $row['name'];
  333. $password = $row['password'];
  334. $profile = $row['profile'];
  335. $limit_uptime = "";
  336. if (isset($row['limit-uptime'])) {
  337. $limit_uptime = $row['limit-uptime'];
  338. }
  339. $uptime = $row['uptime'];
  340. $bytes_in = $row['bytes-in'];
  341. $bytes_out = $row['bytes-out'];
  342. $sisa_time = $this->stator->time_elapsed_A($this->stator->get_menit($limit_uptime, 's') - $this->stator->get_menit($uptime, 's'));
  343. echo "<option value='" . $name . "' data-subtext='(" . $sisa_time . ")' data-icon='glyphicon-user'>" . $name . "</option>";
  344. }
  345. ?>
  346. </select>
  347. </div>
  348. <div class="form-group">
  349. <select id="txt_selectgadget" name="selectgadget" class="selectpicker" data-live-search="true" title="Pilih perangkat" data-width="100%" required data-style="btn-warning" onchange="cektrf(this.value)">
  350. <?php
  351. foreach ($selectgadget as $row):
  352. $list_id = $row->list_id;
  353. $list_name = $row->list_name;
  354. $list_value = $row->list_value;
  355. $list_note = $row->list_note;
  356. $list_icon = $row->list_icon;
  357. ?>
  358. <option value="<?php echo $list_value; ?>" data-subtext="<?php echo $list_note; ?>" data-icon="<?php echo $list_icon; ?>"><?php echo $list_name; ?></option>
  359. <?php endforeach; ?>
  360. </select>
  361. </div>
  362. <div class="form-group" id="sel_trf" style="display:none;">
  363. <select id="txt_selectuser2" name="selectuser2" class="selectpicker" data-live-search="true" title="Pilih sumber transfer" data-width="100%" data-style="btn-success">
  364. <?php
  365. foreach ($hotspotuser as $row) {
  366. $name = $row['name'];
  367. $password = $row['password'];
  368. $profile = $row['profile'];
  369. $limit_uptime = "";
  370. if (isset($row['limit-uptime'])) {
  371. $limit_uptime = $row['limit-uptime'];
  372. }
  373. $uptime = $row['uptime'];
  374. $bytes_in = $row['bytes-in'];
  375. $bytes_out = $row['bytes-out'];
  376. $sisa_time = $this->stator->time_elapsed_A($this->stator->get_menit($limit_uptime, 's') - $this->stator->get_menit($uptime, 's'));
  377. echo "<option value='" . $name . "' data-subtext='(" . $sisa_time . ")' data-icon='glyphicon-user'>" . $name . "</option>";
  378. }
  379. ?>
  380. </select>
  381. </div>
  382. <div class="form-group">
  383. <select id="txt_selecttype" name="selecttype" class="selectpicker" data-live-search="true" title="Uang atau waktu? " data-width="100%" required data-style="btn-primary">
  384. <?php
  385. foreach ($selecttype as $row):
  386. $list_id = $row->list_id;
  387. $list_name = $row->list_name;
  388. $list_value = $row->list_value;
  389. $list_note = $row->list_note;
  390. $list_icon = $row->list_icon;
  391. ?>
  392. <option value="<?php echo $list_value; ?>" data-subtext="<?php echo $list_note; ?>" data-icon="<?php echo $list_icon; ?>"><?php echo $list_name; ?></option>
  393. <?php endforeach; ?>
  394. </select>
  395. </div>
  396. <div>
  397. <input name="nominal" type="text" id="txt_tambah" placeholder="Tambah berapa?" class="input username" style="font-weight:bold;border-radius:4px;color:red;font-size:22px;text-align:right;" autocomplete="off" required onkeyup="hitungrumus()"/>
  398. </div>
  399. <div id="detail_type" style="text-align:right;font-size:10px;"></div>
  400.  
  401. </div>
  402. <div class="footer">
  403. <input type="submit" name="submit" value="PROSES" class="button proses" id="btnTambah" style="font-weight:bold;border-radius:4px;" />
  404. <div style="color:#999;font-size:10px;font-style:italic;text-align:right;">(<a href="javascript:void(0)" onclick="transaksiLain()">transaksi lain</a>)</div>
  405. <div id="rumus_result"></div>
  406. <br/>
  407. </div>
  408. </form>
  409. </div>
  410.  
  411. <div id="kanan">
  412. <!--HEADER-->
  413. <div class="header">
  414. <!--TITLE--><center style="margin-bottom:-20px;"><h1><span style="font-family:Arial;font-weight:bold;"><span style="background:blue;color:white;border-radius:4px;padding:0px 10px;text-shadow:none;font-size:44px;">MUARA</span><span>CYBER</span> <span id="count_online" style="background:#ff4444;color:#fff;border-radius:4px;padding:0px 10px;text-shadow:none;font-size:44px;">0</span></span></h1></center><!--END TITLE-->
  415. <!--DESCRIPTION--><!-- <center><h2><span style="font-size:11px;color:#008899;">..::: PENGGUNA RTPAPAT.NET :::...</span></h2></center> --><!--END DESCRIPTION-->
  416.  
  417. </div>
  418. <div class="content">
  419. <div id="container_status">
  420. <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> <i>sedang memuat data...</i>
  421. </div>
  422. <style>
  423. table td, table th{font-size:11px;}
  424. .nowrap {white-space:nowrap;}
  425. </style>
  426.  
  427. <div class="progress" style="height:8px;margin-bottom:0;" id="status_cpu_strip">
  428. <div class="progress-bar progress-bar-success progress-bar-striped" style="width: 0%" style="min-width: 2em;">
  429. </div>
  430. </div>
  431. <div class="table-responsive" id="div_hotspot_active">
  432. <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> <i>sedang memuat data...</i>
  433. </div>
  434.  
  435. <div style="font-size:10px;font-style:italic;color:#ff265c;" id="diperbarui_pada"></div>
  436. </div>
  437.  
  438. <!--CONTAINER LOG HOTSPOT.begin-->
  439. <!--HEADER-->
  440. <div class="header">
  441. <!--TITLE--><center style="margin-bottom:-20px;"><h1><span style="font-family:Arial;font-weight:bold;"><span style="color:#009988;">LOG</span> HOTSPOT</span></h1></center><!--END TITLE-->
  442. <!--DESCRIPTION--><!-- <center><h2><span style="font-size:11px;color:#008899;">..::: PENGGUNA RTPAPAT.NET :::...</span></h2></center> --><!--END DESCRIPTION-->
  443. </div>
  444. <div class="content">
  445. <style>
  446. table td, table th{font-size:11px;}
  447. .nowrap {white-space:nowrap;}
  448. </style>
  449. <div class="table-responsive" id="div_log_hotspot">
  450. <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> <i>sedang memuat data...</i>
  451. </div>
  452. </div>
  453. <!--CONTAINER LOG HOTSPOT.end-->
  454.  
  455. <!--CONTAINER RIWAYAT JAM.begin-->
  456. <!--HEADER-->
  457. <div class="header">
  458. <!--TITLE--><center style="margin-bottom:-20px;"><h1><span style="font-family:Arial;font-weight:bold;"><span style="color:#009988;">RIWAYAT</span> JAM</span></h1></center><!--END TITLE-->
  459. <!--DESCRIPTION--><!-- <center><h2><span style="font-size:11px;color:#008899;">..::: PENGGUNA RTPAPAT.NET :::...</span></h2></center> --><!--END DESCRIPTION-->
  460. </div>
  461. <div class="content">
  462. <style>
  463. table td, table th{font-size:11px;}
  464. .nowrap {white-space:nowrap;}
  465. </style>
  466. <div class="table-responsive" id="div_riwayat_jam">
  467. <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> <i>sedang memuat data...</i>
  468. </div>
  469. </div>
  470. <!--CONTAINER RIWAYAT JAM.end-->
  471. </div>
  472.  
  473. <script>
  474. function PlayNow() {
  475. var url = "<?php echo base_url('home/playNow') ?>";
  476. url = url;
  477. window.open(url, "playNOW", "toolbar=no,scrollbars=no,resizable=no,top=200,left=200,width=200,height=200,menubar=no,titlebar=no,location=no");
  478. }
  479.  
  480. var awal_ol = 0;
  481. function cek_ol(ol) {
  482. if (ol > awal_ol) {
  483. awal_ol = ol;
  484. } else if (ol < awal_ol) {
  485. PlayNow();
  486. awal_ol = ol;
  487. } else {
  488. }
  489. }
  490. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement