<?php
/* @var $this PrestamoController */
/* @var $model Prestamo */
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});

$('.search-form form').submit(function(){
	$('#prestamo-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");

?>

<style>
    #titulo{
    font-size: 1.4rem;
    }

@media screen and (max-width:780px) and (min-width:300px) {  
    
    #titulo{
    font-size: 1.0rem;
    }

    .table-responsive{
    width: 132%;
    margin-left: -40px;
    }
    
    #a{
        overflow-x: auto;
    }
    
}   
    


</style>








    
  <div class="row justify-content-end">
 
    <div class="col-12  col-sm-12 col-md-8 text-right"  style="margin-right: 25px;" >
         
 <?php echo CHtml::link('<i class="fa fa-file-pdf fa-lg"></i>  PDF', 
             Yii::app()->createUrl('prestamo/Carterapdf'), 
             array('class'=>'btn btn-danger',
                 'data-toggle' => "tooltip",
                 'data-original-title' => 'PDF',
                   "target"=>"_blank"
                 )); 
     ?>     

    <?php echo CHtml::link('<i class="fa fa-file-pdf fa-lg"></i> EXCEL', 
             Yii::app()->createUrl('prestamo/Carteraexcel'), 
             array('class'=>'btn btn-success',
                 'data-toggle' => "tooltip",
                 'data-original-title' => 'EXPORTAR A EXCEL',
                 'style'=>'background-color:#066100;'
                 
                 )); 
     ?> 

     <?php echo CHtml::link('<i class="fas fa-sync fa-lg"></i>', 
             '#', 
             array('class'=>'btn btn-danger',
                 'onClick' => 'window.location="' . Yii::app()->createUrl('prestamo/cartera') . '"; ',
                 'data-toggle' => "tooltip",
                 'data-original-title' => 'REFRESCAR LISTA'
                 )); 
     ?>   
    </div>

                


   </div>

            
    <?php
    if(!empty($_SESSION['id_perfil']) and ($_SESSION['id_perfil']=='1') ){
    ?>
            
     
    <div class="row justify-content-center mt-3 p-3">
  <fieldset class="col-12 col-sm-12 col-md-12 ">
    <legend> DATOS A CONSULTAR</legend>
<?php
  }
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm',
        array('id'=>'consultar-form',
            'enableClientValidation' => true,
            'clientOptions' => array(
                'validateOnSubmit' => true,
            ),
            'htmlOptions' => array('class' => ' m-t-30'),
        ));
        ?>
        <div class="row ">
                  <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 
                            ">
                        <div class="form-group">
                           <?php echo $form->labelEx($consular,'gestor', array('class' => 'col-12 text-uppercase')); ?>
                           <div class="col-12">
                           <?php echo $form->dropdownList($consular,'gestor', ConsultarForm::gestor(),  array('class'=>'form-control form-control-line text-uppercase','prompt' => 'SELECCIONE')); ?> 
                   
                          </div>
                        </div>
                  </div>
            
             <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 
                            ">
                        <div class="form-group">
                           <?php echo $form->labelEx($consular,'zona', array('class' => 'col-12 text-uppercase')); ?>
                           <div class="col-12">
                           <?php echo $form->dropdownList($consular,'zona', ConsultarForm::zona(),  array('class'=>'form-control form-control-line text-uppercase','prompt' => 'SELECCIONE')); ?> 
                   
                          </div>
                        </div>
                  </div>
            
             <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 
                            ">
                        <div class="form-group">
                           <?php echo $form->labelEx($consular,'estatus', array('class' => 'col-12 text-uppercase')); ?>
                           <div class="col-12">
                           <?php echo $form->dropdownList($consular,'estatus', ConsultarForm::estatus(),  array('class'=>'form-control form-control-line text-uppercase','prompt' => 'SELECCIONE')); ?> 
                   
                          </div>
                        </div>
                  </div>
            
            
             <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 
                            ">
                        <div class="form-group">
                           <?php echo $form->labelEx($consular,'cant', array('class' => 'col-12 text-uppercase')); ?>
                           <div class="col-12">
                           <?php echo $form->dropdownList($consular,'cant', ConsultarForm::cant(),  array('class'=>'form-control form-control-line text-uppercase','prompt' => 'SELECCIONE')); ?> 
                   
                          </div>
                        </div>
                  </div>
            
                <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 
                            ">
                        <div class="form-group">
                           <?php echo $form->labelEx($consular,'credito', array('class' => 'col-12 text-uppercase')); ?>
                           <div class="col-12">
                           <?php echo $form->dropdownList($consular,'credito',  Monto::lista(),  array('class'=>'form-control form-control-line text-uppercase','prompt' => 'SELECCIONE')); ?> 
                   
                          </div>
                        </div>
                </div>
            
             <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 
                            ">
                        <div class="form-group">
                           <?php echo $form->labelEx($consular,'id_modalidad', array('class' => 'col-12 text-uppercase')); ?>
                           <div class="col-12">
                           <?php echo $form->dropdownList($consular,'id_modalidad', Modalidad::lista(),  array('class'=>'form-control form-control-line text-uppercase','prompt' => 'SELECCIONE')); ?> 
                   
                          </div>
                        </div>
                  </div>
            
            
            
            
            
            <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4" style="margin-top:25px;">
            <div class="form-group">
            <?php echo CHtml::button('CONSULTAR', array(
                            'class'=>'btn btn-primary  btn-block'
                           ,'ajax' => array(
                            'type' => 'POST',
                            'url' => CController::createUrl('Prestamo/Ajax'), 
                            'data'=>array('gestor'=>'js:ConsultarForm_gestor.value','zona'=>'js:ConsultarForm_zona.value','estatus'=>'js:ConsultarForm_estatus.value','cant'=>'js:ConsultarForm_cant.value','credito'=>'js:ConsultarForm_credito.value' ,'id_modalidad'=>'js:ConsultarForm_id_modalidad.value' ),   
                            'dataType' => 'json',   
                            'beforeSend'=>'function(){
                                 
                                $("#resul").hide();
                                $("#ConsultarForm_clientes").val("");
                                $("#ConsultarForm_soles").val("");
                                $("#ConsultarForm_capitalinteres").val("");
                                $("#ConsultarForm_ingreso").val("");
                                $("#ConsultarForm_porcobrar").val("");

                            }',         
                            'success' => 'js:function(data)
                            {   $("#resul").show();
                                $("#ConsultarForm_clientes").val(data.clientes);
                                $("#ConsultarForm_soles").val(data.soles);
                                $("#ConsultarForm_capitalinteres").val(data.capitalinteres);
                                $("#ConsultarForm_ingreso").val(data.ingreso);
                                $("#ConsultarForm_porcobrar").val(data.porcobrar);

                            }',  
                                'error' => 'function(data, status){ 
                                    $("#resul").hide();
                                $("#ConsultarForm_clientes").val("");
                                $("#ConsultarForm_soles").val("");
                                $("#ConsultarForm_capitalinteres").val("");
                                $("#ConsultarForm_ingreso").val("");
                                $("#ConsultarForm_porcobrar").val("");
                                }',       

                            ),)); ?>
                
           </div>
        </div> 
            
        </div>
    



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

  
</div>    
  </fieldset>
     </div>       
     
            
            
    <div  style="display:none" id="resul" >
                
                
      <div class="row justify-content-center m-2" >
          <div class="col-12 text-center" >          
              <h5>RESULTADOS</h5>   
        </div>        
       </div>          
    <div class="row justify-content-center p-3"  >
        <div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3 text-center"   >
            
            <?php echo $form->labelEx($consular,'clientes', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase', 'style'=>'background: #DE6B04;font-weight: bold;')); ?>
            
                     <?php echo $form->textField($consular,'clientes',array('size'=>60,'maxlength'=>200,
                               'class' => 'form-control form-control-line text-uppercase text-center ','style'=>'font-size: 1rem;font-weight: 400;
    line-height: 1.5;
    color: #12131a;font-weight: bold;',
                               'placeholder'=>"",'readonly'=>'readonly')); ?>
        </div>
        
        
        <div class="col-12  col-md-2 col-lg-2 col-xl-2 text-center">
            
            
            
            <?php echo $form->labelEx($consular,'soles', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase', 'style'=>'background: #DE6B04;font-weight: bold;')); ?>
            
            
              <?php echo $form->textField($consular,'soles',array('size'=>60,'maxlength'=>200,
                               'class' => 'form-control form-control-line text-uppercase text-center ','style'=>'font-size: 1rem;font-weight: 400;font-weight: bold;
    line-height: 1.5;
    color: #12131a;',
                               'placeholder'=>"",'readonly'=>'readonly')); ?>
        </div>
        
        
        <div class="col-12 col-sm-12  col-md-3 col-lg-3 col-xl-3 text-center">
            <?php echo $form->labelEx($consular,'capitalinteres', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase', 'style'=>'background: #DE6B04;font-weight: bold;')); ?>

            <h1>
                
            
             <?php echo $form->textField($consular,'capitalinteres',array('size'=>60,'maxlength'=>200,
                               'class' => 'form-control form-control-line text-uppercase text-center ','style'=>'font-size: 1rem;font-weight: 400;
    line-height: 1.5;
    color: #12131a;font-weight: bold;',
                               'placeholder'=>"",'readonly'=>'readonly')); ?>
            
            </h1>
            
            
        </div>
        
        
         
        <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center">
            <?php echo $form->labelEx($consular,'ingreso', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase', 'style'=>'background: #DE6B04;font-weight: bold;')); ?>

            <h1>
                
            
             <?php echo $form->textField($consular,'ingreso',array('size'=>60,'maxlength'=>200,
                               'class' => 'form-control form-control-line text-uppercase text-center ','style'=>'font-size: 1rem;font-weight: 400;
    line-height: 1.5;
    color: #12131a;font-weight: bold;',
                               'placeholder'=>"",'readonly'=>'readonly')); ?>
            
            </h1>
            
            
        </div>
        
        
        
          
        <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center">
            <?php echo $form->labelEx($consular,'porcobrar', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase', 'style'=>'background: #DE6B04;font-weight: bold;')); ?>

            <h1>
                
            
             <?php echo $form->textField($consular,'porcobrar',array('size'=>60,'maxlength'=>200,
                               'class' => 'form-control form-control-line text-uppercase text-center ','style'=>'font-size: 1rem;font-weight: 400;
    line-height: 1.5;
    color: #12131a;font-weight: bold;',
                               'placeholder'=>"",'readonly'=>'readonly')); ?>
            
            </h1>
            
            
        </div>
    </div>
    
        <hr>
</div>         
     
     
  

<div class="row">
    <div class="col-12 ">
        <?php
        $pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
        echo
        'Ver ' .
         CHtml::dropDownList('pageSize', $pageSize, Utility::listaPageSize(), array(
            'onchange' => "$.fn.yiiGridView.update('prestamo-grid',{ data:{pageSize: $(this).val() }})",
        ))
         . ' Cartera';
        ?>
    </div> 
</div>

<div class='table-responsive'> 
    
    
<div class="search-form" style="display:none">
<?php 

$this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div>
    
    
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'prestamo-grid',
	'dataProvider'=>$model->searchCartera(),
        'pager' => array('cssFile' => Yii::app()->baseUrl.'/public/css/tablas.css'),
	'filter'=>$model,
	'columns'=>array(
                  array(
                    'filter' =>false,
                    'value' => '$data->id_prestamo',
                    'type' => 'text',
                    'name' => 'id_prestamo',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
          
               array(
                    'filter' =>Gestor::lista3(),
                    'value' => '$data->gestor',
                    'type' => 'text',
                    'name' => 'gestor',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
                
           array(
            
                    'value' => 'Utility::fecha($data->fecha_inicio)',
                    'type' => 'text',
                    'name' => 'fecha_inicio',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
          
          
          
          
          
             array(

                    'value' => '$data->dia_prestamo',
                    'type' => 'text',
                    'name' => 'dia_prestamo',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
            
            array(
                   'header'=>'ZONA',
                    'filter' => Zona::lista2(),
                    'value' => '$data->zona',
                    'type' => 'text',
                    'name' => 'zona',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
            array(
                   'header'=>'ESTATUS',
                    'filter' =>Prestamo::listaEstatus(),
                    'value' => 'Prestamo::estatusClass($data->estatus)',
                    'type' => 'html',
                    'name' => 'estatus',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
            
            
            
            array(
                   'header'=>'DNI',
                    'value' => '$data->dni',
                    'type' => 'text',
                    'name' => 'dni',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
             array(
                   'header'=>'NOMBRES',
                    'value' => '$data->nombre',
                    'type' => 'text',
                    'name' => 'nombre',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
                array(
                   'header'=>'APELLIDOS',
                    'value' => '$data->apellido',
                    'type' => 'text',
                    'name' => 'apellido',
                    'htmlOptions' => array( 'class' => 'text-center    '),
                ),
            
                array(
                   'header'=>'CELULAR',
                    'value' => '$data->celular',
                    'type' => 'text',
                    'name' => 'celular',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
      
                array(
                   'header'=>'OBSERVACION',
                    'value' => '$data->observacion',
                    'type' => 'text',
                    'name' => 'observacion',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),

                array(
                   'header'=>'DURACION',
                    'filter'=>Duracion::lista(),  
                    'value' => '$data->id_duracion',
                    'type' => 'text',
                    'name' => 'id_duracion',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),

                array(
                   'header'=>'MODALIDAD',
                    'filter'=> Modalidad::lista(),  
                    'value' => 'Modalidad::descripcion($data->id_modalidad)',
                    'type' => 'text',
                    'name' => 'id_modalidad',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
      
                array(
                   'header'=>'NrºPAGOS',
                    'value' => '$data->cuotas_pagadas',
                    'type' => 'text',
                    'name' => 'cuotas_pagadas',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            
            array(
                   'header'=>'SOLES',
                    'value' => '$data->total',
                    'type' => 'text',
                    'name' => 'total',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            array(
                   'header'=>'NrºATRAZOS',
                    'value' => '$data->atrasos',
                    'type' => 'text',
                    'name' => 'atrasos',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            array(
                   'header'=>'CREDITO',
                    'value' => '$data->id_monto',
                    'type' => 'text',
                    'name' => 'id_monto',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            
                array(
                   'header'=>'CUOTA',
                    'value' => '$data->cuota',
                    'type' => 'text',
                    'name' => 'cuota',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            array(
                   'header'=>'PAGAR',
                    'value' => '$data->pagar',
                    'type' => 'text',
                    'name' => 'pagar',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            
            array(
                   'header'=>'DEBE',
                    'value' => '$data->debe',
                    'type' => 'text',
                    'name' => 'debe',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            
            
              array(
                   'header'=>'FECHA',
                    'value' => '$data->cuotas_pagadas=="0"?null:Utility::fecha($data->fecha_ultimo_pago)',
                    'type' => 'text',
                    'name' => 'fecha_ultimo_pago',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            
                array(
                   'header'=>'SALDO',
                    'value' => '$data->monto_ultimo_pago',
                    'type' => 'text',
                    'name' => 'monto_ultimo_pago',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            

       
            
            
            array(
                   'header'=>'DIRECCION',
                    'value' => '$data->direccion',
                    'type' => 'text',
                    'name' => 'direccion',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            
            array(
                   'header'=>'MZ',
                    'value' => '$data->mz',
                    'type' => 'text',
                    'name' => 'mz',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
            array(
                   'header'=>'LT',
                    'value' => '$data->lt',
                    'type' => 'text',
                    'name' => 'lt',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
       
                array(
                   'header'=>'Num.Renovacion',
                    'value' => '$data->num',
                    'type' => 'text',
                    'name' => 'num',
                    'htmlOptions' => array( 'class' => 'text-center'),
                ),
                
            
		
	),

)); 

?>
</div>




         
    
