<?php
/**
 * @var $this SearchController 
 */
$this->pageTitle = Yii::app()->name . ' - ' . Yii::t('profind', 'Resultados de la búsqueda');
$this->breadcrumbs = array(
    Yii::t('profind', 'Resultados de la búsqueda')
);

?>

<?php $inicio = (($currentPage * $pages->pageSize) - $pages->pageSize) + 1; ?>
<?php $final = $currentPage * $pages->pageSize; ?>
<?php $final = (count($results) < $final) ? count($results) : $final; ?>


<div class="row-fluid search_page">
    <div class="span12">
        <h3 class="heading"><small><?php echo Yii::t('profind', 'Resultados de búsqueda para'); ?></small> <?php echo CHtml::encode($term); ?></h3>
        
        <?php if ($results) : ?>
        <div class="well clearfix">
            <div class="row-fluid">
                <div class="pull-left">
                    <?php echo Yii::t('profind', 'Mostrando');?> <?php echo $inicio; ?> - <?php echo $final; ?> <?php echo Yii::t('profind', 'de'); ?> <?php echo count($results); ?> <?php echo Yii::t('profind', 'resultados');?>
                </div>
            </div>
        </div>
        <?php endif; ?>
        
        <?php if ($pages->pageCount > 1): ?>
            <div class="pagination">
            <?php $this->widget('CLinkPager', array(
                'pages' => $pages,
                'hiddenPageCssClass' => '',
                'header' => '',
                'htmlOptions' => array('class' => '')
                ));
            ?>
            </div>
        <?php endif; ?>

        <div class="search_panel clearfix">    
            <?php if (!empty($results)): ?>                
                <?php for($i = ($inicio - 1); $i < $final; $i++) : ?>
                    <?php $doc = $results[$i]->getDocument(); ?>                    
                    <?php $candidato = Candidato::model()->findByPk($doc->id); ?>

                    <div class="search_item clearfix">
                        <span class="searchNb"><?php echo $i + 1; ?>.</span>
                        <div class="thumbnail pull-left">
                            <?php echo CHtml::image($candidato->fotografia->getThumbnail(), $candidato->nombreCompleto, array('width' => '80', 'height' => '80')); ?>
                        </div>
                        <div class="search_content">
                            <h4>
                                <?php 
                                    echo CHtml::link(
                                        $query->highlightMatches(CHtml::encode($candidato->nombreCompleto)), 
                                        array('candidato/update', 'id' => $candidato->id),
                                        array('class' => 'sepV_a')
                                    );
                                ?>
                                <span class="label label-info"><?php echo $candidato->estado->descripcion; ?></span>
                            </h4>
                            <p class="sepH_b item_description">


                            </p>
                            
                            <small class="sepH_a">Tag 1</small>, <small>Tag 2</small><br/>
                        </div>
                    </div>
                <?php endfor; ?>
            <?php else: ?>
                <p class="error"><?php echo Yii::t('profind', 'No se han encontrado resultados.'); ?></p>
            <?php endif; ?>
        </div>

        <?php if ($pages->pageCount > 1): ?>
            <div class="pagination">
            <?php $this->widget('CLinkPager', array(
                'pages' => $pages,
                'hiddenPageCssClass' => '',
                'header' => '',
                'htmlOptions' => array('class' => '')
                ));
            ?>
            </div>
        <?php endif; ?>
    </div>
</div>
