403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.217.54
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/mitzvahm/wwwdevplanner/mod/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/mitzvahm/wwwdevplanner/mod/guest_form.php
<?php include('_mod_security.php'); ?>
<?php
	//var_dump($_POST);
	if (isset($_SESSION['user_id'])) :
		if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) :
			$action = "Edit";
		else :
			$action = "Add New";
		endif;
	else :
		exit();
	endif;
	if (empty($_REQUEST['ref'])) :
		$_REQUEST['ref'] = 'guests';
	endif;
	$active_tab = 'general';
	$sql = "SELECT * FROM events WHERE user_id = ".$_SESSION['user_id']."  AND id = ".$_SESSION['active_event']." ";
	$result_event = mysqli_query($GLOBALS['con'], $sql);
	if (mysqli_num_rows($result_event) > 0) :
		$row_event = mysqli_fetch_object($result_event);
	endif;
	if ($_POST['ajax_event_submitted'] == '1') :
		if (isset($_POST['active_tab'])) :
			$active_tab = $_POST['active_tab'];
		else :
			$active_tab = 'general';
		endif;
		$ar_err = array();
		if (empty($_POST['last_name'])) :
			$ar_err['last_name'] = 'Last name is required!';
			$err_flag = true;
			$err_tab = 'general';
		endif;
		if (empty($_POST['first_name'])) :
			$ar_err['first_name'] = 'First name is required!';
			$err_flag = true;
			$err_tab = 'general';
		endif;
		if (empty($_POST['guest_type'])) :
			$ar_err['guest_type'] = 'Guest type is required!';
			$err_flag = true;
			$err_tab = 'general';
		endif;
		if (!empty($_POST['guest_type'])) :
		/*
		*/
			if (($_POST['guest_type'] != 'P' && $_POST['guest_type'] != 'G' && $_POST['guest_type'] != 'C') && empty($_POST['primary_guest_id'])) :
				$ar_err['primary_guest_id'] = 'Non-primary guest requires a primary to go with!';
				$err_flag = true;
				$err_tab = 'general';
			endif;
		endif;
		if (!$err_flag) :
			$set = "primary_guest_id = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['primary_guest_id'])),'0').", ".
					"guest_type = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['guest_type']))."', ".
					"salutation = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['salutation']))."', ".
					//"salutation_other = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['salutation_other']))."', ".
					"last_name = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['last_name']))."', ".
					"first_name = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['first_name']))."', ".
					"middle_name = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['middle_name']))."', ".
					"suffix = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['suffix']))."', ".
					//"suffix_other = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['suffix_other']))."', ".
					"street = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['street']))."', ".
					"street2 = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['street2']))."', ".
					"city = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['city']))."', ".
					"state = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['state']))."', ".
					"zip = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['zip']))."', ".
					"country = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['country']))."', ".
					"phone = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['phone']))."', ".
					"mobile = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['mobile']))."', ".
					"email = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['email']))."', ".
					"facebook = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['facebook']))."', ".
					"instagram = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['instagram']))."', ".
					"twitter = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['twitter']))."', ".
					"invite_temple = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['invite_temple'])),'0').", ".
					"invite_av = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['invite_av'])),'0').", ".
					"invite_kv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['invite_kv'])),'0').", ".
					"invite_bv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['invite_bv'])),'0').", ".
					"invite_dv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['invite_dv'])),'0').", ".
					"rsvp_temple = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['rsvp_temple'])),'0').", ".
					"rsvp_av = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['rsvp_av'])),'0').", ".
					"rsvp_kv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['rsvp_kv'])),'0').", ".
					"rsvp_bv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['rsvp_bv'])),'0').", ".
					"rsvp_dv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['rsvp_dv'])),'0').", ".
					"att_temple = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['att_temple'])),'0').", ".
					"att_av = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['att_av'])),'0').", ".
					"att_kv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['att_kv'])),'0').", ".
					"att_bv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['att_bv'])),'0').", ".
					"att_dv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['att_dv'])),'0').", ".
					"table_temple = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['table_temple'])),'0').", ".
					"table_av = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['table_av'])),'0').", ".
					"table_kv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['table_kv'])),'0').", ".
					"table_bv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['table_bv'])),'0').", ".
					"table_dv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['table_dv'])),'0').", ".
					"hotel_stay = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['hotel_stay'])),'0').", ".
					"hotel = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['hotel']))."', ".
					"bus = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['bus'])),'0').", ".
					"bus_temple = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['bus_temple'])),'0').", ".
					"bus_av = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['bus_av'])),'0').", ".
					"bus_kv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['bus_kv'])),'0').", ".
					"bus_bv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['bus_bv'])),'0').", ".
					"bus_dv = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['bus_dv'])),'0').", ".
					"food_restrictions = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['food_restrictions']))."', ".
					"food_preference = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['food_preference']))."', ".
					"favor_size = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['favor_size']))."', ".
					"favor_gender = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['favor_gender']))."', ".
					"gift_received = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['gift_received'])),'0').", ".
					"gift_amt = ".nzfloat(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['gift_amt'])),'0').", ".
					"gift_card = ".nzfloat(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['gift_card'])),'0').", ".
					"gift_other = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['gift_other']))."', ".
					"gift_comment = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['gift_comment']))."', ".
					"gift_thank_you = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['gift_thank_you'])),'0').", ".
					"comments = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST['comments']))."' ";
			if ($action == 'Edit') :
				$sql = "UPDATE guests set ".$set.
					"WHERE id = ".mysqli_real_escape_string($GLOBALS['con'], trim($_REQUEST['id']))." AND user_id = ".$_SESSION['user_id']." AND event_id = ".$_SESSION['active_event'];
				mysqli_query($GLOBALS['con'], $sql) or die('Database Error!');
			else :
				if ($action == 'Add New') :
					$sql = "INSERT INTO guests SET ".
						"user_id = ".$_SESSION['user_id'].", ".
						"event_id = ".$_SESSION['active_event'].", ".
						$set;
					//echo '==='.$sql.'===';
					mysqli_query($GLOBALS['con'], $sql) or die('Database Error!');
					$_REQUEST['id'] = last_id();
				endif;
			endif;
			//****************** Favors **********************
			$favor_link_sql = "DELETE FROM guests_favors WHERE guest_id = ".mysqli_real_escape_string($GLOBALS['con'], trim($_REQUEST['id']))." AND user_id = ".$_SESSION['user_id']." AND event_id = ".$_SESSION['active_event'];
			mysqli_query($GLOBALS['con'], $favor_link_sql) or die('Database Error!');
			foreach ($_POST as $post_key => $post_value) :
				if (substr($post_key,0,11) == 'link_favor_') :
					$ar_link = explode('_',$post_key);
					if (count($ar_link) == 4) :
						$favor_link_sql = "INSERT INTO guests_favors SET ".
											"user_id = ".$_SESSION['user_id'].", ".
											"event_id = ".$_SESSION['active_event'].", ".
											"guest_id = ".mysqli_real_escape_string($GLOBALS['con'], trim($_REQUEST['id'])).", ".
											"favor_id = ".mysqli_real_escape_string($GLOBALS['con'], trim($ar_link[3])).", ".
											"venue = '".mysqli_real_escape_string($GLOBALS['con'], trim($ar_link[2]))."', ".
											"size = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST[$post_key.'_size']))."', ".
											"gender = '".mysqli_real_escape_string($GLOBALS['con'], trim($_POST[$post_key.'_gender']))."' ";
						mysqli_query($GLOBALS['con'], $favor_link_sql) or die('Database Error!');
					endif;
				endif;
			endforeach;
			//************************************************
			if ($_POST['guest_type'] == 'P') :
				$primary_id = $_REQUEST['id'];
			else :
				$primary_id = $_POST['primary_guest_id'];
			endif;
			$form_message = "Saved sucessfully!";
			if ($_POST['xsubmit'] == 'Save & Close') :
				echo "<SCRIPT>";
				echo "window.location.href = 'index.php?IX=".$_REQUEST['ref']."'";
				echo "</SCRIPT>";
			endif;
			if ($_POST['xsubmit'] == 'Save & New') :
				echo "<SCRIPT>";
				echo "window.location.href = 'index.php?IX=guest_form&ref=".$_REQUEST['ref']."'";
				echo "</SCRIPT>";
			endif;
			if ($_POST['xsubmit'] == 'Add Sig. Other') :
				echo "<SCRIPT>";
				echo "window.location.href = 'index.php?IX=guest_form&prepop_id=".$primary_id."&prepop_type=S&ref=".$_REQUEST['ref']."'";
				echo "</SCRIPT>";
			endif;
			if ($_POST['xsubmit'] == 'Add Child') :
				echo "<SCRIPT>";
				echo "window.location.href = 'index.php?IX=guest_form&prepop_id=".$primary_id."&prepop_type=C&ref=".$_REQUEST['ref']."'";
				echo "</SCRIPT>";
			endif;
		else :
			$active_tab = $err_tab;
			$form_message = "Errors found!";
		endif;
	else:
		if ($action == 'Edit') :
			$sql = "SELECT * FROM guests WHERE id = ".mysqli_real_escape_string($GLOBALS['con'], trim($_REQUEST['id']))." AND user_id = ".$_SESSION['user_id']." AND event_id = ".$_SESSION['active_event'];
			$result = mysqli_query($GLOBALS['con'], $sql) or die('Database Error!');
			if (mysqli_num_rows($result) > 0) :
				$row = mysqli_fetch_object($result);
				$_POST['primary_guest_id'] = $row->primary_guest_id;
				$_POST['guest_type'] = $row->guest_type;
				$_POST['salutation'] = $row->salutation;
				//$_POST['salutation_other'] = $row->salutation_other;
				$_POST['last_name'] = $row->last_name;
				$_POST['first_name'] = $row->first_name;
				$_POST['middle_name'] = $row->middle_name;
				$_POST['suffix'] = $row->suffix;
				//$_POST['suffix_other'] = $row->suffix_other;
				$_POST['street'] = $row->street;
				$_POST['street2'] = $row->street2;
				$_POST['city'] = $row->city;
				$_POST['state'] = $row->state;
				$_POST['zip'] = $row->zip;
				$_POST['country'] = $row->country;
				$_POST['phone'] = $row->phone;
				$_POST['mobile'] = $row->mobile;
				$_POST['email'] = $row->email;
				$_POST['facebook'] = $row->facebook;
				$_POST['instagram'] = $row->instagram;
				$_POST['twitter'] = $row->twitter;
				$_POST['invite_temple'] = $row->invite_temple;
				$_POST['invite_av'] = $row->invite_av;
				$_POST['invite_kv'] = $row->invite_kv;
				$_POST['invite_bv'] = $row->invite_bv;
				$_POST['invite_dv'] = $row->invite_dv;
				$_POST['rsvp_temple'] = $row->rsvp_temple;
				$_POST['rsvp_av'] = $row->rsvp_av;
				$_POST['rsvp_kv'] = $row->rsvp_kv;
				$_POST['rsvp_bv'] = $row->rsvp_bv;
				$_POST['rsvp_dv'] = $row->rsvp_dv;
				$_POST['att_temple'] = $row->att_temple;
				$_POST['att_av'] = $row->att_av;
				$_POST['att_kv'] = $row->att_kv;
				$_POST['att_bv'] = $row->att_bv;
				$_POST['att_dv'] = $row->att_dv;
				$_POST['table_temple'] = $row->table_temple;
				$_POST['table_av'] = $row->table_av;
				$_POST['table_kv'] = $row->table_kv;
				$_POST['table_bv'] = $row->table_bv;
				$_POST['table_dv'] = $row->table_dv;
				$_POST['hotel_stay'] = $row->hotel_stay;
				$_POST['hotel'] = $row->hotel;
				$_POST['bus'] = $row->bus;
				$_POST['bus_temple'] = $row->bus_temple;
				$_POST['bus_av'] = $row->bus_av;
				$_POST['bus_kv'] = $row->bus_kv;
				$_POST['bus_bv'] = $row->bus_bv;
				$_POST['bus_dv'] = $row->bus_dv;
				$_POST['food_restrictions'] = $row->food_restrictions;
				$_POST['food_preference'] = $row->food_preference;
				$_POST['favor_size'] = $row->favor_size;
				$_POST['favor_gender'] = $row->favor_gender;
				$_POST['gift_received'] = $row->gift_received;
				$_POST['gift_amt'] = $row->gift_amt;
				$_POST['gift_card'] = $row->gift_card;
				$_POST['gift_other'] = $row->gift_other;
				$_POST['gift_comment'] = $row->gift_comment;
				$_POST['gift_thank_you'] = $row->gift_thank_you;
				$_POST['comments'] = $row->comments;
			else :
				echo form_fatal_error('Invalid Operation!');
				return;
			endif;
		else :
			if (!empty($_REQUEST['prepop_id']) && is_numeric($_REQUEST['prepop_id'])) :
				$sql = "SELECT * FROM guests WHERE id = ".mysqli_real_escape_string($GLOBALS['con'], trim($_REQUEST['prepop_id']))." AND user_id = ".$_SESSION['user_id']." AND event_id = ".$_SESSION['active_event'];
				$result = mysqli_query($GLOBALS['con'], $sql) or die('Database Error!');
				if (mysqli_num_rows($result) > 0) :
					$row = mysqli_fetch_object($result);
					$_POST['primary_guest_id'] = $row->id;
					$_POST['last_name'] = $row->last_name;
					$_POST['street'] = $row->street;
					$_POST['street2'] = $row->street2;
					$_POST['city'] = $row->city;
					$_POST['state'] = $row->state;
					$_POST['zip'] = $row->zip;
					$_POST['country'] = $row->country;
					$_POST['phone'] = $row->phone;
					$_POST['guest_type'] = $_REQUEST['prepop_type'];
				endif;
			endif;
		endif;
	endif;
	
?>

<script>
	var active_page = '<?php echo $_REQUEST['IX']; ?>';
	var active_tab = '';
	
	check_other = function(value, other_id)
	{
		//alert(value);
		if (value == 'Other...')
		{
			$('#' + other_id).show();
		}
		else
		{
			$('#' + other_id).hide();
		}
	}
	
	switch_primary = function() 
	{
		if (document.getElementById('guest_type_p').checked || document.getElementById('guest_type_g').checked)
		{
			$('#row_primary').hide();	
			//$('#submit_ps').show();	
			//$('#submit_pc').show();	
			$('#primary_guest_id').val('');
		}
		else
		{
			$('#row_primary').show();	
			//$('#submit_ps').hide();	
			//$('#submit_pc').hide();	
		}
	}
	
	check_favor = function(favor_id, link_id, venue)
	{
		if ($('input[name="link_favor_' + venue + '_' + favor_id + '"]').attr('checked') == 'checked')
		{
			$('input[name="link_favor_' + venue + '_' + favor_id + '_size"]').attr('disabled', null);
			$('input[name="link_favor_' + venue + '_' + favor_id + '_gender"]').attr('disabled', null);
		}
		else
		{
			$('input[name="link_favor_' + venue + '_' + favor_id + '_size"]').attr('disabled', 'disabled');
			$('input[name="link_favor_' + venue + '_' + favor_id + '_size"]').attr('checked', null);
			$('input[name="link_favor_' + venue + '_' + favor_id + '_gender"]').attr('disabled', 'disabled');
			$('input[name="link_favor_' + venue + '_' + favor_id + '_gender"]').attr('checked', null);
		} 
	}

	switch_rsvp = function(type, rsvp)
	{
		var obj = document.getElementById('rsvp_' + type + '_' + rsvp);
		if (typeof obj == "undefined" || obj == null)
			return;
		if (document.getElementById('rsvp_' + type + '_' + rsvp).checked)
		{
			if (rsvp == 'y')
			{
				document.getElementById('table_' + type).disabled = false;	
				document.getElementById('att_' + type).disabled = false;	
				document.getElementById('bus_' + type).disabled = false;	
				$('.favor_input_check_' + type).attr('disabled',null).change();;
			}
			else
			{
				document.getElementById('table_' + type).disabled = true;	
				document.getElementById('att_' + type).checked = false;	
				document.getElementById('bus_' + type).checked = false;	
				document.getElementById('att_' + type).disabled = true;	
				document.getElementById('bus_' + type).disabled = true;	
				$('.favor_input_check_' + type).attr('checked',null);
				$('.favor_input_check_' + type).attr('disabled','disabled').change();
			}
		}
		else
		{
			if (rsvp == 'y')
			{
				document.getElementById('table_' + type).disabled = true;	
				document.getElementById('att_' + type).checked = false;	
				document.getElementById('bus_' + type).checked = false;	
				document.getElementById('att_' + type).disabled = true;	
				document.getElementById('bus_' + type).disabled = true;	
				$('.favor_input_check_' + type).attr('checked',null);
				$('.favor_input_check_' + type).attr('disabled','disabled').change();
			}
			else
			{
				document.getElementById('table_' + type).disabled = false;	
				document.getElementById('att_' + type).disabled = false;	
				document.getElementById('bus_' + type).disabled = false;	
				$('.favor_input_check_' + type).attr('disabled',null).change();
			}
		}
		/*
		*/
	}
	
	switch_invited = function(type)
	{
		var obj = document.getElementById('invite_' + type);
		if (typeof obj == "undefined" || obj == null)
			return;
		if (document.getElementById('invite_' + type).checked)
		{
			document.getElementById('rsvp_' + type + '_y').disabled = false;	
			document.getElementById('rsvp_' + type + '_n').disabled = false;
			$('#rsvp_' + type + '_y').change();
		}
		else
		{
			document.getElementById('rsvp_' + type + '_y').checked = false; 
			document.getElementById('rsvp_' + type + '_n').checked = false;	
			document.getElementById('rsvp_' + type + '_y').disabled = true;	
			document.getElementById('rsvp_' + type + '_n').disabled = true;	
			document.getElementById('table_' + type).disabled = true;
			$('#rsvp_' + type + '_y').change();
		}
		/*
		*/
	}
	
	switch_gift = function()
	{
		if (document.getElementById('gift_received').checked)
		{
			document.getElementById('gift_amt').disabled = false;
			document.getElementById('gift_card').disabled = false;
			document.getElementById('gift_other').disabled = false;
			document.getElementById('gift_comment').disabled = false;
			document.getElementById('gift_thank_you').disabled = false;
		}
		else
		{
			$('#gift_amt').val('0.00').change();
			$('#gift_card').val('0.00').change();
			$('#gift_other').val('').change();
			$('#gift_comment').val('').change();
			$('#gift_thank_you').attr('checked',null).change();
			document.getElementById('gift_amt').disabled = true;
			document.getElementById('gift_card').disabled = true;
			document.getElementById('gift_other').disabled = true;
			document.getElementById('gift_comment').disabled = true;
			document.getElementById('gift_thank_you').disabled = true;
		}
	}

	update_header = function()
	{
		if ($("#first_name").val() > "" || $("#last_name").val() > "")
		{
			$("#header_repeater").text(" - " + $("#first_name").val() + " " + $("#last_name").val());
		}
	}
	
	$(document).ready(function()	
	{
		switch_tab('<?php echo $active_tab; ?>');
		switch_primary();
		switch_rsvp('temple','y');
		switch_rsvp('av','y');
		switch_rsvp('kv','y');
		switch_rsvp('bv','y');
		switch_rsvp('dv','y');
		switch_invited('temple');
		switch_invited('av');
		switch_invited('kv');
		switch_invited('bv');
		switch_invited('dv');
		switch_gift();
		//check_other($('#salutation').val(),'salutation_other');
		//check_other($('#suffix').val(),'suffix_other');
		update_header();
		$(':input').change(function() {sheet_dirty = true;} );
	}
	)
</script>

<h1>Guest - <?php echo $action; ?><span id="header_repeater"></span></h1>
<?php get_notes(); ?>
<?php get_help_guide('help_guest_form_'.$active_tab); ?>
<?php echo form_message($form_message); ?>

<form style="" name="frm_guest" id="frm_guest" method="post" action="">
	<input name="ajax_event_submitted" type="hidden" value="1" />
	<input name="id" type="hidden" value="<?php echo $_REQUEST['id']; ?>" />
	<input name="active_tab" id="active_tab" type="hidden" value="general" />
	<!-- -------------------------------------------------------------------------------------------------------------- -->
	<div class="form_strip">
		<input type="button" value="Save" onclick="sheet_dirty = false; this.form.submit();" />
		&nbsp;&nbsp;
		<input type="button" value="Save & Close" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
		&nbsp;&nbsp;
		<input type="button" value="Save & New" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
		&nbsp;&nbsp;
		<span id="submit_ps">
			<input type="button" value="Add Sig. Other" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
			&nbsp;&nbsp;
		</span>
		<span id="submit_pc">
			<input type="button" value="Add Child" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
			&nbsp;&nbsp;
		</span>
		<input type="button" value="Cancel" onclick="sheet_dirty = false; window.location.href = 'index.php?IX=<?php echo $_REQUEST['ref']; ?>'" />
	</div>
	<!-- -------------------------------------------------------------------------------------------------------------- -->
	<div class="tab_strip">
		<div class="tab_header" id="tab_general" onclick="switch_tab('general');">
			General
		</div>
		<div class="tab_header" id="tab_tables" onclick="switch_tab('tables');">
			Table Assignment
		</div>
		<div class="tab_header" id="tab_gifts" onclick="switch_tab('gifts');">
			Gifts
		</div>
	</div>
	<div class="cleardiv">
		&nbsp;
	</div>
	<div class="tab_content" id="tab_content_general">
		<div class="form_header">
			General Information
		</div>
		<table class="input_block">
			<tr>
				<td>
					Guest Type
				</td>
				<td colspan="3">
					<input name="guest_type" id="guest_type_p" type="radio" value="P" onchange="switch_primary();" onclick="switch_primary();" onblur="switch_primary();" <?php if ($_POST['guest_type'] == 'P') : echo 'checked="checked"'; endif; ?> />Primary Adult&nbsp;&nbsp;&nbsp;
					<input name="guest_type" id="guest_type_s" type="radio" value="S" onchange="switch_primary();" onclick="switch_primary();" onblur="switch_primary();" <?php if ($_POST['guest_type'] == 'S') : echo 'checked="checked"'; endif; ?> />Significant Other&nbsp;&nbsp;&nbsp;
					<input name="guest_type" id="guest_type_c" type="radio" value="C" onchange="switch_primary();" onclick="switch_primary();" onblur="switch_primary();" <?php if ($_POST['guest_type'] == 'C') : echo 'checked="checked"'; endif; ?> />Child&nbsp;&nbsp;&nbsp;
					<input name="guest_type" id="guest_type_g" type="radio" value="G" onchange="switch_primary();" onclick="switch_primary();" onblur="switch_primary();" <?php if ($_POST['guest_type'] == 'G') : echo 'checked="checked"'; endif; ?> />Gift Only&nbsp;&nbsp;&nbsp;
					<?php show_form_error($ar_err['guest_type']); ?>
				</td>
			</tr>
			<tr id="row_primary">
				<td>
					With Primary
				</td>
				<td>
					<select name="primary_guest_id" id="primary_guest_id" >
						<option value="">Primary Guest / Group / Family...</option>
						<?php
							$sql_str = "SELECT * FROM guests WHERE guest_type = 'P' AND user_id = ".$_SESSION['user_id']." AND event_id = ".$_SESSION['active_event']." ORDER BY last_name";
							$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
							while ($row = mysqli_fetch_object($result)) :
								$selected = '';
								if ($_POST['primary_guest_id'] == $row->id) :
									$selected = 'selected="selected"';
								endif;
								if ($row->salutation == 'Other...') :
									$row->salutation = $row->salutation_other;
								endif;
								if ($row->suffix == 'Other...') :
									$row->suffix = $row->suffix_other;
								endif;
								echo '<option value="'.$row->id.'" '.$selected.'>'.$row->salutation.' '.$row->first_name.' '.$row->middle_name.' '.$row->last_name.' '.$row->suffix.'</option>';
							endwhile;
						?>
					</select>
					<?php show_form_error($ar_err['primary_guest_id']); ?>
				</td>
				<td>&nbsp;
				</td>
				<td>&nbsp;
				</td>
			</tr>
			<tr>
				<td>
					Salutation
				</td>
				<td>
					<?php
						auto_complete('salutation', $_POST['salutation'], $_POST['salutation'], "SELECT salutation, salutation FROM salutations ORDER BY seq, salutation", null, null, null, 2); 
					?>
					<?php show_form_error($ar_err['salutation']); ?>
				</td>
				<td>
					Phone
				</td>
				<td>
					<input name="phone" id="phone" tabindex="13" type="text" maxlength="25" value="<?php echo $_POST['phone']; ?>"  />
					<?php show_form_error($ar_err['phone']); ?>
				</td>
			</tr>
			<tr>
				<td>
					First Name
				</td>
				<td>
					<input name="first_name" id="first_name" tabindex="3" type="text" maxlength="50" onblur="update_header();" value="<?php echo $_POST['first_name']; ?>"  />
					<?php show_form_error($ar_err['first_name']); ?>
				</td>
				<td>
					Mobile
				</td>
				<td>
					<input name="mobile" id="mobile" tabindex="14" type="text" maxlength="25" value="<?php echo $_POST['mobile']; ?>"  />
					<?php show_form_error($ar_err['mobile']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Middle Name
				</td>
				<td>
					<input name="middle_name" id="middle_name" tabindex="4" type="text" maxlength="50" value="<?php echo $_POST['middle_name']; ?>"  />
					<?php show_form_error($ar_err['middle_name']); ?>
				</td>
				<td>
					Email
				</td>
				<td>
					<input name="email" id="email" type="text" tabindex="15" maxlength="100" class="mail_field" value="<?php echo $_POST['email']; ?>"  /><a id="linkout_email" href="mailto:<?php echo $_POST['email']; ?>"><img class="link_out" src="img/link_out_icon.png" /></a>
					<?php show_form_error($ar_err['email']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Last Name
				</td>
				<td>
					<input name="last_name" id="last_name" tabindex="5" type="text" maxlength="50" onblur="update_header();" value="<?php echo $_POST['last_name']; ?>"  />
					<?php show_form_error($ar_err['last_name']); ?>
				</td>
				<td>
					Facebook
				</td>
				<td>
					<input name="facebook" id="facebook" type="text" tabindex="16" class="link_field" maxlength="100" value="<?php echo $_POST['facebook']; ?>"  /><a id="linkout_facebook" target="_blank" href="<?php echo format_http($_POST['facebook']); ?>"><img class="link_out" src="img/link_out_icon.png" /></a>
					<?php show_form_error($ar_err['facebook']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Suffix
				</td>
				<td>
					<?php
						auto_complete('suffix', $_POST['suffix'], $_POST['suffix'], "SELECT suffix, suffix FROM suffixes ORDER BY seq, suffix", null, null, null, 6); 
					?>
					<?php show_form_error($ar_err['suffix']); ?>
				</td>
				<td>
					Instagram
				</td>
				<td>
					<input name="instagram" id="instagram" type="text" tabindex="17" class="link_field" maxlength="100" value="<?php echo $_POST['instagram']; ?>"  /><a id="linkout_instagram" target="_blank" href="<?php echo format_http($_POST['instagram']); ?>"><img class="link_out" src="img/link_out_icon.png" /></a>
					<?php show_form_error($ar_err['instagram']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Street
				</td>
				<td>
					<input name="street" id="street" tabindex="7" type="text" maxlength="100" value="<?php echo $_POST['street']; ?>"  />
					<?php show_form_error($ar_err['street']); ?>
				</td>
				<td>
					Twitter
				</td>
				<td>
					<input name="twitter" id="twitter" type="text" tabindex="18" class="link_field" maxlength="100" value="<?php echo $_POST['twitter']; ?>"  /><a id="linkout_twitter" target="_blank" href="<?php echo format_http($_POST['twitter']); ?>"><img class="link_out" src="img/link_out_icon.png" /></a>
					<?php show_form_error($ar_err['twitter']); ?>
				</td>
			</tr>
			<tr>
				<td>&nbsp;
				</td>
				<td>
					<input name="street2" id="street2" tabindex="8" type="text" maxlength="100" value="<?php echo $_POST['street2']; ?>"  />
					<?php show_form_error($ar_err['street2']); ?>
				</td>
				<td>&nbsp;
				</td>
				<td>&nbsp;
				</td>
			</tr>
			<tr>
				<td>
					City
				</td>
				<td>
					<input name="city" id="city" tabindex="9" type="text" maxlength="50" value="<?php echo $_POST['city']; ?>"  />
					<?php show_form_error($ar_err['city']); ?>
				</td>
				<td>&nbsp;
				</td>
				<td>&nbsp;
				</td>
			</tr>
			<tr>
				<td>
					State
				</td>
				<td>
					<?php
						$sql_str = "SELECT DISTINCT country_sort_code, country FROM states order by country_sort_code";
						$result_country = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
						$sql_union = '';
						$str_union = '';
						while ($row_country = mysqli_fetch_object($result_country)) :
							$sql_union .= $str_union." (SELECT '__', '- - - - - - ".$row_country->country." - - - - - -') ".
								"UNION (SELECT state, state_name FROM states WHERE country_sort_code = ".$row_country->country_sort_code." ORDER BY state_name) ";
							$str_union = ' UNION ';
						endwhile;
						//echo $sql_union;
						auto_complete('state', $_POST['state'], $_POST['state'], $sql_union, null, null, null, 10, "set_country('state', 'country');"); 
						$sql_str = 'SELECT country, state, state_name FROM states ORDER BY country_sort_code, state_name';
						$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
						echo '<script> var ar_states = []; ';
						while ($row = mysqli_fetch_object($result)) :
							echo 'ar_states["'.$row->state.'"] = "'.$row->country.'";'.PHP_EOL;
						endwhile;
						echo '</script>';
					?>
					<?php /* ?>
					<select name="state" id="state" tabindex="10" onchange="set_country('state', 'country');" >
						<option value="">State/Province...</option>
						<?php
							$sql_str = 'SELECT country, state, state_name FROM states ORDER BY country_sort_code, state_name';
							$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
							$hold_country = '';
							while ($row = mysqli_fetch_object($result)) :
								if ($hold_country != $row->country) :
									echo '<option value="">- - - - - - '.$row->country.' - - - - - -</option>';
									$hold_country = $row->country;
								endif;
								$selected = '';
								if ($_POST['state'] == $row->state) :
									$selected = 'selected="selected"';
								endif;
								echo '<option attr_country="'.$row->country.'" value="'.$row->state.'" '.$selected.'>'.$row->state_name.'</option>';
							endwhile;
						?>
					</select>
					<?php */ ?>
					<?php show_form_error($ar_err['state']); ?>
				</td>
				<td>&nbsp;
				</td>
				<td>&nbsp;
				</td>
			</tr>
			<tr>
				<td>
					Zip Code
				</td>
				<td>
					<input name="zip" id="zip" tabindex="11" type="text" maxlength="15" value="<?php echo $_POST['zip']; ?>"  />
					<?php show_form_error($ar_err['zip']); ?>
				</td>
				<td>&nbsp;
				</td>
				<td>&nbsp;
				</td>
			</tr>
			<tr>
				<td>
					Country
				</td>
				<td>
					<input name="country" id="country" tabindex="12" type="text" maxlength="50" value="<?php echo $_POST['country']; ?>"  />
					<?php show_form_error($ar_err['country']); ?>
				</td>
				<td>&nbsp;
				</td>
				<td>&nbsp;
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<table class="input_block">
						<tr>
							<td>
								Event
							</td>
							<td>
								Invited
							</td>
							<td>
								RSVP Yes
							</td>
							<td>
								RSVP No
							</td>
							<td>
								Attended
							</td>
							<td>
								Bus
							</td>
						</tr>
						<?php
							if (!empty($row_event->temple_name)) :
						?>
								<tr>
									<td>
										<?php echo venue_decode('temple'); ?>
									</td>
									<td align="center">
										<input name="invite_temple" id="invite_temple" type="checkbox" value="1" onchange="switch_invited('temple');"  <?php if ($_POST['invite_temple'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['invite_temple']); ?>
									</td>
									<td align="center">
										<input name="rsvp_temple" id="rsvp_temple_y" type="radio" value="1" onchange="switch_rsvp('temple','y');" onclick="switch_rsvp('temple','y');" onblur="switch_rsvp('temple','y');"  <?php if ($_POST['rsvp_temple'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_temple']); ?>
									</td>
									<td align="center">
										<input name="rsvp_temple" id="rsvp_temple_n" type="radio" value="2" onchange="switch_rsvp('temple','n');" onclick="switch_rsvp('temple','n');" onblur="switch_rsvp('temple','n');"  <?php if ($_POST['rsvp_temple'] == '2') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_temple']); ?>
									</td>
									<td align="center">
										<input name="att_temple" id="att_temple" type="checkbox" value="1"  <?php if ($_POST['att_temple'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['att_temple']); ?>
									</td>
									<td align="center">
										<input name="bus_temple" id="bus_temple" type="checkbox" value="1"  <?php if ($_POST['bus_temple'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['bus_temple']); ?>
									</td>
								</tr>
						<?php
							endif;
							if (!empty($row_event->av_name)) :
						?>
								<tr>
									<td>
										<?php echo venue_decode('av'); ?>
									</td>
									<td align="center">
										<input name="invite_av" id="invite_av" type="checkbox" value="1" onchange="switch_invited('av');"  <?php if ($_POST['invite_av'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['invite_av']); ?>
									</td>
									<td align="center">
										<input name="rsvp_av" id="rsvp_av_y" type="radio" value="1" onchange="switch_rsvp('av','y');" onclick="switch_rsvp('av','y');" onblur="switch_rsvp('av','y');" <?php if ($_POST['rsvp_av'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_av']); ?>
									</td>
									<td align="center">
										<input name="rsvp_av" id="rsvp_av_n" type="radio" value="2" onchange="switch_rsvp('av','n');" onclick="switch_rsvp('av','n');" onblur="switch_rsvp('av','n');" <?php if ($_POST['rsvp_av'] == '2') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_av']); ?>
									</td>
									<td align="center">
										<input name="att_av" id="att_av" type="checkbox" value="1"  <?php if ($_POST['att_av'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['att_av']); ?>
									</td>
									<td align="center">
										<input name="bus_av" id="bus_av" type="checkbox" value="1"  <?php if ($_POST['bus_av'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['bus_av']); ?>
									</td>
								</tr>
						<?php
							endif;
							if (!empty($row_event->kv_name)) :
						?>
								<tr>
									<td>
										<?php echo venue_decode('kv'); ?>
									</td>
									<td align="center">
										<input name="invite_kv" id="invite_kv" type="checkbox" value="1" onchange="switch_invited('kv');"  <?php if ($_POST['invite_kv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['invite_kv']); ?>
									</td>
									<td align="center">
										<input name="rsvp_kv" id="rsvp_kv_y" type="radio" value="1" onchange="switch_rsvp('kv','y');" onclick="switch_rsvp('kv','y');" onblur="switch_rsvp('kv','y');" <?php if ($_POST['rsvp_kv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_kv']); ?>
									</td>
									<td align="center">
										<input name="rsvp_kv" id="rsvp_kv_n" type="radio" value="2" onchange="switch_rsvp('kv','n');" onclick="switch_rsvp('kv','n');" onblur="switch_rsvp('kv','n');" <?php if ($_POST['rsvp_kv'] == '2') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_kv']); ?>
									</td>
									<td align="center">
										<input name="att_kv" id="att_kv" type="checkbox" value="1"  <?php if ($_POST['att_kv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['att_kv']); ?>
									</td>
									<td align="center">
										<input name="bus_kv" id="bus_kv" type="checkbox" value="1"  <?php if ($_POST['bus_kv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['bus_kv']); ?>
									</td>
								</tr>
						<?php
							endif;
							if (!empty($row_event->bv_name)) :
						?>
								<tr>
									<td>
										<?php echo venue_decode('bv'); ?>
									</td>
									<td align="center">
										<input name="invite_bv" id="invite_bv" type="checkbox" value="1" onchange="switch_invited('bv');"  <?php if ($_POST['invite_bv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['invite_bv']); ?>
									</td>
									<td align="center">
										<input name="rsvp_bv" id="rsvp_bv_y" type="radio" value="1" onchange="switch_rsvp('bv','y');" onclick="switch_rsvp('bv','y');" onblur="switch_rsvp('bv','y');" <?php if ($_POST['rsvp_bv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_bv']); ?>
									</td>
									<td align="center">
										<input name="rsvp_bv" id="rsvp_bv_n" type="radio" value="2" onchange="switch_rsvp('bv','n');" onclick="switch_rsvp('bv','n');" onblur="switch_rsvp('bv','n');" <?php if ($_POST['rsvp_bv'] == '2') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_bv']); ?>
									</td>
									<td align="center">
										<input name="att_bv" id="att_bv" type="checkbox" value="1"  <?php if ($_POST['att_bv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['att_bv']); ?>
									</td>
									<td align="center">
										<input name="bus_bv" id="bus_bv" type="checkbox" value="1"  <?php if ($_POST['bus_bv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['bus_bv']); ?>
									</td>
								</tr>
						<?php
							endif;
							if (!empty($row_event->dv_name)) :
						?>
								<tr>
									<td>
										<?php echo venue_decode('dv'); ?>
									</td>
									<td align="center">
										<input name="invite_dv" id="invite_dv" type="checkbox" value="1" onchange="switch_invited('dv');"  <?php if ($_POST['invite_dv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['invite_dv']); ?>
									</td>
									<td align="center">
										<input name="rsvp_dv" id="rsvp_dv_y" type="radio" value="1" onchange="switch_rsvp('dv','y');" onclick="switch_rsvp('dv','y');" onblur="switch_rsvp('dv','y');" <?php if ($_POST['rsvp_dv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_dv']); ?>
									</td>
									<td align="center">
										<input name="rsvp_dv" id="rsvp_dv_n" type="radio" value="2" onchange="switch_rsvp('dv','n');" onclick="switch_rsvp('dv','n');" onblur="switch_rsvp('dv','n');" <?php if ($_POST['rsvp_dv'] == '2') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['rsvp_dv']); ?>
									</td>
									<td align="center">
										<input name="att_dv" id="att_dv" type="checkbox" value="1"  <?php if ($_POST['att_dv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['att_dv']); ?>
									</td>
									<td align="center">
										<input name="bus_dv" id="bus_dv" type="checkbox" value="1"  <?php if ($_POST['bus_dv'] == '1') : echo 'checked="checked"'; endif; ?> />
										<?php show_form_error($ar_err['bus_dv']); ?>
									</td>
								</tr>
						<?php
							endif;
						?>
					</table>
				</td>
				<td>&nbsp;
				</td>
				<td>
					Other Family/Group Members:<br /><br />
					<?php
						$sql_str = "SELECT DISTINCT * FROM guests WHERE (primary_guest_id = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_REQUEST['id'])),'-1')." OR id = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['primary_guest_id'])),'-1')." OR primary_guest_id = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_POST['primary_guest_id'])),'-1').")".
									" AND user_id = ".$_SESSION['user_id']."  AND event_id = ".$_SESSION['active_event']." ";
						$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
						while ($row = mysqli_fetch_object($result)) :
							if ($row->id != $_REQUEST['id']):
								echo '<a href="index.php?IX=guest_form&id='.$row->id.'">';
								$name_str = '';
								if ($row->salutation != 'Other...') :
									$name_str = $name_str.$row->salutation.' ';
								else :
									$name_str = $name_str.$row->salutation_other.' ';
								endif;
								$name_str = $name_str.$row->first_name.' '.$row->last_name.' ';
								if ($row->suffix != 'Other...') :
									$name_str = $name_str.$row->suffix.' ';
								else :
									$name_str = $name_str.$row->suffix_other.' ';
								endif;
								echo trim($name_str);
								echo '</a><br />';
							endif;
						endwhile;
					?>
				</td>
			</tr>
			<tr>
				<td>
					Hotel Stay
				</td>
				<td>
					<input name="hotel_stay" id="hotel_stay" tabindex="19" type="checkbox" value="1"  <?php if ($_POST['hotel_stay'] == '1') : echo 'checked="checked"'; endif; ?> />
					<?php show_form_error($ar_err['hotel_stay']); ?>
				</td>
				<td rowspan="5">&nbsp;
				</td>
				<td rowspan="5">
				</td>
			</tr>
			<tr>
				<td>
					Hotel Info
				</td>
				<td>
					<?php
						auto_complete('hotel', $_POST['hotel'], $_POST['hotel'], "SELECT DISTINCT hotel, hotel FROM guests WHERE hotel > '' AND user_id = ".$_SESSION['user_id']."  AND event_id = ".$_SESSION['active_event']." ORDER BY hotel ", false, null, 20, null);
						show_form_error($ar_err['hotel']);
					?>
				</td>
			</tr>
			<?php 
				/*
			?>
			<tr>
				<td>
					Bus
				</td>
				<td>
					<input name="bus" id="bus" tabindex="19" type="checkbox" value="1"  <?php if ($_POST['bus'] == '1') : echo 'checked="checked"'; endif; ?> />
					<?php show_form_error($ar_err['bus']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Food Restrictions
				</td>
				<td>
					<input name="food_restrictions" id="food_restrictions" tabindex="21" type="text" maxlength="100" value="<?php echo $_POST['food_restrictions']; ?>"  />
					<?php show_form_error($ar_err['food_restrictions']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Food Preference
				</td>
				<td>
					<input name="food_preference" id="food_preference" tabindex="22" type="text" maxlength="100" value="<?php echo $_POST['food_preference']; ?>"  />
					<?php show_form_error($ar_err['food_preference']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Favor Size
				</td>
				<td>
					<input name="favor_size" id="favor_size_xs" type="radio" value="XS" <?php if ($_POST['favor_size'] == 'XS') : echo 'checked="checked"'; endif; ?> />XS&nbsp;&nbsp;
					<input name="favor_size" id="favor_size_s" type="radio" value="S" <?php if ($_POST['favor_size'] == 'S') : echo 'checked="checked"'; endif; ?> />S&nbsp;&nbsp;
					<input name="favor_size" id="favor_size_m" type="radio" value="M" <?php if ($_POST['favor_size'] == 'M') : echo 'checked="checked"'; endif; ?> />M&nbsp;&nbsp;
					<input name="favor_size" id="favor_size_l" type="radio" value="L" <?php if ($_POST['favor_size'] == 'L') : echo 'checked="checked"'; endif; ?> />L&nbsp;&nbsp;
					<input name="favor_size" id="favor_size_xl" type="radio" value="XL" <?php if ($_POST['favor_size'] == 'XL') : echo 'checked="checked"'; endif; ?> />XL&nbsp;&nbsp;
					<input name="favor_size" id="favor_size_xxl" type="radio" value="XXL" <?php if ($_POST['favor_size'] == 'XXL') : echo 'checked="checked"'; endif; ?> />XXL&nbsp;&nbsp;
					<?php show_form_error($ar_err['favor_size']); ?>
				</td>
			</tr>
			<tr>
				<td>
					Favor Gender
				</td>
				<td>
					<input name="favor_gender" id="favor_gender_m" type="radio" value="M" <?php if ($_POST['favor_gender'] == 'M') : echo 'checked="checked"'; endif; ?> />Male&nbsp;&nbsp;
					<input name="favor_gender" id="favor_gender_f" type="radio" value="F" <?php if ($_POST['favor_gender'] == 'F') : echo 'checked="checked"'; endif; ?> />Female&nbsp;&nbsp;
					<?php show_form_error($ar_err['favor_size']); ?>
				</td>
			</tr>
			<?php
				*/
			?>
			<tr>
				<td>
					Favors by Event
				</td>
				<td colspan="4">
					<table>
						<?php
							$ar_favor_venues = array('temple','av','kv','bv','dv');
							$favor_defined = false;
							foreach ($ar_favor_venues as $favor_venue) :
								if (venue_decode($favor_venue) > ' ') :
									$sql_favor = "SELECT * FROM favors WHERE venue = '".$favor_venue."' AND user_id = ".$_SESSION['user_id']."  AND event_id = ".$_SESSION['active_event']." ";
									$result_favor = mysqli_query($GLOBALS['con'], $sql_favor);
									if (mysqli_num_rows($result_favor) > 0):
										$favor_defined = true;
										echo '<tr>';
										echo '<td colspan="3">';
										echo venue_decode($favor_venue);
										echo '</td>';
										echo '</tr>';
										while ($row_favor = mysqli_fetch_object($result_favor)) :
											$sql_favor_guest = "SELECT * FROM guests_favors WHERE guest_id = ".nz(mysqli_real_escape_string($GLOBALS['con'], trim($_REQUEST['id'])),'0')." AND favor_id = ".$row_favor->id." AND venue = '".$favor_venue."' AND user_id = ".$_SESSION['user_id']."  AND event_id = ".$_SESSION['active_event']." ";
											$result_favor_guest = mysqli_query($GLOBALS['con'], $sql_favor_guest);
											//echo "===".$sql_favor_guest."===".mysqli_num_rows($result_favor_guest)."===";
											if (mysqli_num_rows($result_favor_guest) >0 ) :
												$row_favor_guest = mysqli_fetch_object($result_favor_guest);
												$favor_link_id = $row_favor_guest->id;
											else :
												unset($row_favor_guest);
												$favor_link_id = 0;
											endif;
											echo '<tr>';
											echo '<td>&nbsp;';
											echo '</td>';
											echo '<td>';
											echo $row_favor->description;
											echo '</td>';
											echo '<td>';
											echo '<input type="checkbox" class="favor_input_check_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'"'.(($row_favor_guest->id >0 ) ? ' checked="checked" ' : ' ').' onchange="check_favor('.$row_favor->id.','.$favor_link_id.',\''.$favor_venue.'\');" />';
											if ($row_favor->size_xs >0 || $row_favor->size_s >0 || $row_favor->size_m >0 || $row_favor->size_l >0 || $row_favor->size_xl >0 || $row_favor->size_xxl >0 ):
												echo '&nbsp;&nbsp;Size: ';
												if ($row_favor->size_xs >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_size" value="XS"'.(($row_favor_guest->size == 'XS') ? ' checked="checked" ' : ' ').'/>';
													echo ' XS ';
												endif;
												if ($row_favor->size_s >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_size" value="S"'.(($row_favor_guest->size == 'S') ? ' checked="checked" ' : ' ').'/>';
													echo ' S ';
												endif;
												if ($row_favor->size_m >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_size" value="M"'.(($row_favor_guest->size == 'M') ? ' checked="checked" ' : ' ').'/>';
													echo ' M ';
												endif;
												if ($row_favor->size_l >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_size" value="L"'.(($row_favor_guest->size == 'L') ? ' checked="checked" ' : ' ').'/>';
													echo ' L ';
												endif;
												if ($row_favor->size_xl >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_size" value="XL"'.(($row_favor_guest->size == 'XL') ? ' checked="checked" ' : ' ').'/>';
													echo ' XL ';
												endif;
												if ($row_favor->size_xxl >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_size" value="XXL"'.(($row_favor_guest->size == 'XXL') ? ' checked="checked" ' : ' ').'/>';
													echo ' XXL ';
												endif;
											endif;
											if ($row_favor->gender_m >0 || $row_favor->gender_f >0 ):
												echo '&nbsp;&nbsp;Gender: ';
												if ($row_favor->gender_m >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_gender" value="M"'.(($row_favor_guest->gender == 'M')?' checked="checked" ':' ').'/>';
													echo ' M ';
												endif;
												if ($row_favor->gender_f >0) :
													echo '<input type="radio" class="favor_input_'.$favor_venue.'" name="link_favor_'.$favor_venue.'_'.$row_favor->id.'_gender" value="F"'.(($row_favor_guest->gender == 'F')?' checked="checked" ':' ').'/>';
													echo ' F ';
												endif;
											endif;
											echo '</td>';
											echo '</tr>';
											echo '<script>';
											echo 'check_favor('.$row_favor->id.','.$favor_link_id.',\''.$favor_venue.'\');';
											echo '</script>';
										endwhile;
									endif;
								endif;
							endforeach;
							if (!$favor_defined) :
								echo '<a href="index.php?IX=favors">Define Favors...</a>';
							endif;
						?>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					Comments
				</td>
				<td colspan="3">
					<textarea name="comments" id="comments" tabindex="23" cols="80" rows="5"><?php echo $_POST['comments']; ?></textarea>
					<?php show_form_error($ar_err['comments']); ?>
				</td>
			</tr>
		</table>
	</div>
	<!-- -------------------------------------------------------------------------------------------------------------- -->
	<div class="tab_content" id="tab_content_tables">
		<div class="form_header">
			Table Assignment
		</div>
		<table class="input_block">
			<tr>
				<td>
					Event
				</td>
				<td>
					Available Table
				</td>
			</tr>
			<tr>
				<td>
					<?php echo venue_decode('temple'); ?>
				</td>
				<td>
					<select name="table_temple" id="table_temple" >
						<option value="">Select Table...</option>
						<?php
							$sql_str = "SELECT t.*, (SELECT COUNT(id) FROM guests WHERE table_temple = t.id AND rsvp_temple = 1) AS capacity_used FROM tables t WHERE t.venue = 'temple' AND t.user_id = ".$_SESSION['user_id']." AND t.event_id = ".$_SESSION['active_event']." ORDER BY t.table_no";
							$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
							while ($row = mysqli_fetch_object($result)) :
								$selected = '';
								if ($row->capacity > $row->capacity_used || $row->id == $_POST['table_temple']) :
									if ($_POST['table_temple'] == $row->id) :
										$selected = 'selected="selected"';
									endif;
									echo '<option value="'.$row->id.'" '.$selected.'>'.$row->table_no.' - '.$row->table_desc.' -- available seats: '.($row->capacity - $row->capacity_used).'</option>';
								endif;
							endwhile;
						?>
					</select>
					<?php show_form_error($ar_err['table_temple']); ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php echo venue_decode('av'); ?>
				</td>
				<td>
					<select name="table_av" id="table_av" >
						<option value="">Select Table...</option>
						<?php
							$sql_str = "SELECT t.*, (SELECT COUNT(id) FROM guests WHERE table_av = t.id AND rsvp_av = 1) AS capacity_used FROM tables t WHERE t.venue = 'av' AND t.user_id = ".$_SESSION['user_id']." AND t.event_id = ".$_SESSION['active_event']." ORDER BY t.table_no";
							$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
							while ($row = mysqli_fetch_object($result)) :
								$selected = '';
								if ($row->capacity > $row->capacity_used || $row->id == $_POST['table_av']) :
									if ($_POST['table_av'] == $row->id) :
										$selected = 'selected="selected"';
									endif;
									echo '<option value="'.$row->id.'" '.$selected.'>'.$row->table_no.' - '.$row->table_desc.' -- available seats: '.($row->capacity - $row->capacity_used).'</option>';
								endif;
							endwhile;
						?>
					</select>
					<?php show_form_error($ar_err['table_av']); ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php echo venue_decode('kv'); ?>
				</td>
				<td>
					<select name="table_kv" id="table_kv" >
						<option value="">Select Table...</option>
						<?php
							$sql_str = "SELECT t.*, (SELECT COUNT(id) FROM guests WHERE table_kv = t.id AND rsvp_kv = 1) AS capacity_used FROM tables t WHERE t.venue = 'kv' AND t.user_id = ".$_SESSION['user_id']." AND t.event_id = ".$_SESSION['active_event']." ORDER BY t.table_no";
							$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
							while ($row = mysqli_fetch_object($result)) :
								$selected = '';
								if ($row->capacity > $row->capacity_used || $row->id == $_POST['table_kv']) :
									if ($_POST['table_kv'] == $row->id) :
										$selected = 'selected="selected"';
									endif;
									echo '<option value="'.$row->id.'" '.$selected.'>'.$row->table_no.' - '.$row->table_desc.' -- available seats: '.($row->capacity - $row->capacity_used).'</option>';
								endif;
							endwhile;
						?>
					</select>
					<?php show_form_error($ar_err['table_kv']); ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php echo venue_decode('bv'); ?>
				</td>
				<td>
					<select name="table_bv" id="table_bv" >
						<option value="">Select Table...</option>
						<?php
							$sql_str = "SELECT t.*, (SELECT COUNT(id) FROM guests WHERE table_bv = t.id AND rsvp_bv = 1) AS capacity_used FROM tables t WHERE t.venue = 'bv' AND t.user_id = ".$_SESSION['user_id']." AND t.event_id = ".$_SESSION['active_event']." ORDER BY t.table_no";
							$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
							while ($row = mysqli_fetch_object($result)) :
								$selected = '';
								if ($row->capacity > $row->capacity_used || $row->id == $_POST['table_bv']) :
									if ($_POST['table_bv'] == $row->id) :
										$selected = 'selected="selected"';
									endif;
									echo '<option value="'.$row->id.'" '.$selected.'>'.$row->table_no.' - '.$row->table_desc.' -- available seats: '.($row->capacity - $row->capacity_used).'</option>';
								endif;
							endwhile;
						?>
					</select>
					<?php show_form_error($ar_err['table_bv']); ?>
				</td>
			</tr>
			<tr>
				<td>
					<?php echo venue_decode('dv'); ?>
				</td>
				<td>
					<select name="table_dv" id="table_dv" >
						<option value="">Select Table...</option>
						<?php
							$sql_str = "SELECT t.*, (SELECT COUNT(id) FROM guests WHERE table_dv = t.id AND rsvp_dv = 1) AS capacity_used FROM tables t WHERE t.venue = 'dv' AND t.user_id = ".$_SESSION['user_id']." AND t.event_id = ".$_SESSION['active_event']." ORDER BY t.table_no";
							$result = mysqli_query($GLOBALS['con'], $sql_str) or die('Database Error!');
							while ($row = mysqli_fetch_object($result)) :
								$selected = '';
								if ($row->capacity > $row->capacity_used || $row->id == $_POST['table_dv']) :
									if ($_POST['table_dv'] == $row->id) :
										$selected = 'selected="selected"';
									endif;
									echo '<option value="'.$row->id.'" '.$selected.'>'.$row->table_no.' - '.$row->table_desc.' -- available seats: '.($row->capacity - $row->capacity_used).'</option>';
								endif;
							endwhile;
						?>
					</select>
					<?php show_form_error($ar_err['table_dv']); ?>
				</td>
			</tr>
		</table>
	</div>
	<!-- -------------------------------------------------------------------------------------------------------------- -->
	<div class="tab_content" id="tab_content_gifts">
		<div class="form_header">
			Gifts Received
		</div>
		<table class="input_block">
			<tr>
				<td>
					Gift Received
				</td>
				<td>
					<input name="gift_received" id="gift_received" type="checkbox" value="1" onchange="switch_gift();"  <?php if ($_POST['gift_received'] == '1') : echo 'checked="checked"'; endif; ?> />
				</td>
			</tr>
			<tr>
				<td>
					Gift Amount
				</td>
				<td>
					<input name="gift_amt" id="gift_amt" type="text" value="<?php echo $_POST['gift_amt']; ?>" maxlength="15" style="width:125px; text-align:right;" onchange="val_dollar_field(this);"  />
				</td>
			</tr>
			<tr>
				<td>
					Gift Card Amount
				</td>
				<td >
					<input name="gift_card" id="gift_card" type="text" value="<?php echo $_POST['gift_card']; ?>" maxlength="15" style="width:125px; text-align:right;" onchange="val_dollar_field(this);"  />
				</td>
			</tr>
			<tr>
				<td>
					Other Gift
				</td>
				<td>
					<input name="gift_other" id="gift_other" type="text" value="<?php echo $_POST['gift_other']; ?>" maxlength="50"  />
				</td>
			</tr>
			<tr>
				<td>
					Comment
				</td>
				<td>
					<input name="gift_comment" id="gift_comment" type="text" value="<?php echo $_POST['gift_comment']; ?>" maxlength="100" />
				</td>
			</tr>
			<tr>
				<td>
					Thank You Sent
				</td>
				<td>
					<input name="gift_thank_you" id="gift_thank_you" type="checkbox" value="1" <?php if ($_POST['gift_thank_you'] == '1') : echo 'checked="checked"'; endif; ?> />
				</td>
			</tr>
		</table>
	</div>
	<!-- -------------------------------------------------------------------------------------------------------------- -->
	<div class="form_strip">
		<input type="button" value="Save" onclick="sheet_dirty = false; this.form.submit();" />
		&nbsp;&nbsp;
		<input type="button" value="Save & Close" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
		&nbsp;&nbsp;
		<input type="button" value="Save & New" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
		&nbsp;&nbsp;
		<span id="submit_ps">
			<input type="button" value="Add Sig. Other" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
			&nbsp;&nbsp;
		</span>
		<span id="submit_pc">
			<input type="button" value="Add Child" onclick="sheet_dirty = false; document.getElementById('xsubmit').value = this.value; this.form.submit();" />
			&nbsp;&nbsp;
		</span>
		<input type="button" value="Cancel" onclick="sheet_dirty = false; window.location.href = 'index.php?IX=<?php echo $_REQUEST['ref']; ?>'" />
		<input type="hidden" name="xsubmit" id="xsubmit" />
	</div>
</form>



Youez - 2016 - github.com/yon3zu
LinuXploit