<?php
$front_required = __('front_required', true);
$front_validation = __('front_validation', true); 

foreach ($front_required as $k => $v) {
	$front_required[$k] = htmlspecialchars($v, ENT_QUOTES);
}
foreach ($front_validation as $k => $v) {
	$front_validation[$k] = htmlspecialchars($v, ENT_QUOTES);
}
if(!isset($index))
{
	$index = $_GET['index'];
}
if(isset($_GET['group_id']))
{
	if($tpl['arr']['status'] == 'T')
	{		
		$subscribed_fields = explode(',', $tpl['arr']['subscribed_fields']);

		if(in_array('first_name', $subscribed_fields))
		{
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_first_name');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="first_name" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['first_name']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('last_name', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_last_name');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="last_name" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['last_name']); ?>" />
				</div>
			</div>
			<?php
		}
		 
		?>
		<div class="form-group">
			<label class="col-sm-3 control-label"><?php __('front_label_email');?></label>
			
			<div class="col-sm-9">
				<input type="text" name="email" class="form-control nsl-text required email" data-msg-required="<?php echo ($front_required['email']); ?>" data-msg-email="<?php echo $front_validation['email_invalid'];?>" data-msg-remote="<?php echo $front_validation['email_used'];?>"/>
			</div>
		</div>
		<?php
		if(in_array('phone', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_phone');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="phone" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['phone']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('website', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_website');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="website" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['website']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('gender', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_gender');?></label>
				<div class="col-sm-9">
					<select name="gender" class="form-control nsl-select required" data-msg-required="<?php echo ($front_required['gender']); ?>" >
						<option value="">-- <?php __('front_label_choose'); ?>--</option>
						<?php
						foreach (__('genderarr', true) as $k => $v)
						{
							?><option value="<?php echo $k; ?>"><?php echo $v; ?></option><?php
						}
						?>
					</select>
				</div>
			</div>
			<?php
		}
		if(in_array('age', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_age');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="age" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['age']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('birthday', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_birthday');?></label>
				<div class="col-sm-9">
					<div class="row">
						<div class="col-sm-3">
							<select name="day" class="form-control nsl-select pjNslBirthday">
								<option value=""><?php __('front_label_day');?></option>
								<?php
								foreach (range(1, 31) as $v)
								{
									$v = str_pad($v, 2, '0', STR_PAD_LEFT); 
									?><option value="<?php echo $v; ?>"><?php echo $v; ?></option><?php
								}
								?>
							</select>
						</div>
						<div class="col-sm-4">
							<select name="month" class="form-control nsl-select pjNslBirthday">
								<option value=""><?php __('front_label_month');?></option>
								<?php
								foreach (range(1, 12) as $v)
								{
									$v = str_pad($v, 2, '0', STR_PAD_LEFT);
									?><option value="<?php echo $v; ?>"><?php echo $v; ?></option><?php
								}
								?>
							</select>
						</div>
						<div class="col-sm-4">
							<select name="year" class="form-control nsl-select pjNslBirthday">
								<option value=""><?php __('front_label_year');?></option>
								<?php
								foreach (range(1900, date('Y')) as $v)
								{
									?><option value="<?php echo $v; ?>"><?php echo $v; ?></option><?php
								}
								?>
							</select>
						</div>
					</div>
					<input type="hidden" name="birthday" class="nsl-text nsl-w300 required" data-msg-required="<?php echo ($front_required['birthday']); ?>"/>
				</div>
			</div>
			<?php
		}
		if(in_array('address', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_address');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="address" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['address']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('city', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_city');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="city" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['city']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('state', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_state');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="state" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['state']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('country', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_country');?></label>
				<div class="col-sm-9">
					<select name="country_id" class="form-control nsl-select required" data-msg-required="<?php echo ($front_required['country']); ?>" >
						<option value="">-- <?php __('front_label_choose'); ?>--</option>
						<?php
						foreach ($tpl['country_arr'] as $k => $v)
						{
							?><option value="<?php echo $v['id']; ?>"><?php echo $v['country_title']; ?></option><?php
						}
						?>
					</select>
				</div>
			</div>
			<?php
		}
		if(in_array('zip', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_zip');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="zip" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['zip']); ?>" />
				</div>
			</div>
			<?php
		}
		if(in_array('company_name', $subscribed_fields))
		{ 
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label"><?php __('front_label_company_name');?></label>
				
				<div class="col-sm-9">
					<input type="text" name="company_name" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['company_name']); ?>" />
				</div>
			</div>
			<?php
		}
		?>
		<div class="form-group">
			<label class="col-sm-3 control-label"><?php __('front_label_captcha');?></label>
			
			<div class="col-sm-9">
				<div class="row">
					<div class="col-sm-6">
						<input type="text" name="captcha" maxlength="6" class="form-control nsl-text required" data-msg-required="<?php echo ($front_required['captcha']); ?>" data-msg-remote="<?php echo $front_validation['captcha_incorrect'];?>"/>
					</div>
					<div class="col-sm-4">
						<img id="nsl_captcha_image_<?php echo $index;?>" src="<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjFront&amp;action=pjActionCaptcha&amp;rand=<?php echo rand(1, 999999); ?>&amp;group_id=<?php echo $_GET['group_id'];?><?php echo isset($_GET['session_id']) ? "&amp;session_id=" . $_GET['session_id'] : "";?>" alt="Captcha" />
					</div>
				</div>
			</div>
		</div>
		<div class="form-group pjNslMessageContainer">
			<div class="col-sm-offset-3 col-sm-9">
				<div id="pjNslErrorWrapper_<?php echo $index;?>" class="nsl-error-container alert alert-danger" role="alert" style="display: none;"></div>
				<div id="pjNslMessageWrapper_<?php echo $index;?>" class="nsl-message-container alert alert-info" role="alert" style="display: none;"></div>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-3 col-sm-9">
				<button style="pointer-events: all; cursor: pointer;" type="submit" name="nsl_subscribe_form_subscribe_<?php echo $index;?>" class="btn btn-default pjCfFormButton"><?php __('front_button_subscribe'); ?></button>
			</div>
		</div>
		<?php
	}else{
		__('front_label_subscribe_inactive');
		?><br/><br/><?php
	}
}else{
	?>
	<div class="form-group">
		<label for="inputPasswordConfirm" class="col-sm-3 control-label">&nbsp;</label>
		
		<div class="col-sm-9">
			<span><?php __('front_label_select_list_prompt');?></span>
		</div>
	</div>
	<?php
}
?>