<?
	ob_start();
	session_start();
	 include("../include/db.inc.php"); 
	 include("../include/bit_functions.inc.php");
	   $db1=new db;
	   $db1->open();mysql_query("SET NAMES 'utf8'");

			if($_GET['del']){  
		
		   $del_query=mysql_query("delete from t123go_memvoucher where id=".$_GET['del']);
			
		}
		
		if(isset($_POST['Addnew_btn'])){
			
					$sql_addqry=mysql_query("insert into t123go_memvoucher(voucher_id,user_id,recive_date)
					values('".$_POST['voucher']."','".$_POST['uname']."','".$_POST['end_time']."')");
					$action=base64_encode(' member voucher has been send');
					header("location:member_voucher.php?action=".$action);
			
		}	
		
		// for edit  
			if(isset($_POST['edit_btn'])){
			$sql_qry=mysql_query("select * from t123go_memvoucher where voucher_id='".trim($_POST['voucher'])."' and id!=".$_GET['id']);
			$category_exists=mysql_num_rows($sql_qry);		
			if($category_exists){
			header("location:member_voucher.php?id=".$_GET['id']."&action=".base64_encode("You edited member voucher ' ".$_POST['voucher']." ' already exists"));
			}
			$sql_update="update t123go_memvoucher set voucher_id='".$_POST['voucher']."',
			user_id='".$_POST['uname']."',recive_date='".$_POST['end_time']."'
			where id=".$_GET['id'];
			mysql_query($sql_update);		
			$action=base64_encode(' member voucher has been edited');
			header("location:member_voucher.php?id=".$_GET['id']."&action=".$action);
    		}	
		
			if($_GET['id']){
			$sql_qry1=mysql_query("select * from t123go_memvoucher where id=".$_GET['id']);
			$myrec=mysql_fetch_array($sql_qry1);		
			$id_found=mysql_num_rows($sql_qry1);
			$curdat='CURDATE()';
			}
			$sql_qry2=mysql_query("select * from t123go_memvoucher ");
			$tot_found=mysql_num_rows($sql_qry2);
			//$script_arr=$data->check_exist('t123go_voucher','voucher_name');	
			
?>
 <!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>

<title>Money-Auctions Administion Console</title>
<link type="text/css" rel="stylesheet" href="../css/dhtmlgoodies_calendar.css?random=20051112" media="screen" />
<script language="JavaScript" src="../js/common.js"></script>
<script language="javascript" src="../js/dhtmlgoodies_calendar.js?random=20060118"></script>
<link href="../css/stylesheet.css" rel="stylesheet" type="text/css">

<style type="text/css">
<!--
.style1 {color: #093A9C}
.style2 {color: #FE6905}
-->
</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:800px">
<div class="maximum">
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::header starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse; border-color:#ffffff">
  <tr>
    <td><? //include("header.php");?></td>
  </tr>
</table>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::header ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->

<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::center starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<div style="margin-top:5px">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" style="border-collapse:collapse; border-color:#404193">
  <tr height="417">
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::left starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->   
    
	<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::left ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->    
<td width="81%" bgcolor="#FFFFFF" valign="top">
	<table width="98%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="text3">	
    <tr>
    <td align="center" valign="top">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
         </table>
      <br>
      <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="30%"><strong>MEMBER VOUCHER LIST</strong> </td>
                      <td width="44%">&nbsp;</td>
                      <td width="26%" align="right"><a href="member_voucher.php?#new" class="link5">
					 Add send voucher
					  </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>
                    <form action="" method="post" enctype="multipart/form-data" name="form1">
                    <table width="96%" border="0" cellspacing="1" cellpadding="1">
                      <tr bgcolor="#FED267"> 
						<td width="131" ><strong><font color="#FFFFFF">Voucher Name</font></strong></td>
                        <td width="141" ><strong><font color="#FFFFFF">Username</font></strong></td>
                         <td width="106" align="center"><strong><font color="#FFFFFF"> Amount</font></strong></td>
                         <td width="164" align="center"><strong><font color="#FFFFFF"> Valid To</font></strong></td>
                        <td width="51" ></td>
                        <td width="62" height="20" align="center"><strong><font color="#FFFFFF">Delete</font></strong></td>
                      </tr>
                    <? $i=0;
				    while($myrow=mysql_fetch_array($sql_qry2)){
					if($i%2==0){$col='#E6F2FF';}else{$col='#FFFFFF';}
			        ?>
                      <tr bgcolor="<?=$col?>"> 
                        <td > <?=get_fieldval(vid,voucher_name,t123go_voucher,$myrow['voucher_id'])?> </td>
                        <td >  <?=get_fieldval(id,uname,user,$myrow['user_id'])?></td>
                        <td align="center"><?=get_fieldval(vid,amount,t123go_voucher,$myrow['voucher_id'])?></td>
                         <td align="center">  <?=$myrow['recive_date']?> </td>
                        <td align="center" >
                        <a href="member_voucher.php?id=<?=$myrow['id']?>#edit" class="link5" title="Click To Edit"> Edit</a></td>
                        <td align="center">                           
                          <table>
                            <tr>
                              <td><? //echo $htm->mkchkbox('d[]','del[]',0,$myrow['vid'])?></td>
                              <td><a href="member_voucher.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>
                          </table> </td>
                      </tr>
                      <? $i++;}?>
                    </table>
                     <table width="96%" border="0" cellspacing="0" cellpadding="0">
                      <tr bgcolor="#FFCA95"> 
                        <td align="center" bgcolor="#95CAFF"><a href="add_voucher.php">BACK TO VOUCHER LIST</a></td>
                      </tr>
                    </table>
                    
            </form>
            <? }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></td>
    </tr>
  </table>
<br>
 <? 
	if($_GET['action']){ echo '<div align="center"><strong>'.base64_decode($_GET['action']).'</strong></div>';}
if(!$_GET['id'] && !$id_found){?><a name="new">
<TABLE WIDTH="74%" 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="19%" ><strong><font color="#003366">Add Send Voucher</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 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="#FFFFFF"> 
            <td width="19%" height="20">Voucher Name</td>
            <td width="72%"> <select name="voucher" >
    	        <option value="0">--Select Voucher--</option>
                                <? $select=mysql_query("select vid,voucher_name from t123go_voucher");
					while($mymaincat=mysql_fetch_array($select))
					{					
						echo '<option value="'.$mymaincat['vid'].'">'.$mymaincat['voucher_name'].'</option>';
				                      	}
				                 ?>
                                </select></td>
          </tr>
           <tr bgcolor="#E6F2FF"> 
            <td height="20">Username</td>
            <td>  <select name="uname" >
	            <option value="0">--Select User--</option>
                                <? $select=mysql_query("select id,uname from user ");
					while($mymaincat=mysql_fetch_array($select))
					{					
						echo '<option value="'.$mymaincat['id'].'">'.$mymaincat['uname'].'</option>';
				                      	}
				                 ?>
                                    </select></td>
              </tr>
              <tr bgcolor="#FFFFFF"> 
            <td height="20">Date</td>
            <td><input name="end_time" type="text" class="inputtext" size="40"><small>
			<input type="button" value="Cal" onClick="displayCalendar(document.addnewfrm.end_time,'yyyy/mm/dd hh:ii',this,true)">
            </small></td>
          </tr>
          <tr bgcolor="#E6F2FF"> 
            <td height="20">&nbsp;</td>
            <td><input name="Addnew_btn" type="submit" class="inputtext" value="Send"> </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  if($_GET['id'] && $id_found){?>
      <a name="edit">
<TABLE WIDTH="74%" 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="22%" align="center" ><strong><font color="#003366">Edit Member Voucher</font></strong></td>
                <td width="76%" 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" >
        <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#003366" >
          <tr bgcolor="#FFFFFF"> 
            <td width="19%" height="20">Voucher Name</td>
            <td width="72%"> <select name="voucher" >
    	        <option value=""></option>
                                <? $select=mysql_query("select vid,voucher_name from t123go_voucher");
					while($mymaincat=mysql_fetch_array($select))
					{		
					
					if($myrec['voucher_id']==$mymaincat['vid']){					
								echo '<option value="'.$mymaincat[vid].'" selected>'.$mymaincat['voucher_name'].'</option>';
								}else{
									echo '<option value="'.$mymaincat[vid].'">'.$mymaincat['voucher_name'].'</option>';
								}
					
						}
				                 ?>
                                </select></td>
          </tr>
           <tr bgcolor="#E6F2FF"> 
            <td height="20">Username</td>
            <td>  <select name="uname" >
	            <option value=""></option>
                                <? $select=mysql_query("select id,uname from user ");
					while($mymaincat=mysql_fetch_array($select)){
					
					if($myrec['user_id']==$mymaincat['id']){					
									echo '<option value="'.$mymaincat['id'].'" selected>'.$mymaincat['uname'].'</option>';
								}else{
									echo '<option value="'.$mymaincat['id'].'">'.$mymaincat['uname'].'</option>';
								}
					
					
				           	}
				                 ?>
                                    </select></td>
              </tr>
              <tr bgcolor="#FFFFFF"> 
            <td height="20">Date</td>
            <td><input name="end_time" type="text" class="inputtext" size="40" value="<?=$myrec['recive_date']?>"><small>
			<input type="button" value="Cal" onClick="displayCalendar(document.editfrm.end_time,'yyyy/mm/dd hh:ii',this,true)">
            </small></td>
          </tr>
          <tr bgcolor="#E6F2FF"> 
            <td height="20">&nbsp;</td>
            <td><input name="edit_btn" type="submit" class="inputtext" value="Edit"></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>
      <? }?>
        </td>
  </tr>
</table>
</div>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::center ends:::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
</div></div>
<div class="bottom_links_show"><? include("footer.php");	?></div>
</div>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
</body>
</html>
