<?php
/**
	Page type C = Costcenter
	Page type P = Project
	
	CREATE NEW COSTCENTERS/PROJECTS BASED ON ROOT COSTCENTER/PROJECT
**/

session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}


include("config.inc.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");


if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

$pagetype = $_GET['pagetype'];


if ($pagetype == 'C'){
	$title = "New Costcenter";
	$root = "Costcenter Code Root";
	$newC = "New Costcenter Code";
}	
else if ($pagetype == 'P'){
	$title = "New Project";
	$root = "Project Code Root";
	$newC = "New Project Code";
}
print <<<HERE
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="css/style.css">
<title>$title</title>
<script type="text/javascript" language="javascript">

function CopyCost(){
	if (document.NewCostProj.rootCode.value =='' || document.NewCostProj.newCode.value =='')
		alert("Please fill in the Required Fields!");
	else{
		document.NewCostProj.action= 'Form_NewCostcenter_action.php';
		document.NewCostProj.submit();
}
}
</script>

<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}

.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; }
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}

.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #000000 ;font-size: 10px;}

</style>

</head>
<body >
<form name='NewCostProj' method='post' action=''>
<input type='hidden' name='pagetype' id='pagetype' value='$pagetype'>		    
HERE;

echo"<table cellpadding='0' cellspacing='0' border='0'  align='left' style='table-layout:fixed' >";
echo"<tr>
		<td id='search-top1' style='height:34px; width:31px;'>&nbsp;</td>
	  	<td id='search-top2' style='height:34px; width:690px' align='center' valign='middle'>
			<table border='0'>
			<tr><td><span class='style3'>$title
			</span></td></tr>
			</table>
		</td>
		<td id='search-top3' style='height:34px; width:31px;'>&nbsp;</td>
	</tr>";

echo"<tr><td id='search-content1' style='width:31px;'>&nbsp;</td>
		 <td id='search-content2' >";
echo"<table border='0' style='table-layout:fixed' width=>
	  <col width=150>
	  <col width=200>
	  <col width=200>
	  <tr class='Search-header-bg'>
		<td height='15' align='center' colspan='3'> <button type='button' id='btnSubmit' name='btnSubmit' onclick='CopyCost(); return false;' title='Copy'><span><span>Copy</span></span></button></td>
	  </tr>     
	  <tr class='Search-header-bg'>
		<td height='15' align='center' colspan='3'><font size='1' color='#FF0000' face='Verdana'><b>".$message."</b></font></td>
	  </tr>	";

echo "<tr height='30px'><td><b>$root</b></td><td><input type='text' name='rootCode' title='Root Code' id='rootCode' value='$rootCode' maxlength='20' style='box-shadow: lightgrey 1px 1px;width: 150px;'></td><td ></td></tr>";	  
echo "<tr height='30px'><td><b>$newC</b></td><td><input type='text' name='newCode' title='New Code' id='newCode' value='$newCode' maxlength='20' style='box-shadow: lightgrey 1px 1px;width: 150px;'></td>
			<td><input type='text' name='newDesc' id='newDesc' value='$newDesc' title='Description' style='box-shadow: lightgrey 1px 1px;width: 180px;'></td></tr>";	  

	  
echo "	  </table><td id='search-content3' style='width:31px;'>&nbsp;</td></tr>
	  <tr >
		<td id='search-bottom1' style='height:34px; width:31px;'>&nbsp;</td>
		<td id='search-bottom2' style='height:34px; ' valign='top'><td id='search-bottom3' style='height:34px; width:31px;'>&nbsp;</td></tr></table>";

print <<<HERE
</form>
</body>

HERE;

?>