<?php
// session_start();
// foreach($_GET  as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}  
// foreach($_POST as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}

// include_once('lib_main.php');
// if(!empty($empr)){$link_data=msql_connect('','','',$empr); $cfg_empr=$empr;}

// $emis0=data_maes('enti',$cfg_ruc);
// var_dump($_SERVER);
// getcwd();
// echo dirname(__DIR__);

$eol="\r\n";  
$xbgcolor1='snow';
$xbgcolor2='gainsboro';
$xbgcolor3='#f0f0f0';

msql_data_seek($res_info1);
msql_data_seek($res_info2);

$aso_info1=msql_fetch_assoc($res_info1);


$emis0=data_maes('enti',$empr0['empr_ruc']);
$adqu0=data_maes('enti',$aso_info1['enti']);
$fpag0=data_maes('fpag',$aso_info1['fpag']);
$iuser0=data_maes('user',$aso_info1['iuser']);
     
if($empr0['empr_ceuser']==1)
{$emis0=data_maes('enti',$iuser0['user_cedula'].'001');}

// echo '*/*/*/'.$aso_info1['docu'].$aso_info1['idnum1'];
$claveacc=gen_clac($aso_info1['docu'],$aso_info1['idnum1']);
$barcode=gen_barcode($claveacc);

// $barcode=gen_barcode($aso_info1['claveacc']);


$href_html='/docu/'.$claveacc.'.html';
$file_html='../'.$cfg_empr.$href_html;




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

//                $urlpdf='https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
          $urlpdf ='https://'.$_SERVER['HTTP_HOST'];
          $urlpdf.='/docu/'.$claveacc.'.html';
          $apykey='k3JVqx9ndmFOPOJHOePrcA9jeWehqUruWDgiOKCXtVe0IyJJ1U6tci6vhXzpiv6J';
          $abutton=$domg->appendChild($domg->createElement('a','PDF'));
               $abutton->setAttribute('href','https://api.html2pdf.app/v1/generate?url='.$urlpdf.'&apiKey='.$apykey);
               $abutton->setAttribute('noprinter','');
               $abutton->setAttribute('align-r',' ');
$html=$domg->saveXML();
// echo $html;





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


if(empty($ppsize)){$ppsize='A4';}
if($ppsize=='A4'){$ppwidth=210; $ppheight=297;}
if($ppsize=='A5'){$ppwidth=148; $ppheight=210;}
if($ppsize=='A6'){$ppwidth=105; $ppheight=148;}

if($ppsize=='A4H'){$ppwidth=297; $ppheight=210;}
if($ppsize=='A5H'){$ppwidth=210; $ppheight=148;}
if($ppsize=='A6H'){$ppwidth=148; $ppheight=105;}

if(substr($ppsize,0,1)!='A'){$ppwidth=80; $ppheight=105; $post=1;}

if($post==1){$xbgcolor2=$xbgcolor3;}



// <div class="col-md-12 text-center mt-5 mb-5 text-center" id="contenedor">
//   <a type="button" class="btn btn-success mb-3" id="crearpdf">Crear PDF</a>
//   <h1 class="text-center">El “Eng Metrics Dashboard” de Uber Para Medir La Productividad De Sus Ingenieros</h1>
//   <img src="https://blog.nubecolectiva.com/wp-content/uploads/2022/10/cimg_destacada_blog_devs-930x360.png" class="img-fluid pb-3">
//   <p class="texto"> El pasado Jueves 4 de Agosto de 2022, Uber la popular empresa proovedora de servicios de movilidad realizo el evento All-Hands. Este evento fue presentado por su actual CEO Dara Khosrowshahi (Hasta la fecha de este Post, es su actual CEO, pero en el futuro no sabemos quien tendrá el cargo) y presento datos interesantes y sobre como mide Uber la productividad de sus ingenieros o las tareas de ingenieria en la empresa, en este artículo te contaré sobre El “Eng Metrics Dashboard” de Uber Para Medir La Productividad De Sus Ingeniero... </p> Leer más: <a href="https://blog.nubecolectiva.com/el-eng-metrics-dashboard-de-uber-para-medir-la-productividad-de-sus-ingenieros/" target="_blank">https://blog.nubecolectiva.com/el-eng-metrics-dashboard-de-uber-para-medir-la-productividad-de-sus-ingenieros/</a>
// </div>


$page=$domg->appendChild($domg->createElement('div',''));
     $page->setAttribute('id','cele');
