| <link href="asset/datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet"> |
| <link href="asset/css/bootstrap.min.css" rel="stylesheet"> |
| <link href="asset/js/jqueryui/jquery-ui.min.css" rel="stylesheet"> |
| <link href="asset/js/autocomplete/autocomplete-0.3.0.css" rel="stylesheet"> |
| |
| <script type="text/javascript" src="asset/js/jquery-1.11.0.js"></script> |
| <script type="text/javascript" src="asset/js/jquery.min.js"></script> |
| <script type="text/javascript" src="asset/js/jqueryui/jquery-ui.min.js"></script> |
| <script type="text/javascript" src="asset/js/autocomplete/autocomplete-0.3.0.js"></script> |
| <script type="text/javascript" src="asset/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"></script> |
| <script type="text/javascript" src="asset/datetimepicker/bootstrap-datetimepicker.id.js" charset="UTF-8"></script> |
| <?php |
| $sql=mysql_query("SELECT kode_beli from pembelian order by kode_beli DESC LIMIT 0,1"); |
| $data=mysql_fetch_array($sql); |
| $kodeawal=substr($data['kode_beli'],3,5)+1; |
| if($kodeawal<10){ |
| $kode='BLJ0000'.$kodeawal; |
| } |
| elseif($kodeawal > 9 && $kodeawal <=99){ |
| $kode='BLJ000'.$kodeawal; |
| }else{ |
| $kode='BLJ000'.$kodeawal; |
| } |
| ?> |
| |
| <?php if($_SERVER['REQUEST_METHOD'] != 'POST'){ ?> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-lg-12"> |
| <form class="form-horizontal" action="" method="POST"> |
| <div class="form-group"> |
| <label for="tanggal_beli" class="col-lg-2 control-label"><strong>Tanggal Beli : </strong></label> |
| <div class="col-lg-2"> |
| <input type="date" class="form-control" id="tanggal_beli" placeholder="Tanggal .."> |
| </div> |
| |
| <label for="total_beli" class="col-lg-2 col-lg-offset-3 control-label"><strong>Total Beli : </strong></label> |
| <div class="col-lg-3"> |
| <div class="input-group"><span class="input-group-addon">Rp</span><input type="text" class="form-control" id="total_beli" name='total_beli' placeholder="Total pembelian .." readonly></div> |
| </div> |
| </div> |
| |
| <div class="form-group"> |
| <label for="kode_beli" class="col-lg-2 control-label"><strong>Kode : </strong></label> |
| <div class="col-lg-2"> |
| <input type="text" maxlength="8" class="form-control uneditable-input" id="kode_beli" name="kode_beli" value="<?php echo $kode;?>"readonly="true" > |
| </div> |
| |
| <label for="nota" class="col-lg-1 control-label"><strong>Nota Beli : </strong></label> |
| <div class="col-lg-2"> |
| <input type="text" maxlength="50" class="form-control" id="nota" name="nota" placeholder="Nota beli ..."> |
| </div> |
| |
| <label for="suplier_id" class="col-lg-1 control-label"><strong>Suplier : </strong></label> |
| <div class="col-lg-4"> |
| <select class="form-control" id="suplier_id" name="suplier_id"> |
| <option value="">Pilih Suplier</option> |
| <?php |
| $query = mysql_query("SELECT * FROM suplier"); |
| while($row = mysql_fetch_array($query)){ |
| echo '<option value="'.$row['id_suplier'].'">'.$row['nama_suplier'].'</option>'; |
| } ?> |
| </select> |
| </div> |
| </div> |
| |
| <div class="form-group"> |
| <label for="keterangan" class="col-lg-2 col-lg-offset-3 control-label"><strong>Keterangan : </strong></label> |
| <div class="col-lg-7"> |
| <textarea maxlength="300" rows="2" class="form-control" id="keterangan" name="keterangan" placeholder="Keterangan ..."></textarea> |
| </div> |
| </div> |
| |
| <div class="table-responsive"> |
| <table class="table table-bordered"> |
| <tr> |
| <th width="2%"><input id="check_all" class="formcontrol" type="checkbox"/></th> |
| <th width="50px">No</th> |
| <th width="300px">Nama Produk</th> |
| <th width="150px">Kode Produk</th> |
| <th width="100px">Jumlah Beli</th> |
| <th width="100px">Harga Beli</th> |
| <th width="100px">Total Beli</th> |
| </tr> |
| <tr> |
| <td><input type='checkbox' class='case'/></td> |
| <td><span id='snum'>1.</span></td> |
| <td><input class="form-control autocomplete_txt" data-type="productNama" type='text' id='namaproduk_1' name='namaproduk[]' autocomplete="off"/></td> |
| <td><input class="form-control autocomplete_txt" data-type="productKode" type='text' id='kodeproduk_1' name='kodeproduk[]' autocomplete="off" readonly/></td> |
| <td><input class="form-control changesNo" type='text' id='jumlahbeli_1' name='jumlahbeli[]' autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"/></td> |
| <td><div class="input-group"><span class="input-group-addon">Rp</span><input class="form-control changesNo" type='text' id='hargabeli_1' name='hargabeli[]' autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"/> </div></td> |
| <td><div class="input-group"><span class="input-group-addon">Rp</span><input class="form-control totalLinePrice" type='text' id='totalbeli_1' name='totalbeli[]' autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly/> </div></td> |
| </tr> |
| </table> |
| </div> |
| <div class="row"> |
| <div class="col-lg-12"> |
| <button type="button" class='btn btn-danger delete'><span class="glyphicon glyphicon-trash"> Delete</span></button> |
| <button type="button" class='btn btn-success addmore'><span class="glyphicon glyphicon-plus"> Tambah</span></button> |
| <input class='btn btn-info' type="submit" value="Simpan" name="simpan" /> |
| </div> |
| </div> |
| </form> |
| |
| |
| |
| <?php |
| } else |
| { |
| |
| $insert_topembelian = "INSERT INTO pembelian VALUES('".$_POST['kode_beli']."', '".$_POST['nota']."', ".$_POST['suplier_id'].", ".$_POST['tanggal_beli'].", ".$_POST['total_beli'].", '".$_POST['keterangan']."')"; |
| |
| mysql_query($insert_topembelian); |
| |
| |
| foreach($_POST['kodeproduk'] as $produk_id => $value_kodeproduk){ |
| foreach($_POST['namaproduk'] as $produk_nm => $value_namaproduk){ |
| foreach($_POST['jumlahbeli'] as $produk_ttl => $value_jumlahbeli){ |
| foreach($_POST['hargabeli'] as $produk_price => $value_hargabeli){ |
| $query_getdetailproduk=mysql_query("SELECT * FROM produk WHERE kode_produk = '$value_kodeproduk'"); |
| $stk_produk = array(); |
| $id_produk = array(); |
| $x=0; |
| while (($row = mysql_fetch_array($query_getdetailproduk, MYSQL_ASSOC)) !== false) |
| { |
| $rslt[$x] = $row['stok_produk']; |
| $id_produk[$x] = $row['id_produk']; |
| } |
| $query="INSERT INTO detail_pembelian (kode_beli, produk_id, jlh_beli, harga_beli, total_beli) |
| VALUES ('$_POST[kode_beli]', $id_produk[0] , $value_jumlahbeli, $value_hargabeli, $_POST[total_beli])"; |
| |
| if (mysql_query($query)){ |
| |
| $updateproduk = "UPDATE produk SET stok_produk = $rslt[$x] + $value_jumlahbeli WHERE kode_produk = '$value_kodeproduk'"; |
| mysql_query($updateproduk); |
| header('Location: dashboard.php?p=produk'); |
| }else{ |
| writeMsg('tambahproduk.gagal'); |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| ?> |
| </div> |
| </div> |
| </div> |
| <script src="asset/js/autocompletepembelian.js"></script> |