<?php
mt_srand();
$index = mt_rand(1, 9999);
?>
<div id="pjWrapper">
	<div class="container-fluid pjCfContainer">
		<?php include_once PJ_VIEWS_PATH . 'pjLoad/elements/header.php';?>
		
		<div class="panel panel-default pjCfBody pjCfForm pjCfFormAccess pjCfFormRegister">
			<header class="panel-heading text-center pjCfFormHead">
				<p class="panel-title pjCfFormTitle"><?php __('front_menu_create_an_account');?></p><!-- /.panel-title pjCfFormTitle -->
			</header><!-- /.panel-heading text-center pjCfFormHead -->
			
			<div class="panel-body pjCfFormBody">
				<form id="pjSFRegisterForm_<?php echo $index;?>" action="<?php echo $_SERVER['PHP_SELF'];?>?controller=pjLoad&amp;action=pjActionRegister" method="post" data-toggle="validator" role="form" enctype="multipart/form-data">
					<input type="hidden" value="1" name="register">
					
					<div class="row">
						<div class="col-lg-offset-3 col-lg-6 col-md-offset-3 col-md-6 col-sm-offset-2 col-sm-8 col-xs-12">
						
							<?php
							if(isset($tpl['err']))
							{
								$front_err = pjSanitize::clean(__('front_err', true));
								$msg = $front_err[$tpl['err']];
								$msg = str_replace("{MAXSIZE}", ini_get('post_max_size'), $msg);
								$msg = str_replace("{POSTSIZE}", ini_get('upload_max_filesize'),$msg);
								?>
								<div class="alert alert-danger" role="alert"><?php echo $msg;?></div>
								<?php
							}
							if(isset($tpl['msg']))
							{
								$front_msg = pjSanitize::clean(__('front_msg', true));
								?>
								<div class="alert alert-success" role="alert"><?php echo $front_msg[$tpl['msg']];?></div>
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_name'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_full_name');?>: </label>
						
									<input type="text" name="name" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_name'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_email'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_email_address');?>: </label>
									
									<input type="email" name="email" class="form-control email<?php echo (int) $tpl['option_arr']['o_rf_include_email'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>" data-msg-email="<?php __('front_email_invalid');?>" data-msg-remote="<?php __('front_email_in_used');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_password'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_password');?>: </label>
									
									<input type="password" id="pjSFPassword" name="password" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_password'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								
								<div class="form-group">
									<label for=""><?php __('front_reenter_password');?>: </label>
									
									<input type="password" name="reenter_password" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_password'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>" data-msg-equalTo="<?php __('front_password_not_match');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_website'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_website');?>: </label>
									
									<input type="text" name="website" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_website'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_phone'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_phone');?>: </label>
									
									<input type="text" name="phone" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_phone'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_address'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_address');?>: </label>
									
									<input type="text" name="address" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_address'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_city'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_city');?>: </label>
									
									<input type="text" name="city" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_city'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_state'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_state');?>: </label>
									
									<input type="text" name="state" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_state'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_zip'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_zip');?>: </label>
									
									<input type="text" name="zip" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_zip'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_country'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<label for=""><?php __('front_country');?>: </label>
									
									<select name="country_id" class="form-control<?php echo (int) $tpl['option_arr']['o_rf_include_country'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>">
										<option value="">-- <?php __('front_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 class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if (in_array((int) $tpl['option_arr']['o_rf_include_avatar'], array(2,3)))
							{ 
								?>
								<div class="form-group">
									<div class="pjCfAddFile">
										<label for=""><?php __('front_avatar');?>: </label>
										
										<div class="pjCfAddFileImage">
											<img src="<?php echo PJ_INSTALL_URL . PJ_IMG_PATH . 'frontend/imgo.jpg';?>" alt="" />
										</div><!-- /.pjCfAddFileImage -->
						
										<div class="btn btn-default pjCfBtn pjCfBtnFile pjCfBtnUpload">
											<?php __('front_add_file');?>
									
											<input type="file" name="avatar" class="pjCfFileUploadField<?php echo (int) $tpl['option_arr']['o_rf_include_avatar'] === 3 ? ' required' : NULL; ?>" data-msg-required="<?php __('front_field_required');?>" data-msg-extension="<?php __('front_file_extensions');?>"/>
										</div>
						
										<a href="#" class="btn btn-default pjCfBtn pjCfBtnFile pjCfBtnReset"><?php __('front_reset_image');?></a>
									</div><!-- /.pjCfAddFile -->
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group -->
								<?php
							}
							if($tpl['use_captcha'] == true)
							{ 
								?>
								<div class="form-group pjCfCaptcha">
									<label for=""><?php __('front_captcha');?>: </label>
									<img class="pjSFFormCaptchaImage" src="<?php echo PJ_INSTALL_FOLDER; ?>index.php?controller=pjFront&amp;action=pjActionCaptcha&amp;rand=<?php echo rand(1, 999999); ?>" alt="CAPTCHA"/>
									<input type="text" name="captcha" class="form-control required" maxlength="6" autocomplete="off" data-msg-required="<?php __('front_field_required');?>" data-msg-remote="<?php __('front_captcha_incorrect');?>"/>
									<div class="help-block with-errors"><ul class="list-unstyled"></ul></div>
								</div><!-- /.form-group pjCfCaptcha -->
								<?php
							} 
							?>
							<div class="form-group pjCfFormActions">
								<button type="submit" class="btn btn-default pjCfBtn pjCfBtnPrimary"><?php __('front_btn_register');?></button>
								<p><?php __('front_if_had_account');?> - <a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjLoad&amp;action=pjActionLogin" class="btn btn-link pjCfBtn pjCfBtnLink"><?php __('front_menu_login');?></a></p>
							</div><!-- /.form-group pjCfFormActions -->
						</div><!-- /.col-lg-offset-3 col-lg-6 col-md-offset-3 col-md-6 col-sm-offset-2 col-sm-8 col-xs-12 -->
					</div><!-- /.row -->
				</form>
			</div><!-- /.panel-body pjCfFormBody -->
		</div><!-- /.panel panel-default pjCfBody pjCfForm pjCfFormAccess pjCfFormRegister -->
	</div><!-- /.container-fluid pjCfContainer -->
</div><!-- /#pjWrapper -->
	
<?php include_once PJ_VIEWS_PATH . 'pjLoad/elements/loadjs.php';?>