<?php session_start();
require('../cfg/res.php');
require('../cfg/cfg.php');
include('php_gene1.php');
include('php_session.php');

$sql_item='select * from item00 where item_codigo="'.$_POST['codigo'].'"';
$codigo=$_POST['codigo'];
if(empty($_POST['codigo'])){$codigo=$_SESSION['user_vcrx_id'];}
if ( !mb_stristr('admi.sist.supe',strtolower($_SESSION['user_vcrx_tipo'])) ) {$codigo=$_SESSION['user_vcrx_id'];}

$sql_item='select *from item00 where item_codigo="'.$codigo.'"';

// console.log( $sql_item);
$res_item=mysql_query($sql_item,$link_vcrx);
	$descri='';
	$descri2='';
	$lsub='';
	$mrca='';
	$modelo='';
	$numpart='';
	$ean='';
	$codigov='';
	$lado='';
	$umdd='';
	$clor='';
	$tlla='';
	$kldd='';
	$rend='';
	$cair='';
	$caird='';
	$ice='';
	$iva='';
	$imgibp='';


get_ean0($codigo);


if(mysql_num_rows($res_item)!=0){	
	$descri=mysql_result($res_item,0,'item_descri');
	$descri2=mysql_result($res_item,0,'item_descri2');
	$lsub=mysql_result($res_item,0,'item_lsub');
	$mrca=mysql_result($res_item,0,'item_mrca');
	$modelo=mysql_result($res_item,0,'item_modelo');
	$numpart=mysql_result($res_item,0,'item_numpart');
	$ean=mysql_result($res_item,0,'item_ean');
	$codigov=mysql_result($res_item,0,'item_codigov');
	$lado=mysql_result($res_item,0,'item_lado');
	$umdd=mysql_result($res_item,0,'item_umdd');
	$clor=mysql_result($res_item,0,'item_clor');
	$tlla=mysql_result($res_item,0,'item_tlla');
	$kldd=mysql_result($res_item,0,'item_kldd');
	$rend=mysql_result($res_item,0,'item_rend');
	$cair=mysql_result($res_item,0,'item_cair');
	$caird=mysql_result($res_item,0,'cair_descri');
	$ice=mysql_result($res_item,0,'item_ice');
	$iva=mysql_result($res_item,0,'item_iva');
	$irbp=mysql_result($res_item,0,'item_irbp');
	$dcto=mysql_result($res_item,0,'item_dcto');
	$puni=mysql_result($res_item,0,'item_puni');
	$cost=mysql_result($res_item,0,'item_cost');
	$ctavtas=mysql_result($res_item,0,'item_ctavtas');
}

echo '<input type="hidden" id="hdescri" value="'.$descri.'"/>';
echo '<input type="hidden" id="hdescri2" value="'.$descri2.'"/>';
echo '<input type="hidden" id="hlsub" value="'.$lsub.'"/>';
echo '<input type="hidden" id="hmrca" value="'.$mrca.'"/>';
echo '<input type="hidden" id="hmodelo" value="'.$modelo.'"/>';
echo '<input type="hidden" id="hnumpart" value="'.$numpart.'"/>';
echo '<input type="hidden" id="hean" value="'.$ean.'"/>';
echo '<input type="hidden" id="hcodigov" value="'.$codigov.'"/>';
echo '<input type="hidden" id="hlado" value="'.$lado.'"/>';
echo '<input type="hidden" id="humdd" value="'.$umdd.'"/>';
echo '<input type="hidden" id="hclor" value="'.$clor.'"/>';
echo '<input type="hidden" id="htlla" value="'.$tlla.'"/>';
echo '<input type="hidden" id="hkldd" value="'.$kldd.'"/>';
echo '<input type="hidden" id="hrend" value="'.$rend.'"/>';
echo '<input type="hidden" id="hcair" value="'.$cair.'"/>';
echo '<input type="hidden" id="hcaird" value="'.$caird.'"/>';
echo '<input type="hidden" id="hice" value="'.$ice.'"/>';
echo '<input type="hidden" id="hiva" value="'.$iva.'"/>';
echo '<input type="hidden" id="hirbp" value="'.$irbp.'"/>';
echo '<input type="hidden" id="hpuni" value="'.$puni.'"/>';
echo '<input type="hidden" id="hcost" value="'.$cost.'"/>';
echo '<input type="hidden" id="hdcto" value="'.$dcto.'"/>';
echo '<input type="hidden" id="hctavtas" value="'.$ctavtas.'"/>';



$sql_imgi='select *from imgi0 where imgi_item="'.$codigo.'" and imgi_status!="X" order by imgi_defa desc,imgi_codigo';

$res_imgi=mysql_query($sql_imgi,$link_vcrx);

$timgi=mysql_num_rows($res_imgi);
if($timgi!=0)
{
$imgidefa=mysql_result($res_imgi,0,'imgi_codigo');

$sql_uimgid='update imgi0 set imgi_defa=1 where imgi_item="'.$codigo.'" and imgi_status!="X"';
$res_uimgid=mysql_query($sql_uimgid,$link_vcrx);

$sql_uimgid='update item0 set item_imgi="'.$imgidefa.'" where item_codigo="'.$codigo.'"';
$res_uimgid=mysql_query($sql_uimgid,$link_vcrx);
}	

$res_imgi=mysql_query($sql_imgi,$link_vcrx);
			
?>
<br>           
<hr>
<table width="100%" border="0" cellpadding="2" cellspacing="0" class="tablitita"   style="border-collapse:collapse;font-size:14px;">
   <tr style="border-top:solid 2px;border-bottom:solid 2px;" align="center">
   <th width= "1%">_</th>
   <th>IMAGEN</th>
   <th></th>
	</tr>

 <?php while($r_imgi=mysql_fetch_assoc($res_imgi)){?>
			
<tr valign="top" id="<?php echo $r_imgi['imgi_codigo'];?>" style="border-bottom:dotted 1px #000000;" >
    <td>
 		<input type="radio" id="<?php echo 'defa'.$r_imgi['imgi_codigo'] ?>" name="imgidefa" <?php if($r_imgi['imgi_defa']=='1'){echo 'checked';}?> onclick="_defa_adr('<?php echo $r_imgi['imgi_codigo'];?>','<?php echo $r_imgi['imgi_item'];?>');"/><span></span> <br/>
		</td>
	
    <td><img src="../ctlg/<?php echo $r_imgi['imgi_file'];?>" style="max-width:100px;max-height:100px;" /></td>
    <td width="20"><input type="image" src="http://vcrxol.com/_img/x.png" width="18" onclick="_delete_adr('<?php echo $r_imgi['imgi_codigo'];?>','<?php echo $r_imgi['imgi_item'];?>');"  /></td>
 </tr>
<?php }?>
<!--     <td id="ttel2"></td>
    <td id="text2"></td>
    <td id="tcontacto2" ></td>
    <td id="tc12"  ></td>
    <td id="tc22"></td>
    <td id="tc32"></td>
    <td id="tcn2"></td>
    <td id="tciudad2"></td>
    <td id="temal2" ></td>
    <td id="tico"></td>
 -->
</table>