<!DOCTYPE html>
<html lang="<?php echo Yii::app()->language; ?>">
    <head>
        <meta charset="utf-8" />

        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title><?php echo CHtml::encode($this->pageTitle); ?></title>

        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/css/bootstrap-responsive.min.css" />

        <!-- Notificaciones -->
        <link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/lib/sticky/sticky.css" />    

        <!-- Estilos -->
        <link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/profind.css" />
        <link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/media.css" />
        <link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/azul.css" />

        <!-- Favicon -->
        <link rel="shortcut icon" href="favicon.ico" />
    </head>
    <body class="sidebar_hidden profind-fixed">
        <div id="maincontainer" class="clearfix">
            <!-- cabecera -->
            <header>
                <div class="navbar navbar-fixed-top">
                    <div class="navbar-inner">
                        <div class="container-fluid">
                            <a class="brand" href="<?php echo Yii::app()->params['frontpage']; ?>"><i class="icon-home icon-white"></i> <?php echo CHtml::encode(Yii::app()->name); ?></a>
                            <ul class="nav user_menu pull-right">
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo Yii::app()->user->name; ?> <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li><?php echo CHtml::link(Yii::t('profind', 'Cambiar la password'), $this->createUrl('seguridadUsuario/cambiarPassword', array('id' => Yii::app()->user->id))); ?></li>
                                        <li class="divider"></li>
                                        <li><?php echo CHtml::link(Yii::t('profind', 'Salir'), $this->createUrl('site/logout')); ?></li>
                                    </ul>
                                </li>
                            </ul>
                            <a data-target=".nav-collapse" data-toggle="collapse" class="btn_menu">
                                <span class="icon-align-justify icon-white"></span>
                            </a>
                            <nav>
                                <div class="nav-collapse">
                                    <?php
                                    $this->widget('zii.widgets.CMenu', array(
                                        'activeCssClass' => 'active',
                                        'encodeLabel' => false,
                                        'htmlOptions' => array(
                                            'class' => 'nav',
                                        ),
                                        'items' => array(
                                            array(
                                                'label' => CHtml::tag('i', array('class' => 'icon-file icon-white'), '') . ' ' . Yii::t('profind', 'Perfil del agente'),
                                                'url' => array('/usuario/modificar', 'id' => Yii::app()->user->id),
                                                'linkOptions' => array(),
                                            ),
                                            array(
                                                'label' => CHtml::tag('i', array('class' => 'icon-briefcase icon-white'), '') . ' ' . Yii::t('profind', 'Empresa'),
                                                'url' => array('/empresa/modificar', 'id' => Yii::app()->user->id_empresa),
                                                'linkOptions' => array(),
                                            ),
                                            /*array(
                                                'label' => CHtml::tag('i', array('class' => 'icon-user icon-white'), '') . ' ' . Yii::t('profind', 'Equipo'),
                                                'url' => array('/equipo/index'),
                                                'linkOptions' => array('class' => 'icon_block contacto'),
                                            ),*/
                                        ),
                                    ));
                                    ?>                                        

                                </div>
                            </nav>
                        </div>
                    </div>
                </div>
            </header>

            <!-- contenido -->
            <div id="contentwrapper">
                <div class="main_content">
                    <?php echo $content; ?>
                </div>
            </div>

            <!-- Bootstrap JS -->
            <script src="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/js/bootstrap.min.js"></script>
            <!-- Arreglo orientación en iOS -->
            <script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/ios-orientationchange-fix.js"></script>
            <!-- Mensajes -->
            <script src="<?php echo Yii::app()->theme->baseUrl; ?>/lib/sticky/sticky.min.js"></script>
        </div>
    </body>
</html>


<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>

<?php
$flashMessages = Yii::app()->user->getFlashes(false);
if (!empty($flashMessages)) {
    $profind_notificaciones = <<<JS
            $(document).ready(function() {
                    profind_notificaciones.sticky();
            });
            profind_notificaciones = {
                sticky: function() {            
JS;
    if (Yii::app()->user->hasFlash('success')):
        $profind_notificaciones .= '$.sticky("' . Yii::app()->user->getFlash('success') . '", {autoclose : 5000, position: "top-center", type: "st-success" });';
    endif;
    if (Yii::app()->user->hasFlash('error')):
        $profind_notificaciones .= '$.sticky("' . Yii::app()->user->getFlash('error') . '", {autoclose : 5000, position: "top-center", type: "st-error" });';
    endif;
    if (Yii::app()->user->hasFlash('notice')):
        $profind_notificaciones .= '$.sticky("' . Yii::app()->user->getFlash('notice') . '", {autoclose : 5000, position: "top-center", type: "st-info" });';
    endif;

    $profind_notificaciones .= '}';
    $profind_notificaciones .= '}';

    Yii::app()->clientScript->registerScript('profind_notificaciones', $profind_notificaciones, CClientScript::POS_END);
}
?>