<?
 function panel_stats()
 { $list_group=execSQL('select t1.pkey,t1.obj_name,t2.obj_name as doctor_name,t2.smena_in 
                            from obj_site_account t1 
                            left join obj_site_account t2 on t2.group_id=t1.pkey and t2.smena=1 
                            where t1.clss=206 and t1.enabled=1 and t1.pkey!=1 
                            order by t1.obj_name') ;

   $now=getdate() ;
   $start_day=mktime(0,0,0,$now['mon'],$now['mday'],$now['year']);

   ?><div id="panel_rmv_stats"><table class="basic full">
     <tr><th>Группа терминалов</th><th>Допущено</th><th>Не допущено</th></tr>
     <?
     if (_sizeof($list_group)) foreach($list_group as $rec)
     {  $usl_based='c_data>='.$start_day.' and group_id='.$rec['pkey'].'  ' ;
        ?><tr></tr>
               <tr><td><?echo $rec['obj_name'] ;
                       $stats=execSQL_row('select dopusk,count(pkey) from view_mo_session where '.$usl_based.' and member_id>0 and model>0  group by dopusk order by dopusk') ;
                               $s2=$stats[1] ; if (!$s2) $s2=0 ;
                               $s3=$stats[2] ; if (!$s3) $s3=0 ;

                       ?></td>
                   <td><?echo $s2?></td>
                   <td><?echo $s3?></td>
               </tr>
        <?
     }
   ?></table><?
   ?></div><?
 }
?>
