<?php
$this->pageTitle = Yii::app()->name . ' - ' . UserModule::t("Profile");
$this->breadcrumbs = array(
    UserModule::t("Profile") => array('profile'),
    UserModule::t("Edit"),
);
$this->menu = array(
    ((UserModule::isAdmin()) ? array('label' => UserModule::t('Manage Users'), 'url' => array('/user/admin')) : array()),
    array('label' => UserModule::t('List User'), 'url' => array('/user')),
    array('label' => UserModule::t('Profile'), 'url' => array('/user/profile')),
    array('label' => UserModule::t('Change password'), 'url' => array('changepassword')),
    array('label' => UserModule::t('Logout'), 'url' => array('/user/logout')),
);
?><div class="page-header"><h1><?php echo UserModule::t('Edit profile'); ?></h1></div>
<?php if (Yii::app()->user->hasFlash('profileMessage')): ?>
    <div class="success">
	<?php echo Yii::app()->user->getFlash('profileMessage'); ?>
    </div>
<?php endif; ?>
<div class="col-xs-12">
    <?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id' => 'profile-form',
	'enableAjaxValidation' => true,
	'htmlOptions' => array('enctype' => 'multipart/form-data'),
    ));
    ?>
    <!--<p class="note"><?php echo UserModule::t('Fields with <span class="required">*</span> are required.'); ?></p>-->
    <?php echo $form->errorSummary(array($model, $profile)); ?>
    <?php
    $profileFields = $profile->getFields();
    if ($profileFields)
    {
	foreach ($profileFields as $field)
	{
	    ?>
	    <?php
	    echo $form->labelEx($profile, $field->varname);
	    if ($widgetEdit = $field->widgetEdit($profile))
	    {
		echo $widgetEdit;
	    }
	    elseif ($field->range)
	    {
		echo $form->dropDownListControlGroup($profile, $field->varname, Profile::range($field->range));
	    }
	    elseif ($field->field_type == "TEXT")
	    {
		echo $form->textAreaControlGroup($profile, $field->varname, array('rows' => 6, 'cols' => 50));
	    }
	    else
	    {
		echo $form->textFieldControlGroup($profile, $field->varname, array( 'maxlength' => (($field->field_size) ? $field->field_size : 255)));
	    }
	    echo $form->error($profile, $field->varname);
	    ?>
	    <?php
	}
    }
    ?>
    <?php echo $form->textFieldControlGroup($model, 'username', array( 'maxlength' => 20)); ?>
    <?php echo $form->textFieldControlGroup($model, 'email', array( 'maxlength' => 128)); ?>
    
	<?php echo CHtml::submitButton($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save')); ?>
    
    <?php $this->endWidget(); ?>
</div>
