<?php
require '../jaivejaive/jaive1NoRefresh.php';
//require '../jaivejaive/jaive1.php';
$CollectionType="";
$Desicion1="";
	//require '../jaivejaive/jaive2.php';
	$CollectionName="Books";
	$CategoryName="";
	$DeptName="";
	$TitleName="";
	$AuthorName="";
	$PublisherName="";
	$ISBNName="";
	$LocationName="";
	$PurchaseName="";
	$LoanName="";
	$ReadName="";
	$QuantityName=0;
	$DescriptionName="";
	$LocationName="";
	$PurchaseName="";
	$LoanName="";
	$ReadName="";
	$QuantityName="";
	$DescriptionName="";
	$PageCode="";
	$PageName="";
	$DeptCode="";
	$CategoryCode="";
	$BookCode="";
	$PageNumber=1;
	$Pages=1;
	$PageTypeName="Normal";
	$PageAccessCode=182;
	$PageAccessName="Public";
	$BookStatus="UNREGISTERED";

	$CollectionName="";
	$CategoryName="";
	$DeptName="";
	$TitleName="";
	$AuthorName="";
	$PublisherName="";
	$ISBNName="";


		if (isset($_POST['CollectionName']))
		$CollectionName=$_POST['CollectionName'];

		if (isset($_POST['CategoryName'])){
		$CategoryName=$_POST['CategoryName'];
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM ecategories WHERE eCategoryName='$CategoryName'");
			while($row5 = mysqli_fetch_array($result5))
			{
			$CategoryCode=$row5["eCategoryCode"];
			}
		}

		if (isset($_POST['CategoryCode'])){
		$CategoryCode=$_POST['CategoryCode'];
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM ecategories WHERE eCategoryCode='$CategoryCode'");
			while($row5 = mysqli_fetch_array($result5))
			{
			$CategoryName=$row5["eCategoryName"];
			}
		}


		if (isset($_POST['DeptName'])){
		$DeptName=$_POST['DeptName'];
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM edept WHERE eDeptName='$DeptName'");
			while($row5 = mysqli_fetch_array($result5))
			{
			$DeptCode=$row5["eDeptCode"];
			$CategoryCode=$row5["eCategoryCode"];
			$CollectionCode=$row5["eCollectionCode"];
			$DeptName=$row5["eDeptName"];
			$CategoryName=$row5["eCategoryName"];
			$CollectionName=$row5["eCollectionName"];
			$BookCode=$DeptCode."001";
			}
		}

		if (isset($_POST['DeptCode'])){
		$DeptCode=$_POST['DeptCode'];
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM edept WHERE eDeptCode='$DeptCode'");
			while($row5 = mysqli_fetch_array($result5))
			{
			$DeptCode=$row5["eDeptCode"];
			$CategoryCode=$row5["eCategoryCode"];
			$CollectionCode=$row5["eCollectionCode"];
			$DeptName=$row5["eDeptName"];
			$CategoryName=$row5["eCategoryName"];
			$CollectionName=$row5["eCollectionName"];
			$BookCode=$DeptCode."001";
			}
		}

		if (isset($_POST['TitleName'])){
		$TitleName=$_POST['TitleName'];
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		//$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eDeptName='$DeptName'");
		$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eDeptCode='$DeptCode' ORDER BY eDeptCode ASC");
			while($row5 = mysqli_fetch_array($result5))
			{
			$subBookCode=$row5["eBookCode"] +1000000001 ;
			$BookCode=substr($subBookCode,1) ;
			}
		}

		if (isset($_POST['AuthorName']))
		$AuthorName=$_POST['AuthorName'];

		if (isset($_POST['PublisherName']))
		$PublisherName=$_POST['PublisherName'];

		if (isset($_POST['ISBNName']))
		$ISBNName=$_POST['ISBNName'];

		if (isset($_POST['Pages']))
		$Pages=$_POST['Pages'];

		if (isset($_POST['LocationName']))
		$LocationName=$_POST['LocationName'];

		if (isset($_POST['PurchaseName']))
		$PurchaseName=$_POST['PurchaseName'];

		if (isset($_POST['LoanName']))
		$LoanName=$_POST['LoanName'];

		if (isset($_POST['ReadName']))
		$ReadName=$_POST['ReadName'];

		if (isset($_POST['QuantityName']))
		$QuantityName=$_POST['QuantityName'];

		if (isset($_POST['DescriptionName']))
		$DescriptionName=$_POST['DescriptionName'];



	$uploaddir=$path2eLibraryImages;
	$uploaddir2=$path2eLibraryImages;

		if($CollectionName=="Books"){
		$uploaddir=$path2eLibraryBooks;
		$uploaddir2=$path2eLibraryBooks;
		$CollectionCode="01";
		}

		if($CollectionName=="Journals"){
		$uploaddir=$path2eLibraryJournals;
		$uploaddir2=$path2eLibraryJournals;
		$CollectionCode="03";
		}

		if($CollectionName=="Magazines"){
		$uploaddir=$path2eLibraryMagazines;
		$uploaddir2=$path2eLibraryMagazines;
		$CollectionCode="02";
		}

		if($CollectionName=="Videos"){
		$uploaddir=$path2eLibraryVideos;
		$uploaddir2=$path2eLibraryVideos;
		$CollectionCode="05";
		}

		if($CollectionName=="Audios"){
		$uploaddir=$path2eLibraryAudios;
		$uploaddir2=$path2eLibraryAudios;
		$CollectionCode="04";
		}

		if($CollectionName=="Photos"){
		$uploaddir=$path2eLibraryPhotos;
		$uploaddir2=$path2eLibraryPhotos;
		$CollectionCode="06";
		}

		if($CollectionName=="Slides"){
		$uploaddir=$path2eLibrarySlides;
		$uploaddir2=$path2eLibrarySlides;
		$CollectionCode="07";
		}



