<?php 
session_start();
foreach($_GET  as $key => $value){${$key}=trim($value);} 
foreach($_POST as $key => $value){${$key}=trim($value);} 
include_once('lib_main.php');
if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}
$user_codigo=$_SESSION['user_codigo'];
$user0=data_maes('user',$user_codigo);
if(empty($user_codigo)){include('user_login0.php');return;}

// $tpos
// 1= punto/venta fecha auto enti nombre wsapp
// 2= registro venta fecha limites     

// echo '<meta http-equiv="refresh" content="5">';
// $clie=$enti;
// $enti='';
if (empty($docu)) $docu=$modu;

$modu=strtolower($modu);
$tabla=$modu;
$cant=0;
$puni=0;
$info='lidet2';
  
// if(empty($info)){$info='vtblog';}
// else{$info='vtdeta';}

$info_descri='LINEUP';

if($info=='vtblog'){$info_descri='LINEUP';}


if(!mb_stristr('sist.supe',$user0['user_tipo']))
{
     $sql_acce='select * from acce1 left join acce2 on idnum1=idnum2 where numero='.$user_codigo.' and docum="COST" and info=1';
     $res_acce=msql_query($sql_acce,$link_data);
     if(msql_num_rows($res_acce)==0){$cost='false';}
}

$sql_liup='select hovi from liup1 where idsoft ='.$idsoft.' and team="'.$team.'"';
$res_liup=msql_query($sql_liup,$link_data);
$hovi=msql_result($res_liup,0,'hovi');

$sql_soft='select * from soft1 where idnum1 ='.$idsoft;
$res_soft=msql_query($sql_soft,$link_data);
$liga=msql_result($res_soft,0,'liga');
$torn=msql_result($res_soft,0,'torn');
$jornada=msql_result($res_soft,0,'jornada');
$fecha=msql_result($res_soft,0,'fecha');


$docu0=data_maes('docu',$docu);
$enti0=data_maes('enti',$enti);
$item0=data_maes('item',$item);
// $ctas0=data_maes('ctas',$ctas);
$lsub0=data_maes('lsub',$lsub);
$ptov0=data_maes('ptov',$ptov);
// $csub0=data_maes('csub',$csub);
$lote0=data_maes('lote',$lote);


$sql_imgi='select * from item0 left join imgi0 on item_codigo=imgi_item where item_status not in ("I","X") and imgi_status not in("I","X") limit 1';
$res_imgi=msql_query($sql_imgi,$link_data);
if(msql_num_rows($res_imgi)!=0){$imgi_ok=1;}

$sql_mrca='select * from mrca0 where mrca_status not in("I","X") limit 1';
$res_mrca=msql_query($sql_mrca,$link_data);
if(msql_num_rows($res_mrca)!=0){$mrca_ok=1;}

$sql_lote='select * from lote0 where lote_status not in("I","X") limit 1';
$res_lote=msql_query($sql_lote,$link_data);
if(msql_num_rows($res_lote)!=0){$lote_ok=1;}

     $ztabla='enti';
     $zwhere='(length(trim(enti_codigo)) = 10 and enti_codigo not in(select jugador from liup2,liup1 where idnum1 = idnum2 and idsoft = '.$idsoft.'))';
     include('ele_datalist.php');

  
$xtitulo='LINEUP';
$xtitle='REGISTRO LINEUP';
$xtopcenter=$xtitle;

$fecha0=fecha0($modu);
if(empty($fecha)){$fecha=date('Y-m-d');}

$fecha_min=date('Y-m-d',strtotime('-7 days'));
$fecha_max=date('Y-m-d');

if($tpos==1)
{
     $fecha_min=date('Y-m-d');
     $fecha_max=date('Y-m-d');
}


// $dom = new DOMDocument();
//      $dom->encoding = 'utf-8';
//      $dom->xmlVersion = '1.0';
//      $dom->formatOutput = true;

// echo $dom->saveXML();


$idnum1='';
//  SELECT DB
// if($tpos==1 and !empty($ptov) and !empty($numero))
// if($tpos!=0 and !empty($ptov) and !empty($numero))
if($idsoft>0)
{
     include('sele_info.php');
     if($user_codigo==2)
     {
           //echo '*/*/*'.$sql_info;
           //echo '*/*/*'.$info;
     }
}



if(!empty($sql_info))
{
     $sql_info1=$sql_info;
     $sql_info1=str_replace('group by idnum1,iddet','group by idnum1',$sql_info1);
     $sql_info1=str_replace('group by idnum1,iddet','group by idnum1',$sql_info1);
     $res_info1=msql_query($sql_info1,$link_data);
     $total=msql_result($res_info1,0,'total');
     $tiva=msql_result($res_info1,0,'iva');
     $subt_iva=msql_result($res_info1,0,'subt_iva_hide');
     $subt_iva0=msql_result($res_info1,0,'subt_iva0_hide');
     
     if(msql_num_rows($res_info1)!=0)
     {
          $subt_iva0=number_format($subt_iva0,2);
          $subt_iva=number_format($subt_iva,2);
          $tiva=number_format($tiva,2);
          $total=number_format($total,2);
     }
     
     $res_info=msql_query($sql_info,$link_data);
     if(!empty($numero))
     {
          $idnum1=msql_result($res_info,0,'idnum1_hide');
          $edit=msql_result($res_info,0,'b_o');

          $data_head=data_docu($docu,$idnum1);
          foreach($data_head as $key => $value){${$key}=trim($value);} 
          
          $nombre='';
          $wsapp='';
          $email='';
          
     }
}


// PANTALLA FILTROS
// echo '<div id="filtros" noprint >';
echo '<div id="filtros"  >';
{
     
// OCULTOS
echo '<div hide>';   
{
$cant = 1;
echo '<input id="modu" value="'.$modu.'">';
echo '<input id="info" value="'.$info.'">';
echo '<input id="idnum1" value="'.$idnum1.'">';
echo '<input id="docu" value="'.$docu.'">';
echo '<input id="cant" value="'.$cant.'">';
}     
echo '</div>';     
     
     
$zobj=2;     
include('ele_break.php');

  $zid='idsoft';
$zlabel='Partido';
$zvalue=$idsoft;
$zvalue=(int)$idsoft;
$zclass='numeric-int';
$zreado=1;
$zondblclick='{document.getElementById("'.$zid.'").style.width="'.round(7*2/3,2).'em";}';     
//$zonblur='{if(document.getElementById("'.$zid.'").getAttribute("disabled")!=""){location.href="?scri='.basename(__FILE__,'.php').'&tpos="+document.getElementById("tpos").value+"&docu="+document.getElementById("docu").value+"&ptov="+document.getElementById("ptov").value+"&numero="+document.getElementById("numero").value;}}';
$zonblur='{if(document.getElementById("'.$zid.'").getAttribute("disabled")!=""){document.getElementById("idnum1").value="";fn_consulta();}}';
// $zbackcolor='black';
// $zfontcolor='white';
$zbackcolor='grey';
$zfontcolor='white';
$zsize=1.2;     
include('ele_input.php');

// $zid='btn_nuevo'; 
// $zlabel='Nuevo';
// $zalign='right';
// $zonclick='{fn_nuevo();}';
// $zsize=1.2;     
// include('ele_button.php');
     
     
// $zid='docu';
// $zlabel='Docum.';
// $zvalue=$docu;
// $ztabla='docu';
// $zwhere='(docu_tabla="'.$modu.'")';
// if(!empty($docu)){$zreado=2;}
// // $zondblclick='{document.getElementById("'.$zid.'").removeAttribute("disabled");}';  
// $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&tpos="+document.getElementById("tpos").value+"&docu="+document.getElementById("docu").value+"&ptov="+document.getElementById("ptov").value;}';
// $zonchange=$zonblur;
// if($tpos==1){$zobj=1;}     
// if($tpos==1){$zreado=1;}     
// if($tpos==1){$zlist='nolist';}     
// include('ele_select.php');
     
     
$zid='liga';
$ztabla='liga';
$zlabel='Liga';
$zvalue=$liga; 
$zreado=1;
include('ele_select.php');

$zid='torn';
$ztabla='torn';
$zlabel='Torneo';
$zvalue=$torn; 
$zreado=1;
include('ele_select.php');

$zid='jornada';
$zlabel='Jornada';
$zvalue=$jornada; 
$zreado=1;
include('ele_input.php');

$zid='fecha';
$ztype='date';
$zlabel='Fecha';
$zvalue=$fecha;
// $zvalue=$data_docu[$zid];
$zmin=$fecha_min;     
$zmax=$fecha_max;
$zreado=1;
include('ele_input.php');  

include('ele_break.php');
     
$zid='team';
$ztabla='team';
$zlabel='Equipo';
$zvalue=$team; 
$zreado=1;
include('ele_select.php');

$zid    ='hovi';
$zlabel ='Team';
$zvalue =$hovi;
// $zbool  = 1 ;
$zoptions='1,Home;2,Guest';  
include('ele_select.php');
  
include('ele_break.php');

{
//     $zobj=1;
//     include('ele_break.php');
     
//   $jugador = '0915255616';
     $zid='jugador';
     $zlabel='Jugador';
     $ztabla='enti';
     $zlist='dl_enti';
     include('ele_input.php');

     $zid='camisa';
     $zclass='numeric-int';
     $zlabel='# Camisa';
     $zvalue=$camisa; 
     $zobj = 2;
     $zwidth=5;
     $zmin=1;
     $zmax=1000;  
     include('ele_input.php');  

     $zid='posi';
     $zlabel='Posicion';
     $zvalue=$posi;
     $ztabla='posi';
     $zwhere='(posi_codigo not in(select posi from liup2,liup1 where idnum1 = idnum2 and team = "'.$team.'" and idsoft = '.$idsoft.'))';
     include('ele_select.php');

     $zid='btn_grabar'; 
     $zlabel='Grabar';
     $zalign='right';
     $zonclick='{save_docu(event);}';
     $zsize=1.5;
     include('ele_button.php');

  $zobj=2;     
include('ele_break.php');


  }  
$zid='btn_print'; 
$zlabel='Imprimir';
$zalign='right';
$href='?prnt=1&docu='.$docu.'&idnum='.$idnum1.'&formato=';  
if(mb_stristr('hg01',$cfg_empr))
{$href.='&destino=txt';}
$zonclick='{print_url("'.$href.'");}';
// $zonclick='{save_docu(event);print_url("'.$href.'");}';
if(empty($idnum1)){$zhide=1;}     
$zsize=0.8;     
include('ele_button.php');

     
$zid='btn_final'; 
$zlabel='Finalizar';
$zalign='right';
$zonclick='{fn_finalizar();}';
if(!empty($numero) and empty($edit)){$zhide=1;}     
if(empty($numero)){$zhide=1;}     
if($stfin==1){$zhide=1;}    
$zhide=1;     
$zsize=0.8;     
include('ele_button.php');
     
$zid='btn_consul'; 
$zlabel='Consultar';
$zalign='right';
$zonclick='{fn_consulta(event);}';
$zhide=1;     
include('ele_button.php');

echo '<span style="float:right; white-space:nowrap;">';     
// echo $msgres;
echo '</span>';     
     
if(!empty($ptov))
{
     
$zobj=1;     
include('ele_break.php');

     
//if(@mb_stristr('vtas',$modu))
{
//     $zobj=1;
//     include('ele_break.php');
     
     $zid='enti';
     $zlabel='Cliente';
     $zvalue=$enti;
//      $zvalue=$data_docu[$zid];
     if(empty($zvalue)){$zvalue='9999999999999';}
     $ztabla='enti';
//      $zobj=4;
     include('ele_input.php');
     
     $zid='lpre'; 
     $zvalue=$lpre;
     $zlabel='Lista'; 
     $zonchange='{buscar_item(event);}';
     $zoptions='puni1,Precio 1;puni2,Precio 2;puni3,Precio 3;puni4,Precio 4;puni5,Precio 5;';
     $zhide=1;
     include('ele_select.php');
     

     $zid='vndd';
     $ztabla='enti';
     $zlabel='Vendedor';
     $zvalue=$vndd;
     $zlist='dlvndd';
//      $zondblclick='{document.getElementById("'.$zid.'").removeAttribute("disabled");}';     
     $zalign='right';
     if($tpos==1){$zreado=2;$zobj=6;}
     if($tpos==2){$zreado=0;$zobj=6;}
     if($tpos!=1){$zdefa=$vndd;}
     include('ele_input.php');
     
     
     
     $zobj     =1;
     include('ele_break.php');
     
     if($tpos==1)
     {

          
          
     $zid='nombre';
     $zlabel='Nombre';
     $zvalue=$nombre;
//      $zreado=2;
     $zsize=0.9;
//      $zwidth=15;
     include('ele_input.php');
     
     $zid='email';
     $zlabel='e-mail';
     $zvalue=$email;
//      $zreado=2;
//      $zwidth=10;
     $zsize=0.9;
     include('ele_input.php');
     
     $zid='wsapp';
     $zlabel='wsapp';
     $zvalue=$wsapp;
     $ztype='number';
//      $zreado=2;
//      $zwidth=10;
     $zsize=0.9;
     include('ele_input.php');
          
     }
          
     if($tpos==2)
     {
          
     $zid='concepto';
     $zlabel='Concepto';
     $zvalue=$concepto;
//      $zreado=2;
//      $zsize=0.9;
     $zwidth=25;
     $zrows=2;
     include('ele_input.php');

                    
     }
          

     $zalign='right';
     $zid='total';
     $zlabel='Total $';
     $zvalue=$total;
     $zclass='numeric-dec';
     $zwidth=7;
     $zmax=99999.99;
     $zsize=1.5;
     $zreado=1;
     include('ele_input.php');
     
//      $zobj=4;
     $zalign='right';
     $zid='tiva';
     $zlabel='IVA';
     $zvalue=$tiva;
     $zclass='numeric-dec';
     $zwidth=7;
     $zmax=999.99;
     $zsize=0.8;
     $zreado=1;
     if($tiva==0 or $tarjeta==0){$zhide=1;}
     include('ele_input.php');
     
//      $zobj=4;
     $zalign='right';
     $zid='subt_iva';
     $zlabel='Sub IVA';
     $zvalue=$subt_iva;
     $zclass='numeric-dec';
     $zwidth=7;
     $zmax=99999.99;
     $zsize=0.8;
     $zreado=1;
     if($subt_iva==0 or $tarjeta==0){$zhide=1;}
     include('ele_input.php');
     
     
//      $zobj=4;
     $zalign='right';
     $zid='subt_iva0';
     $zlabel='Sub IVA 0';
     $zvalue=$subt_iva0;
     $zclass='numeric-dec';
     $zwidth=7;
     $zmax=99999.99;
     $zsize=0.8;
     $zreado=1;
     if($subt_iva0==0 or $tarjeta==0){$zhide=1;}
     include('ele_input.php');
     
          

     $zobj=2;
     include('ele_break.php');
     
     $zobj=4;
     $zid='item';
     $zlabel='Item';
     $zvalue=$item;
     $ztabla='item';
     $zopen=0;
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
//      $zdefa='9999999999';
     include('ele_input.php');
     
//      $zobj=4;
//      $zid='producto';
//      $zlabel='Prod/Serv';
//      $zvalue=$producto;
// //      $zwidth=15;
//      include('ele_input.php');
     
     
     $cant=1;
     $zobj=4;
     $zid='cant';
     $zlabel='Cant.';
     $zvalue=$cant;
     $zdefa=1;
     $zmin=0;
     $zmax=9999;
     if(mb_stristr('imcp',$cfg_empr))
     {$zmax=999999;}
//      $zmaxlen=7;
     $zwidth=5;
     $zclass='numeric-dec';
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
     include('ele_input.php');


//      if($cost=='true')
     {
     $zobj=4;
     $zid='puni';
     $zlabel='P.Unit';
     $zvalue=$puni;
//      $zwidth=6 ;
     $zmin=0;
     $zmax=9999.99;
//      $max_puni=max_puni();
     if($max_puni>=1000){$zmax=9999.99;}
     if($max_puni>=10000){$zmax=99999.99;}
     $zclass='numeric-dec';
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
     $zlist='dlpuni';
     if($tpre==1){$zreado=1;}
     include('ele_input.php');
     }

     
     if(empty($numero)){$dcto=0;}
     $zobj=4;
     $zid='dcto';
     $zlabel='% Dcto.';
     $zvalue=$dcto;
//      $zwidth=6;
     $zmin=0;
     $zmax=99.99;
     $zclass='numeric-dec';
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
     include('ele_input.php');
     
     $zobj=4;
     $zid='iva';
     $zlabel='IVA';
     $zvalue=$iva;
     $zmin=0;
     $zmax=9999;
     $zclass='numeric-dec';
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
//      $zoptions='0;12';
//      include('ele_select.php');
     $zlist='dliva';
     if($tpos==1)
     {$zmax=999;$zreado=1;}
     $zsize=0.9;
     include('ele_input.php');
     
     $zobj=4;
     $zid='ice';
     $zlabel='ICE';
     $zvalue=$ice;
     $zwidth=6;
//      $zoptions='0;12';
     $zhide=1;
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
     include('ele_select.php');
     
     $zobj=4;
     $zid='irbp';
     $zlabel='IRBP';
     $zvalue=$irbp;
     $zwidth=6;
//      $zoptions='0;12';
     $zhide=1;
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
     include('ele_select.php');
     
     $zobj=4;
     $zid='pvp';
     $zlabel='P.V.P.';
     $zvalue=$pvp;
     $zclass='numeric-dec';
     $zwidth=6;
     $zmax=99999;
     $zreado=1;
     if($tpos!=1){$zhide=1;}
     include('ele_input.php');
     
     
     $zobj=4;
     $zid='subtot';
     $zlabel='Sub-Total';
     $zvalue=$subtot;
     $zclass='numeric-dec';
     $zwidth=7;
     $zmax=99999.99;
     $zreado=1;
     include('ele_input.php');

     
     
     
     if($lote_ok==1)
     {
//           $zid='lote';
//           $zlabel='Lote';
//           $zvalue=$lote;
//           $ztabla='lote';
//           $zmaxlen=20;
//           include('ele_input.php');
     }
     
     if($nser_ok==1)
     {
//           $zid='serie';
//           $zlabel='Serie';
//           $zvalue=$serie;
//           include('ele_input.php');
     }
     
     if($mrca_ok==1)
     {
//           $zid='';
//           $zlabel='Marca';
//           $zvalue=$mrca;
//           $ztabla='mrca';
//           $ztodo=1;
//           include('ele_select.php');
     }
     
}


     
// $zobj=1;     
// include('ele_break.php');

     
$zid='btn_deleall'; 
$zlabel='Borrar';
$zalign='right';
$zonclick='{fn_deledeta(event);}';
//$zsize=1.5;
$zbackcolor='darkred';
$zfontcolor='white';     
if(!empty($numero) and empty($edit)){$zhide=1;}       
$zhide=1;     
include('ele_button.php');
     
     
     
     
     
// $zobj=1;     
// include('ele_break.php');

     
$zobj=4;
$zid='detalle';
$zlabel='Notas';
$zwidth=25;    
$zrows=2;     
$zvalue=$detalle;
if($tpos==1)
{$zhide=1;}
     
// $zvalue=$data_docu[$zid];
     
include('ele_input.php');
     

     
     
     

$zobj=2;     
include('ele_break.php');

}
     
// TITULO     
     
     

}     
// include('ele_break.php');

// echo '*/*/*/'.$_COOKIE['oscreen'];




// RESULTADO
$sty_resu='float:right;';
$sty_resu='margin:0 auto;';
echo '<span id="main2" style="'.$sty_resu.'"  >';
// $sql_idx=1;
// for($idx=1; $idx<=$sql_idx; $idx++)
{
     if(gettype($res_info)!='NULL')
     {
          $zreso=$res_info;
          $zinfo=$info;
          $zname=$zname;
          $zhead=0;
          $zgfsize=0.9;
//           $zblockrows=3;
          $zheightrow='2';
          $zblockidnum=1;
          $zhidebtns=1;
//           $zwidthtable='80%';
          include('ele_grid.php');     
          
//           if($info=='vtblog')
//           {if($idx<msql_num_rows($res_krdx)){echo '<div id="pgbreak" style="height:2em;"></div>';}}

     }
}     
echo '</span>';     


echo '</div>';


// echo '<div style="height:4em;">';     
// echo '</div>';     


echo '<div align="center" height="auto" id="divstock">';
// echo '<iframe id="fr_stock" src="" title="Stock"  style="border:none;width:90%;height:600px;align:center; ">';
// echo '</iframe>';
echo '</div>';
     


?>

<script>
function fn_stock(event)
{
     var busca,xsrc='?';
     busca=document.getElementById('cstock').value;
     document.getElementById('divstock').innerHTML='';
     if(busca.length>3)
     {
//           xsrc='?scri=info_modu3&modu=inve&info=iibode&tsaldo=69&prnt=1&prec=pvp&item='+busca;
//           document.getElementById('fr_stock').setAttribute('src',xsrc);
     
          var datapost,dato;
          datapost=new FormData();
          datapost.append('script','info_modu3');
          datapost.append('modu','inve');
          datapost.append('info','iibode');
          datapost.append('prec','pvp');
          datapost.append('prnt','1');
          datapost.append('zhidebtns','1');
          datapost.append('item',busca);
          dato=exe_ajax(datapost,'divstock','',true);
     
     }
     
}
</script>

