<?php 
declare(strict_types=0);
// session_start();
foreach($_GET  as $key => $value){${$key}=trim($value);} 
foreach($_POST as $key => $value){${$key}=trim($value);} 
include_once('lib_main.php');



// header("Location: https://www.ejemplo.com");




if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}
$user_codigo=$_SESSION['user_codigo'];
$user0=data_maes('user',$user_codigo);
$empr0=data_maes('empr',$cfg_empr);
if(empty($user_codigo)){include('user_login0.php');return;}


$sql_updt='update cnmb0 set cnmb_descri=replace(cnmb_descri,"¡","I")';
$res_updt=msql_query($sql_updt,$link_data);

$sql_updt='update cnmb0 set cnmb_descri=replace(cnmb_descri,"¢","O")';
$res_updt=msql_query($sql_updt,$link_data);

$sql_updt='update cnmb0 set cnmb_descri=replace(cnmb_descri,"?CIDO","ACIDO")';
$res_updt=msql_query($sql_updt,$link_data);

$sql_updt='update cnmb0 set cnmb_descri=replace(cnmb_descri,"?cido","Acido")';
$res_updt=msql_query($sql_updt,$link_data);

// $tpos
// 1= prod o servicio unico     
// 2= punto/venta fecha auto enti nombre wsapp
// 3= registro venta fecha limites     
// 9= item varios

// echo '<meta http-equiv="refresh" content="5">';
// $clie=$enti;
// $enti='';


          // oral oral
          // rectal rect
          // vaginal vagi
          // subcutanea
          // intravenosa iven
          // intramuscular imus
          // ocular ocul
          // otica otic
          // nasal
          // inhalacion
          // nebulizacion
          // cutaneo topico
          // cutaneo sistemico
          // transdermico


$modu=strtolower($modu);
$tabla=$modu;

if(!empty($idnum1))
{
     $sql_docu='select * from '.$tabla.'1 left join '.$tabla.'2 on idnum1=idnum2 where idnum1="'.$idnum1.'" order by iddet desc limit 1';
     $res_docu=msql_query($sql_docu,$link_data);
     $data_docu=msql_fetch_assoc($res_docu);
     foreach($data_docu as $campo => $valor){${$campo}=trim($valor);} 
}

if($tpos>=2)
{
     $item='';
     $cant=0;
     $puni=0;
}

if($tpos==9)
{$item='9999999999';}

// $info='vtdeta';
// if(empty($ptoe) and $tpos<=2){$ptoe=$user0['user_ptoe'];}
if(empty($ptoe)){$ptoe = $user0['user_ptoe'];}
if(empty($ptoe)){$ptoe = $_COOKIE['ptoe'];}
if(empty($ptoe)){$ptoe='001001';}

if(empty($mdco)){$mdco=$user0['user_cedula'];}
if(empty($modu)){$modu='rmed';}
if(empty($format)){$format=1;}
if(empty($tpos)){$tpos=2;}
if(empty($tpre)){$tpre=2;}

if(empty($lpre))
{
     $lpre='puni1';
     if($cfg_empr=='imcp'){$lpre='puni3';}
}

if($tpos==3 and empty($ptoe))
{
     $fecha_vtas=date('Y-m-1',strtotime('-1 month'));
//      $sql_vtas='select distinct ptoe from vtas1 where docu like "'.$docu.'%" and status not in("O","X") and fecha>="'.$fecha_vtas.'" order by idnum1 desc';
     $sql_vtas='select distinct ptoe from '.$modu.'1 where docu like "'.$docu.'%" and status not in("O","X") and fecha>="'.$fecha_vtas.'" order by idnum1 desc';
     $res_vtas=msql_query($sql_vtas,$link_data);
//      if(msql_num_rows($res_vtas)>=1)
     {$xptoe=msql_result($res_vtas,0,'ptoe');}     
     if(!empty($xptoe))
     {$ptoe=$xptoe;}
}     
if(empty($ptoe))
{
     $sql_ptoe='select * from '.$modu.'1 where iuser="'.$user_codigo.'" order by idnum1 desc limit 1';
     $res_ptoe=msql_query($sql_ptoe,$link_data);
     $ptoe=msql_result($res_ptoe,0,'ptoe');
}


if($format==1){$info=substr($modu,0,2).'det2';}
if($format==2){$info=substr($modu,0,2).'deta';}
if($format==3){$info=substr($modu,0,2).'blog';}

if($tpos==1){$info=substr($modu,0,2).'det1';}
if($tpos==2){$info=substr($modu,0,2).'det2';}
if($tpos==3){$info=substr($modu,0,2).'det2';}

// if(empty($info)){$info='vtblog';}
// else{$info='vtdeta';}

$info_descri='VENTAS';

if($info=='vtblog'){$info_descri='PTO.EMISION';}

if(empty($user0['user_tipo'])){$cost='false';}

