SHARE
TWEET

return_penjualan.action

a guest Apr 24th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. if(isset($_GET['fakturRtnPenjualan'])){
  3. doTableJSON($_GET['fakturRtnPenjualan'],array(
  4. "id",
  5. "date",
  6. "faktur",
  7. "faktur_penjualan",
  8. "pelanggan_id",
  9. "return_total",
  10. "return_dibayar",
  11. "return_sisa"
  12. ),"WHERE mode='return penjualan'");
  13. }
  14. else
  15.    
  16. if(isset($_GET['startDate']) AND isset($_GET['filterRtnPenjualan'])){
  17.    
  18.  
  19. $startDate=explode('/',$_GET['startDate']);
  20. $startDate=$startDate[2].'-'.$startDate[1].'-'.$startDate[0];  
  21.  
  22. $endDate=explode('/',$_GET['endDate']);
  23. $endDate=$endDate[2].'-'.$endDate[1].'-'.$endDate[0];  
  24.    
  25. doTableJSON($_GET['filterRtnPenjualan'],array(
  26. "id",
  27. "date",
  28. "faktur",
  29. "faktur_penjualan",
  30. "pelanggan_id",
  31. "return_total",
  32. "return_dibayar",
  33. "return_sisa"
  34. ),"WHERE mode='return penjualan' AND date>='".$startDate."' AND date<='".$endDate."' ");
  35. }
  36. else
  37. if(isset($_GET['totalRtnPenjualan'])){
  38. $rtnPenjualan=sumData('faktur','grand_total',"WHERE mode='return penjualan'");
  39.  
  40. ?> 
  41. <table class="table">
  42. <tr>
  43. <td><h3>Total Return Penjualan </h3></td><td> <h3><?php echo currency($rtnPenjualan);?></h3></td>
  44. </tr>
  45. </table>
  46. <?php
  47. }
  48. else
  49. if(isset($_GET['totalRtnPenjualanFilter'])){
  50. $startDate=explode('/',$_GET['startDate']);
  51. $startDate=$startDate[2].'-'.$startDate[1].'-'.$startDate[0];  
  52.  
  53. $endDate=explode('/',$_GET['endDate']);
  54. $endDate=$endDate[2].'-'.$endDate[1].'-'.$endDate[0];  
  55.  
  56. $rtnPenjualan=sumData('faktur','grand_total',"WHERE mode='return penjualan'  AND date>='".$startDate."' AND date<='".$endDate."'  ");
  57.  
  58.     ?>
  59.    
  60. <table class="table">
  61. <tr>
  62. <td><h3>Total Return Penjualan </h3></td><td> <h3><?php echo currency($rtnPenjualan);?></h3></td>
  63. </tr>
  64.  
  65. </table>
  66. <?php
  67. }
  68.  
  69.  
  70. elseif(isset($_GET['tableFakturBarangJual'])){
  71.     if(isset($_GET['fakturPenjualan'])){
  72.         $faktur=$_GET['fakturPenjualan'];
  73.     }else{
  74.         $faktur=1;
  75.     }
  76. doTableJSON($_GET['tableFakturBarangJual'],array(
  77. "id",
  78. "faktur",
  79. "date",
  80. "kode_barang",
  81. "nama_barang",
  82. "harga",
  83. "qty",
  84. "total"
  85. ),"WHERE status=2 AND faktur='".$faktur."'");
  86. }
  87. elseif(isset($_GET['tableRtnPenjualan'])){
  88. doTableJSON($_GET['tableRtnPenjualan'],array(
  89. "id",
  90. "kode_barang",
  91. "nama_barang",
  92. "harga",
  93. "qty",
  94. "total"
  95. ),"WHERE status=1");
  96. }elseif(isset($_GET['addCartRtnJual'])){
  97.     $barang=doTableArray("daftar_barang",array("id_barang","nama_barang","harga_jual"),"where kode_barang='".$_GET['kode_barang']."'");
  98.     $id_barang=$barang[0][0];
  99.     $nama_barang=$barang[0][1];
  100.     $harga=$barang[0][2];
  101.     $checkCart=checkData($_GET['addCartRtnBeli'],"WHERE kode_barang='".$_GET['kode_barang']."' AND status=1 ");
  102.     $total=$harga*$_GET['qty'];
  103.     if($checkCart <1){
  104.  
  105.         doInsert($_GET['addCartRtnBeli'],
  106.         "
  107.         id_barang,kode_barang,nama_barang,harga,qty,faktur,date,total,status
  108.         ",
  109.         "
  110.         '".$id_barang."',
  111.         '".$_GET['kode_barang']."',
  112.         '".$nama_barang."',
  113.         '".$harga."',
  114.         '".$_GET['qty']."',
  115.         '".$_GET['faktur']."',
  116.         '".date("Y-m-d")."',
  117.         '".$total."',
  118.         '1'
  119.         ");
  120.     }else{
  121.         doUpdate($_GET['addCartRtnBeli'],"qty=qty+".$_GET['qty'].",total=total+".$total."","WHERE kode_barang='".$_GET['kode_barang']."' AND status=1");
  122.     }
  123.  
  124. }
  125. elseif(isset($_GET['inputRtnPenjualan'])){
  126.  
  127. // Hapus pemasukan
  128.  
  129.     $user_id=$_GET['user_id']; 
  130.     $date=$_GET['date'];
  131.     $getDate=explode("/",$date);
  132.     $tanggal=$getDate[0];
  133.     $bulan=$getDate[1];
  134.     $tahun=$getDate[2];
  135.     $date=$tahun."-".$bulan."-".$tanggal;
  136.     $faktur=$_GET['faktur'];
  137.     $faktur_penjualan=$_GET['fakturPenjualan'];
  138.  
  139.     $total=xCurrency($_GET['total']);
  140.    
  141.         doInsert("faktur",
  142.         "
  143.         faktur,pelanggan_id,tanggal,bulan,tahun,date,total,
  144.         pengeluaran,voucher,diskon,grand_total,dibayar,kembali,mode,
  145.         keterangan,status,hutang,hutang_dibayar,hutang_sisa,tempo,
  146.         user_id
  147.         ",
  148.         "
  149.         '".$faktur."',
  150.         '0',
  151.         '".$tanggal."',
  152.         '".$bulan."',
  153.         '".$tahun."',
  154.         '".$date."',
  155.         '".$total."',
  156.         '".$total."',
  157.         '0',
  158.         '0',
  159.         '".$total."',
  160.         '".$total."',
  161.         '0',
  162.         'return penjualan',
  163.         'Return Penjualan : ".$faktur_penjualan."',
  164.         'tunai',
  165.         '0',
  166.         '0',
  167.         '0',
  168.         '0',
  169.         '".$user_id."'
  170.         ");
  171.        
  172.         doInsert("return_barang",
  173.         "
  174.         faktur,pelanggan_id,tanggal,bulan,tahun,date,total,
  175.         return_penjualan,return_pembelian,dibayar,mode,
  176.         keterangan,status,return_total,return_dibayar,return_sisa,
  177.         user_id,faktur_penjualan
  178.         ",
  179.         "
  180.         '".$faktur."',
  181.         '".getFakturPelanggan($faktur_penjualan)."',
  182.         '".$tanggal."',
  183.         '".$bulan."',
  184.         '".$tahun."',
  185.         '".$date."',
  186.         '".$total."',
  187.         '".$total."',
  188.         '0',
  189.         '".$total."',
  190.         'return penjualan',
  191.         'Return Penjualan : ".$faktur_penjualan."',
  192.         'tunai',
  193.         '".$total."',
  194.         '".$total."',
  195.         '0',
  196.         '".$user_id."',
  197.         '".$faktur_penjualan."'
  198.         ");
  199.        
  200.         $items=doTableArray("return_penjualan",array("qty","id_barang"),"WHERE status=1");
  201.         foreach($items as $row){
  202.            
  203.         doUpdate("daftar_barang", //tabel:kasir_penjualan
  204.         "stok=stok+".$row[0]."
  205.         ",
  206.         "WHERE id_barang='".$row[1]."'"
  207.         );
  208.         doUpdate("kasir_penjualan", //tabel:kasir_penjualan
  209.         "qty=qty-".$row[0].", total=total*(qty-".$row[0].")
  210.         ",
  211.         "WHERE id_barang='".$row[1]."' AND faktur='".$faktur_penjualan."'"
  212.         );
  213.        
  214.         }      
  215.         doUpdate("return_penjualan", //tabel:kasir_penjualan
  216.         "
  217.         date='".$date."',
  218.         faktur='".$faktur."',
  219.         status='2'
  220.  
  221.         ",
  222.         "WHERE status='1'"
  223.         ); 
  224.  
  225.  
  226. }else
  227. if(isset($_GET['dataRtnPenjualan'])){
  228.    
  229. $items=doTableArray("return_penjualan",array("kode_barang","nama_barang","harga","qty","total","faktur"),"WHERE status=2 AND faktur='".$_GET['faktur']."'");
  230. $faktur=doTableArray("return_barang",array("date","pelanggan_id","return_penjualan"),"where faktur='".$_GET['faktur']."'");
  231. $date= $faktur[0][0];
  232. $pelanggan_id= $faktur[0][1];
  233. $return= $faktur[0][2];
  234.  
  235. if(intval($pelanggan_id) !='' || intval($pelanggan_id)!=0){
  236. $pelanggan=doTableArray("pelanggan",array("nama_pelanggan","alamat","kota"),"where id='".intval($pelanggan_id)."'");
  237. if($pelanggan){$nama_pelanggan=$pelanggan[0][0];$alamat=$pelanggan[0][1];$kota=$pelanggan[0][2];}else{$nama_pelanggan='-';$alamat='';$kota='';}
  238. }else{
  239. $nama_pelanggan='-';
  240. $alamat='';
  241. $kota='';
  242. }
  243.  
  244.  
  245. ?>
  246. <div style="overflow-y: auto; height:430px; ">
  247. <div id="printArea">
  248. <div class="title" style="margin-bottom:10px;text-align:left">
  249. <b><?php echo getPengaturan('nama_toko');?></b>
  250. <br>
  251. <small><?php echo getPengaturan('alamat');?> Telp/HP <?php echo getPengaturan('no_hp');?></small>
  252. </div>
  253. <table class="table">
  254. <tr>
  255. <td style="width:150px">Tanggal</td><td style="width:30px">:</td><td><?php echo $date;?></td>
  256. <td >Pelanggan</td><td style="width:30px">:</td><td><?php echo $nama_pelanggan;?></td>
  257. </tr>
  258. <tr>
  259. <td style="width:150px">No Return Penjualan</td><td>:</td><td><?php echo $_GET['faktur'];?></td>
  260. <td >Alamat</td><td style="width:30px">:</td><td><?php echo $alamat;?> <?php echo $kota;?></td>
  261. </tr>
  262. </table>
  263.  
  264. <table class="table " id="dataPenjualan" cellspacing="0">
  265.   <thead>
  266.     <tr>
  267.       <th style="width:50px">No</th>
  268.       <th>Kode</th>
  269.       <th>Nama Barang</th>
  270.       <th>Harga</th>
  271.       <th>Qty</th>
  272.       <th >Total</th>
  273.     </tr>
  274.   </thead>
  275.   <tbody >
  276.   <?php
  277.   $i=1;
  278.     foreach($items as $row){
  279.       echo '<tr>';
  280.       echo '<td>'.$i.'</td>';
  281.       echo '<td>'.$row[0].'</td>';
  282.       echo '<td>'.$row[1].'</td>';
  283.       echo '<td>'. currency($row[2]).'</td>';
  284.       echo '<td>'.$row[3].'</td>';
  285.       echo '<td>'. currency($row[4]).'</td>';
  286.       echo '</tr>';
  287.       $i++;      
  288.   }  
  289.   ?>
  290.   <tr><td colspan=3></td><td colspan=2><b>Total</b></td><td> : <?php echo currency($return);?></td></tr>
  291.   </tbody>
  292.   </table>
  293. </div>
  294. </div>
  295. <?php
  296. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top