if (isset($_SESSION['sBox1']))
{
$uname=$_SESSION['sBox1'];
$B1=$_SESSION['sBox1'];
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP1='$uname' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$uname=$ap1;
$B1=$ap1;
}
if (isset($_SESSION['sBox2']))
{
$nname=$_SESSION['sBox2'];
$B2=$_SESSION['sBox2'];
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP2='$nname' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$nname=$ap2;
$B2=$ap2;
}
if (isset($_SESSION['sBox3']))
{
$Lname=$_SESSION['sBox3'];
$B3 = $_SESSION['sBox3'];
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP3='$Lname' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$Lname=$ap3;
$B3=$ap3;
}
if (isset($_SESSION['sBox4']))
{
$bname=$_SESSION['sBox4'];
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP4='$bname' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$bname=$ap4;
}
if (isset($_SESSION['sRB1']))
{
$Bf=$_SESSION['sRB1'];
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP5='$Bf' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$Bf=$ap5;
}
if (isset($_SESSION['sdownloadfile']))
{
$downloadfile=$_SESSION['sdownloadfile'];
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP6='$downloadfile' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$downloadfile=$ap6;
}

if (isset($_POST['submit1']))
{
$chstatus=$_POST['submit1'];

	if($chstatus=="Cancel"){
	$fpath="$forms/frmeLibrary/frmDisplayeLibrary.php";
	$action1="$ffname$fpath";
	header("Location: $action1", true. 303);
	exit;
	}
}

$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
$action1="$ffname$fpath";
echo "<Center>";
echo "<Form Name=\"frmeLibrary1\" method=\"post\" action=\"$action1\">\n";
echo "<INPUT TYPE =\"SUBMIT\"  style=\"width:120; height: 40\" VALUE = \"New Category\" name = \"Desicion1\" >\n";
echo "<INPUT TYPE =\"SUBMIT\"  style=\"width:120; height: 40\" VALUE = \"New Department\" name = \"Desicion1\" >\n";
echo "<INPUT TYPE =\"SUBMIT\"  style=\"width:120; height: 40\" VALUE = \"Cancel\" name = \"submit1\" >\n";
echo "</Center>";
echo "</Form>";

if (isset($_POST['Desicion1']))
$Desicion1=$_POST['Desicion1'];


if($Desicion1=="New Category"){
	$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
	$action1="$ffname$fpath";
	echo "<Center>";
	echo "<Form Name=\"frmeLibrary1\" method=\"post\" action=\"$action1\">\n";

	echo "<p>";
	echo "<span style=\"text-align:center; font-size: 14.0pt; font-family: 'Times New Roman',serif; color: #000000; font-weight: normal\">
      Add New Category</span>\n";
	echo "<p>";

	echo "Select a Collection";
	echo "<br>\n";
	echo "<select size=\"1\" name=\"CollectionName\" style=\"width: 250\">\n";
	echo "<OPTION VALUE=\"Books\">Books</option>\n";
	echo "<OPTION VALUE=\"Journals\">Journals</option>\n";
	echo "<OPTION VALUE=\"Magazines\">Magazines</option>\n";
	echo "<OPTION VALUE=\"Videos\">Videos</option>\n";
	echo "<OPTION VALUE=\"Audios\">Audios</option>\n";
	echo "<OPTION VALUE=\"Photos\">Photos</option>\n";
	echo "<OPTION VALUE=\"Slides\">Slides</option>\n";
	echo "</select>\n";
	echo "<p>\n";
	echo "Enter New Category Name";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"NewCategory\" size=\"40\"  maxlenght=\"60\"  style=\"text-align:Center; background-color:#00FFFF\" Value=\"\" >";
	echo "<p><INPUT TYPE =\"SUBMIT\"  style=\"width:150; height: 40\" VALUE = \"Make New Category\" name = \"Desicion1\">\n";
	echo "<INPUT TYPE =\"SUBMIT\"  style=\"width:150; height: 40\" VALUE = \"Cancel\" name = \"submit1\"><br>\n";
	echo "</Center>";
	echo "</Form>";
return;

}