if(!mb_stristr2('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';}
}

// set_docu("RMED","TRAN","rmed","RECETA MEDICA");
// if(empty($docu) and $modu=='vtas'){$docu='FC10';}
// if(empty($docu) and $modu=='clie'){$docu='PF10';}
if(empty($docu)){$docu='RMD1';}

$docu0=data_maes('docu',$docu);
$enti0=data_maes('enti',$enti);
$item0=data_maes('item',$item);
$lsub0=data_maes('lsub',$lsub);
$ptoe0=data_maes('ptoe',$ptoe);
$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;}



$xtitulo='VENTAS';
if($modu=='vtas'){$xtitulo='VENTAS';}
if($modu=='clie'){$xtitulo='CLIENTES';}

$xtitle='REG.'.$xtitulo;
if($tpos==2){$xtitle='RECETA MEDICA';}
$xtopcenter=$xtitle;
if(!empty($docu)){$xtitle.=' /'.$docu;}
if(!empty($numero)){$xtitle.='-'.$numero;}

$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');
$fecha_max=date('Y-m-d',strtotime('+7 days'));



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

if(date('Y-m-d')<="2023-08-30")
{
     if($empr0['empr_codigo']=='zmac'){$fecha_min="2020-01-01";}
}
// $dom = new DOMDocument();
//      $dom->encoding = 'utf-8';
//      $dom->xmlVersion = '1.0';
//      $dom->formatOutput = true;

// echo $dom->saveXML();

//if ($cfg_empr=='span')
//   {
//     $fecha_min=date('Y-m-d',strtotime('-150 days'));
//   }

$idnum1='';
//  SELECT DB
if($tpos!=0 and !empty($docu)  and !empty($ptoe) and !empty($numero))
{
//      $mdco='';
     include('sele_info.php');
}

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');
     
     $claveacc=msql_result($res_info1,0,'claveacc_hide');
     $iuser=msql_result($res_info1,0,'iuser_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='';
          $email='';
          $wsapp='';
          
     }
}

if(empty($numero))
{
     $dcto=0;
     $total=0;
     $efectivo=0;
     $tarjeta=0;
     $credito=0;
     $cambio=0;

     $nombre='';
     $email='';
     $wsapp='';
     
}

