<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	include_once PJ_VIEWS_PATH . 'pjLayouts/elements/requestmenu.php';
	pjUtil::printNotice(__('infoAddRequestTitle', true), __('infoAddRequestDesc', true));

	$show_period = 'false';
	if((strpos($tpl['option_arr']['o_time_format'], 'a') > -1 || strpos($tpl['option_arr']['o_time_format'], 'A') > -1))
	{
		$show_period = 'true';
	}
	
	$week_start = isset($tpl['option_arr']['o_week_start']) && in_array((int) $tpl['option_arr']['o_week_start'], range(0,6)) ? (int) $tpl['option_arr']['o_week_start'] : 0;
	$jqDateFormat = pjUtil::jqDateFormat($tpl['option_arr']['o_date_format']);
	$jqTimeFormat = pjUtil::jqTimeFormat($tpl['option_arr']['o_time_format']);
	?>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminRequests&amp;action=pjActionCreate" method="post" id="frmCreateRequest" class="form pj-form" autocomplete="off">
		<input type="hidden" name="request_create" value="1" />
		<p>
			<label class="title"><?php __('lblReasonToCall'); ?></label>
			<span class="inline_block">
				<select name="reason_id" id="reason_id" class="pj-form-field w200 required" data-msg-required="<?php __('lblFieldRequired');?>">
					<option value="">-- <?php __('lblChoose'); ?>--</option>
					<?php
					foreach ($tpl['reason_arr'] as $k => $v)
					{
						?><option value="<?php echo $v['id']; ?>"><?php echo $v['reason']; ?></option><?php
					}
					?>
				</select>
			</span>
		</p>
		<?php
		if (in_array((int) $tpl['option_arr']['o_bf_include_name'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblName'); ?></label>
				<span class="inline_block">
					<input type="text" name="name" id="name" class="pj-form-field w326<?php echo (int) $tpl['option_arr']['o_bf_include_name'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_email'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblEmail'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-email"></abbr></span>
					<input type="text" name="email" id="email" class="pj-form-field email w300<?php echo (int) $tpl['option_arr']['o_bf_include_email'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>" data-msg-email="<?php __('lblEmailInvalid');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_phone'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblPhone'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-phone"></abbr></span>
					<input type="text" name="phone" id="phone" class="pj-form-field w300<?php echo (int) $tpl['option_arr']['o_bf_include_phone'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_company'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblCompany'); ?></label>
				<span class="inline_block">
					<input type="text" name="company" id="company" class="pj-form-field w326<?php echo (int) $tpl['option_arr']['o_bf_include_company'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_address'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblAddress'); ?></label>
				<span class="inline_block">
					<input type="text" name="address" id="address" class="pj-form-field w326<?php echo (int) $tpl['option_arr']['o_bf_include_address'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_city'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblCity'); ?></label>
				<span class="inline_block">
					<input type="text" name="city" id="city" class="pj-form-field w326<?php echo (int) $tpl['option_arr']['o_bf_include_city'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_state'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblState'); ?></label>
				<span class="inline_block">
					<input type="text" name="state" id="state" class="pj-form-field w326<?php echo (int) $tpl['option_arr']['o_bf_include_state'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_zip'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblZip'); ?></label>
				<span class="inline_block">
					<input type="text" name="zip" id="zip" class="pj-form-field w326<?php echo (int) $tpl['option_arr']['o_bf_include_zip'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"/>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_country'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblCountry'); ?></label>
				<span class="inline_block">
					<select name="country_id" id="country_id" class="pj-form-field w340<?php echo (int) $tpl['option_arr']['o_bf_include_country'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>">
						<option value="">-- <?php __('lblChoose'); ?>--</option>
						<?php
						foreach ($tpl['country_arr'] as $k => $v)
						{
							?><option value="<?php echo $v['id']; ?>"><?php echo $v['country_title']; ?></option><?php
						}
						?>
					</select>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_notes'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblNotes'); ?></label>
				<span class="inline_block">
					<textarea name="notes" id="notes" class="pj-form-field w500 h80<?php echo (int) $tpl['option_arr']['o_bf_include_notes'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>"></textarea>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_calltime'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblBestTimeToCall'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-after">
					<input type="text" name="besttime" class="pj-form-field pointer w140 datetimepick<?php echo (int) $tpl['option_arr']['o_bf_include_calltime'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>" readonly="readonly" rel="<?php echo $week_start; ?>" rev="<?php echo $jqDateFormat; ?>" lang="<?php echo $jqTimeFormat; ?>"/>
					<span class="pj-form-field-after"><abbr class="pj-form-field-icon-date"></abbr></span>
				</span>
			</p>
			<?php
		}
		if (in_array((int) $tpl['option_arr']['o_bf_include_timezone'], array(2,3)))
		{ 
			?>
			<p>
				<label class="title"><?php __('lblMyTimezone'); ?></label>
				<span class="inline_block">
					<select name="timezone" id="timezone" class="pj-form-field w150<?php echo (int) $tpl['option_arr']['o_bf_include_timezone'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('lblFieldRequired');?>">
						<?php
						$default = explode("::", $tpl['timezone_arr']['value']);
						$enum = explode("|", $default[0]);
						
						$enumLabels = array();
						if (!empty($tpl['timezone_arr']['label']) && strpos($tpl['timezone_arr']['label'], "|") !== false)
						{
							$enumLabels = explode("|", $tpl['timezone_arr']['label']);
						}
						foreach ($enum as $k => $el)
						{
							if ($default[1] == $el)
							{
								?><option value="<?php echo $el; ?>" selected="selected"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
							} else {
								?><option value="<?php echo $el; ?>"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
							}
						}
						?>
					</select>
				</span>
			</p>
			<?php
		} 
		?>
		<p>
			<label class="title">&nbsp;</label>
			<input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" />
			<input type="button" value="<?php __('btnCancel'); ?>" class="pj-button" onclick="window.location.href='<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjAdminRequests&action=pjActionIndex';" />
		</p>
	</form>
	
	<script type="text/javascript">
	var myLabel = myLabel || {};
	myLabel.showperiod = <?php echo $show_period; ?>;
	</script>
	<?php
}
?>