<?php 
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/fileinput.js',CClientScript::POS_END);
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/fileinput.css');?>
<?php
$this->breadcrumbs=array(
	'Datos Txt Integrados'=>array('index'),
	'Create',
);

$this->menu=array(
	array('label'=>'List DatosTxtIntegrado','url'=>array('index')),
	array('label'=>'Manage DatosTxtIntegrado','url'=>array('admin')),
);
?>

<h3 style="text-align: center;">Carga masiva de n&oacute;mina de pr&eacute;stamo<br><?php echo $modelPrenomina->nombre_archivo?></h3>
<?php
    foreach(Yii::app()->user->getFlashes() as $key => $message) {
        echo '<div class="alert alert-' . $key . '">' . $message . "</div>\n";
    }
?>



<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'carga-masiva-form',
	'enableAjaxValidation'=>false,
        'htmlOptions'=>array('enctype'=>'multipart/form-data','onsubmit'=>'activar_barra();'),
         'type'=>'horizontal',
)); ?>

	<?php echo $form->errorSummary($model); ?>
       <hr>
    <div class="rows">
    	<div class="span11">
    		<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>Categor&iacute;a del pr&eacute;stamo</b></td>
        <td style="text-align: center"><b>Plazo</b></td>
        <td style="text-align: center"><b>Cantidad de cuotas</b></td>
        <td style="text-align: center"><b>Monto capital</b></td>
        <td style="text-align: center"><b>Monto interes</b></td>
        <td style="text-align: center"><b>Monto total</b></td>
      </tr>
      <?php    $sumaCuota = $sumaMonto=$sumaCapita = $sumaInteres =  0;
            foreach ($data as $key => $value) {
                    $sumaCuota+= $value['cantidad_cuota'];
                    $sumaInteres+= $value['interes'];
                    $sumaCapita+= $value['capital'];
                    $sumaMonto+= $value['monto'];
                    ?>
            <tr>
                <td><?php echo $value['nombre_titulo']?></td>
                <td><?php echo $value['descripcion']?></td>
                <td style="text-align: center"><?php echo $value['cantidad_cuota']?></td>
                <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['capital'],'')?></td>
                <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['interes'],'')?></td>
                <td style="text-align: right">Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($value['monto'],'')?></td>
            </tr>

         <?php }?>
        <tr class="info" >
            <th></th>
            <th style="text-align: center"><b>Totales</b></th>
            <th style="text-align: center"><b><?php echo $sumaCuota?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaCapita,'')?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaInteres,'')?></b></th>
            <th style="text-align: right"><b>Bs. <?php echo Yii::app()->numberFormatter->formatCurrency($sumaMonto,'')?></b></th>
        </tr>
    </table>
    	</div>
    </div>
    <?php echo  CHtml::link('Descargar prenómina',array('/prestamo/DatosPreNominaCredito/generarPrenominaExcel','id'=>$modelPrenomina->id) ,array('target'=>'_blank','class'=>'btn btn-link'));?>
    <?php echo  CHtml::link('Descargar formato de carga','doc/carga_masiva_retenciones/formato_retenciones.xls' ,array('target'=>'_blank','class'=>'btn btn-link'));?>
    <hr>
    <p class="help-block">Los campos con <span class="required">*</span> son obligatorios.</p>
    <br>
	<?php echo $form->fileFieldRow($model,'nombre_archivo',array('class'=>'file file-loading','data-show-caption'=>true)); ?>
    <?php echo $form->textFieldRow($model,'num_comprobante',array('class'=>'span8')); ?>
    <?php echo $form->textAreaRow($model,'descripcion',array('rows'=>6, 'cols'=>50, 'class'=>'span8')); ?>

	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>'Guardar',
		)); ?>
	</div>

<?php $this->endWidget(); ?>

<?= $this->renderPartial('application.modules.aportes.views.datosTxtIntegrado.barra_carga', array('titulo' => 'Cargando n&oacute;mina de aportes...')) ?>
