<h3 style="text-align: center">Aprobar Solicitud de Retiro Parcial</h3>
<div class="form">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'liquidacion-form',
        'enableAjaxValidation' => false,
        'enableClientValidation' => true,
        'clientOptions' => array(
        'validateOnSubmit' => true,
        'validateOnChange' => true,
        'validateOnType' => true,
        ),
));?>
     <?php echo $this->renderPartial('application.modules.asociado.views.asociado.haberesSocio', array(
        'modelAsociado'=>$model->idAsociado,
        'haberes'=>$modelHaberesSocio,
        'etiquetaFecha'=>'Fecha de Inscripci&oacute;n',
        'fecha'=>$model->idAsociado->fechaingreso,
        'disponible' => new Disponibilidad([
            'asociado' => $model->idAsociado->idasociado,
            'proceso' => 1,
        ])
    )); ?>
    <?php echo $this->renderPartial('application.modules.asociado.views.asociado.detallesHaberesSocio', array('id'=>$model->idasociado)); ?>

    <?php if (count($prestamos)>0) { ?>
  <div class="well" >
        <fieldset>
            <legend>Pago de pr&eacute;stasmos con retiro parcial</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;" style="width: 18%"><b>Categor&iacute;a</b></td>
            <td style="text-align: center;"><b>Plazo del pr&eacute;stamo</b></td>
            <td style="text-align: center;"><b>Monto solicitado</b></td>
            <td style="text-align: center;"><b>Monto aprobado</b></td>
            <td style="text-align: center;"><b>Fecha del pr&eacute;stamo</b></td>
            <td style="text-align: center;"><b>Saldo deudor</b></td>
            <td style="text-align: center;"><b>Estaus</b></td>
          </tr>
          <?php foreach ($prestamos as $key => $value) {?>
            <tr>
              <td><?= $value['categoria'] ?></td>
              <td><?= $value['plazo_prestamo'] ?></td>
              <td style="text-align: right;"><?= number_format($value['prestamo'],2,',','.') ?></td>
              <td style="text-align: right;"><?= number_format($value['prestamo'],2,',','.') ?></td>
              <td style="text-align: center;"><?= date('d-m-Y',strtotime($value['fecha_registro'])) ?></td>
              <td style="text-align: right;"><?= number_format($value['monto'],2,',','.') ?></td>
              <td><?= $value['nombre_estatus_credito'] ?></td>
            </tr>
          <?php }?>
          <tr>
              <td style="text-align: center;" colspan="5"><b>Total</b></td>
              <td style="text-align: right;"><b><?= number_format($model->saldo_deudor,2,',','.') ?></b></td>
              <td class="text-right"></td>
            </tr>
        </table>
      </fieldset>
    </div>
<?php } ?>

  <div class="well" >
        <fieldset>
            <legend>Informaci&oacute;n del Retiro Parcial</legend>
            <div class="row">
<!--                <div class="span3">
                  <?php //echo CHtml::label('<strong>Total Neto Aportes:</strong>',''); ?>
                  <?php //echo number_format($model->monto_aportes,2,',','.'); ?>
               </div>-->
               <div class="span3">
                  <?= CHtml::label('<strong>Monto Disponible</strong>','') ?>
                  <?= number_format($modelHaberesSocio->montoDisponibilidad(), 2, ',', '.') ?>
               </div>
                 <div class="span3">
                  <?php echo CHtml::label('<strong>Monto Solicitado:</strong>',''); ?>
                  <?php echo $model->monto_solicitado; ?>
               </div>

                <?php if($model->saldo_deudor > 0){ ?>
                 <div class="span3">
                   <strong>Saldo deudor:</strong><br>
                   <?= number_format($model->saldo_deudor, 2, ',', '.') ?>
               </div>
                <?php } ?>
            </div>
            <hr />
        </fieldset>
    </div>
    <div class="alert alert-info">
           <div class="row">
               <div class="span5">
                   <?php echo CHtml::label('<strong>Monto a ser Aprobado:</strong>',''); ?>
                    <?php echo  ' Bs.' . $form->textfield($model,'monto_aprobado',array('maxlength'=>'10')) ;?>
                    <?php echo  $form->error($model,'monto_aprobado') ;?>
                    <div style='color: #000; font-size: 11px;'> (El monto aprobado no puede ser mayor que el monto disponible (<?php echo $porcentaje?>))</div><br />


               </div>
                <div class="span5">
                    <?php echo CHtml::label('<strong>Fecha de aprobacion:</strong>',''); ?>
                    <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                              'model' => $modelEstatusRetiro,
                              'attribute' => 'fecha_registro',
                              'value' => $modelEstatusRetiro->fecha_registro,
                              'language' => 'es',
                              'htmlOptions' => array('readonly' => "readonly", 'class' => 'input-xlarge'),
                              //additional javascript options for the date picker plugin
                              'options' => array(
                                  'autoSize' => true,
                                  'defaultDate'=>'03-03-2011',
                                  //'dateFormat'=>'yy-m-d',
                                  'dateFormat' => 'dd-mm-yy',
                                  'buttonImage' => Yii::app()->baseUrl . '/images/calendar.png',
                                  'buttonImageOnly' => true,
                                  'buttonText' => 'Fecha',
                                  'selectOtherMonths' => true,
                                  'showAnim' => 'slide',
                                  'showButtonPanel' => true,
                                  'showOn' => 'button',
                                  'changeMonth' => 'true',
                                  'changeYear' => 'true',
                                  'maxDate'=> "+0D",
                              ),
                        'htmlOptions'=>array('value'=>date('d-m-Y'))
                          ));
                    ?>
                    <?php echo $form->error($modelEstatusRetiro,'fecha_registro') ;?>
                </div>
           </div>
           <div class="row">
               <div class="span11">

                   <?php echo $form->labelEx($modelEstatusRetiro,'observacion'); ?>
                   <?php echo $form->textarea($modelEstatusRetiro,'observacion', array('style'=>'width: 100%;')); ?>
                   <?php echo $form->error($modelEstatusRetiro,'observacion'); ?>
               </div>
           </div>

    </div>

    <div class="form-actions"  style="text-align: center">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType' => 'submit',
			'type' => 'success',
			'id' => 'btn_registrar',
                        'icon'=>'icon-ok',
			'label' => 'Aprobar Retiro Parcial',

                ));?>

                 <?php $this->widget('bootstrap.widgets.TbButton', array(
                                    'buttonType' => 'submit',
                                    'type' => 'danger',
                                    'id' => 'btn_denegar',
                                    'icon'=>'icon-remove',
                                    'label' => 'Denegar Retiro Parcial',

                ));?>
	</div>



<?php $this->endWidget(); ?>

</div>
