<?php Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/lib/uniform/css/uniform.default.css'); ?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/bootstrap-fileupload.js'); ?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/lib/uniform/jquery.uniform.min.js', CClientScript::POS_END); ?>

<?php Yii::app()->clientScript->registerScript(
        'uniform', "
            $(document).ready(function(){ 
                $('.uni_style').uniform();
            });
        ", CClientScript::POS_END);
?>

<?php Yii::app()->clientScript->registerScript(
        'quitar_logotipo', "
            $(document).ready(function(){
                $(document).find(':file').bind('change', function(event, param) {
                    if (param == 'clear') {
                        $('#quitar_logotipo').val('1');
                    }
                });
            });
        ", CClientScript::POS_END);
?>

<div class="row-fluid">
    <div class="span12">
        <h3 class="heading"><?php echo Yii::t('profind', 'Empresa'); ?></h3>
        
        <div class="row-fluid">
            <div class="span8">
                <p>Recoger datos desde la red: 
                    <?php echo CHtml::link('LinkedIn', Yii::app()->createUrl('empresa/modificar', array('id' => $model->id, 'provider' => 'LinkedIn'))); ?>, 
                    <?php echo CHtml::link('Facebook', Yii::app()->createUrl('empresa/modificar', array('id' => $model->id, 'provider' => 'Facebook'))); ?>, 
                    <?php echo CHtml::link('Twitter', Yii::app()->createUrl('empresa/modificar', array('id' => $model->id, 'provider' => 'Twitter'))); ?>.
                </p>
                
                
                <?php if($model->hasErrors()) { ?>
                    <div class="alert alert-error">
                        <a data-dismiss="alert" class="close">×</a>
                        <?php echo CHtml::errorSummary($model, 
                                '<strong>' . Yii::t('profind', 'Se han encontrado errores') . '</strong>',
                                '', 
                                array('firstError' => true)); ?>
                    </div>
                <?php } ?>

                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id' => 'empresa-form',
                    'enableAjaxValidation' => false,
                    'htmlOptions' => array(
                        'enctype' => 'multipart/form-data',
                        'class' => 'form-horizontal'
                    )
                        ));
                ?>
                
                <fieldset>
                    <div class="control-group formSep">
                            <?php echo $form->labelEx($model, 'cif', array('class' => 'control-label')); ?>
                            <div class="controls">
                                <?php echo $form->textField($model, 'cif', array('class' => 'input-xlarge')); ?>
                            </div>
                    </div>
                    <div class="control-group formSep">
                        <?php echo $form->labelEx($model, 'nombre', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <?php echo $form->textField($model, 'nombre', array('class' => 'input-xlarge')); ?>
                        </div>              
                    </div>
                    <div class="control-group formSep">
                        <?php echo $form->labelEx($model, 'email', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <div class="input-prepend">
                                <span class="add-on"><i class="icon-envelope"></i></span>
                                <?php echo $form->textField($model, 'email', array('class' => 'input-xlarge')); ?>
                            </div>
                        </div>
                    </div>
                    <div class="control-group formSep">
                        <?php echo $form->labelEx($model, 'pagina_web', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <?php echo $form->textField($model, 'pagina_web', array('class' => 'input-xlarge')); ?>
                        </div>
                    </div>
                    <div class="control-group formSep">
                        <?php echo $form->labelEx($model, 'direccion', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <?php echo $form->textArea($model, 'direccion', array('class' => 'input-xlarge')); ?>
                        </div>
                    </div>
                    <div class="control-group formSep">
                        <?php echo $form->labelEx($model, 'empleados', array('class' => 'control-label')); ?>
                        <div class="controls">        
                            <?php 
                            $lista = array("menos de 10" => "menos de 10", "entre 10 - 100" => "entre 10 - 100", "más de 100" => "más de 100",);
                            echo $form->dropDownList(
                                 $model,
                                 'empleados',                        
                                 $lista,
                                 array(
                                    'empty' => '',
                                    'class'=>'uni_style input-xlarge',
                                 ));               
                           ?>
                        </div>
                    </div>
                    <div class="control-group">
                        <?php echo $form->labelEx($model, 'descripcion', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <?php echo $form->textArea($model, 'descripcion', array('class' => 'input-xlarge', 'rows'=>7)); ?>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary"><?php echo $model->isNewRecord ? Yii::t('profind', 'Crear') : Yii::t('profind', 'Guardar cambios'); ?></button>
                        <button class="btn"><?php echo Yii::t('profind', 'Cancelar'); ?></button>
                    </div>                        

            </div>
            <div class="span4">

                    <div class="control-group">
                        <?php echo $form->labelEx($model, 'ficheroLogotipo', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <div class="fileupload <?php echo ($model->logotipo->tieneFotografia()) ? 'fileupload-exists' : 'fileupload-new'; ?>" data-provides="fileupload">
                                <div class="fileupload-preview thumbnail" style="width: 150px; height: 150px;">
                                    <?php echo CHtml::image($model->logotipo->getThumbnail()); ?>
                                </div>
                                <div>
                                    <span class="btn btn-file">
                                        <span class="fileupload-new"><?php echo Yii::t('profind', 'Seleccionar imagen'); ?></span>
                                        <span class="fileupload-exists"><?php echo Yii::t('profind', 'Cambiar'); ?></span>
                                        <?php echo $form->fileField($model, 'ficheroLogotipo'); ?>
                                        <input type="hidden" id="quitar_logotipo" name="quitar_logotipo" value="0">
                                    </span>
                                    <a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><?php echo Yii::t('profind', 'Quitar'); ?></a>
                                </div>
                            </div>
                        </div>
                    </div>
                
                
                </fieldset>
                <?php $this->endWidget(); ?>

            </div>
        </div>
    </div>
</div>
