<?php
/* @var $this RendicionController */
/* @var $model Rendicion */
/* @var $form CActiveForm */
?>

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'rendicion-form',
		'enableClientValidation' => true,
        'htmlOptions' => array(
                'class' => 'form-horizontal','enctype'=>'multipart/form-data'
        ),
        'clientOptions'=>array(
        'validateOnSubmit'=>true,
  ),
)); ?>

	<p class="sub-title">Los campos con <code class="highlighter-rouge">*</code> son obligatorios.</p>
        
        
        <div class="row">
             <div class="col-12  col-12 col-sm-12 col-md-4 col-lg-4 col-xl-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' => 'SELECCIONE')); ?> 
                           <?php echo $form->error($model,'id_gestor'); ?>
                          </div>
                        </div>
               </div>
 
            <div class="col-12  col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4">
                        <div class="form-group">
                           <?php echo $form->labelEx($model,'fecha', array('class' => 'col-12 text-uppercase')); ?>
                           <div class="col-12">
                           <?php
                        $this->widget('ext.YiiDateTimePicker.jqueryDateTime', array(
                            'model' => $model,
                            'attribute' => 'fecha',
                            'options' => array(
                                'lang'=>'es',
                                'timepicker'=>false,
                                'format'=>'d-m-Y',
                                ),
                            'htmlOptions' => array(
                                'class' => 'form-control',
                                'placeholder'=>"dd-mm-aaaa",
                                'autocomplete'=>"off"
                                ),
                        ));
                        ?>
                           <?php echo $form->error($model,'fecha'); ?>
                          </div>
                        </div>
               </div>
        </div>
        
       
        <div class="row">
     
             <div class="col-12  col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'saldo_anterior', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'saldo_anterior',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control numeros', 'autocomplete'=>"off","onChange"=>'calcular()' ,
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'saldo_anterior'); ?>
                      </div>
                    </div>
            </div>
              <div class="col-12  col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'transferencias', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'transferencias',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control numeros', 'autocomplete'=>"off","onChange"=>'calcular()' ,
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'transferencias'); ?>
                      </div>
                    </div>
            </div>
            
             <div class="col-12  col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'saldo_capital', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'saldo_capital',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control ', 'autocomplete'=>"off",'readonly'=>"true" ,"onChange"=>'calcular()' ,
                            "onChange"=>'calcular()' ,
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'saldo_capital'); ?>
                      </div>
                    </div>
            </div>
            
        </div>

	<div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo1', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo1',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control  bg-warning text-uppercase', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo1'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto1', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto1',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control numeros', "onChange"=>'calcular()' ,
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto1'); ?>
                      </div>
                    </div>
            </div>
	</div>


	<div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo2', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo2',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control  bg-warning text-uppercase', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo2'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto2', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto2',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()' ,
                               'class' => 'form-control numeros ', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto2'); ?>
                      </div>
                    </div>
            </div>
	</div>

        
        <div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo3', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo3',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control  bg-warning text-uppercase', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo3'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto3', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto3',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()' ,
                               'class' => 'form-control numeros', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto3'); ?>
                      </div>
                    </div>
            </div>
	</div>
        
        <div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo4', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo4',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control    text-uppercase', 'autocomplete'=>"off",
                               'style'=>'background: #FFFF00;',
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo4'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto4', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto4',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()' ,
                               'class' => 'form-control numeros', 'autocomplete'=>"off",'style'=>'background: #FFFF00;','readonly'=>"true",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto4'); ?>
                      </div>
                    </div>
            </div>
	</div>
        
        <div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo5', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo5',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control bg-warning text-uppercase', 'autocomplete'=>"off",
                               "onChange"=>'calcular()' ,
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo5'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto5', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto5',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()',
                               'class' => 'form-control numeros', 
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto5'); ?>
                      </div>
                    </div>
            </div>
	</div>
        
        
        
                <div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo6', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo6',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control bg-warning text-uppercase', 
                            'autocomplete'=>"off", 
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo6'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto6', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto6',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()',
                               'class' => 'form-control numeros',
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto6'); ?>
                      </div>
                    </div>
            </div>
	</div>
        
                <div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo7', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo7',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control bg-warning text-uppercase', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo7'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto7', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto7',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()',
                               'class' => 'form-control numeros', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto7'); ?>
                      </div>
                    </div>
            </div>
	</div>
        
        
        
        
                <div class="row">
            
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'campo8', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'campo8',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control bg-warning text-uppercase', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'campo8'); ?>
                      </div>
                    </div>
            </div>
            <div class="col-12 col-sm-12 col-md-6  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'monto8', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'monto8',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()',
                               'class' => 'form-control numeros', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'monto8'); ?>
                      </div>
                    </div>
            </div>
	</div>
        
        
        
	<div class="row">
            
             <div class="col-12 col-sm-12 col-md-3  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'sub_total', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'sub_total',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control', 'autocomplete'=>"off",'readonly'=>"true" ,"onChange"=>'calcular()',
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'sub_total'); ?>
                      </div>
                    </div>
            </div>
            
            
              <div class="col-12 col-sm-12 col-md-3  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'efectivo', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'efectivo',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()',
                               'class' => 'form-control numeros', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'efectivo'); ?>
                      </div>
                    </div>
            </div>
            
              <div class="col-12 col-sm-12 col-md-3  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'deposito', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'deposito',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()',
                               'class' => 'form-control numeros', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'deposito'); ?>
                      </div>
                    </div>
            </div>
                <div class="col-12 col-sm-12 col-md-3  ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'total', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'total',array('size'=>60,'maxlength'=>100,
                               'class' => 'form-control', 'autocomplete'=>"off",'readonly'=>"true" ,"onChange"=>'calcular()',
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'total'); ?>
                      </div>
                    </div>
            </div>
	</div>
        
        <div class="row justify-content-center">
            <div class="col-12 ">
                    <div class="form-group">
                       <?php echo $form->labelEx($model,'observacion', array('class' => 'col-12  text-uppercase')); ?>
                       <div class="col-12">
                        <?php echo $form->textField($model,'observacion',array('size'=>60,'maxlength'=>100,"onChange"=>'calcular()',
                               'class' => 'form-control', 'autocomplete'=>"off",
                               'placeholder'=>"")); ?>
                        <?php echo $form->error($model,'observacion'); ?>
                      </div>
                    </div>
            </div>
        </div>
         
        
        
        
	    <div class="row justify-content-center m-t-30">
      
                    <div class="col-12 col-sm-12 col-md-6 col-ld-6 col-xl-6 ">
                          
                                <div class="form-group ">
                               <?php echo $form->labelEx($model, 'foto', array('class' => 'col-md-12 mdi mdi-image-outline menu-icon mdi-18px text-uppercase')); ?>
                               <div class="col-12">  
                                  <?php
                                    echo CHtml::activeFileField($model, 'foto'); ?>
                                   <?php echo $form->error($model, 'foto'); ?>
                               </div>
                           </div>
                         
                    </div>
     
                    <div class="col-12 col-sm-12 col-md-6 col-ld-6 col-xl-6 text-right ">
                        <img src="<?php echo Yii::app()->request->baseUrl.'/upload/'.$model->foto;  ?>" id="imagen2"  class="img-fluid" style="max-width: 150px;margin-right: 15px;">
                    </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="submit" 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>

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

