<?
	include("head.php");
	include("../include/db.inc.php");
	include("../include/pager.php");
	 include("../include/bit_functions.inc.php");

	$db1=new db;
    $db1->open();

	if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
 
if(isset($_POST['add_type']))
	{
		extract($_POST);
		
		 $sql_chk="select * from admin_type where type='$type'";
     $res_chk=mysql_query($sql_chk);
	if(mysql_num_rows($res_chk)>0 || $type=='')
	 {
  ?>
<script type=text/javascript language=javascript>
	    alert("Sorry This Admin already exist");
	    window.location.href="admin_type.php";
	   </script>
<?
	 } 
		else{
		 $sql="insert  into admin_type set type='$type', admin='$admin', category='$category', product ='$product', user='$user', news='$news', ads_blogs ='$ads_blogs',		 stats='$stats', country='$country', content_footer='$content_footer'";
 		 $res=mysql_query($sql);	
		}		
					
	}
	
	 if(isset($_POST['edit_type']))
	{
		extract($_POST);
		
		 $sql="update admin_type set  admin='$admin', category='$category', product ='$product', user='$user', news='$news', ads_blogs ='$ads_blogs', 
		 stats='$stats', content_footer='$content_footer', country='$country' where id=".$type_id;
 		 $res=mysql_query($sql) or die(mysql_error().$sql);	
		 header("location:admin_type.php");
					
	}
	
	if(isset($_GET['edit_id'])){
	
	 $sql_query=mysql_query("select * from admin_type where id=".$_GET['edit_id']);
	 $my_subadmin=mysql_fetch_array($sql_query);
	 
	}
	?>
	<?
	if(isset($_GET['del'])){
		$sql_qry=mysql_query("delete  from admin_type where id=".$_GET['del']);
		header("location:admin_type.php");
	}
	?>
<html >
<head>

<title>Money-Auctions Administion Console</title>
<link href="file:///C|/Documents and Settings/RAJAT/My Documents/index.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
a {
	font-size: 11px;
	color: #003366;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #003366;
}
a:hover {
	text-decoration: underline;
	color: #003366;
}
a:active {
	text-decoration: none;
	color: #333333;
}
-->
</style>
</head>

<body bgcolor="#ffffff">
<div class="admin_wrapper">
<div class="logo_show"><? include("minorlogout.php");?></div>
<div style="float:left; width:200px">
<div class="topg_links_show"><? include("left.php");	?></div>
<div class="top_links_show"><? include("belowleft1.php");	?></div></div>
<div style="float:left; width:750px">
<div class="maximum">


	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                <td background="img/bg01.gif">
				<strong>&nbsp;SUB ADMIN TYPES</strong>
				<a href="subadmin.php" style="margin-left:50px"><strong>&nbsp;Show Subadmin Details</strong></a>
				<a href="admin_type.php" style="margin-left:50px"><strong>&nbsp;Add Subadmin Type</strong></a>
				</td>
                <td width="35"><img src="img/04.gif" width="35" height="23"></td>
              </tr>
            </table>
			
			<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="22" valign="top" background="img/tbl-left04.gif"><img src="img/tbl-left04.gif" width="22" height="13"></td>
                <td valign="top" > <br>
			<table width="99%" height="74" border="1" cellpadding="1" cellspacing="1" style="border-collapse:collapse; border-color:#FED267">
                      <tr bgcolor="#FED267"> 
					   <td width="4%"  align="center"><strong><font color="#FFFFFF">S.No.</font></strong></td>
                        <td width="14%" ><strong><font color="#FFFFFF">Type</font></strong></td>
                        <td width="12%" ><strong><font color="#FFFFFF">Edit | Delete</font></strong></td>
                      </tr>
					  
					  <?
					  
					 $limit=10;
					  $i=getStart($limit);	
					  $sel_query=mysql_query(dopaging("select id,type from admin_type where type != 'superadmin'",$limit)) or die(mysql_error());
					  $num_subadmin=mysql_num_rows($sel_query);
                      while($myrow=mysql_fetch_array($sel_query)){ 
					  $i++;
					   ?>
                      <tr onMouseOver="this.style.backgroundColor='#FFECBF'" onMouseOut="this.style.backgroundColor='#ffffff'"> 
					  <td  align="center"><?=$i;?></td>
                        <td style="padding-left:5px;"><?=$myrow['type'];?></td>
                        <td style="padding-left:5px;"><a href="admin_type.php?edit_id=<?=$myrow['id']?>">Edit </a> | 
						<a href="admin_type.php?del=<?=$myrow['id']?>"  onClick="return confirm('Are you sure to delete this admin type ?');">Delete</a>
                        </td>
                        
                      
                      </tr>
                      <? 
									} if(rightpaging())?>
				<tr><td height="22" colspan=3 align=center><br>
				  <?=rightpaging()?></td></tr>
                  </table>
		
   </td>
<td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9">												</td>
              </tr>
            </table>
			
			 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33" height="12"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
                <td align="right" background="img/tbl-bg.gif"><img src="img/tbl-right05.gif" width="35" height="12"></td>
              </tr>
            </table>
			 <? if($_GET['edit_id']!=''){ ?>
			<TABLE WIDTH="78%" BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
        <TR> 
          <TD> <img border='0' src="border_img/circle_01.gif" WIDTH=36 HEIGHT=35 ALT=""></TD>
          <TD width="901" height="34" valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="29%" ><strong><font color="#003366"> Edit <?=ucfirst($my_subadmin['type']);?>Type</font></strong></td>
                <td width="69%" background="border_img/circle_02.gif">&nbsp;</td>
              </tr>
            </table></TD>
          <TD> <img border='0' src="border_img/circle_03.gif" WIDTH=35 HEIGHT=35 ALT=""></TD>
        </TR>
        <TR> 
          <TD width="36" background="border_img/circle_04.gif">&nbsp; </TD>
          <TD align="left" valign="top"> 
			<form name="form1" method="post" action=""  onSubmit="return checkform();">
			<input type="hidden" name="type_id" value="<?=$my_subadmin['id']?>">
		  <table width="68%" style="margin-left:30px; padding-bottom:10px;">
             <tr width="35">
              <td width="76" ><strong>Type :</strong></td>
              <td width="272">
			  <? if($_GET['edit_id']!=''){ 
			  echo $my_subadmin['type'];
			  }else{
			  ?>
			  <input type="text" name="type" size="25" /> 
			  <? }?>
			  </td>  </tr>
            <tr>
              <td valign="top" ><strong>Facilities :</strong></td>
              <td align="left" >
			   <input type="checkbox" value="1" style="margin-left:-10px;" <? if($my_subadmin['admin']=='1'){ echo "checked";}?> name="admin">
                &nbsp; Admin Management <br>
			  <input type="checkbox" value="1" name="category" <? if($my_subadmin['category']=='1'){ echo "checked";}?> >
                &nbsp; Category Management <br>
			  <input type="checkbox" value="1" style="margin-left:-5px;" name="product" <? if($my_subadmin['product']=='1'){ echo "checked";}?>>
                &nbsp; Product Management <br>
                <input type="checkbox" value="1" style="margin-left:-19px;" name="user" <? if($my_subadmin['user']=='1'){ echo "checked";}?>>
                &nbsp; User Management <br>
                <input type="checkbox" value="1" style="margin-left:-15px;" name="news" <? if($my_subadmin['news']=='1'){ echo "checked";}?>>
                &nbsp; News Management<br>
				<input type="checkbox" value="1" style="margin-left:-55px;" name="ads_blogs" <? if($my_subadmin['ads_blogs']=='1'){ echo "checked";}?>>
                &nbsp; Ads & Blogs<br>
                <input type="checkbox" value="1" style="margin-left:-45px;" name="stats" <? if($my_subadmin['stats']=='1'){ echo "checked";}?>>
                &nbsp; Site Statistics<br>
                <input type="checkbox" value="1" style="margin-left:-25px;" name="content_footer" <? if($my_subadmin['content_footer']=='1'){ echo "checked";}?>>
                &nbsp; Site Management <br>
				<input type="checkbox" value="1"  style="margin-left:12px;" name="country" <? if($my_subadmin['country']=='1'){ echo "checked";}?>>
                &nbsp; Countries Management 
			  </td>
            </tr>
			<br/>
			 <tr> 
                      <td align="center" colspan="2">
					 
					   <input type="submit"  name="edit_type" value="Update Type"  /></td>
					  
                      
       	    </tr>
           
          </table>
		</form>
		</TD>
          <TD width="36" background="border_img/circle_06.gif">&nbsp; </TD>
        </TR>
        <TR> 
          <TD> <img border='0' src="border_img/circle_07.gif" WIDTH=36 HEIGHT=34 ALT=""></TD>
          <TD height="34" background="border_img/circle_08.gif">&nbsp; </TD>
          <TD> <img border='0' src="border_img/circle_09.gif" WIDTH=35 HEIGHT=34 ALT=""></TD>
        </TR>
      </TABLE>
	   <? }
	  else 
	  {
	  ?>
	  <TABLE WIDTH="78%" BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
        <TR> 
          <TD> <img border='0' src="border_img/circle_01.gif" WIDTH=36 HEIGHT=35 ALT=""></TD>
          <TD width="901" height="34" valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="14%" ><strong><font color="#003366"> Add Type</font></strong></td>
                <td width="79%" background="border_img/circle_02.gif">&nbsp;</td>
              </tr>
            </table></TD>
          <TD> <img border='0' src="border_img/circle_03.gif" WIDTH=35 HEIGHT=35 ALT=""></TD>
        </TR>
        <TR> 
          <TD width="36" background="border_img/circle_04.gif">&nbsp; </TD>
          <TD align="left" valign="top"> 
			<form name="form1" method="post" action=""  onSubmit="return checkform();">
		  <table width="68%" style="margin-left:30px; padding-bottom:10px;">
             <tr width="35">
              <td width="76" ><strong>Type :</strong></td>
              <td width="272">
			  <input type="text" name="type" size="25" /> 
			  </td>  </tr>
            <tr>
              <td valign="top" ><strong>Facilities :</strong></td>
              <td align="left" >
			   <input type="checkbox" value="1" style="margin-left:-10px;"  name="admin">
                &nbsp; Admin Management <br>
			  <input type="checkbox" value="1" name="category"  >
                &nbsp; Category Management <br>
			  <input type="checkbox" value="1" style="margin-left:-5px;" name="product" >
                &nbsp; Product Management <br>
                <input type="checkbox" value="1" style="margin-left:-19px;" name="user" >
                &nbsp; User Management <br>
                <input type="checkbox" value="1" style="margin-left:-15px;" name="news" >
                &nbsp; News Management<br>
				<input type="checkbox" value="1" style="margin-left:-55px;" name="ads_blogs" >
                &nbsp; Ads & Blogs<br>
                <input type="checkbox" value="1" style="margin-left:-45px;" name="stats" >
                &nbsp; Site Statistics<br>
                <input type="checkbox" value="1" style="margin-left:-25px;" name="content_footer" >
                &nbsp; Site Management <br>
				<input type="checkbox" value="1"  style="margin-left:12px;" name="country" >
                &nbsp; Countries Management 
			  </td>
            </tr>
			<br/>
			 <tr> 
			   <td width="70" align="left" ><input type="submit"  name="add_type" value="Add Type"  /></td>
              <td width="52"><input type="reset" name="cancel" value="cancel"  /></td>
					
                      
       	    </tr>
           
          </table>
		</form>
		</TD>
          <TD width="36" background="border_img/circle_06.gif">&nbsp; </TD>
        </TR>
        <TR> 
          <TD> <img border='0' src="border_img/circle_07.gif" WIDTH=36 HEIGHT=34 ALT=""></TD>
          <TD height="34" background="border_img/circle_08.gif">&nbsp; </TD>
          <TD> <img border='0' src="border_img/circle_09.gif" WIDTH=35 HEIGHT=34 ALT=""></TD>
        </TR>
      </TABLE>
	  <? }?>
 </div></div>
<div class="bottom_links_show"><? include("footer.php");	?></div>
</div>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
</body>
</html>