drimlen

prosesInput

Jun 23rd, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.67 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.   <title>Purchasing Product From Supplier</title>
  5.  
  6.   </SCRIPT>
  7. </head>
  8.  
  9. <body>
  10.  
  11. <?php
  12.  
  13. include("../connect.php");
  14.  
  15.     $bulan = date("F");
  16.     $tanggal = date("d-Y");
  17.     $date = date("Y-m-d");
  18.  
  19.     $totalItem = $_POST['listItem'];
  20.  
  21. //start formating id_pembelian
  22.  
  23.     $sqlSelect = "SELECT max(id_pembelian) as idMax from detail_pembelian";
  24.     $resultSelect = mysql_query($sqlSelect);
  25.  
  26.     $data = mysql_fetch_array($resultSelect);
  27.     $dataId = $data['idMax'];
  28.  
  29.     $reqId = (int) substr($dataId, 2,4);
  30.     $reqId++;
  31.  
  32.     $idpembelian = 'PR' . sprintf("%04s", $reqId);
  33.  
  34. //end of format
  35.  
  36. //start formating id_detail_pembelian
  37.  
  38.     $sqlSelectDetail = "SELECT max(id_detail_pembelian) as idDetailMax from detail_pembelian";
  39.     $resultSelectDetail = mysql_query($sqlSelectDetail);
  40.  
  41.     $dataDetail = mysql_fetch_array($resultSelectDetail);
  42.     $dataDetailNew = $dataDetail['idDetailMax'];
  43.  
  44.     $reqIdDetail = (int) substr($dataDetailNew, 2,4);
  45.  
  46.     $iddetail = 'DP' . sprintf("%04s", $reqIdDetail);
  47.  
  48. //end of format
  49.  
  50.     echo "<form method='POST' action='../proses/doInsertFormPurchase.php' >";
  51.      echo "<table align='center'>";
  52.       echo "<tr bgcolor='iceblue'>";
  53.        echo "<td align='center' colspan='5' width='450' ><font face='calibri' size='6' color='white' >SKY NET POS SYSTEM
  54.              </br> Purchasing Form </td>";
  55.       echo "</tr>";
  56.       echo "<tr bgcolor='iceblue'>";
  57.        echo "<td align='left' colspan='3'><font face='calibri' size='4' color='white' >No Form:</br>
  58.              $idpembelian</td>";
  59.        echo "<td align='right' colspan='2'><font face='calibri' size='4' color='white' >$bulan </br> $tanggal </td>";
  60.       echo "</tr>";
  61.       echo "<tr bgcolor='iceblue'>";
  62.        echo "<td align='center' ><font face='calibri' size='4' color='white' >No</td>";
  63.        echo "<td align='center' ><font face='calibri' size='4' color='white' >Merk Product </td>";
  64.        echo "<td align='center' ><font face='calibri' size='4' color='white' >Purchase Price </td>";
  65.        echo "<td align='center' ><font face='calibri' size='4' color='white' >Sold Price </td>";
  66.        echo "<td align='center' ><font face='calibri' size='4' color='white' >QTY </td>";
  67.       echo "</tr>";
  68.  
  69. //select data list
  70.  
  71.       $nomor=0;
  72.  
  73.       for ($i=0; $i<$totalItem; $i++){
  74.      
  75.       $nomor++;
  76.       $iddetail++;
  77.  
  78.       echo "<input type='hidden' name='iddetail[]' value='$iddetail'>";
  79.       echo "<input type='hidden' name='idpembelian[]' value='$idpembelian'>";
  80.       echo "<input type='hidden' name='date[]' value='$date'>";
  81.       echo "<input type='hidden' name='nomor[]' value='$nomor'>";
  82.       echo "<tr bgcolor='iceblue'>";
  83.        echo "<td align='center'><font face='calibri' size='4' color='white' >$nomor</td>";
  84.        echo "<td align='center'><font face='calibri' size='4' color='white' ><SELECT name='nameID[]'>";
  85.                
  86.                 $sqlSelectId = "SELECT id_produk, merk_produk from master_produk";
  87.                 $resultSelectId = mysql_query($sqlSelectId, $conn)or
  88.                     die(mysql_error()."An error occure in SQL Query <br> Query: $sqlSelectId");
  89.  
  90.                 while ($line = mysql_fetch_row($resultSelectId)) {
  91.                     $idproduk = $line[0];
  92.                     $merk = $line[1];
  93.  
  94.                     echo "<option value='$idproduk, $merk'>$merk</option>";
  95.                 }
  96.  
  97.        echo "</td>";
  98.        echo "<td align='center'><input type='text' name='hargabeli[]' size='14'></td>";
  99.        echo "<td align='center'><input type='text' name='hargajual[]' size='14'> </td>";
  100.        echo "<td align='center'><input type='text' name='qty[]' size='1'> </td>";
  101.       echo "</tr>";
  102.       }
  103.  
  104. //end of select data
  105.  
  106.       echo "<tr bgcolor='iceblue'>";
  107.        echo "<td align='center' colspan='5'><input type='submit' value='Save' ></td>";
  108.       echo "</tr>";
  109.      echo "</table>";
  110.     echo "</form>";
  111.  
  112. ?>
  113.  
  114. </body>
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment