<!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>

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

        <!-- 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="">

        <div id="maincontainer" class="clearfix">
            <!-- cabecera -->
            <header>
                <div class="navbar navbar-fixed-top">
                    <div class="navbar-inner">
                        <div class="container-fluid">
                            <div class="brand">
                                <?php echo CHtml::image(Yii::app()->baseUrl . '/images/logo_profind.png', Yii::app()->name); ?>
                            </div>
                            
                            
                            <ul class="nav nav-collapse user_menu pull-right">
                                <li class="hidden-phone hidden-tablet"></li>                                
                                <li class="divider-vertical hidden-phone hidden-tablet"></li>
                                <li class="dropdown">
                                    <a data-toggle="dropdown" class="dropdown-toggle" href="#"><?php echo CHtml::encode(Yii::app()->user->name); ?> <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li><?php echo CHtml::link(Yii::t('profind', 'Perfil'), $this->createUrl('usuario/modificar', array('id' => Yii::app()->user->id))); ?></li>
                                        <?php if (Yii::app()->user->esCoordinador): ?>
                                            <li><?php echo CHtml::link(Yii::t('profind', 'Empresa'), $this->createUrl('empresa/modificar', array('id' => Yii::app()->user->id_empresa))); ?></li>
                                            <li><?php echo CHtml::link(Yii::t('profind', 'Productos'), $this->createUrl('subscripcion/modificar', array('id' => Yii::app()->user->subscripcion->id))); ?></li>
                                            <?php if (Yii::app()->user->tieneEquipo): ?>
                                                <li><?php echo CHtml::link(Yii::t('profind', 'Equipo'), $this->createUrl('equipo/index')); ?></li>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                        <li class="divider"></li>
                                        <li><?php echo CHtml::link(Yii::t('profind', 'Networks'), $this->createUrl('network/index')); ?></li>
                                        <li><?php echo CHtml::link(Yii::t('profind', 'Portales'), $this->createUrl('portal/index')); ?></li>
                                        <li class="divider"></li>
                                        <li><?php echo CHtml::link(Yii::t('profind', 'Cambiar la password'), $this->createUrl('usuario/cambiarPassword', array('id' => Yii::app()->user->id))); ?></li>
                                    </ul>
                                </li>                                
                                <li>
                                    <?php echo CHtml::link(
                                            CHtml::tag('i', array('class' => 'icon-off icon-white'), '') . ' ' . Yii::t('profind', 'Salir'),
                                            $this->createUrl('site/logout')
                                        ); 
                                    ?>
                                </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
                                    $itemsMenu = array();

                                    // Tablero
                                    $itemsMenu[] = array(
                                        'label' => CHtml::tag('i', array('class' => 'icon-th icon-white'), '') . ' ' . Yii::t('profind', 'Tablero'),
                                        'url' => '',
                                        'linkOptions' => array(),
                                    );

                                    // Publicaciones
                                    $itemsMenu[] = array(
                                        'label' => CHtml::tag('i', array('class' => 'icon-tags icon-white'), '') . ' ' . Yii::t('profind', 'Publicaciones'),
                                        'url' => '',
                                        'linkOptions' => array(),
                                    );

                                    // Inscripciones                                    
                                    $itemsMenu[] = array(
                                        'label' => CHtml::tag('i', array('class' => 'icon-bookmark icon-white'), '') . ' ' . Yii::t('profind', 'Inscripciones'),
                                        'url' => '',
                                        'linkOptions' => array(),
                                    );

                                    // BD Candidatos
                                    $itemsMenu[] = array(
                                        'label' => CHtml::tag('i', array('class' => 'icon-hdd icon-white'), '') . ' ' . Yii::t('profind', 'BD Candidatos'),
                                        'url' => array('/candidato/index'),
                                        'linkOptions' => array(),
                                    );

                                    // Blog
                                    $itemsMenu[] = array(
                                            'label' => CHtml::tag('i', array('class' => 'icon-globe icon-white'), '') . ' ' . Yii::t('profind', 'Blog'),
                                            'url' => 'http://www.profindtic.com/blog',
                                            'linkOptions' => array(),
                                    );

                                    $this->widget('zii.widgets.CMenu', array(
                                        'activeCssClass' => 'active',
                                        'encodeLabel' => false,
                                        'htmlOptions' => array(
                                            'class' => 'nav',
                                        ),
                                        'items' => $itemsMenu,
                                    ));
                                    ?>
                                </div>
                            </nav>
                        </div>
                    </div>
                </div>
            </header>

            <!-- contenido -->
            <div id="contentwrapper">
                <div class="main_content">
                    
                    <?php if(isset($this->breadcrumbs)):?>
                        <?php $this->widget('zii.widgets.CBreadcrumbs', array(
                            'homeLink' => CHtml::link(Yii::t('intranet', 'Tablero'), array('/site/index')),
                            'tagName' => 'ul',
                            'links' => $this->breadcrumbs,
                            'activeLinkTemplate' => '<li><a href="{url}">{label}</a></li>',
                            'inactiveLinkTemplate' => '<li class="active">{label}</li>',
                            'separator' => '<span class="divider">/</span>',
                            'htmlOptions' => array('class' => 'breadcrumb'),
                        )); ?>
                    <?php endif; ?>
                    
                    <?php echo $content; ?>
                </div>
            </div>

            <!-- sidebar -->
            <div class="sidebar">
                <div class="sidebar_inner">
                    <form action="#" class="input-append" method="post" >
                        <input autocomplete="off" name="query" class="search_query input-medium" size="16" type="text" placeholder="<?php echo Yii::t('profind', 'Buscar...'); ?>" />
                        <button type="submit" class="btn"><i class="icon-search"></i></button>
                    </form>
                    <div id="side_accordion" class="accordion">
                        <?php if (count($this->menu )> 0): ?>
                        <div class="accordion-group">
                            <div class="accordion-heading">
                                <a class="accordion-toggle" data-toggle="collapse" href="#collapseMenu">
                                    <i class="icon-cog"></i> <?php echo Yii::t('profind', 'Menú'); ?>
                                </a>
                            </div>
                            <div id="collapseMenu" class="accordion-body in collapse" style="height: auto;">
                                <div class="accordion-inner">
                                    <?php $this->widget('zii.widgets.CMenu', array(
                                        'activeCssClass' => 'active',
                                        'encodeLabel' => false,
                                        'items'=> (isset($this->menu['sidebar'])) ? $this->menu['sidebar'] : $this->menu,
                                        'htmlOptions' => array(
                                            'class' => 'nav nav-list',
                                        ),
                                    )); ?>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>
                        <?php if (isset($this->clips['sidebar'])) echo $this->clips['sidebar']; ?>
                    </div>
                </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>
            <!-- General -->
            <script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/profind-general.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);
}
?>
