<?php
/* 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(isset( $_SESSION["sess_artistid"]) and $_SESSION["sess_artistid"]!= ""){
	$artistid = $_SESSION["sess_artistid"];
}else{
	header("Location:login.php");
	exit;
}




if(isset($_GET["txtSearch"]) and $_GET["txtSearch"]!="")
{
	$txtSearch = $_GET["txtSearch"];
	$cmbSearchType = $_GET["cmbSearchType"];
}
else if(isset($_POST["txtSearch"]) and $_POST["txtSearch"]!="")
{
	$txtSearch = $_POST["txtSearch"];
	$cmbSearchType = $_POST["cmbSearchType"];
}


if(isset($_GET['msg']))
{
	$message = $_GET['msg'];
}


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

	header("Location:".$_SERVER['PHP_SELF']."?page=".$_POST['gotoPage']);
	
		
}



$sql = " SELECT nemail_id,vtemplate_title FROM ".$tableprefix."email_templates 
		 WHERE vtemplate_flag = 'S'  
		 ORDER BY nemail_id  DESC ";
		
		
		
	if(!(isset($pagenum)))
	{
		$pagenum = 1;
	} 
	
	$limit = 10;
	
	if(empty($page))
	{
		$page = 1;
	}
	
	$result=mysql_query($sql) or die(mysql_error());						
	
	$totalrows = mysql_num_rows($result);
	
	$limitvalue = ($page - 1) * $limit;
	
	$query_string = " LIMIT $limitvalue, $limit";
	
	$sql = $sql.$query_string;
	   
	$rs = mysql_query($sql) or die(mysql_error());

	$numofpages = ceil($totalrows / $limit);

include "../includes/htmltop.php";
?>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{

  var form_name = new Array('txtSearch');		
  var display_name = new Array('Template Name');
  var count = 1;	

  if(check_fields('frmTemplate',form_name,display_name,count))	
  {
  
  	
	 document.frmTemplate.submit();	
   
  }
  else
  {
  
  		return false;
  
  }
     
}
</script>

		<body>
		<center>
		
		<div align="left" id="layout">
		
		
				
				
				<!--header area start -->
<?php

	include_once("../includes/topheader_seller.php")

?>
				
				<!--header area end -->
				
				
				
				
				<div align="left" class="main_body">
				<!--main body start -->
				
				
				
<?php
		include_once("../includes/artisttopmenu.php")
?>		
																					
								
					<div align="left" class="content_area">
					
					<!--content area start -->
							
					<div align="left" class="page_title"><?php echo TEXT_EMAIL_TEMP;?></div>
					
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
					
<!--					
					
                    <br>											
					<div align="left">																			

					<form action="" method="post" name="frmTemplate">

					<table width="100%" border="0" cellpadding="0" cellspacing="0" class="manage_top">
					  <tr>
						<td width="55%" align="left" valign="middle">
							<select name="cmbSearchType" class="textbox">
							<option value="templatename"  <? //if($cmbSearchType == "templatename" || $cmbSearchType == ""){ echo("selected"); } ?>>Template Name</option>
							</select> &nbsp;
							<input type="text" name="txtSearch"  maxlength="50" value="<? //echo(htmlentities($txtSearch)); ?>" class="textbox">
							&nbsp;
							<a style="cursor:pointer" onClick="javascript:clickSearch();"><img src="<? //php echo $imagefolder;?>/search_bttn.gif" width="60" height="19" /></a></td>
																							
						</td>
						
					  </tr>
					</table>
					</form>	  

						</div>
						
-->						
						
						<div align="left">
						
						<form action="" method="post" name="frmEmailTemplate">
					
						<table width="100%" border="0" cellpadding="0" cellspacing="0" class="manage_table">
						  <tr class="form_header">
							<th width="6%" height="23" align="center" valign="middle">#</th>
							<th width="63%" align="left" valign="middle"><?php echo TEXT_TEMP_TITLE;?></th>
							<th align="center" class="form_header" valign="middle" colspan="4"><?php echo TEXT_ACTION;?></th>
						  </tr>
					
<?php

	if(mysql_num_rows($result) > 0 )
	{
		$i = 1;
		
		while($row = mysql_fetch_array($rs))
		{
																														
?>
								
								
								
								<tr>
									<td align="center" valign="middle"><?php echo $i?></td>
									<td align="left" valign="middle"><?php echo (ucwords(str_replace('_',' ',$row["vtemplate_title"])));?></td>
									<td align="left" valign="middle" colspan="4">
										<a style="cursor:pointer" href="email_template_edit_seller.php?edit_id=<?php echo $row["nemail_id"]?>"><img border="0" src="<?php echo $imagefolder?>/btn_edit.gif" title="<?php echo TITLE_EDIT_EMAIL_TEMPLATE; ?>"></a>&nbsp;
									</td>
									
								</tr>
								
								
								
								
								
<?php
	$i++;
	
	}
											
}
else
{
										
?>										

										<tr>
											<td align="center" valign="middle" colspan="6"  class="text_information"><?php echo TEXT_NO_RECORD;?></td>
										</tr>
										
										
										
										
<?php										
}

										if($page > 1)
										{
											$pageprev = $page-1;
											
											$previous_page = "<a href=".$_SERVER['PHP_SELF']."?page=$pageprev alt='Previous' border='0' class='small_gray_button'>prev</a>";
											
										}
																														
																							
										if($page < $numofpages)
										{
											$pagenext = ($page + 1);
											
											$next = "<a href=".$_SERVER['PHP_SELF']."?page=$pagenext alt='Next' border='0' class='small_gray_button'>next</a>";
											
										}	


if($page < $numofpages || $page > 1)
{
?>

								
										<tr>
											<td align="center" colspan="8">
												<table width="100%" border="0" cellspacing="10" cellpadding="0">
													<tr align="left" valign="middle">
														<td width="21%" align="right"><?php echo $previous_page?></td>
														<td width="23%" align="right">
															Page(s) <?php echo $page ?>/<?php echo $numofpages?>&nbsp;&nbsp;Goto
														</td>
														<td width="8%" align="right">
															<select class="textarea2" name="gotoPage" style="padding:4px 5px; margin-bottom:1px; ">
<?php
									for($i=1;$i<=$numofpages;$i++)
									{		
										
										
										if($i == $_GET['page'])
										{
											$page_selected = "selected";
										}
										else
										{
											$page_selected = "";
										}
										
										
?>									
									<option value="<?php echo $i?>" <?php echo $page_selected?>><?php echo $i?></option>
									
<?php
									}
									
?>									
										</select>
														</td>
														<td width="7%">
															<a onClick="Javascript:document.frmTemplate1.submit();" class="go_button_2">Go</a>
														</td>
														<td width="41%" align="center"><?php echo $next?></td>
													</tr>
												</table>
											
										</td>
										</tr>
										<?php
										}
										?>
										</table>
										
						  </form>
										
																	

						</div>
						
						
				<!--content area end-->
								
				</div>
				
								
					<div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>
				
				
<?php
	include "../includes/footer.php";
?>


