<?php
ob_start();
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php

include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";


if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE); 
} 

if(isset( $_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= ""){
	$adminname = $_SESSION["sess_adminname"];
}else{
	header("Location:login.php");
	exit;
}


include "../includes/htmltop.php";

			
if(isset($_POST['add']))
{


	/*check whether template with the same name exists in the database*/
		
	$select_template = "SELECT * FROM ".$tableprefix."template_master WHERE LOWER(vtemplate_name) = ".GetSQLValueString(strtolower($_POST['txtTemplateName']),"text");
	$result_template = mysql_query($select_template) or die(mysql_error());
	
	if(mysql_num_rows($result_template)>0)
	{
	
		$message = "Template Name Already Exists !!";
	}
	else
	{	
	
		
		
			$insert_template = "INSERT INTO ".$tableprefix."template_master(vtemplate_name,vtop_filename,vleft_filename,vbottom_filename,vactive_status)
								VALUES(".GetSQLValueString($_POST['txtTemplateName'],"text").","
								.GetSQLValueString($_POST['txtTopFile'],"text").","
								.GetSQLValueString($_POST['txtLeftFile'],"text").","
								.GetSQLValueString($_POST['txtBottomFile'],"text").",
								'N')";
			mysql_query($insert_template) or die(mysql_error());									  

			header('Location:templates.php?msg=Template Added Successfully !!');								  
	}						  

}
?>
<body topmargin="0">
<script>
function checkAddTemplateForm()
{

  var form_name = new Array('txtTemplateName','txtTopFile','txtLeftFile','txtBottomFile');		
  var display_name = new Array('Template Name','Top File Name','Left File Name','Bottom File Name');
  var count = 4;	

  if(check_fields('frmAddTemplate',form_name,display_name,count))	
  {
  
  	
	 //document.frmAddBanner.submit();	
   
  }
  else
  {
  
  		return false;
  
  }
   
}

</script>
<table width="804" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center" >
			<table width="802" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td >
						<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
            				<tr>
              					<td>
									<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="maintext">
                  						<tr>
                    						<td>
												<?php include "../includes/topheader_admin.php";?>
												<table width="100%"  border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td valign="top" bgcolor="#FFFFFF">
															<?php 
																include "../includes/admintopmenu.php"; 
																include "../includes/dotline.php";
																
															?>
																<table width="100%"  border="0" cellspacing="0" cellpadding="0">
																<tr>
																	<td style="width:1px" class="siteborder"><img src="../images/spacer.gif"></td>
																	<td width="100%">
																		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
																			<tr>
																				<td align="center" valign="top">
																					<p>&nbsp;</p>
																						<table width="100%" class="headingbig">
																							<tr>
																							  <td align="center">Template Adding </td>
																							</tr>
																						</table>                                   
																						<table width="100%">
																							<tr>
																								<td>
																									<!-- ***************************************************** -->
																									<form name="frmAddTemplate" action="#" method="POST" onSubmit="return checkAddTemplateForm();">
																										<table cellpadding="2" cellspacing="2" width="70%" class="heading">
																											<tr><td colspan="3">&nbsp;</td></tr>
																											<tr><td colspan="3" class="message" align="left"><?php echo $message;?></td></tr>
																											<tr><td colspan="3"><span class="required_field">*</span>&nbsp;Fields are mandatory</td></tr>
																											<tr><td width="26%" align="left" valign=top>Template Name&nbsp;<span class="required_field">*</span></td><td width="2%" >&nbsp;</td>
																												<td width="72%" align="left" valign=top><input class="textbox" type="text" name="txtTemplateName" value="" size="25" maxlength="50"></td>
																											</tr>
																											<tr>
																											  <td align="left" valign=top>Top File Name&nbsp;<span class="required_field">*</span></td>
																											  <td >&nbsp;</td>
																												<td valign=top align="left"><input class="textbox" type="text" name="txtTopFile" value="" size="25" maxlength="50"></td>
																											</tr>
																											<tr><td align="left" valign=top>Left File Name&nbsp;<span class="required_field">*</span></td><td >&nbsp;</td>
																												<td valign=top align="left"><input class="textbox" type="text" name="txtLeftFile" value="" size="25" maxlength="50">&nbsp;
																												</td>
																											</tr>
																											<tr><td align="left" valign=top>Bottom File Name&nbsp;<span class="required_field">*</span></td><td >&nbsp;</td>
																												<td valign=top align="left"><input class="textbox" type="text" name="txtBottomFile" value="" size="25" maxlength="50">&nbsp;
																												</td>
																											</tr>
																											<tr><td colspan="3">&nbsp;</td></tr>
																											<tr>
																												<td colspan="3" align="center"><input type="submit" value="Add" name="add" class="button"></td>
																											</tr>
																											<tr><td colspan="3">&nbsp;</td></tr>
																										</table>
																									</form>
																									<!-- ***************************************************** -->
																								</td>
																							</tr>
																						</table>
																					
                             														
																				</td>
                                											</tr>
                           												</table>
                             										</td>
                              										<td style="width:1px" class="siteborder"><img src="../images/spacer.gif"></td>
                                  								</tr>
                     										</table>	
															<?php
																include "../includes/dotline.php";
																include "../includes/adminbottommenu.php";
																include "../includes/bottomband.php";
															?>
														</td>
                          							</tr>
                      							</table>
											</td>
                  						</tr>
									</table>
								</td>
 							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<?php 
include "../includes/footer.php";
ob_end_flush();
?>
</body>
</html>
