Advertisement
lutfirizal

Eksport XLS Daftar Obat

Dec 6th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 KB | None | 0 0
  1. <?php
  2.     global $db;
  3.  
  4.     $obat_rows = $db->get_result("
  5.         SELECT DISTINCT b.id_obat, b.kode_obat, b.nama_obat
  6.         FROM smis_frm_obat_masuk a INNER JOIN smis_frm_dobat_masuk b ON a.id = b.id_obat_masuk
  7.         ORDER BY b.kode_obat ASC, b.nama_obat ASC
  8.     ");
  9.  
  10.     echo "<table border='0'>";
  11.     echo "<tr>";
  12.     echo    "<th>Nomor</th>";
  13.     echo    "<th>ID Data</th>";
  14.     echo    "<th>Farmalkes ID</th>";
  15.     echo    "<th>Nama Obat/Medsupp</th>";
  16.     echo    "<th>Kemasan</th>";
  17.     echo    "<th>Satuan</th>";
  18.     echo    "<th>Isi</th>";
  19.     echo    "<th>Harga Netto</th>";
  20.     echo    "<th>Produsen</th>";
  21.     echo    "<th>PBF</th>";
  22.     echo "</tr>";
  23.     $nomor = 1;
  24.     if ($obat_rows != null) {
  25.         foreach ($obat_rows as $obat_row) {
  26.             $id_obat = $obat_row->id_obat;
  27.             $kode_obat = $obat_row->kode_obat;
  28.             $nama_obat = $obat_row->nama_obat;
  29.  
  30.             $satuan = "";
  31.             $harga = 0;
  32.             $pabrik = "";
  33.             $pbf = "";
  34.  
  35.             $last_data = $db->get_row("
  36.                 SELECT a.nama_vendor, c.produsen, c.satuan
  37.                 FROM (smis_frm_obat_masuk a INNER JOIN smis_frm_dobat_masuk b ON a.id = b.id_obat_masuk) INNER JOIN smis_frm_stok_obat c ON b.id = c.id_dobat_masuk
  38.                 WHERE a.prop = '' AND b.prop = '' AND c.prop = '' AND b.id_obat = '" . $id_obat . "'
  39.                 ORDER BY c.id DESC
  40.             ");
  41.             if ($last_data != null) {
  42.                 $pabrik = $last_data->produsen;
  43.                 $pbf = $last_data->nama_vendor;
  44.                 $satuan = $last_data->satuan;
  45.             }
  46.  
  47.             $harga_data = $db->get_row("
  48.                 SELECT MAX(c.hna) hna
  49.                 FROM (smis_frm_obat_masuk a INNER JOIN smis_frm_dobat_masuk b ON a.id = b.id_obat_masuk) INNER JOIN smis_frm_stok_obat c ON b.id = c.id_dobat_masuk
  50.                 WHERE a.prop = '' AND b.prop = '' AND c.prop = '' AND b.id_obat = '" . $id_obat . "'
  51.             ");
  52.             if ($harga_data != null)
  53.                 $harga = $harga_data->hna;
  54.  
  55.             echo "<tr>";
  56.             echo    "<td>" . $nomor++ . "</td>";
  57.             echo    "<td>" . $id_obat . "</td>";
  58.             echo    "<td>" . $kode_obat . "</td>";
  59.             echo    "<td>" . $nama_obat . "</td>";
  60.             echo    "<td></td>";
  61.             echo    "<td>" . $satuan . "</td>";
  62.             echo    "<td></td>";
  63.             echo    "<td>" . $harga . "</td>";
  64.             echo    "<td>" . $pabrik . "</td>";
  65.             echo    "<td>" . $pbf . "</td>";
  66.             echo "</tr>";
  67.         }
  68.         echo "</table>";
  69.     }
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement