Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function startCalc(){
- interval = setInterval("calc()",1);}
- function calc(){
- one = document.autoSumForm.harga[].value;
- two = document.autoSumForm.jumlah[].value;
- document.autoSumForm.total.value = (one * two);}
- function stopCalc(){
- clearInterval(interval);}
- </script>
- <?php
- $ID = @$_GET['ID'];
- $sql_dokter = mysqli_query($koneksi,"SELECT * FROM tb_periksa_dokter WHERE id_periksa_dokter = '$ID'") or die (mysqli_error());
- $data_dokter = mysqli_fetch_array($sql_dokter);
- ?>
- <div class="row">
- <div class="col-lg-12">
- <h3 class="page-header"><i class="fa fa-file-text-o"></i> Data Obat</h3>
- <ol class="breadcrumb">
- <li><i class="fa fa-home"></i><a href="index.html">Home</a></li>
- <li><i class="icon_document_alt"></i>Data</li>
- <li><i class="fa fa-file-text-o"></i>Data Obat</li>
- </ol>
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12">
- <section class="panel">
- <header class="panel-heading">
- Data Obat
- </header>
- </div>
- <div class="panel-body">
- <div class="table-responsive">
- <form class="form-validate form-horizontal" id="feedback_form" method="POST" action="" name='autoSumForm'>
- <table id="datatables" class="table table-bordered table-hover table-striped">
- <thead>
- <tr>
- <th>No.</th>
- <th>Nama Obat</th>
- <th>Harga</th>
- <th>Jumlah</th>
- <th>Total</th>
- </tr>
- </thead>
- <tbody>
- <?php
- include('../config/koneksi.php');
- $no = 1;
- $sql = "SELECT * FROM tb_obat";
- $query = mysqli_query($koneksi,$sql) or die (mysqli_error());
- $data = mysqli_fetch_array($query);
- //while($data = mysqli_fetch_array($query))
- //{
- ?>
- <tr>
- <td><?php echo $no++; ?></td>
- <td>
- <?php echo $data['nm_obat']; ?>
- <input type="hidden" name="id_periksa_dokter[]" value="<?php echo $data_dokter['id_periksa_dokter']; ?>" />
- <input type="hidden" name="id_obat[]" value="<?php echo $data['id_obat']; ?>" />
- </td>
- <td>
- <?php echo $data['harga']; ?>
- <input type="text" name="harga[]" onFocus="startCalc();" onBlur="stopCalc();" />
- </td>
- <td>
- <input type="number" name="jumlah[]" onFocus="startCalc();" onBlur="stopCalc();" />
- </td>
- <?php
- //}
- ?>
- <td>
- <input readonly type="number" name="total" readonly />
- </td>
- </tr>
- </tbody>
- </table>
- <div class="form-group">
- <div class="col-lg-offset-5 col-lg-10">
- <input class="btn btn-primary" type="submit" value="Save" name="save">
- <button class="btn btn-default" type="reset">Cancel</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- </section>
- </div>
- </div>
- <?php
- $id_periksa_dokter = @$_POST['id_periksa_dokter'];
- $id_obat = @$_POST['id_obat'];
- $jumlah = @$_POST['jumlah'];
- $harga = @$_POST['harga'];
- $hasil =
- $save = @$_POST['save'];
- if($save)
- {
- if($id_periksa_dokter == '' || $id_obat == '' || $harga == '' || $jumlah == '')
- {
- ?>
- <script type="text/javascript">alert("Inputan Tidak Boleh Kosong!")</script>
- <?php
- }
- else
- {
- foreach ($jumlah as $i => $jumlah2)
- {
- if(!empty($jumlah2))
- {
- $sql_detail = "INSERT INTO tb_detail_obat VALUES ('$id_periksa_dokter[$i]', '$id_obat[$i]', '$harga[$i]', '$jumlah2')" or die (mysqli_error());
- $query = mysqli_query($koneksi,$sql_detail);
- }
- }
- echo "<script type='text/javascript'>alert('Tambah Data Berhasil');window.location.href='?page=periksa&action=selesai';</script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement