<?php if(!class_exists('raintpl')){exit;}?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es" >
<head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">
   
   <title><?php echo $fsc->page->title;?> &lsaquo; <?php echo $fsc->empresa->nombre;?></title>
   <meta name="description" content="Software de facturación y contabilidad para pymes. Es software bajo licencia GNU/AGPL." />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <link rel="shortcut icon" href="view/img/favicon.ico" />
   <link rel="stylesheet" href="<?php echo $fsc->user->css;?>" />
   <link rel="stylesheet" href="view/css/datepicker.css" />
   <link rel="stylesheet" href="view/css/custom.css" />
   <script
  src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script>
   <!--<script type="text/javascript" src="view/js/jquery-2.1.1.min.js"></script>-->
  <!-- <script type="text/javascript" src="view/js/bootstrap.min.js"></script>
   <script type="text/javascript" src="view/js/bootstrap-datepicker.js" charset="UTF-8"></script>
   <script type="text/javascript" src="view/js/jquery.autocomplete.min.js"></script>
   <script type="text/javascript" src="view/js/base.js"></script>
   <script src="/functions.js"></script>-->

 
<script type="text/javascript">
/*  $(document).ready(function(){
    //$('#lista1').val(1);
//    alert("hola 1 " + $('#tiporeten').val() );
    recargarLista();
//alert("hola 1 " + $('#tiporeten').val() );
    $("#tiporeten").change(function(){
      alert("hola");
      recargarLista();
    });
  })*/
</script> 

<script type="text/javascript">
/*  
     // alert("hola " + $('#tiporeten').val() );
    // $('#porcreten').val(4);
    $.ajax({
      type:"POST",
      //url:'plugins/retenciones/controller/cretencompra.php',
      url:'<?php echo $fsc->url();?>',
      data:"conceptoret=" + $('#tiporeten').val(''),
      success:function(r){
        $('#selconcepto').html(r);
        }
    });*/
  </script>


<script type="text/javascript">
 /*   
    function listas1(vv){
        alert("funcion listas 1");
        //johnli(); "<?php echo $fsc->url();?>&delete="+id;
        //window.location.href = "<?php echo $fsc->url();?>&johnli="+vv;     // funciona y carga combo dinamicamente
  
        
        var lista = document.getElementById("tiporeten");
        alert(" lista " + document.getElementById("tiporeten").value);
        //var opcion = lista.selectedIndex;        
        $.ajax({
      type:"POST",
      url:'<?php echo $fsc->url();?> &johnli='+vv,
      data:"tiporeten=" + document.getElementById("tiporeten").value,
      success:function(r){
        $('#selconcepto').html(r);
        alert ($('#selconcepto').html(r))
        }
  })
}
*/
// funcion para asignar valor de porcentaje de retencion 
/*function fun_porreten(preten){
var valor = document.getElementById('codigo').value;
//alert("% reten " + "<?php echo $value->porcent;?>" + valor);  
porcreten = valor;
}
*/
</script>   




  
  
<script type="text/javascript">
      function show_precio(precio)
      {
         <?php if( FS_POS_DIVISA=='right' ){ ?>

         return number_format(precio, <?php  echo FS_NF0;?>, '<?php  echo FS_NF1;?>', '<?php  echo FS_NF2;?>')+' <?php echo $fsc->simbolo_divisa();?>';
         <?php }else{ ?>

         return '<?php echo $fsc->simbolo_divisa();?>'+number_format(precio, <?php  echo FS_NF0;?>, '<?php  echo FS_NF1;?>', '<?php  echo FS_NF2;?>');
         <?php } ?>

      }

      function show_numero(numero)
      {
         return number_format(numero, <?php  echo FS_NF0;?>, '<?php  echo FS_NF1;?>', '<?php  echo FS_NF2;?>');
      }
      function delete_retencion(id)
      {
         if( confirm("¿Realmente desea eliminar esta retencion?") )
            window.location.href = "<?php echo $fsc->url();?>&delete="+id;
      }
      function anular_retencion(id)
      {
         if( confirm("¿Realmente desea anular esta retencion?") )
            window.location.href = "<?php echo $fsc->url();?>&anular="+id;
      }      
   </script>
   <?php $loop_var1=$fsc->extensions; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

      <?php if( $value1->type=='head' ){ ?><?php echo $value1->text;?><?php } ?>

   <?php } ?>

