<?php 	if(! function_exists('check_session')){ die(); } ?>
    <style type="text/css">
	.style4 {
		border-collapse: collapse;
		border: 1px solid #c0c0c0;
	}
	.style5 {
		font-family: Tahoma;
		font-size: 9pt;
	}
	.style6 {
		font-size: 9pt;
		border-left: 0px solid #C0C0C0;
		border-right-style: solid;
		border-right-width: 0px;
		border-top: 0px solid #C0C0C0;
		border-bottom-style: solid;
		border-bottom-width: 0px;
	}
	.style7 {
		font-family: Tahoma;
		font-size: 8pt;
		border-left: 0px solid #C0C0C0;
		border-right-style: solid;
		border-right-width: 1px;
		border-top: 0px solid #C0C0C0;
		border-bottom-style: solid;
		border-bottom-width: 0px;
		height: 30px;
	}
	.style8 {
		border-collapse: collapse;
		border-left-style: solid;
		border-left-width: 1px;
		border-right: 1px solid #C0C0C0;
		border-top-style: solid;
		border-top-width: 1px;
		border-bottom: 1px solid #C0C0C0;
	}
	.style9 {
		font-size: 8pt;
	 color:silver;
	}
	.style10 {
		font-size: 8pt;
	}
	.style11 {
		color: #C0C0C0;
	}
	</style>

	<center>
	<?php 
	$what	= $GLOBALS['what'];
	$rows	= $GLOBALS['rows'];
	switch($what){
	case 'add':
		$link	= 'members.php?step=insert';
		$w1		= 'إضافة';
	break;
	case 'edit':
		$link	= 'members.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="username" type="text" value="<?= $rows['username']; ?>" />
				  <br /><span style="color: silver;font-size:8pt">يحتوي فقط على حروف و ارقام و مسافات</span>
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;كلمة المرور:-&nbsp;</td>
			  <td class="left_table">
				  <input name="password" type="text" value="" />
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;البريد الإلكتروني :-&nbsp;</td>
			  <td class="left_table">
				  <input name="email" type="text" value="<?= $rows['email']; ?>" />
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;الموقع :-&nbsp;</td>
			  <td class="left_table">
				  <input name="website" type="text" value="<?= $rows['website']; ?>" />
				  <span style="color: silver;font-size:8pt">مثل : http://mysite.com</span>
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;الدولة :-&nbsp;</td>
			  <td class="left_table">
				<?php countrys_menu($rows['country'],$GLOBALS['language']['l']);
				echo $GLOBALS['array']['country'];
				?>
			  </td>
		  </tr>
		  
		  <tr>
			  <td class="right_table" >&nbsp;المجموعة التي ينتمي إليها :-&nbsp;</td>
			  <td class="left_table">
				  <select name="group_id">
				  <?php while($gro = mysql_fetch_array($GLOBALS['groups_query'])){ ?>
				  <?php if($gro['id'] == $GLOBALS['VGroup']){ }else{ ?>
				  <option value="<?= $gro['id']; ?>" 
				  <?php if($gro['id'] == $rows['group_id']){ echo 'SELECTED'; }?>><?= $gro['name']; ?></option>
				  <?php } } ?>
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;اللغة المستخدمة	  :-&nbsp;</td>
			  <td class="left_table">
				  <select name="language">
				  <?php while($grox = mysql_fetch_array($GLOBALS['languages_query'])){ ?>
				  <option value="<?= $grox['id']; ?>" 
				  <?php if($grox['id'] == $rows['language']){ echo 'SELECTED'; }?>><?= $grox['language']; ?></option>
				  <?php } ?>
				  </select>
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;التقييم	  :-&nbsp;</td>
			  <td class="left_table">
			  <?php 
			  $Rate	= Rate($rows['votes'],$rows['rate']);
			  if($Rate > 0){ ?>
				<img src="style/img/stars/<?= $Rate; ?>.gif" alt="<?=$Rate; ?>" />
				<? }else{ ?>
				لا يوجد تقييمات !
				<? } ?>
			</td>
		  </tr>


		  </table>

	  
  <br/>
  <br/>
  <div align="center">
		<input type="submit" value="<?= $w1; ?> العضو" class="button" />
		</div>
			</form>

	<br /><br />
	<?php 
	$query	= $GLOBALS['db']->query("SELECT * FROM `linked_services` WHERE `user_id`='".$rows['id']."'");
	$num	= $GLOBALS['db']->rows_num($query);
	if($num > 0){
	?>
		<table style="width: 90%">
	<tr>
		<td class="head">الخدمات</td>
	</tr>
	</table>
	<?php
	while($services	= $GLOBALS['db']->fetch($query)){ 
		$service	= $GLOBALS['db']->fetch($GLOBALS['db']->query("SELECT * FROM `services` WHERE `id`='".$services['service_id']."'"));
		
	?>

	  <table cellspacing="1" class="style4" style="width: 90%">
		  <tr>
				<td class="right_table">الخدمة</td>
				<td class="left_table"><?php echo $service['title']; ?> | 
				<a href="services.php?step=unlink&id=<?php echo $services['id']; ?>&to=members.php?step=edit[and]id=<?= $rows['id']; ?>" style="color: red" onclick="javascript: return confirm('هل أنت متأكد ؟');">إزالة</a>
				<br /><?php echo $service['desc']; ?></td>
			</tr>
		  <tr>
				<td class="right_table">ملاحظات</td>
				<td class="left_table" style="border-top: 1px dotted #e0e0e0"><?php echo $service['text']; ?></td>
			</tr>
		<?php if($services['text'] != ''){ ?>
		  <tr>
				<td class="right_table">ملاحظات إضافية</td>
				<td class="left_table" style="border-top: 1px dotted #e0e0e0"><?php echo $services['text']; ?></td>
			</tr>
		<?php } ?>
		</table>
		<br />
		<hr style="width: 90%;border:1px dotted silver" />
		<br />
	<?php 
	}
	} 
	?>

		  
	<?php if($what == 'edit'){
  $squery	= mysql_query("SELECT `id`,`title` FROM `services`");
  if(mysql_num_rows($squery) > 0){ 
				  ?>
<br /><br />
    <form method="post" action="services.php?step=link&user_id=<?= $rows['id']; ?>&to=members.php?step=edit[and]id=<?= $rows['id']; ?>">

	  <table style="width: 90%">
		  <tr>
			  <td class="head">ربط خدمة</td>
		  </tr>
	  </table>
	  <table cellspacing="1" class="style4" style="width: 90%">
		  <tr>
			  <td class="right_table" >&nbsp;اسم الخدمة :-&nbsp;</td>
			  <td class="left_table">
				  <select name="service_id">
				  <?php
				  while($srows=mysql_fetch_array($squery)){ ?>
				  <option value="<?php echo $srows['id']; ?>"><?php echo $srows['title']; ?></option>
				  <?php }
					
				  ?>
				  </select>
			</td>
		  </tr>
		  <tr>
			  <td class="right_table" >&nbsp;ملاحظات إضافة:-&nbsp;</td>
			  <td class="left_table">
				  <textarea name="text"></textarea>
			</td>
		  </tr>

		  </table>

	  
  <br/>
  <br/>
  <div align="center">
		<input type="submit" value="ربط الخدمه" class="button" />
		</div>
			</form>

<?php } } ?>