</div>


<script type="text/javascript">  

function calcular() {
 
  var suma=0;
  var saldo_anterior=0;
  var transferencia=0;

  if($('#Rendicion_saldo_anterior').val()>0){
      saldo_anterior = $('#Rendicion_saldo_anterior').val(); 
  }
  
  if($('#Rendicion_transferencias').val()){
      transferencia = $('#Rendicion_transferencias').val();
  }
 
  suma =  parseFloat(transferencia) +  parseFloat(saldo_anterior);
  
  
  $('#Rendicion_saldo_capital').val(suma);
  
  var suma2 = 0;
  var suma3=0;
  var saldo_capital=0;
  var monto1=0;
  var monto2=0;
  var monto3=0;
  var monto4=0;
  var monto5=0;
  var monto6=0;
  var monto7=0;
  var monto8=0;
  
  if($('#Rendicion_saldo_capital').val()>0){
    saldo_capital = $('#Rendicion_saldo_capital').val();  
  }
  
  if($('#Rendicion_monto1').val()>0){
    monto1 = $('#Rendicion_monto1').val();  
  }
  
  if($('#Rendicion_monto2').val()>0){
    monto2 = $('#Rendicion_monto2').val();  
  }

  if($('#Rendicion_monto3').val()>0){
    monto3 = $('#Rendicion_monto3').val();  
  }

    monto4 = parseFloat(saldo_capital) + (parseFloat(monto1)+parseFloat(monto2)+parseFloat(monto3));  
  
  $('#Rendicion_monto4').val(monto4);
  
  
  if($('#Rendicion_monto5').val()>0){
    monto5 = $('#Rendicion_monto5').val();  
  }
   if($('#Rendicion_monto6').val()>0){
    monto6 = $('#Rendicion_monto6').val();  
  }
   if($('#Rendicion_monto7').val()>0){
    monto7 = $('#Rendicion_monto7').val();  
  }
   if($('#Rendicion_monto8').val()>0){
    monto8 = $('#Rendicion_monto8').val();  
  }
 
  var transferencia = $('#Rendicion_transferencias').val();
  
  suma2 = parseFloat(monto5)+ parseFloat(monto6)+ parseFloat(monto7)+ parseFloat(monto8);

  var t=0;
  
  t=parseFloat(monto4) -suma2;
  
  $('#Rendicion_sub_total').val(t);
  
  var suma3 = 0;
  var sub_total=0;
  var efectivo=0;
  var deposito=0;

  if($('#Rendicion_sub_total').val()>0){
    sub_total = $('#Rendicion_sub_total').val();  
  }
  
  if($('#Rendicion_efectivo').val()>0){
    efectivo = $('#Rendicion_efectivo').val();  
  }
  
  if($('#Rendicion_deposito').val()>0){
    deposito = $('#Rendicion_deposito').val();  
  }

  suma3=parseFloat(efectivo)+parseFloat(deposito);

  
  $('#Rendicion_total').val(suma3);
  
  
}


   
   
   
  function readImages (input) {
    if (input.files && input.files[0]) {
      var reader = new FileReader();
      reader.onload = function (e) {
          $('#imagen2').attr('src', e.target.result); 
      }
      reader.readAsDataURL(input.files[0]);
    }
  }
  
  
   
 $("#Rendicion_foto").change(function () {
    readImages(this);
  });
   
   




</script> 