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


	if ($_POST['kind']==1)
	{
	mysql_query("insert into `hand_book` (name,kind,tou,matn1,pic,matn2,pic2,matn3,pic3,user,city)
	VALUES ('{$_POST['name']}','{$_POST['kind']}','{$_POST['tou']}','{$_POST['matn1']}','{$pic}','{$_POST['matn2']}','{$pic2}','{$_POST['matn3']}','{$pic3}','{$_SESSION['user']}','{$_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("insert into `hand_book` (name,kind,tou,matn1,pic,matn2,pic2,user,city)
	VALUES ('{$_POST['name']}','{$_POST['kind']}','{$_POST['tou']}','{$_POST['matn1']}','{$pic}','{$_POST['matn2']}','{$pic2}','{$_SESSION['user']}','{$_SESSION['city']}')");


	copy($_FILES[picture][tmp_name],"uplowd/maghale/".$pic);
	copy($_FILES[picture2][tmp_name],"uplowd/maghale/".$pic2);
	}
	?>
	<script>
		window.alert("مشخصات جدید ذخیره شد");
	</script>
	<?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
if ($_GET['kin']==1 or $_POST['kind']==1)
{
	$titr1="آپلود کتاب خطی جدید";
	$kin=1;
	$nam="نام کتاب";
}
elseif ($_GET['kin']==2 or $_POST['kind']==2)
{
	$titr1="آپلود مقاله جدید";
	$kin=2;
	$nam="عنوان مقاله";
}
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/>

<form name="jk" id="jk" method="post" action="book2.php"  enctype="multipart/form-data">
<input name="kind" type="hidden" value="<?php echo $kin; ?>">
<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><?php echo $titr1; ?>:</b>
					</td>
				</tr>
				<?php
				$fg16=mysql_query("select id from book_group where (city='{$_SESSION['city']}') order by id  DESC ");
				$v16=mysql_fetch_assoc($fg16);
				$vall=$v16['id']+1;
				?>
				<tr>
					<td align="center" style="font-family:tahoma">
						<table width="90%" align="center"  bgcolor="#BBD9EE" border="1">
							<tr>
								<td>
									<?php echo $nam; ?>:
								</td>
								<td align="center">
									<input name="name" size="50" type="text" tabindex="1" >
								</td>
							</tr>
							<?php
							if ($_GET['kin']==1 or $_POST['kind']==1)
							{
							?>
							<tr>
								<td>
									توضیحات
								</td>
								<td align="center">
									<textarea name="tou" tabindex="1" cols="45" rows="15"></textarea>
								</td>
							</tr>
							<?php
							}
							else
							{
							?>
							<input name="tou" type="hidden" value="">
							<?php
							}
							?>
							<tr>
								<td>
									آپلود فایل:
								</td>
								<td align="center">
									<?php
									if ($_GET['kin']==1 or $_POST['kind']==1)
									{
									?>
									شماره صفحه:
									<input name="matn1" type="text" size="5" maxlength="150" tabindex="2" />
									<?php
									}
									?>
									<input name="picture" type="file" size="15" maxlength="150" tabindex="2" />
									<?php
									if ($_GET['kin']==1 or $_POST['kind']==1)
									{
									?>
									شماره صفحه:
									<input name="matn2" type="text" size="5" maxlength="150" tabindex="2" />
									<?php
									}
									?>
									<input name="picture2" type="file" size="15" maxlength="150" tabindex="2" />
									<?php
									if ($_GET['kin']==1 or $_POST['kind']==1)
									{
									?>
									شماره صفحه:
									<input name="matn3" type="text" size="5" maxlength="150" tabindex="2" />
									<input name="picture3" type="file" size="15" maxlength="150" tabindex="2" />
									<?php
									}
									if ($_GET['kin']==2 or $_POST['kind']==2)
									{
									?>
									<input name="matn1" type="hidden" value="">
									<input name="matn2" type="hidden" value="">
									<?php
									}
									?>

								</td>
							</tr>
							<tr>
								<td colspan="2" align="center">
									<table align="center" >
										<tr>
											<td align="left">
												<button tabindex="3" name="ok_group" title="ذخیره اطلاعات" type="submit" ><img src="images/sabtf2.png"  name="neew"  border="0" width="30" height="30" ></button>
											</td>
											</form>
											<form action="book.php?kin=<?php echo $_GET['kin']?>" method="post">
											<input name="kind" type="hidden" value="<?php echo $kin; ?>">
											<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>
</form>
<?php
}
else
include('index.php');
?>
</body>