<?php
session_start();
if($_SESSION[id]!="")
{
include ('dbf.php');
if (isset($_POST['edit_group']))
{
	$pic=basename( $_FILES['picture']['name']);
	$pic2=basename( $_FILES['picture2']['name']);
	$pic3=basename( $_FILES['picture3']['name']);

	if ($_POST['kind']==1)
	{
	mysql_query("update  hand_book  set name='{$_POST['name']}',tou='{$_POST['tou']}'
	,pic='{$pic}',pic2='{$pic2}',pic3='{$pic3}',matn1='{$_POST['matn1']}',matn2='{$_POST['matn2']}',matn3='{$_POST['matn3']}'
	,user='{$_SESSION[user]}' where (ip='{$_POST['ip']}' and city='{$_SESSION['city']}')");

	copy($_FILES[picture][tmp_name],"uplowd/handbook/".$pic);
	copy($_FILES[picture2][tmp_name],"uplowd/handbook/".$pic2);
	copy($_FILES[picture3][tmp_name],"uplowd/handbook/".$pic3);
	}
	if ($_POST['kind']==2)
	{
	mysql_query("update  hand_book  set name='{$_POST['name']}',tou='{$_POST['tou']}'
	,pic='{$pic}',pic2='{$pic2}',matn1='{$_POST['matn1']}',matn2='{$_POST['matn2']}'
	,user='{$_SESSION[user]}' where (ip='{$_POST['ip']}' and city='{$_SESSION['city']}')");

	copy($_FILES[picture][tmp_name],"uplowd/maghale/".$pic);
	copy($_FILES[picture2][tmp_name],"uplowd/maghale/".$pic2);
	copy($_FILES[picture3][tmp_name],"uplowd/maghale/".$pic3);
	}
	?>
	<script>
		window.alert("                 .اطلاعات اصلاح شد");
	</script>
	<?php
}
if (isset($_POST['del_group']))
{
	$fg=mysql_query("delete from `hand_book` where (ip='{$_POST['ip']}' and kind='{$_POST['kind']}' and city='{$_SESSION['city']}')");
	?>
	<script>
		window.alert("                 .اطلاعات حذف گردید");
	</script>
	<?php
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html dir="rtl">
<head>
<title>نرم افزار کتابداری نوین</title>
</head>
<body bgcolor="#FDE2C5">
<?php
if ($_GET['kin']==1  or $_POST['kind']==1)
{
	$titr="لیست کتب خطی";
	$kin=1;
}
elseif ($_GET['kin']==2 or $_POST['kind']==2)
{
	$titr="لیست مقالات";
	$kin=2;
}
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>
<br/>
<table width="90%" align="center" border="2" style="border-color:blue">
	<tr>
		<td align="center">
			<table width="100%" align="center">
				<tr>
					<td align="center">
						<b><?php echo $titr; ?></b>
					</td>
				</tr>
				<tr>
					<td align="center">
						<table width="50%" border="1" align="center" bgcolor="aqua">
							<tr align="center" style="font-family:tahoma">
								<td width="1%">--</td>
								<td width="1%">--</td>
								<td width="5%">ردیف</td>
								<td width="15%">نام</td>
								<td  width="10%">نام تصویر</td>
							</tr>
							<?php
							$color=array('#488AC7','#BBD9EE'); $a=0;
							if ($_GET['kin']==1 or $_POST['kind']==1)
							$fg=mysql_query("select * from hand_book where (kind=1 and city='{$_SESSION['city']}') order by ip");
							if ($_GET['kin']==2 or $_POST['kind']==2)
							$fg=mysql_query("select * from hand_book where (kind=2 and city='{$_SESSION['city']}') order by ip");

							$i=1;
							while($v=mysql_fetch_assoc($fg))
							{
								$ccode=$v['ip'];
								echo "<tr  align='center'  bgcolor=$color[$a] >
								<td><a href='book1.php?ip=".$ccode."&kin=".$kin."&mode=delete'><img src='images/b_drop.png' border='0' width='20' height='20'></a></td>
								<td><a href='book1.php?ip=".$ccode."&kin=".$kin."&mode=update'><img src='images/b_edit.png' border='0' width='20' height='20'></a></td>
								<td>".$i."</td>";
								echo "<td>".$v['name']."</td>";
								echo "<td>".$v['pic']."</td>";
								$i++;
								if($a==1) $a=0;  else $a=1;
							}
							?>
							<tr>
								<td colspan="10" align="center"  bgcolor="aqua">
								<table border="0">
								<tr>
								<td>
									<a href="book2.php?kin=<?php echo $kin; ?>" tabindex="1" title="جديد">
									<img src="images/sabt2.png" name="Add"  border="0" width="46" height="41" >
									</a>
									<?php
									if ($_GET['kin']==1)
									{
									?>
									<a href="book5.php?kin=<?php echo $kin; ?>" tabindex="1" title="مشاهده موارد درخواستی">
									<img src="images/dar.png" name="Add"  border="0" width="46" height="41" >
									</a>
									<?php
									}
									?>
								</td>
								</tr>
								</table>
								</td>
							</tr>
							<?php
							if (isset($_POST['ok_group11']))
							{
								mysql_query("update  book_group1  set name1='{$_POST['name1']}',name2='{$_POST['name2']}',name3='{$_POST['name3']}'
								,user='{$_SESSION[user]}' where (city='{$_SESSION['city']}')");
							}
							if (isset($_GET['group1']))
							{
							$fg10=mysql_query("select * from book_group1 where (city='{$_SESSION['city']}')   ");
							$v10=mysql_fetch_assoc($fg10);
							?>
							<form method="post" action="book_group.php">
							<tr bgcolor="#488AC7">
								<td colspan="10" valign="middle">
								<input name="name1" type="text" value="<?php echo $v10['name1']; ?>">
								<input name="name2" type="text" value="<?php echo $v10['name2']; ?>">
								<input name="name3" type="text" value="<?php echo $v10['name3']; ?>">
								<button tabindex="3" name="ok_group11" title="ذخیره اطلاعات" type="submit" ><img src="images/b_edit.png"  name="neew"  border="0" width="30" height="30" ></button>
								<button tabindex="3" name="back" title="بازگشت" type="submit" ><img src="images/r1.png"  name="neew"  border="0" width="30" height="30" ></button>
								</td>
							</tr>
							</form>
							<?php
							}
							?>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<?php
}
else
include('index.php');
?>
</body>