<?
echo time();
include_once("config.php");
include_once("session_class.php");
include_once("persinfo_class.php");


$res=db_use('query',"
select * from 
(
(select t.id_thing,th.id_thing2,th.name,i.id_person as inv,p.id_person as put,k.id_person as kom,0 as oper,0 as own from thing t 
left join thing_har th on th.id_thing2=t.id_thing2 
left join inv i on i.id_thing=t.id_thing
left join puton p on p.id_thing=t.id_thing
left join komok k on k.id_thing=t.id_thing

where 
th.id_thing2=677 and 
((t.id_thing>=97332 and t.id_thing<=97400) or (t.id_thing>=97449 and t.id_thing<=97498)or (t.id_thing>=98130 and t.id_thing<=98185) or (t.id_thing>=98191 and t.id_thing<=98217) or (t.id_thing>=98441 and t.id_thing<=98460)or t.id_thing>100488 ) limit 1000) 

union 
(select t.id_thing,677 as id_thing2,'Клонирование (история)' as name,0 as inv,0 as put,k.id_person as kom,k.oper,k.id_owner as own  from
thing_history t 
left join komok_sells k on k.id_thing=t.id_thing 
where id_thing2=677 and ((t.id_thing>=97332 and t.id_thing<=97400) or (t.id_thing>=97449 and t.id_thing<=97498)or (t.id_thing>=98130 and t.id_thing<=98185) or (t.id_thing>=98191 and t.id_thing<=98217) or (t.id_thing>=98441 and t.id_thing<=98460)or t.id_thing>100488)
))dd

order by id_thing 
");
echo "<table><tr><td>id<td>td2<td>назв<td>инв<td>одет<td>комок";
unset($i);while ($i<mysql_num_rows($res)) {
	$i++;$s=mysql_fetch_array($res);
	echo '<tr><td>'.$s[id_thing].'<td>'.$s[id_thing2].'<td>'.$s[name].'<td>'.$s[inv].'<td>'.$s[put].'<td>'.$s[kom]." ".(($s[kom]==0 && $s[oper]==2)?'автоматически скриптом комка ':'').($s[oper]==2?'сдано в гос':'').($s[own]?'- владелец: '.$s[own]:'');
	
}
?>