<?
	include("head.php");
	include("../include/db.inc.php");
	include("../include/pager.php");	
	require_once("../include/bit_functions.inc.php");
	$db1=new db;
    $db1->open();
	if($_SESSION['uid']=='' || $_SESSION['pwd']=='')
	{
		//header("location:login.php");
	}
	if($_POST['Addnew_btn'])
   { 
	extract ($_POST);
	$num_site=mysql_num_rows(mysql_query("select id from site_var where cid='$country' "));
					if($num_site!=0){
					$msg = "This Country Name already exist";
					header("location:site_var.php?error_action='".base64_encode($msg)."'");
					}else{
	 $sql="insert into site_var (id,cid,currency,symbol,paypal_code) values ('','$country','$currency','$symbol','$paypal_code')";
		  $res=mysql_query($sql);
        }
		  }
			if($_POST['edit_btn'])
  			 { 
				extract ($_POST);
					$num_site=mysql_num_rows(mysql_query("select id from site_var where cid='$country' and id!='$site_id'"));
					if($num_site!=0){
					$msg = "This Country Name already exist";
					header("location:site_var.php?error_action='".base64_encode($msg)."'");
					}else{
				   $sql_update=mysql_query("update site_var set cid='$country',currency='$currency',symbol='$symbol',paypal_code='$paypal_code' where id=".$site_id);
				   }
		  	}
				if($_GET['del']){  
		   		$del_query=mysql_query("delete from site_var where id=".$_GET['del']);
			}
			if($_GET['id']){  
			$sql_qry1=mysql_query("select id,cid,currency,symbol,paypal_code from site_var where id=".$_GET['id']);
			$myrec=mysql_fetch_array($sql_qry1);		
			$id_found=mysql_num_rows($sql_qry1);
			}
			if($_GET['currency_symbol_id']){  
			mysql_query("update site_var set status='0'");
			mysql_query("update site_var set status='1' where id='".$_GET['currency_symbol_id']."'");
			$msg = "Change current currency symbol ";
					header("location:site_var.php?error_action='".base64_encode($msg)."'");
			
			
			
			}
			 $limit=20;
			 $i=getStart($limit);	
		     $selt="select * from site_var";
		     $sql_qry2=mysql_query(dopaging($selt,$limit));
			 $tot_found=mysql_num_rows($sql_qry2);
			 
	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="index.css" rel="stylesheet" type="text/css" />
<script src="../include/validation.js"></script>
<link rel="shortcut icon" href="<?=_BASEURL_?>/favicon.ico" />
</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:800px">
<div class="maximum"> 
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::center starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
      <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
  <tr> 
    <td width="15" valign="top">&nbsp;</td>
          <td valign="top"><br> <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">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="20%"><strong>Currency List</strong> </td>
                      <td width="54%">&nbsp;</td>
                      <td width="26%" align="right">
					  <a href="site_var.php#new" class="link5">Add New</a>
					  </td>
                    </tr>
                  </table></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" align="center">		  		  		             
			 <? if($_GET['error_action']){ print "<font color='red'><strong>".base64_decode($_GET['error_action'])."</strong></font>";}else if($_GET['action']){ print "<strong>".base64_decode($_GET['action'])."</strong>";}
                if($tot_found){
             ?>
                    <br>
                  
                    <table width="96%" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse; border-color:#FED267">
                      <tr bgcolor="#FED267"> 
					  <td width="35" align="center" ><strong><font color="#FFFFFF">S.No.</font></strong>  </td>
                        
                        <td width="130" ><strong><font color="#FFFFFF">Country Name</font></strong></td>
                        <td width="93" ><strong><font color="#FFFFFF">Currency</font></strong></td>
                        <td width="77" align="center"><strong><font color="#FFFFFF"> Symbol</font></strong></td>
					    <td width="126" align="center" ><strong><font color="#FFFFFF">Paypal Code</font></strong>  </td>
                        <td width="126" align="center" ><strong><font color="#FFFFFF">Select Site Currency</font></strong>  </td>
                        <td width="98" height="20" align="center"><strong><font color="#FFFFFF">Edit </font></strong></td>
						<td width="55" height="20" align="center"><strong><font color="#FFFFFF">Delete </font></strong></td>
                      </tr>
					 <? 
					  
					 while($myrow=mysql_fetch_array($sql_qry2)){
					 $i++;
					 if($i%2==0){$col='#E6E4E3';}else{$col='#FFFFFF';}
					
			        ?>  <form action="" method="post" enctype="multipart/form-data" name="form1">
                      <tr onMouseOver="this.style.backgroundColor='#FFECBF'" onMouseOut="this.style.backgroundColor='#ffffff'"> 
					  <td align="center" valign="top"><?=$i?></td>
                        <td > <?=get_fieldval(id,state,country,$myrow['cid'])?>  </td>
                        <td > <? echo $myrow['currency']?> </td>
                        <td align="center">  <?=$myrow['symbol']?> </td>
                        <td align="center"><?=$myrow['paypal_code']?></td>
						 <td align="center" valign="top">
						 <a href="site_var.php?currency_symbol_id=<?=$myrow['id']?>">
						 <input type="radio" name="currency_symbol" <? if($myrow['status']==1){echo "checked";}?> value="<?=$myrow['symbol']?>" /></a></td>
                        <td align="center" >
                        <a href="site_var.php?id=<?=$myrow['id']?>#edit" class="link5" title="Click To Edit">Edit</a></td>
                        <td align="center">                           
                          <a href="site_var.php?del=<?=$myrow['id']?>" onClick="return confirm('Are you sure to delete this Voucher ?');">
							  <img src="../images/category/imgdelete.gif" border="0"></a></td>
                           
                      </tr> </form>
                      <? }
						if(rightpaging()){	// if there are more than one pages then only display paging
							?>
									<tr>
										<td colspan="9" align="center"><br><? echo rightpaging(); ?></td>
									</tr>
							<?
								}	// end of paging display
							?>
					  </table>
                     <table width="96%" border="0" cellspacing="0" cellpadding="0">
                      <tr bgcolor="#E6E4E3"> 
                       </tr>
                    </table>
           
            <? }else{ echo '<br><br><br><br><strong>No record found</strong><br><br><br><br>';} ?>
            </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"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
                <td  width="709" align="right" background="img/tbl-bg.gif"></td>
                <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
              </tr>
            </table>
    </td>
    <td width="15" valign="top">&nbsp;</td>
  </tr>
</table>
  <? 
if(!$_GET['id'] ){?>
 <a name="new">  
<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 align="center" width="14%" ><strong><font color="#003366">Add New</font></strong></td>
                <td width="85%" 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 action="" method="post" enctype="multipart/form-data" name="addnewfrm" onSubmit="return valform(this)">
         <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#003366" >
          <tr bgcolor="#E6F2FF"> 
            <td width="19%" height="20">Country Name</td>
            <td width="72%"><select name="country">
      <option value="0">Select Country</option>
              <?    $country=mysql_query("select * from country order by state ");
					while($row_c=mysql_fetch_array($country))
					{
							?>
							<option value="<?=$row_c['id'];?>"><?=$row_c['state'];?></option>
							<? }?>
            </select>	
	</td>
          </tr>
           <tr bgcolor="#FFFFFF"> 
            <td height="20">Country Currency</td>
            <td><input name="currency" type="text" class="inputtext" size="40" maxlength="145"></td>
          </tr>
          <tr bgcolor="#E6F2FF"> 
            <td height="20">Country Symbol</td>
            <td><input name="symbol" type="text" class="inputtext" size="40" maxlength="145"></td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td height="20">Paypal Code</td>
            <td><input name="paypal_code" type="text" class="inputtext" size="40" maxlength="145">
			</td>
          </tr>
          <tr bgcolor="#E6F2FF"> 
            <td height="20">&nbsp;</td>
            <td><input name="Addnew_btn" type="submit" class="inputtext" value="Save" style="padding-bottom:18px;"></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></a>
	   <? }else  if($_GET['id'] && $id_found){?> 
      <a name="edit">   
<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 height="34" valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="14%"  align="center"><strong><font color="#003366">Edit</font></strong></td>
                <td width="86%" 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 action="" method="post" enctype="multipart/form-data" name="editfrm" >
         <input type="hidden" name="site_id" value="<?=$myrec['id']?>" />
        <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#003366" >
          <tr bgcolor="#E6F2FF"> 
            <td width="19%" height="20">Country Name</td>
            <td width="72%"><select name="country">
      <option value="0">Select Country</option>
              <? $country=mysql_query("select * from country order by state ");
					while($row_c=mysql_fetch_array($country))
					{
						if($myrec['cid']==$row_c['id']){	
						echo	'<option value="'.$row_c['id'].'" selected>'.$row_c['state'].'</option>';
						} else{
						echo	'<option value="'.$row_c['id'].'">'.$row_c['state'].'</option>';
						}
							 }?>
            </select>	
</td>
          </tr>
           <tr bgcolor="#FFFFFF"> 
            <td height="20">Country Currency</td>
            <td><input name="currency" type="text" class="inputtext" size="40" maxlength="145" value="<?=$myrec['currency']?>"></td>
          </tr>
          <tr bgcolor="#E6F2FF"> 
            <td height="20">Country Symbol</td>
            <td><input name="symbol" type="text" class="inputtext" size="40" maxlength="145"  value="<?=$myrec['symbol']?>"></td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td height="20">Paypal Code</td>
            <td><input name="paypal_code" type="text" class="inputtext" size="40" maxlength="145"  value="<?=$myrec['site_name']?>">
			</td>
          </tr>
          <tr bgcolor="#E6F2FF"> 
            <td height="20">&nbsp;</td>
            <td><input name="edit_btn" type="submit" class="inputtext" value="Save" style="padding-bottom:18px;"></td>
          </tr>
        </table>
        </form>
            </TD>
          <TD width="35" 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></a>
      <? }?>
   </div></div>   
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::center ends:::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
  <div class="bottom_links_show"><? include("footer.php");	?></div>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
</body>
</html>

