Advertisement
Guest User

trx_pembelian.php

a guest
Jul 30th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.89 KB | None | 0 0
  1. <?php
  2. if (!defined('YBASE')) exit ('Now Allowed');
  3. include 'notification.php';
  4. if (@$_GET['op'] == 'edprod') {
  5.     $idp = abs((int)($_GET['idp']));
  6.     $edprod = yposSQL('SHOW','ypos_vPembelianDtl','kdbarang, nama_barang, harga_pokok_jual, idDtlPembelian, qty_beli, harga_beli_satBaru, total_beli',"idDtlPembelian=$idp")->fetch_array();
  7. }
  8.  
  9. switch($act) {
  10.     default :?>
  11. <a href="<?php echo $set->folder_modul.'='.$modul.'&act=new';?>"><button name="save" value="add">Buat Baru</button></a>
  12. <table id="dataTable"  class="table" width="80%">
  13. <tr id="tbl">
  14. <th>No</th>
  15. <th>Kode Pembelian</th>
  16. <th>Nota</th>
  17. <th>Suplier</th>
  18. <th>Total</th>
  19. <th>Tanggal</th>
  20. <th>Operator</th>
  21. <th></th></tr>
  22. <?php
  23. $no =1;
  24. $q = yposSQL('SHOW','ypos_pembelian a, ypos_suplier b','kdPembelian, no_nota, total_pembelian, userID, tgl_input, nama_sup',"a.kdsup=b.kdsup && a.ids=$_SESSION[yids] && 1=1",'tgl_input DESC');
  25.     while ($r = $q->fetch_array()) {?>
  26.                 <tr align="center">        
  27.                 <td align="center"><?php echo $no;?></td>
  28.                 <td><?php echo $r['kdPembelian'];?></td>
  29.                 <td><?php echo $r['no_nota'];?></td>
  30.                 <td><?php echo $r['nama_sup'];?></td>
  31.                 <td><?php echo idr($r['total_pembelian']);?></td>
  32.                 <td><?php echo $r['tgl_input'];?></td>
  33.                 <td><?php echo $r['userID'];?></td>
  34.                 <td align="center">
  35.                 <?php if ($r['userID'] == $_SESSION['yuser']) {?>
  36.                 <a href="<?php echo $set->folder_modul.'='.$modul?>&act=new&id=<?php echo $r['kdPembelian'].'&ttl='.$r['total_pembelian'].'&nota='.$r['no_nota'];?>"><img src="images/icon-edit-on.png" border="0" width="20" height="20" /></a><?php } else {?>
  37.                 <img src="images/icon-edit-off.png" border="0" width="20" height="20" />
  38.                 <?php }?></td></tr>
  39.                 <?php
  40.                 $no++;
  41.                 } // end while
  42. ?>
  43.                 </table><?php
  44.     break;
  45.     case 'new':
  46.     if(!empty($kode)) {
  47.         $ed = yposSQL('SHOW','ypos_pembelian a, ypos_suplier b','kdPembelian as kode, no_nota as nota, total_pembelian as ttl, a.kdsup, tgl_beli as tgl, nama_sup as sup',"a.kdsup=b.kdsup && kdPembelian='$kode'")->fetch_array();
  48.     } else {
  49.         $genCode = genCode("P-".$set->kdSET.date('Ymd'),'kdPembelian','ypos_pembelian','7');
  50.     };?>
  51.     <form method="post" action="<?php echo $set->folder_modul.'/'.$modul;?>/aksi.php?<?php echo $set->folder_modul.'='.$modul.'&id='.@$ed['kode'].'&nota='.@$ed['nota'].'&act='.@$act.'&idp='.@$edprod['idDtlPembelian'];?>" name="form" id="form">
  52.     <fieldset>
  53.     <legend>Data Pembelian</legend>
  54. <table>
  55.         <tr align="left">
  56.         <td><b>Kode Pembelian</b></td>
  57.         <td>:</td>
  58.         <td>
  59.         <?php if(!empty($kode)) {
  60.             echo $ed['kode'];?>
  61.             <input type="hidden" class="inp-form" name="kode" required="required" size="25" value="<?php echo $ed['kode'];?>"/>
  62.         <?php } else { echo $genCode;?>
  63.             <input type="hidden" class="inp-form" name="kode" required="required" size="25" value="<?php echo $genCode;?>"/>
  64.         <?php }?>
  65.         </td>
  66.         <td width="200"></td>
  67.         <td></td>
  68.         <td></td>
  69.         <td align="right"></td>
  70.         </tr>
  71.         <tr>
  72.         <td><b>Tanggal Transaksi</b></td>
  73.         <td>:</td>
  74.         <td><input type="text" name="tgl" class="tgl" size="25" <?php if(!empty($kode)) { echo 'value="'.$ed['tgl'].'" '.$read .'';} else { echo 'value="'.$getDate.'".';} ?>/></td>
  75.         <td></td>
  76.         <td colspan="3" rowspan="2" width="300"><div id="total"><br/> Rp <?php echo idr(@$ed['ttl']);?></div></td>
  77.         </tr>
  78.         <tr>
  79.         <td><b>Suplier</b></td>
  80.         <td>:</td>
  81.         <td><div class="styled-select slate semi-square"><select name="sup" <?php if(!empty($kode)) { echo $read;}?>>
  82.     <?php $sup = yposSQL('SHOW','ypos_suplier','kdsup, nama_sup',"ids=$_SESSION[yids] && 1=1",'nama_sup');
  83.     while ($rs = $sup->fetch_array()) {
  84.         if ($ed['kdsup'] == $rs['kdsup']) {
  85.             echo "<option value='$rs[kdsup]' selected=selected>$rs[nama_sup]</option>";
  86.         } else {
  87.             echo "<option value='$rs[kdsup]'>$rs[nama_sup]</option>";
  88.         }
  89.     } $sup->free_result();?>
  90.     </select></div></td>
  91.         <td></td>
  92.         </tr>
  93.         <tr>
  94.         <td><b>No. Nota</b></td>
  95.         <td>:</td>
  96.         <td><input type="text" name="nota" size="25" value="<?php echo @$ed['nota'];?>" <?php if(!empty($kode)) { echo $read;}?>/></td>
  97.         <td></td>
  98.         <td></td>
  99.         <td></td>
  100.         <td></td>
  101.         </tr>
  102. </table>
  103. </fieldset>
  104. <fieldset>
  105. <legend>Item Pembelian</legend>
  106. <table border="0">
  107.   <tr>
  108.     <td><b>Cari Barang</b></td>
  109.     <td><input type="text" name="brg" size="50" required="required" placeholder="Nama Barang" id="brg" value="<?php if (@$_GET['op'] == 'edprod') { echo @$edprod['kdbarang'].' - '.@$edprod['nama_barang'].' (Rp : '.idr($edprod['harga_pokok_jual']).')';};?>"/></td>
  110.     <td><input type="text" name="qty" id="qty_p" required="required" placeholder="Qty" size="10" value="<?php echo @$edprod['qty_beli'];?>"/></td>
  111.     <td><input type="text" name="total_harga" id="total_harga" required="required" placeholder="Total Harga Beli" value="<?php echo @$edprod['total_beli'];?>"/></td>
  112.     <td><input type="text" name="harga_satuan" id="hs" placeholder="Harga Satuan" disabled="disabled" value="<?php echo @$edprod['harga_beli_satBaru'];?>"/></td>
  113.     <td>
  114.         <?php if (@$_GET['op'] == 'edprod') {
  115.                 echo '<input type="hidden" name="tipe" value="edProd"/>';
  116.                 echo '<input type="submit" class="submit" name="save" value="Simpan"/>';
  117.         }
  118.           else {
  119.                 echo '<input type="hidden" name="tipe" value="save"/>';
  120.                 echo '<input type="submit" class="submit" name="save" value="Tambahkan"/>';
  121.         }?>
  122.     </td>
  123.   </tr>
  124. </table>
  125. </fieldset>
  126. </form>
  127. <table border="0" id="dataTable" width="90%">
  128.   <tr id="tbl" align="center">
  129.     <td width="35">No</td>
  130.     <td>Kode Barang</td>
  131.     <td>Nama Barang</td>
  132.     <td>Qty</td>
  133.     <td>Harga</td>
  134.     <td>Total</td>
  135.     <td width="100"></td>
  136.   </tr>
  137. <?php
  138. $Qitem = yposSQL('SHOW','ypos_vPembelianDtl','kdbarang, nama_barang, nama_sup, no_nota, total_pembelian, idDtlPembelian, kdPembelian, qty_beli, harga_beli_satBaru',"kdPembelian='$kode' && 1=1");
  139. $no = 1;
  140. while ($getItem = $Qitem->fetch_array()) {?>
  141.   <tr>
  142.     <td align="center"><?php echo $no;?></td>
  143.     <td align="center"><?php echo $getItem['kdbarang'];?></td>
  144.     <td><?php echo $getItem['nama_barang'];?></td>
  145.     <td align="center"><?php echo $getItem['qty_beli'];?></td>
  146.     <td align="right"><?php echo idr($getItem['harga_beli_satBaru']);?></td>
  147.     <td align="right"><?php echo idr($getItem['qty_beli'] * $getItem['harga_beli_satBaru']);?></td>
  148.     <td align="center"><a href="<?php echo $set->folder_modul.'='.$modul?>&act=new&op=edprod&id=<?php echo $getItem['kdPembelian'].'&idp='.$getItem['idDtlPembelian'].'&ttl='.$getItem['total_pembelian'].'&nota='.$getItem['no_nota'];?>"><img src="images/icon-edit-on.png" border="0" width="20" height="20" /></a>
  149.     <a href="<?php echo $set->folder_modul.'='.$modul?>&act=delete&id=<?php echo $getItem['idDtlPembelian'].'&kdp='.$getItem['kdPembelian'];?>" onClick="return confirm('Anda yakin ingin menghapus data ini?')"><img src="images/delete-icon.png" border="0" width="20" height="20" /></a></td>
  150.   </tr>
  151.   <?php $no++; }
  152.   $total = yposSQL('SHOW','ypos_pembeliandtl','DISTINCT SUM(qty_beli) AS t_qty, SUM(harga_beli) AS t_harga',"kdPembelian='$kode' && 1=1")->fetch_array();?>
  153.     <tr>
  154.     <td colspan="3" align="center">Grand Total</td>
  155.     <td align="center"><?php echo $total['t_qty'];?></td>
  156.     <td align="right"><?php echo idr($total['t_harga']);?></td>
  157.     <td align="right"><?php echo idr(@$ed['ttl']);?></td>
  158.     <td></td>
  159.   </tr>
  160.   <tr>
  161.     <td colspan="6" align="center"></td>
  162.     <td align="center"><a href="<?php echo $set->folder_modul.'='.$modul;?>"><button class="submit">Selesai</button></a></td>
  163.   </tr>
  164. </table>
  165. <?php
  166. break;
  167. case 'delete':
  168. $kdp = anti($_GET['kdp']);
  169. $mysqli->query("CALL ypos_trxPembelianDtl_delProd($id,'$kdp',@error)");
  170. echo "<meta content='0; url=$set->folder_modul=$modul&act=new&id=$kdp' http-equiv='refresh'/>";
  171. break;
  172. }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement