<?php defined('C5_EXECUTE') or die("Access Denied."); ?>

<script type="text/javascript">
$(function() {
	$('i.icon-question-sign').parent().tooltip();
});
</script>

<div class="row">
<div class="col-sm-offset-1 col-sm-10">

	<h1 class="page-header"><?php echo t('Edit Profile')?></h1>

	<form method="post" action="<?php echo $view->action('save')?>" enctype="multipart/form-data">
	<?php  $attribs = UserAttributeKey::getEditableInProfileList(); 
	$valt->output('profile_edit');
	if(is_array($attribs) && count($attribs)) { 
	?>
		<fieldset>
		<legend><?php echo t('Basic Information')?></legend>
		<div class="form-group">
			<?php echo $form->label('uEmail', t('Email'))?>
    		<?php echo $form->text('uEmail',$profile->getUserEmail())?>
		</div>
		<?php  if(ENABLE_USER_TIMEZONES) { ?>
            <div class="form-group">
				<?php echo  $form->label('uTimezone', t('Time Zone'))?>
				<?php echo  $form->select('uTimezone',
					Core::make('helper/date')->getTimezones(), 
					($profile->getUserTimezone()?$profile->getUserTimezone():date_default_timezone_get())
			); ?>
			</div>
		<?php  } ?>               
		<?php 
		$af = Loader::helper('form/attribute');
		$af->setAttributeObject($profile);
		foreach($attribs as $ak) {
			print '<div class="ccm-profile-attribute">';
			print $af->display($ak, $ak->isAttributeKeyRequiredOnProfile());
			print '</div>';
		} ?>
		</fieldset>
	<?php  } ?>
	<?php
	$ats = AuthenticationType::getList(true, true);
	$count = 0;
	$displayAts = array();
	foreach ($ats as $at) {
		if (method_exists($at->controller, 'hook')) {
			$count++;
			$displayAts[] = $at;
		}
	}
	if ($count) {
		?>
		<fieldset>
			<legend><?php echo t('Authentication Types')?></legend>
			<?php
			foreach ($displayAts as $at) {
				$at->renderHook();
			}
			?>
		</fieldset>
		<?php
	}
	?>
        <br/>
	<fieldset>
    	<legend><?php echo t('Change Password')?></legend>
        <div class="form-group">
            <?php echo $form->label('uPasswordNew', t('New Password'))?>
            <?php echo $form->password('uPasswordNew')?>
            <a href="javascript:void(0)" title="<?php echo t("Leave blank to keep current password.")?>"><i class="icon-question-sign"></i></a>
		</div>

        <div class="form-group">
            <?php echo $form->label('uPasswordNewConfirm', t('Confirm New Password'))?>
            <div class="controls">
                <?php echo $form->password('uPasswordNewConfirm')?>
            </div>
        </div>
	
	</fieldset>

	<div class="form-actions">
		<a href="<?php echo URL::to('/account')?>" class="btn btn-default" /><?php echo t('Back to Account')?></a>
		<input type="submit" name="save" value="<?php echo t('Save')?>" class="btn btn-primary pull-right" />
	</div>
	
	</form>

</div>
</div>