//      $page->setAttribute('id','contenedor');
//      $page->setAttribute('class','col-md-12 mt-5 mb-5 ');

     $page->setAttribute('date',date('Y-m-d'));
     $page->setAttribute('time1',date('H:i:s'));
//      $page->setAttribute('line-h100','');
     $xstyle='';
//      $xstyle.='width:'.$ppwidth.'mm;';
//      $xstyle.='all:unset;';
     $xstyle.='font-family:arial;';
     $xstyle.='font-size:12px;';
     $xstyle.='-webkit-print-color-adjust: exact;';
//      $xstyle.='border:solid 1px; ';
//      $xstyle.='border-color:red; ';
// $xstyle.='margin: 0;padding: 0;border: 0;font-size: 100%;font: inherit;vertical-align: baseline;';
     $page->setAttribute('style',$xstyle);
//      $page->setAttribute('style','-webkit-print-color-adjust: exact;');


     $xstyle='@media print{[noprinter]{display:none;}}';
     $style=$page->appendChild($domg->createElement('style',$xstyle));

     $xstyle='@media screen{[noscreen]{display:none;}}';
     $style=$page->appendChild($domg->createElement('style',$xstyle));

     $xstyle='@media screen{tr[name]:hover{background-color:lightblue !important;};}';
     $style=$page->appendChild($domg->createElement('style',$xstyle));

     $xstyle='table{cellspacing:3 !important;cellpadding:3 !important; border-collapse:collapse;}';
     $style=$page->appendChild($domg->createElement('style',$xstyle));


//           $abutton=$page->appendChild($domg->createElement('a','PDF'));
//                $abutton->setAttribute('type','button');
//                $abutton->setAttribute('class','btn btn-success mb-3');
//                $abutton->setAttribute('id','crearpdf');
//                $abutton->setAttribute('style','display:none;');


//      $head1=$page->appendChild($domg->createElement('div',' '));
//           $xstyle='';
// //           $xstyle.='position:fixed;top:0;width:100%;';
//           $xstyle.='border-top:solid 1px;';
//           $xstyle.='border-bottom:solid 1px;';
//           $xstyle.='text-align:center;';
//           $xstyle.='font-weight:bold;';
// //           $xstyle.='letter-spacing:5pt;';
//           $xstyle.='padding:0em;';
//           $xstyle.='background:'.$xbgcolor2.';';
//           $head1->setAttribute('style',$xstyle);

//           $tablh=$head1->appendChild($domg->createElement('table',''));
          $tablh=$page->appendChild($domg->createElement('table',''));
               $tablh->setAttribute("width",'100%');
               $tablh->setAttribute("align",'center');

          $xstyle='';
//           $xstyle.='position:fixed;top:0;width:100%;';
          $xstyle.='border-top:solid 1px;';
          $xstyle.='border-bottom:solid 1px;';
          $xstyle.='text-align:center;';
          $xstyle.='font-weight:bold;';
          $xstyle.='padding:0em;';
          $xstyle.='background:'.$xbgcolor2.';';
          $xstyle.='border-collapse:collapse;';
          $tablh->setAttribute('style',$xstyle);



               if(empty($post))
              {
               $trow=$tablh->appendChild($domg->createElement('tr',''));
               $tcol=$tablh->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute("width",'20%');
               $tcol=$tablh->appendChild($domg->createElement('td','COMPROBANTE - ELECTRONICO'));
                    $tcol->setAttribute("width",'60%');
                    $tcol->setAttribute("style","letter-spacing:5pt;");
               $tcol=$tablh->appendChild($domg->createElement('td',));
                    $tcol->setAttribute("width",'20%');
                    $tcol->setAttribute("align",'right');
                    $tcol->setAttribute("style",'font-size:0.6em; margin:0px;');
                    $div=$tcol->appendChild($domg->createElement('span','REGISTRO : '.$iuser0['user_descri']));
                    $div=$tcol->appendChild($domg->createElement('div',' '));
                    $div=$tcol->appendChild($domg->createElement('span',date('d/M/y H:i:s',$docu1['idate'])));

               }


               if($post==1)
               {
               $trow=$tablh->appendChild($domg->createElement('tr',''));
               $tcol=$tablh->appendChild($domg->createElement('td',));
                    $tcol->setAttribute("align",'right');
                    $tcol->setAttribute("style",'font-size:0.6em; margin:0px;');
                    $div=$tcol->appendChild($domg->createElement('span','REGISTRO : '.$iuser0['user_descri']));
                    $div=$tcol->appendChild($domg->createElement('span',' - '));
                    $div=$tcol->appendChild($domg->createElement('span',date('d/M/y H:i:s',$docu1['idate'])));
                    
                    
               $trow=$tablh->appendChild($domg->createElement('tr',''));
               $tcol=$tablh->appendChild($domg->createElement('td','COMPROBANTE - ELECTRONICO'));
                    $tcol->setAttribute("style","letter-spacing:3pt;");
                    
                    
               }



     $tabl1=$page->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:12px;';
               $tabl1->setAttribute('style',$xstyle);
               $tabl1->setAttribute('width','100%');
