<?php
/* @var $this RetiroParcialController */
/* @var $model RetiroParcial */
/* @var $form CActiveForm */
?>

<div class="form">

<?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id' => 'pagarMP-form',
            //'type' => 'horizontal',
        'enableAjaxValidation' => false,
        'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,
            'validateOnChange' => true,
            'validateOnType' => true,
        ),
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
    ));
?>

<h1 style="text-align: center"><img style="width:80px; height: 80px;" src="images/paga_dinero.png" id="paga_dinero"> Pagar concepto montepio</h1>
<br>

<?php echo $form->errorSummary($model); ?>
    
    <fieldset>  <!-- Inicio de tabla de datos de fallecido-->
        <legend style=" font-size: 17px;"><b>Datos del fallecido</b></legend>
        <table class="table table-bordered table-striped table-hover items table table-striped table-bordered table-condensed" >
            <tr class="info" >
                <td style="text-align: center"><b>C&eacute;dula</b></td>
                <td style="text-align: center"><b>Nombre y Apellido</b></td>
                <td style="text-align: center"><b>Empresa</b></td>
                <td style="text-align: center"><b>Unidad</b></td>
                <td style="text-align: center"><b>Ultimo Sueldo</b></td>
                <td style="text-align: center"><b>Porcentaje</b></td>

                <td style="text-align: center"><b><?php echo 'Fecha de Registro' ?></b></td>
                <td style="text-align: center"><b>Estatus</b></td>
            </tr>
            <tr>
                <td style="text-align: center"><?php echo $model->idAsociado->cedula; ?></td>
                <td style="text-align: center"><?php echo $model->idAsociado->nombre.' '.$model->idAsociado->apellidos; ?></td>
                <td style="text-align: center"><?php echo ($model->idAsociado->unidad)?$model->idAsociado->unidad->descripcion:""; ?></td>
                <td style="text-align: center"><?php echo $model->idAsociado->lugartrabajo; ?></td>
                <td style="text-align: center"><?php echo $model->idAsociado->utltimoSueldo($model->idAsociado->idasociado);?></td>
                <td style="text-align: center"><?php echo ($model->idAsociado->aportes)?$model->idAsociado->aportes->descripcion:""; ?></td>
                <td style="text-align: center"><?php echo $model->idAsociado->fechaingreso ?></td>
                <td style="text-align: center"><?php echo ($model->idAsociado->blnborrado=="1")?"Inactivo":strtoupper($model->idAsociado->idEstatus->nombre_estatus); ?></td>
            </tr>
        </table>
    </fieldset>
    <br>
    <fieldset>  <!-- Inicio de tabla de datos de los beneficiarios-->
        <legend style=" font-size: 17px;"><b>Beneficiarios</b></legend>            
        <table id="tbl-beneficiarios" class="table table-bordered" >
                <tr style="background-color: #d9edf7;">
                    <td style="width: 20%"></td>
                    <td style="width: 20%"><b>Nombres y apellidos</b></td>
                    <td style="width: 20%"><b>C&eacute;dula</b></td>
                    <td style="width: 20%"><b>Parentesco</b></td>
                    <td style="width: 20%"><b>Fecha de Nacimiento</b></td>
                    <td style="width: 20%"><b>Distribuci&oacute;n</b></td>
                </tr>
                <!--Seccion beneficiarios se llena con un foreach-->
                <?php foreach ($beneficiarios as $key => $value) { ?>                
                    <tr>
                        <td><b>Beneficiario N° <?php echo $key + 1 ?></b></td>
                        <td><?php echo $value->idBeneficiario->nombre.' '.$value->idBeneficiario->apellido; ?></td>
                        <td><?php echo $value->idBeneficiario->cedula; ?></td>
                        <td><?php echo $value->idBeneficiario->parent->descripcion; ?></td>
                        <td><?php echo date("d-m-Y", strtotime($value->idBeneficiario->fecha)); ?></td>
                        <td><span class="distribucion">Bs. <?php echo number_format($value->monto_distribuido, 2,',','.'); ?></span></td>
                    </tr>

                <?php } ?>
        </table>
    </fieldset>
    <br>
    <p class="note">Los campos con <span class="required">*</span> son obligatorios.</p>
    <div class="well">
        <div class="row">

            <div class="span5">
                <?php echo CHtml::label('Monto a pagar', ''); ?>
                <?php echo CHtml::label('<b>'.number_format($model->monto_solicitud, 2, ',','.').'</b>', ''); ?>
            </div>
            <div class="span11">
                <?php
                echo $form->dropDownListRow($comprobante, 'id_banco', CHtml::listData(ParamBancos::model()->findAll(array('condition' => 'estatus=true and blnborrado=false')), 'id', 'descripcion'), 
                                                                                    array('prompt' => '-- Seleccione banco--','style'=>'width: 100%'));
                ?>
            </div>
                
        </div>
        <div class="row">           
            <div class="span5">
                <?php echo $form->textFieldRow($comprobante, 'referencia'); ?>
            </div>
            <div class="span5">
                <?php echo $form->labelEx($comprobante, 'fecha_pago'); ?>
                <?php
                $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                    'model' => $comprobante,
                    'attribute' => 'fecha_pago',
                    'value' => $comprobante->fecha_pago,
                    'language' => 'es',
                    'htmlOptions' => array('readonly' => true, 'style' => 'width:140px'),
                    //additional javascript options for the date picker plugin
                    'options' => array(
                        'autoSize' => true,
                        'defaultDate' => $comprobante->fecha_pago,
                        //'dateFormat'=>'yy-m-d',
                        'dateFormat' => 'dd-mm-yy',
                        'yearRange' => "1900:+nn",
                        'maxDate'=>'0d',
//                            'maxDate'=>$model->fechafin(),
                        'buttonImage' => Yii::app()->baseUrl . '/images/calendar.png',
                        'buttonImageOnly' => true,
                        'buttonText' => 'Fecha referencia',
                        'selectOtherMonths' => true,
                        'showAnim' => 'slide',
                        'showButtonPanel' => true,
                        'showOn' => 'button',
                        'showOtherMonths' => true,
                        'changeMonth' => 'true',
                        'changeYear' => 'true',
                    ),
                ));
                ?> 
                    <?php echo $form->error($comprobante, 'fecha_registro'); ?>
                </div>
            </div>
            <div class="row">
                
                
            </div>
            <div class="row-fluid">
                <?php echo $form->textAreaRow($comprobante, 'observacion',array('style'=>'width: 100%')); ?>
            </div>

        </div>
        <div class="row-fluid" style="text-align: center">
            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                'buttonType' => 'submit',
                'type' => 'success',
                'icon' => 'icon-ok',
                'label' => 'Realizar pago',
            ));
            ?>
        </div>

<?php $this->endWidget(); ?>
</div><!-- form -->