<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="function/dataTables/media/css/demo_page.css">
<link rel="stylesheet" href="function/dataTables/media/css/demo_table_jui.css">
<link rel="stylesheet" href="function/dataTables/media/themes/smoothness/jquery-ui-1.8.4.custom.css">
<script type="text/javascript" src="function/dataTables/media/js/jquery.js"></script>
<script type="text/javascript" src="function/dataTables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript">
	$(document).ready( function () {
		var oTable = $('#myTables').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	function setTrColor(obj, color)
	{
		obj.style.backgroundColor=color;
		obj.onmouseout = function(){
				obj.style.backgroundColor=''; 
		}
	}
		function save_click(id,code){
		var a = confirm("Apakah anda yakin akan meyimpan data?");
		if (a == true){
			form.action ='?page=Proses-Master-Price&Act=SAVE';
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function export_data()
	{
		form.action ='./master_data/price/export_master_price.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
</script>
<form name="form" method="post" enctype="multipart/form-data">
<table width="100%">
	<tr>
		<th colspan="11">MASTER PRICE</th>
	</tr>
	<tr>
		<td colspan="11">&nbsp;</td>		
	</tr>
	<tr>
		<td colspan="11">
		Proses : <input type="button" name="simpan" value="SIMPAN" onclick="save_click();" />
		<input type="button" name="export" value="Export to Excel" onClick="export_data();" style="cursor:pointer" />
		</td>
	</tr>
</table>	
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<th>No.</th>
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Satuan</th>
		<th>Price List</th>
		<th>Currencry</th>
		<th>Nett</th>
		<th>Gross</th>
		<th>Box</th>
		<th>Pallet</th>
		<th>Kategori</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.id,a.prod_code, a.prod_name, a.prod_type, a.prod_spec, a.prod_sat, a.prod_desc, b.prod_cat
		FROM product a INNER JOIN product_category b ON b.id=a.prod_cat WHERE a.prod_cat =5 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
			$mtp = mysql_fetch_array(mysql_query("SELECT * FROM master_price WHERE mtp_prodid='$dd->id' AND mtp_status=10"));
			if(empty($mtp['id'])){
				$mtp_price = 0;
			}else{
				$mtp_price = $mtp['mtp_price'];
			}
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="left"><?=$dd->prod_code;?></td>
			<td align="left"><?=$dd->prod_name;?></td>
			<td align="center"><?=$dd->prod_sat;?></td>
			<td align="center">
				<input type="hidden" name="prodid[<?=$dd->id;?>]" value="<?=$dd->id;?>" size="10" style="text-align:right" />
				<input type="text" name="mtp_price[<?=$dd->id;?>]" value="<?=$mtp_price;?>" size="10" style="text-align:right" />
			</td>
			<td align="center">
				<select name="mtp_currency[<?=$dd->id;?>]">
					<option value="0" selected="selected">PILIH</option>
					<?php
					  $dataSql = mysql_query("SELECT currency FROM currency ORDER BY id ASC");
					  while ($dataRow = mysql_fetch_array($dataSql)) {									
						if ($dataRow['currency']== $mtp['mtp_currency']) {
								$cek = " selected";
							} else { $cek=""; }
							echo "<option value='$dataRow[currency]' $cek>$dataRow[currency]</option>";
					  }
					  $sqlData =""; 
					?>
				 </select>
			</td>
			<td align="center">
				<input type="text" name="mtp_nett[<?=$dd->id;?>]" value="<?=$mtp['mtp_nett'];?>" size="10" style="text-align:right" />
			</td>
			<td align="center">
				<input type="text" name="mtp_gross[<?=$dd->id;?>]" value="<?=$mtp['mtp_gross'];?>" size="10" style="text-align:right" />
			</td>
			<td align="center">
				<input type="text" name="mtp_box[<?=$dd->id;?>]" value="<?=$mtp['mtp_box'];?>" size="5" style="text-align:right" />
			</td>
			<td align="center">
				<input type="text" name="mtp_pallet[<?=$dd->id;?>]" value="<?=$mtp['mtp_pallet'];?>" size="5" style="text-align:right" />
			</td>
			
			<td align="left"><?=$dd->prod_cat;?></td>
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>
</form>