<?php
session_start();

include("header.php");
include("leftSideMenu.php");
include("../config.php");

$eventId = $_GET['eid'];
if($eventId == 26) {
 $eventName = "A Night With Rabbi Shergill - DC (26th July 2014: 7:30pm)";
} else if($eventId == 27) {
  $eventName = "A Night with Rabbi Shergill - NYC (27th July: 6:30pm)";
} else if($eventId == 2){
  $eventName = "A Night with Rabbi Shergill - CA (2rd August: 6:00pm)";
  
} 

?>

<script type="text/javascript">
function confirmDelete() {
	var agree = confirm("Are you sure to delete this user");
	if (agree) return true;
	else return false ;
}
</script>

<div id="main">
	<div class="full_w">
		<div class="h_title">Ticket Registration Listing</div>
		<div>
		
		
		<table>
		<tr>
			<td><h2><?php echo $eventName; ?></h2></td>
			<td><a href="generateCSV.php?eid=<?php echo $_GET['eid'];?>"><input type="button" value="Download CSV" name="downloadcsv" class="alt_btn" style="margin-left:10px"> </a></td>
			
		</tr>
		</table>
		
		</div>
		<div style="float: right; font-size: 14px; padding: 31px;">
            <a href="event_printall.php?eid=<?php echo base64_encode($_GET['eid']) ?>">Print All tickets</a>
        </div>	
			
		<div class="entry">
			<div class="sep"></div>
		</div>
		<table>
			<thead>
				<tr>
					<th scope="col">ID</th>
					<th scope="col">Name</th>
                      <th scope="col">City</th>
                      <th scope="col">State</th>
                       <!--<th scope="col">Event</th>-->
                       <th scope="col">Is Donated</th>
                       <th scope="col">	Ticket Purchased </th>				
					<th scope="col" style="width: 65px;">Action</th>
				</tr>
			</thead>
      <?php
      $sqlGetUsers = "SELECT * FROM user_information where event_selected='".$_GET['eid']."' AND id=parent_id";
//echo "-->".$sqlGetUsers;exit;
      $usersListing = mysql_query($sqlGetUsers);
		$i=1;
      while($users = mysql_fetch_array($usersListing)){
      
      	//print_r($users['is_donated']);
        if($users['event_selected']=="26"){
                $event = "DC (26th July 2014: 7:30pm)";
        } else if ($users['event_selected']=="27"){
                $event = "NYC (27th July: 6:30pm)";
               
        } else if($users['event_selected']=="2"){
        		$event = "CA (2nd August: 6:00pm)";
        		
        }
        
       
      ?>
      <tbody>
        <tr>
          <td class="align-center"><?php echo $i;?></td>
          <td><?php echo $users['first_name'].' '.$users['last_name'];?></td>
          <td><?php echo $users['city'];?></td>
          <td><?php echo $users['state'];?></td>			
          <!--<td><?php echo $event;?></td>-->
          <td><?php if($users['is_donated'] == 1) { echo "Yes"; } else { echo "No";}?></td>
          <td><?php $testquery	= "SELECT count(*) FROM user_information WHERE parent_id = '".$users['parent_id']."' AND is_ticket_generated = 1";
					$getis_donated	= mysql_query($testquery);
					$userscount = mysql_fetch_array($getis_donated);
					print_r($userscount[0]);

          ?> </td>
          
          <td>
            
            <a href="registrationDetails.php?uid=<?php echo $users['id'];?>&eid=<?php echo $_GET['eid'];?>" title="View Details">View</a><br/>
		<?php if($users['is_donated'] == 1) { ?>
             <a href="generatepdf.php?pid=<?php echo base64_encode($users['id']);?>" title="View Details">Print Ticket</a>
                        <!--<a href="#" class="table-icon delete" title="Delete" onClick="return confirmDelete()"></a>-->
		<?php } ?>
          </td>
        </tr>
      </tbody>
      <?php $i++;
      } 
      ?>
		</table>
	</div>

</div>
<div class="clear"></div>
</div>

<?php include("footer.php"); ?>
