<?php
declare(strict_types=0);

if($cfg_empr=='imcp')
{
//      $serie_lote=get_serie_lote($docu,$idnum);
     
//      $sql_updt='update bcos1 set caba2="C004" where idnum1="7651" ';
//      $res_updt=msql_query($sql_updt,$link_data);
     
//      $sql_updt='update bcos2 set ctas="" where idnum2="7651" ';
//      $res_updt=msql_query($sql_updt,$link_data);
     
//      $sql_updt='update bcos2 set docum="IE10" where idnum2="7751" ';
//      $res_updt=msql_query($sql_updt,$link_data);
     
}

// $post = point of sale ticket
// var_dump2($zreso);

// $fdoc=1;
// if($docu=='DA16')
// {if(empty($pgsize)){$pgsize='A4H';}}


// echo '<br>====='.vtas_ingr_difer($docu,$idnum);

$pgland=0;
if($pgsize=='A4H'){$pgland=1;}


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

$linxblock=5;
$numlin=0;
if($post==1){$linxblock=999999;}
if($modu=='rmed'){$linxblock=2;}
if($modu=='rmed'){$linxblock=1;}

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

$aso_info1=msql_fetch_assoc($res_info1);

$acce_user=accexuser($_SESSION['user_codigo'],$aso_info1['docu']);

// var_dump2($acce_user);

$emis0=data_maes('enti',$empr0['empr_ruc']);
// echo '/*/*'.$empr0['empr_ruc'];
// var_dump($emis0);
$adqu0=data_maes('enti',$aso_info1['enti']);
$fpag0=data_maes('fpag',$aso_info1['fpag']);
$suco0=data_maes('suco',$aso_info1['suco']);
$iuser0=data_maes('user',$aso_info1['iuser']);



// if(mb_stristr2('.EB13.IB11',$aso_info1['docu']))
// {$idinve=gen_invent($aso_info1['docu'],$aso_info1['idnum1']);}

// if(mb_stristr2('.FC10',$aso_info1['docu']))
// {$idinve=gen_invent($aso_info1['docu'],$aso_info1['idnum1']);}



$pagare1='';
$pagare2='';
if($aso_info1['docu']=='FC10' and $empr0['empr_codigo']=='sawo')
{ 
     $pagare1.='Autorizo (amos) a SUAREZ ALBAN WILSON OSWALDO a consultar mis datos, y a publicar los valores incurridos en MORA '; 
     $pagare1.='que puedan generarse de las operaciones de orden crediticio en cualquier buro de crédito autorizado.';

     $pagare2.='Pagaré.- "He recibido en cantidad y calidad lo detallado en esta factura por el valor indicado en "TOTAL" suma que DEBO Y PAGARE sin protesto, ';
     $pagare2.='incondicionalmente, en esta ciudad, a SUAREZ ALBAN WILSON OSWALDO, en el plazo estipulado contado desde hoy. ';
     $pagare2.='En caso de mora me sujeto a los intereses máximos de mora previstos en la ley y a ser demandado en juicio ejecutivo o en verbal sumario ';
     $pagare2.='a elección del actor, ante los jueces de esta ciudad, para lo cual renuncio a otro domicilio".';

}

// echo '====='.$aso_info1['suco'];
// if($modu=='infi'){$cost='false';}


if(mb_stristr2('.comp.retc',$modu))
{
     $emis0=$adqu0;
     $adqu0=data_maes('enti',$aso_info1['toenti']);
     if(empty($aso_info1['toenti']))
     {$adqu0=data_maes('enti',$empr0['empr_ruc']);}
     
     $emis0=data_maes('enti',$aso_info1['enti']);
}     

     
if(!mb_stristr2('.comp.retc',$modu))
if($empr0['empr_ceuser']==1)
{
     $emis0=data_maes('enti',$iuser0['user_cedula'].'001');
     
//      if($empr0['empr_ceuser']==1)
     {
//           $sql_user='select * from user0 where user_cedula like "'.substr($ruc_emisor,0,10).'%"';
          $sql_user='select * from user0 where user_cedula like "'.substr($emis0['enti_codigo'],0,10).'%"';
          $res_user=msql_query($sql_user,$link_data);
          $ceuser_codigo=msql_result($res_user,0,'user_codigo');
          $ceuser0=data_maes('user',$ceuser_codigo);
     }
     
     
}

if($modu=='rmed')
{
     $emis0=data_maes('enti',$aso_info1['mdco']);
}


if($cont!=1)
{
$claveacc=gen_clacc($aso_info1['docu'],$aso_info1['idnum1']);
$barcode=gen_barcode($claveacc);
}

// echo '/*/*/*'.$claveacc;

if(empty($claveacc)){$barcode=gen_barcode($empr0['empr_ruc'].' '.$aso_info1['ptoe'].$aso_info1['numero']);}
if(empty($claveacc)){$claveacc=$aso_info1['claveacc'];}


if(mb_stristr2('.vtas.retp.guia',$modu) or mb_stristr2('.FP03.FP11',$docu))
{
     if(!empty($claveacc)){gen_cexml($claveacc);}
}


if($modu=='inve' or $modu=='pduc')
{
     $user_cost=0;
     if(@mb_stristr2('.sist.supe',$user0['user_tipo']))
     {$user_cost=1;}
     else
     {
          $sql_cost ='select * ';
          $sql_cost.='from acce1 ';
          $sql_cost.='left join acce2 on idnum1=idnum2 ';
          $sql_cost.='where numero="'.$user_codigo.'" ';
          $sql_cost.='and docum="COST" ';
          $sql_cost.='and (cons=1 or info=1)';
          $res_cost=msql_query($sql_cost,$link_data);
          if(msql_num_rows($res_cost)!=0){$user_cost=1;}
     }
}

$user_apro=0;
if(@mb_stristr2('.sist.suXpe',$user0['user_tipo']))
{$user_apro=1;}
else
{
     $sql_apro ='select * ';
     $sql_apro.='from acce1 ';
     $sql_apro.='left join acce2 on idnum1=idnum2 ';
     $sql_apro.='where numero="'.$user0['user_codigo'].'" ';
     $sql_apro.='and docum="'.$docu.'" ';
     $sql_apro.='and (apro=1)';
     $res_apro=msql_query($sql_apro,$link_data);
     if(msql_num_rows($res_apro)!=0){$user_apro=1;}
}


// $href_html='/docu/'.$claveacc.'.html';
$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'];
//      $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();



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

$fontsize=10; //printer
$fontmail=10;
$fontscre=12;

if(!empty($mailsend)){$fontscre=$fontmail;}     

if(empty($ppsize)){$ppsize=$aso_info1['docu_ppsize'];}
if(empty($ppsize)){$ppsize='A4';}

if($docu=='DA16'){$ppsize='A4-H';}

if($ppsize=='A4'){$ppwidth=210; $ppheight=297;}
if($ppsize=='A5'){$ppwidth=148; $ppheight=210; $ppwidth-=20; $fontsize=8;}
if($ppsize=='A6'){$ppwidth=105; $ppheight=148; $ppwidth-=20; $fontsize=6;}

// if($ppsize=='A4H'){$ppwidth=297; $ppheight=210;}
if($ppsize=='A4-H'){$ppwidth=297; $ppheight=210; $fontsize=10;}
if($ppsize=='A5-H'){$ppwidth=210; $ppheight=148; $ppwidth-=20; $fontsize=8;}
if($ppsize=='A6-H'){$ppwidth=148; $ppheight=105; $ppwidth-=20; $fontsize=6;}

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

// if($pgsize=='P')

if(empty($user_codigo)){$post=0;}


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

// $post=1;
// $fontsize=10;

// if($modu=='rmed'){$fontsize=8;}
// if($docu=='DA16'){$fontsize=10;}

// <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>

// @media screen{.noscreen{display:none;} [noscreen]{display:none;}}
// @media print {[bt_e],[bt_-][bt_o],[bt_x],[bt_r],[bt_n]{display:none;}}
// @media print {.noprint{display:none;} [noprint]{display:none;}}

// echo '*/*/*/'.$_SESSION['screeno'];

     
$css_value='';
$css_value.='@media screen{[screen_width]{width:100%;} [screen_fontsize]{font-size:'.$fontscre.'px; font-family:Arial;}} ';
$css_value.='@media print{[print_width]{width:'.$ppwidth.'mm;} [print_fontsize]{font-size:'.$fontsize.'px; font-family:Arial;}} ';

$css_value.='@media screen{.noscreen{display:none;} [noscreen]{display:none;}} ';
$css_value.='@media print {.noprint{display:none;} [noprint]{display:none;}} ';

// $css_value.='@page{margin-top: 0.5cm; margin-bottom: 0.5cm;}';
// $css_value.='html{margin-top: 0.5cm; margin-bottom: 0.5cm;}';

// $css=$domg->appendChild($domg->createElement('style',$css_value));
// $page=$domg->appendChild($domg->createElement('div',''));


$tag_html='html';
$tag_head='head';
if(!empty($mailsend))
{
//      $tag_html='html2';
//      $tag_head='head2';
}

$pagehtml=$domg->appendChild($domg->createElement($tag_html,' '));

$pagehead=$pagehtml->appendChild($domg->createElement($tag_head,' '));
     $meta=$pagehead->appendChild($domg->createElement('meta',' '));
     $meta->setAttribute('charset','UTF-8');
$css=$pagehead->appendChild($domg->createElement('style',$css_value));


$page=$pagehtml->appendChild($domg->createElement('body',' '));
     $page->setAttribute('id','cele');
     $page->setAttribute('screen_width',' ');
     $page->setAttribute('print_width',' ');
     $page->setAttribute('screen_fontsize',' ');
     $page->setAttribute('print_fontsize',' ');
//      $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('charset','UTF-8');
     $xstyle='';
//      $xstyle.='all:unset;';
//      $xstyle.='width:'.$ppwidth.'mm;';
//      $xstyle.='@media print {width:'.$ppwidth.'mm;}';
//      $xstyle.='font-size:'.$fontsize.'px;';
     $xstyle.='font-family:arial;';
     if(!empty($mailsend)){$xstyle.='font-size:10px;';};

     $xstyle.='-webkit-print-color-adjust: exact;';
     $xstyle.='page-break-inside: avoid;';
     $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));

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

          $xstyle='';
          $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;';

          $xstyle.='font-family:Arial;';
          if(!empty($mailsend)){$xstyle.='font-size:10px;';};

//           if($tkwidth>0)
//           {$xstyle.='max-width:65mm;';}
          if($tckt==1)
          {$xstyle.='display:none;';}
          $tablh->setAttribute('style',$xstyle);
          $tablh->setAttribute('screen_fontsize','');
          $tablh->setAttribute('print_fontsize','');


          $lblcomprob='COMPROBANTE - ELECTRONICO';
          if($modu=='rmed'){$lblcomprob='RECETA - ELECTRONICA';}
          if($cont==1){$lblcomprob='DIARIO - CONTABLE';}
          if($post==1)
          {$lblcomprob=str_replace('-',' ',$lblcomprob);}



          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',$lblcomprob));
                    $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;');
                    if(empty($hideusr))
                    {
                    $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',strtotime($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;');
                    if(empty($hideusr))
                    {
                    $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',strtotime($docu1['idate']))));
                    
                    
               $trow=$tablh->appendChild($domg->createElement('tr',''));
//                $tcol=$tablh->appendChild($domg->createElement('td','COMPROBANTE - ELECTRONICO'));
               $tcol=$tablh->appendChild($domg->createElement('td',$lblcomprob));
                    $xstyle1="letter-spacing:1pt;";
                    $tcol->setAttribute('style',$xstyle1);
                    
                    
          }



     $tabl1=$page->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse; font-family:Arial;';
               if(!empty($mailsend)){$xstyle.='font-size:10px;';};
               $tabl1->setAttribute('class','docu-ride');
               $tabl1->setAttribute('style',$xstyle);
               $tabl1->setAttribute('width','100%');
               $tabl1->setAttribute('screen_fontsize','');
               $tabl1->setAttribute('print_fontsize','');

     $tabl2=$page->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse; font-family:Arial;';
               if(!empty($mailsend)){$xstyle.='font-size:10px;';};
               $tabl2->setAttribute('style',$xstyle);
               $tabl2->setAttribute('width','100%');
               $tabl2->setAttribute('screen_fontsize','');
               $tabl2->setAttribute('print_fontsize','');

     $tabl3=$page->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse; font-family:Arial;';
               if(!empty($mailsend)){$xstyle.='font-size:10px;';};
               $tabl3->setAttribute('style',$xstyle);
               $tabl3->setAttribute('width','100%');
               $tabl3->setAttribute('screen_fontsize','');
               $tabl3->setAttribute('print_fontsize','');


               

     $foot1=$page->appendChild($domg->createElement('div',''));
          $xstyle='';
          $xstyle.='margin-top:5mm;';
//           $xstyle.='position:fixed;bottom:0;width:100%;';
          $xstyle.='border-top:solid 1px;';
          $xstyle.='border-bottom:solid 1px;';
          $xstyle.='font-weight:bold;';
          $xstyle.='background:'.$xbgcolor2.';';
          $xstyle.='font-family:Arial;';
          $xstyle.='font-size:10px;';
//           if(!empty($mailsend)){$xstyle.='font-size:10px;';};
//           $xstyle.='position:sticky;';
//           $xstyle.='bottom:0;';
          if($tckt==1)
          {$xstyle.='display:none;';}
          $foot1->setAttribute('style',$xstyle);

//           if(1==2)
          {
               
          $tablf=$foot1->appendChild($domg->createElement('table',''));
               $tablf->setAttribute('width','100%');
//           $tcol=$tablf->appendChild($domg->createElement('td','ID : '.$docu1['idnum1']));
               
               
//           $tcol=$tablf->appendChild($domg->createElement('td','ID : '.$idnum));
          $tcol=$tablf->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('width','50%');
               $tcol->setAttribute('style','font-size:0.9em');
               $div=$tcol->appendChild($domg->createElement('span','ID : '.$idnum));
//                echo '===>'.$docu1['idfrom'];
               if(!empty($docu1['idfrom']))
               {
                    $div=$tcol->appendChild($domg->createElement('div',''));
                    $div=$tcol->appendChild($domg->createElement('span','IDF: '.$docu1['idfrom']));
               }
               
          $tcol=$tablf->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','right');
               $tcol->setAttribute('style','font-size:0.6em');
               if(empty($hideusr))
               {
               $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',''));
          $thead=$tabl1->appendChild($domg->createElement('tbody',''));
          $tbody=$tabl1->appendChild($domg->createElement('tbody',''));
          $tfoot=$tabl1->appendChild($domg->createElement('tfoot',''));

          if($cont==1)
          {
//                $tbody->setAttribute('style','display:none;');
//                $tfoot->setAttribute('style','display:none;');
          }
//           $thead=$tabl1->appendChild($domg->createElement('table',''));
//           $tbody=$tabl1->appendChild($domg->createElement('table',''));
//           $tfoot=$tabl1->appendChild($domg->createElement('table',''));

          $thead2=$tabl2->appendChild($domg->createElement('thead',''));
          $tbody2=$tabl2->appendChild($domg->createElement('tbody',''));
          $tfoot2=$tabl2->appendChild($domg->createElement('tfoot',''));

          $thead3=$tabl3->appendChild($domg->createElement('thead',''));
          $tbody3=$tabl3->appendChild($domg->createElement('tbody',''));
          $tfoot3=$tabl3->appendChild($domg->createElement('tfoot',''));




          if(empty($post) and $pgland==0)
          {
//                $thead->setAttribute('style','display: table-header-group;');
               
               $trowh0=$thead->appendChild($domg->createElement('tr',''));
                    $trowh0->setAttribute('valign','top');

               $tcol=$trowh0->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('colspan','2');
               $head0=$tcol->appendChild($domg->createElement('div',''));
               
               
               
               $trowh=$thead->appendChild($domg->createElement('tr',' '));
                    $trowh->setAttribute('valign','top');
//                     $trowh->setAttribute('style','font-size:0.5em;');
               
               $trowg=$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%');
                    if($modu=='rmed'){$tcol->setAttribute('width','50%');}
               $logo=$tcol->appendChild($domg->createElement('div',''));
               
               if($modu=='rmed')
               {
                    $dato1=$tcol->appendChild($domg->createElement('div',''));
               }
               
               $emis=$tcol->appendChild($domg->createElement('div',''));
               $adqu=$tcol->appendChild($domg->createElement('div',''));
               $adic=$tcol->appendChild($domg->createElement('div',''));
               $jwib=$tcol->appendChild($domg->createElement('div',''));

               $tcol=$trowh->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('style','vertical-align:top;');
                    $tcol->setAttribute('width','40%');
                    if($modu=='rmed'){$tcol->setAttribute('width','50%');}
               $barc=$tcol->appendChild($domg->createElement('div',''));
               $dato=$tcol->appendChild($domg->createElement('div',''));
               $resu=$tcol->appendChild($domg->createElement('div',''));
               $fpag=$tcol->appendChild($domg->createElement('div',''));
               $suco=$tcol->appendChild($domg->createElement('div',''));
               $docm=$tcol->appendChild($domg->createElement('div',''));
               $impo=$tcol->appendChild($domg->createElement('div',''));

               if($modu=='rmed')
               {
                    $emis2=$tcol->appendChild($domg->createElement('div',''));
                    $adqu2=$tcol->appendChild($domg->createElement('div',''));
               }
               
               $tcol=$trowg->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('width','60%');
//                $dtra=$tcol->appendChild($domg->createElement('div',''));
               
//                $tcol=$trowb->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('colspan','2');
//                     $tcol->setAttribute('style','vertical-align:top;');
               
               $tcol=$trowb->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('colspan','2');
//                     $tcol->setAttribute('style','vertical-align:top;');
               $dtra=$tcol->appendChild($domg->createElement('div',''));
               $deta=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               $nota=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               $nlet=$tcol->appendChild($domg->createElement('div',''));

               
               $trowb=$tbody3->appendChild($domg->createElement('tr',' '));
//                     $trowb->setAttribute('style','font-size:0.9em; line-height:1em; text-align:justify;');
                    $trowb->setAttribute('style','font-size:0.8em; line-height:1em; text-align:justify;');
               $tcol=$trowb->appendChild($domg->createElement('td',' '));
               $paga1=$tcol->appendChild($domg->createElement('div',' '));
                    $tcol->setAttribute('width','50%');
                    $tcol->setAttribute('style','vertical-align:bottom; padding-left:1em; padding-right:1em;');
               $tcol=$trowb->appendChild($domg->createElement('td',' '));
               $paga2=$tcol->appendChild($domg->createElement('div',' '));
                    $tcol->setAttribute('style','vertical-align:bottom; padding-left:1em; padding-right:1em;');
               
               $trowb=$tbody2->appendChild($domg->createElement('tr',''));
               $tcol=$trowb->appendChild($domg->createElement('td',''));
               $detai=$tcol->appendChild($domg->createElement('div',''));
               
               $trowb=$tbody2->appendChild($domg->createElement('tr',''));
               $tcol=$trowb->appendChild($domg->createElement('td',''));
               $detaa=$tcol->appendChild($domg->createElement('div',''));
               
          }

          if(empty($post) and $pgland==1)
          {
               
               $trowh0=$thead->appendChild($domg->createElement('tr',''));
                    $trowh0->setAttribute('valign','top');
               
               $tcol=$trowh0->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('colspan','2');
               $head0=$tcol->appendChild($domg->createElement('div',''));
               
               
               $trowh=$thead->appendChild($domg->createElement('tr',''));
                    $trowh->setAttribute('valign','top');
               
               $trowg=$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','display:none;');
//                     $tcol->setAttribute('style','vertical-align:top;');
                    $tcol->setAttribute('width','20%');
               $logo=$tcol->appendChild($domg->createElement('div',''));
               $barc=$tcol->appendChild($domg->createElement('div',''));
               
               
               $tcol=$trowh->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','display:none;');
               $emis=$tcol->appendChild($domg->createElement('div',''));
               $adqu=$tcol->appendChild($domg->createElement('div',''));
               $adic=$tcol->appendChild($domg->createElement('div',''));
               $jwib=$tcol->appendChild($domg->createElement('div',''));

               
               
               
               $tcol=$trowh->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('width','30%');
               $dato=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowh->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('width','30%');
               $resu=$tcol->appendChild($domg->createElement('div',''));
               

               
               $tcol=$trowh->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('width','30%');
               $impo=$tcol->appendChild($domg->createElement('div',''));


               $fpag=$tcol->appendChild($domg->createElement('div',''));
               $suco=$tcol->appendChild($domg->createElement('div',''));
               $docm=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowg->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('width','60%');
//                $dtra=$tcol->appendChild($domg->createElement('div',''));
               
//                $tcol=$trowb->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('colspan','2');
//                     $tcol->setAttribute('style','vertical-align:top;');
               
               $tcol=$trowb->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('colspan','3');
//                     $tcol->setAttribute('style','vertical-align:top;');
               $dtra=$tcol->appendChild($domg->createElement('div',''));
               $deta=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               $nota=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               $nlet=$tcol->appendChild($domg->createElement('div',''));

               
               $trowb=$tbody2->appendChild($domg->createElement('tr',''));
               $tcol=$trowb->appendChild($domg->createElement('td',''));
               $detai=$tcol->appendChild($domg->createElement('div',''));
               
               $trowb=$tbody2->appendChild($domg->createElement('tr',''));
               $tcol=$trowb->appendChild($domg->createElement('td',''));
               $detaa=$tcol->appendChild($domg->createElement('div',''));
               
          }



          if($post==1)
          {
               $trowh0=$thead->appendChild($domg->createElement('tr',''));
                    $trowh0->setAttribute('valign','top');

               $tcol=$trowh0->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('colspan','2');
               $head0=$tcol->appendChild($domg->createElement('div',''));
               
               $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',''));
               $jwib=$tcol->appendChild($domg->createElement('div',''));
               $dato=$tcol->appendChild($domg->createElement('div',''));
               $resu=$tcol->appendChild($domg->createElement('div',''));
               $fpag=$tcol->appendChild($domg->createElement('div',''));
               $suco=$tcol->appendChild($domg->createElement('div',''));
               $impo=$tcol->appendChild($domg->createElement('div',''));
               $docm=$tcol->appendChild($domg->createElement('div',''));
               
//                $tcol=$trowb->appendChild($domg->createElement('td',''));
               
               $tcol=$trowb->appendChild($domg->createElement('td',''));
               $dtra=$tcol->appendChild($domg->createElement('div',''));
               $deta=$tcol->appendChild($domg->createElement('div',''));
               
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               $nlet=$tcol->appendChild($domg->createElement('div',''));
               $nota=$tcol->appendChild($domg->createElement('div',''));
               $brk=$tcol->appendChild($domg->createElement('br',''));
               $paga1=$tcol->appendChild($domg->createElement('div',''));
//                     $paga1->appendChild($domg->createElement('style','text-align: justify;'));
//                     $paga1->appendChild($domg->createElement('br',''));
               $brk=$tcol->appendChild($domg->createElement('br',''));
               $paga2=$tcol->appendChild($domg->createElement('div',''));
//                     $paga2->appendChild($domg->createElement('br',''));

               
               $trowb=$tbody2->appendChild($domg->createElement('tr',''));
               $tcol=$trowb->appendChild($domg->createElement('td',''));
               $detai=$tcol->appendChild($domg->createElement('div',''));
               
               $trowb=$tbody2->appendChild($domg->createElement('tr',''));
               $tcol=$trowb->appendChild($domg->createElement('td',''));
               $detaa=$tcol->appendChild($domg->createElement('div',''));
               
               
               
          }


//           if($modu=='rmed')
//           {$adic->setAttribute('style','display:none !important;');}

          if(empty($barcode))
          {$barc->setAttribute('hide','');}

          if(!empty($cont))
          {
               $logo->setAttribute('hide','');
               $barc->setAttribute('hide','');
//                $adic->setAttribute('hide','');
          }

          if(mb_stristr2('.comp.retc',$modu))
          {
               $logo->setAttribute('hide','');
               $barc->setAttribute('hide','');
          }
          if($modu=='bcos' and !mb_stristr2('.CH.',substr($docu,0,2)))
          {
               $logo->setAttribute('hide','');
               $barc->setAttribute('hide','');
          }

//                $fpag->setAttribute('style','display:none;');


//           if(!empty($cong0['cong     _codigo']))
          if($empr0['empr_codigo']=='jwib')
          {
               $emis->setAttribute('hide','');
               $adqu->setAttribute('hide','');
               $adic->setAttribute('hide','');
          }

          $xstyle1='';
          $xstyle1.='margin-top:1mm;';
          if($tkwidth>0)
          {$xstyle1.='max-width:65mm;';}
          if($tkwidth==65)
          {$xstyle1.='display:none;';}
//           $xstyle1.='margin-left:0.5mm;';
//           $xstyle1.='border:solid 1px;';
          $logo->setAttribute('style',$xstyle1);
          $barc->setAttribute('style',$xstyle1);

          $xstyle1='';
          $xstyle1.='margin-top:1mm;';
          if($tkwidth>0)
          {$xstyle1.='max-width:65mm;';}
//           $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);
          $jwib->setAttribute('style',$xstyle1);
          $dtra->setAttribute('style',$xstyle1);
          $deta->setAttribute('style',$xstyle1);
          $nota->setAttribute('style',$xstyle1);
          $nlet->setAttribute('style',$xstyle1);

          $fpag->setAttribute('style',$xstyle1);
          $docm->setAttribute('style',$xstyle1);

//           if($modu=='guia'){$adqu->setAttribute('hide','');}
          if($modu=='guia'){removeNode($adqu);}


          // LOGO
{
          $ttbl=$logo->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1){$xstyle.='display:none;';}
     
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','center');
          $ahref=$tcol->appendChild($domg->createElement('a',''));
     
               $href='https://'.$_SERVER['SERVER_NAME'].'/';
               if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
               {$href.='index3.php';}
               $href.='?scri=info_docu3&prnt=1&pgsize='.$pgsize.'&clave='.$aso_info1['claveacc'];
               $ahref->setAttribute('href',$href);
          $imag=$ahref->appendChild($domg->createElement('img',''));
//                $imag->setAttribute('src','https://vcrxol.com/_logo/logo'.strtolower($empr0['empr_codigo']).'2.png');
     
               $xsrc0='../_logo/logo'.strtolower($empr0['empr_codigo']).'2.png';
               $xsrc='https://'.$file_server.'/_logo/logo'.strtolower($empr0['empr_codigo']).'2.png';

               if($empr0['empr_ceuser']!=1)
               {
                    $tipologo='ptov';
                    $sql_logo='select * from logo0 where ifnull(logo_status,"") not in("I","X") and logo_tipo like "'.$tipologo.'" and logo_ptoe="'.$aso_info1['ptov'].'" order by logo_idate desc  ';
                    $res_logo=msql_query($sql_logo,$link_data);
                    $logo_file=msql_result($res_logo,0,'logo_file');
                    $logofile0='../_logo/'.$logo_file.'';
                    $logofile='https://'.$file_server.'/_logo/'.$logo_file.'';
                    
//                     echo '==='.$logofile0;
                    
                    if(!empty($logo_file))
                    if(file_exists($logofile0))
                    {
                         $xsrc0=$logofile0;
                         $xsrc=$logofile;
                    }
               }
               
               if($empr0['empr_ceuser']==1)
               {
                    $sql_logo='select * from logo0 where ifnull(logo_status,"") not in("I","X") and logo_enti like "'.trim($docu1['vndd']).'%" order by logo_idate desc ';
                    $res_logo=msql_query($sql_logo,$link_data);
                    $logo_file=msql_result($res_logo,0,'logo_file');
                    $logofile0='../_logo/'.$logo_file.'';
                    $logofile='https://'.$file_server.'/_logo/'.$logo_file.'';
                    
                    if(!empty($logo_file))
                    if(file_exists($logofile0))
                    {
                         $xsrc0=$logofile0;
                         $xsrc=$logofile;
                    }
               }
     
               if(file_exists($xsrc0))
               {$imag->setAttribute('src',$xsrc);}
               else
               {$imag->parentNode->removeChild($imag);}
     
               $imag->setAttribute('alt','Logo');
     
               $imag->setAttribute('style','max-width:100%; max-height:20mm;');
}

          // BARCODE
{
          $ttbl=$barc->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1){$xstyle.='display:none;';}
     
     
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','center');
          $ahref=$tcol->appendChild($domg->createElement('a',''));
               $href='https://'.$_SERVER['SERVER_NAME'].'/';
               if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
               {$href.='index3.php';}
               $href.='?scri=info_docu3&prnt=1&clave='.$aso_info1['claveacc'];
     
               $ahref->setAttribute('href',$href);
          $imag=$tcol->appendChild($domg->createElement('img',''));
               $imag->setAttribute('src','https://'.$file_server.'/'.$barcode.'');
               $imag->setAttribute('alt','BarCode');
               $imag->setAttribute('style','max-width:100%; max-height:20mm;');
     
}



     if(1==2)
     if($modu=='rmed')
     {
          $ttbl=$head0->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('cellpadding','1');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
          
          $tcolg=$ttbl->appendChild($domg->createElement('colgroup',''));
          $thead=$ttbl->appendChild($domg->createElement('thead',''));
          $tbody=$ttbl->appendChild($domg->createElement('tbody',''));
          $tfoot=$ttbl->appendChild($domg->createElement('tfoot',''));
          
          $col=$tcolg->appendChild($domg->createElement('col',""));
          $col=$tcolg->appendChild($domg->createElement('col',""));
          $col=$tcolg->appendChild($domg->createElement('col',""));
          $col=$tcolg->appendChild($domg->createElement('col',""));
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
               $trowh->setAttribute('style','border-top:solid 1px;');
          $tcol=$trowh->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('colspan','10');
               $xstyle='';    
               $xstyle.='letter-spacing:5pt;text-align:;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
          $tcol=$trowh->appendChild($domg->createElement('td','FECHA : '.$aso_info1['dia_des'].' - '.$aso_info1['dmy2']));
//           $tcol=$trowh->appendChild($domg->createElement('td','FECHA :'));
//           $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['dia_des'].' - '.$aso_info1['dmy1']));
//           if($post==1){$trowh=$thead->appendChild($domg->createElement('tr',''));}
          $tcol=$trowh->appendChild($domg->createElement('td','NUMERO : '.$aso_info1['numero']));
               $tcol->setAttribute('align','right');
//           $tcol=$trowh->appendChild($domg->createElement('td','NUMERO :'));
//           $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['numero']));
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
          $tcol=$trowh->appendChild($domg->createElement('td','FECHA : '.$aso_info1['dia_des'].' - '.$aso_info1['dmy2']));
          $tcol=$trowh->appendChild($domg->createElement('td','DESCARGAR : '.$aso_info1['numero']));
               $tcol->setAttribute('align','right');
          
     }









          // EMISOR
{
          $ttbl=$emis->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               if($post==1)
               {$xstyle.='text-align:center;';}
//                if($modu=='rmed')
//                {$xstyle.='font-size:1.8em !important;';}
     
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

          $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:;');


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

//           if(empty($post))
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','RUC / CI'));
               if($post==1){$tcol->setAttribute('style','display:none;');}
//           $tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_codigo']));
               
          $edit_emis=0;
          if(mb_stristr2('.sist.supe.admi',$user0['user_tipo'])){$edit_emis=1;}
          if($edit_emis==0)
          {$tcol=$trow->appendChild($domg->createElement('td',$emis0['enti_codigo']));}
          if($edit_emis==1)
          {
               $tcol=$trow->appendChild($domg->createElement('td',' '));
                    $codigo = $tcol->appendChild($domg->createElement('a',$emis0['enti_codigo']));
                    $xonclick='{regi_maes("enti","'.$emis0['enti_codigo'].'");}';
                    $codigo->setAttribute('onclick',$xonclick);
          }
               
               
               
               
               
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('style','font-weight:bold;text-transform: uppercase;');

          $lblrazsoc='RAZ.SOCIAL';
          if($modu=='rmed')
          {$lblrazsoc='NOMBRE';}
               
          $tcol=$trow->appendChild($domg->createElement('td',$lblrazsoc));
               if($post==1){$tcol->setAttribute('style','display:none;');}
          $tcol=$trow->appendChild($domg->createElement('td',htmlspecialchars($emis0['enti_razsoc'])));
               $tcol->setAttribute('style','color:black; font-size:100%;');
               
          if($modu=='rmed')
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','REG.  SENESCYT'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
//                $tcol=$trow->appendChild($domg->createElement('td',$iuser0['user_registro'].' / '.$iuser0['user_senescyt']));
               $tcol=$trow->appendChild($domg->createElement('td',$iuser0['user_senescyt']));
               
//                if($modu=='rmed')
               {
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $tcol=$trow->appendChild($domg->createElement('td','CONTACTO'));
                         if($post==1){$tcol->setAttribute('style','display:none;');}
                    $tcol=$trow->appendChild($domg->createElement('td',$iuser0['user_wsapp'].' - '.$iuser0['user_email']));
               }
               
          }
               
     
          if(!empty($emis0['enti_nomcom']) and $emis0['enti_nomcom']!=$emis0['enti_razsoc'])
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               if(mb_stristr2('.inve.infi.prod',$modu)){$trow->setAttribute('style','display:none;');}
          $tcol=$trow->appendChild($domg->createElement('td','NOM.COMERCIAL'));
               if($post==1){$tcol->setAttribute('style','display:none;');}
          $tcol=$trow->appendChild($domg->createElement('td',htmlspecialchars($emis0['enti_nomcom'])));
          }
   
               
          if(mb_stristr2('.vtas.clie.comp.prov.carr.lpro.guia.retc.retp',$modu))
          {
               
               
//           var_dump2($emis0);     
               
          $tipo_contrib='';
          $obcon_descri='';
          $rimpe_descri='';
//           if($emis0['enti_obcon']==1){$tipo_contrib='OBLIGADO CONTABILIDAD';}
//           if($emis0['enti_obcon']=='S'){$tipo_contrib='OBLIGADO CONTABILIDAD';}
//           if($emis0['enti_rimpe']==1){$tipo_contrib='RIMPE EMPRENDEDOR';}
//           if($emis0['enti_rimpe']==2){$tipo_contrib='RIMPE NEGOCIO POPULAR';}
               
          if($emis0['enti_obcon']==1){$obcon_descri='OBLIGADO CONTABILIDAD';}
          if($emis0['enti_obcon']=='S'){$obcon_descri='OBLIGADO CONTABILIDAD';}
//           if($emis0['enti_rimpe']==0){$rimpe_descri='REGIMEN GENERAL';}
          if($emis0['enti_rimpe']==1){$rimpe_descri='RIMPE EMPRENDEDOR';}
          if($emis0['enti_rimpe']==2){$rimpe_descri='RIMPE NEGOCIO POPULAR';}
               
               
//           if(!empty($tipo_contrib))
               
//                echo '==='.$emis0['enti_obcon'];
   
          if($emis0['enti_obcon']==1 or $emis0['enti_obcon']=='S' or !empty($emis0['enti_tipoCont'] or $emis0['enti_agret']==1))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               if(mb_stristr2('.inve.infi.prod',$modu)){$trow->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td','CONTRIBUYENTE'));
               if($post==1){$tcol->setAttribute('style','display:none;');}
               
               $tcol=$trow->appendChild($domg->createElement('td',''));
               
               if(!empty($obcon_descri))
               {$div=$tcol->appendChild($domg->createElement('span',' '.$obcon_descri.' . '));}
               
               if(!empty($emis0['enti_tipoCont']))
               {$div=$tcol->appendChild($domg->createElement('span',' '.$emis0['enti_tipoCont'].' . '));}
               
               if($emis0['enti_agret']==1)
               {$div=$tcol->appendChild($domg->createElement('span',' AGENTE DE RETENCION . '));}
               
          }
               
               
//           if(mb_stristr2('.vtas.clie.comp.prov.carr.guia.retc.retp',$modu))
//           {
               $xmatriz1=$emis0['enti_matriz'];
               if(empty($xmatriz1)){$xmatriz1=$emis0['enti_direccion'];}
               if(empty($xmatriz1)){$xmatriz1=$emis0['enti_ciudad'];}
               if($empr0['empr_ceuser']==1){$xmatriz1=$ceuser0['user_calle1'];}

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','MATRIZ'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',$xmatriz1));


               $wsappnum=$emis0['enti_wsapp'];
               if(empty($wsappnum))
               {$wsappnum=$emis0['enti_telefono'];}
               $walink='https://'.$_SERVER['SERVER_NAME'].'/';
               if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
               {$walink.='index3.php';}
               $walink.='?scri=info_docu3&prnt=1&clave='.$claveacc;
               $walink=urlencode($walink);
               
//                echo '=='.$user0['user_telefono'];

               $xtelefono=$emis0['enti_telefono'];
               if($empr0['empr_ceuser']==1){$xtelefono=$ceuser0['user_wsapp'];}
//                var_dump2($ceuser0);
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','TELEFONO'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',''));
                    $tcol->appendChild($domg->createElement('span',$xtelefono));
                    $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');


               $xemail=$emis0['enti_email'];
               if($emis0['enti_email']!=$emis0['enti_emailce'])
               {$xemail.='; '.$emis0['enti_emailce'];}
               $xemail=alltrim(strtolower($xemail));
               
               if($empr0['empr_ceuser']==1){$xemail=$ceuser0['user_email'];}
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','E-MAIL'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',$xemail));
               }
               
          }
               

     
     
               
}

          // ADQUIRIENTE
// if(1==2)
{
          $ttbl=$adqu->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               if($post==1)
               {$xstyle.='text-align:center;';}
     
               if(!mb_stristr2('.vtas.clie',$modu))
               if(substr($emis0['enti_codigo'],0,10)==substr($adqu0['enti_codigo'],0,10))
               {$xstyle.='display:none;';}
     
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');


          $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:;');

          $lblrecibe='ENTIDAD';
          if($modu=='vtas'){$lblrecibe='ADQUIRIENTE';}
          if($modu=='clie'){$lblrecibe='CLIENTE';}
          if($modu=='dxco'){$lblrecibe='CLIENTE';}
     
          if($modu=='comp'){$lblrecibe='ADQUIRIENTE';}
          if($modu=='prov'){$lblrecibe='PROVEEDOR';}
          if($modu=='dxpa'){$lblrecibe='PROVEEDOR';}
     
          if($modu=='retc'){$lblrecibe='SUJETO RETENIDO';}
          if($modu=='retp'){$lblrecibe='SUJETO RETENIDO';}
     
          if($modu=='guia'){$lblrecibe='DESTINATARIO';}
          if($modu=='hcli'){$lblrecibe='PACIENTE';}
          if($modu=='rmed'){$lblrecibe='PACIENTE';}
          if($modu=='infi'){$lblrecibe='ENTIDAD';}
          if($modu=='pduc'){$lblrecibe='TALLER';}
          if($modu=='inve')
          {
               $lblrecibe='ENTIDAD';
               if(mb_stristr2('.IB10.IB15',$docu))
               {$lblrecibe='PROVEEDOR';}
               if(mb_stristr2('.EB10.EB15',$docu))
               {$lblrecibe='CLIENTE';}
          }
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',$lblrecibe));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:1em;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 '));
               if($post==1){$tcol->setAttribute('style','display:none;');}
          $edit_adqu=0;
     
          if(mb_stristr2('.sist.supe.admi',$user0['user_tipo'])){$edit_adqu=1;}
     
//           echo '===='.$adqu0['enti_idexterior'];
          $adquiriente=$adqu0['enti_codigo'];
     
          if(substr($adquiriente,0,2)=='99' and !empty($adqu0['enti_idexterior']))
          {$adquiriente=$adqu0['enti_idexterior'];}

          if($edit_adqu==0)
          {$tcol=$trow->appendChild($domg->createElement('td',$adquiriente));}
     
          if($edit_adqu==1)
          {
               $tcol=$trow->appendChild($domg->createElement('td',' '));
                    $codigo = $tcol->appendChild($domg->createElement('a',$adquiriente));
                    $xonclick='{regi_maes("enti","'.$adqu0['enti_codigo'].'");}';
                    $codigo->setAttribute('onclick',$xonclick);
          }
     
          $enti_razsoc=$adqu0['enti_razsoc'];
          if(empty($enti_razsoc))
          {$enti_razsoc=$adqu0['enti_descri'];}
          if(mb_stristr2($enti_razsoc,'*** Nuev'))
          {
               ruc_search1($adqu0['enti_codigo']);
               $adqu0=data_maes('enti',$aso_info1['enti']);
          }
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('style','font-weight:bold; text-transform: uppercase;');
          $lblrazsoc='RAZ.SOCIAL';
          if($modu=='rmed')
          {$lblrazsoc='NOMBRE';}
          $tcol=$trow->appendChild($domg->createElement('td',$lblrazsoc));
               if($post==1){$tcol->setAttribute('style','display:none;');}
          $tcol=$trow->appendChild($domg->createElement('td',htmlspecialchars($enti_razsoc)));
               $tcol->setAttribute('style','color:black; font-size:100%;');
     
          if($modu=='rmed')
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('style','font-weight:; text-transform: ;');
               $tcol=$trow->appendChild($domg->createElement('td','SEXO / EDAD'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_sexod'].' / '.$adqu0['enti_edad1'].' Años '.$adqu0['enti_edad2'].' Meses'));
          }
     
          if(substr($adqu0['enti_codigo'],0,4)!='9999')
          {

//           if($cont!=1 and $cont!=2)     
          if($cont!=1)     
          if(!mb_stristr2('.comp.retc',$modu))
          {
               
          if(!empty($adqu0['enti_nomcom']) and $adqu0['enti_nomcom']!=$adqu0['enti_razsoc'])
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               if($modu=='rmed'){$trow->setAttribute('style','display:none;'); }
          $tcol=$trow->appendChild($domg->createElement('td','NOM.COMERCIAL'));
               if($post==1){$tcol->setAttribute('style','display:none;');}
          $tcol=$trow->appendChild($domg->createElement('td',htmlspecialchars($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'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',$tipo_contrib));
          }

               
          $xmatriz2=$adqu0['enti_matriz'];
          $xciudad2=$adqu0['enti_ciudad'];
          $xdireccion2=$adqu0['enti_direccion'];
          if(empty($xmatriz2)){$xmatriz2=$adqu0['enti_direccion'];}
          if(empty($xmatriz2)){$xmatriz2=$adqu0['enti_ciudad'];}
          if($xmatriz2==$xdireccion2){$xdireccion2='';}
          if($empr0['empr_taxi']==1){if(strlen($xmatriz2)<=3){$xmatriz2=$xmatriz1;}}
          if(strlen($xmatriz2)<=3){$xmatriz2='GUAYAQUIL';}
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','MATRIZ'));
               if($post==1){$tcol->setAttribute('style','display:none;');}
          $tcol=$trow->appendChild($domg->createElement('td',''));
               if($modu=='rmed'){$trow->setAttribute('style','display:none;');}
               
               if(mb_stristr2('.vtas.clie.carr.guia',$modu))
               {
                    $href=$tcol->appendChild($domg->createElement('a',$xmatriz2));
                    $lbl_link='https://'.strtolower($empr0['empr_codigo']).'.'.$file_server.'/index3.php?scri=ele_adrs&zdocu='.$aso_info1['docu'].'&zidnum='.$aso_info1['idnum1'].'&prnt=1';
                         $href->setAttribute('href',$lbl_link);
                         $href->setAttribute('target','_blank');
               }
               else
               {
                    $href=$tcol->appendChild($domg->createElement('span',$xmatriz2));
               }

               
           
          // valida guia rem     
          $btn_guiar=0;
          if(empty($mailsend))
          {
               if(mb_stristr2('.FC',substr($docu,0,2))){$btn_guiar=1;}
               if(mb_stristr2('.EB10.EB13',substr($docu,0,4))){$btn_guiar=1;}
               $btn_guiar=$btn_guiar*$empr0['empr_guia'];
               
               if($btn_guiar==1)
               {
                    if(substr($docu,0,2)=='FC' and $aso_info1['fecha']<date('Y-m-d',strtotime('-1 month'))){$btn_guiar=0;}
                    if(substr($docu,0,2)=='EB' and $aso_info1['fecha']<date('Y-m-d',strtotime('-3 days'))){$btn_guiar=0;}
               }

               if($btn_guiar==1)
               {
                    $sql_guia='select * from guia1 where ifnull(status,"")not in ("O","X") order by fecha desc, idnum1 desc limit 1';
                    $res_guia=msql_query($sql_guia,$link_data);
                    $ptoe_guia=msql_result($res_guia,0,'ptoe');

                    $sql_guia='select * from guia1 where ifnull(status,"")not in ("O","X") and idfrom="'.$idnum.'" ';
                    $res_guia=msql_query($sql_guia,$link_data);
                    if(msql_num_rows($res_guia)==0){$btn_guiar=1;}else{$btn_guiar=0;}
               }
          }
//                echo '===='.$btn_guiar;
               
          // boton guia rem                       
          if($btn_guiar==1)
          {
               $btn_guiar=$tcol->appendChild($domg->createElement('button','📦 Guía Rem.'));
                    $btn_guiar->setAttribute('accesskey','G');
                    $btn_guiar->setAttribute('noprinter','');
                    $btn_guiar->setAttribute('size120','');
                    $btn_guiar->setAttribute('title','Emitir Guía de Remisión');
                    $btn_guiar->setAttribute('style','float:right;background:cyan; color:;font-weight:bold; font-size:1em;');
                    $btn_guiar->setAttribute('onclick','{gene_guia("'.$docu.'","'.$idnum.'","GR10","'.$ptoe_guia.'");}');

          }

               
               
               $btn_matriz=0;
               if(mb_stristr2('.vtas.clie.',$modu) or mb_stristr2('.EB10.EB13',$docu)){$btn_matriz=1;}
               if(1==2)
               if($btn_matriz==1)
               {
                    $btn_matriz=$tcol->appendChild($domg->createElement('button','📦 Etqta'));
                         $btn_matriz->setAttribute('size120','');
                         $btn_matriz->setAttribute('title','Imprimir Etiqueta');
                         $btn_matriz->setAttribute('noprinter','');
                         $btn_matriz->setAttribute('style','float:right;background:cyan; color:;font-weight:bold; font-size:1em;');
//                          $btn_matriz->setAttribute('onclick','{mail_docu("'.$docu.'","'.$idnum.'","'.$xemail.'");}');
               }
                  
                  
                  
               
               
     
               
               
               
               

          if(!empty($xciudad2))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','CIUDAD'));
               if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',$xciudad2));
          }

          if(!empty($xdireccion2))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','DIRECCION'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',$xdireccion2));
          }

          $wsappnum=$adqu0['enti_wsapp'];
          if(empty($wsappnum))
          {$wsappnum=$adqu0['enti_telefono'];}
          $walink='https://'.$_SERVER['SERVER_NAME'].'/';
          if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
          {$walink.='index3.php';}
          $walink.='?scri=info_docu3&prnt=1&clave='.$claveacc;
          $walink=urlencode($walink);

//           if(!empty($wsappnum))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    if($modu=='rmed'){$trow->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td','TELEFONO'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $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');
               
               if($user0['user_hide_wsapp']==1 and (mb_stristr2('.vtas.clie',$modu)))
                    {$trow->setAttribute('style','display:none;');}
               
          }

          $xemail=$adqu0['enti_email'];
          $xemail=alltrim(strtolower($xemail));
          if($adqu0['enti_email']!=$adqu0['enti_emailce'])
          {$xemail.=', '.$adqu0['enti_emailce'];}

          $xemail=alltrim(strtolower($xemail));
          $xemail=str_replace_all('  ','',$xemail);
          $xemail=str_replace_all(';',',',$xemail);
          $xemail=str_replace_all(', ,',',',$xemail);
          $xemail=str_replace_all(',,',',',$xemail);
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               if($modu=='rmed'){$trow->setAttribute('style','display:none;');}
          $tcol=$trow->appendChild($domg->createElement('td','E-MAIL'));
               if($post==1){$tcol->setAttribute('style','display:none;');}
//           $tcol=$trow->appendChild($domg->createElement('td',$xemail));
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $span=$tcol->appendChild($domg->createElement('span',$xemail.','));
               
               $btn_mail=0;
               if(mb_stristr2('.vtas.clie.retp.guia',$modu) or mb_stristr2('.FP03.FP11',$docu)){$btn_mail=1;}
               
               
               if(empty($mailsend))
               if($btn_mail==1)
               {
//                echo '===='.$btn_mail.$mailsend;
                    if(strlen(trim($xemail))<6){$xemail=$emis0['enti_email'].',';}
                    
//                     📧
                    $btn_mail=$tcol->appendChild($domg->createElement('button','📧 eMail'));
                         $btn_mail->setAttribute('accesskey','M');
                         $btn_mail->setAttribute('size120','');
                         $btn_mail->setAttribute('title','Enviar e-Mail');
                         $btn_mail->setAttribute('noprinter','');
                         $btn_mail->setAttribute('style','float:right;background:cyan; color:;font-weight:bold; font-size:1em;');
                         $btn_mail->setAttribute('onclick','{mail_docu("'.$docu.'","'.$idnum.'","'.$xemail.'");}');
                    
               }
               

               
          if($modu=='rmed')
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','CONTACTO'));
                    if($post==1){$tcol->setAttribute('style','display:none;');}
               $tcol=$trow->appendChild($domg->createElement('td',$adqu0['enti_telefono'].' - '.$xemail));
          }
               
               
               
               
          }
               
               
          }
     
     
}




$xtcant=abs($aso_info1['tcant']);
$xtsubt=abs($aso_info1['tsubt']);
$xtiva=abs($aso_info1['tiva']);
$xtotal=abs($aso_info1['total']);

$wa_text='';
$wa_link='';
$wa_link2='';
{
//      $href='https://'.$_SERVER['SERVER_NAME'].'/';
//      if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//      {$href.='index3.php';}
     
//      $wa_link='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/docu/'.$claveacc.'.html';
     $wa_link='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/-docu/'.$claveacc.'.html';
     $wa_link ='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/?scri=info_docu3&clave='.$aso_info1['claveacc'].'&prnt=1';
     $wa_link2='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/?scri=info_docu3&docu='.$aso_info1['docu'].'&idnum='.$aso_info1['idnum1'].'&prnt=1';

     $wa_text='*== '.$aso_info1['docu_descri'].' ==*'; 
     $wa_text.='%0A';
     $wa_text.='🏢 Emisor : '.$emis0['enti_codigo'].' - '.$emis0['enti_descri']; 
     $wa_text.='%0A';
     $wa_text.='👤 '.$lblrecibe.' : '.$adqu0['enti_codigo'].' - '.$adqu0['enti_descri']; 
     $wa_text.='%0A';
     $wa_text.='📆 Fecha : '.$aso_info1['dia_des'].' - '.$aso_info1['dmy1']; 
     $wa_text.='%0A';
     $wa_text.='№ Número : '.$aso_info1['ptoe'].'-'.$aso_info1['numero']; 
     if(!empty($aso_info1['concepto']))
     {
     $wa_text.='%0A';
     $wa_text.='Concepto : '.$aso_info1['concepto']; 
     }
     $wa_text.='%0A';
     $wa_text.='Unidades : '.number_format($xtcant,2); 
     $wa_text.='%0A';
     if(mb_stristr2('.vtas.clie.comp.prov.carr',$modu))
     {
          $wa_text.='Sub-tot : '.number_format($xtsubt,2); 
          $wa_text.='%0A';
          $wa_text.='IVA : '.number_format($xtiva,2); 
          $wa_text.='%0A';
          $wa_text.='💲Total : '.number_format($xtotal,2); 
          $wa_text.='%0A';
     }
     $wa_text.='🔑Clave : '.$aso_info1['claveacc']; 
     $wa_text.='%0A';

     ///////////////////
     $wa_text2=$wa_text;
     
     $wa_text.='🔗Link : '.$wa_link; 
     $wa_text.='%0A';
     $wa_text=urldecode($wa_text);
     $wa_text=str_replace('&','%26',$wa_text);
     $wa_text=str_replace('https://','',$wa_text);

     $wa_text2.='🔗Link : '.$wa_link2; 
     $wa_text2.='%0A';
     $wa_text2=urldecode($wa_text2);
     $wa_text2=str_replace('&','%26',$wa_text2);
     $wa_text2=str_replace('https://','',$wa_text2);

}


// if($docu=='RTRT')
if($empr0['empr_codigo']=='jwib')
{
//      $wa_link='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/docu/'.$claveacc.'.html';
     $wa_link='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/-docu/'.$claveacc.'.html';
     $wa_link ='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/?scri=info_docu3&clave='.$aso_info1['claveacc'].'&prnt=1';
     $wa_link2='https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/?scri=info_docu3&docu='.$aso_info1['docu'].'&idnum='.$aso_info1['idnum1'].'&prnt=1';

     $wa_text='*== '.$aso_info1['docu_descri'].' ==*'; 
     $wa_text.='%0A';
//      $wa_text.='🏢 Congregación : '.$cong_descri; 
//      $wa_text.='%0A';
     $wa_text.='🗺 Territorio : '.$aso_info1['trty_descri'] ; 
     $wa_text.='%0A';
     $wa_text.='🏢 Referencia : '.$aso_info1['trty_referencia'] ; 
     $wa_text.='%0A';
     $wa_text.='👤 '.'ASIGNADO A :'.' : '.$aso_info1['asignado']; 
     $wa_text.='%0A';
     $wa_text.='📆 Fecha : '.$aso_info1['dia_des'].' - '.$aso_info1['dmy1']; 
     $wa_text.='%0A';
//      $wa_text.='№ Número : '.$aso_info1['ptoe'].'-'.$aso_info1['numero']; 
//      $wa_text.='%0A';
//      $wa_text.='Unidades : '.number_format($xtcant,2); 
//      $wa_text.='%0A';
     
//      if(mb_stristr2('.vtas.clie.comp.prov.carr',$modu))
//      {
//           $wa_text.='Sub-tot : '.number_format($xtsubt,2); 
//           $wa_text.='%0A';
//           $wa_text.='IVA : '.number_format($xtiva,2); 
//           $wa_text.='%0A';
//           $wa_text.='💲Total : '.number_format($xtotal,2); 
//           $wa_text.='%0A';
//      }
//      $wa_text.='🔑Clave : '.$aso_info1['claveacc']; 
//      $wa_text.='%0A';

     
//      echo ':::'.$wa_text;
     ///////////////////
     $wa_text2=$wa_text;
     
     $wa_text.='🔗Link : '.$wa_link; 
     $wa_text.='%0A';
     $wa_text=urldecode($wa_text);
     $wa_text=str_replace('&','%26',$wa_text);
     $wa_text=str_replace('https://','',$wa_text);

     $wa_text2.='🔗Link : '.$wa_link2; 
     $wa_text2.='%0A';
     $wa_text2=urldecode($wa_text2);
     $wa_text2=str_replace('&','%26',$wa_text2);
     $wa_text2=str_replace('https://','',$wa_text2);

}




          // DATOS COMPROBANTE
{
          $ttbl=$dato->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='cellpadding:5px;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
//                 if($modu=='rmed')
//                {$xstyle.='font-size:1.8em !important;';}
     
     
     
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');

          $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:;');


          $lbldato='DATOS DEL COMPROBANTE';
          if($modu=='rmed'){$lbldato='RECETA ELECTRONICA';}
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',$lbldato));
               $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',''));
               if($modu=='rmed'){$trow->setAttribute('style','display:none;');}
          $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']));
               $tcol->setAttribute('style','font-size:; text-align:;');

     
                    
                    
     
                    $hrefd='';
                    $hrefd.='https://'.$_SERVER['SERVER_NAME'].'/';
//                     if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                     {$hrefd.='index3.php';}
                    $hrefd.='?scri=info_docu3';
                    $hrefd.='&prnt=1';
                    $hrefd.='&docu='.$aso_info1['docu'].'';
                    if($cont==1)
                    {$hrefd.='&idnum='.$aso_info1['idfrom'].'';}
                    if($cont!=1)
                    {$hrefd.='&idnum='.$aso_info1['idnum1'].'';}
     
                    $pcont=2;
                    if($aso_info1['idate']>=date('Y-m-d',strtotime('-1 week'))){$pcont=3;}
//                     if($aso_info1['fecha']>='2024-01-01'){$pcont=3;}
               
     
                    if(empty($abon) and empty($bode) and empty($cont))
                    {
                         $hrefd.='&bode=1';
                         $hrefd.='&abon=1';
                         $hrefd.='&cont='.$pcont;
                    }
                    
                    if(mb_stristr2('.RM.',substr($docu,0,2) ))
                    {$hrefd='';}
     
     
//                     if($xtra==1){$href.='&xtra=0';}
//                     if($xtra!=1){$href.='&xtra=1';}
     
          $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',' '));
               $link=$tcol->appendChild($domg->createElement('a',$aso_info1['ptoe'].'-'.$aso_info1['numero']));
               $link->setAttribute('href',$hrefd);
               $tcol->setAttribute('style','font-size:150%; text-align:;');

//                if($user_codigo==2)
     
//                var_dump2($acce_user);
               $btn_copy=0;
               if(mb_stristr2('.PS.PP.PC.PF.DD.FC.OT.',substr($aso_info1['docu'],0,2)) or $docu=='FP90'){$btn_copy=1;}
               if($acce_user['nuev']==1){$btn_copy=$btn_copy*1;}
               if($acce_user['nuev']!=1){$btn_copy=0;}
               if($aso_info1['fecha']<date('Y-m-01',strtotime('-15 month'))){$btn_copy=0;}
     
               if($btn_copy==1)
               {
                    $btn_copy=$tcol->appendChild($domg->createElement('button','Copiar'));
                         $btn_copy->setAttribute('accesskey','C');
                         $btn_copy->setAttribute('noprinter','');
                         $btn_copy->setAttribute('title','Copiar Documento');
                         $btn_copy->setAttribute('style','float:right;background:gold;color:;font-weight:bold; font-size:0.8em;');
                         $btn_copy->setAttribute('onclick','{copy_docu("'.$docu.'","'.$idnum.'");}');
                    
               }

     
          $colormes=array();
          $colormes[1]='lightyellow';
          $colormes[2]='palegreeen';
          $colormes[3]='lightcyan';
          $colormes[4]='lavender';
          $colormes[5]='mistyrose';
          $colormes[6]='#FFDAC1';
     
          $colormes[7]='lightyellow';
          $colormes[8]='palegreeen';
          $colormes[9]='lightcyan';
          $colormes[10]='lavender';
          $colormes[11]='mistyrose';
          $colormes[12]='#FFDAC1';
     
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               $xstyle.='font-weight:bold;';
               $xstyle.='background:'.$colormes[(int)$aso_info1['mes']].';';
               $trow->setAttribute('style',$xstyle);
     
          $tcol=$trow->appendChild($domg->createElement('td','FECHA :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $xfecha=$aso_info1['dia_des'].' - '.strtoupper($aso_info1['dmy2']);
          if($modu=='rmed'){$xfecha=ucwords2('Guayaquil, '.$xfecha);}

     
     
          if(mb_stristr2('.inve.opro.pduc.nomi',$modu))
          if($empr0['empr_sema']==1)
          {$xfecha.=' - Sem.:'.$aso_info1['sema'];}
     
          $tcol=$trow->appendChild($domg->createElement('td',$xfecha));
     
          if($empr0['empr_sema']==1)
          {
//                $trow=$ttbl->appendChild($domg->createElement('tr',''));
//                $tcol=$trow->appendChild($domg->createElement('td','SEMANA :'));
//                     $xstyle='text-align:right;';
//                     $tcol->setAttribute('style',$xstyle);
//                $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['sema']));
          }

     
     
          if($cont!=1)
          {
     
     
          if(!empty($aso_info1['fcobro']))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','FEC.COBRO :'));
                    $xstyle='text-align:right;';
                    $tcol->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td',date('l - d/M/Y',strtotime($aso_info1['fcobro'])).' '));
          }
     
     
//           if(!empty($aso_info1['plazo']))
//           if($aso_info1['plazo']>1)
          if( (substr($aso_info1['docu'],0,2)=='FC' and $empr0['empr_cxco']==1) or (substr($aso_info1['docu'],0,2)=='FP10' and $empr0['empr_cxpa']==1) )     
          if($aso_info1['status']!='O')     
          if(!empty($aso_info1['vence_ddmy']))               
          {
               $trowv=$ttbl->appendChild($domg->createElement('tr',''));
               
               $tcol=$trowv->appendChild($domg->createElement('td','VENCE :'));
                    $xstyle='text-align:right;';
                    $tcol->setAttribute('style',$xstyle);
               
               $xsaldo=$aso_info1['total'];
               if(gettype($res_abon)=='object')
               {
                    msql_data_seek($res_abon);
                    while($aso_abon=msql_fetch_assoc($res_abon))
                    {$xsaldo=$xsaldo +$aso_abon['debito'] -$aso_abon['credito'];}
               }
               
               $xstyle='';
               if($xsaldo>1)
               {
                    $diasv=days_diff($aso_info1['vence']);
                    $xstyle.=color_cxcp($diasv);
               }
               
               $vencestr=$aso_info1['vence_ddmy'];
               if($diasv>0){$vencestr.=' ('.$diasv.')';}
               $tcol=$trowv->appendChild($domg->createElement('td',$vencestr));
               $trowv->setAttribute('style',$xstyle);
               
               
               
               
               
               
          }
     
     
          if(mb_stristr2('.opro',$modu))
          {
               $span=$tcol->appendChild($domg->createElement('span',' - SEM. '.$aso_info1['sema'].''));
               $span->setAttribute('style','font-weight:bold; font-size:1.1em;');
          }

          
          if(mb_stristr2('.opro',$modu))
          {
//           $trow=$ttbl->appendChild($domg->createElement('tr',''));
//           $tcol=$trow->appendChild($domg->createElement('td','SEMANA :'));
//                //
//                $xstyle='text-align:right;';
//                $tcol->setAttribute('style',$xstyle);
//           $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['sema']));
          }


//           $vndd0=data_maes('vndd',$aso_info1['vndd'].'001');
//                var_dump2($vndd0);
               
          if((int)$aso_info1['vndd']>0)
          if(strlen($aso_info1['vndd'])>=10)
          if(substr($aso_info1['vndd'],0,4)!='9999')     
          if(!mb_stristr2($claveacc,$aso_info1['vndd']))
          {
//                $vndd_descri=$aso_info1['vndd'].' /'.ucwords2(strtolower($aso_info1['vndd_descri']));
               $vndd_descri=$aso_info1['vndd_ape1'].' '.ucwords2(strtolower($aso_info1['vndd_nom1']));
               if(empty($vndd_descri))
               {$vndd_descri=$aso_info1['vndd_descri'];}
               $vndd_descri=trim($vndd_descri);
               
               if(empty($vndd_descri))
               {
                    $vndd0=data_maes('enti',$aso_info1['vndd']);
                    $vndd_descri=$vndd0['enti_ape1'].' '.ucwords2(strtolower($vndd0['enti_nom1']));
                    $vndd_descri=trim($vndd_descri);
                    if(empty($vndd_descri))
                    {$vndd_descri=$vndd0['enti_descri'];}
               }
               
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','VENDEDOR :'));
//                     $tcol->setAttribute('size80','');
                    $xstyle='text-align:right; font-size:80%;';
                    $tcol->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td',$vndd_descri));
          }
     
          if(mb_stristr2('.caja',$aso_info1['docu_tabla']))
          {
               if(!empty($aso_info1['caja']))
               {
                    $caja_descri=$aso_info1['caja'].' /'.(($aso_info1['caja_descri']));
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='background-color:'.$aso_info1['caja_color'].';';
                         $xstyle.='font-weight:bold;';
                         $trow->setAttribute('style',$xstyle);
                 $tcol=$trow->appendChild($domg->createElement('td','CAJA :'));
                         $xstyle='text-align:right;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',$caja_descri));
//                          $xstyle='background-color:'.$aso_info1['caja_color'].';';
//                          $trow->setAttribute('style',$xstyle);
               }
          }
     
          if(mb_stristr2('.bcos',$aso_info1['docu_tabla']))
          {
               if(!empty($aso_info1['ctab']))
               {
                    $ctab_descri=$aso_info1['ctab'].' /'.(($aso_info1['ctab_descri']));
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='background-color:'.$aso_info1['ctab_color'].';';
                         $xstyle.='font-weight:bold;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','CTA.BANC. :'));
                         $xstyle='text-align:right;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',$ctab_descri));
//                          $xstyle='background-color:'.$aso_info1['ctab_color'].';';
//                          $tcol->setAttribute('style',$xstyle);
               }
          }
     
          if(mb_stristr2('.caja.bcos',$aso_info1['docu_tabla']))
          {
               if(!empty($aso_info1['caba2']))
               {
                    $caba2=data_maes('caba',$aso_info1['caba2']);
                    $caba_descri=$aso_info1['caba2'].' /'.(($caba2['caba_descri']));
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='background-color:'.$caba2['caba_color'].';';
                         $xstyle.='font-weight:bold;';
                         $trow->setAttribute('style',$xstyle);
                    
                    if(mb_stristr2('.IE13.DB13.DB10',$aso_info1['docu']))
                    {$tcol=$trow->appendChild($domg->createElement('td','ORIGEN :'));}
                    else
                    {$tcol=$trow->appendChild($domg->createElement('td','DESTINO :'));}
                         $xstyle='text-align:right;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',$caba_descri));
//                          $xstyle='background-color:'.$caba2['caba_color'].';';
//                          $tcol->setAttribute('style',$xstyle);
               }
          }
     
          if(mb_stristr2('.inve.infi.prXod',$aso_info1['docu_tabla']))
          {
               if(!empty($aso_info1['bode']))
               {
                    $bode_descri=$aso_info1['bode'].' /'.(($aso_info1['bode_descri']));
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='background-color:'.$aso_info1['bode_color'].';';
                         $xstyle.='font-weight:bold;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','BODEGA :'));
                         $xstyle='text-align:right;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',$bode_descri));
//                          $xstyle='background-color:'.$aso_info1['bode_color'].';';
//                          $tcol->setAttribute('style',$xstyle);
               }

               if(!empty($aso_info1['bode2']))
               {
                    $bode20=data_maes('bode',$aso_info1['bode2']);
     //                $lblbode2='DESTINO';
                    if($docu=='IB13')
                    {
                         $lblbode2='ORIGEN';
                         $docu13='EB13';
                         $idii13=$aso_info1['idfrom'];
                    }
                    
                    if($docu=='EB13')
                    {
                         $lblbode2='DESTINO';
                         $docu13='IB13';
                         $sql_ii13='select * from inve1 where ifnull(status,"")!="X" and idfrom="'.$aso_info1['idnum1'].'" ';
                         $res_ii13=msql_query($sql_ii13,$link_data);
                         $idii13=msql_result($res_ii13,0,'idnum1');
                    }
                    
                    $href='';
                    $href.='https://'.$_SERVER['SERVER_NAME'].'/';
//                     if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                     {$href.='index3.php';}
                    $href.='?scri=info_docu3';
                    $href.='&prnt=1';
                    $href.='&docu='.$docu13.'';
                    $href.='&idnum='.$idii13.'';
                    
                    $bode_descri=$aso_info1['bode2'].' /'.(($bode20['bode_descri']));
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='background-color:'.$bode20['bode_color'].';';
                         $xstyle.='font-weight:bold;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',$lblbode2.' :'));
                         $xstyle='text-align:right;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',''));
//                          $xstyle='background-color:'.$bode20['bode_color'].';';
//                          $tcol->setAttribute('style',$xstyle);
                    
                         $ref=$tcol->appendChild($domg->createElement('a',$bode_descri));
                              $ref->setAttribute('href',$href);
                    
                    
                    
                    
                    if($aso_info1['dias']!=0)
                    {
//                          $trow=$ttbl->appendChild($domg->createElement('div',''));
                         $trow=$tcol->appendChild($domg->createElement('span',' ==> '));
                         $tcol=$trow->appendChild($domg->createElement('span',$aso_info1['dias']));
                         $tcol=$trow->appendChild($domg->createElement('span',' DIAS '));
                         
                    }
                    
                    
               }


               if(mb_stristr2('.IB11.EB11',$docu))
               {
                    if($docu=='IB11')
                    {
                         $docu11='EB11';
                         $sql_ii11='select * from inve1 where ifnull(status,"")not in("O","X") and docu="'.$docu11.'" and idfrom="'.$aso_info1['idnum1'].'"';
                         $res_ii11=msql_query($sql_ii11,$link_data);
                         $idii11=msql_result($res_ii11,0,'idnum1');
                         $nume11=msql_result($res_ii11,0,'numero');
                    }
                    
                    
                    
                    if($docu=='EB11')
                    {
                         $docu11='IB11';
                         $sql_ii11='select * from inve1 where ifnull(status,"")not in("O","X") and docu="'.$docu11.'" and idnum1="'.$aso_info1['idfrom'].'"';
                         $res_ii11=msql_query($sql_ii11,$link_data);
                         $idii11=msql_result($res_ii11,0,'idnum1');
                         $nume11=msql_result($res_ii11,0,'numero');
                    }
                    
                    $href='';
                    $href.='https://'.$_SERVER['SERVER_NAME'].'/';
                    if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
                    {$href.='index3.php';}
                    $href.='?scri=info_docu3';
                    $href.='&prnt=1';
                    $href.='&docu='.$docu11.'';
                    $href.='&idnum='.$idii11.'';
                    
//                     $bode_descri=$aso_info1['bode2'].' /'.(($bode20['bode_descri']));
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $tcol=$trow->appendChild($domg->createElement('td','RELACIONADO'.' :'));
                         $xstyle='text-align:right;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',''));
//                          $xstyle='background-color:'.$bode20['bode_color'].';';
//                          $tcol->setAttribute('style',$xstyle);
                    
                         $ref=$tcol->appendChild($domg->createElement('a',$docu11.' - '.$nume11));
                              $ref->setAttribute('href',$href);
                    
               }
          }

          if($docu!='NC10')
          if(!empty($aso_info1['todocu']) )
          {
               $lbldocu2='APLICA';
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td',$lbldocu2.' :'));
                    $xstyle='text-align:right;';
                    $tcol->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['todocu'].' - '.$aso_info1['toptoe'].'-'.$aso_info1['tonume']));

               if($aso_info1['dias']!=0)
               {
//                          $trow=$ttbl->appendChild($domg->createElement('div',''));
//                          $trow=$tcol->appendChild($domg->createElement('span',' ==> '));
//                          $tcol=$trow->appendChild($domg->createElement('span',$aso_info1['dias']));
//                          $tcol=$trow->appendChild($domg->createElement('span',' DIAS '));

               }

          }

          if(!empty($aso_info1['numfac']) )
          {
//                $bode20=data_maes('bode',$bode2);
//                $lbldocu2='FACTURA';
               $lbldocu2='';
               if($docu=='IB10'){$lbldocu2='FACTURA';}
               if($docu=='EB10'){$lbldocu2='FACTURA';}
               if($docu=='EB19'){$lbldocu2='ORDEN';}
               if($docu=='IB12'){$lbldocu2='N/C';}
               if($docu=='EB12'){$lbldocu2='N/C';}
               if($docu=='IB15'){$lbldocu2='FACTURA';}
//                     if($docu=='IB13'){$lblbode2='ORIGEN';}
//                $bode_descri=$aso_info1['bode2'].' /'.(($bode20['bode_descri']));

               if(!empty($lbldocu2))
               {
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $tcol=$trow->appendChild($domg->createElement('td',$lbldocu2.' :'));
                         $xstyle='text-align:right;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['numfac']));
//                     $col=$tcol->appendChild($domg->createElement('a',$aso_info1['numfac']));

//                     $href='';
//                     $href.='https://'.$_SERVER['SERVER_NAME'].'/';
//                     if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                     {$href.='index3.php';}
//                     $href='?scri=info_docu3&prnt=1';
//                     $href.='&docu='.$aso_abon['docu'].'&idnum='.$aso_abon['idnum1_hide'].'';
//                     $ref=$tcol->appendChild($domg->createElement('a',htmlspecialchars($aso_info1['numfac'])));                           
//                     $ref->setAttribute('num',$value);
//                     $ref->setAttribute('href',$href);
//                     $ref->setAttribute('target','_blank');
                    
                    
               }

               if($aso_info1['dias']!=0)
               {
//                          $trow=$ttbl->appendChild($domg->createElement('div',''));
//                          $trow=$tcol->appendChild($domg->createElement('span',' ==> '));
//                          $tcol=$trow->appendChild($domg->createElement('span',$aso_info1['dias']));
//                          $tcol=$trow->appendChild($domg->createElement('span',' DIAS '));

               }

          }

          if(!empty($aso_info1['impor']))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('bold','');
               $tcol=$trow->appendChild($domg->createElement('td','IMPORTACION :'));
                    $xstyle='text-align:right;';
                    $tcol->setAttribute('style',$xstyle);
               $ximpor=$aso_info1['impor'];
               $tcol=$trow->appendChild($domg->createElement('td',''));
               $aref=$tcol->appendChild($domg->createElement('a',$ximpor));
//                echo '=== '.$cost;
               if($cost=='true')
               {
                    $sql_impo='select * from prov1 where ifnull(status,"")not in ("O","X") and docu="DA16" and trim(impor)="'.$ximpor.'"';
                    $res_impo=msql_query($sql_impo,$link_data);
                    $idimpo=msql_result($res_impo,0,'idnum1');
                    
                    $href='';
                    $href.='https://'.$_SERVER['SERVER_NAME'].'/';
                    $href.='?scri=info_docu3';
                    $href.='&prnt=1';
                    $href.='&docu=DA16';
                    $href.='&idnum='.$idimpo.'';
                    $href.='&bode=1';
                    
                    $aref->setAttribute('href',$href);
                    $aref->setAttribute('target','_blank');

               }
               
               
               
          }

          if(!empty($aso_info1['nume_impo']))
          {
//                $trow=$ttbl->appendChild($domg->createElement('tr',''));
//                $tcol=$trow->appendChild($domg->createElement('td','IMPORTACION :'));
//                     $xstyle='text-align:right;';
//                     $tcol->setAttribute('style',$xstyle);
//                $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['nume_impo']));
          }
     
//      echo '*/*/*'.$aso_info1['ambice'];
          if(!empty($claveacc))
          {

     
          if(mb_stristr2('.vtas.comp.retp.retc.guia',$aso_info1['docu_tabla']))
          {
               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; font-size:80%';
                    $tcol->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td',$ambice));
               
               
               $btn_atrz=0;
               if(mb_stristr2('.vtas.retp.guia',$aso_info1['docu_tabla']) or mb_stristr2('.FP03',$aso_info1['docu'])){$btn_atrz=1;}
               if(empty($aso_info1['autorfec'])){$btn_atrz=$btn_atrz *1;}
               
               $horaActual = new DateTime();
               $horaActual->modify('-5 minutes');
               $xhora=$horaActual->format('Y-m-d H:i:s');
//                if($aso_info1['recepfec']>=$xhora){$btn_atrz=0;}
               if(!empty($aso_info1['autorfec'])){$btn_atrz=0;}
               if(empty($user0['user_tipo'])){$btn_atrz=0;}
               
               
               if($btn_atrz==1)
               {
                    $btn_atrz=$tcol->appendChild($domg->createElement('button','Aut.SRI'));
                         $btn_atrz->setAttribute('title','Autorizar en SRI');
                         $btn_atrz->setAttribute('noprinter','');
                         $btn_atrz->setAttribute('style','float:right;background:royalblue;color:white;font-weight:bold; font-size:1.0em;');
                         $btn_atrz->setAttribute('onclick','{atrz_docu("'.$docu.'","'.$idnum.'");}');
               }
          }
     
          $xml_file='../_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.xml';
          if(!file_exists($xml_file))
          {$xml_file='../_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.sign.xml';}
          if(!file_exists($xml_file))
          {$xml_file='../_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.sri.xml';}
          $xml_file=str_replace('../','https://'.$file_server.'/',$xml_file);
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
//                if($modu=='rmed'){$xstyle='display:none;';}
               if($modu=='rmed'){$trow->setAttribute('noprinter','');}
               $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',''));
               $href=$tcol->appendChild($domg->createElement('span',''));
                    $href->setAttribute('href',$xml_file);
                    $href->setAttribute('target','_blank');
               $clave1=$href->appendChild($domg->createElement('div',$aso_info1['claveacc1']));
                    $clave1->setAttribute('noprinter','');
                    $xstyle='font-size:90%;';
                    $tcol->setAttribute('style',$xstyle);
                    $onclick='{navigator.clipboard.writeText("'.$aso_info1['claveacc'].'")}';
                    $onclick.='{swal_fire("<msg><icon>info</icon><title>Se copió al PortaPapeles</title><text>'.$aso_info1['claveacc1'].'</text><timer>3000</timer></msg>")}';
                    $clave1->setAttribute('onclick',$onclick);
               
               if(empty($mailsend))
               {
               $clave2=$tcol->appendChild($domg->createElement('div',$aso_info1['claveacc2']));
                    $clave2->setAttribute('noscreen','');
               }
               
               
          }

          if(!empty($aso_info1['firmafec']) and empty($aso_info1['autorfec']))
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','FIRMADO :'));
               $xstyle='text-align:right;font-size:80%;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $href=$tcol->appendChild($domg->createElement('a',''));
                    $href->setAttribute('href','https://'.$file_server.'/_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.sign.xml');
                    $href->setAttribute('target','_blank');
               $autorfec=$href->appendChild($domg->createElement('div',$aso_info1['firmafec']));
//                     $autorfec->setAttribute('style','background:darkred;color:white;font-weight:bold');
          }

               
               
          if(!empty($aso_info1['autorfec']))
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','AUTORIZADO :'));
               $xstyle='text-align:right;font-size:80%;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $href=$tcol->appendChild($domg->createElement('a',''));
                    $href->setAttribute('href','https://'.$file_server.'/_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.sri.xml');
                    $href->setAttribute('target','_blank');
               $autorfec=$href->appendChild($domg->createElement('div',$aso_info1['autorfec']));
//                     $autorfec->setAttribute('style','background:darkred;color:white;font-weight:bold');
          }

     
               
          }
     
          if(empty($mailsend))
          if(mb_stristr2('.XOA',$aso_info1['status']))
          {
               $stat_descri=$aso_info1['stat_descri'];
               
               $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);
               
               
               $xstyle='';
               if(mb_stristr2('.XO',$aso_info1['status']))
               {
                    $xstyle.='background:darkred;color:white;font-weight:bold';
                    $stat_descri.=' => '.$aso_info1['odate'];
                    if($_SESSION['user_codigo']==2)
                    {$stat_descri.=' ('.$aso_info1['ouser'].')';}
                    
               }
               if(mb_stristr2('.A',$aso_info1['status']))
               {
                    $xstyle.='background:green;color:white;font-weight:bold';
                    $stat_descri.=' => '.$aso_info1['adate'];
               }
               
               $tcol=$trow->appendChild($domg->createElement('td',$stat_descri));
                    $tcol->setAttribute('style',$xstyle);
               
//                if(mb_stristr2('.XO',$aso_info1['status']))
//                {$tcol->setAttribute('style','background:darkred;color:white;font-weight:bold');}
//                if(mb_stristr2('.A',$aso_info1['status']))
//                {$tcol->setAttribute('style','background:green;color:white;font-weight:bold');}
          }

     
          if(empty($mailsend))
          if(mb_stristr2('.-',$aso_info1['status']))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='';
                    $trow->setAttribute('style',$xstyle);
                    $trow->setAttribute('hide','');
                    $trow->setAttribute('noprint','');
               $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']));
               
               if(mb_stristr2('.PS.PP.PC.PF',substr($aso_info1['docu'],0,2)))
               {
                    $acce_docu=accexdocu($aso_info1['docu']);
                    if($acce_docu['apro']==1)
                    {
                         $trow->removeAttribute('hide');

                         if($acce_user['apro']==1)
                         {
                              $btn_apro=$tcol->appendChild($domg->createElement('button','Aprobar'));
                              $btn_apro->setAttribute('title','Aprobar Documento');
                              $btn_apro->setAttribute('style','float:right;background:green;color:white;font-weight:bold; font-size:1em;');
                              $tconfirm=$docu.'-'.(int)$aso_info1['numero'];
                              $btn_apro->setAttribute('onclick','{prcs_docu("'.$docu.'","'.$idnum.'","A","'.$tconfirm.'","refresh");}');
                         }
                    }
                    
                    
               }
               
//                if($user_codigo==2)
               if($modu=='clie' or $modu=='otbj')
               {
                    $btn_fact=0;
                    $acce_userf=accexuser($_SESSION['user_codigo'],'FC');
                    if($acce_userf['nuev']==1){$btn_fact=1;}
                    
                    if($acce_docu['apro']==1 and $aso_info1['status']!='A'){$btn_fact=0;}
                         
                    if($btn_fact==1)
                    {
                         $trow->removeAttribute('hide');
                         
                         if(mb_stristr2('.deXmo.luca',$empr0['empr_codigo']))
                         {
                         $btn_fact=$tcol->appendChild($domg->createElement('button','NO/Venta'));
                              $btn_fact->setAttribute('accesskey','N');
                              $btn_fact->setAttribute('noprinter','');
                              $btn_fact->setAttribute('title','No/Venta '.$aso_info1['docu_descri']);
                              $btn_fact->setAttribute('style','float:right;background:blue;color:white;font-weight:bold; font-size:1em;');
                              $btn_fact->setAttribute('onclick','{clie2vtas("'.$docu.'","'.$idnum.'","FC90","'.$aso_info1['ptov'].'");}');
                              
                         $btn_fact=$tcol->appendChild($domg->createElement('button','_'));
                              $btn_fact->setAttribute('style','float:right;background:; color:white;font-weight:bold; font-size:1em;');
                         }
                         
                         $btn_fact=$tcol->appendChild($domg->createElement('button','Facturar'));
                              $btn_fact->setAttribute('accesskey','F');
                              $btn_fact->setAttribute('noprinter','');
                              $btn_fact->setAttribute('title','Facturar '.$aso_info1['docu_descri']);
                              $btn_fact->setAttribute('style','float:right;background:navy;color:white;font-weight:bold; font-size:1em;');
                              $btn_fact->setAttribute('onclick','{clie2vtas("'.$docu.'","'.$idnum.'","FC10","'.$aso_info1['ptov'].'");}');
                         
                    }
               }
               
               
               
          }
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $xstyle='';
               if($docu=='DA16'){$xstyle='display:none;';}
               $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');

               {
               $href='';
               $href.='https://api.whatsapp.com/send/';
               $href.='?phone=';
               $href.='&text='.$wa_text;
     
               $wap_l=$tcol->appendChild($domg->createElement('a','WsApp'));
                    $wap_l->setAttribute('href',$href);
                    $wap_l->setAttribute('target','_blank');
               }

     
     
     
               if(!empty($claveacc))
               {
                    
               $xml_file='../_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.xml';
               if(!file_exists($xml_file))
               {$xml_file='../_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.sign.xml';}
               if(!file_exists($xml_file))
               {$xml_file='../_cele/'.str_replace('-','',$aso_info1['fecha']).'/'.$aso_info1['claveacc'].'.sri.xml';}
     
               if(mb_stristr2('.vtas.comp.retp.retc.guia.',$aso_info1['docu_tabla']))
               {
                    $xml_file=str_replace('../','https://'.$file_server.'/',$xml_file);
                    $span=$tcol->appendChild($domg->createElement('span',' - '));
                    $xml_l=$tcol->appendChild($domg->createElement('a','XML'));
                         $xml_l->setAttribute('href',$xml_file);               
                         $xml_l->setAttribute('target','_blank');
               }
               
               $span=$tcol->appendChild($domg->createElement('span',' - '));
               $htm_l=$tcol->appendChild($domg->createElement('a','HTML'));
//                     $htm_f='/docu/'.$claveacc.'.html';
                    $htm_f='/-docu/'.$claveacc.'.html';
//                     $htm_l->setAttribute('href','https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/docu/'.$claveacc.'.html');
                    $htm_l->setAttribute('href','https://'.$file_server.'/'.strtolower($empr0['empr_codigo']).'/-docu/'.$claveacc.'.html');
                    $htm_l->setAttribute('target','_blank');
               
               $span=$tcol->appendChild($domg->createElement('span',' - '));
               $pdf_l=$tcol->appendChild($domg->createElement('a','PDF'));
                    $pdf_l->setAttribute('href','https://'.$file_server.'/_lib/crea_html2pdf.php?desti=2&empr='.strtolower($empr0['empr_codigo']).'&clave='.$claveacc.'');
                    $pdf_l->setAttribute('target','_blank');
               }
     
     
               if($empr0['empr_codigo']=='mhec')
               if(mb_stristr2($emis0['enti_descri'],'COSTCO'))
               {
                    $span=$tcol->appendChild($domg->createElement('span',' - '));
                    $htm_l=$tcol->appendChild($domg->createElement('a','FAC_EXT'));
//                          $htm_f='/docu/'.$claveacc.'.html';
                         $htm_f='/-docu/'.$claveacc.'.html';
//                          $htm_l->setAttribute('href',$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'&espe=costco');
                         $htm_l->setAttribute('href',$_SERVER['REQUEST_URI'].'&espe=costco');
                         $htm_l->setAttribute('target','_blank');
                    
//                     echo '<br>==='.$_SERVER['HTTP_HOST'];
//                     echo '<br>==='.$_SERVER['REQUEST_URI'];
               }
     
                    
               $clac0=data_maes('clac',$claveacc);
               if(mb_stristr2('.vtas.retp.guia',$modu) or mb_stristr2('.FP03',$docu) )     
               if(!empty($aso_info1['recepmsj']))
               if(empty($aso_info1['autorfec']))
               {
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='';
                         $trow->setAttribute('style',$xstyle);
                         $trow->setAttribute('noprinter','');
                         $trow->setAttribute('bold','');
                    
                    $errlbl='';
                    if(empty(err_autor($aso_info1['autormsj'])))
                    {$trow->setAttribute('orange',''); $errlbl='RECEPCION :';}
                    else{$trow->setAttribute('red',''); $errlbl='AUTORIZACION :'; }
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$errlbl));
//                          $xstyle='text-align:right;font-size:80%;';
                         $xstyle='text-align:right;font-size:75%;';
                         $tcol->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['recepmsj'].' :: '.$aso_info1['autormsj']));
               }

     
     
}




          // RESUMEN
{
                    $hrefc='';
                    $hrefc.='https://'.$_SERVER['SERVER_NAME'].'/';
//                     if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                     {$hrefc.='index3.php';}
                    $hrefc.='?scri=info_docu3';
                    $hrefc.='&prnt=1';
                    $hrefc.='&docu='.$aso_info1['docu'].'';
                    $hrefc.='&idnum='.$aso_info1['idnum1'].'';
                    if(!empty($bode))
                    {$hrefc.='&bode='.$bode.'';}
                    if(!empty($abon))
                    {$hrefc.='&abon='.$abon.'';}
                    if($cont==2){{$hrefc.='&cont=1';}}
                    else{$hrefc.='&cont=2';}
     
                    $hrefb='';
                    $hrefb.='https://'.$_SERVER['SERVER_NAME'].'/';
//                     if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                     {$hrefb.='index3.php';}
                    $hrefb.='?scri=info_docu3';
                    $hrefb.='&prnt=1';
                    $hrefb.='&docu='.$aso_info1['docu'].'';
                    $hrefb.='&idnum='.$aso_info1['idnum1'].'';
                    if(empty($bode))
                    {$hrefb.='&bode=1';}
                    if(!empty($abon))
                    {$hrefb.='&abon='.$abon.'';}
     
                    $pcont=$cont;
//                     if($aso_info1['fecha']>=date('Y-m-d',strtotime('-1 week'))){$pcont=3;}
                    if($aso_info1['idate']>=date('Y-m-d',strtotime('-1 week'))){$pcont=3;}
     
                    if(!empty($cont))
                    {$hrefb.='&cont='.$pcont.'';}
     
                    $hrefa='';
                    $hrefa.='https://'.$_SERVER['SERVER_NAME'].'/';
//                     if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                     {$hrefa.='index3.php';}
                    $hrefa.='?scri=info_docu3';
                    $hrefa.='&prnt=1';
                    $hrefa.='&docu='.$aso_info1['docu'].'';
                    $hrefa.='&idnum='.$aso_info1['idnum1'].'';
                    if(!empty($bode))
                    {$hrefa.='&bode='.$bode.'';}
                    if(empty($abon))
                    {$hrefa.='&abon=1';}
                    if(!empty($cont))
                    {$hrefa.='&cont='.$cont.'';}
     
     
     
          $ttbl=$resu->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='cellpadding:5px;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

          $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($cont!=1)
          {
               if(mb_stristr2('.inve.infi.opro.',$modu))
               {
                    $xtotal=abs($aso_info1['total']);
     //                $xtotal=0;

                    $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(abs($aso_info1['tcant']),2)));

                    if(empty($user_cost))
                    {$xtotal=0;}

                    if($user_cost==1)
                    {
                    $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',' '));
     //                     $onclick='{window.open("'.$hrefc.'","_self")}';
     //                     $tcol->setAttribute('onclick',$onclick);
                         $link=$tcol->appendChild($domg->createElement('a',number_format(abs($aso_info1['total']),2)));
                         $link->setAttribute('href',$hrefc);
                         $xstyle='font-size:120%;';
                         $tcol->setAttribute('style',$xstyle);
                    }

               }

               if(mb_stristr2('.pduc.',$modu))
               {
                    $xtotal=abs($aso_info1['total']);
     //                $xtotal=0;

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

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

                    if(empty($user_cost))
                    {$xtotal=0;}

                    if($user_cost==1)
                    {
                    $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',' '));
     //                     $onclick='{window.open("'.$hrefc.'","_self")}';
     //                     $tcol->setAttribute('onclick',$onclick);
                         $link=$tcol->appendChild($domg->createElement('a',number_format(abs($aso_info1['total']),2)));
                         $link->setAttribute('href',$hrefc);
                         $xstyle='font-size:120%;';
                         $tcol->setAttribute('style',$xstyle);
                    }

               }

               if(mb_stristr2('.guia',$modu))
               {
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $xstyle.='font-weight:bold;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','UNIDADES :'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['tcant']),2)));
                         $xstyle='font-size:120%;';
                         $tcol->setAttribute('style',$xstyle);
               }

               if(mb_stristr2('.hcli',$modu))
               {
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','SIGNOS VITALES'));
                         $tcol->setAttribute('colspan',2);
                         $xstyle='';
                         $xstyle.='text-align:right;';
                         $xstyle.='letter-spacing:1.5pt;';
                         $trow->setAttribute('style',$xstyle);

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','Temperatura Corporal :'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['tempcor']),1)));

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','Frecuencia Respiratoria :'));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['freqres']));

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','Frecuencia Cardíaca :'));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['freqcar']));

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','Presión Arterial :'));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['presart']));


                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','EXPLORACION'));
                         $tcol->setAttribute('colspan',2);
                         $xstyle='';
                         $xstyle.='text-align:right;';
                         $xstyle.='letter-spacing:1.5pt;';
                         $trow->setAttribute('style',$xstyle);

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','Peso Kg. :'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['pesokg']),2)));

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


               }

               if(mb_stristr2('.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',' '));
     //                     $onclick='{window.open("'.$hrefb.'","_self")}';
     //                     $tcol->setAttribute('onclick',$onclick);
                    $link=$tcol->appendChild($domg->createElement('a',number_format(abs($aso_info1['tcant']),2)));
                    $link->setAttribute('href',$hrefb);
                    $xstyle='font-size:120%;';
                    $xstyle.='font-weight:bold;';
                    $tcol->setAttribute('style',$xstyle);



                    $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(abs($aso_info1['tsubt']),2)));


                    if($aso_info1['tdcto']>0)
                    {
                         $sql_dcto='select distinct dcto from '.$modu.'2 where idnum2 ='.$idnum;
                         $res_dcto=msql_query($sql_dcto,$link_data);
                         $dcto_porc=0;
                         if(msql_num_rows($res_dcto)==1)
                         {$dcto_porc=msql_result($res_dcto,0,'dcto');}

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right; text-decoration:underline;';
                         $trow->setAttribute('style',$xstyle);
                    $dcto_descri='DESCUENTOS : ';     
                    if(!empty($dcto_porc))
                    {$dcto_descri='Descuento '.round($dcto_porc,2).'% ';}

                    $tcol=$trow->appendChild($domg->createElement('td',$dcto_descri));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['tdcto']),2)));

                    }

     //                if(1==2)
                    if($aso_info1['tprop']>0)
                    {
                         $sql_prop='select distinct prop from '.$modu.'2 where idnum2 ='.$idnum;
                         $res_prop=msql_query($sql_prop,$link_data);
                         $prop_porc=0;
                         if(msql_num_rows($res_prop)==1)
                         {$prop_porc=msql_result($res_prop,0,'prop');}

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right; text-decoration:underline;';
                         $trow->setAttribute('style',$xstyle);
                    $prop_descri='Propina : ';     
                    if(!empty($prop_porc))
                    {$prop_descri='Propina '.round($prop_porc,2).'% ';}

                    $tcol=$trow->appendChild($domg->createElement('td',$prop_descri));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['tprop']),2)));

                    }

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         if(mb_stristr2('.comp.prov',$modu) and $aso_info1['subtiva0']==0)
                         {$xstyle='display:none;';}
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','Sub-Total IVA 0%'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['subtiva0']),2)));



                    //
                    $ivax=$aso_info1['iva'];
                    if($ivax<=0){$ivax=$_SESSION['porc_iva'];}
     //                echo '==='.$_SESSION['porc_iva'];

                    if(1==2)
                    {
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         if(mb_stristr2('.comp.prov',$modu) and $aso_info1['subtiva']==0)
                         {$xstyle='display:none;';}
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','Sub-Total IVA '.number_format($ivax,0).'%'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['subtiva']),2)));


                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right; font-style:italic;';
                         if(mb_stristr2('.comp.prov',$modu) and $aso_info1['tiva']==0)
                         {$xstyle='display:none;';}
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','IVA '.number_format($ivax,0).'%'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['tiva']),2)));
                         $xstyle='font-style:italic;';
                         $tcol->setAttribute('style',$xstyle);
                    }



     //                if($user_codigo==2)
                    if(mb_stristr2('.vtas.comp.clie.prov',$modu))
                    while($aso_info3=msql_fetch_assoc($res_info3))
                    {
                         if($aso_info3['iva']!=0)
                         {
                              $trow=$ttbl->appendChild($domg->createElement('tr',''));
                                   $xstyle='text-align:right;';
                                   if(mb_stristr2('.comp.prov',$modu) and $aso_info3['subtiva']==0)
                                   {$xstyle='display:none;';}
                                   $trow->setAttribute('style',$xstyle);
                              $tcol=$trow->appendChild($domg->createElement('td','Sub-Total IVA '.number_format($aso_info3['iva'],0).'%'));
                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info3['subtiva']),2)));

                              $trow=$ttbl->appendChild($domg->createElement('tr',''));
                                   $xstyle='text-align:right; font-style:italic;';
                                   if(mb_stristr2('.comp.prov',$modu) and $aso_info3['tiva']==0)
                                   {$xstyle='display:none;';}
                                   $trow->setAttribute('style',$xstyle);
                              $tcol=$trow->appendChild($domg->createElement('td','IVA '.number_format($aso_info3['iva'],0).'%'));
                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info3['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',' '));
     //                     $onclick='{window.open("'.$hrefc.'","_self")}';
     //                     $tcol->setAttribute('onclick',$onclick);
                         $link=$tcol->appendChild($domg->createElement('a',number_format(abs($aso_info1['total']),2)));
                         $link->setAttribute('href',$hrefc);
                         $xstyle='font-size:150%;';
                         if($docu=='DA16'){$xstyle='font-size:120%;';}
                         $tcol->setAttribute('style',$xstyle);



                    if($docu=='DA16')
                    {
     //                $trow=$ttbl->appendChild($domg->createElement('tr',''));
     //                     $xstyle='text-align:right;';
     //                     $xstyle.='font-weight:bold;';
     //                     $trow->setAttribute('style',$xstyle);
     //                $tcol=$trow->appendChild($domg->createElement('td','KILOS :'));
     //                $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['peso']),2)));
     //                     $xstyle='font-size:120%;';
     //                     $tcol->setAttribute('style',$xstyle);


                    }



                    }

               if(mb_stristr2('.caja.bcos.caba',$modu))
               {

                    $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(abs($aso_info1['total']),2)));
                    $tcol=$trow->appendChild($domg->createElement('td',' '));
     //                     $onclick='{window.open("'.$hrefc.'","_self")}';
     //                     $tcol->setAttribute('onclick',$onclick);
                         $link=$tcol->appendChild($domg->createElement('a',number_format(abs($aso_info1['total']),2)));
                         $link->setAttribute('href',$hrefc);
                         $xstyle='font-size:150%;';
                         $tcol->setAttribute('style',$xstyle);



                    }

               if(mb_stristr2('.retc.retp.',$modu))
               {
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','RET.IVA :'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['rete_iva']),2)));

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','RET.RENTA :'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['rete_rta']),2)));

                    $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 :'));
     //                     $onclick='{window.open("'.$hrefc.'","_self")}';
     //                     $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trow->appendChild($domg->createElement('td',' '));
                         $link=$tcol->appendChild($domg->createElement('a',number_format(abs($aso_info1['total']),2)));
                         $link->setAttribute('href',$hrefc);
                         $xstyle='font-size:150%;';
                         $tcol->setAttribute('style',$xstyle);



                    }
               
               if(mb_stristr2('.otbj.',$modu))
               {
                    $tot_mmoo=0;
                    $tot_repu=0;
                    while($aso_info3=msql_fetch_assoc($res_info3))
                    {
                         if(stripos($aso_info3['fase'],'trabajo')!==false){$tot_mmoo+=$aso_info3['tsubt']; }
                         if(stripos($aso_info3['fase'],'contrato')!==false){$tot_mmoo+=$aso_info3['tsubt'];}
                         if(stripos($aso_info3['fase'],'repuesto')!==false){$tot_repu+=$aso_info3['tsubt'];}
                    }
                         
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','TRABAJOS M.O. :'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($tot_mmoo,2)));

                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right;';
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','REPUESTOS :'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($tot_repu,2)));

                    
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $xstyle='text-align:right; font-style:italic;';
                         if($aso_info1['tiva']==0)
                         {$xstyle='display:none;';}
                         $trow->setAttribute('style',$xstyle);
                    $tcol=$trow->appendChild($domg->createElement('td','IVA '.number_format($aso_info1['iva'],0).'%'));
                    $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($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',' '));
                         $link=$tcol->appendChild($domg->createElement('a',number_format(abs($aso_info1['total']),2)));
                         $link->setAttribute('href',$hrefc);
                         $xstyle='font-size:150%;';
                         $tcol->setAttribute('style',$xstyle);



                    }
               
          }
     
          if($modu=='cont' or $cont==1)
          {
               $xtotal=abs($aso_info1['total'])/2;
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','DEBITOS :'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info1['debito']),2)));

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

               
               $xdifer=abs($aso_info1['debito'])-abs($aso_info1['credito']);
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $xstyle='text-align:right;';
                    $xstyle.='font-weight:bold;';
                    $trow->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td','DIFERENCIA :'));
               $tcol=$trow->appendChild($domg->createElement('td',number_format($xdifer,2)));
                    $xstyle='font-size:150%;';
                    $tcol->setAttribute('style',$xstyle);
               
               if(abs($xdifer)>=1/100)
               {$trow->setAttribute('red','');}
               if(abs($xdifer)<1/100)
               {$trow->setAttribute('hide','');}



               }

     
}

     if($modu=='guia')
     {
          $ttbl=$dtra->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
//                if($tckt==1)
//                {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('cellpadding','1');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
          
          $tcolg=$ttbl->appendChild($domg->createElement('colgroup',''));
          $thead=$ttbl->appendChild($domg->createElement('thead',''));
          $tbody=$ttbl->appendChild($domg->createElement('tbody',''));
          $tfoot=$ttbl->appendChild($domg->createElement('tfoot',''));
          
          $col=$tcolg->appendChild($domg->createElement('col',""));
//                $col->setAttribute('style','font-weight: bold; background-color:'.$xbgcolor3.';');
          $col=$tcolg->appendChild($domg->createElement('col',""));
          $col=$tcolg->appendChild($domg->createElement('col',""));
//                $col->setAttribute('style','font-weight: bold; background-color:'.$xbgcolor3.';');
          $col=$tcolg->appendChild($domg->createElement('col',""));
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
               $trowh->setAttribute('style','border-top:solid 1px;');
          $tcol=$trowh->appendChild($domg->createElement('td','DATOS DEL TRANSPORTE'));
               $tcol->setAttribute('colspan','10');
               $xstyle='';    
               $xstyle.='letter-spacing:3pt;text-align:;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
          $tcol=$trowh->appendChild($domg->createElement('td','INICIO DEL TRANSPORTE:'));
//           $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['fecha1']));
//           echo strftime('Y-m-d',$aso_info1['fecha1']);
          $tcol=$trowh->appendChild($domg->createElement('td',strftime2('%A %d/%b/%Y',strtotime($aso_info1['fecha1']) )));
          if($post==1){$trowh=$thead->appendChild($domg->createElement('tr',''));}
          $tcol=$trowh->appendChild($domg->createElement('td','FIN DEL TRANSPORTE:'));
//           $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['fecha2']));
          $tcol=$trowh->appendChild($domg->createElement('td',strftime2('%A %d/%b/%Y',strtotime($aso_info1['fecha2']) )));
          
//           var_dump2($aso_info1);
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
               $trowh->setAttribute('style','border-top:solid 1px; font-weight:; background-color:'.$xbgcolor.';');
          $tcol=$trowh->appendChild($domg->createElement('td','No ID. CONDUCTOR:'));
          $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['cedula1']));
               $tcol->setAttribute('style','font-weight:bold;');
          if($post==1){$trowh=$thead->appendChild($domg->createElement('tr',''));}
          $tcol=$trowh->appendChild($domg->createElement('td','No ID. DESTINATARIO:'));
          $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['cedula2']));
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
//                $trow->setAttribute('style','font-weight: bold; background-color:'.$xbgcolor3.';');
          $tcol=$trowh->appendChild($domg->createElement('td','NOMBRE CONDUCTOR:'));
          $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['nombre1']));
          if($post==1){$trowh=$thead->appendChild($domg->createElement('tr',''));}
          $tcol=$trowh->appendChild($domg->createElement('td','NOMBRE. DESTINATARIO:'));
          $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['nombre2']));
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
               $trowh->setAttribute('style','border-top:solid 1px; font-weight:; background-color:'.$xbgcolor.';');
          $tcol=$trowh->appendChild($domg->createElement('td','PLACA DEL VEHICULO:'));
//           $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['placa']));
        $xplvh=$aso_info1['plvh'];
        if(empty($xplvh))
        {$xplvh=$aso_info1['placa'];}
          $tcol=$trowh->appendChild($domg->createElement('td',$xplvh.' / '.$aso_info1['plvh_descri']));
               $tcol->setAttribute('style','font-weight:bold;');
          if($post==1){$trowh=$thead->appendChild($domg->createElement('tr',''));}
          $tcol=$trowh->appendChild($domg->createElement('td','RUTA :'));
          $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['ruta']));
          
          $trowh=$thead->appendChild($domg->createElement('tr',''));
          $tcol=$trowh->appendChild($domg->createElement('td','PUNTO DE PARTIDA:'));
          $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['punto1']));
          if($post==1){$trowh=$thead->appendChild($domg->createElement('tr',''));}
          $tcol=$trowh->appendChild($domg->createElement('td','PUNTO DE LLEGADA:'));
          $tcol=$trowh->appendChild($domg->createElement('td',$aso_info1['punto2']));

          if($post==0)
          {
               $trowh=$thead->appendChild($domg->createElement('tr',''));
//                $trow->setAttribute('hide','');
               $tcol=$trowh->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('width','25%');
               $tcol=$trowh->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('width','25%');
               $tcol=$trowh->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('width','25%');
               $tcol=$trowh->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('width','25%');
               
          }
          
          
     }




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

          $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',''));
          $tcolia=$trow->appendChild($domg->createElement('td','INFORMACION ADICIONAL'));
               $tcolia->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:2pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcolia->setAttribute('style',$xstyle);

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


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

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

          if(!empty($aso_info1['proyecto']))
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','UBICACION'));
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['proyecto'].' : '.$aso_info1['pisomz'].' : '.$aso_info1['dptovi'].' / '.$aso_info1['infoadic']));
          }

          if($empr0['empr_garage']==1)
          if(mb_stristr2('FC.',substr($docu,0,2)))
          {
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','PLACA'));
//                     //
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['plvh'].' /'.$aso_info1['plvh_mrca'].' /'.$aso_info1['plvh_modelo']));

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','HORAS'));
//                     //
//                $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['hora1'].' &#10132; '.$aso_info1['hora2'].' = '.number_format($aso_info1['cant'],0).' Hora o Fracción'));
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['hora1'].' ➔ '.$aso_info1['hora2'].' ⚌ '.$aso_info1['hora12'].''));
                    $tcol->appendChild($domg->createElement('div','('.number_format($aso_info1['cant'],0).') Hora o Fracción'));
     
          }     
     
          if($empr0['empr_taller']==1)
          if(mb_stristr2('OT.',substr($docu,0,2)))
          {
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','PLACA'));
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['plvh'].' /'.$aso_info1['plvh_mrca'].' /'.$aso_info1['plvh_modelo']));

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','VINN'));
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['vinn']));
     
          }     
     
     
     
          if(!empty($aso_info1['infoadic']))
          {
               $infoadic=$aso_info1['infoadic'];
               $infoadic=str_replace('|',' |',$infoadic);
               $infoadic=str_replace('}{',',',$infoadic);
               $infoadic=json_decode($infoadic,true);
               
               $xcoli=1;               
               $x2col=0;
               if(count($infoadic)>8)
               {
                    $x2col=2;
                    $tcolia->setAttribute('colspan','4');
               }
               
               foreach($infoadic as $key1=>$val1)
               {
                    $xcoli++;
                    if($x2col!=2)                              
                    {$trow=$ttbl->appendChild($domg->createElement('tr',''));}
                    
                    if($x2col==2 and $xcoli % 2 ==0)
                    {$trow=$ttbl->appendChild($domg->createElement('tr',''));}
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$key1));
                         $tcol->setAttribute('style','font-weight:bold;');
                         if($x2col==2)
                         {$tcol->setAttribute('width','10%');}
                    
                    
                    $val1=alltrim($val1);
                    $tcol=$trow->appendChild($domg->createElement('td',$val1));
                         if($x2col==2)
                         {$tcol->setAttribute('width','30%');}
               }
          }
     
     

     
}


          // JWIB
if($empr0['empr_codigo']=='jwib')
{
          $ttbl=$jwib->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='cellpadding:5px;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','3');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');

          $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',''));
          $tcolia=$trow->appendChild($domg->createElement('td','JWIB'));
               $tcolia->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:2pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcolia->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']));
//           }
     
//           if(!empty($aso_info1['concepto']))
//           $trty=data_maes('trty',$aso_info1)
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','CONGREGACION'));
               $tcol=$trow->appendChild($domg->createElement('td',$cong0['cong_descri']));
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('style','font-size:2em; ');
               $tcol=$trow->appendChild($domg->createElement('td','TERRITORIO'));
                    $tcol->setAttribute('style','font-weight:bold; padding:5px 0 5px 0 ;');
//                $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['trty_descri']));
               $tcol=$trow->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','font-weight:bold; padding:5px 0 5px 0 ;');

               
               $href='https://'.$_SERVER['SERVER_NAME'].'/';
               if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
               {$href.='index3.php';}
               $href.='?scri=regi_jwrv3';
               $href.='&rtdocu='.$aso_info1['docu'];
               $href.='&rtidnum='.$aso_info1['idnum1'];
               $href.='&rtnumero='.$aso_info1['numero'];
//                $ref=$tcol->appendChild($domg->createElement('a',$aso_info1['docu'].'-'.$aso_info1['numero']));                           
               $ref=$tcol->appendChild($domg->createElement('a',$aso_info1['trty_descri']));                           
               $ref->setAttribute('href',$href);
               $ref->setAttribute('target','_blank');
               
               
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','REFERENCIA'));
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['trty_referencia']));
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','ASIGNADO A '));
               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['asignado']));
               
//                $trow=$ttbl->appendChild($domg->createElement('tr',''));
//                $tcol=$trow->appendChild($domg->createElement('td','LINK'));
//                $tcol=$trow->appendChild($domg->createElement('td',''));
               
                    
                    
                    
               
          }
     
}


          // FORMA DE PAGO
if($cont!=1)
if(mb_stristr2('.FC.FP',substr($docu1['docu'],0,2)))
{
          $ttbl=$fpag->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

     
          if(mb_stristr2('.vtas.comp',$modu) and !empty($aso_info1['fpag']))
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td',' '));
//                $onclick='{window.open("'.$hrefa.'","_self")}';
//                $tcol->setAttribute('onclick',$onclick);
               $tcol->setAttribute('colspan','2');
          $link=$tcol->appendChild($domg->createElement('span','FORMA DE PAGO'));
               $xstyle='';
               $xstyle.='letter-spacing:2pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
//                $link->setAttribute('href',$hrefa);
               

          $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',''));
          $link=$tcol->appendChild($domg->createElement('a',number_format($aso_info1['total'],2)));
               $link->setAttribute('href',$hrefa);
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          }
}


          // SUSTENTO DEL COMPROBANTE
if(mb_stristr2('.FP',substr($docu1['docu'],0,2)))
{
          $ttbl=$suco->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

     
          if(mb_stristr2('.comp',$modu) and !empty($aso_info1['suco']))
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','SUSTENTO DEL COMPROBANTE'));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='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['suco'].' - '.$suco0['suco_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);
          }
}



          // IMPORTACION
// if(mb_stristr2('.DA',substr($docu1['docu'],0,2)))
if($docu1['docu']=='DA16')     
{
          $totcif=$aso_info1['tsubt']+$aso_info1['costoe1']+$aso_info1['seguro1']+$aso_info1['flete1'];
          $totimpo=$totcif;
          $totimpo+=$aso_info1['tadva'];
          $totimpo+=$aso_info1['tfodi'];
          $totimpo+=$aso_info1['costol1'];
                         
     
     
          $ttbl=$impo->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','IMPORTACION : '.$aso_info1['impor']));
               $tcol->setAttribute('colspan','2');
               $xstyle='';
               $xstyle.='letter-spacing:pt;text-align:center;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $impo1=$trow->appendChild($domg->createElement('td',''));
          $impo2=$trow->appendChild($domg->createElement('td',''));
     
          $ttbl1=$impo1->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='float:left;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl1->setAttribute('style',$xstyle);
               $ttbl1->setAttribute('border','1');
               $ttbl1->setAttribute('width','100%');
               $ttbl1->setAttribute('cellspacing','0');
               $ttbl1->setAttribute('screen_fontsize','');
               $ttbl1->setAttribute('print_fontsize','');

          $ttbl2=$impo2->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='float:right;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl2->setAttribute('style',$xstyle);
               $ttbl2->setAttribute('border','1');
               $ttbl2->setAttribute('width','100%');
               $ttbl2->setAttribute('cellspacing','0');
               $ttbl2->setAttribute('screen_fontsize','');
               $ttbl2->setAttribute('print_fontsize','');
     
     
//           if(mb_stristr2('.vtas.comp',$modu) and !empty($aso_info1['fpag']))
          {
          $trow=$ttbl1->appendChild($domg->createElement('tr',''));
//           $tcol=$trow->appendChild($domg->createElement('td','IMPORTACION : '.$aso_info1['impor']));
//                $tcol->setAttribute('colspan','10');
//                $xstyle='';
//                $xstyle.='letter-spacing:pt;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','SUBTOTAL :'));
//                $xstyle='text-align:right;';
//                $tcol->setAttribute('style',$xstyle);
//           $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['total'],2)));
//                $xstyle='text-align:right;';
//                $tcol->setAttribute('style',$xstyle);
               
          $trow=$ttbl1->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','COSTOS EXTERIOR :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['costoe1'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['d_ce']));
               $xstyle='text-align:center;';
               $tcol->setAttribute('style',$xstyle);
               
          $trow=$ttbl1->appendChild($domg->createElement('tr',''));
               $xstyle='font-weight:bold;';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','FOB :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['total']+$aso_info1['costoe1'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               
          $trow=$ttbl1->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','SEGURO :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['seguro1'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['d_sg']));
               $xstyle='text-align:center;';
               $tcol->setAttribute('style',$xstyle);
               
          $trow=$ttbl1->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','FLETE :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['flete1'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['d_fl']));
               $xstyle='text-align:center;';
               $tcol->setAttribute('style',$xstyle);
               
          $trow=$ttbl1->appendChild($domg->createElement('tr',''));
               $xstyle='font-weight:bold;';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','CIF :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['total']+$aso_info1['costoe1']+$aso_info1['seguro1']+$aso_info1['flete1'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               
               
          $trow=$ttbl2->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','AD-VALOREM :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tadva'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);

          if($aso_info1['tespe']>0)
          {
          $trow=$ttbl2->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','ESPECIFICO :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tespe'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               
          }

          if($aso_info1['tdump']>0)
          {
          $trow=$ttbl2->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','DUMPING :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tdump'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          }

               
          $trow=$ttbl2->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','FODINFA :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tfodi'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               
          $trow=$ttbl2->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','COSTOS LOCALES :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['costol1'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['d_cl']));
               $xstyle='text-align:center;';
               $tcol->setAttribute('style',$xstyle);
               
               
               
          $trow=$ttbl2->appendChild($domg->createElement('tr',''));
               $xstyle='font-weight:bold;';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','TOTAL :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($totimpo,2)));
               $xstyle='text-align:right;';
               $xstyle.='font-size:120%;';
               $tcol->setAttribute('style',$xstyle);
               
          $trow=$ttbl2->appendChild($domg->createElement('tr',''));
               $xstyle='font-weight:bold;';
               $xstyle='';
               $trow->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td','KILOS :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info1['tpeso'],2)));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               
//           $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['d_cl']));
//                $xstyle='text-align:center;';
//                $tcol->setAttribute('style',$xstyle);
               
               
               
               
          }
}





if(mb_stristr2('.NC.NP',substr($docu1['docu'],0,2)))
{
          $ttbl=$docm->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');

     
          if(mb_stristr2('.vtas.comp',$modu))
          {
               $sql_modi='select * from '.$modu.'1 ';
               $sql_modi.='left join '.$modu.'2 on idnum1=idnum2 ';
               $sql_modi.='left join docu0 on docu=docu_codigo ';
               $sql_modi=calc_fields($modu,$sql_modi);
               $sql_modi.='where ifnull(status,"")not in ("X") ';
               $sql_modi.='and docu="'.$aso_info1['todocu'].'" and ptoe="'.$aso_info1['toptoe'].'" and numero="'.$aso_info1['tonume'].'"';
               if($modu=='comp')
               {$sql_modi.='and enti like "'.substr($aso_info1['enti'],0,10).'%"';}
               $res_modi=msql_query($sql_modi,$link_data);
               $aso_modi=msql_fetch_assoc($res_modi);     

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','MODIFICA'));
                    $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','COMPROB :'));
                    $xstyle='text-align:right;';
                    $tcol->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td',$aso_modi['docu_descri']));

               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','NUMERO :'));
                    $xstyle='text-align:right;';
                    $tcol->setAttribute('style',$xstyle);
               $tcol=$trow->appendChild($domg->createElement('td',''));
                    $hrefd='';
                    $hrefd.='https://'.$_SERVER['SERVER_NAME'].'/';
//                     if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                     {$hrefd.='index3.php';}
                    $hrefd.='?scri=info_docu3&prnt=1';
                    $hrefd.='&docu='.$aso_modi['docu'].'&idnum='.$aso_modi['idnum1'].'';
//                     $onclick='{window.open("'.$hrefd.'","_self");}';
//                     $tcol->setAttribute('onclick',$onclick);
                    $ref=$tcol->appendChild($domg->createElement('a',$aso_modi['ptoe'].' - '.$aso_modi['numero']));
//                     $ref=$tcol->appendChild($domg->createElement('a',htmlspecialchars((int)$aso_info2['numer'])));
//                     $ref->setAttribute('num',$value);
                    $ref->setAttribute('href',$hrefd);
                    $ref->setAttribute('target','_blank');
               
               

               $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',strtoupper($aso_modi['dmy1'])));
          }
}


if(mb_stristr2('.IB.EB.EP.SP',substr($docu1['docu'],0,2)))
{
          $ttbl=$fpag->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','1');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

     
          if(mb_stristr2('.inve.infi.',$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);
          }
}


if($modu=='rmed' and empty($post))
{
     $clonedNode = $dato->cloneNode(true);
     $dato1->appendChild($domg->importNode($clonedNode, true));     

     $clonedNode = $emis->cloneNode(true);
     $emis2->appendChild($domg->importNode($clonedNode, true));     

     $clonedNode = $adqu->cloneNode(true);
     $adqu2->appendChild($domg->importNode($clonedNode, true));     

     $emis2->nodeValue='';
     $adqu->nodeValue='';
}


          // NOTAS
{
          $ttbl=$nota->appendChild($domg->createElement('table',''));
               $xstyle='';
//                $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
//                if($tckt==1)
               $xstyle.='display:none;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('style','display:none;');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

          $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);

          if($docu1['efectivo']!=0)
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','EFECTIVO : '.number_format($docu1['efectivo'],2)));
               $xstyle='';
               $xstyle.='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          }
     
          if($docu1['cheque']!=0)
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','VALOR CHEQUE : '.number_format($docu1['cheque'],2)));
               $xstyle='';
               $xstyle.='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          }
     
          if($docu1['tarjeta']!=0)
          {
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','# VOUCHER : '.$docu1['numvou']));
               $xstyle='';
               $xstyle.='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $tcol=$trow->appendChild($domg->createElement('td','VALOR VOUCHER : '.number_format($docu1['tarjeta'],2)));
               $xstyle='';
               $xstyle.='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
          }
     
          if($empr0['empr_codigo']=='ptsa' and substr($docu1['docu'],0,2)=='PF')
          {
               $ttbl->setAttribute('style','display:;');
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('style','border-top:1px solid;');
               $tcol=$trow->appendChild($domg->createElement('td',''));
//                     $div=$tcol->appendChild($domg->createElement('div','GARANTIA : 1 AÑO'));
//                          $div->setAttribute('style','font-weight:bold;');
               
                    $div=$tcol->appendChild($domg->createElement('div',''));
                         $div->appendChild($domg->createElement('strong','VALIDEZ DE OFERTA : '));
                         $div->appendChild($domg->createElement('span','7 DIAS'));
               
                    $div=$tcol->appendChild($domg->createElement('div',''));
                         $div->appendChild($domg->createElement('strong','FORMA DE PAGO : '));
                         $div->appendChild($domg->createElement('span','CONTADO CONTRA ENTREGA'));
               
                    $div=$tcol->appendChild($domg->createElement('div',''));
                         $div->appendChild($domg->createElement('strong','TIEMPO DE ENTREGA : '));
                         $div->appendChild($domg->createElement('span','15 DIAS'));
               
                    $div=$tcol->appendChild($domg->createElement('div',''));
                         $div->appendChild($domg->createElement('strong','GARANTIA : '));
                         $div->appendChild($domg->createElement('span','1 AÑO'));
               
          }
     
          if($empr0['empr_codigo']=='ptsa' and substr($docu1['docu'],0,2)=='FC')
          {
               $ttbl->setAttribute('style','display:;');
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('style','border-top:1px solid;');
               $tcol=$trow->appendChild($domg->createElement('td',''));
                    $div=$tcol->appendChild($domg->createElement('div','PARA DEPOSITO O TRANSFERENCIA :'));
                         $div->setAttribute('style','font-weight:bold;');
               
                    $div=$tcol->appendChild($domg->createElement('div',''));
                         $div->appendChild($domg->createElement('strong','BCO. PRODUBANCO : '));
                         $div->appendChild($domg->createElement('span','CTA. AHO. # 1200 665 4245'));
          }
     
          if($empr0['empr_codigo']=='vare' and substr($docu1['docu'],0,2)=='FC')
          {
               $ttbl->setAttribute('style','display:;');
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('style','border-top:1px solid;');
               $tcol=$trow->appendChild($domg->createElement('td',''));
                    $div=$tcol->appendChild($domg->createElement('div','PARA DEPOSITO O TRANSFERENCIA :'));
                         $div->setAttribute('style','font-weight:bold; ');
               
//                     $div=$tcol->appendChild($domg->createElement('div',' '));
//                          $div->appendChild($domg->createElement('strong','BCO. GUAYAQUIL : '));
//                          $div->appendChild($domg->createElement('span','CTA. AHO. # 00 4756 9791'));
               
                    $div=$tcol->appendChild($domg->createElement('div',' '));
                         $div->appendChild($domg->createElement('strong','BCO. PRODUBANCO : '));
                         $div->appendChild($domg->createElement('span','CTA. AHO. # 1800 519 3308'));
               
//                     $div=$tcol->appendChild($domg->createElement('div',' '));
//                          $div->appendChild($domg->createElement('strong','BCO. PACIFICO : '));
//                          $div->appendChild($domg->createElement('span','CTA. CTE. # 556 7424'));
          }
     
          if($empr0['empr_codigo']=='jare' and substr($docu1['docu'],0,2)=='FC')
          {
               $ttbl->setAttribute('style','display:;');
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('style','border-top:1px solid;');
               $tcol=$trow->appendChild($domg->createElement('td',''));
                    $div=$tcol->appendChild($domg->createElement('div','PARA DEPOSITO O TRANSFERENCIA :'));
                         $div->setAttribute('style','font-weight:bold; ');
               
                    $div=$tcol->appendChild($domg->createElement('div',' '));
                         $div->appendChild($domg->createElement('strong','BCO. PRODUBANCO : '));
                         $div->appendChild($domg->createElement('span','CTA. AHO. # 1201 108 8201')); 
               
               
                    $div=$tcol->appendChild($domg->createElement('div',' '));
                         $div->appendChild($domg->createElement('strong','BCO. PACIFICO : '));
                         $div->appendChild($domg->createElement('span','CTA. CTE. # 105 209 1813'));
          }
     
     
// foreach ($array as $clave => $valor) {
//     echo "Clave: $clave, Valor: $valor\n";

          if($modu=='vtas' or $modu=='inve')
          {
               $serie_lote=get_serie_lote($docu,$idnum);
               if(count($serie_lote)>0)
               {
                    $ttbl->setAttribute('style','display:;');
                    $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('style','border-top:1px solid;');
                    $tcol=$trow->appendChild($domg->createElement('td',''));
                         $div=$tcol->appendChild($domg->createElement('div','LOTES :'));
                              $div->setAttribute('style','font-weight:bold; ');
                    foreach($serie_lote as $key=>$value)
                    {

                              $div=$tcol->appendChild($domg->createElement('div',' '));
                                   $div->appendChild($domg->createElement('strong',$key.'  '));
                                   $div->appendChild($domg->createElement('span',$value)); 
                    }

               }
          }
     
 
          if($cont!=1)
          if(mb_stristr2('.vtas.comp.retp.guia',$aso_info1['docu_tabla']))
          {
               $ttbl->setAttribute('style','display:;');
               if($tckt==1)
               {$ttbl->setAttribute('style','display:none;');}
               
               $trow=$ttbl->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('style','border-top:1px solid;');
               $tcol=$trow->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('noprinter','');
                    $sri=$tcol->appendChild($domg->createElement('span','Mas información en : '));
                    $sri=$tcol->appendChild($domg->createElement('a','PORTAL S.R.I.'));
                         $sri->setAttribute('target','_blank');
//                          $sri->setAttribute('href','https://www.sri.gob.ec/web/guest/facturacion-electronica');
                         $sri->setAttribute('href','https://www.sri.gob.ec/facturacion-electronica');
                         $tcol->appendChild($domg->createElement('span',' / '));
                    $sri=$tcol->appendChild($domg->createElement('a','VALIDADOR S.R.I.'));
                         $sri->setAttribute('target','_blank');
                         $onclick='';
                         $onclick.='{navigator.clipboard.writeText("'.$aso_info1['claveacc'].'")}';
                         $sri->setAttribute('onclick',$onclick);
                         $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:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

          if($xtotal!=0)
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','SON : '.num2let(round($xtotal,2))));
               $xstyle='';
               $xstyle.='text-align:right;font-weight:bold;';
               if($docu=='DA16')
               $xstyle.='display:none;';
               $tcol->setAttribute('style',$xstyle);
          }

     
     
     
}





          // DETALLE
// if($cont!=1)
// if(1==2)
{
     
          $xcost=1;
          if($docu=='PS10'){$xcost=0;}
          if($docu=='LP10'){$xcost=0;}
          if($modu=='lpro'){$xcost=0;}
     
     
          $name='detalle';     
          $ttbl=$deta->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('id',$name);
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
               $ttbl->setAttribute('name',$name);
               $ttbl->setAttribute('blockrows',$linxblock);
               if(empty($mailsend))
               {$ttbl->setAttribute('onmouseover','dottedTable('.$name.','.$linxblock.');');}
    

          $tcolg=$ttbl->appendChild($domg->createElement('colgroup',''));
          $thead=$ttbl->appendChild($domg->createElement('thead',''));
          $tbody=$ttbl->appendChild($domg->createElement('tbody',''));
          $tfoot=$ttbl->appendChild($domg->createElement('tfoot',''));

//                $thead->setAttribute('onmouseover','dottedTable('.$name.');');
     
     
          $trowh=$thead->appendChild($domg->createElement('tr',''));
               if($modu=='rmed')
               {$trowh->setAttribute('style','display:none;');}
          $tcoldeta=$trowh->appendChild($domg->createElement('td',''));
               $tcoldeta->setAttribute('colspan','2');
               $xstyle='';    
               $xstyle.='background:'.$xbgcolor2.';';
               $tcoldeta->setAttribute('style',$xstyle);
     
               $span=$tcoldeta->appendChild($domg->createElement('span','DETALLE'));
                    $xstyle='';    
                    $xstyle.='letter-spacing:5pt; font-weight:bold;';
                    $span->setAttribute('style',$xstyle);
               if(msql_num_rows($res_info2)>30)
               {
               $span=$tcoldeta->appendChild($domg->createElement('span',$aso_info1['docu_descri'].' : '.$aso_info1['ptoe'].' - '.$aso_info1['numero']));
                    $xstyle='';    
                    $xstyle.='float:right; font-weight:bold;';
                    $span->setAttribute('style',$xstyle);
               }
     
     
     
          $xsort=0;
          $clin=1;

     
     
     
          if(mb_stristr2('.cont.',$modu))
          {
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $style.='top:0px;';
               $trowh=$thead->appendChild($domg->createElement('tr',''));
                    $trowh->setAttribute('valign','middle');
                    $trowh->setAttribute('style',$style);
                    $trowh->setAttribute('sticky',' ');
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $style.='bottom:0px;';
               $trowf=$tfoot->appendChild($domg->createElement('tr',''));
                    $trowf->setAttribute('valign','top');
                    $trowf->setAttribute('style',$style);
                    $trowf->setAttribute('sticky',' ');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','align:center;');
                    $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','CODIGO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',' '));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','CONTABLE'));
                    $tcol->setAttribute('style','letter-spacing:3pt;');
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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','DEBITO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['debito'],2)));
                    $tcol->setAttribute('align','right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','CREDITO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['credito'],2)));
                    $tcol->setAttribute('align','right');
               
               if($aso_info1['detalle_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
//                     $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }               

               if($aso_info1['csub_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','C-SUBC'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }               

               if($aso_info1['item_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','ITEM'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','PRODUCTO / SERVICIO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
               $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'));
//                     $onclick='sortTable(this,'.$xsort++.',"");';
//                     $tcol->setAttribute('onclick',$onclick);
//                $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_t'];}
//                     if($post==1){$item_codigo='';}
                    
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($numlin % $linxblock==0)
                         {$trow->setAttribute('style','border-bottom:dotted 1px;');}
//                          {$trow->setAttribute('bb-do1','');}

                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ctas']));
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ctas_descri']));
// t                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['debito'],2)));
                         $tcol->setAttribute('align','right');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['credito'],2)));
                         $tcol->setAttribute('align','right');

                    if($aso_info1['detalle_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['detalle']));
//                     $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['csub_descri']));
                    }
                    

                    if($aso_info1['csub_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['csub']));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['csub_descri']));
                    }
                    
                    if($aso_info1['item_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item']));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item_descri']));
                    }
                    
                    
//                     if($aso_info1['lote_m']!='')
//                     {
//                     $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['lote']));
//                     }
//                          $tcol->setAttribute('align','center');
               }

          }
     
          if(mb_stristr2('.vtas.clie.carr.comp.prov.lpro',$modu))
          {
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $style.='top:0px;';
               $trowh=$thead->appendChild($domg->createElement('tr',''));
                    $trowh->setAttribute('valign','middle');
                    $trowh->setAttribute('style',$style);
                    $trowh->setAttribute('sticky',' ');
               
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $style.='bottom:0px;';
               $trowf=$tfoot->appendChild($domg->createElement('tr',''));
                    $trowf->setAttribute('valign','top');
                    $trowf->setAttribute('style',$style);
                    $trowf->setAttribute('sticky',' ');
               
               if($post!=1)
               {$colg=$tcolg->appendChild($domg->createElement('col',''));}
               if($post!=1)
               {$colg->setAttribute('style','background-color:#f0f0f0;');}
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
                    $onclick='sortTable(this,'.$xsort++.',"N");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               
               
               
               
               
               if($post!=1)
               {$colg=$tcolg->appendChild($domg->createElement('col',''));}
               $lblitem='ITEM';
               if($post==1){$lblitem='';}
//                if($modu=='clie'){$lblitem='';}
               $tcol=$trowh->appendChild($domg->createElement('th',$lblitem));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               if($post!=1)
               {$colg=$tcolg->appendChild($domg->createElement('col',''));}
               $tcol=$trowh->appendChild($domg->createElement('th','DESCRIPCION'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                     
                    $tcol->setAttribute('onclick',$onclick);
                    $tcol->setAttribute('style','letter-spacing:3pt;');
                    if($post==1)
                    {$tcol->setAttribute('colspan','10');}
               $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
                    $tcol->setAttribute('style','letter-spacing:3pt;');    
                    $tcol->setAttribute('align','center');
                    if($post==1)
                    {$tcol->setAttribute('colspan','10');}

               
               if($post==1)
               {
                    $trowh=$thead->appendChild($domg->createElement('tr',''));
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $tcol=$trowh->appendChild($domg->createElement('th',''));
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $tcol=$trowh->appendChild($domg->createElement('th',''));
                    
                    $trowf=$tfoot->appendChild($domg->createElement('tr',''));
                    $tcol=$trowf->appendChild($domg->createElement('th',''));
                    $tcol=$trowf->appendChild($domg->createElement('th',''));
                    $trowh->setAttribute('valign','top');
                    $trowh->setAttribute('style',$style);
                    $trowf->setAttribute('valign','top');
                    $trowf->setAttribute('style',$style);
                    
               }
               
               if(substr($docu,2,2)=='15')
               if($empr0['empr_automotriz']==1 and $empr0['empr_impo']==1)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','MODELO_VH'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                          
                         $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }
               
               
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','CANT'));
                    $onclick='sortTable(this,'.$xsort++.',"N");';
                     
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format(abs($aso_info1['tcant']),$aso_info1['item_duni'])));
                    $tcol->setAttribute('align','right');
               

               
               
               if($aso_info1['umdd_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','UMDD'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                          
                         $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }
               
               
//                echo $docu.$xcost;
               
               if($xcost==1)
               {
               
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $tcol=$trowh->appendChild($domg->createElement('th','UNIT.'));
                         $onclick='sortTable(this,'.$xsort++.',"N");';

                         $tcol->setAttribute('onclick',$onclick);
                    $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.'));
                         $onclick='sortTable(this,'.$xsort++.',"N");';

                         $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',number_format(abs($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.'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';

                              $tcol->setAttribute('onclick',$onclick);
//                          $tcol=$trowf->appendChild($domg->createElement('td',abs(number_format($aso_info1['tdcto']),2)));
                         $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['tprop']>0)
                    {
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $tcol=$trowh->appendChild($domg->createElement('th','PROP.'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';

                              $tcol->setAttribute('onclick',$onclick);
                         $tcol=$trowf->appendChild($domg->createElement('td',(number_format($aso_info1['tprop'],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'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';

                              $tcol->setAttribute('onclick',$onclick);
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format(abs($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'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';

                              $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',abs(number_format($aso_info1['tice']),2)));
                         $tcol->setAttribute('align','right');
                    }

                    if($docu!='DA16')
                    {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','background-color:#f0f0f0;');
                    }
//                     if($docu=='DA16'){$colg->setAttribute('style','displayx:nonex;');}
                    $tcol=$trowh->appendChild($domg->createElement('th','TOTAL'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
                    if($docu=='DA16'){$tcol->setAttribute('style','display:none;');}
                    
                    $tcol=$trowf->appendChild($domg->createElement('td',number_format(abs($aso_info1['total']),2)));
                         $tcol->setAttribute('align','right');
                    if($docu=='DA16'){$tcol->setAttribute('style','display:none;');}

                    
                    
               }

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

               if($aso_info1['csub_m']!='')
               {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','CENT. /SUB-CENT'));
                         $onclick='sortTable(this,'.$xsort++.',"N");';

                         $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
               }

               
//                echo '===='.$aso_info1['detalle_l'];
               
               if($aso_info1['detalle_l']>0)
               {
//                     $colg=$tcolg->appendChild($domg->createElement('col','style=max-width:405px;'));
                    $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                         $tcol->setAttribute('onclick',$onclick);
//                          $tcol->setAttribute('style','max-width:40%;');
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
//                          $tcol->setAttribute('style','max-width:40%;');
               }

               if($aso_info1['cair_m']!='')
               {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $tcol=$trowh->appendChild($domg->createElement('th','CAIR'));
                              $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
               }

               if($aso_info1['ctas_m']!='')
               {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $tcol=$trowh->appendChild($domg->createElement('th','CTA'));
                              $onclick='sortTable(this,'.$xsort++.',"");';
                              $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',''));

                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $tcol=$trowh->appendChild($domg->createElement('th','CONTABLE'));
                              $onclick='sortTable(this,'.$xsort++.',"");';
                              $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
                    
               }

               if($aso_info1['plvh_m']!='')
               {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold; align:center;');
                    $tcol=$trowh->appendChild($domg->createElement('th','VHCL'));
                              $onclick='sortTable(this,'.$xsort++.',"");';

                              $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
                    
                    
                    if($empr0['empr_automotriz'])
                    {
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Vehiculo'));
                                   $onclick='sortTable(this,'.$xsort++.',"");';

                                   $tcol->setAttribute('onclick',$onclick);
                         $tcol=$trowf->appendChild($domg->createElement('td',''));
                         
                    }
                    
                    
                    
               }

               if($aso_info1['cntn_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','CONTENEDOR'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                          
                         $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','DESDE'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                          
                         $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));

               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','HASTA'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                          
                         $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    
               }

//                if(mb_stristr2('.vtas.clie',$modu))
                    
               if($empr0['empr_codigo']=='imcp')
               if(mb_stristr2('.vtas.clie.',$modu))
               {
                    // descripcion 2
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th',''));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                          
                         $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    
               }
                    
                    
               if(mb_stristr2('.comp.prov.lpro.',$modu))
               {
                    
                    
//                     echo '==='.$aso_info1['tcant_conv'];
                    
//                     if($aso_info1['detalle_t']!='')
//                     {
//                          $colg=$tcolg->appendChild($domg->createElement('col',''));
                         
// //                          $colg->setAttribute('style','font-weigth:bold;');
//                          $tcol=$trowh->appendChild($domg->createElement('th','Detalle'));
//                               $onclick='sortTable(this,'.$xsort++.',"");';

// //                               $tcol->setAttribute('onclick',$onclick);
// //                               $colg->setAttribute('style','background-color:#f0f0f0;');
//                          $tcol=$trowf->appendChild($domg->createElement('td',''));
// //                               $tcol->setAttribute('align','right');
//                     }
                    
                    
                    if($aso_info1['cant_conv']!=0)
                    if($aso_info1['tcant']!=$aso_info1['cant_conv'])
                    {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','U.Conv'));
                         $onclick='sortTable(this,'.$xsort++.',"N");';
                          
                         $tcol->setAttribute('onclick',$onclick);
                         $colg->setAttribute('style','background-color:#f0f0f0;');
                    $tcol=$trowf->appendChild($domg->createElement('td',number_format(abs($aso_info1['cant_conv']),2)));
                         $tcol->setAttribute('align','right');

                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','UM'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                          
                         $tcol->setAttribute('onclick',$onclick);
                         $tcol->setAttribute('title','Unidad de Medida');
                         $tcol=$trowf->appendChild($domg->createElement('td',''));
                         $tcol->setAttribute('align','right');
                    }                         
                    
                    if($docu=='DA16')
                    {
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
//                          $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Kg.'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tpeso'],2)));
                              $tcol->setAttribute('align','right');
                         
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
//                          $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Cost.Ext.'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['costoe1'],2)));
                              $tcol->setAttribute('align','right');

                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','background-color:#f0f0f0;');
                         $tcol=$trowh->appendChild($domg->createElement('th','FOB'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tsubt']+$aso_info1['costoe1'],2)));
                              $tcol->setAttribute('align','right');

                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Seguro'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['seguro1'],2)));
                              $tcol->setAttribute('align','right');

                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Flete'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['flete1'],2)));
                              $tcol->setAttribute('align','right');

                         
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','background-color:#f0f0f0;');
                         $tcol=$trowh->appendChild($domg->createElement('th','CIF'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($totcif,2)));
                              $tcol->setAttribute('align','right');

                         
                         
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Arancel'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',''));
                              $tcol->setAttribute('align','right');

                         
                         
                         
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Ad.Valor.'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tadva'],2)));
                              $tcol->setAttribute('align','right');
                         
                         
                         
                         

                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Fodinfa'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tfodi'],2)));
                              $tcol->setAttribute('align','right');

                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','font-weigth:bold;');
                         $tcol=$trowh->appendChild($domg->createElement('th','Cost.Local'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['costol1'],2)));
                              $tcol->setAttribute('align','right');

                         
                         $colg=$tcolg->appendChild($domg->createElement('col',''));
                         $colg->setAttribute('style','background-color:#f0f0f0;');
                         $tcol=$trowh->appendChild($domg->createElement('th','TOTAL'));
                              $onclick='sortTable(this,'.$xsort++.',"N");';
                              $tcol->setAttribute('onclick',$onclick);
//                               $tcol->setAttribute('title','COSTO Unitario');
//                          $tcol=$trowf->appendChild($domg->createElement('td',''));
                         
//                          $totimpo=$totcif;
//                          $totimpo+=$aso_info1['tadva'];
//                          $totimpo+=$aso_info1['tfodi'];
//                          $totimpo+=$aso_info1['costol1'];
                         
                         $tcol=$trowf->appendChild($domg->createElement('td',number_format($totimpo,2)));
                              $tcol->setAttribute('align','right');

                         
                         
                         
                    }
                    
                    
                    if($xcost==1)
                    {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','C.Unit.'));
                         $onclick='sortTable(this,'.$xsort++.',"N");';
                          
                         $tcol->setAttribute('onclick',$onclick);
                         $tcol->setAttribute('title','COSTO Unitario');
                    
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
                         $tcol->setAttribute('align','right');
                    }

                    if($aso_info1['cant_conv']!=0)
                    if($aso_info1['tcant']!=$aso_info1['cant_conv'])
                    {
                    $lbl_up='';
                    $lbl_fc='';
                    {
                         $lbl_up='UP';
                         $lbl_fc='FC';
                    }
                         
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th',$lbl_up));
                         $onclick='sortTable(this,'.$xsort++.',"N");';
                          
                         $tcol->setAttribute('onclick',$onclick);
                         $tcol->setAttribute('title','Unidades X Presentación');
                    $tcol=$trowf->appendChild($domg->createElement('td',''));

                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th',$lbl_fc));
                         $onclick='sortTable(this,'.$xsort++.',"N");';
                          
                         $tcol->setAttribute('onclick',$onclick);
                         $tcol->setAttribute('title','Factor de Conversión');
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
                         
                    }
                    
//                     if(substr($docu,0,2)=='PT')
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
//                     $tcol_hin=$trowh->appendChild($domg->createElement('th','% IN'));
                    $tcol_hin=$trowh->appendChild($domg->createElement('th',''));
                         $onclick='sortTable(this,'.$xsort++.',"N");';
                         $tcol_hin->setAttribute('onclick',$onclick);
//                          $tcol_hin->setAttribute('title','% Inventario');
//                          $tcol_hin->setAttribute('hide','');
                    $tcol_fin=$trowf->appendChild($domg->createElement('td',''));
//                          $tcol_fin->setAttribute('hide','');
                    
               }
               
               
               if($puni2==1)
               if($aso_info1['tsubt2']>0)
               {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','Unit.R'));
                         $onclick='sortTable(this,'.$xsort++.',"N");';
                         $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',''));
                    
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','SubT.R'));
                         $onclick='sortTable(this,'.$xsort++.',"N");';
                         $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tsubt2'],2)));
                              $tcol->setAttribute('align','right');
                    
               }
               
               
               
               
               msql_data_seek($res_info2);
               while($aso_info2=msql_fetch_assoc($res_info2))
               {
                    $item_codigo=$aso_info2['item'];
                    $item_codigov=$aso_info2['item_codigov'];
                    
                    if(@mb_stristr2($item_codigo,$item_codigov))
                    {$item_codigo=$item_codigov;}
                    
                    $item_descri=$aso_info2['item_descri'];
                    if($post==1)
                    {
                         $item_codigo='';
                         $item_descri=$aso_info2['item_codigo'].' - '.$aso_info2['item_descri'];
                    }
                    
//                     echo '<br>==== '.$item_descri;
                    
                    
                    if($empr0['empr_codigo']=='imcp')
                    {$item_descri=$aso_info2['item_descri2'];}
                    
                    if($empr0['empr_codigo']=='orel')
                    {$item_codigo=$aso_info2['item_codigov'];}
                    
                    if(substr($aso_info2['item'],0,4)=='9999' or substr($aso_info2['item'],0,4)=='8888' )
                    {$item_descri=$aso_info2['detalle_t'];}
                    
                    if(empty($item_descri))
                    {$item_descri=$aso_info2['item_descri'];}
                    
                    if(empty($item_descri))
                    {$item_descri=$aso_info1['concepto_t'];}
                    
                    if(empty($item_codigo)){$item_codigo=$aso_info2['itemce'];}
                    if(empty($item_codigo)){$item_codigo=$aso_info2['itemce2'];}
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                    
                         if($post==1)
                         {$trow->setAttribute('style','border-top:1px dotted; background-color:#fff;');}
                    
                         if($numlin % $linxblock==0)
                         {$trow->setAttribute('style','border-bottom:1px dotted;');}
//                $colg->setAttribute('style','background-color:#f0f0f0;');
                    
                    
//                     if($modu=='clie'){$item_codigo='';}
//                     {$tcol->setAttribute('style','display:none;');}
                    $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',htmlspecialchars($item_descri)));
// 
                    if($post==1)
                    {
                         $tcol->setAttribute('colspan','10');
                    }
                    
                    if($post==1)
                    {
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                    $trow->setAttribute('name',$aso_info2['iddet']);
                    $trow->setAttribute('valign','top');
                    $tcol=$trow->appendChild($domg->createElement('td',''));
                    $tcol=$trow->appendChild($domg->createElement('td',''));
                    }


                    if(substr($docu,2,2)=='15')
                    if($empr0['empr_automotriz']==1 and $empr0['empr_impo']==1)
                    {
                         $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['mdvh_descri']));
                              $tcol->setAttribute('align','center');
                         
                    }
                    
                    
                    $cantidad=number_format($aso_info2['cant'],$aso_info2['item_duni']);
                    
                    if(!empty($user0['user_tipo']))
                    if(mb_stristr2('.sist.supe.admi.oper',$user0['user_tipo']))
                    {
                         $sal_item=sal_item($aso_info2['item'],'','','',$aso_info1['fecha']);
                         if($sal_item['uni_fin']<=0)
                         {
//                               $trow->setAttribute('style',"color:darkred; text-decoration: underline;");
//                               $cantidad='* '.$cantidad;
                         }
                    }
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$cantidad));
                         $tcol->setAttribute('align','right');

                    
                    if($aso_info1['umdd_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['umdd']));
                         $tcol->setAttribute('align','center');
                         
                    }
                    
                    
                    
                    if($xcost==1)
                    {
                         if($aso_info2['puni']>1)
                         {$tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['puni'],2)));}
                         else
                         {$tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['puni'],$aso_info2['item_dcos'])));}
                         
                              $tcol->setAttribute('align','right');
     //                          $tcol->setAttribute('hide','');
                              if($aso_info2['item_dpre']>2)
                              {$tcol->setAttribute('style','font-size:0.9em;');}
                         $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['tsubt']),2)));
                              $tcol->setAttribute('align','right');
                         
                         if($aso_info1['tdcto']!=0)
                         {
                         $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['tdcto']),2)));
                              $tcol->setAttribute('align','right');
                              $tcol->setAttribute('style','text-decoration:underline;');
                              $tcol->setAttribute('title',number_format(abs($aso_info2['dcto']),2).'%');
                         }
                         
                         if($aso_info1['tprop']!=0)
                         {
                         $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['tprop']),2)));
                              $tcol->setAttribute('align','right');
                              $tcol->setAttribute('style','text-decoration:underline;');
                              $tcol->setAttribute('title',number_format(abs($aso_info2['tprop']),2).'%');
                         }
                         
                         
                         if($aso_info1['tiva']!=0)
                         {
                         $tcol=$trow->appendChild($domg->createElement('td',''.number_format(abs($aso_info2['tiva']),2)));
//                               $tcol->setAttribute('title',$aso_info2['iva'].'%');
                              $tcol->setAttribute('title',number_format($aso_info2['iva'],1).'%');
                              $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(abs($aso_info2['tice']),2)));
                              $tcol->setAttribute('align','right');
                         }

                         // total
                         $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['total']),2)));
                              $tcol->setAttribute('style','font-weight:bold;');
                              $tcol->setAttribute('align','right');
                         if($docu=='DA16'){$tcol->setAttribute('style','display:none;');}
                         
                    }

                         
                         
                    if($aso_info1['lote_m']!='')
                    {$tcol=$trow->appendChild($domg->createElement('td',$aso_info2['lote']));}
                    
                    if($aso_info1['csub_m']!='')
                    {$tcol=$trow->appendChild($domg->createElement('td',$aso_info2['csub']));}
                    
                    $xdetalle=alltrim($aso_info2['detalle_t']);
                    if($aso_info2['itemce']!='')
                    {$xdetalle.=' /'.alltrim($aso_info2['itemce']);}
                    if($aso_info2['itemce2']!='' and $aso_info2['itemce']!=$aso_info2['itemce2'])
                    {$xdetalle.=' /'.alltrim($aso_info2['itemce2']);}

//                     $xdetalle.='**';
                         
//                     echo '<br>*/*/*'.$item_descri;
//                     echo '<br>*/*/*'.$xdetalle;
                    if($item_descri==$xdetalle){$xdetalle='';}
//                     $xdetalle=str_replace($item_descri,'',$xdetalle);
                    
//                     if($aso_info1['detalle_d']!='')
//                     {$tcol=$trow->appendChild($domg->createElement('td',$xdetalle));}
                    
//                     if($aso_info2['detalle_t']!='' or $aso_info2['cant']!=$aso_info2['cant_conv'])
                    if($aso_info1['detalle_l']>0)
                    {
                         $tcol=$trow->appendChild($domg->createElement('td',$xdetalle));
//                          $tcol->setAttribute('style','max-width:40%;');
//                          $tcol->setAttribute('style','max-width:500px;');
                         
                    }
                         
                         
                    
                    if($aso_info1['cair_m']!='')
                    {
                         $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['cair'])));
                              $tcol->setAttribute('align-c','');
                         
                    }
                         
                         
                    
                    if($aso_info1['ctas_m']!='')
                    {
                         $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['ctas'])));
                         $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['ctas_descri'])));
                    }
                    
                    if($aso_info1['plvh_m']!='')
                    {
                         $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['plvh'])));
                              $tcol->setAttribute('align','center');
                              
                         
                         if($empr0['empr_automotriz']==1)
                         {
//                               $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['plvh_mrca'].' /'.$aso_info1['plvh_modelo'].' /'.$aso_info1['plvh_anio'].' /'.$aso_info1['plvh_clor1']));
                              $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['plvh_descri']));
                         }
                         
                    }
                    
                    if($aso_info1['cntn_m']!='')
                    {
                         $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['cntn'])));
                         $tcol->setAttribute('align','center');
                         $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['cntnf1'])));
                         $tcol->setAttribute('align','center');
                         $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['cntnf2'])));
                         $tcol->setAttribute('align','center');
                    }

                    
                    if($empr0['empr_codigo']=='imcp')
                    if(mb_stristr2('.vtas.clie.',$modu))
                    {
                         //español
//                          $tcol=$trow->appendChild($domg->createElement('td',alltrim($aso_info2['item_descri2'])));
                    }
                    
                    
                    
                    if(mb_stristr2('.comp.prov.lpro.',$modu))
                    {

                         if($aso_info1['cant_conv']!=0)
                         if($aso_info1['tcant']!=$aso_info1['cant_conv'])
                         {
                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['cant_conv']),$aso_info2['item_duni'])));
                                   $tcol->setAttribute('align','right');
                              $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item_umdd']));
                                   $tcol->setAttribute('align','center');
                                   $tcol->setAttribute('style','font-size:0.8em;');
                         }



                         if($docu=='DA16')
                         {
     //                               $tcol->setAttribute('style','font-weight:bold;');

                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['peso']),2)));
                                   $tcol->setAttribute('align','right');


                              if($aso_info1['costoe1d']==1){$costoe2=abs($aso_info1['costoe1']/$aso_info1['tcant']*$aso_info2['cant']);}
                              if($aso_info1['costoe1d']==2){$costoe2=abs($aso_info1['costoe1']/$aso_info1['tsubt']*$aso_info2['subt']);}
                              if($aso_info1['costoe1d']==3){$costoe2=abs($aso_info1['costoe1']/$aso_info1['tpeso']*$aso_info2['peso']);}
                              if($aso_info1['costoe1d']==4){$costoe2=abs($aso_info1['costoe1']/$aso_info1['tvolu']*$aso_info2['volu']);}
                              $tcol=$trow->appendChild($domg->createElement('td',number_format($costoe2,2)));
                                   $tcol->setAttribute('align','right');

                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['subt']+$costoe2),2)));
                                   $tcol->setAttribute('align','right');
                                   $tcol->setAttribute('style','font-weight:bold;');

                              if($aso_info1['seguro1d']==1){$seguro2=abs($aso_info1['seguro1']/$aso_info1['tcant']*$aso_info2['cant']);}
                              if($aso_info1['seguro1d']==2){$seguro2=abs($aso_info1['seguro1']/$aso_info1['tsubt']*$aso_info2['subt']);}
                              if($aso_info1['seguro1d']==3){$seguro2=abs($aso_info1['seguro1']/$aso_info1['tpeso']*$aso_info2['peso']);}
                              if($aso_info1['seguro1d']==4){$seguro2=abs($aso_info1['seguro1']/$aso_info1['tvolu']*$aso_info2['volu']);}
                              $tcol=$trow->appendChild($domg->createElement('td',number_format($seguro2,2)));
                                   $tcol->setAttribute('align','right');

                              if($aso_info1['flete1d']==1){$flete2=abs($aso_info1['flete1']/$aso_info1['tcant']*$aso_info2['cant']);}
                              if($aso_info1['flete1d']==2){$flete2=abs($aso_info1['flete1']/$aso_info1['tsubt']*$aso_info2['subt']);}
                              if($aso_info1['flete1d']==3){$flete2=abs($aso_info1['flete1']/$aso_info1['tpeso']*$aso_info2['peso']);}
                              if($aso_info1['flete1d']==4){$flete2=abs($aso_info1['flete1']/$aso_info1['tvolu']*$aso_info2['volu']);}
                              $tcol=$trow->appendChild($domg->createElement('td',number_format($flete2,2)));
                                   $tcol->setAttribute('align','right');

                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['subt']+$costoe2+$seguro2+$flete2),2)));
                                   $tcol->setAttribute('align','right');
                                   $tcol->setAttribute('style','font-weight:bold;');

                              $tcol=$trow->appendChild($domg->createElement('td',(($aso_info2['arcl']))));
     //                               $tcol->setAttribute('align','right');



                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['adva']),2)));
                                   $tcol->setAttribute('align','right');
                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['fodi']),2)));
                                   $tcol->setAttribute('align','right');


                              if($aso_info1['costol1d']==1){$costol2=abs($aso_info1['costol1']/$aso_info1['tcant']*$aso_info2['cant']);}
                              if($aso_info1['costol1d']==2){$costol2=abs($aso_info1['costol1']/$aso_info1['tsubt']*$aso_info2['subt']);}
                              if($aso_info1['costol1d']==3){$costol2=abs($aso_info1['costol1']/$aso_info1['tpeso']*$aso_info2['peso']);}
                              if($aso_info1['costol1d']==4){$costol2=abs($aso_info1['costol1']/$aso_info1['tvolu']*$aso_info2['volu']);}
                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($costol2),2)));
                                   $tcol->setAttribute('align','right');

                              $tcol=$trow->appendChild($domg->createElement('td',number_format(abs($aso_info2['total']+$costoe2+$seguro2+$flete2+$aso_info2['adva']+$aso_info2['fodi']+$costol2),2)));
                                   $tcol->setAttribute('align','right');
                                   $tcol->setAttribute('style','font-weight:bold;');


                         }                         


                         if($xcost==1)
                         {
                              $costo_unit=$aso_info2['cuni1_conv'];
                              
                              if($docu=='DA16')
                              {$costo_unit=abs($aso_info2['total'] +$costoe2 +$seguro2 +$flete2 +$aso_info2['adva'] +$aso_info2['fodi']+$costol2) /$aso_info2['cant'];}
                              
                              if($docu=='DA16' and $empr0['empr_codigo']=='mhec')
                              {$costo_unit=abs($aso_info2['total'] +$costoe2 +$seguro2 +$flete2 +$aso_info2['adva'] +$aso_info2['fodi'] +$costol2 +$aso_info2['l_comp']) /$aso_info2['cant'];}
                              
                              if($docu=='DA16' and $docu1['fecha']>=date('Y-m-01',strtotime('-2 month')))
                              {
                                   $sql_updt='update prov2 set cuni="'.$costo_unit.'" where idnum2="'.$idnum.'" and iddet="'.$aso_info2['iddet'].'" ';
                                   $res_updt=msql_query($sql_updt,$link_data);
                              }

                              if($costo_unit>1)
                              {$tcol=$trow->appendChild($domg->createElement('td',number_format(abs($costo_unit),2)));}
                              else     
                              {$tcol=$trow->appendChild($domg->createElement('td',number_format(abs($costo_unit),$aso_info2['item_dcos'])));}

                              $tcol->setAttribute('align','right');
                              $tcol->setAttribute('style','font-weight:bold; font-style:italic; ');
                         }

                         if($aso_info1['cant_conv']!=0)
                         if($aso_info2['cant']!=$aso_info2['cant_conv'])
                         {
                              $uxpre=$aso_info2['uxpre'];
                              $facon=$aso_info2['facon'];
                              if(empty($uxpre)){$uxpre=1;}
                              if(empty($facon)){$facon=1;}

                              if($uxpre*$facon==1 or $uxpre*$facon==0)
                              {$uxpre='';$facon='';}
                              else
                              {
                                   $uxpre=number_format(abs($uxpre),2);
                                   $facon=number_format(abs($facon),2);
                              }

                              $tcol=$trow->appendChild($domg->createElement('td',$uxpre));
                                   $tcol->setAttribute('align','right');
                                   $xstyle='font-size:0.8em;';
                                   $tcol->setAttribute('style',$xstyle);

                              $tcol=$trow->appendChild($domg->createElement('td',$facon));
                                   $tcol->setAttribute('align','right');
                                   $xstyle='font-size:0.8em;';
                                   $tcol->setAttribute('style',$xstyle);
                         }

                         
                         
                              $porc_inve=$aso_info2['inve_cant']/$aso_info2['cant_conv']*100;
                              if($porc_inve==0)
                              {$tcol=$trow->appendChild($domg->createElement('td',''));}
                         
                              if($porc_inve!=0)
                              {
//                                    $tcol_hin->removeAttribute('hide');
//                                    $tcol_fin->removeAttribute('hide');
//                                    $tcol_hin->appendChild($domg->createElement('span','% IN'));
                                   $tcol_hin->nodeValue="% IN";
                                   $tcol_hin->setAttribute('title','% Inventario');
                                   
                              $tcol=$trow->appendChild($domg->createElement('td',number_format($porc_inve,1).''));
                                   $tcol->setAttribute('align','center');
                                   $xstyle='font-size:0.8em;';
                                   if($porc_inve>110){$xstyle.='background-color:black; color:white;';}
                                   elseif($porc_inve>100){$xstyle.='background-color:blue; color:white;';}
                                   elseif($porc_inve==100){$xstyle.='background-color:green; color:white;';}
                                   elseif($porc_inve>90){$xstyle.='background-color:gold; color:black;';}
                                   elseif($porc_inve>0){$xstyle.='background-color:darkred; color:white;';}
                                   $tcol->setAttribute('style',$xstyle);
                              }

          
                              if($puni2==1)
                              if($aso_info1['tsubt2']>0)
                              {
//                                    $tcol_hin->nodeValue="% IN";
//                                    $tcol_hin->setAttribute('title','% Inventario');
                                   
                              $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['puni2'],2).''));
                                   $tcol->setAttribute('align','right');
//                                    $xstyle='font-size:0.8em;';
//                                    if($porc_inve>110){$xstyle.='background-color:black; color:white;';}
//                                    elseif($porc_inve>100){$xstyle.='background-color:blue; color:white;';}
//                                    elseif($porc_inve==100){$xstyle.='background-color:green; color:white;';}
//                                    elseif($porc_inve>90){$xstyle.='background-color:gold; color:black;';}
//                                    elseif($porc_inve>0){$xstyle.='background-color:darkred; color:white;';}
//                                    $tcol->setAttribute('style',$xstyle);
                                   
                                   
                              $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['tsubt2'],2).''));
                                   $tcol->setAttribute('align','right');
                                   
                                   
                              }




                    }
                    
               }

          }
     
          if(mb_stristr2('.inve.infi.opro..',$modu))
          {
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $style.='top:0px;';
               $trowh=$thead->appendChild($domg->createElement('tr',''));
                    $trowh->setAttribute('valign','middle');
                    $trowh->setAttribute('style',$style);
                    $trowh->setAttribute('sticky',' ');
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
               $style.='bottom:0px;';
               $trowf=$tfoot->appendChild($domg->createElement('tr',''));
                    $trowf->setAttribute('valign','top');
                    $trowf->setAttribute('style',$style);
                    $trowf->setAttribute('sticky',' ');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','align:center;');
                    $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','LINEA'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','ITEM'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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;');
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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','')); //nega *
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','U.M.')); //umdd
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               if($aso_info1['tsaco']>0)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcolh=$trowh->appendChild($domg->createElement('th','SACO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcolf=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tsaco'],2)));
//                if($aso_info1['tsaco']==0)
//                {
//                     $tcolh->setAttribute('style','display:none;');
//                     $tcolf->setAttribute('style','display:none;');
//                $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcolf->setAttribute('align','right');
               }

               if($user_cost==1)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','C.UNIT'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('align','right');
                    
                    
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','SUB-TOT'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tsubt'],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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }

               if($aso_info1['cambio_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','CAMBIO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));

               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','DESC.CAMBIO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }
               
               
               if($aso_info1['detalle_t']!='')
               {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                         $tcol->setAttribute('onclick',$onclick);
                    $tcol=$trowf->appendChild($domg->createElement('td',''));

               }
               

           
               msql_data_seek($res_info2);
               while($aso_info2=msql_fetch_assoc($res_info2))
               {
                    $item_codigo=$aso_info2['item'];
                    $item_descri=$aso_info2['item_descri'];
                    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_t'];}
                    if($post==1){$item_codigo='';}
                    
                    $xnega='';
                    if(!empty($aso_info2['nega'])){$xnega='*';}

                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($aso_info2['item_status']=='I')
                         {
                              $item_descri.=' ==>(INACTIVO)';
                              $trow->setAttribute('bgc-ulyellow',' ');
                         }
                         $xstyle='';
                         if(!empty($xnega))
                         {
                              $xstyle.='font-weight:bold;';
                              $xstyle.='background-color:#ffffcc;';
                         }
                    
                         if($numlin % $linxblock==0)
                         {$xstyle.='border-bottom:dotted 1px;';}
                    
                         if(!empty($xstyle))
                         {$trow->setAttribute('style',$xstyle);}
//                          {$trow->setAttribute('bb-do1','');}
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item_lsub']));
                         $tcol->setAttribute('align','center');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$item_codigo));
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$item_descri));
                    
                    $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',$xnega));
                              
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item_umdd']));
                         $tcol->setAttribute('align','center');
                    
                    if($aso_info1['tsaco']>0)
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['saco'],$aso_info2['item_duni'])));
                         $tcol->setAttribute('align','right');
                    }
//                          {$tcol->setAttribute('style','display:none;');}
                    
                    if($user_cost==1)
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['puni'],$aso_info2['item_dcos'])));
                         $tcol->setAttribute('align','right');
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['tsubt'],2)));
                         $tcol->setAttribute('align','right');
                    }
                    
                    if($aso_info1['lote_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['lote']));
                    }
                    
                    if($aso_info1['cambio_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['cambio']));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ibod_descri']));
                    }
//                          $tcol->setAttribute('align','center');
                    if($aso_info1['detalle_t']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['detalle']));
                    }
               }

          }
     
          if(mb_stristr2('.pduc.',$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','middle');
                    $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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','LINEA'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','ITEM'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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;');
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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'));
//                     $onclick='sortTable(this,'.$xsort++.',"");';
//                     $tcol->setAttribute('onclick',$onclick);
//                $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',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','ENTRADA'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['entrada'],$aso_info1['item_duni'])));
                    $tcol->setAttribute('align','right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','SALIDA'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['salida'],$aso_info1['item_duni'])));
                    $tcol->setAttribute('align','right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','')); //nega *
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','U.M.')); //umdd
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               if($aso_info1['tsaco']>0)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcolh=$trowh->appendChild($domg->createElement('th','SACO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcolf=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tsaco'],2)));
//                if($aso_info1['tsaco']==0)
//                {
//                     $tcolh->setAttribute('style','display:none;');
//                     $tcolf->setAttribute('style','display:none;');
//                $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcolf->setAttribute('align','right');
               }

               if($user_cost==1)
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','C.UNIT'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('align','right');
                    
                    
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','SUB-TOT'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tsubt'],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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }

               if($aso_info1['cambio_m']!='')
               {
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','CAMBIO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));

               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $colg->setAttribute('style','font-weigth:bold;');
               $tcol=$trowh->appendChild($domg->createElement('th','DESC.CAMBIO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               }
               
               
               if($aso_info1['detalle_t']!='')
               {
                    $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','font-weigth:bold;');
                    $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
                         $onclick='sortTable(this,'.$xsort++.',"");';
                         $tcol->setAttribute('onclick',$onclick);
                    $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_t'];}
                    if($post==1){$item_codigo='';}
                    
                    
                    $xnega='';
                    if(!empty($aso_info2['nega'])){$xnega='*';}

                    
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($aso_info2['item_status']=='I')
                         {
                              $item_descri.=' ==>(INACTIVO)';
                              $trow->setAttribute('bgc-ulyellow',' ');
                         }
                    
                    
                         $xstyle='';
                         if(!empty($xnega))
                         {
//                               $xstyle.='color:darkred;';
//                               $xstyle.='text-decoration:red wavy underline;';
//                               $xstyle.='background-color:lightpink;';
                              $xstyle.='font-weight:bold;';
                              $xstyle.='background-color:#ffffcc;';
//                               $xstyle.='text-decoration:darkred underline;';
                         }
                    
                         if($numlin % $linxblock==0)
                         {$xstyle.='border-bottom:dotted 1px;';}
                    
                         if(!empty($xstyle))
                         {$trow->setAttribute('style',$xstyle);}
//                          {$trow->setAttribute('bb-do1','');}
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item_lsub']));
                         $tcol->setAttribute('align','center');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$item_codigo));
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$item_descri));
                    
//                     $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['entrada'],$aso_info2['item_duni'])));
                         $tcol->setAttribute('align','right');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['salida'],$aso_info2['item_duni'])));
                         $tcol->setAttribute('align','right');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$xnega));
                              
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['item_umdd']));
                         $tcol->setAttribute('align','center');
                    
                    if($aso_info1['tsaco']>0)
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['saco'],$aso_info2['item_duni'])));
                         $tcol->setAttribute('align','right');
                    }
//                          {$tcol->setAttribute('style','display:none;');}
                    
                    if($user_cost==1)
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['puni'],$aso_info2['item_dcos'])));
                         $tcol->setAttribute('align','right');
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['tsubt'],2)));
                         $tcol->setAttribute('align','right');
                    }
                    
                    if($aso_info1['lote_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['lote']));
                    }
                    
                    if($aso_info1['cambio_m']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['cambio']));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ibod_descri']));
                    }
//                          $tcol->setAttribute('align','center');
                    if($aso_info1['detalle_t']!='')
                    {
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['detalle']));
                    }
               }

          }
     
          if(mb_stristr2('.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','middle');
                    $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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','ITEM'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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;');
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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.'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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_t'];}
                    if($post==1){$item_codigo='';}
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($numlin % $linxblock==0)
                         {$trow->setAttribute('style','border-bottom:dotted 1px;');}
//                          {$trow->setAttribute('bb-do1','');}

                    $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');
               }

          }


     
//           if(1==2)
//           if(mb_stristr2('.rmed.',$modu))
     
          if(!empty($cont))
          {
//                $logo->setAttribute('style','display:none;');
//                $barc->setAttribute('style','display:none;');
          }
     
     
          if($cont==1)
          {
//                $nota->setAttribute('style','display:none;');
//                $nlet->setAttribute('style','display:none;');
          }
     
          if($modu=='rmed')
          {
               $tablh->setAttribute('style','display:none;');
               $tablf->setAttribute('style','display:none;');
               $logo->setAttribute('style','display:none;');
               $barc->setAttribute('style','display:none;');
               $adic->setAttribute('style','display:none;');
               $resu->setAttribute('style','display:none;');
               
//                $emis->setAttribute('style','font-size:0.9em;');
               
               
               $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','middle');
                    $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);

               
               
//                $tcol=$trowh->appendChild($domg->createElement('td',' '));
//                     $tcol->setAttribute('width','50%');
//                     $tcol->setAttribute('colspan','3');
//                $tcol=$trowh->appendChild($domg->createElement('td',' '));
//                     $tcol->setAttribute('width','50%');
//                $trowh=$thead->appendChild($domg->createElement('tr',' '));
               
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
                    $colg->setAttribute('style','align:center;');
                    $colg->setAttribute('style','background-color:#f0f0f0;');
               
               $tcol=$trowh->appendChild($domg->createElement('th','.'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
                    $tcol->setAttribute('width','1%');
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','PRESCRIPCION'));
                    $tcol->setAttribute('style','letter-spacing:0.5em;');
                    $tcol->setAttribute('width','49%');
//                     $tcol->setAttribute('colspan','2');
               $tcol=$trowf->appendChild($domg->createElement('td',''));


               $tcol=$trowh->appendChild($domg->createElement('th','.'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
                    $tcol->setAttribute('width','1%');
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','INDICACIONES'));
                    $tcol->setAttribute('style','letter-spacing:0.5em;');
                    $tcol->setAttribute('width','49%');
//                     $tcol->setAttribute('colspan','2');
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               

           
               msql_data_seek($res_info2);
               while($aso_info2=msql_fetch_assoc($res_info2))
               {
                    $numlin++;
                    $xstyle='';
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
//                          $xstyle.='height:2em;';
                    
                         $trfsize=1.2;
                         if($aso_info1['iddet_c']>2){$trfsize=1.1;}
                         if($aso_info1['iddet_c']>4){$trfsize=1;}
                         $xstyle.='font-size:'.$trfsize.'em; ';
                         
                              
//                     echo $xstyle;
//                          $xstyle='line-height:1.5; ';
                         if($numlin % $linxblock==0)
                         {$xstyle.='border-bottom:dotted 1px; ';}
                    
                         $trow->setAttribute('style',$xstyle);
//                          {$trow->setAttribute('bb-do1','');}

                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');

                    
                    
                    if(!empty($aso_info2['farmaco']))
                    {$xfarmaco=''.strtoupper2($aso_info2['farmaco']);}
                    
                    if(!empty($aso_info2['medicamento']))
                    {
                         $xmedica0=$aso_info2['medicamento'];
                         $xmedica1=substr($xmedica0,0,strpos($xmedica0,'||'));
                         $xmedica2=substr($xmedica0,strpos($xmedica0,'||')+2);
                         $xmedica=''.strtoupper2($xmedica0);
                         
                         if(mb_stristr2($xmedica1,$xmedica2))
                         {$xmedica=$xmedica1;}
                         
                         if(mb_stristr2($xmedica1,substr($xmedica2,0,10)))
                         {$xmedica=$xmedica1;}
                         
                    }
                    
                    $sql_rgsn='select * from rgsn0 where rgsn_descri like "'.$xmedica1.'%"';
                    $res_rgsn=msql_query($sql_rgsn,$link_data);
                    $xpriact=msql_result($res_rgsn,0,'rgsn_priact');
                    $xpriact=trim($xpriact);
                    
                    if(mb_stristr2($xpriact,'tiene'))
                    {
                         $xpriact=substr($xpriact,strpos($xpriact,'tiene')+5);
                         $xpriact=trim($xpriact);
                         if(mb_stristr2($xpriact,'     ')){$xpriact=substr($xpriact,0,strpos($xpriact,'     '));}
                         if(mb_stristr2($xpriact,'.....')){$xpriact=substr($xpriact,0,strpos($xpriact,'.....'));}
                         if(mb_stristr2($xpriact,'…')){$xpriact=substr($xpriact,0,strpos($xpriact,'…'));}
                         if(mb_stristr2($xpriact,'(')){$xpriact=substr($xpriact,0,strpos($xpriact,'('));}
                         
                    }
                    
                    if(substr($xpriact,0,1)==':'){$xpriact=substr($xpriact,1);}
                    if(substr($xpriact,0,1)=='*'){$xpriact=substr($xpriact,1);}
//                     echo '<br>===> '.$xpriact;
                    
                    $tcol=$trow->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','padding-right:2em;');
                    
                    $xcanti='# '.number_format($aso_info2['cant'],0);
                         $span=$tcol->appendChild($domg->createElement('span',$xcanti));
                              $span->setAttribute('style','font-size:1.2em; font-weight:bold; white-space:nowrap; float:right;');
                    
                    
                    
                         $span=$tcol->appendChild($domg->createElement('span',$xfarmaco));
                         $span->setAttribute('style','text-decoration:underline; letter-spacing:0.1em; ');
                         if(!empty($xfarmaco) and !empty($xmedica))
                         {$span=$tcol->appendChild($domg->createElement('div',' '));}
                         else
                         {$span=$tcol->appendChild($domg->createElement('span',' '));}
                         $span=$tcol->appendChild($domg->createElement('span',$xmedica));
                         $span->setAttribute('style','font-style:italic; ');
                    
                    
//                     $xcanti='# '.number_format($aso_info2['cant'],0);
//                     $tcol=$trow->appendChild($domg->createElement('td',$xcanti));
//                          $tcol->setAttribute('style','font-size:1.2em; font-weight:bold; white-space:nowrap;');

                    
                    if(empty($post))
                    {
//                          $tcol2=$trow;
                         $tcolx=$trow->appendChild($domg->createElement('td',''));
                         $tcol2=$trow->appendChild($domg->createElement('td',''));
                         $col_ele='span';
//                          $col_align='center';
                    }
                    
                    if($post==1)
                    {
                         $tcol2=$trow->appendChild($domg->createElement('td',''));
                         $col_ele='span';
                         $col_align='';
                    }

                    $tcol2->setAttribute('style','padding-left:20px; padding-bottom:1em;');
                    
                    $xmedicamento=ucwords2($aso_info2['medicamento']);
                    $xposi=strpos($xmedicamento,'||');
                    if($xposi>0)
                    {$xmedicamento=substr($xmedicamento,0,$xposi);}
                         
                    $xindica='';
                    $xindica.=$xmedicamento;
                    if(empty($xindica))
                    {$xindica.=$xfarmaco;}
                    $tcol=$tcol2->appendChild($domg->createElement($col_ele,$xindica));
                         $tcol->setAttribute('align',$col_align);
                         $tcol->setAttribute('style','font-weight:bold;');
                    
                    
//                     if($post==1)                    
                    $tcol=$tcol2->appendChild($domg->createElement('div',' '));
                    
                    $xiconindica=0;
                    $xindica='';
                    if($xiconindica)
                    {$xindica.=' ➡️ ';}
                    else
                    {$xindica.=' ► ';}     
                         
                    {$xindica.=' Vía: ';}
                    $xindica.=ucwords2($aso_info2['via']);
                    $xindica.='.';
                    $tcol=$tcol2->appendChild($domg->createElement($col_ele,$xindica));
//                          $tcol->setAttribute('align',$col_align);
                         $tcol->setAttribute('style','white-space: nowrap; float:left;');

                    
                    
                    
                    if(!empty($aso_info2['dosis']))
                    {
                         if($post==1)                    
                         $tcol=$tcol2->appendChild($domg->createElement('div',' '));

                         $xindica='';
                         if($xiconindica){$xindica.=' 🧪 ';}
                         else{$xindica.='.|';}
                         $xindica.='Dosis: ';
                         $xindica.=ucwords2($aso_info2['dosis']);
                         $xindica.='.';
                         $tcol=$tcol2->appendChild($domg->createElement($col_ele,$xindica));
                              $tcol->setAttribute('style','white-space: nowrap; float:left; ');
                         
                    }

                    
                    if($post==1)                    
                    $tcol=$tcol2->appendChild($domg->createElement('div',' '));
                    
                    
                    $xfreq=strtoupper($aso_info2['frecuencia']);
                    $xindica='';
                    if($xiconindica){$xindica.=' ⏱️ ';}
                    else{$xindica.='|';}
                    
                    $xindica.=' ';
                    if(mb_stristr2($xfreq,'HORA'))
                    {$xindica.=' Cada: ';}
                    $xindica.=ucfirst2($xfreq);
//                     $xindica.='';
                    $tcol=$tcol2->appendChild($domg->createElement($col_ele,$xindica));
//                          $tcol->setAttribute('align',$col_align);$xstyle.='';
                         $tcol->setAttribute('style','white-space: nowrap; font-weight:bold; float:left; ');

                    if($post==1)                    
                    $tcol=$tcol2->appendChild($domg->createElement('div',' '));
                    
                    $xdias=ucwords2($aso_info2['duracion'])*1;
                    $xindica='';
                    if($xiconindica){$xindica.=' 🗓️ ';}
//                     else{$xindica.=' |';}
                    
                    
                    if($xdias>0)
                    {
                    $xindica.='.x ';
                    $xindica.=$xdias;
                    $xindica.=' Día';
                    if($xdias>1){$xindica.='s';}
                    }
                         
                         
                    {$xindica.='.';}
                    $tcol=$tcol2->appendChild($domg->createElement($col_ele,$xindica));
                         $tcol->setAttribute('style','white-space: nowrap;  float:left; ');
                    
                    

                    
                    $xindica='';
                    $xindica.=($aso_info2['indicaciones']);
                    if(!empty($xindica))
                    {
                         if($xiconindica)
                         {$xindica=' ➡️ '.$xindica;}
                         else
                         {$xindica=' ► '.$xindica;}     
                         
                    $tcol=$tcol2->appendChild($domg->createElement('div',' '));
                         $tcol->setAttribute('style','clear:both;');
                    $tcol=$tcol2->appendChild($domg->createElement('div',''.$xindica));
                         $tcol->setAttribute('style','font-style:italic; clear:both;');
//                     $tcol=$tcol2->appendChild($domg->createElement('div',' '));
//                          $tcol->setAttribute('style','font-style:italic; float:lefx; clear:both;');
                    }
                    
//                     {$hdiv=$tcol2->appendChild($domg->createElement('div',' '));}
//                     $hdiv->setAttribute('style','min-height:50px;');
                    
               }

          }

     
     
          if(mb_stristr2('.caja.bcos.dxco.dxpa',$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','middle');
                    $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',''));
                    $div=$tcol->appendChild($domg->createElement('div','COMPROBANTE'));
               $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
//                     $tcol->setAttribute('style','letter-spacing:3pt;');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th',''));
                    $div=$tcol->appendChild($domg->createElement('div','PTO.EMI.'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));

               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th',''));
                    $div=$tcol->appendChild($domg->createElement('div','NUMERO'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));

               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','VALOR'));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['total'],2)));
                    $tcol->setAttribute('align','right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','CUENTA'));
               $tcol=$trowf->appendChild($domg->createElement('td',' '));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th',''));
                    $div=$tcol->appendChild($domg->createElement('div','CONTABLE'));
//                $tcol=$trowf->appendChild($domg->createElement('td',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('align','right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
               $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_t'];}
//                     if($post==1){$item_codigo='';}
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($numlin % $linxblock==0)
                         {$trow->setAttribute('style','border-bottom:dotted 1px;');}
//                          {$trow->setAttribute('bb-do1','');}

                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');
                    
                    $docum0=data_maes('docu',$aso_info2['docum']);
//                     var_dump2($docum0);
                    $docum_descri=$docum0['docu_descri'];
//                     if(substr($aso_info2['docum'],0,1)=='F'){$docum_descri='FACTURA';}
//                     if(substr($aso_info2['docum'],0,4)=='FP03'){$docum_descri='LIQUIDACION DE COMPRA';}
//                     if(substr($aso_info2['docum'],0,4)=='FP11'){$docum_descri='LIQUIDACION DE COMPRA';}
                    $tcol=$trow->appendChild($domg->createElement('td',$docum_descri));
                         $tcol->setAttribute('align','center');
                    
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ptoem']));
                         $tcol->setAttribute('align','center');
                    
                    
                    if(!empty($aso_info2['docum']))
                    {
                         $sql_idcb ='select * from '.$docum0['docu_tabla'].'1 ';
                         $sql_idcb.='where ifnull(status,"")not in ("X") ';
                         $sql_idcb.='and docu like "'.substr($aso_info2['docum'],0,2).'%" ';
                         if(!empty($aso_info2['ptoem']))
                         {$sql_idcb.='and ptoe="'.$aso_info2['ptoem'].'" ';}
//                          $sql_idcb.='and numero*1="'.(int)$aso_info2['numer'].'" ';
                         $sql_idcb.='and idfrom="'.$aso_info1['idnum1'].'" ';
                         $res_idcb=msql_query($sql_idcb,$link_data);

//                          echo '==='.$sql_idcb;
                         
                         if(msql_num_rows($res_idcb)==0)
                         {
                              $sql_idcb ='select * from '.$docum0['docu_tabla'].'1 ';
                              $sql_idcb.='where ifnull(status,"")not in ("X") ';
                              $sql_idcb.='and docu like "'.substr($aso_info2['docum'],0,2).'%" ';
                              if(!empty($aso_info2['ptoem']))
                              {$sql_idcb.='and ptoe="'.$aso_info2['ptoem'].'" ';}
     //                          $sql_idcb.='and numero*1="'.(int)$aso_info2['numer'].'" ';
                              $sql_idcb.='and idnum1="'.$aso_info1['idfrom'].'" ';
                              $res_idcb=msql_query($sql_idcb,$link_data);
                         }
                         
                         
//                          if(msql_num_rows($res_idcb)==0 )
                         if(msql_num_rows($res_idcb)==0 or mb_stristr2('.dxco.dxpa',$modu))
                         {
                              $sql_idcb ='select * from '.$docum0['docu_tabla'].'1 ';
                              $sql_idcb.='where ifnull(status,"")not in ("X") ';
                              $sql_idcb.='and docu like "'.substr($aso_info2['docum'],0,2).'%" ';
                              if(!empty($aso_info2['ptoem']))
                              {$sql_idcb.='and ptoe="'.$aso_info2['ptoem'].'" ';}
                              $sql_idcb.='and numero*1="'.(int)$aso_info2['numer'].'" ';
//                               $sql_idcb.='and idnum1="'.$aso_info1['idfrom'].'" ';
                              $res_idcb=msql_query($sql_idcb,$link_data);
                         }
                         
                         
//                          echo '==='.$sql_idcb;
                         
                         $xidcb=msql_result($res_idcb,0,'idnum1');
                    }
                    
                    $tcol=$trow->appendChild($domg->createElement('td',' '));
                         $tcol->setAttribute('align','center');
                         $style='';
                         $style.='background-color:'.$xbgcolor3.';';
                         $tcol->setAttribute('style',$style);

                         $href='';
                         $href.='https://'.$_SERVER['SERVER_NAME'].'/';
//                          if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
//                          {$href.='index3.php';}
                         $href='?scri=info_docu3&prnt=1';
                         $href.='&docu='.$aso_info2['docum'];
                         $href.='&idnum='.$xidcb.'';
                         $href.='&cont='.$cont.'';
                    
                         $ref=$tcol->appendChild($domg->createElement('a',htmlspecialchars((int)$aso_info2['numer'])));
                         $ref->setAttribute('num',$value);
                         $ref->setAttribute('href',$href);
                         $ref->setAttribute('target','_blank');
                    
                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['total'],2)));
                         $tcol->setAttribute('align','right');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ctas']));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ctas_descri']));
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['detalle']));
                    
                    
                    
//                          $tcol->setAttribute('align','center');
               }

          }
     
     
     
          if(mb_stristr2('.retc.retp.',$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','middle');
                    $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',''));
                    $div=$tcol->appendChild($domg->createElement('div','EJERCICIO'));
                    $div=$tcol->appendChild($domg->createElement('div','FISCAL'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
//                     $tcol->setAttribute('style','letter-spacing:3pt;');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th',''));
                    $div=$tcol->appendChild($domg->createElement('div','BASE'));
                    $div=$tcol->appendChild($domg->createElement('div','IMPONIBLE'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));

               $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowh->appendChild($domg->createElement('th','IMPUESTO'));
//                $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['tcant'],$aso_info1['item_duni'])));
//                     $tcol->setAttribute('align','right');
               $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
                    $tcol->setAttribute('style','letter-spacing:3pt;');    
                    $tcol->setAttribute('align','center');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','%RET.'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th',''));
                    $div=$tcol->appendChild($domg->createElement('div','VALOR'));
                    $div=$tcol->appendChild($domg->createElement('div','RETENIDO'));
//                $tcol=$trowf->appendChild($domg->createElement('td',''));
               $colg->setAttribute('style','background-color:#f0f0f0;');
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['total'],2)));
                    $tcol->setAttribute('align','right');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','COMPROBANTE'));
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','NUMERO'));
               $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_t'];}
//                     if($post==1){$item_codigo='';}
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($numlin % $linxblock==0)
                         {$trow->setAttribute('style','border-bottom:dotted 1px;');}
//                          {$trow->setAttribute('bb-do1','');}

                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',substr($aso_info1['fecha'],0,4)));
                         $tcol->setAttribute('align','center');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['cant'],2)));
                         $tcol->setAttribute('align','right');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',''));
                         if($aso_info2['base_rta']>0)
                         {
                              $div=$tcol->appendChild($domg->createElement('div',$aso_info2['cair_descri']));
                              $div=$tcol->appendChild($domg->createElement('div','('.$aso_info2['cair'].')'));
                         }
                         if($aso_info2['base_iva']>0)
                         {
                              $div=$tcol->appendChild($domg->createElement('div','IVA'.' ('.$aso_info2['cair'].')'));
//                               $div=$tcol->appendChild($domg->createElement('div',$aso_info2['cair']));
                         }
                         $tcol->setAttribute('align','center');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['puni'],2)));
                         $tcol->setAttribute('align','center');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['total'],2)));
                         $tcol->setAttribute('align','right');
                    
                    $docum0=data_maes('docu',$aso_info2['docum']);
                    if(substr($aso_info2['docum'],0,1)=='F'){$docum_descri='FACTURA';}
                    if(substr($aso_info2['docum'],0,4)=='FP03'){$docum_descri='LIQUIDACION DE COMPRA';}
                    if(substr($aso_info2['docum'],0,4)=='FP11'){$docum_descri='LIQUIDACION DE COMPRA';}
                    $tcol=$trow->appendChild($domg->createElement('td',$docum_descri));
                         $tcol->setAttribute('align','center');
                    
//                     $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['ptoem'].'-'.$aso_info2['numer']));
                    
                    $tcol=$trow->appendChild($domg->createElement('td',' '));
                         $tcol->setAttribute('align','center');
                         $style='';
//                          $style.='background-color:'.$xbgcolor3.';';
                         $tcol->setAttribute('style',$style);
                    
                         if($modu=='retc'){$tfac='vtas';}
                         if($modu=='retp'){$tfac='comp';}
                    
                         $sql_fact='select * from '.$tfac.'1 ';
                         $sql_fact.='where ifnull(status,"")not in("X") ';
                         $sql_fact.='and docu="'.$aso_info2['docum'].'" ';
                         $sql_fact.='and ptoe="'.$aso_info2['ptoem'].'" ';
                         $sql_fact.='and numero="'.$aso_info2['numer'].'" ';
                         $sql_fact.='and enti like "'.substr($aso_info2['enti'],0,10).'%" ';
                         $res_fact=msql_query($sql_fact,$link_data);
                    
//                          if($modu=='retc')
                         if(msql_num_rows($res_fact)==0)
                         {
                              $sql_fact='select * from '.$tfac.'1 ';
                              $sql_fact.='where ifnull(status,"")not in("X") ';
                              $sql_fact.='and docu="'.$aso_info2['docum'].'" ';
//                               $sql_fact.='and ptoe="'.$aso_info2['ptoem'].'" ';
                              $sql_fact.='and numero="'.$aso_info2['numer'].'" ';
                              $sql_fact.='and enti like "'.substr($aso_info2['enti'],0,10).'%" ';
                              $res_fact=msql_query($sql_fact,$link_data);
                         }
                    
                         $idfact=msql_result($res_fact,0,'idnum1');     
                    

                         $href='https://'.$_SERVER['SERVER_NAME'].'/';
                         if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
                         {$href.='index3.php';}
                         $href.='?scri=info_docu3&prnt=1';
//                          $href.='&docu='.$aso_info2['docum'].'&idnum='.$aso_info2['idnum2'].'';
                         $href.='&docu='.$aso_info2['docum'].'&idnum='.$idfact.'';
                         $ref=$tcol->appendChild($domg->createElement('a',$aso_info2['ptoem'].'-'.$aso_info2['numer']));                           
                         $ref->setAttribute('num',$value);
                         $ref->setAttribute('href',$href);
                         $ref->setAttribute('target','_blank');
                    
                    
                         $tcol->setAttribute('align','center');
                    
//                          $tcol->setAttribute('align','center');
               }

          }
     
          if(mb_stristr2('.hcli.',$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','middle');
                    $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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','DATO'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','NOTAS'));
                    $tcol->setAttribute('style','letter-spacing:3pt;');
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','letter-spacing:3pt;');    
                    $tcol->setAttribute('align','center');

               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','USR'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $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_t'];}
                    if($post==1){$item_codigo='';}
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($numlin % $linxblock==0)
                         {$trow->setAttribute('style','border-bottom:dotted 1px;');}
//                          {$trow->setAttribute('bb-do1','');}

                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');
                    $tcol=$trow->appendChild($domg->createElement('td',strtoupper($aso_info2['dato'])));
                    
                    $xnotas=$aso_info2['item_descri'].' /'.$aso_info2['notas'];
                    $tcol=$trow->appendChild($domg->createElement('td',$xnotas));
                    
                    $tcol=$trow->appendChild($domg->createElement('td',$aso_info2['iuser2']));
                         $tcol->setAttribute('align','center');
               }

          }

     

          if(mb_stristr2('.otbj.',$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','middle');
                    $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'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('th',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','FECHA'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','HORA'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','FASE'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','DETALLES'));
                    $tcol->setAttribute('style','letter-spacing:3pt;');
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
                    $tcol->setAttribute('style','letter-spacing:3pt;');    
                    $tcol->setAttribute('align','center');
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','VALOR'));
                    $tcol->setAttribute('style','letter-spacing:3pt;');
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($aso_info1['total'],2)));
//                     $tcol->setAttribute('style','letter-spacing:3pt;');    
                    $tcol->setAttribute('align','right');
               
               
               $colg=$tcolg->appendChild($domg->createElement('col',''));
               $tcol=$trowh->appendChild($domg->createElement('th','NOTAS'));
                    $onclick='sortTable(this,'.$xsort++.',"");';
                    $tcol->setAttribute('onclick',$onclick);
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               
//                $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $tcol=$trowh->appendChild($domg->createElement('th','MECANICO'));
//                     $onclick='sortTable(this,'.$xsort++.',"");';
//                     $tcol->setAttribute('onclick',$onclick);
//                $tcol=$trowf->appendChild($domg->createElement('td',''));
               
               

//                $colg=$tcolg->appendChild($domg->createElement('col',''));
//                $tcol=$trowh->appendChild($domg->createElement('th','USR'));
//                     $onclick='sortTable(this,'.$xsort++.',"");';
//                     $tcol->setAttribute('onclick',$onclick);
//                $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_t'];}
                    if($post==1){$item_codigo='';}
                    
                    $numlin++;
                    $trow=$tbody->appendChild($domg->createElement('tr',''));
                         $trow->setAttribute('name',$aso_info2['iddet']);
                         $trow->setAttribute('valign','top');
                         if($numlin % $linxblock==0)
                         {$trow->setAttribute('style','border-bottom:dotted 1px;');}
//                          {$trow->setAttribute('bb-do1','');}

                    $tcol=$trow->appendChild($domg->createElement('td',$clin++.'.'));
                         $tcol->setAttribute('align','center');
                    
                    $tcol=$trow->appendChild($domg->createElement('td',($aso_info2['fecha1'])));
                         $tcol->setAttribute('align','center');
                    $tcol=$trow->appendChild($domg->createElement('td',($aso_info2['hora1'])));
                         $tcol->setAttribute('align','center');
                    
                    $xfase=($aso_info2['fase']);
                    if(stripos($xfase,'contra')!==false){$xfase='TRABAJO';}
                    $xfase=strtoupper($xfase);
                    $tcol=$trow->appendChild($domg->createElement('td',$xfase));
//                          $tcol->setAttribute('align','center');
                    
                    $xdatos=$aso_info2['item_descri'].' /'.$aso_info2['detalles'];
                    $tcol=$trow->appendChild($domg->createElement('td',$xdatos));
           
                    $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_info2['total'],2)));
                         $tcol->setAttribute('align','right');
           
                    $xnotas=$aso_info2['detalle'];
                    $tcol=$trow->appendChild($domg->createElement('td',$xnotas));
           
//                     $mecanico=ucwords2(($aso_info2['mcnc_ape1'].' '.$aso_info2['mcnc_nom1']));
//                     $tcol=$trow->appendChild($domg->createElement('td',$mecanico));
//                          $tcol->setAttribute('align','center');
                    
//                     $iuser20=data_maes('user',$aso_info2['iuser2']);
//                     $tcol=$trow->appendChild($domg->createElement('td',$iuser20['user_descri']));
//                          $tcol->setAttribute('align','center');
               }

          }

     

     
          $numcol = 0;
          foreach($trowh->childNodes as $node)    
          if(!($node instanceof \DomText))$numcol++;
          $tcoldeta->setAttribute('colspan',$numcol);

     
     

     
}

          // DATOS TICKET
if($tckt==1)
{

     $ttbl=$dato->appendChild($domg->createElement('table',''));
               $xstyle='';
//                $xstyle.='border-collapse:collapse;';
//                $xstyle.='cellpadding:50px;';
//                $xstyle.='cellspacing:50px;';
//                $xstyle.='font-size:'.$fontsize.'px;';
               $xstyle.='font-weight:bold;';
               $xstyle.='font-size:16px;';
               $xstyle.='line-height:2em;';
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
//                $ttbl->setAttribute('cellpadding','');
               $ttbl->setAttribute('cellspacing','10');

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


          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','TICKET'));
               $tcol->setAttribute('colspan','2');
               $tcol->setAttribute('align','center');
               $xstyle='';
               $xstyle.='letter-spacing:1em;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','EMISOR :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','center');
               $tcol->appendChild($domg->createElement('div',$emis0['enti_codigo']));
               $tcol->appendChild($domg->createElement('div',$emis0['enti_nomcom']));

     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('style','font-weight:bold; text-transform: uppercase;');
          $tcol=$trow->appendChild($domg->createElement('td','CLIENTE :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('style','display:none;');
               $tcol->setAttribute('align','center');
               $tcol->appendChild($domg->createElement('div',$adqu0['enti_codigo']));
               $tcol->appendChild($domg->createElement('div',$adqu0['enti_razsoc']));
     
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','FECHA :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['dia_des'].' '.strtoupper($aso_info1['dmy1'])));
               $tcol->setAttribute('align','center');

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

     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','PLACA :'));
               $trow->setAttribute('style','font-weight:bold; ');
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','center');
               $tcol->setAttribute('style','font-size:150%;');
              $tcol->appendChild($domg->createElement('div',strtoupper($aso_info1['plvh'])));
              $tcol->appendChild($domg->createElement('div',$aso_info1['plvh_mrca'].' /'.$aso_info1['plvh_clor']));

     
          if(!empty($aso_info1['plvh_propietario']) and 1==2)
          {
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','NOMBRE :'));
               $trow->setAttribute('style','font-weight:bold; ');
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td',''));
               $tcol->setAttribute('align','center');
               $tcol->setAttribute('style','font-size:70%;');
              $tcol->appendChild($domg->createElement('div',ucwords2($aso_info1['plvh_propietario'])));
          }

     
     
     
     
          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','TARIFA :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td',str_replace('GARAGE','',$aso_info1['item_descri'])));
               $tcol->setAttribute('align','center');
               $tcol->appendChild($domg->createElement('div',' '));
               $tcol->appendChild($domg->createElement('span',number_format($aso_info1['puni']*(1+$aso_info1['iva']/100),2)));
               $tcol->appendChild($domg->createElement('span',' x Hora o Frac.'));

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','ENTRA :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td','ENTRA : '.$aso_info1['hora1']));
               $tcol->setAttribute('align','center');
               $tcol->setAttribute('style','font-size:150%;');

          $trow=$ttbl->appendChild($domg->createElement('tr',''));
          $tcol=$trow->appendChild($domg->createElement('td','ID :'));
               $xstyle='text-align:right;';
               $tcol->setAttribute('style',$xstyle);
               $tcol->setAttribute('style','display:none;');
          $tcol=$trow->appendChild($domg->createElement('td',$aso_info1['idnum1']));
               $tcol->setAttribute('style','font-size:100%;');
               $tcol->setAttribute('align','right');

     
     
     
//           if(empty($mailsend))
          if(mb_stristr2('.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('align','center');
                    $tcol->setAttribute('style','background:darkred;color:white;font-weight:bold');
          }
     
     

     
}


if(empty($cont) and empty($abon) and empty($bode))
{
     if(!empty($pagare1)){$span=$paga1->appendChild($domg->createElement('span',$pagare1));}
     if(!empty($pagare2)){$span=$paga2->appendChild($domg->createElement('span',$pagare2));}
}     


/* <p class="pgbreak" /></p>	 */


// if($cont!=0)
// if(!empty($cont))
if($cont>=2)     
if(gettype($res_cont)=='object')
{
                    
          $ttbl=$detai->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='margin-top:5mm;';
               $xstyle.='font-family:arial;';     
               $xstyle.='page-break-inside: avoid;';     
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('id','tbl_cont');
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

          $tcolg=$ttbl->appendChild($domg->createElement('colgroup',''));
          $thead=$ttbl->appendChild($domg->createElement('thead',''));
          $tbody=$ttbl->appendChild($domg->createElement('tbody',''));
          $tfoot=$ttbl->appendChild($domg->createElement('tfoot',''));
     
          $trowh=$thead->appendChild($domg->createElement('tr',''));
     
          $tcol=$trowh->appendChild($domg->createElement('td',' '));
               $tcol->setAttribute('colspan','20');
               $xstyle='';    
               $xstyle.='font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
          $span=$tcol->appendChild($domg->createElement('span','CONTABILIDAD'));
               $xstyle='';    
               $xstyle.='letter-spacing:5pt;';
               $span->setAttribute('style',$xstyle);
          $span=$tcol->appendChild($domg->createElement('span',$aso_info1['docu'].' : '.$aso_info1['ptoe'].' - '.$aso_info1['numero']));
               $xstyle='';    
               $xstyle.='float:right;';
               $span->setAttribute('style',$xstyle);
     
               $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','middle');
               $trowh->setAttribute('style',$style);
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
     
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
          $trowf=$tfoot->appendChild($domg->createElement('tr',''));
               $trowf->setAttribute('valign','top');
               $trowf->setAttribute('style',$style);
               
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
               $tcol=$trowh->appendChild($domg->createElement('th','CUENTA'));
               $tcol=$trowh->appendChild($domg->createElement('th','CONTABLE'));
               $tcol=$trowh->appendChild($domg->createElement('th','DEBITOS'));
               $tcol=$trowh->appendChild($domg->createElement('th','CREDITOS'));
               $tcol=$trowh->appendChild($domg->createElement('th',''));
               $tcol=$trowh->appendChild($domg->createElement('th','CSUB'));
               $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
               $tcol=$trowh->appendChild($domg->createElement('th','CAIR'));
               $tcol=$trowh->appendChild($domg->createElement('th',''));
               $tcol=$trowh->appendChild($domg->createElement('th',''));

     
     $tot_debito=0;
     $tot_credito=0;
     $xrow=0;
     $numlin=0;
     msql_data_seek($res_cont);
     while($aso_cont=msql_fetch_assoc($res_cont))
     {
          $xidcont=$aso_cont['idnum1'];          
          $trow=$tbody->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('name',$xrow++);
               $numlin++;
               if($numlin % $linxblock==0)
               {$trow->setAttribute('style','border-bottom:1px dotted;');}
          
          
          $tcol=$trow->appendChild($domg->createElement('td',$numlin.'.'));
               $tcol->setAttribute('align','center');
               $style='';
               $style.='background-color:'.$xbgcolor3.';';
               $tcol->setAttribute('style',$style);
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_cont['ctas']));
          $tcol=$trow->appendChild($domg->createElement('td',$aso_cont['ctas_descri']));
          
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_cont['debito'],2)));
               $tcol->setAttribute('align','right');
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_cont['credito'],2)));
               $tcol->setAttribute('align','right');
          
          $tcol=$trow->appendChild($domg->createElement('td',''));
          $tcol=$trow->appendChild($domg->createElement('td',$aso_cont['csub']));
               $tcol->setAttribute('align','center');
          $tcol=$trow->appendChild($domg->createElement('td',$aso_cont['detalle']));
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_cont['cair']));
               $tcol->setAttribute('align','center');
          
          
          
          
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_cont['item']));
               $tcol->setAttribute('align','center');
          $tcol=$trow->appendChild($domg->createElement('td',$aso_cont['item_descri']));
          
          $tot_debito+=$aso_cont['debito'];
          $tot_credito+=$aso_cont['credito'];
          
          
     }
     
//      msql_data_seek($res_cont);
     
          $tcol=$trowf->appendChild($domg->createElement('td',''));
     
     
          $tcol=$trowf->appendChild($domg->createElement('td','ID : '.$xidcont));
          $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
               $tcol->setAttribute('align','center');          
          $tcol=$trowf->appendChild($domg->createElement('td',number_format($tot_debito,2)));
               $tcol->setAttribute('align','right');
          $tcol=$trowf->appendChild($domg->createElement('td',number_format($tot_credito,2)));
               $tcol->setAttribute('align','right');

     
          $difer=$tot_debito-$tot_credito;
          if(abs($difer)<1/100){$difer='';}
          else{$difer=number_format($difer,2);}
     
          $tcol=$trowf->appendChild($domg->createElement('td',$difer));
               $tcol->setAttribute('align','right');
               $tcol->setAttribute('red','');
     
     
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));

     
     
     
}  

// if(gettype($res_inve)=='object')
if($bode==1)     
{
          $ttbl=$detai->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='margin-top:5mm;';
               $xstyle.='font-family:arial;';     
               $xstyle.='page-break-inside: avoid;';     
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('id','tbl_inve');
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

          $tcolg=$ttbl->appendChild($domg->createElement('colgroup',''));
          $thead=$ttbl->appendChild($domg->createElement('thead',''));
          $tbody=$ttbl->appendChild($domg->createElement('tbody',''));
          $tfoot=$ttbl->appendChild($domg->createElement('tfoot',''));
     
          $trowh=$thead->appendChild($domg->createElement('tr',''));
          $tcol=$trowh->appendChild($domg->createElement('td',' '));
               $tcol->setAttribute('colspan','20');
               $xstyle='';    
               $xstyle.='font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
          $span=$tcol->appendChild($domg->createElement('span','BODEGA'));
               $xstyle='';    
               $xstyle.='letter-spacing:5pt;';
               $span->setAttribute('style',$xstyle);
          $span=$tcol->appendChild($domg->createElement('span',$aso_info1['docu'].' : '.$aso_info1['ptoe'].' - '.$aso_info1['numero']));
               $xstyle='';    
               $xstyle.='float:right;';
               $span->setAttribute('style',$xstyle);
     
     
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
          $trowh=$thead->appendChild($domg->createElement('tr',''));
//           $trowh=$thead->appendChild($domg->createElement('tr',''));
               $trowh->setAttribute('valign','middle');
               $trowh->setAttribute('style',$style);
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
//                $trow->setAttribute('valign','top');
//                $trow->setAttribute('style',$style);
     
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
          $trowf=$tfoot->appendChild($domg->createElement('tr',''));
               $trowf->setAttribute('valign','top');
               $trowf->setAttribute('style',$style);
               
//                if($post!=1)
//                {$colg=$tcolg->appendChild($domg->createElement('col',''));}
//                if($post!=1)
//                {$colg->setAttribute('style','background-color:#f0f0f0;');}
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
               $tcol=$trowh->appendChild($domg->createElement('th','FECHA'));
               $tcol=$trowh->appendChild($domg->createElement('th','DOCU'));
               $tcol=$trowh->appendChild($domg->createElement('th','BODE'));
               $tcol=$trowh->appendChild($domg->createElement('th','NUMERO'));
               $tcol=$trowh->appendChild($domg->createElement('th','ITEM'));
               $tcol=$trowh->appendChild($domg->createElement('th','DESCRIPCION'));
               $tcol=$trowh->appendChild($domg->createElement('th','CANT'));
               $tcol=$trowh->appendChild($domg->createElement('th','U.Mdd'));
     
     
               if($cost=='true')
               {
                    $tcol=$trowh->appendChild($domg->createElement('th','UNIT'));
                    $tcol=$trowh->appendChild($domg->createElement('th','TOTAL'));
               }
     
               $tcol=$trowh->appendChild($domg->createElement('th','LOTE / SERIE'));
               $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
     
     $cant_bode=0;
     $cost_bode=0;
     $xrow=0;
     $numlin=0;
     if(gettype($res_inve)=='object')
     {
     msql_data_seek($res_inve);
     while($aso_inve=msql_fetch_assoc($res_inve))
     {
          $trow=$tbody->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('name',$xrow++);
               $numlin++;
               if($numlin % $linxblock==0)
               {$trow->setAttribute('style','border-bottom:1px dotted;');}
          
          
          $tcol=$trow->appendChild($domg->createElement('td',$numlin.'.'));
               $tcol->setAttribute('align','center');
               $style='';
               $style.='background-color:'.$xbgcolor3.';';
               $tcol->setAttribute('style',$style);
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['fecha']));
               $tcol->setAttribute('align','center');
               $tcol->setAttribute('style','white-space: nowrap');
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['docu']));
               $tcol->setAttribute('align','center');
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['bode']));
               $tcol->setAttribute('align','center');
          
          
//           $tcol=$trow->appendChild($domg->createElement('td',(int)$aso_inve['numero']));
          $tcol=$trow->appendChild($domg->createElement('td',' '));
               $tcol->setAttribute('align','center');
               $style='';
               $style.='background-color:'.$xbgcolor3.';';
               $tcol->setAttribute('style',$style);

          
//                $href='https://'.strtolower($empr0['empr_codigo']).'.'.$file_server.'/';
               $href='';
               $href.='https://'.$_SERVER['SERVER_NAME'].'/';
               if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
               {$href.='index3.php';}
               $href.='?scri=info_docu3&prnt=1';
               $href.='&docu='.$aso_inve['docu'].'&idnum='.$aso_inve['idnum1'].'';
               $ref=$tcol->appendChild($domg->createElement('a',htmlspecialchars((int)$aso_inve['numero'])));                           
               $ref->setAttribute('num',$value);
               $ref->setAttribute('href',$href);
               $ref->setAttribute('target','_blank');
          
          
//           echo '<br>==>'.$aso_info1['impor'];
          
          $cant_comp=$aso_inve['cant'];
          if(!empty($aso_info1['impor']))
          {
               $sql_prov ='select * from prov1 ';
               $sql_prov.='left join prov2 on idnum1=idnum2 ';
               $sql_prov.='where ifnull(status,"")not in ("O","X") ';
               $sql_prov.='and impor="'.$aso_info1['impor'].'" ';
               $sql_prov.='and item="'.$aso_inve['item'].'" ';
               $res_prov=msql_query($sql_prov,$link_data);
               $cant_comp=msql_result($res_prov,0,'cant');
          }
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['item']));
               $tcol->setAttribute('align','center');
               if($cant_comp==0)
               {
                    $tcol->setAttribute('bold','');
                    $tcol->setAttribute('style','background-color:gold');
               }
          
          
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['item_descri']));
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_inve['cant'],$aso_inve['item_duni'])));
               $tcol->setAttribute('align','right');          
               $style='';
               $style.='background-color:'.$xbgcolor3.';';
               if($cant_comp<$aso_inve['cant'])
               {
                    $tcol->setAttribute('bold','');
                    $style.='background-color:gold;';
               }
          
          
               $tcol->setAttribute('style',$style);
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['item_umdd']));
               $tcol->setAttribute('align','center');          
          
          if($cost=='true')
          {
               
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_inve['puni'],$aso_inve['item_dcos'])));
               $tcol->setAttribute('align','right');          
               $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_inve['cant']*$aso_inve['puni'],2)));
               $tcol->setAttribute('align','right');          
          }
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['lote']));
          $tcol=$trow->appendChild($domg->createElement('td',$aso_inve['detalle_t']));
          $cant_bode+=$aso_inve['cant'];
//           echo '<br>=== '.$cant_bode;
          $cost_bode+=$aso_inve['cant']*$aso_inve['puni'];
     }
     }     
     

          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
               $tcol->setAttribute('align','center');          
          $tcol=$trowf->appendChild($domg->createElement('td',number_format($cant_bode,2)));
               $tcol->setAttribute('align','right');
          $tcol=$trowf->appendChild($domg->createElement('td',''));

          if($cost=='true')
          {
               $tcol=$trowf->appendChild($domg->createElement('td',''));
               $tcol=$trowf->appendChild($domg->createElement('td',number_format($cost_bode,2)));
               $tcol->setAttribute('align','right');
          }
     
          $cant_fact=$aso_info1['cant_conv'];
     
//      echo '==='.$cant_fact;
     
          if($modu=='vtas')
          {
               $sql_cantfact='select sum(cant) as cant_fact from vtas2 ';
               $sql_cantfact.='where idnum2="'.$aso_info1['idnum1'].'" ';
               $sql_cantfact.='and item in(select distinct item from inve1 left join inve2 on idnum1=idnum2 where ifnull(status,"")not in ("O","X") and docu like "IB%")';
               $res_cantfact=msql_query($sql_cantfact,$link_data);
               $cant_fact=msql_result($res_cantfact,0,'cant_fact');               
          }
     
          if($modu=='opro')
          {
               $sql_cantfact='select sum(cant) as cant_fact from opro2 ';
               $sql_cantfact.='where idnum2="'.$aso_info1['idnum1'].'" ';
               $sql_cantfact.='and item in(select distinct item from inve1 left join inve2 on idnum1=idnum2 where ifnull(status,"")not in ("O","X") and docu like "IB%")';
               $res_cantfact=msql_query($sql_cantfact,$link_data);
               $cant_fact=msql_result($res_cantfact,0,'cant_fact');               
          }
     
//      echo '===='.$sql_cantfact;
//      echo '===='.$cant_fact;
     
          $porc_inve=0;
          if($cant_fact>0)
          {$porc_inve=($cant_bode/$cant_fact)*100;}
     
//           echo '<br>== '.$cant_bode;
//           echo '<br>== '.$cant_fact;
//           echo '<br>== '.$porc_inve;
     
          $textoinve='INVENTARIO : ';
          $textoinve.=number_format($porc_inve,1).' %';
          $tcol=$trowf->appendChild($domg->createElement('td',$textoinve));
               $xstyle='white-space:nowrap;';
//                $xstyle='';
               if($porc_inve>110){$xstyle.='background-color:black; color:white;';}
               elseif($porc_inve>100){$xstyle.='background-color:blue; color:white;';}
               elseif($porc_inve==100){$xstyle.='background-color:green; color:white;';}
               elseif($porc_inve>90){$xstyle.='background-color:gold; color:black;';}
               elseif($porc_inve>0){$xstyle.='background-color:darkred; color:white;';}
     
               $tcol->setAttribute('colspan','2');          
               $tcol->setAttribute('align','center');          
               $tcol->setAttribute('style',$xstyle);          
// 
//           $tcol=$trowf->appendChild($domg->createElement('td',''));
     
     
     
     
}


if($abon==1)     
if(substr($docu,0,1)=='F')
{
          $ttbl=$detaa->appendChild($domg->createElement('table',''));
               $xstyle='';
               $xstyle.='border-collapse:collapse;';
               $xstyle.='margin-top:5mm;';
               $xstyle.='font-family:arial;';     
               if($tckt==1)
               {$xstyle.='display:none;';}
               $ttbl->setAttribute('id','tbl_abon');
               $ttbl->setAttribute('style',$xstyle);
               $ttbl->setAttribute('border','0');
               $ttbl->setAttribute('width','100%');
               $ttbl->setAttribute('cellspacing','0');
               $ttbl->setAttribute('screen_fontsize','');
               $ttbl->setAttribute('print_fontsize','');
     

          $tcolg=$ttbl->appendChild($domg->createElement('colgroup',''));
          $thead=$ttbl->appendChild($domg->createElement('thead',''));
          $tbody=$ttbl->appendChild($domg->createElement('tbody',''));
          $tfoot=$ttbl->appendChild($domg->createElement('tfoot',''));
     
          $trowh=$thead->appendChild($domg->createElement('tr',''));
          $tcol=$trowh->appendChild($domg->createElement('td','ABONOS'));
               $tcol->setAttribute('colspan','20');
               $xstyle='';    
               $xstyle.='letter-spacing:5pt;text-align:;font-weight:bold;';
               $xstyle.='background:'.$xbgcolor2.';';
               $tcol->setAttribute('style',$xstyle);
     
               $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','middle');
               $trowh->setAttribute('style',$style);
               $style='border-top:solid 1px; border-bottom:solid 2px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
     
               $style='border-top:solid 2px; border-bottom:solid 1px;';
               $style.='background-color:'.$xbgcolor2.'; font-weight:bold;';
          $trowf=$tfoot->appendChild($domg->createElement('tr',''));
               $trowf->setAttribute('valign','top');
               $trowf->setAttribute('style',$style);
               
               $tcol=$trowh->appendChild($domg->createElement('th','L'));
               $tcol=$trowh->appendChild($domg->createElement('th','FECHA'));
               $tcol=$trowh->appendChild($domg->createElement('th','DOCU'));
               $tcol=$trowh->appendChild($domg->createElement('th','NUMERO'));
               $tcol=$trowh->appendChild($domg->createElement('th','DEBITO'));
               $tcol=$trowh->appendChild($domg->createElement('th','CREDITO'));
               $tcol=$trowh->appendChild($domg->createElement('th','CAIR'));
//                $tcol=$trowh->appendChild($domg->createElement('th','BASE'));
               $tcol=$trowh->appendChild($domg->createElement('th','% RTA'));
               $tcol=$trowh->appendChild($domg->createElement('th','% IVA'));
               $tcol=$trowh->appendChild($domg->createElement('th','DETALLE'));
                    $tcol->setAttribute('width','50%;');
     
     $tot_debito=0;
     $tot_credito=0;
     $xrow=0;
     $numlin=0;
     if(gettype($res_abon)=='object')
     {
     msql_data_seek($res_abon);
     while($aso_abon=msql_fetch_assoc($res_abon))
     {
          $trow=$tbody->appendChild($domg->createElement('tr',''));
               $trow->setAttribute('name',$xrow++);
               if($aso_abon['st']=='O')
               {$trow->setAttribute('linethr','');}
          
               $numlin++;
               if($numlin % $linxblock==0)
               {$trow->setAttribute('style','border-bottom:1px dotted;');}
          
          
          $tcol=$trow->appendChild($domg->createElement('td',$numlin.'.'));
               $tcol->setAttribute('align','center');
               $style='';
               $style.='background-color:'.$xbgcolor3.';';
               $tcol->setAttribute('style',$style);
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_abon['fecha']));
               $tcol->setAttribute('align','center');
               $tcol->setAttribute('style','white-space: nowrap;');
          $tcol=$trow->appendChild($domg->createElement('td',$aso_abon['documento']));
               $tcol->setAttribute('align','center');
          
//           $tcol=$trow->appendChild($domg->createElement('td',$aso_abon['ptoem_hide'].'-'.$aso_abon['numero']));
//                $tcol->setAttribute('align','center');
//                $style='';
//                $style.='white-space: nowrap;background-color:'.$xbgcolor3.';';
//                $tcol->setAttribute('style',$style);

          
          $tcol=$trow->appendChild($domg->createElement('td',' '));
               $tcol->setAttribute('align','center');
               $style='';
               $style.='white-space: nowrap;background-color:'.$xbgcolor3.';';
               $tcol->setAttribute('style',$style);

               $href='';
               $href.='https://'.$_SERVER['SERVER_NAME'].'/';
               if(mb_stristr2($_SERVER['REQUEST_URI'],'index3.php'))
               {$href.='index3.php';}
               $href='?scri=info_docu3&prnt=1';
               $href.='&docu='.$aso_abon['docu'].'&idnum='.$aso_abon['idnum1_hide'].'';
               $ref=$tcol->appendChild($domg->createElement('a',htmlspecialchars((int)$aso_abon['numero'])));                           
               $ref->setAttribute('num',$value);
               $ref->setAttribute('href',$href);
               $ref->setAttribute('target','_blank');
          
          
          
          
          
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_abon['debito'],2)));
               $tcol->setAttribute('align','right');          
               $style='';
//                $style.='background-color:'.$xbgcolor3.';';
               $tcol->setAttribute('style',$style);
          
          $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_abon['credito'],2)));
               $tcol->setAttribute('align','right');          
               $style='';
               $tcol->setAttribute('style',$style);
          
          
//           $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_abon['cant'],2)));
//                $tcol->setAttribute('align','right');          
//                $style='';
//                $tcol->setAttribute('style',$style);
          
          
          
          $xcair='';
          $xpor_rta='';
          $xpor_iva='';
          if(substr($aso_abon['docu'],0,1)=='R' and $aso_abon['saldo']!=0)
          {
               $xcair=$aso_abon['cair_hide'];
               $xpor_rta=number_format($aso_abon['porc_rta_hide'],2);
               $xpor_iva=number_format($aso_abon['porc_iva_hide'],2);
          }
          
          $tcol=$trow->appendChild($domg->createElement('td',$xcair));
               $tcol->setAttribute('align','center');          
          
          
//           $tcol=$trow->appendChild($domg->createElement('td',number_format($aso_abon['cant'],2)));
//                $tcol->setAttribute('align','right');          
//                $style='';
//                $tcol->setAttribute('style',$style);
          
          
          
          $tcol=$trow->appendChild($domg->createElement('td',$xpor_rta));
               $tcol->setAttribute('align','center');          
          $tcol=$trow->appendChild($domg->createElement('td',$xpor_iva));
               $tcol->setAttribute('align','center');          

          
          $xdeta='';
          if($aso_abon['fcobro_hide']>date('Y-m-d'))
          {
               $xdeta=' /F.Cobro :'.$aso_abon['fcobro_hide'].' => '.number_format($aso_abon['cheque_hide'],2);
          }
          
          
          
          $tcol=$trow->appendChild($domg->createElement('td',$aso_abon['detalle_t'].$xdeta));
//           $cant_bode+=$aso_abon['cant'];
//           $cost_bode+=$aso_abon['cant']*$aso_abon['puni'];
          
          $tot_debito+=$aso_abon['debito'];
          $tot_credito+=$aso_abon['credito'];
     }
     }
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td','TOTALES'));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',number_format($tot_debito,2)));
               $tcol->setAttribute('align','right');
          $tcol=$trowf->appendChild($domg->createElement('td',number_format($tot_credito,2)));
               $tcol->setAttribute('align','right');
//           $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));
          $tcol=$trowf->appendChild($domg->createElement('td',''));

          $xsaldo=$aso_info1['total']+$tot_debito-$tot_credito;
          $textoabon='SALDO : ';
          $textoabon.=number_format($xsaldo,2).' ';
//           $textoabon.=number_format($xsaldo,8).' ';
          $tcol=$trowf->appendChild($domg->createElement('td',$textoabon));
               $xstyle='white-space:nowrap;';

          if($xsaldo>(1/100)){$xstyle.='background-color:gold; color:black;';}
          elseif(abs($xsaldo)<=(1/100)){$xstyle.='background-color:green; color:white;';}
          elseif($xsaldo<(-1/100)){$xstyle.='background-color:darkred; color:white;';}
        //   echo '==='.$xsaldo;
     
//           if($xsaldo<1){removeNode($trowv);}
          if($xsaldo<1)
          {
//                echo '=========';
//                $xstyle='';
//                $xstyle.=color_cxcp($diasv);
//                $trowv->setAttribute('style',$xstyle);
          }

          $tcol->setAttribute('colspan','2');          
          $tcol->setAttribute('align','center');          
          $tcol->setAttribute('style',$xstyle);          
     
}

if(gettype($res_fdoc)=='object')
{
     $ttbl=$detai->appendChild($domg->createElement('div',''));
     msql_data_seek($res_fdoc);
     while($aso_fdoc=msql_fetch_assoc($res_fdoc))
     {
          $zdom=$domg; 
          $zele=$ttbl;
          $zobj=2;
          $zdocu=$docu;
          $zidnum=$idnum;
          $ziddet=$aso_fdoc['iddet'];
          $zcant=$aso_fdoc['cant'];
          $zdescri2=$aso_fdoc['detalle'];
          include('ele_filedocu.php');     
     }
     
}


if($modu=='rmed')
{
     $ciex=$detai->appendChild($domg->createElement('div',''));
          $span=$ciex->appendChild($domg->createElement('div',' '));
          $span=$ciex->appendChild($domg->createElement('span',' ⚕️ CIE-10 : '));
               $xstyle='font-weight:bold;';
               $span->setAttribute('style',$xstyle);
          $span=$ciex->appendChild($domg->createElement('span',$aso_info1['ciex'].' - '.$aso_info1['ciex_descri']));
               $xstyle='font-style:italic;';
               $span->setAttribute('style',$xstyle);
     
          if(!empty($aso_info1['ciex2']))
          {
          $span=$ciex->appendChild($domg->createElement('div',' '));
          $span=$ciex->appendChild($domg->createElement('span',' ⚕️ CIE-10 : '));
               $xstyle='font-weight:bold;';
               $span->setAttribute('style',$xstyle);
          $span=$ciex->appendChild($domg->createElement('span',$aso_info1['ciex2'].' - '.$aso_info1['cie2_descri']));
               $xstyle='font-style:italic;';
               $span->setAttribute('style',$xstyle);
          }
     
          if(!empty($aso_info1['ciex3']))
          {
          $span=$ciex->appendChild($domg->createElement('div',' '));
          $span=$ciex->appendChild($domg->createElement('span',' ⚕️ CIE-10 : '));
               $xstyle='font-weight:bold;';
               $span->setAttribute('style',$xstyle);
          $span=$ciex->appendChild($domg->createElement('span',$aso_info1['ciex3'].' - '.$aso_info1['cie3_descri']));
               $xstyle='font-style:italic;';
               $span->setAttribute('style',$xstyle);
          }
     
}


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

// Suponiendo que $dom es tu objeto DOMDocument
$buttons = $domg->getElementsByTagName('button');
// Recorremos la lista de elementos en orden inverso, para evitar problemas al eliminar
for ($idx = $buttons->length - 1; $idx >= 0; $idx--)
{
    $button = $buttons->item($idx);
    $button->parentNode->removeChild($button);
}
$html=$domg->saveHTML();

// if(empty($post))
// if(empty($mailsend))
if(empty($cont) and empty($bode) and empty($abon))
{file_put_contents($file_html,$html);}


// echo $_SESSION['server'];
// echo $_SESSION['domain'];
// echo $_SESSION['subdom'];





return; 
?>