//                $tabl1->setAttribute('valign','top');
//                $tabl1->setAttribute('border','1');

//           $trow=$tabl1->appendChild($domg->createElement('tr',''));


     $foot1=$page->appendChild($domg->createElement('div',''));
          $xstyle='';
//           $xstyle.='margin-top:15mm;';
//           $xstyle.='position:fixed;bottom:0;width:100%;';
          $xstyle.='border-top:solid 1px;';
          $xstyle.='border-bottom:solid 1px;';
          $xstyle.='font-weight:bold;';
          $xstyle.='background:'.$xbgcolor2.';';
          $foot1->setAttribute('style',$xstyle);

          $tablf=$foot1->appendChild($domg->createElement('table',''));
               $tablf->setAttribute("width",'100%');
          $trow=$tablf->appendChild($domg->createElement('trow',''));
          $tcol=$tablf->appendChild($domg->createElement('td','&#127380; : '.$docu1['idnum1']));
               $tcol->setAttribute("width",'50%');
          $tcol=$tablf->appendChild($domg->createElement('td',''));
               $tcol->setAttribute("align",'right');
               $tcol->setAttribute("style",'font-size:0.6em');
               $div=$tcol->appendChild($domg->createElement('span','IMPRESO : '.$user0['user_descri']));
               $div=$tcol->appendChild($domg->createElement('span',' '));
               if(empty($post))
               {$div=$tcol->appendChild($domg->createElement('div',''));}
               $div=$tcol->appendChild($domg->createElement('span',date('d/M/y H:i:s')));




          $thead=$tabl1->appendChild($domg->createElement('thead',''));
          $tbody=$tabl1->appendChild($domg->createElement('tbody',''));
          $tfoot=$tabl1->appendChild($domg->createElement('tfoot',''));

//           $trowh=$thead->appendChild($domg->createElement('tr',''));
//           $trowb=$tbody->appendChild($domg->createElement('tr',''));
//           $trowf=$tfoot->appendChild($domg->createElement('tr',''));

          if(empty($post))
          {
               $trowh=$thead->appendChild($domg->createElement('tr',''));
               $trowb=$tbody->appendChild($domg->createElement('tr',''));
               $trowf=$tfoot->appendChild($domg->createElement('tr',''));
               
               $tcol=$trowh->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','vertical-align:top;');
                    $tcol->setAttribute('width','60%');
               $logo=$tcol->appendChild($domg->createElement('div',''));
               $emis=$tcol->appendChild($domg->createElement('div',''));
               $adqu=$tcol->appendChild($domg->createElement('div',''));
               $adic=$tcol->appendChild($domg->createElement('div',''));

               $tcol=$trowh->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','vertical-align:top;');
                    $tcol->setAttribute('width','40%');
               $barc=$tcol->appendChild($domg->createElement('div',''));
               $dato=$tcol->appendChild($domg->createElement('div',''));
               $resu=$tcol->appendChild($domg->createElement('div',''));
               $fpag=$tcol->appendChild($domg->createElement('div',''));

               $tcol=$trowb->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('colspan','2');
                    $tcol->setAttribute('style','vertical-align:top;');
               $deta=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('colspan','2');
                    $tcol->setAttribute('style','vertical-align:top;');
               $nota=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','vertical-align:top;');
               $nlet=$tcol->appendChild($domg->createElement('div',''));
               
          }

          if($post==1)
          {
               $trowh=$tbody->appendChild($domg->createElement('tr',''));
               $trowb=$tbody->appendChild($domg->createElement('tr',''));
               $trowf=$tbody->appendChild($domg->createElement('tr',''));
               
               $tcol=$trowh->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','vertical-align:top;');
               $logo=$tcol->appendChild($domg->createElement('div',''));
               $barc=$tcol->appendChild($domg->createElement('div',''));
               $emis=$tcol->appendChild($domg->createElement('div',''));
               $adqu=$tcol->appendChild($domg->createElement('div',''));
               $adic=$tcol->appendChild($domg->createElement('div',''));
               $dato=$tcol->appendChild($domg->createElement('div',''));
               $resu=$tcol->appendChild($domg->createElement('div',''));
               $fpag=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowb->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','vertical-align:top;');
               $deta=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               $nlet=$tcol->appendChild($domg->createElement('div',''));
               $nota=$tcol->appendChild($domg->createElement('div',''));
               
          }

          $xstyle1='';
          $xstyle1.='margin-top:1mm;';
//           $xstyle1.='margin-left:0.5mm;';
//           $xstyle1.='border:solid 1px;';
          $logo->setAttribute('style',$xstyle1);
          $barc->setAttribute('style',$xstyle1);

          $xstyle1='';
          $xstyle1.='margin-top:1mm;';
//           $xstyle1.='margin-left:0.5mm;';
          $emis->setAttribute('style',$xstyle1);
          $adqu->setAttribute('style',$xstyle1);
          $dato->setAttribute('style',$xstyle1);
          $resu->setAttribute('style',$xstyle1);
          $adic->setAttribute('style',$xstyle1);
          $fpag->setAttribute('style',$xstyle1);
          $deta->setAttribute('style',$xstyle1);
          $nota->setAttribute('style',$xstyle1);
          $nlet->setAttribute('style',$xstyle1);


          // LOGO
{
          $ttbl=$logo->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','center');
          $ahref=$tcol->appendChild($domg->createElement('a',''));
               $ahref->setAttribute('href','https://'.strtolower($empr0['empr_codigo']).'.vcrxol.com/index3.php?scri=info_docu3&prnt=1&pgsize='.$pgsize.'&clave='.$aso_info1['claveacc']);
          $imag=$ahref->appendChild($domg->createElement('img',''));
               $imag->setAttribute('src','https://vcrxol.com/_logo/logo'.strtolower($empr0['empr_codigo']).'2.png');
               $imag->setAttribute('style','max-width:100%; max-height:20mm;');
}

          // BARCODE
{
          $ttbl=$barc->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');


          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','center');
          $ahref=$tcol->appendChild($domg->createElement('a',''));
               $ahref->setAttribute('href','https://'.strtolower($empr0['empr_codigo']).'.vcrxol.com/index3.php?scri=info_docu3&prnt=1&clave='.$aso_info1['claveacc']);
          $imag=$tcol->appendChild($domg->createElement('img',''));
               $imag->setAttribute('src','https://vcrxol.com/-bcode/'.$aso_info1['claveacc'].'.jpg');
               $imag->setAttribute('style','max-width:100%; max-height:20mm;');
     
     
}

          // EMISOR
{
          $ttbl=$emis->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');

          $tgrp=$ttbl->appendChild($domg->createElement('colgroup',''));
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');


          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('th','EMISOR'));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:1em;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','RUC / CI'));
          $tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_codigo']));
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('style','font-weight:bold;text-transform: uppercase;');
          $tcol=$trow->appendChild($domg->createElement('td','RAZ.SOCIAL'));
          $tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_razsoc']));
     
          if(!empty($emis0['enti_nomcom']) and $emis0['enti_nomcom']!=$emis0['enti_razsoc'])
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','NOM.COMERCIAL'));
          $tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_nomcom']));
          }
     
          $tipo_contrib='';
          if($emis0['enti_obcon']==1){$tipo_contrib='OBLIGADO CONTABILIDAD';}
          if($emis0['enti_rimpe']==1){$tipo_contrib='RIMPE EMPRENDEDOR';}
          if($emis0['enti_rimpe']==2){$tipo_contrib='RIMPE NEGOCIO POPULAR';}
          if(!empty($tipo_contrib))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','CONTRIBUYENTE'));
               $tcol=$trow->appendChild($domg->createElement('td',$tipo_contrib));
          }
          if($emis0['enti_agret']==1){$agen_reten='AGENTE DE RETENCION';}
          if(!empty($agen_reten))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','CONTRIBUYENTE'));
               $tcol=$trow->appendChild($domg->createElement('td',$agen_reten));
          }
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','MATRIZ'));
          $tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_matriz']));
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','TELEFONO'));
//           $tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_telefono']));

          $wsappnum=$emis0['enti_wsapp'];
          if(empty($wsappnum))
          {$wsappnum=$emis0['enti_telefono'];}
          $walink='https://'.strtolower($empr0['empr_codigo']).'.vcrxol.com/?scri=info_docu3&prnt=1&clave='.$claveacc;
          $walink=urlencode($walink);
     
          $tcol=$trow->appendChild($domg->createElement('td',' '));
               $tcol->appendChild($domg->createElement('span',$emis0['enti_telefono']));
               $tcol->appendChild($domg->createElement('span',' - '));
               $wsapp=$tcol->appendChild($domg->createElement('a',$wsappnum));
               $wsapp->setAttribute('href','https://api.whatsapp.com/send/?phone=593'.$wsappnum.'&text='.$walink.'');
               $wsapp->setAttribute('target','_blank');

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','E-MAIL'));
          $tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_email'].','.$emis0['enti_emailce']));
}

          // ADQUIRIENTE
{
          $ttbl=$adqu->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='border-spacing:10px;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');

          $tgrp=$ttbl->appendChild($domg->createElement('colgroup',''));
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');


          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','ADQUIRIENTE'));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:3pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','RUC / CI'));
          $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_codigo']));
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('style','font-weight:bold; text-transform: uppercase;');
          $tcol=$trow->appendChild($domg->createElement('td','RAZ.SOCIAL'));
          $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_razsoc']));
     
          if(!empty($adqu0['enti_nomcom']) and $adqu0['enti_nomcom']!=$adqu0['enti_razsoc'])
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','NOM.COMERCIAL'));
          $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_nomcom']));
          }
               
          $tipo_contrib='';
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          if($adqu0['enti_obcon']==1){$tipo_contrib='OBLIGADO CONTABILIDAD';}
          if($adqu0['enti_rimpe']==1){$tipo_contrib='RIMPE EMPRENDEDOR';}
          if($adqu0['enti_rimpe']==2){$tipo_contrib='RIMPE NEGOCIO POPULAR';}
          if(!empty($tipo_contrib))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','CONTRIBUYENTE'));
               $tcol=$trow->appendChild($domg->createElement('td',$tipo_contrib));
          }
     
     
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','MATRIZ'));
          $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_matriz']));
     
//           $trow=$ttbl->appendChild($domg->createElement('tr',''));
//           $tcol=$trow->appendChild($domg->createElement('td','TELEFONO'));
//           $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_telefono']));

     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','TELEFONO'));
     
          $wsappnum=$adqu0['enti_wsapp'];
          if(empty($wsappnum))
          {$wsappnum=$adqu0['enti_telefono'];}
          $walink='https://'.strtolower($empr0['empr_codigo']).'.vcrxol.com/?scri=info_docu3&prnt=1&clave='.$claveacc;
          $walink=urlencode($walink);
     
          $tcol=$trow->appendChild($domg->createElement('td',' '));
               $tcol->appendChild($domg->createElement('span',$adqu0['enti_telefono']));
               $tcol->appendChild($domg->createElement('span',' - '));
               $wsapp=$tcol->appendChild($domg->createElement('a',$wsappnum));
               $wsapp->setAttribute('href','https://api.whatsapp.com/send/?phone=593'.$wsappnum.'&text='.$walink.'');
               $wsapp->setAttribute('target','_blank');
     
     
     
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','E-MAIL'));
          $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_email'].','.$adqu0['enti_emailce']));
}

          // DATOS COMPROBANTE
{
          $ttbl=$dato->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='cellpadding:5px;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');

          $tgrp=$ttbl->appendChild($domg->createElement('colgroup',''));
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');


          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','DATOS DEL COMPROBANTE'));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:0em;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','TIPO :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['docu_descri']));
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('style','font-weight:bold; ');
          $tcol=$trow->appendChild($domg->createElement('td','NUMERO :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['ptoe'].'-'.$aso_info1['numero']));
               $tcol->setAttribute('style','font-size:150%;');

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','FECHA :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['dia_des'].' '.strtoupper($aso_info1['dmy1'])));
     
          if(!empty($aso_info1['vndd']))
          {
               $vndd_descri=$aso_info1['vndd'].' /'.ucwords(strtolower($aso_info1['vndd_descri']));
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','VENDEDOR :'));
                    $xstyle='text-align:right;';
                    $tcol->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td',$vndd_descri));
          }
     
          
//           if($aso_info1['ptov_ambice']==1){$ambice='PRUEBA';}
//           if($aso_info1['ptov_ambice']==2){$ambice='PRODUCCION';}
          if($aso_info1['ambice']==1){$ambice='PRUEBA';}
          if($aso_info1['ambice']==2){$ambice='PRODUCCION';}
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               if($aso_info1['ambice']==1){$xstyle='color:darkred; font-weight:bold;';}
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','AMBIENTE :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('size80','');
          $tcol=$trow->appendChild($domg->createElement('td',$ambice));


     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','CLAVE ACCESO :'));
               $xstyle='text-align:right;font-size:80%;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',' '));
               $clave=$tcol->appendChild($domg->createElement('div',$aso_info1['claveacc1']));
               $clave2=$tcol->appendChild($domg->createElement('div',$aso_info1['claveacc2']));
                    $xstyle='font-size:90%;';
                    $tcol->setAttribute('style',$xstyle);
                    $clave->setAttribute('noprinter','');
                    $clave2->setAttribute('noscreen','');
     
     
          if(mb_stristr('XO',$aso_info1['status']))
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','STATUS :'));
               $xstyle='text-align:right;font-size:80%;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['stat_descri']));
                    $tcol->setAttribute('style','background:darkred;color:white;font-weight:bold');
          }
     
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               $trow->setAttribute('style',$xstyle);
               $trow->setAttribute('noprinter','');
          $tcol=$trow->appendChild($domg->createElement('td','DESCARGAR :'));
               $xstyle='text-align:right;font-size:80%;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',' '));
               $tcol->setAttribute('align','center');
               $xml_l=$tcol->appendChild($domg->createElement('a','XML'));
               $span=$tcol->appendChild($domg->createElement('span',' - '));
               $xml_2=$tcol->appendChild($domg->createElement('a','SIGN'));
               $span=$tcol->appendChild($domg->createElement('span',' - '));
               $htm_l=$tcol->appendChild($domg->createElement('a','HTML'));
               $span=$tcol->appendChild($domg->createElement('span',' - '));
               $pdf_l=$tcol->appendChild($domg->createElement('a','PDF'));
//                     $xml_l->setAttribute('href','https://vcrxol/'.$empr0['empr_codigo'].'/');
                    $xml_l->setAttribute('href','https://vcrxol.com/_cele/'.substr($claveacc,4,4).substr($claveacc,2,2).'/'.$claveacc.'b.xml');
//                     $xml_l->setAttribute('download','');
                    $xml_l->setAttribute('target','_blank');
                    $xml_2->setAttribute('href','https://vcrxol.com/_cele/'.substr($claveacc,4,4).substr($claveacc,2,2).'/'.$claveacc.'.xml');
//                     $xml_2->setAttribute('download',$claveacc.'.xml');
                    $xml_2->setAttribute('target','_blank');
                    $htm_l->setAttribute('href','https://vcrxol.com/'.strtolower($empr0['empr_codigo']).'/docu/'.$claveacc.'.html');
//                     $htm_l->setAttribute('download',' ');
                    $htm_l->setAttribute('target','_blank');
                    $pdf_l->setAttribute('href','https://vcrxol.com/_lib/crea_html2pdf.php?desti=2&empr='.strtolower($empr0['empr_codigo']).'&clave='.$claveacc.'');
