Advertisement
squad_add

distribusi.php

Sep 29th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. <?php
  2. include 'headeradmin.php';
  3. include 'produk_list.php';
  4. $value = $_SESSION['user']['Id_Admin'];
  5. ?>
  6. <?PHP
  7. $Host = "localhost";
  8. $username = "root";
  9. $password = "";
  10. $database = "dbmonera";
  11. $koneksi = new mysqli( $Host, $username, $password, $database );
  12. if ($koneksi->connect_error){
  13. echo 'Gagal koneksi ke database';
  14. } else {
  15. //koneksi berhsil
  16. }
  17. // membuat query max
  18. $carikode = mysqli_query($koneksi, "select max(Id_Distribusi) from distribusi") or die (mysql_error());
  19. // menjadikannya array
  20. $datakode = mysqli_fetch_array($carikode);
  21. // jika $datakode
  22. if ($datakode) {
  23. $nilaikode = substr($datakode[0], 1);
  24. // menjadikan $nilaikode ( int )
  25. $kode = (int) $nilaikode;
  26. // setiap $kode di tambah 1
  27. $kode = $kode + 1;
  28. $kode_otomatis = "H".str_pad($kode, 4, "0", STR_PAD_LEFT);
  29. } else {
  30. $kode_otomatis = "H0001";
  31. }
  32.  
  33. ?>
  34.  
  35. <h3><span class="glyphicon glyphicon-briefcase"></span> Data Produk </h3>
  36. <input TYPE="button" class="btn btn-default" href="" onclick="history.go(-1);" value="Kembali">
  37. <form method="post" action="distribusi_do_simpan.php">
  38. <div>
  39. <table class="table">
  40. <tr>
  41. <td>Id Distribusi :</td>
  42. <td> <input type="text" class="form-control" name="id_distribusi" required value="<?php echo $kode_otomatis ?>"></td>
  43. </tr>
  44. <tr>
  45. <td>Nama Produk</td>
  46. <td>
  47. <?php foreach ($produk_dataok as $produk): ?>
  48. <div class="checkbox">
  49. <label><input type="checkbox" name="nama_produk[]" value="<?php echo $produk['Id_Produk'] ?>"><?php echo $produk['Nama_Produk'] ?></label>
  50. <?php endforeach ?>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td>Jumlah :</td>
  55. <td><input type="text" class="form-control" name="total" required ></td>
  56. </tr>
  57. <tr>
  58. <td>Admin :</td>
  59. <td><input type="text" class="form-control" name="admin" required value="<?php echo $value;?>"></td>
  60. </tr>
  61. <tr>
  62. <td></td>
  63. <td><input type="submit" class="btn btn-info" value="Simpan">
  64. <a href="produk.php?halaman=" class="btn btn-danger"> Reset </a>
  65. <a href="produk.php?halaman=" class="btn btn-success"> Add More Produk </a> </td>
  66. </tr>
  67. </table>
  68. </div>
  69. </form>
  70. </form>
  71. <div class="box">
  72. <table id="provinsi" class="table table-bordered">
  73. <thead>
  74. <tr>
  75. <th width="10%">ID Produk</th>
  76. <th width="15%">Nama Produk</th>
  77. <th width="15%">Jumlah</th>
  78. <th width="10%">Admin</th>
  79. <th width="10%">Action</th>
  80. </tr>
  81. </thead>
  82. <tbody>
  83. <?php
  84.  
  85. //Data mentah yang ditampilkan ke tabel
  86. mysql_connect('localhost', 'root', '');
  87. mysql_select_db('dbmonera');
  88. $sql = mysql_query("SELECT Produk.Id_Produk, produk.Nama_Produk, distribusi.Total, admin.Nama_Admin
  89. FROM produk, detail_distribusi, distribusi, admin
  90. WHERE produk.Id_Produk = detail_distribusi.Id_Produk AND detail_distribusi.Id_Distribusi = distribusi.Id_Distribusi AND distribusi.Id_Admin = admin.Id_Admin");
  91. $no = 1;
  92. while ($r = mysql_fetch_array($sql)) {
  93. ?>
  94.  
  95.  
  96.  
  97. <tr align='left'>
  98. <td><?php echo $r['Id_Produk']; ?></td>
  99. <td><?php echo $r['Nama_Produk']; ?></td>
  100. <td><?php echo $r['Total']; ?></td>
  101. <td><?php echo $r['Nama_Admin']; ?></td>
  102. <td>
  103. <a href="produk_edit.php?id_produk=<?php echo $r['Id_Produk']; ?>" class="btn btn-edit">Edit</a>
  104. <a href="produk_delete.php?id_produk=<?php echo $r['Id_Produk']; ?>" class="btn btn-hapus" onclick="return confirm('anda yakin akan menghapus data?');">Hapus</a>
  105. </td>
  106. </tr>
  107. <?php
  108. $no++;
  109. }
  110. ?>
  111. </tbody>
  112. </table>
  113. </div>
  114. <?php include 'footeradmin.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement