<?php     
declare(strict_types=0);
$ztabla=trim(strtolower($ztabla));
$zcodigo=trim($zcodigo);
$zalign='left';
$tdstyle='';

$zmodu=$ztabla;
if(@mb_stristr('clie.prov.empl',$zmodu)){$ztabla='enti';}
if(@mb_stristr('inve.prec.teki',$zmodu)){$ztabla='item';}


if(empty($zobj)){$zobj=3;}
if(empty($zorient)){$zorient=0;}
if(empty($zstockv)){$zstockv=0;}
if(empty($zstock012)){$zstock012=0;}
if(empty($zfoto012)){$zfoto012=0;}
if(empty($zstock)){$zstock=0;}
if(empty($zid)){$zid=microtime()*1000000;}
if(empty($zsize)){$zsize=1;}
if(!empty($zsize) and $zsize!=1){$zstyle.='font-size:'.($zsize).'em;';}
if(!empty($zcolor)){$zstyle.='background:'.$zcolor.';';}
if($zobj==5 and getPlatform()=='Android'){$zobj=1;}
if($zobj==5 or $zorient==1){$zfixh=0;}

$xlimit=10;
if($zobj==1 or $zobj==5){$xlimit=1;}

if($zobj==2){$zstockv=0;}
if($zobj==2 and $zupld==1){$zstockv=1; $zprecio='';}

$ztablai='img'.substr($ztabla,0,1);

if($ztcell>=2){$zstyle.='width:100%;';}

if(!empty($zstockv))
{
     $stock=sal_item($zcodigo,$zbode);
     $zstock=$stock['uni_fin'];
//      echo '<br>**/*/'.$zstock;
}

$maxcarr=99999;
if($zstockv==2)
{
//      if(mb_stristr('gmny.gnya',$cfg_empr)){$maxcarr=999;}
//      if(mb_stristr('orel',$cfg_empr)){$maxcarr=9999;}
}

$ver_tallas=0;
if(mb_stristr('gmny.gnya',$cfg_empr)){$ver_tallas=2;}
// if(mb_stristr('gmny.gnya',$cfg_empr)){$solo_ctlg=1;}

// count(item_tlla) as item_ctalla
if(!empty($ztabla))
{
   $sql_master ='select * ';
   $sql_master.='from '.$ztabla.'0 ';
//    $sql_master.='left join '.$ztablai.'0 on '.$ztabla.'_codigo ='.$ztablai.'_'.$ztabla.' ';
     if($ztabla=='enti')
     {
          $sql_master.='left join zsub0 on '.$ztabla.'_zsub=zsub_codigo ';
          $sql_master.='left join tpro0 on '.$ztabla.'_tpro=tpro_codigo ';
     }
     
     if($ztabla=='item')
     {
          $sql_master.='left join lsub0 on '.$ztabla.'_lsub=lsub_codigo ';
          $sql_master.='left join mrca0 on '.$ztabla.'_mrca=mrca_codigo ';
          $sql_master.='left join tlla0 on '.$ztabla.'_tlla=tlla_codigo ';
          $sql_master.='left join clor0 on '.$ztabla.'_clor=clor_codigo ';
          $sql_master.='left join kldd0 on '.$ztabla.'_kldd=kldd_codigo ';
     }
     
//    $sql_master.='where length(trim('.$ztabla.'_codigo))>=6 ';
//    $sql_master.='and '.$ztabla.'_codigo like "'.$zcodigo.'%" ';
//    $sql_master.='and '.$ztabla.'_status not in ("O","X") ';
//    $sql_master.='and '.$ztablai.'_status not in ("O","X") ';
   $sql_master.='where trim('.$ztabla.'_codigo) like "'.$zcodigo.'" ';
//    if($solo_foto==1)
//    {$sql_master.='and '.$ztablai.'_file is not null ';}
//    $sql_master.='order by '.$ztablai.'_defa desc,'.$ztablai.'_idate desc ,'.$ztablai.'_codigo ';
//    $sql_master.='limit '.$xlimit;
   $res_master=msql_query($sql_master,$link_data);
//      echo $sql_master;
     
     $calc_master=calc_maes($ztabla);
     if(!empty($calc_master))
     {$sql_master=str_replace(' from ',','.$calc_master.' from ',$sql_master);}
     
     
}

// if(msql_num_rows($res_master)==0)
// {
//      $sql_master=str_replace('and '.$ztablai.'_status not in ("O","X") ','',$sql_master);
//      $res_master=msql_query($sql_master,$link_data);
// }

if(msql_num_rows($res_master)!=0)
{
     msql_data_seek($res_master,0);
     $asoc=msql_fetch_assoc($res_master);

     $img_codigo=trim($asoc[$ztabla.'_mdlo']);
     if(strlen($img_codigo)<6){$img_codigo=$asoc[$ztabla.'_rfer'];}
     if(strlen($img_codigo)<6){$img_codigo=$asoc[$ztabla.'_codigo'];}
     if(strlen($img_codigo)<6){$img_codigo=$zcodigo;}

     if(mb_stristr('orel.amay',$cfg_empr))
     {$img_codigo=trim($asoc[$ztabla.'_codigov']);}

     if(mb_stristr('gmny',$cfg_empr))
     {$img_codigo=trim($asoc[$ztabla.'_mdlo']);}

     $img_rfer=trim($asoc[$ztabla.'_rfer']);
     if(strlen($img_rfer)<6){$img_rfer=$asoc[$ztabla.'_codigo'];}

     $img_descri=trim($asoc[$ztabla.'_descri']);
     
     $maes_codigo=trim($asoc[$ztabla.'_codigo']);
     $maes_descri=trim($asoc[$ztabla.'_descri']);
     
     
     $zsub_descri=trim($asoc['zsub_descri']);
     $tpro_descri=trim($asoc['tpro_descri']);
     
     $lsub_descri=trim($asoc['lsub_descri']);
     $mrca_descri=trim($asoc['mrca_descri']);
     $tlla_descri=trim($asoc['tlla_descri']);
     $kldd_descri=trim($asoc['kldd_descri']);
     $item_composi=trim($asoc['item_composi']);
     $item_umdd=trim($asoc['item_umdd']);
     $item_duni=$asoc['item_duni'];
     $item_dpre=trim($asoc['item_dpre']);
     $clor_descri=trim($asoc['clor_descri']);
     $clor_hexa=trim($asoc['clor_hexa']);

     $img_descri=str_replace($mrca_descri,'',$img_descri);     

     if($item_dpre<2 or mb_stristr($zprecio,'pvp')){$item_dpre=2;}     
     if(mb_stristr('imcp',$cfg_empr)){$item_dpre=4;}

//      echo '*/*/*/'.$zprecio;
     
     if(!empty($zprecio))
     {
          $zprecio=strtolower($zprecio);
          $xprecio=$asoc['item_'.$zprecio];
     }

     if($ztabla=='item' and $ver_tallas>0)
     {
          $sql_tllas ='select * ';
          $sql_tllas.='from item0 left join tlla0 on item_tlla=tlla_codigo ';
          $sql_tllas.='where item_status not in("O","X") ';
          $sql_tllas.='and length(trim(item_codigo))>=6 ';
          $sql_tllas.='and item_codigo like "'.$img_rfer.'%" ';
     //      $sql_tllas.='and tlla_codigo*1>0 ';
          if($solo_ctlg==1)
          {$sql_tllas.='and item_ctlg=1 ';}
          $sql_tllas.='order by tlla_codigo ';
          $sql_tllas.='';
          $sql_tllas.='';
          $res_tllas=msql_query($sql_tllas,$link_data);
          $ctllas=msql_num_rows($res_tllas);

          $tlla_descri2='';

          if(empty($user_codigo))
          {
               msql_data_seek($res_tllas,0);
               while($aso_tllas=msql_fetch_assoc($res_tllas))
               {
                    if((int)$aso_tllas['item_tlla']>0 or ((int)$aso_tllas['item_tlla']==0 and $ctllas==1))
                    {$tlla_descri2.=$aso_tllas['tlla_descri'].' ';}
               }
          }
     }     


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

     if(!empty($zdom)){$domd0=$zdom;}
     if(!empty($zele)){$elem0=$zele;}

     if($ztcell>=2)
     {
          $element=$elem0->appendChild($domd0->createElement("td"));
               if(!empty($zid))
               {$element->setAttribute("id",$zid);}
               $element->setAttribute("valign","top");
     }
     else
     {
          $spandiv='div';

          $element=$elem0->appendChild($domd0->createElement($spandiv,""));
//                if(empty($zdom))
//                {
//                     $zstyle.="float:".$zalign.";";
//                     $element->setAttribute("style",$zstyle);
//                }
//                if(empty($zdom))
//                {$element->setAttribute("style","float:".$zalign.";margin-left:".$zsize*(0.5)."em;margin-right:".$zsize*(0.5)."em;margin-bottom:".$zsize*(0)."em;");}

               $element->setAttribute("style","clear:both;");
          
               if(!empty($zid))
               {$element->setAttribute("id",$zid);}
               $element->setAttribute("img-span",'');
     }

     if(!empty($zhide)){$element->setAttribute("hide","");}

     $trheight="";
     $tbheight=0;
//      if(mb_stristr('orel',$cfg_empr))
//      {$tbheight=35;}
//      if(mb_stristr('gmny.gnya',$cfg_empr))
//      {$tbheight=40;}
     if($zobj==5){$tbheight=0;}     

     $cfotos=0;
     msql_data_seek($res_master,0);

     while($asoc=msql_fetch_assoc($res_master))
     {if($asoc[$ztablai.'_status']!='X'){$cfotos++;}}

     if($cfotos==0){{$tbheight=15;}}     

          $table=$element->appendChild($domd0->createElement("div",""));
               $table->setAttribute("tab-tab","");
     
          $trow=$table->appendChild($domd0->createElement("div",""));
               $trow->setAttribute("tab-row","");
     
          $tcell=$trow->appendChild($domd0->createElement("div",""));
               $tcell->setAttribute("tab-col","");
               $span=$tcell->appendChild($domd0->createElement("span",$maes_codigo));
               
          $tcell=$trow->appendChild($domd0->createElement("div",""));
               $tcell->setAttribute("tab-col","");
               $span=$tcell->appendChild($domd0->createElement("span",htmlspecialchars($maes_descri)));
     
          $tcell=$trow->appendChild($domd0->createElement("div",""));
               $tcell->setAttribute("tab-col","");
               $span=$tcell->appendChild($domd0->createElement("span",$zsub_descri));
     
     
     
          $table=$element->appendChild($domd0->createElement("table",""));
     //           $table->setAttribute("border",'1');
               $table->setAttribute("name",$zcodigo);
               $table->setAttribute("cellpadding",'0');
     //           $table->setAttribute("img-table",'');
               if($zobj==5)
               {$table->setAttribute("img-list",'');}
               else
               {$table->setAttribute("img-table",'');}

               $table->setAttribute("class",'img-table');
               if(!empty($tbheight))
               {$table->setAttribute("style","min-height:".$tbheight."em;");}

          $trow=$table->appendChild($domd0->createElement("tr",""));

          $tcell=$trow->appendChild($domd0->createElement("td",""));
               $tcell->setAttribute("colspan",'99');
               $tcell->setAttribute("style","height:2em;");

          // header
          msql_data_seek($res_master,0);
          $asoc=msql_fetch_assoc($res_master);
          $hr=$tcell->appendChild($domd0->createElement("hr",""));
               $hr->setAttribute("color",$empr0['empr_color1']);
               $hr->setAttribute("size","5");
               $hr->setAttribute("noshade","");

//           $onclick='{window.location.href="?scri=info_maes3&buscar='.$zcodigo.'&format='.$format.'"}';
          $onclick='{window.location.href="?scri=info_maes3&modu='.$ztabla.'&buscar='.$zcodigo.'&format='.$format.'"}';
          if($zobj!=2)
          {
               if($zobj!=4 and $zobj!=5)
               {
                    $span=$tcell->appendChild($domd0->createElement("a",'CODIGO : '.$img_codigo));
                              $span->setAttribute("name",'codigo');
                              $span->setAttribute("bold",'');
                              $span->setAttribute("onclick",$onclick);
                    $div=$tcell->appendChild($domd0->createElement("div",$lsub_descri));
                         $div->setAttribute("size80",'');
                         $div->setAttribute("bold",'');
               }

               $trow=$table->appendChild($domd0->createElement("tr",""));
               if($cfotos==0)
               {$trow->setAttribute("style",'height:5em;');}
               if($cfotos>=1)
               {$trow->setAttribute("style",$trheight);}
               
               if($cfotos>1)
               {
                    $tcell=$trow->appendChild($domd0->createElement("td",""));
                         $tcell->setAttribute("width",'10%');
                         $tcell->setAttribute("style",$trheight);          
               }
          }

          // detail
          if($zobj==2 and $zupld==1)
          {
               //input file
               $trow=$table->appendChild($domd0->createElement("tr",""));
               $tcell=$trow->appendChild($domd0->createElement("td",""));
               $tcell->setAttribute("style","min-width:24em;");
               $tcell->setAttribute("colspan","2");
               
               $div=$tcell->appendChild($domd0->createElement("div","CODIGO : ".$img_codigo));
               $div->setAttribute("bold","");
//                $div->setAttribute("onclick",$onclick);
               $div->setAttribute("style","color:".$empr0['empr_color1']);
               
               $div=$tcell->appendChild($domd0->createElement("div",' '.$lsub_descri));
                    $div->setAttribute("bold",'');
//                     $div->setAttribute("style",'min-height:'.intval(4*$zsize).'em;');

               
               $input=$div->appendChild($domd0->createElement("input",""));
               $input->setAttribute("id","if".$zcodigo);
               $input->setAttribute("type","file");
               $input->setAttribute("hide","");
               $input->setAttribute("multiple","");
               $input->setAttribute("accept","image/*");
               $input->setAttribute("onchange","{document.getElementById('sf".$zcodigo."').value=this.files.length+' archivo(s)';}");
               
               $div=$tcell->appendChild($domd0->createElement("span",""));
                    $div->setAttribute("rel-left","");
               $label=$div->appendChild($domd0->createElement("label","Seleccionar Fotos : "));
                    $label->setAttribute("for","if".$zcodigo);
               
               $div=$tcell->appendChild($domd0->createElement("span",""));                         
                    $div->setAttribute("rel-left","");
               $input=$div->appendChild($domd0->createElement("input",""));     
                    $input->setAttribute("id","sf".$zcodigo);
                    $input->setAttribute("readonly","");
                    $input->setAttribute("sel-file","");
//                     $input->setAttribute("for","if".$zcodigo);
                    $input->setAttribute("onclick","{document.getElementById('if".$zcodigo."').click();}");

               $div=$tcell->appendChild($domd0->createElement("span",""));                         
                    $div->setAttribute("rel-left","");
//                $button=$div->appendChild($domd0->createElement("button","▲"));                         
               $button=$div->appendChild($domd0->createElement("button","Subir Fotos"));                         
                    $button->setAttribute("btn-file","");
//                     $button->setAttribute("title","Subir Fotos");
                    $button->setAttribute("zoom80","");
                    $button->setAttribute("onclick","upld_master('".$ztablai."',".$zcodigo.",'if".$zcodigo."')");
//                $button->setAttribute("tabindex","-1");

               
               $trow=$table->appendChild($domd0->createElement("tr",""));
//                $tcell=$trow->appendChild($domd0->createElement("td",""));
               
               
//                if($cfotos==0)
               if(empty($asoc[$ztablai.'_file']) or empty($cfotos))
               {$tcell=$trow->appendChild($domd0->createElement("th","Sin Foto"));}
               
               
               
          }
               
          if($zobj==2 and $cfotos>=1)
          {
               if($zorient==0)
               {$trow=$table->appendChild($domd0->createElement("tr",""));}

               msql_data_seek($res_master,0);
               while($asoc=msql_fetch_assoc($res_master))
               {
                    if($zorient==1)
                    {$trow=$table->appendChild($domd0->createElement("tr",""));}
                    $tcell=$trow->appendChild($domd0->createElement("td",""));
                         $tcell->setAttribute("style",'width:auto');
                         $tcell->setAttribute("id",'td'.$asoc[$ztablai.'_codigo']);
//                          if($asoc[$ztablai.'_status']=='X')
                         if(empty($asoc[$ztablai.'_file']))
                         {$tcell->setAttribute("hide"," ");}
                    
                    if($zupld==1)
                    {
                         $div=$tcell->appendChild($domd0->createElement("div",""));                         
                         $div->setAttribute("style","border:1px;border-style:solid;border-color:black;background-color:".$empr0['empr_color2'].";");
                         $div->setAttribute("onclick","document.getElementById('rd".$asoc[$ztablai.'_codigo']."').click();");
                         $div->setAttribute("title","Fijar Principal");
                         
                         $radio=$div->appendChild($domd0->createElement("input",""));                         
                         $radio->setAttribute("type",'radio');
                         $radio->setAttribute("name",$zcodigo);
                         $radio->setAttribute("id","rd".$asoc[$ztablai.'_codigo']);
                         $radio->setAttribute("valign-t","");
                         if($asoc[$ztablai.'_defa']==1)
                         {$radio->setAttribute("checked","");}
                         $radio->setAttribute("onclick","defa_master('".$ztablai."',".$asoc[$ztablai.'_codigo'].")");
                         $radio->setAttribute("tabindex","-1");
                         
//                          echo '<br>*/*/'.$asoc[$ztablai.'_defa'];
                    }
                    
                    $div=$tcell->appendChild($domd0->createElement("div",""));                         
                    $image=$div->appendChild($domd0->createElement("img",""));
                         $image->setAttribute("id",'img_'.$asoc[$ztablai.'_codigo']);
//                          $image->setAttribute("src",'../'.$cfg_empr.'/'.$ztablai.'/'.$asoc[$ztablai.'_file']);
                         $image->setAttribute("src",'//'.$file_server.'/'.$cfg_empr.'/'.$ztablai.'/'.$asoc[$ztablai.'_file']);
                    
                         $image->setAttribute("style",'width:auto');
                         if($zorient==0)
                         {
//                               $image->setAttribute("rel-left",'');
                              $image->setAttribute("style",'max-width:'.intval(12*$zsize).'em;' );
                         }
                    
                    if($zupld==1)
                    {
                         $div=$tcell->appendChild($domd0->createElement("div",""));                         
                         $button=$div->appendChild($domd0->createElement("button","X"));                         
                         $button->setAttribute("tabindex","-1");
                         $button->setAttribute("btn-elim","");
                         $button->setAttribute("onclick","dele_master('".$ztablai."',".$asoc[$ztablai.'_codigo'].")");
                    }
                    
                    
               }
          }

     
          if($zobj==2 and $zupld==1)
          {
//                //input file
               $trow=$table->appendChild($domd0->createElement("tr",""));
               $tcell=$trow->appendChild($domd0->createElement("td",""));
               $tcell->setAttribute("colspan",3);
//                $div=$tcell->appendChild($domd0->createElement("div",$img_descri));
//                     if(strlen($img_descri)>40){$div->setAttribute("size80",'');}
//                     if(strlen($img_descri)>60){$div->setAttribute("size60",'');}
          }
               
     
     
          if($zobj>2 and $cfotos>1)
          {    
               msql_data_seek($res_master,0);
               while($asoc=msql_fetch_assoc($res_master))
               {
                    $div=$tcell->appendChild($domd0->createElement("div",""));
                    $image=$div->appendChild($domd0->createElement("img",""));
//                          $image->setAttribute("src",'../'.$cfg_empr.'/'.$ztablai.'/'.$asoc[$ztablai.'_file']);
                         $image->setAttribute("src",'//'.$file_server.'/'.$cfg_empr.'/'.$ztablai.'/'.$asoc[$ztablai.'_file']);
                    
                         $image->setAttribute("onmouseover","{document.getElementById('".$zcodigo."_img').src=this.src;}");
                         $image->setAttribute("style",'max-width:'.intval(4*$zsize).'em');
//                          if($asoc[$ztablai.'_status']=='X')
//                          {$tcell->setAttribute("hide"," ");}
                         if(empty($asoc[$ztablai.'_file']))
                         {$tcell->setAttribute("hide"," ");}
               }
          }

          // main
          if($zobj!=2)
          {
               msql_data_seek($res_master,0);
               $asoc=msql_fetch_assoc($res_master);
               $img_file=$asoc[$ztablai.'_file'];
               $img_stat=$asoc[$ztablai.'_status'];

//                if(empty($img_file))
               if(empty($img_file) or $img_stat=='X')
               {
                    $tcell=$trow->appendChild($domd0->createElement("td"," "));
                    $div=$tcell->appendChild($domd0->createElement("div"," "));
                         $div->setAttribute("style","height:1em;");
                    $div=$tcell->appendChild($domd0->createElement("div","Sin Foto"));
                         $div->setAttribute("style","height:2em;");
                         if($zobj==4)
                         {$div->setAttribute("style","height:2em; width:21em;");}
                    $div=$tcell->appendChild($domd0->createElement("div"," "));
                         $div->setAttribute("style","height:1em;");
               }
               else
               {
                    $tcell=$trow->appendChild($domd0->createElement("td",""));
                         if($cfotos>1)
                         {$tdstyle.='min-width:'.intval(17*$zsize).'em;';}
                         else
                         {$tdstyle.='min-width:'.intval(21*$zsize).'em;';}
                         if($zobj==5)
                         {$tdstyle='width:'.intval(7*$zsize).'em; ';}
                    
                         if($zfixh==1)
                         {$trow->setAttribute("style","height:".intval(28*$zsize)."em;");}
                    
                         $tcell->setAttribute("style",$tdstyle);

                    $image=$tcell->appendChild($domd0->createElement("img",""));   
                         $image->setAttribute("id",$zcodigo.'_img');
                         $image->setAttribute("ondblclick","{_clickimg('".$img_rfer."');}");
//                          $image->setAttribute("src",'../'.$cfg_empr.'/'.$ztablai.'/'.$img_file);
                         $image->setAttribute("src",'//'.$file_server.'/'.$cfg_empr.'/'.$ztablai.'/'.$img_file);
                         $istyle='width:'.intval(21*$zsize).'em; ';
//                          if($zfixh==1)
//                          {$istyle='width:auto;max-height:'.intval(21*$zsize).'em; ';}
                         if($zobj==5)
                         {$istyle='width:'.intval(4*$zsize).'em; ';}
                         $image->setAttribute("style",$istyle);
               }
          }

          // foot
          msql_data_seek($res_master,0);
          $asoc=msql_fetch_assoc($res_master);

          if($zobj==4 or $zobj==5)
          {$tcell=$trow->appendChild($domd0->createElement("td",""));}
     
               if($cfotos>1)
               {$tdstyle='min-width:'.intval(17*$zsize).'em;';}
               else
               {$tdstyle='min-width:'.intval(21*$zsize).'em;';}
     
               if($zobj==5)
               {$tdstyle='width:'.intval(21*$zsize).'em;';}

//                if($zobj==2 and $zupld==1)
               if($zobj==2 and $zorient==0)
               {$tdstyle='width:auto';}

               $tcell->setAttribute("style",$tdstyle);
     
//           if($zobj!=2)
          {
               if($zobj==4 or $zobj==5)
               {
                    $span=$tcell->appendChild($domd0->createElement("a",'CODIGO : '.$img_codigo));
                              $span->setAttribute("name",'codigo');
                              $span->setAttribute("bold",'');
                              $span->setAttribute("onclick",$onclick);

                    $div=$tcell->appendChild($domd0->createElement("div",' '.$lsub_descri));
                         $div->setAttribute("bold",'');
                         $div->setAttribute("style",'min-height:'.intval(4*$zsize).'em;');
               }

               if($zobj==5)
               {
                    $tcell=$trow->appendChild($domd0->createElement("td",""));
                    $tdstyle='width:'.intval(21*$zsize).'em; ';
                    $tcell->setAttribute("style",$tdstyle);
               }

               //DESCRIPCION
               if($zobj!=2 or $zupld==1)
               {

               $div=$tcell->appendChild($domd0->createElement("div",$mrca_descri));
                    $div->setAttribute("bold","");
                    $div->setAttribute("size80","");
               $div=$tcell->appendChild($domd0->createElement("div",htmlspecialchars($img_descri)));
                    $div->setAttribute("id",$zid.'_desc');
               if($zobj==4)
               {$div->setAttribute("style",'min-width:'.intval(21*$zsize).'em;'.'min-height:'.intval(4*$zsize).'em;');}
               else
               {
                    if(strlen($img_descri)>40){$div->setAttribute("size80",'');}
                    if(strlen($img_descri)>60){$div->setAttribute("size60",'');}
               }

               // ADICIONALES
               if(!empty($kldd_descri))
               {
                    $div=$tcell->appendChild($domd0->createElement("div",''.$kldd_descri.' /'.$item_composi));
                         if($zobj==4)
                         {$div->setAttribute("style",'min-height:'.intval(2*$zsize).'em;');}
                         else
                         {$div->setAttribute("size80",'');}
                         $div->setAttribute("italic",'');
               }

               if(strlen($clor_descri)>=3)
               {
                    $xclor='COLOR : '.$clor_descri;
                    if($zsize<1){$xclor=$clor_descri;  }
                    $div=$tcell->appendChild($domd0->createElement("div",$xclor));
                    $div->setAttribute("size80",'');
                    if(!empty($clor_hexa))
                    {
                         $div->setAttribute("bold",'');
                         $div->setAttribute("style",'border:4px solid;border-color:'.$clor_hexa);
                    }                         
               }

               if(!empty($tlla_descri2))
               {
                    $div=$tcell->appendChild($domd0->createElement("div",' '.$tlla_descri2));
                    if($zobj==4)
                    {$div->setAttribute("style",'min-height:'.intval(2*$zsize).'em;');}
                    else
                    {$div->setAttribute("size80",'');}
               }

//                     echo '*/*/*'.$zstockv;
               if(!empty($zstockv))
               {
                    $alertmsg='';
                    $sstyle='';
                    $maxcarr=(int)$zstock;
                    if($zstock>0)
                    {
                         if($zstockv==1){$valstock='STOCK : '.number_format($zstock,$item_duni).' '.$item_umdd;}
                         if($zstockv>=2){$valstock='DISPONIBLE';}
                         if($zstockv==3){$alertmsg="{_clickdispon('".$zid."_desc','".number_format($zstock,$item_duni).' '.$item_umdd."');}";}
                    }
                    else{$valstock='NO DISPONIBLE'; $sstyle='color:darkred;';}

                    $div=$tcell->appendChild($domd0->createElement("div",$valstock));
                         if($zobj==4)
                         {$div->setAttribute("style",'min-height:'.intval(3*$zsize).'em;');}
                         else
                         {$div->setAttribute("size80",'');}
                         $div->setAttribute("bold",'');
                         if(!empty($sstyle))
                         {$div->setAttribute("style",$sstyle);}
                         if(!empty($alertmsg))
                         {
                              $div->setAttribute("unselect",'');
                              $div->setAttribute("onclick",$alertmsg);
                         }
               }

               if(!empty($xprecio))
               {
                    $lblprecio='PVP : $ '.number_format($xprecio,$item_dpre);;
                    if(mb_stristr($zprecio,'puni')){$lblprecio='P.Uni : $ '.number_format($xprecio,$item_dpre).' +imp.';}
                    $div=$tcell->appendChild($domd0->createElement("div",$lblprecio))     ;
                         if($zobj==4)
                         {$div->setAttribute("style",'min-height:'.intval(3*$zsize).'em;');}
                         else
                         {$div->setAttribute("size80",'');}
                         $div->setAttribute("bold",'');
               }

               if(!empty($zcarr) and !empty($user_codigo))
               {
                    if($zobj==5)
                    {
                         $tcell=$trow->appendChild($domd0->createElement("td",""));
                         $tdstyle='width:'.intval(21*$zsize).'em; ';
                         $tcell->setAttribute("style",$tdstyle);
                    }

                    if($ver_tallas==0)
                    {
                         $sql_carr ='select cant from carr1 ';
                         $sql_carr.='left join carr2 on idnum1=idnum2 ';
                         $sql_carr.='left join item0 on item=item_codigo ';
                         $sql_carr.='where iuser="'.$user_codigo.'" ';
                         $sql_carr.='and item like "'.$zcodigo.'%"';
                         $res_carr=msql_query($sql_carr,$link_data);
                         $cantcarr=msql_result($res_carr,0,'cant');
                         $idcantcarr=$zid.'_cant';

                         if(empty($item_umdd) or substr($item_umdd,0,2)=='UN')
                         {$cantcarr=(int)$cantcarr;}

          //                if($maxcarr>0)
                         {
                         $divt=$tcell->appendChild($domd0->createElement("div"," "));
//                               $divt->setAttribute("autocomplete","off");
//                               $divt->setAttribute("flex-center","");
                                                            
//                          $div=$divt->appendChild($domd0->createElement("label","Carrito : "));
//                               $div->setAttribute("for",$idcantcarr);
//                               $div->setAttribute("valign-m","");
                              
                         $button=$divt->appendChild($domd0->createElement("button","-"));
                              $button->setAttribute("onclick","$(this).next()[0].stepDown();$(this).next()[0].oninput();");
                              $button->setAttribute("valign-t","");
                              $button->setAttribute("style","width:3em;height:2em;");
                              
                         $div=$divt->appendChild($domd0->createElement("input",""));
                              $div->setAttribute("id",$idcantcarr);
                              $div->setAttribute("type","number");
                              $div->setAttribute("value",$cantcarr);
                              $div->setAttribute("cantcarr","");
                              $div->setAttribute("min","0");
                              $div->setAttribute("max",$maxcarr);
                              $div->setAttribute("oninput","{save_carr('".$zcodigo."',this.value);}");
                              $div->setAttribute("autocomplete","off");
                              
                         $button=$divt->appendChild($domd0->createElement("button","+"));
                              $button->setAttribute("onclick","$(this).prev()[0].stepUp();$(this).prev()[0].oninput();");
                              $button->setAttribute("valign-t","");
                              $button->setAttribute("style","width:3em;height:2em;");
                              
                         }

                    }

                    if($ver_tallas==2)
                    {
                         msql_data_seek($res_tllas,0); 
                         while($aso_tllas=msql_fetch_assoc($res_tllas))
                         {
                              if((int)$aso_tllas['item_tlla']>0 or ((int)$aso_tllas['item_tlla']==0 and $ctllas==1) )
                              {
                              $sql_carr ='select cant from carr1 ';
                              $sql_carr.='left join carr2 on idnum1=idnum2 ';
                              $sql_carr.='left join item0 on item=item_codigo ';
                              $sql_carr.='where iuser="'.$user_codigo.'" ';
                              $sql_carr.='and item like "'.$aso_tllas['item_codigo'].'%"';
                              $res_carr=msql_query($sql_carr,$link_data);
                              $cantcarr=msql_result($res_carr,0,'cant');
                              $idcantcarr=$zid.'_cant';

                              if(empty($item_umdd) or substr($item_umdd,0,2)=='UN')
                              {$cantcarr=(int)$cantcarr;}

//                               $span=$tcell->appendChild($domd0->createElement("span"," "));
//                               $span->setAttribute("style","float:left;width:1em;height:1em;display:block;");

// margin-left:".$zsize*(0.5)."em;margin-right:".$zsize*(0.5)."em;margin-bottom:".$zsize*(0.0)."em;                                   
                                   
                              $divt=$tcell->appendChild($domd0->createElement("div"," "));
//                                    $divt->setAttribute("style","position:relative;float:left;");
                                   $divt->setAttribute("style","position:relative;float:left;margin-left:".$zsize*(0.5)."em;margin-right:".$zsize*(0.5)."em;margin-bottom:".$zsize*(0.0)."em;");


                              $div=$divt->appendChild($domd0->createElement("label",$aso_tllas['tlla_descri']));
                                   $div->setAttribute("for",$idcantcarr);
                                   
                              $button=$divt->appendChild($domd0->createElement("button","+"));
                                   $button->setAttribute("onclick","$(this).next()[0].stepUp();$(this).next()[0].oninput();");
                                   $button->setAttribute("valign-t","");
                                   $button->setAttribute("style","width:4em;height:2em;display:block;color:grey;");
                              
                                   
                              $div=$divt->appendChild($domd0->createElement("input",""));
                                   $div->setAttribute("cantcarr","");
                                   $div->setAttribute("id",$idcantcarr);
                                   $div->setAttribute("type","number");
                                   $div->setAttribute("min","0");
                                   $div->setAttribute("max","99");
                                   $div->setAttribute("value",$cantcarr);
                                   $div->setAttribute("oninput","{save_carr('".$aso_tllas['item_codigo']."',this.value);}");
                                   $div->setAttribute("style","width:3em;margin-bottom:0em;");
                                   $div->setAttribute("autocomplete","off");
                                   
                              $button=$divt->appendChild($domd0->createElement("button","-"));
                                   $button->setAttribute("onclick","$(this).prev()[0].stepDown();$(this).prev()[0].oninput();");
                                   $button->setAttribute("valign-t","");
                                   $button->setAttribute("style","width:4em;height:2em;display:block;color:grey;");
                              
                                   
                              }

                         }
                    }

                    if($ztotpvp>0)
                    {
                         $div=$tcell->appendChild($domd0->createElement("div",'Sub-Tot : $ '.number_format($ztotpvp,2)));
                         $div->setAttribute("bold"," ");
                         $div->setAttribute("style","clear:both;");
                         $div->setAttribute("onclick","{location.reload();}");
                    }

               }

                    
               }

          }

          $trow=$table->appendChild($domd0->createElement("tr",""));
          $tcell=$trow->appendChild($domd0->createElement("td",""));
               $tcell->setAttribute("colspan",'99');
     //           $tcell->setAttribute("style",'height:1em;');
          $hr=$trow->appendChild($domd0->createElement("hr",""));
               $hr->setAttribute("size","4");
               $hr->setAttribute("noshade","");
               if($zobj==5)
               {$hr->setAttribute("hide"," ");}

          if(empty($zdom))
          {
               if($zxml==1){$zxml=$domd0->saveXML();}
               else{echo $domd0->saveXML();}
          }     

}

include ('ele_reset.php');

?>



