<?php
/* @var $this PagosController */
/* @var $model Pagos */
/* @var $form CActiveForm */
?>



<div class="form">
  <?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'pagos-form',
        'htmlOptions'=>array(
           'class' => 'form-horizontal','enctype'=>'multipart/form-data'
            
            ),
        'enableClientValidation' => true,
        'clientOptions'=>array(
        'validateOnSubmit'=>true,
  ),
      
)); ?>
    
	<div class="row">
            <div class="col-12">
                <p class="note">Los campos con <span class="required">*</span> son obligatorios.</p>
            </div> 
        </div>
    
    
    
    
        <div class="row">
            <div class="col-12 col-sm-12 col-md-4">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'dni', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'dni',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control form-control-line text-uppercase', 'autocomplete'=>"off",
                               'placeholder'=>"",'readonly'=>'true'
                            )); ?>
                        <?php echo $form->error($model,'dni'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-3 col-lg-4">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'nombre', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'nombre',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control form-control-line text-uppercase', 'readonly'=>'true','autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'nombre'); ?>
                      </div>
                    </div>
             </div>
               <div class="col-12 col-sm-12 col-md-4">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'apellido', array('class' => 'col-12 mdi mdi-mail mdi-18px text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'apellido',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control form-control-line text-uppercase', 'readonly'=>'true','autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'apellido'); ?>
                      </div>
                    </div>
          </div>
 
            
        </div>
    
    
  
    
    
    
            
    <div class="row justify-content-center">
               
   
        
              
        
     
                <div class="col-12 col-sm-12 col-md-4">
                        <div class="form-group">
                          <?php echo $form->labelEx($model,'cuota', array('class' => 'col-12 mdi mdi-mail mdi-18px')); ?>
                           <div class="col-12">
                           <?php echo $form->textField($model,'cuota',array('size'=>60,'maxlength'=>100,
                                   'class' => 'form-control form-control-line text-uppercase', 
                                   'placeholder'=>"")); ?>
                            <?php echo $form->error($model,'cuota'); ?>
                          </div>
                        </div>
                </div>
                
                
           <div class="col-12 col-sm-12 col-md-4">
                        <div class="form-group">
                          <?php echo $form->labelEx($model,'mora', array('class' => 'col-12 mdi mdi-mail mdi-18px','style'=>'font-size: 18px;color: red;' )); ?>
                           <div class="col-12">
                           <?php echo $form->textField($model,'mora',array('size'=>60,'maxlength'=>100,
                                   'class' => 'form-control form-control-line text-uppercase', 
                                   'placeholder'=>"")); ?>
                            <?php echo $form->error($model,'mora'); ?>
                          </div>
                        </div>
                </div>
    
    </div>
   

    
        <div class="row justify-content-end">
             
         
         <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 mb-2">
             <button type="reset" class="btn btn-large btn-block btn-default  ">
                         <i class="fa  fa-eraser fa-lg   "></i>     LIMPIAR FORMULARIO</button>
                   </div>  
            
            <div class="col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 mb-2">
                <button type="button" id="btn-confirm" class="btn btn-large btn-block btn-danger  ">
                            <i class="fa fa-floppy-o fa-lg   "></i>    <?php echo $model->isNewRecord ? "GUARDAR" : "MODIFICAR"; ?></button>
                   </div> 
         
        </div>
               
            <div class="row justify-content-center">
                <div class="col-12 col-sm-12 col-md-8 col-lg-8 col-xl-8">
                <?php echo $form->errorSummary($model); ?>
                </div>
            </div>
        <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="mi-modal" >
  <div class="modal-dialog modal-sm" >
    <div class="modal-content" style="background-color: #E63914; color: #FFF;  ">
        <div class="modal-header text-center" style="border-bottom: 1px solid #E63914;">
          <h4 class="modal-title" id="myModalLabel " style="font-size: 30px;"><br>¿CONFORME? <br><br> </h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
        <div class="modal-footer" style="margin-top: -30px;">
            <button type="button" class="btn btn-default" id="modal-btn-si" style="font-size: 25px;">Si </button>
            <button type="button" class="btn btn-primary" id="modal-btn-no" style="font-size: 25px;">No</button>
        </div>
      </div>
    </div>
  </div>



<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="mi-modal2">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">DNI INGRESADO NO TIENE PRESTAMO REGISTRADO EN EL SISTEMA </h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
      </div>
    </div>
  </div>

<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="mi-modal3">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">VISTA PREVIA</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

      </div>
        <div class="modal-body" style="margin-top: -30px;">
         <div class="row">
             
              <div class="col-12 text-black" id="dni">
                
            </div>
              <div class="col-12 text-black" id="nombre">
                
            </div>
              <div class="col-12 text-black" id="apellido">
                
            </div>
            <div class="col-12 text-black" id="gestor">
                
            </div>
             
            <div class="col-12 text-black" id="modalidad">
                
            </div>
            <div class="col-12 text-black" id="banco">
                
            </div>
             <div class="col-12 text-black" id="num_operacion">
                
            </div>
             <div class="col-12 text-black" id="hora_operacion">
                
            </div>
             <div class="col-12 text-black" id="fecha_operacion">
                
            </div>
            
        </div>
            
        </div>
        
        
      </div>
    </div>
  </div>

<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="mi-modal4">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">ERROR!!! </h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
        <div class="modal-footer" id="error" style="margin-top: -30px;">
            
        </div>        
        
      </div>
    </div>
  </div>
    
<?php $this->endWidget(); ?>
</div><!-- form -->


<script type="application/javascript">

$(document).ready(function() {
    $('#Pagos_hora').mask('00:00:00');
 }); 


</script>
<script type="application/javascript">
    
 var id_modalidad_pago= $('#Pagos_id_modalidad_pago').val();

 var modalConfirm = function(callback){
  $("#btn-confirm").on("click", function(){
    $("#mi-modal").modal('show');
  });
  $("#modal-btn-si").on("click", function(){
    callback(true);
    $("#mi-modal").modal('hide');
  });
  $("#modal-btn-no").on("click", function(){
    callback(false);
    $("#mi-modal").modal('hide');
  });
};




modalConfirm(function(confirm){
  if(confirm){
   var cuota= $('#Pagos_cuota').val();
   var mora= $('#Pagos_mora').val();
   var id_modalidad_pago=$('#Pagos_id_modalidad_pago').val(); 
   var banco=    $('#Pagos_id_banco').val();  
   var operacion=$('#Pagos_num_operacion').val();  
   var fecha=    $('#Pagos_fecha').val();  
   var hora=     $('#Pagos_hora').val();
   var id_modalidad_pago=  $('#Pagos_id_modalidad_pago').val();
   
  
       if((cuota == "" || cuota.length == 0) && (mora == "" || mora.length == 0) ){
             $("#error").html('<div class="text-danger col-12">Debe ingresar un monto cuota o mora válido.</div> '); 
             $("#mi-modal4").modal('show');
        }else{
           if((id_modalidad_pago==2)&& ((banco == "" || banco.length == 0) || 
                   (operacion == "" || operacion.length == 0) || 
                   (fecha == "" || fecha.length == 0) ||  (hora == "" || hora.length == 0)    )   ){
               $("#error").html('<div class="text-danger col-12">Su modalidad de pago es <b>BAUCHER</b>. Debe seleccionar el banco, la fecha, hora e ingresar el número de operación .</div> ');
               $("#mi-modal4").modal('show');
            }else{
               
               $("#pagos-form").submit(); 
           }
       }
  }else{

    return false;
  }
});
  
$('#buscar').click(function(){
$('.search-form').toggle();
});



$(document).ready(function() {
  $('#Pagos_num_operacion').mask('99999999999999', {translation: { 'A':{pattern: /[1-9]/}}, clearIfNotMatch: true});
  $('#Pagos_cuota').mask('A99999999999999', {translation: { 'A':{pattern: /[1-9]/}}, clearIfNotMatch: true});
  $('#Pagos_mora').mask('A99999999999999', {translation: { 'A':{pattern: /[1-9]/}}, clearIfNotMatch: true});
  $('#Pagos_hora').mask('00:00');
 }); 

$('#Pagos_id_modalidad_pago').on('change',function(){   
  var id_modalidad_pago=$(this).val();  

  //recibos
  if(id_modalidad_pago==1){
     $('#Pagos_id_banco').attr('disabled',true);  
     $('#Pagos_id_banco').val('');
     $('#Pagos_num_operacion').attr('readonly',true);  
     $('#Pagos_num_operacion').val('');
     
     $('#Pagos_fecha').attr('disabled',true);  
     $('#Pagos_fecha').val('');
     
     $('#Pagos_hora').val('');
     $('#Pagos_hora').attr('readonly',true); 
     $('#Pagos_imagen').val('');
     $('#Pagos_imagen').attr('readonly',true); 
  }else{
     $('#Pagos_id_banco').attr('disabled',false); 
     $('#Pagos_num_operacion').attr('readonly',false); 
     
     $('#Pagos_fecha').attr('disabled',false);
     
     $('#Pagos_hora').attr('readonly',false);
     $('#Pagos_imagen').attr('readonly',false);
  }  
});
</script>