// datalist
// echo '*/*/*'.$ptoe;
// $ptoe='';
if(!empty($ptoe))
{


// $zid='dlrgsn';     
// $ztabla='rgsn';
// $zcolu='rgsn_nomcom';     
// $zcolu2='rgsn_nomcom';     
// include('ele_datalist.php');

     
$ztabla='cnmb';
include('ele_datalist.php');

     
     
     
$ztabla='mdcn';
$zwhere='(length(trim(mdcn_codigo))>3)';     
include('ele_datalist.php');

     
// $zid='dl_fmco';     
// $ztabla='cnmb';
// $zcolu='cnmb_descri';     
// $zcolu2='cnmb_descri';     
// $zwhere='(length(trim(cnmb_codigo))>=6)';     
// include('ele_datalist.php');

     
     
$sql_fmco='select count(farmaco)as cfmco, farmaco ';
$sql_fmco.='from rmed1 left join rmed2 on idnum1=idnum2 ';
$sql_fmco.='where ifnull(status,"")not in ("O","X") ';
$sql_fmco.='and fecha >=curdate()-interval 1 month ';
// $sql_fmco.='and farmaco not in(select prac_codigo from prac0) ';
$sql_fmco.='and farmaco not in(select prac_descri from prac0) ';
$sql_fmco.='group by farmaco';
$res_fmco=msql_query($sql_fmco,$link_data);     

while($aso_fmco=msql_fetch_assoc($res_fmco))
{
     if($aso_fmco['cfmco']>=1)
     {
          $xcodigo=$aso_fmco['farmaco'];
          if (!preg_match('/[0-9]/', $xcodigo))
          {
        //   $sql_inse='insert into prac0(prac_codigo,prac_descri,prac_idate)value("'.$xcodigo.'","'.$aso_fmco['farmaco'].'",now())';
        //   $res_inse=msql_query($sql_inse,$link_data);
            $prac0=data_maes('prac',$xcodigo);
            if($prac0['prac_codigo']=='')
          {inse_maes('prac',$xcodigo,$aso_fmco['farmaco']);}
          }
     }
     
}
     
     
     
     

$zid='dl_fmco';     
$ztabla='prac';
$zcolu='prac_descri';     
$zcolu2='prac_descri';     
// $zwhere='(length(trim(cnmb_codigo))>=6)';     
include('ele_datalist.php');

     
$zid='dlmedicamento';     
$zdocu=$docu;
$zcolu='medicamento';     
$zcolu2='medicamento';     
include('ele_datalist.php');


     
     
          // oral oral
          // rectal rect
          // vaginal vagi
          // subcutanea
          // intravenosa iven
          // intramuscular imus
          // ocular ocul
          // otica otic
          // nasal
          // inhalacion
          // nebulizacion
          // cutaneo topico
          // cutaneo sistemico
          // transdermico

$fdl_rmed=date('Y-m-01',strtotime('-30 days'));
     
$zid='dlvia';     
$zdocu=$docu;
$zcolu='via';     
$zcolu2='via';     
$zwhere='(fecha>="'.$fdl_rmed.'")';
include('ele_datalist.php');

     
$zid='dldosis';     
$zdocu=$docu;
$zcolu='dosis';     
$zcolu2='dosis';     
$zwhere='(fecha>="'.$fdl_rmed.'" and substring(dosis,1,1)*1>0)';
include('ele_datalist.php');

     
$zid='dlfrecuencia';     
$zdocu=$docu;
$zcolu='frecuencia';     
$zcolu2='frecuencia';     
// $zwhere='(mdco like "5'.$user0['user_cedula'].'%")';
$zwhere='(fecha>="'.$fdl_rmed.'" and substring(frecuencia,1,1)*1>0)';
include('ele_datalist.php');

     
     
$zid='dlindicaciones';     
$zdocu=$docu;
$zcolu='indicaciones';     
$zcolu2='indicaciones';     
$zwhere='(fecha>="'.$fdl_rmed.'" and mdco like "'.$user0['user_cedula'].'%")';
include('ele_datalist.php');



$ztabla='ciex';
// {$zwhere='(left(ciex_codigo,3) in(select distinct left(ciex,3) from rmed1) )';}
include('ele_datalist.php');

$ztabla='enti';
{$zwhere='(left(enti_codigo,10) in(select distinct left(enti,10) from vtas1) or left(enti_codigo,10) in(select distinct left(enti,10) from clie1))';}
include('ele_datalist.php');

$ztabla='fpag';
// {$zwhere='(left(enti_codigo,10) in(select distinct left(enti,10) from vtas1) or left(enti_codigo,10) in(select distinct left(enti,10) from clie1))';}
include('ele_datalist.php');

     
// $fec_mdco=date('Y-m-01',strtotime('-3 month'));
// $zid='dlmdco';     
// $ztabla='enti';
// $zwhere='(left(enti_codigo,10) in(select distinct left(mdco,10) from vtas1 where fecha>="'.$fec_mdco.'") or left(enti_codigo,10) in(select distinct left(mdco,10) from clie1  where fecha>="'.$fec_mdco.'"))';
// include('ele_datalist.php');
    
              
$ztabla='item';
$zlpre='pvp1';     
$zstockv=1;     
$zwhere='(left(item_codigo,2)!="99")';
// $zwhere='(left(item_codigo,2)!="99" and left(item_codigo,1)!="0")';     
include('ele_datalist.php');

     
     
     
$ztabla='lote';
include('ele_datalist.php');
     
$ztabla='vhcl';
include('ele_datalist.php');
     
$ztabla='cntn';
include('ele_datalist.php');
     
$ztabla='docu';
$zwhere='(docu_tabla="'.$modu.'")';
include('ele_datalist.php');

echo '<datalist id="dlpuni"></datalist>';
echo '<datalist id="dlpvp"></datalist>';
echo '<datalist id="dldcto"></datalist>';

}