//                     $htm_l->setAttribute('download',' ');
                    $htm_l->setAttribute('target','_blank');

     
}

          // RESUMEN
{
          $ttbl=$resu->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='cellpadding:5px;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');

          $tgrp=$ttbl->appendChild($domg->createElement('colgroup',''));
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');


          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','RESUMEN'));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:1em;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);

          if(mb_stristr('guia',$modu))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','UNIDADES :'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tcant'],2)));
          }
     
     
          if(mb_stristr('vtas.clie.carr.comp.prov.',$modu))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','UNIDADES :'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tcant'],2)));

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','SUB-TOTAL :'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tsubt'],2)));


               if($aso_info1['tdcto']>0)
               {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
     //                $xstyle='text-align:right; font-style:italic;';
                    $xstyle='text-align:right; text-decoration:underline;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','DESCUENTO :'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tdcto'],2)));

               }

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','Sub-Total IVA 0%'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['subtiva0'],2)));

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','Sub-Total IVA 12%'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['subtiva'],2)));

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right; font-style:italic;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','IVA 12%'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tiva'],2)));
                    $xstyle='font-style:italic;';
                    $tcol->setAttribute('style',$xstyle);

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $xstyle.='font-weight:bold;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','TOTAL :'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['total'],2)));
                    $xstyle='font-size:150%;';
                    $tcol->setAttribute('style',$xstyle);
               }
     
     

     
}

          // INFORMACION ADICIONAL
{
          $ttbl=$adic->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='cellpadding:5px;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');

          $tgrp=$ttbl->appendChild($domg->createElement('colgroup',''));
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');
               $tcol=$tgrp->appendChild($domg->createElement('col',''));
               $tcol->setAttribute('style','background-color:;');


          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','INFORMACION ADICIONAL'));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:2pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);

     
          if(!empty($aso_info1['concepto']))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','CONCEPTO'));
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['concepto']));
          }
     
     
     
     

     
}

          // FORMA DE PAGO
{
          $ttbl=$fpag->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');

     
          if(mb_stristr('vtas.comp',$modu))
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','FORMA DE PAGO'));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:2pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['fpag'].' - '.$fpag0['fpag_descri']));
               $xstyle='text-align:center;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['total'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          }
}

          // NOTAS
{
          $ttbl=$nota->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','NOTAS'));
//                $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:2pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.'; border-top:solid 2px; border-bottom:solidd 2px;';
               $tcol->setAttribute('style',$xstyle);

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('noprinter','');
               $sri=$tcol->appendChild($domg->createElement('span','Mas información en :'));
//                     $sri->setAttribute('noprinter','');
               $sri=$tcol->appendChild($domg->createElement('a','PORTAL S.R.I.'));
//                     $sri->setAttribute('noprinter','');
                    $sri->setAttribute('target','_blank');
                    $sri->setAttribute('href','https://www.sri.gob.ec/web/guest/facturacion-electronica');
                    $tcol->appendChild($domg->createElement('span',' / '));
               $sri=$tcol->appendChild($domg->createElement('a','VALIDADOR S.R.I.'));
//                     $sri->setAttribute('noprinter','');
                    $sri->setAttribute('target','_blank');
                    $sri->setAttribute('href','https://srienlinea.sri.gob.ec/comprobantes-electronicos-internet/publico/validezComprobantes.jsf');
     
}

          // NUM LETRAS