<script>
function fn_consulta(event)
{
     var xhref='',dataget;
     xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';

//     alert(document.getElementById('numero').value);
     
     dataget=new_FormData('filtros','get');
     xhref=xhref+dataget;
     
     document.getElementById("main2").innerHTML='Espere...';
     location.href=xhref;
}
</script>



<script>
function fn_nuevo(event)
{
     var enti;
     swal.fire({
          icon:'warning',
          title:'Nuevo Documento',
          text:'Continuar ?',
          confirmButtonText:'Nuevo',
          confirmButtonColor:color1,
          focusCancel:true,
          showCancelButton:true,
          cancelButtonColor: 'darkred',
          timer:60000
     }).then((result) => 
          {
               if(result.isConfirmed)
               {
                    document.getElementById("fecha").value="";
                    document.getElementById("numero").value="";
                    document.getElementById("idnum1").value="";
                    enti=document.getElementById("enti").value;
     //                if(enti.indexOf("9999999999")<0)
                    {document.getElementById("enti").value="";}
                    fn_consulta(event);
               }
          })
}     
     
</script>


<script>
function fn_deledeta(event)
{
     
     anul_docu(document.getElementById('docu').value,document.getElementById('idnum1').value,'ALL');
     //fn_consulta(event);

     return;
     
}     
     