</head>
<body>
   <?php if( $fsc->get_errors() ){ ?>

   <div class="alert alert-danger hidden-print">
      <ul><?php $loop_var1=$fsc->get_errors(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?><li><?php echo $value1;?></li><?php } ?></ul>
   </div>
   <?php } ?>

   
   <?php if( $fsc->get_messages() ){ ?>

   <div class="alert alert-success hidden-print">
      <ul><?php $loop_var1=$fsc->get_messages(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?><li><?php echo $value1;?></li><?php } ?></ul>
   </div>
   <?php } ?>

   
   <?php if( $fsc->get_advices() ){ ?>

   <div class="alert alert-info hidden-print">
      <ul><?php $loop_var1=$fsc->get_advices(); $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?><li><?php echo $value1;?></li><?php } ?></ul>
   </div>
   <?php } ?>

   
   <div class="table-responsive">
      <table class="table table-hover">
         <thead>
            <tr>
               <!--<th class="text-left">Documento</th>-->
                <th class="text-center">Doc.Sustento</th>
		            <th class="text-center">Fecha</th>
                <th class="text-center">Tipo/Retención</th>
                <th class="text-center">Concepto</th>                
                <th class="text-center">% Retención</th>
                <th class="text-center">Base</th>
                <th class="text-center">Valor</th>
                <th width="140"></th>
            </tr>
         </thead>

         <?php $loop_var1=$fsc->retenciones; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

         <form class="table-responsive" action="<?php echo $fsc->url();?>" method="post">
            <tr>
               <td>
                 <select type="text"  name="coddocsustento" class="form-control text-right" >
                    <option >COMPRA</option>
                    <option >TARJECREDITO</option>
                    <option >RENDFINANCIE</option>
                    <option >FONDOSFINANC</option>
                    <option value="coddocsustento" selected=""><?php echo $value1->coddocsustento;?></option>
                  </select> 
               </td>

               <td>
                  <!--<input type="hidden" name="idretencion" value="<?php echo $value1->id;?>"/>-->
                 <input type="text" name="fecha" class="form-control datepicker" value="<?php echo $value1->fecha;?>" autocomplete="off"/>
               </td>
			   
               <td>
                  <select type="text"  name="tiporeten" class="form-control text-right" >
                    
                    <option >IVA</option>
                    <option>RENTA</option>
                    
                    <option value="tiporeten" selected=""><?php echo $value1->tiporeten;?></option>
                    
                    </select> 
               </td>

               <td>
             <input type="text" name="codigoret" class="form-control" value="<?php echo $value1->concepto;?>" diasbled= "" autocomplete="off"/>
    <!--            
               <select  name="codigoret"   class="form-control"  disabled="">
                  <?php $loop_var2=$fsc->selconcepto; $counter2=-1; if($loop_var2) foreach( $loop_var2 as $key2 => $value2 ){ $counter2++; ?>

                     <?php if( $value2->codigo==$value2->codigoret ){ ?>

                     <option value="<?php echo $value2->codigo;?>" selected=""><?php echo $value2->concepto;?>---<?php echo $value2->porcent;?></option>
                     <?php }else{ ?>

                     <option value="<?php echo $value2->codigo;?>"><?php echo $value2->codigo;?>*/*<?php echo $value2->codigoret;?><?php echo $value2->concepto;?>---<?php echo $value2->porcent;?></option>
                     <?php } ?>

                  <?php } ?>

               </select> -->
               </td>

               <td>
                  <input type="text" name="porcreten" class="form-control text-right" value="<?php echo $value1->porcreten;?>" autocomplete="off"/>
               </td>
               
               <td>
                  <input type="text" name="basereten" class="form-control text-right" value="<?php echo $value1->basereten;?>" autocomplete="off"/>
               </td>
               <td>
                  <input type="text" name="importe" class="form-control text-right" value="<?php echo $value1->importe;?>" autocomplete="off"/>
               </td>
<!--
               <td>
                  <div class="form-control text-right"><?php echo $fsc->show_precio($value1->importe);?></div>
               </td>
-->
               <td class="text-right">
                  <div class="btn-group">
                     <?php if( $value1->estado == 'ENVIADO' ){ ?>

                     <a class="btn btn-sm btn-warning" title="Anular" onclick="anular_retencion('<?php echo $value1->id;?>')">
                        <span class="glyphicon glyphicon-warning-sign"></span>
                     </a>
                     <?php } ?>

                     <?php if( $value1->estado == '' ){ ?>

                     <a class="btn btn-sm btn-danger" title="Eliminar" onclick="delete_retencion('<?php echo $value1->id;?>')">
                        <span class="glyphicon glyphicon-trash"></span>
                     </a>
                     <button class="btn btn-sm btn-primary" type="submit" onclick="" title="Guardar">
                        <span class="glyphicon glyphicon-floppy-disk"></span>
                     </button>
                     <?php } ?>                      
                     <?php if( $value1->estado == 'ANULADO' ){ ?>

                     <a class="btn btn-sm btn-danger" title="RETENCION ANULADA" >
                        <span class="glyphicon glyphicon-remove-circle"></span>
                     </a>
                     <?php } ?>                     

                  </div>
               </td>
            </tr>
         </form>
         <?php } ?>

         <?php if( !$fsc->retenida ){ ?>

         <form class="table-responsive" action="<?php echo $fsc->url();?>" method="post">
            <tr class="bg-info">
               <td>
                  <select type="text"  name="coddocsustento" id = "coddocsustento" value="RENDFINANCIE" class="form-control text-right" >
                    <option >RENDFINANCIE</option>
                    <option >TARJECREDITO</option>
                    <option >COMPRA</option>
                    <option >FONDOSFINANC</option>
                  </select> 
   		         </td>
			   
               <td>
                  <input type="text" width="25" name="fecha" id= "fecha" class="form-control datepicker" value="<?php echo $fsc->today();?>" autocomplete="off"/>
               </td>
               <td>
                   <select type="text"  name="tiporeten"  id = "tiporeten" class="form-control text-right" >
                     <!--onchange="javascript:listas1(this.value);" > -->
                    <option>IVA</option>
                    <option>RENTA</option>  
                    </select> 
                     
               </td>

           <td>             
               <select  name="codigoret"  class="form-control" >
                  <?php $loop_var1=$fsc->selconcepto; $counter1=-1; if($loop_var1) foreach( $loop_var1 as $key1 => $value1 ){ $counter1++; ?>

                     <?php if( $value1->codigo == $value1->retenciones->codigoret ){ ?>

                     <option value="<?php echo $value1->codigo;?>" selected=""><?php echo $value1->codigo;?>---<?php echo $value1->concepto;?>---<?php echo $value1->porcent;?></option>
                     <?php }else{ ?>

                     <option value="<?php echo $value1->codigo;?>"><?php echo $value1->codigo;?>---<?php echo $value1->concepto;?>----<?php echo $value1->porcent;?></option>
                     <?php } ?>

                  <?php } ?>

               </select>
            </td>

               <td>
                  <input type="text" name="porcreten" id ="porcreten" value=""class=" form-control text-right"  autocomplete="off"/>
               </td>
               <td>-</td>
               <td>-</td>
               <!--
               <td>
                  <input type="text" name="basereten" class="form-control text-right" value="<?php echo $fsc->basereten;?>" autocomplete="off"/>
               </td>
               
               <td>
                  <input type="text" name="importe" class="form-control text-right" value="<?php echo $fsc->pendiente;?>" autocomplete="off"/>
               </td>
              -->
               <td class="text-right">
                  <button class="btn btn-sm btn-primary" type="submit" onclick="this.disabled=true;this.form.submit();" title="Guardar">
                     <span class="glyphicon glyphicon-floppy-disk"></span>
                  </button>
               </td>
            </tr>
         </form>
         <?php } ?>

      </table>
   </div>
</body>
</html>