if($Desicion1=="New Department"){
	$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
	$action1="$ffname$fpath";
	echo "<Center>";
	echo "<Form Name=\"frmeLibrary1\" method=\"post\" action=\"$action1\">\n";

	echo "<br>";
	echo "<span style=\"text-align:center; font-size: 14.0pt; font-family: 'Times New Roman',serif; color: #000000; font-weight: normal\">
      Add New Department</span>\n";
	echo "<p>";

	echo "Select a Category";
	echo "<br>\n";
	$Dots=" | ";
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM ecategories ORDER BY eCollectionName, eCategoryName ASC");
	//echo "<select size=\"1\" name=\"CategoryName\" style=\"width: 250\">\n";
	echo "<select size=\"1\" name=\"CategoryCode\" style=\"width: 250\">\n";
	while($row5 = mysqli_fetch_array($result5))
	{
 	$outputValue1=$row5["eCollectionName"];
 	$outputValue2=$row5["eCategoryName"];
 	$outputValue=$row5["eCategoryCode"];
	echo "<OPTION VALUE=\"$outputValue\">$outputValue1$Dots$outputValue2</option>\n";
	}
	echo "</select>\n";

	echo "<p>\n";
	echo "Enter New Department Name";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"NewDepartment\" size=\"40\"  maxlenght=\"60\"  style=\"text-align:Center; background-color:#00FFFF\" Value=\"\">";
	echo "<p><INPUT TYPE =\"SUBMIT\"  style=\"width:150; height: 40\" VALUE = \"Make New Department\" name = \"Desicion1\">\n";
	echo "<INPUT TYPE =\"SUBMIT\"  style=\"width:150; height: 40\" VALUE = \"Cancel\" name = \"submit1\"><br>\n";

	echo "</Center>";
	echo "</Form>";
return;
}


if($Desicion1=="Make New Category"){
	$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
	$action1="$ffname$fpath";
	echo "<Center>";
	echo "<Form Name=\"frmeLibrary1\" method=\"post\" action=\"$action1\">\n";

	if (isset($_POST['CollectionName'])){
	$CollectionName=$_POST['CollectionName'];
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM ecollections WHERE eCollectionName='$CollectionName'");
	while($row5 = mysqli_fetch_array($result5))
	{
 	$CollectionCode=$row5["eCollectionCode"];
	}


		if (isset($_POST['NewCategory'])){
		$NewCategory=$_POST['NewCategory'];
		$numresult=0;
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM ecategories WHERE eCategoryName='$NewCategory' AND eCollectionCode='$CollectionCode'") ;
		$numresult=mysqli_num_rows($result5);
			if($numresult<1){
 				$CategoryCode=$CollectionCode."01";
				$NewCategoryCode=$CollectionCode."01";
				mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
				$result5=mysqli_query($connect,"SELECT*  FROM ecategories WHERE eCollectionCode='$CollectionCode'");
				while($row5 = mysqli_fetch_array($result5)){
				//$CategoryCode=$row5["eCategoryCode"];
				//$NewCategoryCode=$CategoryCode+1;
 				$CategoryCode=$row5["eCategoryCode"]+10001;
				$NewCategoryCode=substr($CategoryCode,1);
				}

  					mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
  					$qry = "INSERT INTO ecategories (eCollectionCode, eCollectionName, eCategoryCode, eCategoryName) VALUES
					('" . mysqli_real_escape_string($connect, $CollectionCode) . "', '" . mysqli_real_escape_string($connect, $CollectionName) . "', '" . mysqli_real_escape_string($connect, $NewCategoryCode) . "', '" . mysqli_real_escape_string($connect, $NewCategory) . "')";
					mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());

			}else{
			echo "The Category Name You Supplied Already Exists In This Collection. Choose Another Name And Try Again";
			return;
			}


		}

	}

	echo "<INPUT TYPE =\"SUBMIT\"  style=\"width:150; height: 40\" VALUE = \"New Category Created\" name = \"\"><br>\n";

	echo "</Center>";
	echo "</Form>";

}


if($Desicion1=="Make New Department"){
	$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
	$action1="$ffname$fpath";
	echo "<Center>";
	echo "<Form Name=\"frmeLibrary1\" method=\"post\" action=\"$action1\">\n";

	if (isset($_POST['CategoryCode'])){
	$CategoryCode=$_POST['CategoryCode'];
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM ecategories WHERE eCategoryCode='$CategoryCode'");
	while($row5 = mysqli_fetch_array($result5))
	{
 	$CategoryName=$row5["eCategoryName"];
 	$CollectionCode=$row5["eCollectionCode"];
 	$CollectionName=$row5["eCollectionName"];
	}


		if (isset($_POST['NewDepartment'])){
		$NewDepartment=$_POST['NewDepartment'];
		$numresult=0;
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM edept WHERE eDeptName='$NewDepartment' AND eCategoryCode='$CategoryCode'");
		$numresult=mysqli_num_rows($result5);
			if($numresult<1){
 				$DeptCode=$CategoryCode."01";
				$NewDeptCode=$CategoryCode."01";
				mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
				$result5=mysqli_query($connect,"SELECT*  FROM edept WHERE eCategoryCode='$CategoryCode'");
				while($row5 = mysqli_fetch_array($result5)){
 				$DeptCode=$row5["eDeptCode"]+1000001;
				$NewDeptCode=substr($DeptCode,1);
				}


  					mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
  					$qry = "INSERT INTO edept (eCollectionCode, eCollectionName, eCategoryCode, eCategoryName, eDeptCode, eDeptName) VALUES
					('" . mysqli_real_escape_string($connect, $CollectionCode) . "', '" . mysqli_real_escape_string($connect, $CollectionName) . "', '" . mysqli_real_escape_string($connect, $CategoryCode) . "', '" . mysqli_real_escape_string($connect, $CategoryName) . "', '" . mysqli_real_escape_string($connect, $NewDeptCode) . "', '" . mysqli_real_escape_string($connect, $NewDepartment) . "')";
					mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());

			}else{
			echo "The Department Name You Supplied Already Exists In This Category. Choose Another name And Try Again";
			return;
			}


		}

	}

	echo "<INPUT TYPE =\"SUBMIT\"  style=\"width:150; height: 40\" VALUE = \"New Department Created\" name = \"\"><br>\n";

	echo "</Center>";
	echo "</Form>";

}



if (isset($_POST['submit1']))
{
	$sumitter=$_POST['submit1'];
	if($sumitter!=="Done"){
	$Desicion1="Display";
	}
}

//===============================main start=====================
if($Desicion1=="Display")
{
	if(empty($_FILES['attachement2']['name'])OR empty($_FILES['attachement']['name'])){
	$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
	$action1="$ffname$fpath";
	header("Location: $action1", true. 303);
	exit;
	}

//==========================================================
	$CollectionType="MainDocumentPage";
 	if($CollectionType=="MainDocumentPage") 
	{
	$picName="";
	$cp=0;
	$fsize=0;
	$extension="";
	$uploadfile="";

	$newcode=$_SESSION['sBox1'];
	$picName=$newcode;

	$Dots=".";
	$picName="$CollectionName.$Dots.$CategoryName.$Dots.$DeptName.$Dots.$TitleName";



		//========================= Main Document upload begins ===================================
	$Spacers=" ";
	$PageCode=$BookCode."0002";
	$PageName="$TitleName$Spacers"."Page0002";
	$PageNumber=2;

	$dir2 = opendir($uploaddir2);
	$files2 = array();

		if(isset($_FILES['attachement2']) && !empty($_FILES['attachement2']['name'])) {
		$allowedExts = array("jpg", "jpeg", "pjpeg", "gif", "png", "pdf", "mpeg", "mp3", "mp4", "mpeg2", "mpg", "avi", "RMI", "mid", "wmv", "wma", "wav");
		$extension = end(explode(".", $_FILES['attachement2']["name"]));
//echo "  extension:".$extension;
		$fsize = $_FILES['attachement2']["size"];
//echo "  attachement2:".$_FILES['attachement2']["type"];
			if ((($_FILES['attachement2']["type"] == "image/gif")
			|| ($_FILES['attachement2']["type"] == "image/jpeg")
			|| ($_FILES['attachement2']["type"] == "image/pjpeg")
			|| ($_FILES['attachement2']["type"] == "image/jpg")
			|| ($_FILES['attachement2']["type"] == "image/png")
			|| ($_FILES['attachement2']["type"] == "image/gif")
			|| ($_FILES['attachement2']["type"] == "application/pdf")
			|| ($_FILES['attachement2']["type"] == "video/mpeg")
			|| ($_FILES['attachement2']["type"] == "application/mp3")
			|| ($_FILES['attachement2']["type"] == "video/mp4")
			|| ($_FILES['attachement2']["type"] == "video/mpeg2")
			|| ($_FILES['attachement2']["type"] == "video/mpg")
			|| ($_FILES['attachement2']["type"] == "video/avi")
			|| ($_FILES['attachement2']["type"] == "audio/RMI")
			|| ($_FILES['attachement2']["type"] == "audio/mid")
			|| ($_FILES['attachement2']["type"] == "audio/wma")
			|| ($_FILES['attachement2']["type"] == "video/wmv")
			|| ($_FILES['attachement2']["type"] == "audio/wav"))
			&& ($_FILES['attachement2']["size"] < 10000000)
			&& in_array($extension, $allowedExts))
			{

			while($file = readdir($dir2))
			{
			array_push($files2,"$file");
			$myPcode=substr($file, 0, 7);
			}
			closedir($dir2);
			$Dots=".";
			$picName="$CollectionName$Dots$CategoryName$Dots$DeptName$Dots$TitleName";
			$uploadfile= $uploaddir2 . $picName.$Dots.$extension;
			$uploadfile=preg_replace('/\s/','',$uploadfile);
			$previousToDestroy = empty($globals['attachement2']) && !empty($_FILES['attachement2']['name']) ? '' : $uploaddir2 . $files2[ceil(count($files2)-'1')];
				if(!move_uploaded_file($_FILES['attachement2']['tmp_name'], $uploadfile)) {
				echo '<pre>
 				Your file was not uploaded please try again
 				here are your debug informations:
 				'.print_r($_FILES) .'
 				</pre>';
				}
				else
				{
				echo "<center>\n";
				$extension1=".".$extension;
				$myFilePath=$picName.$Dots.$extension;
  				mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
  				$qry = "INSERT INTO elibrary (eCollectionCode, eCollectionName, eCategoryCode, eCategoryName, eDeptCode, eDeptName, eBookCode, eBookName, eAuthorName, ePublisherName, eBookISBN, ePageSize, ePageExtCode, eBookPages, ePageCode, ePageName, ePageNumber, ePageTypeName, ePageAccessCode, ePageAccessName, ePageLocation, eBookPrice, elprice, erprice, eQty, eDescription, ePagePath, eFilePath, eUserCode, eUserName, eStatus) VALUES
				('" . mysqli_real_escape_string($connect, $CollectionCode) . "', '" . mysqli_real_escape_string($connect, $CollectionName) . "', '" . mysqli_real_escape_string($connect, $CategoryCode) . "', '" . mysqli_real_escape_string($connect, $CategoryName) . "', '" . mysqli_real_escape_string($connect, $DeptCode) . "', '" . mysqli_real_escape_string($connect, $DeptName) . "'
				, '" . mysqli_real_escape_string($connect, $BookCode) . "', '" . mysqli_real_escape_string($connect, $TitleName) . "', '" . mysqli_real_escape_string($connect, $AuthorName) . "', '" . mysqli_real_escape_string($connect, $PublisherName) . "'
				, '" . mysqli_real_escape_string($connect, $ISBNName) . "', '" . mysqli_real_escape_string($connect, $fsize) . "', '" . mysqli_real_escape_string($connect, $extension1) . "', '" . mysqli_real_escape_string($connect, $Pages) . "', '" . mysqli_real_escape_string($connect, $PageCode) . "', '" . mysqli_real_escape_string($connect, $PageName) . "'
				, '" . mysqli_real_escape_string($connect, $PageNumber) . "', '" . mysqli_real_escape_string($connect, $PageTypeName) . "', '" . mysqli_real_escape_string($connect, $PageAccessCode) . "', '" . mysqli_real_escape_string($connect, $PageAccessName) . "', '" . mysqli_real_escape_string($connect, $LocationName) . "', '" . mysqli_real_escape_string($connect, $PurchaseName) . "', '" . mysqli_real_escape_string($connect, $LoanName) . "'
				, '" . mysqli_real_escape_string($connect, $ReadName) . "', '" . mysqli_real_escape_string($connect, $QuantityName) . "'
				, '" . mysqli_real_escape_string($connect, $DescriptionName) . "', '" . mysqli_real_escape_string($connect, $uploadfile ) . "', '" . mysqli_real_escape_string($connect, $myFilePath) . "', '" . mysqli_real_escape_string($connect, $uname ) . "', '" . mysqli_real_escape_string($connect, $nname ) . "', '" . mysqli_real_escape_string($connect, $BookStatus ) . "')";
				mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
  				//-------------------------------------------

				echo $uploadfile . " <br>succesfully uploaded!";
				echo "</center>\n";
				}
			$globals['attachement2'] = $_FILES['attachement2']['name'];

			if(!empty($previousToDestroy)) { unlink($previousToDestroy); }

			}
		}
		//========================= end Main Document upload ===================================
	}


	$CollectionType="CoverPage";

 	if($CollectionType=="CoverPage") 
	{
	$cp=0;
	$fsize=0;
	$extension="";
	$uploadfile="";


	$newcode=$_SESSION['sBox1'];
	//$codePX=$_SESSION['sRB1'];
	$picName=$newcode;

	$Dots=".";
	$picName="$CollectionName.$Dots.$CategoryName.$Dots.$DeptName.$Dots.$TitleName";


	//=======Cover Page Upload Start =========================

	$Spacers=" ";
	$uploaddir=$path2eLibraryImages;
	$PageCode=$BookCode."0001";
	$PageName=$TitleName." "."Page0001";
	$PageNumber=1;
	$dir = opendir($uploaddir);
	$files = array();

		if(isset($_FILES['attachement']) && !empty($_FILES['attachement']['name'])) {
		$allowedExts = array("jpg", "jpeg", "pjpeg", "gif", "png");
		$extension = end(explode(".", $_FILES['attachement']["name"]));
		$fsize = $_FILES['attachement']["size"];
			if ((($_FILES['attachement']["type"] == "image/gif")
			|| ($_FILES['attachement']["type"] == "image/jpeg")
			|| ($_FILES['attachement']["type"] == "image/pjpeg")
			|| ($_FILES['attachement']["type"] == "image/png")
			|| ($_FILES['attachement']["type"] == "image/jpg"))
			&& ($_FILES['attachement']["size"] < 2000000)
			&& in_array($extension, $allowedExts))
			{

				while($file = readdir($dir))
				{
				array_push($files,"$file");
				$myPcode=substr($file, 0, 7);
				//echo $myPcode;
				}
			closedir($dir);
			//$picName="$newcode$codePX";
			//$picName=$CollectionName.".".$CategoryName.".".$DeptName.".".$TitleName;
			$Dots=".";
			$picName="$CollectionName$Dots$CategoryName$Dots$DeptName$Dots$TitleName";
			//echo $picName;
			//$_FILES['attachement']['name'] = ceil($picName).''.strrchr($_FILES['attachement']['name'], '.');
			//$_FILES['attachement']['name'] = $picName;
			//$uploadfile = $uploaddir . basename($_FILES['attachement']['name']);
			$uploadfile= $uploaddir . $picName.$Dots.$extension;
			$uploadfile=preg_replace('/\s/','',$uploadfile);
			$previousToDestroy = empty($globals['attachement']) && !empty($_FILES['attachement']['name']) ? '' : $uploaddir . $files[ceil(count($files)-'1')];
				if(!move_uploaded_file($_FILES['attachement']['tmp_name'], $uploadfile)) {
				echo '<pre>
 				Your file was not uploaded please try again
 				here are your debug informations:
 				'.print_r($_FILES) .'
 				</pre>';
				}
				else
				{
				echo "<center>\n";
				$extension1=".".$extension;
  				$myFilePath=$picName.$Dots.$extension;
				mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
  				$qry = "INSERT INTO elibrary (eCollectionCode, eCollectionName, eCategoryCode, eCategoryName, eDeptCode, eDeptName, eBookCode, eBookName, eAuthorName, ePublisherName, eBookISBN, ePageSize, ePageExtCode, eBookPages, ePageCode, ePageName, ePageNumber, ePageTypeName, ePageAccessCode, ePageAccessName, ePageLocation, eBookPrice, elprice, erprice, eQty, eDescription, ePagePath, eFilePath, eUserCode, eUserName, eStatus) VALUES
				('" . mysqli_real_escape_string($connect, $CollectionCode) . "', '" . mysqli_real_escape_string($connect, $CollectionName) . "', '" . mysqli_real_escape_string($connect, $CategoryCode) . "', '" . mysqli_real_escape_string($connect, $CategoryName) . "', '" . mysqli_real_escape_string($connect, $DeptCode) . "', '" . mysqli_real_escape_string($connect, $DeptName) . "'
				, '" . mysqli_real_escape_string($connect, $BookCode) . "', '" . mysqli_real_escape_string($connect, $TitleName) . "', '" . mysqli_real_escape_string($connect, $AuthorName) . "', '" . mysqli_real_escape_string($connect, $PublisherName) . "'
				, '" . mysqli_real_escape_string($connect, $ISBNName) . "', '" . mysqli_real_escape_string($connect, $fsize) . "', '" . mysqli_real_escape_string($connect, $extension1) . "', '" . mysqli_real_escape_string($connect, $Pages) . "', '" . mysqli_real_escape_string($connect, $PageCode) . "', '" . mysqli_real_escape_string($connect, $PageName) . "'
				, '" . mysqli_real_escape_string($connect, $PageNumber) . "', '" . mysqli_real_escape_string($connect, $PageTypeName) . "', '" . mysqli_real_escape_string($connect, $PageAccessCode) . "', '" . mysqli_real_escape_string($connect, $PageAccessName) . "', '" . mysqli_real_escape_string($connect, $LocationName) . "', '" . mysqli_real_escape_string($connect, $PurchaseName) . "', '" . mysqli_real_escape_string($connect, $LoanName) . "'
				, '" . mysqli_real_escape_string($connect, $ReadName) . "', '" . mysqli_real_escape_string($connect, $QuantityName) . "'
				, '" . mysqli_real_escape_string($connect, $DescriptionName) . "', '" . mysqli_real_escape_string($connect, $uploadfile ) . "', '" . mysqli_real_escape_string($connect, $myFilePath) . "', '" . mysqli_real_escape_string($connect, $uname ) . "', '" . mysqli_real_escape_string($connect, $nname ) . "', '" . mysqli_real_escape_string($connect, $BookStatus ) . "')";
				mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
  				//-------------------------------------------

				echo $uploadfile . " <br>succesfully uploaded!";
				echo "</center>\n";
				}
			$globals['attachement'] = $_FILES['attachement']['name'];
				if(!empty($previousToDestroy)) { unlink($previousToDestroy); }
			}
		}


	}

//===============================main end=====================
}

if (isset($_POST['submit1']))
{
	$sumitter=$_POST['submit1'];
	if($sumitter=="Done")
	{

		$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
		$action1="$ffname$fpath";
		echo "<center>\n";
		echo "<Form Name=\"frmpdi1\" method=\"post\" action=\"$action1\">\n";
		echo "<p><input type=\"hidden\" name=\"Box1\" value=\"$uname\"> </p>\n";
		echo "<p><input type=\"hidden\" name=\"Box2\" value=\"$nname\"> </p>\n";
		echo "<p><input type=\"submit\" name=\"submit1\" value=\"Done\"></p>\n";
		echo "<p><input type=\"submit\" name=\"submit1\" value=\"Cancel\"></p>\n";
		echo "</form>\n";
		echo "</center>\n";

	}else{

		echo "<center>\n";
		//echo "<p>";
		echo "<span style=\"text-align:center; font-size: 14.0pt; font-family: 'Cooper Black',serif; background-color:#00c000; color: #ffffff; font-weight: normal\">
      		Upload New Document</span>\n";
		echo "</center>\n";
		//echo "<p>";

		echo '<center>
		<form action="" method="post" enctype="multipart/form-data">
		<br>
		Fetch Cover Page(.jpg)
		<br>
		<input type="hidden" name="MAX_FILE_SIZE" value="10000000" > </input>
		<input type="file" name="attachement" name="attachement" size="35"></input>
		<p>
		Fetch Main Document(.pdf,.mpeg,.avi, etc)
		<br>
		<input type="hidden" name="MAX_FILE_SIZE" value="10000000" > </input>
   		<input type="file" name="attachement2" name="attachement2"  size="35"></input>
		<br>
   		<input type="hidden" name="Box1" value="$uname"></input>
		</center>';

	
	//==================================
	echo "<center>";

	echo "<p>\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"\" value=\"Collection\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Category\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<select size=\"1\" name=\"CollectionName\" style=\"width: 150\">\n";
	echo "<OPTION VALUE=\"Books\">Books</option>\n";
	echo "<OPTION VALUE=\"Journals\">Journals</option>\n";
	echo "<OPTION VALUE=\"Magazines\">Magazines</option>\n";
	echo "<OPTION VALUE=\"Videos\">Videos</option>\n";
	echo "<OPTION VALUE=\"Audios\">Audios</option>\n";
	echo "<OPTION VALUE=\"Photos\">Photos</option>\n";
	echo "<OPTION VALUE=\"Slides\">Slides</option>\n";
	echo "</select>\n";



	//echo "<p>\n";
	//echo "<br>\n";
	$Dottings=" | ";
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM ecategories ORDER BY eCollectionName, eCategoryName ASC");
	echo "<select size=\"1\" name=\"CategoryName\" style=\"width: 150\">\n";
	while($row5 = mysqli_fetch_array($result5))
	{
   	$outputValue1=$row5["eCollectionName"];
	$outputValue=$row5["eCategoryName"];
	echo "<OPTION VALUE=\"$outputValue\">$outputValue1$Dottings$outputValue</option>\n";
	}
	echo "</select>\n";

	echo "<p>\n";
	echo "";
	echo "<input type=\"text\" name=\"\" value=\"Department\" style=\"width: 300; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	$Dottings=" | ";
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM edept ORDER BY eCollectionName, eCategoryName, eDeptName ASC");
	echo "<select size=\"1\" name=\"DeptName\" style=\"width: 300\">\n";
	while($row5 = mysqli_fetch_array($result5))
	{
  		$outputValue1=$row5["eCollectionName"];
  		$outputValue2=$row5["eCategoryName"];
		$outputValue=$row5["eDeptName"];
		echo "<OPTION VALUE=\"$outputValue\">$outputValue1$Dottings$outputValue2$Dottings$outputValue</option>\n";
	}
	echo "</select>\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Document Title (Name of Book, Video etc)\" style=\"width: 300; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"TitleName\" size=\"40\" value=\"\" style=\"width: 300\">\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Author\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Publisher\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"AuthorName\" size=\"40\" value=\"\" style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"PublisherName\" size=\"40\" value=\"\"  style=\"width: 150\">\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"ISBN\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Pages | Tracks\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"ISBNName\" size=\"40\" value=\"\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"Pages\" size=\"40\" value=\"1\"  style=\"width: 150\">\n";


	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Physical location\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Purchase Price\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"locationName\" size=\"40\" value=\"NA\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"PurchaseName\" size=\"40\" value=\"0\"  style=\"width: 150\">\n";

	echo "<p>\n";

	echo "<input type=\"text\" name=\"Price\" value=\"Loan | Borrow \" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Read Price\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"LoanName\" size=\"40\" value=\"0\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"ReadName\" size=\"40\" value=\"0\"  style=\"width: 150\">\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Licensed Quantity\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Document Description\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"QuantityName\" size=\"40\" value=\"1\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"DescriptionName\" size=\"40\" value=\"NA\"  style=\"width: 150\">\n";

	echo "</center>";

	//==================================
	echo '<center>
   	<input type="submit" name="submit1" value="submit"></input>
   	<input type="submit" name="submit1" value="Done"></input>
 	</form>
	</center>';

		echo '<center><hr>
		Example, to Upload a Book Do the following:<br>
		1. Fetch The Cover Page - in jpg format.<br>
		2. Fetch The Main Document - in pdf, mpeg, avi or other formats.<br>
		Note: boxes should not be left blank.<p>
	</center>';

	}
  		//<input type="text" name="" value="Category" style="width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: normal"></input>

}else{
		echo "<center>\n";
		//echo "<p>";
		echo "<span style=\"text-align:center; font-size: 14.0pt; font-family: 'Cooper Black',serif; background-color:#00c000; color: #ffffff; font-weight: normal\">
      		Upload New Document</span>\n";
		echo "</center>\n";
		//echo "<p>";

		echo '<center>
		<form action="" method="post" enctype="multipart/form-data">
		<br>
		Fetch Cover Page(.jpg)
		<br>
		<input type="hidden" name="MAX_FILE_SIZE" value="10000000" > </input>
		<input type="file" name="attachement" name="attachement" size="35"></input>
		<p>
		Fetch Main Document(.pdf,.mpeg,.avi, etc)
		<br>
		<input type="hidden" name="MAX_FILE_SIZE" value="10000000" > </input>
   		<input type="file" name="attachement2" name="attachement2"  size="35"></input>
		<br>
   		<input type="hidden" name="Box1" value="$uname"></input>
		</center>';

	
	//==================================
	echo "<center>";

	echo "<p>\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"\" value=\"Collection\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Category\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<select size=\"1\" name=\"CollectionName\" style=\"width: 150\">\n";
	echo "<OPTION VALUE=\"Books\">Books</option>\n";
	echo "<OPTION VALUE=\"Journals\">Journals</option>\n";
	echo "<OPTION VALUE=\"Magazines\">Magazines</option>\n";
	echo "<OPTION VALUE=\"Videos\">Videos</option>\n";
	echo "<OPTION VALUE=\"Audios\">Audios</option>\n";
	echo "<OPTION VALUE=\"Photos\">Photos</option>\n";
	echo "<OPTION VALUE=\"Slides\">Slides</option>\n";
	echo "</select>\n";



	//echo "<p>\n";
	//echo "<br>\n";
	$Dottings=" | ";
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM ecategories ORDER BY eCollectionName, eCategoryName ASC");
	echo "<select size=\"1\" name=\"CategoryName\" style=\"width: 150\">\n";
	while($row5 = mysqli_fetch_array($result5))
	{
   	$outputValue1=$row5["eCollectionName"];
	$outputValue=$row5["eCategoryName"];
	echo "<OPTION VALUE=\"$outputValue\">$outputValue1$Dottings$outputValue</option>\n";
	}
	echo "</select>\n";

	echo "<p>\n";
	echo "";
	echo "<input type=\"text\" name=\"\" value=\"Department\" style=\"width: 300; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	$Dottings=" | ";
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM edept ORDER BY eCollectionName, eCategoryName, eDeptName ASC");
	echo "<select size=\"1\" name=\"DeptName\" style=\"width: 300\">\n";
	while($row5 = mysqli_fetch_array($result5))
	{
  		$outputValue1=$row5["eCollectionName"];
  		$outputValue2=$row5["eCategoryName"];
		$outputValue=$row5["eDeptName"];
		echo "<OPTION VALUE=\"$outputValue\">$outputValue1$Dottings$outputValue2$Dottings$outputValue</option>\n";
	}
	echo "</select>\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Document Title (Name of Book, Video etc)\" style=\"width: 300; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"TitleName\" size=\"40\" value=\"\" style=\"width: 300\">\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Author\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Publisher\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"AuthorName\" size=\"40\" value=\"\" style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"PublisherName\" size=\"40\" value=\"\"  style=\"width: 150\">\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"ISBN\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Pages | Tracks\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"ISBNName\" size=\"40\" value=\"\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"Pages\" size=\"40\" value=\"1\"  style=\"width: 150\">\n";


	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Physical location\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Purchase Price\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"locationName\" size=\"40\" value=\"NA\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"PurchaseName\" size=\"40\" value=\"0\"  style=\"width: 150\">\n";

	echo "<p>\n";

	echo "<input type=\"text\" name=\"Price\" value=\"Loan | Borrow \" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Read Price\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"LoanName\" size=\"40\" value=\"0\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"ReadName\" size=\"40\" value=\"0\"  style=\"width: 150\">\n";

	echo "<p>\n";
	echo "<input type=\"text\" name=\"\" value=\"Licensed Quantity\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<input type=\"text\" name=\"\" value=\"Document Description\" style=\"width: 150; text-align:center; font-size: 11.0pt; font-family: 'Times New Roman',serif; background-color:#00c000; color: #ffffff; font-weight: Bold\">\n";
	echo "<br>\n";
	echo "<input type=\"text\" name=\"QuantityName\" size=\"40\" value=\"1\"  style=\"width: 150\">\n";

	//echo "<p>\n";
	//echo "<br>\n";
	echo "<input type=\"text\" name=\"DescriptionName\" size=\"40\" value=\"NA\"  style=\"width: 150\">\n";

	echo "</center>";

	//==================================
	echo '<center>
   	<input type="submit" name="submit1" value="submit"></input>
   	<input type="submit" name="submit1" value="Done"></input>
 	</form>
	</center>';

		echo '<center><hr>
		Example, to Upload a Book Do the following:<br>
		1. Fetch The Cover Page - in jpg format.<br>
		2. Fetch The Main Document - in pdf, mpeg, avi or other formats.<br>
		Note: boxes should not be left blank.<p>
	</center>';

}


//==========================================================
 ?>  