<?php 
session_start();
foreach($_GET as $campo => $valor){${$campo}=trim($valor);} 
foreach($_POST as $campo => $valor){${$campo}=trim($valor);} 

$user_codigo=$_SESSION['user_codigo'];
// $user_codigo=10;

$docu='CAR1';
$precio='pvp1';     



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

$ptitulo='CARRITO DE COMPRAS';
include('ele_title.php');



// $table=$dom->appendChild($dom->createElement("table"));
//      $table->setAttribute("width","100%");
//      $table->setAttribute("cellpadding","0");
//      $table->setAttribute("cellspacing","0");
//      $table->setAttribute("style","border-collapse:collapse;");
// //      $table->setAttribute("border","1");
// $trow=$table->appendChild($dom->createElement("tr"));
// $tcell=$trow->appendChild($dom->createElement("td"));



$pid='orden'; $pdefa=$orden;
$plabel='Ordenar X';
$ponchange='{orden_item();}';

$poptions='Codigo;Nombre(A-Z);Nombre(Z-A);Precio >;Precio <';
include('ele_select.php');


include('ele_break.php');
// echo $dom->saveXML();




// if(!empty($busca))
{
          
$sql_item ='select ';
$sql_item.='* ';
$sql_item.='from carr1 ';
$sql_item.='left join carr2 on idnum1=idnum2 ';
$sql_item.='left join item0 on item=item_codigo ';
$sql_item.='left join imgi0 on left(item,10)=left(imgi_item,10) ';
$sql_item.='left join lsub0 on item_lsub=lsub_codigo ';
$sql_item.='left join mrca0 on item_mrca=mrca_codigo ';
$sql_item.='left join clor0 on item_clor=clor_codigo ';
$sql_item.='left join tlla0 on item_tlla=tlla_codigo ';
$sql_item.='left join kldd0 on item_kldd=kldd_codigo ';
$sql_item.='where item_status not in ("I","X") ';
$sql_item.='and docu="'.$docu.'" ';
$sql_item.='and iuser='.$user_codigo.' ';
// $sql_item.='and item_codigo not like "99%" ';
     
// $xgroupby='group by idnum1,iddet ';
// $xgroupby='group by left(item,8) ';
$xgroupby='group by left(item,10) ';
if(mb_stristr('gmny.gnya',$cfg_empr)){$xgroupby='group by left(item,10) ';}     
    

                                 
// if(mb_stristr($orden,'Cod'))
{$xorderby='order by item_codigo ';}
if(mb_stristr($orden,'A-Z')){$xorderby='order by item_descri,item_codigo ';}
if(mb_stristr($orden,'Z-A')){$xorderby='order by item_descri desc,item_codigo ';}
if(mb_stristr($orden,'<')){$xorderby='order by item_puni,item_descri ';}
if(mb_stristr($orden,'>')){$xorderby='order by item_puni desc,item_descri ';}

$sql_item.=$xgroupby;
$sql_item.=$xorderby;
$res_item=msql_query($sql_item,$link_data);
     
// echo '<response>';     
// echo '<msgsys>';
// echo $sql_item;
// echo msql_error($link_data);
// echo '</msgsys>';     
// echo '</response>';     
     
while($aso_item=msql_fetch_assoc($res_item))
{
     
     $pid=$aso_item['item_codigo'];
     $ptabla='item';
     $pprecio='pvp1';
     $pcodigo=$aso_item['item_codigo'];
     $pobj=1;
     $pcarr=1;
     $pstockv=2;
     
     $pcodigo=$aso_item['item_rfer'];
     if(empty($pcodigo)){$pcodigo=$aso_item['item_mdlo'];}
     if(empty($pcodigo)){$pcodigo=$aso_item['item_codigo'];}
//      $pstockv=3;
//      if(mb_stristr('gnya.gmny',$cfg_empr) and !esMovil()){$pobj=4;}
//      if(mb_stristr('gnya.gmny',$cfg_empr)){$pstockv=0;}
     
//      if(mb_stristr('gnya.gmny',$cfg_empr) and !esMovil()){$pobj=4;}
     include('ele_image.php');
     
}
     
}

?>


<script>
     function orden_item()
     {
          get_para();
          var xhref='';
          xhref=xhref+'?scri=shop_cart2';
          if(document.getElementById("orden")){xorden=document.getElementById("orden").value;xhref=xhref+'&orden='+xorden;}
          location.href=xhref;          
     }
</script>

<script>
function save_carr(item,cant)
{
     var data=new FormData();
     data.append('script','save_carr');
     data.append('item',item);
     data.append('cant',cant);
     exe_ajax(data);
}

</script>



<script>document.title="<?php echo ucfirst($cfg_descri).' - Catálogo';?>"</script>
