<?php
if($_SESSION['orgunitid_r'] != "")  header("Location: ?d=index"); 
htmltage("ຂໍ້ມູນປະເພດການຈັດຕັ້ງ");
?>
<div class="contentpage">
	<h1 class="headtitle">ລາຍການປະເພດການຈັດຕັ້ງ</h1>
	<div class="searchbox">
	<form method="get">
		<input type="hidden" name="d" value="webmaster/manage/unittype" />
		<table class="">
			<tr>
				<td>ຄົ້ນຫາ: </td>
				<td><input type="text" name="typename" placeholder="ຊື່ປະເພດການຈັດຕັ້ງ (ລາວ)" size="30" value="<?= $_GET['typename'] ?>" /></td>
				<td><input type="submit" value="Search" class="btn2" /><input type="reset" value="Reset" class="btn2" 
                onclick="document.location='?d=webmaster/manage/unittype'"  /></td>
			</tr>
		</table>
	</form>
	</div>
	
<!-- The table Select From -->

<?php if ($eqcount == 0) { ?>
	<div class="centered messagebox">
		<p class="errormessage">ບໍ່ພົບລາຍການທີ່ຄົ້ນຫາ, ກະລຸນາປ້ອນຂໍ້ມູນໃຫມ່</p>
	</div>	 	
<?php } else { ?>	  <?}?>  
<h4><?= $pagedescription ?></h4>
<form method="post" id="editable" action="?d=webmaster/manage/unittype">
	<table class = "beautified editable">
	  <tr>
	  	<th>ລຳດັບ</th>	  
	  	<th>ຊື່ປະເພດການຈັດຕັ້ງ (ລາວ)</th>	  		  		  	
	  	<th>ຊື່ປະເພດການຈັດຕັ້ງ (ອັງກິດ)</th>  		
	  	<th>ຊື່ບໍລິສັດ</th>  		
		<?php if($user_role == 1){?>
		<th>ລຶບ</th>
		<? } ?>
	  </tr>
	  <?php  
		$i = 1;
		while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ ?>
		<tr>
			<td class ="centered itemcols">
				<span><?= ($i+$start) ?></span>
				<input type="hidden" name="type[]" class="type" value="unchanged" />
				<input type="hidden" name="id[]" value="<?= $row['unittypeid'] ?>" />
			</td>
			<td class=""><input type="text" name="typename_la[]" size = "" value="<?= $row['unittypename'] ?>" /></td>					
			<td class=""><input type="text" name="typename_eng[]" size = "" value="<?= $row['unittypenameeng'] ?>" /></td>
			<td class="">
				<select name="orgid[]">
					<!---<option value="">-- ທຸກ --</option>-->
					<?php 
					$org = org();
					while ($rs = mysql_fetch_array($org,MYSQL_ASSOC)) {
						$selected = $rs['orgid'] == $row['orgid'] ? "selected" : ""; 
					?>
						<option value="<?= $rs['orgid'] ?>" <?= $selected ?>><?= $rs['orgname'] ?></option>
					<?php } ?>
				</select>
			</td>
			<?php if($user_role == 1){ ?>
			<td class="centered adjust" ><a href ="?d=webmaster/manage/unittype&del_id=<?php echo $row["unittypeid"]; ?>" 
            onclick="return confirm('ທ່ານຕ້ອງການລຶບແທ້ບໍ...?')"><img src = "img/del.ico" border = '0' width = '20p' height = '20px'  /></a> </td>						
			<?}?>
		</tr>
		<?php $i++;} ?>	
	</table>
	<?php if($user_role == 1){ ?>
	<div class="menubox">		
		<input type="button" id="addEq" class = "btn2" value="  &#3776;&#3742;&#3765;&#3784;&#3745;  " />
		<input type="button" id="reset" class = "btn2" value="  &#3725;&#3771;&#3713;&#3776;&#3749;&#3765;&#3713;  " />
		<input type="submit" class = "btn2 right" value="  &#3738;&#3761;&#3737;&#3735;&#3766;&#3713;  "  id="right" onclick="return confirm('ທ່ານຕ້ອງການບັນທຶກແທ້ບໍ...?')"/>
	</div>
	<? }?>

</form>
<div class="paging">
<?php
	if ($pagecount > 1){
		if ($pagenum > 1) echo "<a href='?d=webmaster/manage/unittype&$params&start=".(($pagenum-2)*$pagesize)."' $isselected>&lt; ກັບຄືນ</a>";
		for ($i = 0; $i < $pagecount; $i++){
			if ($i == $pagenum-1) $isselected = "class='selected'";
			else $isselected = "";
			echo "<a href='?d=webmaster/manage/unittype&$params&start=".($i*$pagesize)."' $isselected>".($i+1)."</a>";
		}
		if ($pagenum < $pagecount) echo "<a href='?d=webmaster/manage/unittype&$params&start=".($pagenum*$pagesize)."' $isselected>ຕໍ່ໄປ  &gt;</a>";
	}
?>
</div>
</div>
<table class="template hidden" id = "tab">			
	<tr>
		<td class = "centered">
			<span></span>
			<input type="hidden" name="type[]" class="type" value="added" />
			<input type="hidden" name="id[]" />
		</td>		
		<td class="eqcodecols"><input type="text" name="typename_la[]" value="" /></td>
		<td class=""><input type="text" name="typename_eng[]" size = "" value="" /></td>
		<td class="">
				<select name="orgid[]">
					<!---<option value="">-- ທຸກ --</option>-->
					<?php 
					$org = org();
					while ($rs = mysql_fetch_array($org,MYSQL_ASSOC)) {
						// $selected = $rs['orgid'] == $row['orgid'] ? "selected" : ""; 
					?>
						<option value="<?= $rs['orgid'] ?>" <?= $selected ?>><?= $rs['orgname'] ?></option>
					<?php } ?>
				</select>
			</td>		
		<td class="centered"><img src = "img/del.ico" border = '0' width = '20p' height = '20px' class = "delete1" /></td>
	</tr>
</table>