</script>




<script>
function fn_finalizar(event)
{
     swal.fire({
          icon:'warning',
          title:'Finalizar Documento',
          text:'Continuar ?',
          confirmButtonText:'Finalizar',
          confirmButtonColor:color1,
          focusCancel:true,
          showCancelButton:true,
          cancelButtonColor: 'darkred',
          timer:10000
     }).then((result) => 
          {
               if(result.isConfirmed)
               {
               document.getElementById("stfin").value="1";
               save_docu(event);
               }
          })
}
</script>



<script>
function calc_subtot(event)
{
     var cant,puni,dcto,iva,ice,irbp,pvp;
     var subtot,tdcto,tice,tiva,tirbp,subtot,total;
     var efectivo,tarjeta,cambio;
     
     if(document.getElementById("cant")){cant=document.getElementById("cant").value ||0;}
     if(document.getElementById("puni")){puni=document.getElementById("puni").value ||0;}
     if(document.getElementById("dcto")){dcto=document.getElementById("dcto").value ||0;}
     if(document.getElementById("iva")){iva=document.getElementById("iva").value ||0;}
     if(document.getElementById("ice")){ice=document.getElementById("ice").value ||0;}
     if(document.getElementById("irbp")){irbp=document.getElementById("irbp").value ||0;}
     
     if(document.getElementById("subtot")){subtot=document.getElementById("subtot").value ||0;}
     if(document.getElementById("total")){total=document.getElementById("total").value ||0;}
     if(document.getElementById("efectivo")){efectivo=document.getElementById("efectivo").value ||0;}
     if(document.getElementById("tarjeta")){tarjeta=document.getElementById("tarjeta").value ||0;}
     
     subtot=puni;
     tdcto=subtot*dcto/100;
     tice=subtot*ice/100;
     subtot=subtot-tdcto+tice;
     tiva=subtot*iva/100;
     tirbp=cant*irbp;
     subtot=subtot+tiva;
     
     pvp=subtot;
     pvp=pvp.toFixed(2);
     
     subtot=subtot*cant;
     subtot=subtot.toFixed(2);
     
     if(total==0){total=subtot;}
     
     cambio=0;
//      if(efectivo>total && total>0)
     if(parseFloat(efectivo)>parseFloat(total) && parseFloat(total)>0)
     {cambio=efectivo-total;}
     
     if(document.getElementById("pvp")){document.getElementById("pvp").value=parseFloat(pvp);}
     if(document.getElementById("subtot")){document.getElementById("subtot").value=subtot;}
     
     
     if(document.getElementById("cambio"))
     {
          document.getElementById("cambio").value=cambio.toFixed(2);
          document.getElementById('cambio').style.color='navy';
          document.getElementById('cambio').style.fontSize='1.2em';
          if(cambio>0)
          {document.getElementById('cambio').style.color='darkred';}
     }

     
//      document.getElementById('subt_iva0_ele').setAttribute("hide","");
//      document.getElementById('subt_iva_ele').setAttribute("hide","");
//      document.getElementById('tiva_ele').setAttribute("hide","");
//      if(tarjeta>0)
//      {
//           document.getElementById('subt_iva0_ele').removeAttribute("hide");
//           document.getElementById('subt_iva_ele').removeAttribute("hide");
//           document.getElementById('tiva_ele').removeAttribute("hide");
//      }

}
</script>


<script>document.title="<?php echo $xtitle;?>"</script>
<script>document.getElementById('topcenter').innerHTML="<?php echo $xtopcenter;?>"</script>
<script>calc_subtot()</script>
<!-- <script>set_noback();</script> -->
<!-- <script>window.onbeforeunload = function(){return 'Are you sure you want to leave?';};</script> -->