{
          $ttbl=$nlet->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');

          if($aso_info1['total']!=0)
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','SON : '.num2let(number_format($aso_info1['total'],2))));
//                $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='text-align:right;font-weight:bold;';
//                $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
          }

}




          // DETALLE
{
          $ttbl=$deta->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='font-size:12px;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');

          $tcolg=$ttbl->appendChild($domg->createElement('colgroup',''));
          $thead=$ttbl->appendChild($domg->createElement('thead',''));
          $tbody=$ttbl->appendChild($domg->createElement('tbody',''));
          $tfoot=$ttbl->appendChild($domg->createElement('tfoot',''));
     
          $trow=$thead->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','DETALLE'));
               $tcol->setAttribute('colspan','20');
               $xstyle='';    
               $xstyle.='letter-spacing:5pt;text-align:;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
     

     
          $clin=1;
          if(mb_stristr('vtas.clie.carr.comp.prov.',$modu))
          {
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $trowh=$thead->appendChild($domg->createElement('tr',''));
                    $trowh->setAttribute('valign','top');
                    $trowh->setAttribute("style",$style);
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $trowf=$tfoot->appendChild($domg->createElement('tr',''));
                    $trowf->setAttribute('valign','top');
                    $trowf->setAttribute("style",$style);
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute("style",'align:center;');
                    $colg->setAttribute("style",'background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','ITEM'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','DESCRIPCION'));
                    $tcol->setAttribute("style",'letter-spacing:3pt;');
               $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
                    $tcol->setAttribute("style",'letter-spacing:3pt;');    
                    $tcol->setAttribute("align",'center');

               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute("style",'background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','CANT'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tcant'],$aso_info1['item_duni'])));
                    $tcol->setAttribute("align",'right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','UNIT.'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute("style",'background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','SUBT.'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tsubt'],2)));
                    $tcol->setAttribute("align",'right');
               
               if($aso_info1['tdcto']>0)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','DCTO.'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tdcto'],2)));
                    $tcol->setAttribute("align",'right');
                    $tcol->setAttribute("style",'text-decoration:underline;');
               }
               
               if($aso_info1['tiva']>0)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','IVA'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tiva'],2)));
                    $tcol->setAttribute("align",'right');
                    $xstyle='font-style:italic;';
                    $tcol->setAttribute('style',$xstyle);
                    
               }
               
               
               if($aso_info1['tice']>0)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','ICE'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tice'],2)));
                    $tcol->setAttribute("align",'right');
               }
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $colg->setAttribute("style",'background-color:#e8e8e8;');
               $colg->setAttribute("style",'background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','TOTAL'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['total'],2)));
                    $tcol->setAttribute("align",'right');

               if($aso_info1['lote_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute("style",'font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','LOTE'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }

           
               msql_data_seek($res_info2);
               while($aso_info2=msql_fetch_assoc($res_info2))
               {
                    $item_descri=$aso_info2['item_descri'];
                    $item_codigo=$aso_info2['item'];
                    if($empr0['empr_codigo']=='IMCP')
                    {$item_descri=$aso_info2['item_descri2'];}
                    if(empty($item_descri))                    
                    {$item_descri=$aso_info2['item_descri'];}
                    if(substr($aso_info2['item'],0,4)=='9999')                    
                    {$item_descri=$aso_info2['detalle'];}
                    if($post==1){$item_codigo='';}
                    
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute("name",$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                    $tcol=$trow->appendChild($domg->createElement('td',$clin++));
                         $tcol->setAttribute("align",'center');
                    $tcol=$trow->appendChild($domg->createElement('td',$item_codigo));
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$item_descri));
// t                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['cant'],$aso_info2['item_duni'])));
                         $tcol->setAttribute("align",'right');
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['puni'],$aso_info2['item_dpre'])));
                         $tcol->setAttribute("align",'right');
                         if($aso_info2['item_dpre']>2)
                         {$tcol->setAttribute("style",'font-size:0.9em;');}
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['tsubt'],2)));
                         $tcol->setAttribute("align",'right');
                    if($aso_info1['tdcto']>0)
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['tdcto'],2)));
                         $tcol->setAttribute("align",'right');
                         $tcol->setAttribute("style",'text-decoration:underline;');
                    }
                    if($aso_info1['tiva']>0)
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['tiva'],2)));
                         $tcol->setAttribute("align",'right');
                         $xstyle='font-style:italic;';
                         $tcol->setAttribute('style',$xstyle);
                         
                    }
                    if($aso_info1['tice']>0)
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['tice'],2)));
                         $tcol->setAttribute("align",'right');
                    }
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['total'],2)));
                         $tcol->setAttribute("align",'right');
                    
                    if($aso_info1['lote_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['lote']));
                    }
//                          $tcol->setAttribute("align",'center');
               }

          }
     

          if(mb_stristr('guia',$modu))
          {
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $trowh=$thead->appendChild($domg->createElement('tr',''));
                    $trowh->setAttribute('valign','top');
                    $trowh->setAttribute("style",$style);
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $trowf=$tfoot->appendChild($domg->createElement('tr',''));
                    $trowf->setAttribute('valign','top');
                    $trowf->setAttribute("style",$style);
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute("style",'align:center;');
                    $colg->setAttribute("style",'background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','ITEM'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','DESCRIPCION'));
                    $tcol->setAttribute("style",'letter-spacing:3pt;');
               $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
                    $tcol->setAttribute("style",'letter-spacing:3pt;');    
                    $tcol->setAttribute("align",'center');

               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute("style",'background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','CANT'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tcant'],$aso_info1['item_duni'])));
                    $tcol->setAttribute("align",'right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','UNID.'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               

               if($aso_info1['lote_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute("style",'font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','LOTE'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }

           
               msql_data_seek($res_info2);
               while($aso_info2=msql_fetch_assoc($res_info2))
               {
                    $item_descri=$aso_info2['item_descri'];
                    $item_codigo=$aso_info2['item'];
                    if($empr0['empr_codigo']=='IMCP')
                    {$item_descri=$aso_info2['item_descri2'];}
                    if(empty($item_descri))                    
                    {$item_descri=$aso_info2['item_descri'];}
                    if(substr($aso_info2['item'],0,4)=='9999')                    
                    {$item_descri=$aso_info2['detalle'];}
                    if($post==1){$item_codigo='';}
                    
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute("name",$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                    $tcol=$trow->appendChild($domg->createElement('td',$clin++));
                         $tcol->setAttribute("align",'center');
                    $tcol=$trow->appendChild($domg->createElement('td',$item_codigo));
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$item_descri));
// t                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['cant'],$aso_info2['item_duni'])));
                         $tcol->setAttribute("align",'right');
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item_umdd']));
                         $tcol->setAttribute("align",'center');
                    
                    if($aso_info1['lote_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['lote']));
                    }
//                          $tcol->setAttribute("align",'center');
               }

          }
     
     
     
     

     
}

$html=$domg->saveHTML();
echo $html;

// $href_php_xls='/docu/'.$xlsf.'.php';
// // $href_php_xls='/docu/'.date('md_Hi').'.php';
// $file_php_xls='../'.$cfg_empr.$href_php_xls;
file_put_contents($file_html,$html);





return; 
?>


