Advertisement
Guest User

script 2

a guest
Jun 12th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. <?php
  2. if(session_id() == '') {
  3. session_start();
  4. $agenid=$_SESSION['agenid'];
  5.  
  6. if(session_is_registered('agenid')){
  7. }
  8. else{
  9. header("location:admin.php");
  10. }
  11. }
  12. ?>
  13.  
  14. <div class="menu">
  15. <?php include 'menu.php';?>
  16. </div>
  17.  
  18. <!doctype html>
  19. <html lang="en">
  20. <head>
  21. <meta charset="utf-8">
  22. <title>Transaksi</title>
  23. <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  24. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  25. <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  26. <link rel="stylesheet" href="/resources/demos/style.css">
  27. <script>
  28. $(function() {
  29. $( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' }).val();
  30. });
  31. </script>
  32. </head>
  33.  
  34. <head>
  35. <meta charset="utf-8">
  36. <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  37. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  38. <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  39. <link rel="stylesheet" href="/resources/demos/style.css">
  40. <script>
  41. $(function() {
  42. $( "#datepicker2" ).datepicker({ dateFormat: 'yy-mm-dd' }).val();
  43. });
  44. </script>
  45. </head>
  46. <body>
  47.  
  48. <form method="GET" action="transaksi.php">
  49. <p>Pencarian berdasarkan tanggal: </p>
  50. <p>
  51. <label style="color:#FFF;" for="from">Dari</label>
  52. Dari:<input type="text" id="datepicker" name="dp1">
  53. <label style="color:#FFF;" for="from">Sampai</label>
  54. Sampai:<input type="text" id="datepicker2" name="dp2">
  55.  
  56. <input name="tcari" type="submit" value="cari" />
  57. </p>
  58. <p>&nbsp; </p>
  59.  
  60. <table width="734" border='0' align='center'>
  61. <tr bgcolor=#ADFF2F><th width="34">No</th><th width="97">Tanggal</th><th width="88">AGENID</th><th width="71">Nominal</th><th width="129">Nomor</th><th width="81">Status</th><th width="220">VSN</th>
  62.  
  63. <?php
  64. include 'koneksi.php';
  65. $from = $_GET['dp1'];
  66. $to = $_GET['dp2'];
  67.  
  68. if (isset($_POST['tcari'])) {
  69.  
  70. $dataPerPage = 6;
  71. if(isset($_GET['paging']))
  72. {
  73. $noPage = $_GET['paging'];
  74. }
  75. else $noPage = 1;
  76.  
  77. $offset = ($noPage - 1) * $dataPerPage;
  78.  
  79. $query = "SELECT * from log_transaksi where tanggal >= DATE_FORMAT('" . $from . "', '%Y-%m-%d') AND tanggal <= DATE_FORMAT('" . $to . "', '%Y-%m-%d') AND agenid ='$agenid' ORDER BY tanggal,jam ASC LIMIT $offset, $dataPerPage";
  80. $exe = mysql_query($query);
  81.  
  82. $query = "SELECT COUNT(*) AS jumData FROM product ";
  83. $hasil = mysql_query($query);
  84. $data = mysql_fetch_array($hasil);
  85. $jumData = $data['jumData'];
  86. $jumPage = ceil($jumData/$dataPerPage);
  87.  
  88.  
  89. $no = 1;
  90. $baru = "#FFFF00";
  91. $lama="#FFFF00";
  92. while($row = mysql_fetch_assoc($exe)){
  93.  
  94. $a = $row['tanggal'];
  95. $b = $row['jam'];
  96. $c = $row['agenid'];
  97. $d = $row['denom'];
  98. $e = $row['nomor'];
  99. $f = $row['harga'];
  100. $g = $row['status'];
  101. $h = $row['vsn'];
  102.  
  103.  
  104. // beri warna selang seling
  105. if(($no % 2)==0)$warna = $baru;
  106.  
  107. else $warna = $lama;
  108.  
  109.  
  110. echo "<tr bgcolor=$warna align=center>
  111. <td>$no</td>
  112. <td>$a<br>$b</td>
  113. <td>$c</td>
  114. <td bgcolor=blue>$d<br>$f</td>
  115. <td>$e</td>
  116. <td>$g</td>
  117. <td>$h</td>
  118. </tr>";
  119. $no++;
  120.  
  121. if ($noPage > 1) echo "<a href='".$_SERVER['PHP_SELF']."?paging=".($noPage-1)."'>&lt;&lt; Prev</a>";
  122.  
  123.  
  124. // memunculkan nomor halaman dan linknya
  125.  
  126.  
  127. for($page = 1; $page <= $jumPage; $page++)
  128. {
  129. if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage))
  130. {
  131. if (($showPage == 1) && ($page != 2)) echo "...";
  132. if (($showPage != ($jumPage - 1)) && ($page == $jumPage)) echo "...";
  133. if ($page == $noPage) echo " <b>".$page."</b> ";
  134. else echo " <a href='".$_SERVER['PHP_SELF']."?paging=".$page."'>".$page."</a> ";
  135. $showPage = $page;
  136. }
  137. }
  138.  
  139.  
  140. // menampilkan link next
  141.  
  142.  
  143. if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?paging=".($noPage+1)."'>Next &gt;&gt;</a>";
  144. }}
  145. ?>
  146.  
  147.  
  148.  
  149. </table>
  150.  
  151.  
  152. </form>
  153.  
  154.  
  155. </body>
  156. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement