<?php
session_start();
if($_SESSION[id]!="")
{
include ('dbf.php');
?>
<html dir="rtl">
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>نرم افزار کتابداری نوین</title>

</head>
<body bgcolor="#FDE2C5">
<?php include ('header.php'); ?>
<table width="90%" align="center" border="0">
	<tr>
		<td align="center" valign="bottom" height="70">
			<?php  include ('menu.php'); ?>
		</td>
	</tr>
</table>
<script src="ajax1.js"></script>
<br/>

<?php
$fg10=mysql_query("select * from book_group1 where (city='{$_SESSION['city']}')   ");
$v10=mysql_fetch_assoc($fg10);

$fg16=mysql_query("select * from book_group where (ip='{$_GET['ip']}' and city='{$_SESSION['city']}') order by id   ");
$v16=mysql_fetch_assoc($fg16);
if ($_GET['mode']=='group' or isset($_POST['group_ok']))
{
if (isset($_POST['group_ok']))
{
	mysql_query("update  ketab  set sath='{$_POST['sath']}',sath1='{$_POST['sath1']}' where (ip='{$_POST['ip']}' and city='{$_SESSION['city']}')");
	$ipp=$_POST['ip'];
	?>
	<script>
		window.alert("                 .گروه بندی کتاب ، ذخیره شد");
	</script>
	<?php
}
else
$ipp=$_GET['ip'];
?>
<form name="jk" id="jk" method="post" action="book_group1.php">
<input name="ip" type="hidden" value="<?php echo $ipp; ?>">
<table width="90%" align="center" border="2" style="border-color:blue">
	<tr>
		<td align="center" height="350">
			<table width="40%" align="center" border="1" bgcolor="#BBD9EE">
				<tr>
					<td align="right" style="font-family:tahoma" colspan="2" bgcolor="#488AC7">
						<b>تعیین گروه کتاب:</b>
					</td>
				</tr>
				<?php
				$fg17=mysql_query("select * from ketab where (ip='{$ipp}' and city='{$_SESSION['city']}') order by id   ");
				$v17=mysql_fetch_assoc($fg17);
				?>
				<tr>
					<td align="center" style="font-family:tahoma" colspan="2">
						<b>نام کتاب:</b>
						<b style="color:red"><?php echo $v17['name'].'-'.$v17['id']; ?></b>
					</td>
				</tr>
				<tr>
					<td align="center" style="font-family:tahoma" colspan="2">
						<b>گروه:</b>
						<?php
						$fg18=mysql_query("select * from book_group where (ip='{$v17['sath1']}' and city='{$_SESSION['city']}') order by id   ");
						$v18=mysql_fetch_assoc($fg18);

						if ($v17['sath']=='1')
						$sathh1=$v10['name1'];
						if ($v17['sath']=='2')
						$sathh1=$v10['name2'];
						if ($v17['sath']=='3')
						$sathh1=$v10['name3'];
						?>
						<b style="color:red"><?php echo $sathh1.'-'.$v18['name']; ?></b>
					</td>
				</tr>
				<tr>
					<td align="center" width="50%">
						تعیین سطح:
					</td>
					<td align="center">
						<select tabindex="2" name="sath" id="sath" onchange="groupbok(this.value)"  style="font-size: 9pt;font-family:tahoma">
							<option value="" style="font-size: 9pt;font-family:tahoma">انتخاب فرمایید</option>
							<option value="1" style="font-size: 9pt;font-family:tahoma"><?php echo $v10['name1'];?></option>
							<option value="2" style="font-size: 9pt;font-family:tahoma"><?php echo $v10['name2'];?></option>
							<option value="3" style="font-size: 9pt;font-family:tahoma"><?php echo $v10['name3'];?></option>
						</select>
						<div id="tafodiv77" >
	       				</div>
					</td>
				</tr>
				<tr>
					<td align="center" style="font-family:tahoma" colspan="2" bgcolor="#488AC7">
						<button tabindex="3" name="group_ok" title="ذخیره اطلاعات" type="submit" ><img src="images/sabtf2.png"  name="neew"  border="0" width="30" height="30" ></button>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</form>
<?php
}
?>
<form name="jk" id="jk" method="post" action="book_group.php">
<input name="ip" type="hidden" value="<?php echo $_GET['ip']; ?>">
<?php
if ($_GET['mode']=='delete')
{
?>
<table width="90%" align="center" border="2" style="border-color:blue">
	<tr>
		<td align="center" height="350">
			<table width="40%" align="center">
				<tr>
					<td align="right" style="font-family:tahoma">
						<b>حذف مشخصات گروه کتاب:</b>
					</td>
				</tr>
				<tr>
					<td align="center" style="font-family:tahoma">
						<table width="90%" align="center"  bgcolor="#BBD9EE" border="1">
							<tr>
								<td>
									کد گروه:
								</td>
								<td align="center">
									<input name="id"  type="text" readonly value="<?php echo $v16['id']; ?>">
								</td>
							</tr>
							<tr>
								<td>
									تعیین سطح:
								</td>
								<td align="center">
									<?php
									if ($v16['sath']=='1')
									$sathh=$v10['name1'];
									if ($v16['sath']=='2')
									$sathh=$v10['name2'];
									if ($v16['sath']=='3')
									$sathh=$v10['name3'];
									echo $sathh;
									?>
								</td>
							</tr>

							<tr>
								<td>
									نام گروه:
								</td>
								<td align="center">
									<input name="name" type="text" readonly size="45" value="<?php echo $v16['name']; ?>">
								</td>
							</tr>
							<tr>
								<td colspan="2" align="center">
									<table align="center" >
										<tr>
											<td align="left">
												<button tabindex="3" name="del_group" title="ذخیره اطلاعات" type="submit" ><img src="images/b_drop.png"  name="neew"  border="0" width="30" height="30" ></button>
											</td>
											<td align="right">
												<button tabindex="3" name="back" title="بازگشت" type="submit" ><img src="images/r1.png"  name="neew"  border="0" width="30" height="30" ></button>
											</td>
											</form>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<?php
}
if ($_GET['mode']=='update')
{
?>
<table width="90%" align="center" border="2" style="border-color:blue">
	<tr>
		<td align="center" height="350">
			<table width="40%" align="center">
				<tr>
					<td align="right" style="font-family:tahoma">
						<b>اصلاح مشخصات گروه کتاب:</b>
					</td>
				</tr>
				<tr>
					<td align="center" style="font-family:tahoma">
						<table width="90%" align="center"  bgcolor="#BBD9EE" border="1">
							<tr>
								<td>
									کد گروه:
								</td>
								<td align="center">
									<input name="id"  type="text" tabindex="1" value="<?php echo $v16['id']; ?>">
								</td>
							</tr>
							<tr>
								<td>
									تعیین سطح:
								</td>
								<td align="center">
									<?php
									if ($v16['sath']=='1')
									$sathh=$v10['name1'];
									if ($v16['sath']=='2')
									$sathh=$v10['name2'];
									if ($v16['sath']=='3')
									$sathh=$v10['name3'];
									?>
									<select tabindex="2" name="sath" id="sath"  style="font-size: 9pt;font-family:tahoma">
										<option value="<?php echo $v16['sath']; ?>" style="font-size: 9pt;font-family:tahoma"><?php echo $sathh; ?></option>
										<option value="1" style="font-size: 9pt;font-family:tahoma"><?php echo $v10['name1']; ?></option>
										<option value="2" style="font-size: 9pt;font-family:tahoma"><?php echo $v10['name2']; ?></option>
										<option value="3" style="font-size: 9pt;font-family:tahoma"><?php echo $v10['name3']; ?></option>
									</select>
								</td>
							</tr>

							<tr>
								<td>
									نام گروه:
								</td>
								<td align="center">
									<input name="name" type="text" tabindex="3" size="45" value="<?php echo $v16['name']; ?>">
								</td>
							</tr>
							<tr>
								<td colspan="2" align="center">
									<table align="center" >
										<tr>
											<td align="left">
												<button tabindex="3" name="edit_group" title="ذخیره اطلاعات" type="submit" ><img src="images/b_edit.png"  name="neew"  border="0" width="30" height="30" ></button>
											</td>
											<td align="right">
												<button tabindex="3" name="back" title="بازگشت" type="submit" ><img src="images/r1.png"  name="neew"  border="0" width="30" height="30" ></button>
											</td>
											</form>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<?php
}
?>
</form>
<?php
}
else
include('index.php');
?>
</body>