// PANTALLA FILTROS
// echo '<div id="filtros" noprint >';
echo '<div id="filtros"  >';
{
     
// OCULTOS
echo '<div hide>';   
{
// echo '<input id="ipip" value="'.$ipip.'">';
echo '<input id="modu" value="'.$modu.'">';
echo '<input id="info" value="'.$info.'">';
echo '<input id="tpos" value="'.$tpos.'">';
echo '<input id="tpre" value="'.$tpre.'">';
echo '<input id="idnum1" value="'.$idnum1.'">';
echo '<input id="stfin" value="'.$stfin.'">';
}     
echo '</div>';     
     
     
$zobj=2;     
include('ele_break.php');
     
$zid='btn_nuevo'; 
$zlabel='Nuevo';
$zalign='right';
$zonclick='{fn_nuevo();}';
$zsize=1.5;     
include('ele_button.php');
     
     
         
$zid='fecha';
$ztype='date';
$zlabel='Fecha';
$zvalue=$fecha;
// $zvalue=$data_docu[$zid];
$zmin=$fecha_min;     
$zmax=$fecha_max;     
if($tpos==1){$zhide=1;}
if($tpos==2){$zhide=1;}
$zreado=2;     
include('ele_input.php');  
     
     

//      echo '====='.$docu.$modu; 
$zid='docu';
$zlabel='Docum.';
$zvalue=$docu;
$ztabla='docu';
$zwhere='(docu_tabla="'.$modu.'")';
if(!empty($docu)){$zreado=2;}
// $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&tpos="+document.getElementById("tpos").value+"&docu="+document.getElementById("docu").value+"&ptoe="+document.getElementById("ptoe").value;}';
// $zonblur='{location.href="?scri='.basename(__FILE__,'.php').'&tpos="+document.getElementById("tpos").value+"&docu="+document.getElementById("docu").value+"&ptoe="+document.getElementById("ptoe").value+"&modu="+document.getElementById("modu").value;}';
$zonblur='{fn_consulta(event);}';
$zonchange=$zonblur;
// if($tpos<=2){$zobj=1;}     
// if($tpos<=2){$zreado=1;}     
// if($tpos<=2){$zlist='nolist';}     
$zsize=0.9;     
include('ele_select.php');
     
     
$zid='ptoe';
$ztabla='ptoe';
$zlabel='Pto.Vta.';
$zvalue='001001'; 
$zhide=1;     
include('ele_select.php');


if($tpos==1){$zobj=1;}     
$zid='numero';
$zlabel='№';
     
$zvalue=$numero;
$zvalue=(int)$numero;
// $zmin=1;
// $zmax=9999999;     
$zclass='numeric-int';
$zreado=2;     
$zondblclick='{document.getElementById("'.$zid.'").style.width="'.round(7*2/3,2).'em";}';     
// $zonblur='{if(document.getElementById("'.$zid.'").getAttribute("disabled")!=""){document.getElementById("idnum1").value="";fn_consulta();}}';
$zonblur='{if(document.getElementById("'.$zid.'").getAttribute("disabled")!=""){document.getElementById("idnum1").value="";}}';
$zonchange='{fn_consulta(event);}';
$zbackcolor='grey';
$zfontcolor='white';
$zsize=1.2;     
include('ele_input.php');
     
$zid='btn_wsapp'; 
$zsize=1.5;
$zalign='right';
$zlabel='✆';
// $zlabel='📞';     
$zlabel='💬';     
$ztitle='Enviar WhatsApp';     
$zbackcolor='lightgreen';
if(!empty($numero))
{
     if($tpos!=3)
     {$zonclick='{send_wsapp(document.getElementById("wsapp").value);}';}
     if($tpos==3)
     {$zonclick='{send_wsapp();}';}
}
if(empty($claveacc)){$zonclick='{location.reload();';}
if(empty($numero)){$zhide=1;}  
include('ele_button.php');
     
     
$zid='btn_print'; 
$zsize=1.5;     
$zalign='right';
$zlabel='Imprimir';
$href='?scri=info_docu3&prnt=1&docu='.$docu.'&idnum='.$idnum1.'&formato=';  
if(mb_stristr2('hg01',$cfg_empr)){$href.='&destino=txt';}
if(mb_stristr2('anml',$cfg_empr)){$href.='&pgsize=P';}
$zonclick='{print_url("'.$href.'");}';
if(empty($idnum1)){$zhide=1;}     
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');

     
     
$zobj=1;     
include('ele_break.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($ptoe))
{
     
$zobj=1;     
include('ele_break.php');

     
//if(@mb_stristr2('vtas',$modu))
{
//     $zobj=1;
//     include('ele_break.php');

//      echo '==='.$mdco;
//      $zid='fpag';
//      $ztabla='fpag';
//      $zwhere='(fpag_codigo*1=1 or fpag_codigo*1>=15)';
//      $zlabel='F.Pago';
//      $zvalue=$fpag;
// //      $zlist='';
//      $zalign='right';
//      $zexact=1;
//      $zdefa='01';
//      if($tpos==1){$zobj=1;$zhide=0; }
//      if($tpos==2){$zreado=0;$zobj=4;}
//      if($tpos==3){$zreado=0;$zobj=4; $zdefa='20';}
//      $zsize=0.9;
//      include('ele_select.php');
     

     
     
     
     
     $zid='plazo';
     $zlabel='Plazo';
     $zvalue=$plazo;
     $zalign='right';
     $zsize=0.9;
     $zmin=0;
     $zmax=30*3;
     $zclass='numeric-int';
     if($tpos==1){$zobj=1;$zhide=1; }
     if($tpos==2){$zobj=1;$zhide=1; }
     if($tpos==3){$zreado=0;$zobj=4;}
     if($modu=='clie'){$zmax=30;}
     
//      include('ele_select.php');
     include('ele_input.php');
     
     
     
     
     $zid='enti';
//      $zlabel='Cliente';
     $zlabel='Cédula';
     $zvalue=$enti;
     if(empty($zvalue)){$zvalue='9999999999999';}
     $ztabla='enti';
//      $zopen=1;
     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');
     
     $zobj=1;
     include('ele_break.php');
     
//      if($tpos==2)
     {
     $zid='nombre';
     $zlabel='🤒 Paciente';
     $zvalue=$nombre;
     $zsize=0.9;
     include('ele_input.php');

          
     $zid='sexo';
     $zlabel='Sexo';
     $zvalue=$sexo;
     $zoptions='0,N/A;1,Masculino;2,Femenino';
     $zsize=0.9;
//      $zalign='right';
     include('ele_select.php');
          
          
          
     $zid='fechanac';
     $zlabel='Nacimiento';
     $zvalue=$fechanac;
     $ztype='date';
     $zmin=date('Y-m-d',strtotime('-1200 month'));
     $zmax=date('Y-m-d',strtotime('-1 day'));
     $zsize=0.9;
//      $zalign='right';
     include('ele_input.php');
          
          

          
     
          
          
     $zobj=1;
     include('ele_break.php');
     
          
          
     $zid='email';
     $zlabel='e-mail';
     $zvalue=$email;
     $zsize=0.9;
     include('ele_input.php');
     }

     if($tpos!=3)
     {
     $zid='wsapp';
     $zlabel='wsapp';
     $zvalue=$wsapp;
     $ztype='number';
     $zsize=0.9;
     if(!empty($numero))
     {$zonclick='{send_wsapp(document.getElementById("wsapp").value);}';}
     if($user0['user_hide_wsapp']==1)
     {$zhide=1;}
     include('ele_input.php');
     }          

     $zobj=1;
     include('ele_break.php');
     
     $zid='ciex';
     $zlabel='⚕️ CIE-10';
     $zvalue=$ciex;
     $ztabla='ciex';
     $zwidth=20;
     include('ele_input.php');

     
     
     $zid='mdco';
     $zlabel='Médico';
//      $zlist='dlmdco';
     $zalign='right';
     $zvalue=$mdco;
     $zvalue=$user0['user_cedula'];
     $zreado=1;
     include('ele_input.php');
     
     
     
     $zobj=1;
     include('ele_break.php');

     $zid='ciex2';
     $zlabel='⚕️ CIE-10.₂';
     $zvalue=$ciex2;
     $ztabla='ciex';
     $zwidth=0.8;
//      $zsize='80%';
     include('ele_input.php');

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

     $zid='ciex3';
     $zlabel='⚕️ CIE-10.₃';
     $zvalue=$ciex3;
     $ztabla='ciex';
     $zwidth=20;
     include('ele_input.php');


     
     
     
     
     
     if($tpos==3)
     {
     $zid='concepto';
     $zlabel='Concepto';
     $zvalue=$concepto;
     $zwidth=25;
     $zrows=2;
     include('ele_input.php');

     if(mb_stristr2('demo.sawo',$cfg_empr))
     {
          $zid='numoc';
          $zlabel='# Orden';
          $zvalue=$numoc;
          include('ele_input.php');
     }
                    
     }
          

//      $zalign='right';
//      $zid='total';
//      $zlabel='Total';
//      $zvalue='💲 '.$total;
//      $zwidth=7;
//      $zsize=1.5;
//      $zreado=1;
//      $zhide=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');

     
// echo '*/*/*'.$ptoe;
     //820
     
// and !empty($edit)
     
if(!empty($ptoe) )
{
     
     $zobj=4;
     $zid='item';
     $zlabel='Item';
     $zvalue=$item;
     $ztabla='item';
     $zopen=0;
//      $zonchange='calc_subtot();';
//      $zonblur=$zonchange;
     if($tpos==1){$zvalue='';}
//      if($tpos==1)
//      {$zonchange='if(this.value.length==13){document.getElementById("puni").value=0;save_docu(event);};';}
//      if($tpos==1)
//      {$zonkeyup="{if(isValidBarcode(this.value)){btn_grabar.onclick(); this.value=null;};}";}
     if($tpos==9){$zhide=1;}
     $zhide=1;
     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.';
//      $zlabel='Cant.';
//      $zvalue=$cant;
     $zdefa=1;
     $zmin=0;
     $zmax=999;
     $zwidth=5;
     $zclass='numeric-int';
//      $zonchange='calc_subtot();';
//      $zonblur='calc_subtot();';
     include('ele_input.php');

     
     
     $zobj=4;
     $zid='farmaco';
     $zlabel='⚛️  Fármaco';
     $zwidth=10;
     $zplace='Fármaco';
     $zlist='dl_fmco';
     $zonchange='{opt_list_mdcn();}';
     include('ele_input.php');
     
     $zobj=4;
     $zid='medicamento';
     $zlabel='💊  Medicamento';
     $zwidth=20;
     $zlist='dl_mdcn';
     $zonblur='(set_via());';
     include('ele_input.php');
     
//      $zobj=4;
//      $zid='prescripcion';
//      $zlabel='💊  Prescripción';
//      $zwidth=25;
//      $zlist='dl_mdcn';
//      $zplace='Medicamento';
//      $zonblur='(set_via());';
//      include('ele_input.php');
     
     
//      ➡️💉
     $zobj=4;
     $zid='via';
     $zlabel='➡️ Vía';
//      $zvalue=$via;
     $zwidth=8;
     $zlist='dl'.$zid;
//      $zdefa='Oral';
//      $zplace='Oral';
     include('ele_input.php');
     
     $zobj=4;
     $zid='dosis';
     $zlabel='🧪 Dosis';
//      $zvalue=$dosis;
     $zwidth=10;
     $zlist='dl'.$zid;
//      $zplace='';
     include('ele_input.php');
     
     $zobj=4;
     $zid='frecuencia';
     $zlabel='⏱️ Frecuencia';
//      $zvalue=$frecuencia;
     $zwidth=10;
     $zlist='dl'.$zid;
     include('ele_input.php');
     
     $zobj=4;
     $zid='duracion';
//      $zlabel='🗓️ Duración';
     $zlabel='🗓️ Días';
//      $zvalue=$duracion;
//      $zwidth=6;
//      $zlist='dl'.$zid;
     $zplace='Días';
     $zmin=0;
     $zmax=90;
     $zclass='numeric-int';
     include('ele_input.php');
     
     $zobj=4;
     $zid='indicaciones';
     $zlabel='📝 Indicaciones';
//      $zvalue=$indicaciones;
     $zlist='dlindicaciones';
     $zwidth=20;
     include('ele_input.php');
     
     

//      if($cost=='true')

     
     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();';
     if($tpos==1){$zhide=1;}
     if(substr($docu,0,2)=='NC'){$zhide=1;}
     $zhide=1;
     include('ele_input.php');
     
     
     $zobj=4;
     $zid='iva';
     $zlabel='% IVA';
     $zvalue=$iva;
     $zmin=0;
//      $zmax=12;
     $zmax=$_SESSION['porc_iva'];
     if(empty($zmax)){$zmax=15;}
     $zclass='numeric-dec';
     $zonchange='calc_subtot();';
     $zonblur='calc_subtot();';
//      $zoptions='0;12';
//      include('ele_select.php');
     $zlist='dliva';
     $zsize=0.9;
     if($tpos==1){$zhide=1;}
     if($tpos==2){$zmax=999;$zreado=1;}
     $zhide=1;
     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();';
     if($tpos==1){$zhide=1;}
     $zhide=1;
     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();';
     $zhide=1;
     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;}
     $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;
     $zhide=1;
     include('ele_input.php');

     
     
     
     
}
          

$zid='btn_grabar'; 
$zlabel='Grabar';
$zalign='right';
$zonclick='{save_docu(event);}';
// $zonclick='{save_docu(event);vali_docu(event);}';
$zsize=1.5;
if(!empty($numero) and empty($edit)){$zhide=1;}  
if($format==3){$zhide=0;}
include('ele_button.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');
     

if(1==2)     
if($empr0['empr_veterinaria']==1)     
{
     $zid='dl_pcnt';     
     $ztabla='enti';
//      {$zwhere='(left(enti_codigo,10) in(select distinct left(pcnt,10) from vtas2) or left(enti_codigo,10) in(select distinct left(pcnt,10) from clie2))';}
     if(mb_stristr2('anml',$cfg_empr))
     {$zwhere='(left(enti_codigo,2)="99")';}
     include('ele_datalist.php');
     
     $zobj=4;
     $zid='pcnt';
     $ztabla='enti';
     $zlabel='Mascota';
     $zvalue=$pcnt;
     $zlist='dl_pcnt';
     include('ele_input.php');
}
     
if(1==2)     
if($empr0['empr_automotriz']==1)     
{
     $zobj=4;
     $zid='vhcl';
     $ztabla='vhcl';
     $zlabel='Vehiculo';
     $zvalue=$vhcl;
     include('ele_input.php');
}
     
     
// $zobj=1;     
// include('ele_break.php');

if($empr0['empr_codigo']=='pcs1')
{
     $zobj=4;
     $zid='cntn';
     $ztabla='cntn';
     $zlabel='Contenedor';
     $zvalue=$cntn;
     include('ele_input.php');    
     
     $zobj=4;
     $zid='cntnf1';
     $ztype='date';
     $zlabel='Desde';
     $zvalue=$cntnf1;
     $zmin=date('Y-m-01',strtotime('-1 month'));
     $zmax=date('Y-m-t',strtotime('+1 month'));
     include('ele_input.php');    
     
     $zobj=4;
     $zid='cntnf2';
     $ztype='date';
     $zlabel='Hasta';
     $zvalue=$cntnf2;
     $zmin=date('Y-m-01',strtotime('-1 month'));
     $zmax=date('Y-m-t',strtotime('+1 month'));
     include('ele_input.php');    
     
     $cant=1;
     $zobj=4;
     $zid='envio';
     $zlabel='Envio';
     $zvalue=$envio;
     $zdefa=0;
     $zmin=0;
     $zmax=99;
//      $zmaxlen=7;
     $zwidth=5;
     $zclass='numeric-dec';
//      $zonchange='calc_subtot();';
//      $zonblur='calc_subtot();';
     include('ele_input.php');
     
}
     
     
     
     
if($tpos==9)
{
     $zid='dl_detalle';
     $zdocu=$docu;
     $zcolu='detalle';
     include('ele_datalist.php');
}
     
     
     
$zobj=4;
$zid='detalle';
$zlabel='Notas';
$zwidth=25;    
$zrows=2;     
$zvalue=$detalle;
if($tpos==1){$zhide=1;}
if($tpos==2){$zhide=1;}
if($tpos==9){$zlist='dl_detalle'; $zrows=1;}     
     
include('ele_input.php');
     
     
}

     
    
     

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

}
     
// TITULO     
     
     

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

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

// COBRO
$sty_pago='float:right;';
if($tpos==3){$sty_pago.='display:none;';}
if($tpos==9){$sty_pago.='display:none;';}
echo '<span noprint style="'.$sty_pago.'"  >';
if(1==2)
{
     $zalign='right';
     $zid='efectivo';
     $zlabel='💵 Efectivo';
     $zvalue=$efectivo;
     $zmin=0;
     $zmax=99999;
     $zwidth=5;
     $zclass='numeric-dec';
//      $zonchange='calc_subtot();';
     if(!empty($numero))
     {
          $zsave=1;
          $zsavet=$modu;
          $zsavei=$idnum1;
          $zsavef=$zid;
//           $zonblur='{save_data(event,this.id);}';
//           $zonblur='{document.getElementById("item").value=""; save_docu(event);}';
     }
     include('ele_input.php');
     
     $zobj=1;
     $zalign='right';
     $zid='caja';
     $zlabel='Caja';
     $ztabla='caja';
     $zvalue=$caja;
     $zdefa=$caja;
//      if(empty($zvalue)){$zvalue=$ptoe;$zdefa=$ptoe;}
     if($tpos==2){$zvalue=$ptoe; $zhide=1;}
     include('ele_select.php');

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

     $zalign='right';
     $zid='tarjeta';
     $zlabel='💳 Tarjeta';
     $zvalue=$tarjeta;
     $zmin=0;
     $zmax=99999;
     $zwidth=5;
     $zclass='numeric-dec';
//      $zonchange='{calc_subtot();}';
     if(!empty($numero))
     {
          $zsave=1;
          $zsavet=$modu;
          $zsavei=$idnum1;
          $zsavef=$zid;
     }
     include('ele_input.php');
     

     $zobj=1;
     $zalign='right';
     $zid='numvou';
     $zlabel='# Voucher';
     $zvalue=$nume_vouc;
     $zmin=0;
     $zmax=999999999;     
     $zclass='numeric-int';
     if(!empty($numero))
     {
          $zsave=1;
          $zsavet=$modu;
          $zsavei=$idnum1;
          $zsavef=$zid;
//           $zonblur='{save_data(event,this.id);}';
//           $zonblur='{document.getElementById("item").value=""; save_docu(event);}';
     }
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');
     
     
//      $zobj=4;
     $zalign='right';
     $zid='credito';
     $zlabel='✍ Crédito ';
     $zvalue=$credito;
     $zmin=0;
     $zmax=99999;
     $zwidth=5;
     $zclass='numeric-dec';
     $zonchange='{calc_subtot();}';
//      $zonblur='calc_subtot();';
     if(!empty($numero))
     {
          $zsave=1;
          $zsavet=$modu;
          $zsavei=$idnum1;
          $zsavef=$zid;
//           $zonblur='{save_data(event,this.id);}';
//           $zonblur='{document.getElementById("item").value=""; save_docu(event);}';
     }
     include('ele_input.php');
     
     $zobj=1;     
     include('ele_break.php');

//      $zlabel='💲🪙🔂 Cambio ';
     $zalign='right';
     $zid='cambio';
     $zlabel='🪙  Cambio ';
     $zmin=0;
     $zmax=99999;
     $zwidth=8;
     $zclass='numeric-dec';
     $zreado=1;
     include('ele_input.php');


}
echo '</span>';



// RESULTADO
$sty_resu='float:right;';
$sty_resu='margin:0 auto;';
echo '<span id="main2" style="'.$sty_resu.'"  >';
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:1em;"></div>';     


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

$zobj=1;
$zid='cstock';
$zlabel='Consulta Stock';
$zwidth=25;         
$zvalue='';
$zonenter='{fn_stock();}';
$zonblur='{fn_stock();}';
if($tpos==1){$zhide=1;}
if($tpos==9){$zhide=1;}
if(substr($docu,0,2)=='NC'){$zhide=1;}
$zhide=1;
include('ele_input.php');

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

     $div=$dom_div->appendChild($dom_div->createElement("div",""));
          $div->setAttribute("id","divextra1");
          $div->setAttribute("align","center");
          $div->setAttribute("height","auto");
          $div->setAttribute("unselectable","on");
          $div->setAttribute("onmousedown","return false;");
          $div->setAttribute("onselecstart","return false;");
          $div->setAttribute("style","margin-top:0em;");
echo $dom_div->saveHTML();



echo '<div style="clear:both;">&#127380; : '.$idnum1.'</div>';
// echo 'CA:'.$data_head['claveacc'];
     


?>

<script>
function fn_stock(event)
{
     var busca,xsrc='?';
     busca=document.getElementById('cstock').value;
     document.getElementById('divextra1').innerHTML='';
     if(busca.length>3)
     {
          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('zhidehead','1');
          datapost.append('item',busca);
          dato=exe_ajax(datapost,'divextra1','',true);
     
     }
     
}
</script>

<script>
function fn_consulta(event)
{
     var xhref='',dataget;
     xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';
     
     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=parseFloat(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';}
     }

     

}
</script>

<script>document.title="<?php echo $xtitle;?>"</script>
<script>document.getElementById('topcenter').innerHTML="<?php echo $xtopcenter;?>"</script>

<script>
function set_via()
{
     var medicamento=document.getElementById('medicamento').value.toUpperCase();
     if(medicamento.includes('TABLETA')){document.getElementById('via').value='ORAL';}
     if(medicamento.includes('COMPRIMIDO')){document.getElementById('via').value='ORAL';}
     if(medicamento.includes('SUSPENSION')){document.getElementById('via').value='ORAL';}
     if(medicamento.includes('CAPSULA')){document.getElementById('via').value='ORAL';}
     
     return;
}
</script>

<script>
function send_wsapp(wsapp='')
{
     var url='',texto='',phone='',link='';
     link='https://<?php echo strtolower($empr0['empr_codigo']); ?>.vcrxol.com/index3.php?scri=info_docu3&prnt=1';
     link=link+'&clave='+'<?php echo $claveacc; ?>';
     
     if(document.getElementById('wsapp'))
     {
          wsapp=document.getElementById('wsapp').value;
          if(wsapp==='')
          {
               var mensaje='';
               mensaje=mensaje+'<result>';
               mensaje=mensaje+'<text>Digite Número</text>';
               mensaje=mensaje+'</result>';
               swal_fire(mensaje);
               return;
          }

          if(wsapp.length<10)
          {
               var mensaje='';
               mensaje=mensaje+'<result>';
               mensaje=mensaje+'<text>Número Incompleto</text>';
               mensaje=mensaje+'</result>';
               swal_fire(mensaje);
               return;
          }
          
          wsapp.substring(wsapp.length-10);
          wsapp=String(wsapp).padStart(10, '0');

          phone='593';
          phone='593'+wsapp;
          
          
     }
     
     
     
     {
//      var eol='%0A';
     var eol='\r\n';
     texto ='*= COMPROBANTE ELECTRONICO =*';
     texto+=eol;
     texto+=eol;
     texto+='📃 Tipo  : '+'<?php echo $docu0['docu_descri']; ?>'+' ';
     texto+=eol;
     texto+='🏢 Emisor : '+'<?php echo $empr0['empr_ruc'].' - '.$empr0['empr_descri']; ?>'+' ';
     texto+=eol;
     texto+='👤 Cliente : '+'<?php echo $enti.' - '.ucwords($enti0['enti_descri']) ; ?>'+' ';
     texto+=eol;
     texto+='📆 Fecha : '+'<?php echo $fecha; ?>'+' ';
     texto+=eol;
     texto+='№ : *'+'<?php echo $ptoe.'-'.$numero; ?>'+'* ';
     texto+=eol;
     texto+='💲 Valor : '+'<?php echo number_format($total,2); ?>'+' ';
     texto+=eol;
     texto+='🔑 Clave : '+'<?php echo $claveacc; ?>'+' ';
     texto+=eol;
     texto+='🔗 Link : '+link;
          
     texto=encodeURIComponent(texto);
//      texto=encodeURI(texto);
     }
     
     url=url+'https://api.whatsapp.com/send/';
     url=url+'?phone='+phone;
     url=url+'&text='+texto;
     window.open(url,'_blank');
}
</script>



<script>document.getElementById('enti').focus();</script>

<?php if(!empty($idnum1)){ ?>
<script>document.getElementById('item').focus();</script>
<?php } ?>
<?php if($tpos==1){ ?>
<!-- <script>document.getElementById('item').value='';</script> -->
<?php } ?>



<script>
    
window.onload = function ()
{
    var xhref=location.href;
      
    if(xhref.indexOf('demo')>=0)
    {window.location='https://www.ecuamedico.com';}
}
</script>

<!-- <script>set_noback();</script> -->
<!-- <script>window.onbeforeunload = function(){return 'Are you sure you want to leave?';};</script> -->

