<?php


$total_porcenaje=0;
$pocentaje_dia=Cliente::porcentaje($pago_aldia,$aldia_capital);
$porcentaje_atraso=Cliente::porcentaje($pago_atraso,$atraso_capital);
$porcentaje_vencido=Cliente::porcentaje($pago_vencido,$vencido_capital);
$porcentaje_mora=Cliente::porcentaje($pago_mora,$moras_capital);
$porcentaje_cancelados=Cliente::porcentaje($pago_cancelados,$cancelados_capital);

$total_porcenaje=$pocentaje_dia+$porcentaje_atraso+$porcentaje_vencido+$porcentaje_mora+$porcentaje_cancelados;
$total2=$aldia_capital+$atraso_capital+$vencido_capital+$cancelados_capital;
$total4=$pago_aldia+$pago_atraso+$pago_vencido+$pago_mora+$pago_cancelados;

$azul='#85C1E9';
$amarillo='#FFF59D';
$rojo='#EC7063';
$morado='#E1BEE7';
$verde='#76D7C4';
$bg_cancelados='#EC7063';
?>




    <div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'cobro-form',
	'enableClientValidation' => true,
        'htmlOptions' => array(
                'class' => 'form-horizontal'
            ),
      'clientOptions'=>array(
        'validateOnSubmit'=>true,
  ),
)); ?>
    
    <div class="row">
          <div class="col-12 mb-3">
            <div class="row ">
                
                <div class="col-12 col-sm-12 col-md-7 col-lg-7 col-xl-7  ">
                    <p class="note">Los campos con <span class="required ">*</span> son obligatorios.</p>
                </div>
     
                
            </div>
        </div>
    </div>  


    
    <div class="row justify-content-center">
                <div class="col-12  col-12 col-sm-12 col-md-4">
                        <div class="form-group">
                           <?php echo $form->labelEx($model,'id_gestor', array('class' => 'col-12 text-uppercase mdi mdi-face-outline mdi-18px')); ?>
                           <div class="col-12">
                           <?php echo $form->dropdownList($model,'id_gestor', Gestor::lista(),  array('class'=>'form-control form-control-line text-uppercase',
                               'prompt' => 'TODOS LOS GESTORES')); ?> 
                           <?php echo $form->error($model,'id_gestor'); ?>
                          </div>
                        </div>
               </div>
        
      
        
             <div class="col-12  col-12 col-sm-12 col-md-4">
                   <div class="form-group ">
                     <?php echo $form->labelEx($model, 'fecha_desde', array('class' => 'col-12 mdi mdi-calendar-blank mdi-18px')); ?>
                     <div class="col-12">

                        <?php
                        $this->widget('ext.YiiDateTimePicker.jqueryDateTime', array(
                            'model' => $model,
                            'attribute' => 'fecha_desde',
                            'options' => array(
                                'lang'=>'es',
                                'timepicker'=>false,
                                'format'=>'Y-m-d'),
                            'htmlOptions' => array(
                                'class' => 'form-control form-control-line',
                                'placeholder'=>"aaaa-mm-dd",
                                'autocomplete'=>"off"
                                
                                ),
                                
                        ));
                        
                        ?>
                  <?php echo $form->error($model,'fecha_desde'); ?>
                     </div>
                 </div>
                    </div>
            
                 <div class="col-12  col-12 col-sm-12 col-md-4">
                             <div class="form-group ">
                     <?php echo $form->labelEx($model, 'fecha_hasta', array('class' => 'col-md-12 mdi mdi-calendar-blank mdi-18px')); ?>
                     <div class="col-12">

                        <?php
                        $this->widget('ext.YiiDateTimePicker.jqueryDateTime', array(
                            'model' => $model,
                            'attribute' => 'fecha_hasta',
                            'options' => array(
                                'lang'=>'es',
                                'timepicker'=>false,
                                'format'=>'Y-m-d'),
                                'htmlOptions' => array(
                                'class' => 'form-control form-control-line',
                                'placeholder'=>"aaaa-mm-dd",
                                'autocomplete'=>"off"   
                             ),
                                
                        ));
                        
                        ?>
                 <?php echo $form->error($model,'fecha_hasta'); ?>
                     </div>
                 </div>
                    </div>
       
        
        
    </div>
    

        
        <div class="row justify-content-center">
            
          
             <div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3 ">
            <div class="form-group">
                  <?php echo CHtml::submitButton('CONSULTAR ',array('class'=>'btn btn-block btn-success fa fa-search  font-weight-medium mt-3')); ?>
           </div>
        </div> 
            
            
            
            
            
        </div>
        
        
<?php $this->endWidget(); ?>
    
      <?php echo $form->errorSummary($model); ?>
    </div>
    

            
            <br>
            
            <div class="row justify-content-center mt-4">
                <div class="col-12 col-sm-12 col-md-5  text-center p-1" style="background-color: #4268F1">
                    <h5>CANTIDAD</h5>
                </div>
                
                <div class="col-12 col-sm-12 col-md-5 text-center offset-1 p-1"style="background-color: #4268F1">
                    <h5>SOLES</h5>
                </div>
                
            </div>
            
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2  text-center p-1" style="background-color:<?php echo $azul;  ?> ;">
                    <h5>AL DIA</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-3  text-center p-1" style="background-color:<?php echo $azul;  ?>;">
                    <h5><?php echo $aldia; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2  text-center offset-1 p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5>AL DIA</h5>
                </div>
                <div class="col-12 col-sm-12   col-md-3 text-center p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5><?php echo number_format($aldia_capital, 2, ',', '.')  ; ?></h5>
                </div>
                
            </div>
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2   text-center p-1"   style="background-color: <?php echo $amarillo;  ?>;">
                    <h5>ATRASOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-3 text-center p-1" style="background-color: <?php echo $amarillo;  ?>;">
                    <h5><?php echo $atraso; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2   text-center offset-1 p-1" style="background-color: <?php echo $amarillo;  ?>;">
                    <h5>ATRASOS</h5>
                </div>
                <div class="col-12 col-sm-12   col-md-3 text-center p-1"style="background-color: <?php echo $amarillo;  ?>;" >
                    <h5><?php echo number_format($atraso_capital, 2, ',', '.'); ?></h5>
                </div>
                
            </div>
             <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2  text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5>VENCIDOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-3 text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5><?php echo $vencido; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2  text-center offset-1 p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5>VENCIDOS</h5>
                </div>
                <div class="col-12 col-sm-12   col-md-3  text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5><?php echo number_format($vencido_capital, 2, ',', '.');  ?></h5>
                </div>
                
            </div>
            
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2  text-center p-1" style="background-color:  <?php echo $morado;  ?>;">
                    <h5>MORAS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-3 text-center p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5><?php echo $moras; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2  text-center offset-1 p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5>MORAS</h5>
                </div>
                <div class="col-12 col-sm-12   col-md-3 text-center p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5><?php echo number_format($moras_capital, 2, ',', '.'); ?></h5>
                </div>
                
            </div>
             <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2 text-center p-1" style="background-color:  <?php echo $bg_cancelados;  ?>;">
                    <h5>CANCELADOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-3 text-center p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5><?php echo $cancelados; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 text-center offset-1 p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5>CANCELADOS</h5>
                </div>
                <div class="col-12 col-sm-12   col-md-3  text-center p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5><?php echo number_format($cancelados_capital, 2, ',', '.'); ?></h5>
                </div>
                
            </div>
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2  text-center p-1" style="background-color: <?php echo $verde;  ?>;">
                    <h5>TOTAL</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-3 text-center p-1"style="background-color: <?php echo $verde;  ?>">
                    <h5><?php echo $total; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2  text-center offset-1 p-1"style="background-color: <?php echo $verde;  ?>;">
                    <h5>TOTAL</h5>
                </div>
                <div class="col-12 col-sm-12   col-md-3  text-center p-1"style="background-color: <?php echo $verde;  ?>;">
                    <h5><?php echo  number_format($total2, 2, ',', '.')  ; ?></h5>
                </div>
                
            </div>
            
            
            
            
            
            
             <div class="row justify-content-center mt-4">
                <div class="col-12 col-sm-12 col-md-9 col-lg-9 col-xl-9 text-center p-1" style="background-color: #4268F1">
                    <h4>MOVIMIENTO GENERAL</h4>
                </div>
            </div>
            
            
            
             <div class="row justify-content-center mt-4">
                <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 text-center p-1" style="background-color: #4268F1">
                    <h5>CANTIDAD</h5>
                </div>
                
                <div class="col-12 col-sm-12 col-md-2 text-center offset-3 p-1"style="background-color: #4268F1">
                    <h5>CUOTA</h5>
                </div>
                 
                <div class="col-12 col-sm-12 col-md-2 text-center p-1"style="background-color: #4268F1">
                    <h5>MORA</h5>
                </div> 
                 
                 <div class="col-12 col-sm-12 col-md-1 col-lg-1 col-xl-1 text-center  p-1"style="background-color: #4268F1">
                    <h5>%</h5>
                </div>
            </div>
            
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2  text-center p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5>AL DIA</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5><?php echo $cantidad_pago_aldia; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center offset-1 p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5>AL DIA</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5><?php echo number_format($pago_aldia, 2, ',', '.'); ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5><?php echo number_format($pago_aldia_mora, 2, ',', '.'); ?></h5>
                </div>
                
                
                <div class="col-12 col-sm-12  col-md-1 col-lg-1 col-xl-1  text-center p-1" style="background-color: <?php echo $azul;  ?>;">
                    <h5><?php  echo $pocentaje_dia;    ?>%</h5>
                </div>
                
            </div>
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2  text-center p-1"   style="background-color: <?php echo $amarillo;  ?>;">
                    <h5>ATRASOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center p-1" style="background-color: <?php echo $amarillo;  ?>;">
                    <h5><?php echo $cantidad_pago_atraso; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center offset-1 p-1" style="background-color: <?php echo $amarillo;  ?>;">
                    <h5>ATRASOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $amarillo;  ?>;" >
                    <h5><?php echo number_format($pago_atraso, 2, ',', '.'); ?></h5>
                </div>
                
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $amarillo;  ?>;" >
                    <h5><?php echo number_format($pago_atraso_mora, 2, ',', '.'); ?></h5>
                </div>
                 <div class="col-12 col-sm-12  col-md-1 col-lg-1 col-xl-1  text-center p-1"style="background-color: <?php echo $amarillo;  ?>;" >
                    <h5><?=  $porcentaje_atraso;    ?>%</h5>
                </div>
            </div>
             <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5>VENCIDOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5><?php echo $cantidad_pago_vencido; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center offset-1 p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5>VENCIDOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5><?php echo number_format($pago_vencido, 2, ',', '.'); ?></h5>
                </div>
                 <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5><?php echo number_format($pago_vencido_mora, 2, ',', '.'); ?></h5>
                </div>
                 
                <div class="col-12 col-sm-12  col-md-1 col-lg-1 col-xl-1  text-center p-1"style="background-color: <?php echo $rojo;  ?>;">
                    <h5><?=  $porcentaje_vencido;    ?>%</h5>
                </div>
            </div>
            
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2  text-center p-1" style="background-color: <?php echo $morado;  ?>;">
                    <h5>MORAS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5><?php echo $cantidad_pago_mora; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center offset-1 p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5>MORAS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5><?php echo  number_format($pago_mora, 2, ',', '.');  ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5><?php echo  number_format($pago_mora_mora, 2, ',', '.');  ?></h5>
                </div>
                
                <div class="col-12 col-sm-12  col-md-1 col-lg-1 col-xl-1  text-center p-1"style="background-color: <?php echo $morado;  ?>;">
                    <h5><?=  $porcentaje_mora;    ?>%</h5>
                </div>
            </div>
             <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2  text-center p-1" style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5>CANCELADOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5><?php echo $cantidad_pago_cancelados; ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2 text-center offset-1 p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5>CANCELADOS</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5><?php echo  number_format($pago_cancelados, 2, ',', '.');  ?></h5>
                </div>
                 <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5><?php echo  number_format($pago_cancelados_mora, 2, ',', '.');  ?></h5>
                </div>
                 
                <div class="col-12 col-sm-12  col-md-1 col-lg-1 col-xl-1  text-center p-1"style="background-color: <?php echo $bg_cancelados;  ?>;">
                    <h5><?=  $porcentaje_cancelados;    ?>%</h5>
                </div>
            </div>
            
            
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-2 col-lg-2 col-xl-2  text-center p-1" style="background-color: <?php echo $verde;  ?>;">
                    <h5>TOTAL</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $verde;  ?>;">
                    <h5><?php echo  $total3;    ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center offset-1 p-1"style="background-color: <?php echo $verde;  ?>;">
                    <h5>TOTAL</h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $verde;  ?>;">
                    <h5><?php echo number_format($total4, 2, ',', '.');    ?></h5>
                </div>
                <div class="col-12 col-sm-12  col-md-2 col-lg-2 col-xl-2  text-center p-1"style="background-color: <?php echo $verde;  ?>;">
                    <h5><?php echo number_format($total4_mora, 2, ',', '.');    ?></h5>
                </div>
                
                
                <div class="col-12 col-sm-12  col-md-1 col-lg-1 col-xl-1  text-center p-1"style="background-color: <?php echo $verde;  ?>;">
                    <h5><?=  $total_porcenaje;    ?>%</h5>
                </div>
            </div>
 
            <br><br>
                    <div class="row justify-content-center mt-4">
                        <div class="col-12  text-center">
                            <b>MOVIMIENTO GENERAL</b>
                        </div>
                     </div>    
                        
            <div class="row justify-content-center ">
                <div class="col-12 text-center" style="color:#000020;">
                                
         <?php 
        $this->widget(
            'chartjs.widgets.ChPie', 
            array(
                'width' => 600,
                'height' => 350,
                'htmlOptions' => array(),
                'drawLabels' => true,
                'datasets' => array(
                    array(
                        "value" => $pocentaje_dia,
                        "color" => "#5DADE2",
                        "label" => 'AL DIA '.$pocentaje_dia.'%'
                    ),
                    array(
                        "value" => $porcentaje_atraso,
                        "color" => "#FFFF00",
                        "label" => 'ATRASOS '.$porcentaje_atraso.'%'
                    ),
                    array(
                        "value" => $porcentaje_vencido,
                        "color" => "#FF0000",
                        "label" => 'VENCIDOS '.$porcentaje_vencido.'%' 
                    ),
                    array(
                        "value" => $porcentaje_mora,
                        "color" => "#BB8FCE",
                        "label" => 'MORA '.$porcentaje_mora.'%'
                    ),
                    
                    array(
                        "value" => $porcentaje_cancelados,
                        "color" => "#BB8FCE",
                        "label" => 'CANCELADOS '.$porcentaje_cancelados.'%'
                    ),
                    
                    array(
                        "value" => $total_porcenaje,
                        "color" => "#33CC33",
                        "label" => 'TOTAL '.$total_porcenaje.'%'
                    )
                ),
                'options' => array()
            )
        ); 
    ?>        
                
                        </div>
            </div> 
                        
            <br><br>
           
            <div class="row justify-content-center mt-4 " >
                        <div class="col-12 col-sm-12 col-md-8 col-lg-8 col-xl-8  text-center">
                            <b>CARTERA GENERAL</b>
                        </div>
                     </div> 
            
  
      <div class="row justify-content-center ">
                <div class="col-12 text-center" style="color:#000020;">
                                
         <?php 
        $this->widget(
            'chartjs.widgets.ChPie', 
            array(
                'width' => 600,
                'height' => 350,
                'htmlOptions' => array(),
                'drawLabels' => true,
                'datasets' => array(
                    array(
                        "value" => $total_porcenaje,
                        "color" => "#5DADE2",
                        "label" => 'COBRADO '.$total_porcenaje.'%'
                    ),
                    array(
                        "value" => 100-$total_porcenaje,
                        "color" => "#EC150A",
                        "label" => 'NO COBRADO '.(100-$total_porcenaje).'%'
                    ),
              
                ),
                'options' => array()
            )
        ); 
    ?>        
                
                        </div>
            </div>
            
            
           