<?php
include_once dirname(__FILE__) . '/elements/header.php';

$FORM = array();
$CLIENT = $tpl['arr'];

?>
<div class="pjTbs-body">
	<form id="pjTbsProfileForm_<?php echo $controller->_get->toString('index');?>" action="#" method="post" class="pjTbsProfileForm">
		<input type="hidden" name="tbs_profile" value="1" />
		<input type="hidden" name="foreign_id" value="<?php echo $tpl['arr']['foreign_id']; ?>" />
		
		<div class="pjTbs-box-title"><?php __('front_profile');?></div><!-- /.pjTbs-box-title -->
		
		<div class="row">
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_title'); ?></label>

					<select name="title" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_title'] == 3) ? ' required' : NULL; ?>" data-msg-required="<?php __('front_required_field');?>">
						<option value="">----</option>
						<?php
						$title_arr = pjUtil::getTitles();
						$name_titles = __('personal_titles', true, false);
						foreach ($title_arr as $v)
						{
						    ?><option value="<?php echo $v; ?>"<?php echo isset($CLIENT['title']) && $CLIENT['title'] == $v ? ' selected="selected"' : NULL; ?>><?php echo $name_titles[$v]; ?></option><?php
						}
						?>
					</select>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
		</div>
		<div class="row">
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_fname'); ?></label>
					<?php
						$name_arr = pjUtil::splitName($CLIENT['name']);
					?>
					<input type="text" name="fname" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_fname'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_fname']) ? pjSanitize::clean($FORM['c_fname']) : (isset($name_arr[0]) ? pjSanitize::clean($name_arr[0]) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_lname'); ?></label>
					
					<input type="text" name="lname" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_lname'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_lname']) ? pjSanitize::clean($FORM['c_lname']) : (isset($name_arr[1]) ? pjSanitize::clean($name_arr[1]) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
		</div><!-- /.row -->
		
		<div class="row">
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_phone'); ?></label>
					
					<input type="text" name="phone" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_phone'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_phone']) ? pjSanitize::clean($FORM['c_phone']) : (isset($CLIENT['phone']) ? pjSanitize::clean($CLIENT['phone']) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_email'); ?></label>
					
					<input type="text" name="email" class="form-control email<?php echo ($tpl['option_arr']['o_bf_include_email'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_email']) ? pjSanitize::clean($FORM['c_email']) : (isset($CLIENT['email']) ? pjSanitize::clean($CLIENT['email']) : NULL);?>" data-msg-required="<?php __('front_required_field');?>" data-msg-email="<?php __('front_email_validation');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
		</div><!-- /.row -->
		
		<div class="row">
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_company'); ?></label>
					
					<input type="text" name="company" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_company'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_company']) ? pjSanitize::clean($FORM['c_company']) : (isset($CLIENT['company']) ? pjSanitize::clean($CLIENT['company']) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_address'); ?></label>
					
					<input type="text" name="address" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_address'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_address']) ? pjSanitize::clean($FORM['c_address']) : (isset($CLIENT['address']) ? pjSanitize::clean($CLIENT['address']) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
		</div><!-- /.row -->
		
		<div class="row">
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_city'); ?></label>
					
					<input type="text" name="city" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_city'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_city']) ? pjSanitize::clean($FORM['c_city']) : (isset($CLIENT['city']) ? pjSanitize::clean($CLIENT['city']) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_state'); ?></label>
					
					<input type="text" name="state" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_state'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_state']) ? pjSanitize::clean($FORM['c_state']) : (isset($CLIENT['state']) ? pjSanitize::clean($CLIENT['state']) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
		</div><!-- /.row -->
		
		<div class="row">
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_zip'); ?></label>
					
					<input type="text" name="zip" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_zip'] == 3) ? ' required' : NULL; ?>" value="<?php echo isset($FORM['c_zip']) ? pjSanitize::clean($FORM['c_zip']) : (isset($CLIENT['zip']) ? pjSanitize::clean($CLIENT['zip']) : NULL);?>" data-msg-required="<?php __('front_required_field');?>"/>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
			<div class="col-sm-6 col-xs-12">
				<div class="form-group">
					<label><?php __('front_country'); ?></label>
					
					<select name="country_id" class="form-control<?php echo ($tpl['option_arr']['o_bf_include_country'] == 3) ? ' required' : NULL; ?>" data-msg-required="<?php __('front_required_field');?>">
						<option value="">----</option>
						<?php
						foreach ($tpl['country_arr'] as $v)
						{
							?><option value="<?php echo $v['id']; ?>"<?php echo isset($FORM['c_country']) ? ($FORM['c_country'] == $v['id'] ? ' selected="selected"' : NULL) : (isset($CLIENT['country_id']) ? ($CLIENT['country_id'] == $v['id'] ? ' selected="selected"' : NULL) : NULL) ; ?>><?php echo $v['country_title']; ?></option><?php
						}
						?>
					</select>
					<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
				</div><!-- /.form-group -->
			</div><!-- /.col-sm-6 col-xs-12 -->
		</div><!-- /.row -->
		<br/>
		<div class="pjTbs-body-actions">
			<div id="pjTbsProfileMessage" class="alert pjTbsProfileMessage" style="display:none;"></div>
		
			<div class="row">
				<div class="col-sm-3 col-xs-12">
					<a href="#" class="btn btn-secondary btn-block pjTbsBtnBack" data-load="loadSearch"><?php __('front_btn_back');?></a>
				</div><!-- /.col-sm-3 -->

				<div class="col-sm-3 col-sm-offset-6 col-xs-12">
					<input type="submit" value="<?php __('front_btn_save');?>" class="btn btn-primary btn-block" >
				</div><!-- /.col-sm-3 -->
			</div><!-- /.row -->
		</div><!-- /.pjTbs-body-actions -->
	</form>
</div>