<?php 	if(! function_exists('check_session')){ die(); } ?>

	<center>
	<?php 
	$what	= $GLOBALS['what'];
	$rows	= $GLOBALS['rows'];
	switch($what){
	case 'add':
		$link	= 'sections.php?step=insert';
		$w1		= 'إضافة';
	break;
	case 'edit':
		$link	= 'sections.php?step=update&id='.$rows['id'].'&to='.$_GET['to'];
		$w1		= 'تعديل';
	break;
	}
	?>
    <form method="post" action="<?= $link; ?>">

	  <table style="width: 90%">
		  <tr>
			  <td class="head"><?= $w1; ?> قسم</td>
		  </tr>
	  </table>
	  <table cellspacing="1" class="style4" style="width: 90%">
		  <tr>
			  <td class="right_table" >&nbsp;اسم القسم :-&nbsp;</td>
			  <td class="left_table">
				  <input name="title" type="text" value="<?= $rows['title']; ?>" />
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;وصف قصير :-&nbsp;</td>
			  <td class="left_table">
				  <input name="desc" type="text" value="<?= $rows['desc']; ?>" />
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;مخصص للأعضاء المسجلين ؟ :-&nbsp;</td>
			  <td class="left_table">
				  <select name="only_for_members">
				  <option value="1" <?php if($rows['only_for_members'] == 1){ echo 'SELECTED'; } ?>>نعم</option>
				  <option value="2" <?php if($rows['only_for_members'] == 2){ echo 'SELECTED'; } ?>>لا</option>
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;المجموعات التي تستطيع اضافة تذاكر في هذا القسم :-&nbsp;</td>
			  <td class="left_table">
				  <select name="groups_ids[]" multiple="multiple">
				  <option value="all" <?php if(in_array('all',$rows['groups_ids'])){ echo 'SELECTED'; } ?>>الكل</option>
				  <?php while($gro = mysql_fetch_array($GLOBALS['groups_query'])){ ?>
				  <option value="<?= $gro['id']; ?>" 
				  <? if(in_array($gro['id'],$rows['groups_ids'])){ echo 'SELECTED'; }?>><?= $gro['name']; ?></option>
				  <?php } ?>
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;اللغات التي يظهر فيها القسم :-&nbsp;</td>
			  <td class="left_table">
				  <select name="language_id">
				  <option value="all" <?php if($rows['languages_ids'] == 'all'){ echo 'SELECTED'; } ?>>الكل</option>
				  <?php while($lng = mysql_fetch_array($GLOBALS['languages_query'])){ ?>
				  <option value="<?= $lng['id']; ?>" 
				  <? if($rows['language_id'] == $lng['id']){ echo 'SELECTED'; }?>><?= $lng['language']; ?></option>
				  <?php } ?>
			</td>
		  </tr>

		  <tr>
			  <td class="right_table" >&nbsp;الترتيب :-&nbsp;</td>
			  <td class="left_table">
				  <input type="text" name="level" value="<?= $rows['level'] ?>" />
			</td>
		  </tr>


		  </table>

	  
  <br/>
  <br/>
  <div align="center">
		<input type="submit" value="<?= $w1; ?> القسم" class="button" />
		</div>
			</form>

</center>