<?
function panel_list_cars($options=array())
{
  ?><div id="panel_list_cars"><?

      $_usl=array() ; $view_client=1 ; $title='' ; $arr_title=array() ; $cnt=0 ;
      $_usl[]='clss=361' ;
      $_usl[]='enabled=1' ;
      if ($options['client_id'])
      { $ids_orgs=execSQL_line('select pkey from obj_site_personals where clss=207 and enabled=1 and client_id='.MEMBER()->id) ;
        if (_sizeof($ids_orgs)) $_usl[]='parent in ('.implode(',',$ids_orgs).')' ;
      }
      if ($options['view_ext'])     $_usl[]='ext=1';
      if ($options['org_id'])       $_usl[]='parent='.$options['org_id'] ;
      if ($options['car_id'])       $_usl[]='pkey in ('.$options['car_id'].')' ;

      //damp_array($options,1,-1);
      //damp_array($_usl,1,-1);

      // формируеем заголовок
      if ($options['client_id'])           $arr_title['Клиент']=execSQL_value('select obj_name from obj_site_account where pkey='.$options['client_id']) ;
      if ($options['view_ext'])            $arr_title['Доп.списки']='Да' ;
      if ($options['org_id'])              $arr_title['Организация']=PERSONAL()->get_name_by_id($options['org_id']) ;
      if ($options['park_id'])             $arr_title['Автопарк']=PERSONAL()->get_name_by_id($options['park_id']);
      if ($options['cars_id_search'])      $arr_title['Поиск авто по']=$options['cars_id_search'] ;

      $options['ext']='client' ;
      $options['cmd']='export_cars' ;
      $arr=array() ;
      if (_sizeof($options)) foreach($options as $key=>$value)
      { $arr[]=$key.'='.$value ;
        $query=implode('&',$arr) ;
        $arr_title['Выгрузка в excel']='<a href="/XLS/?'.$query.'">Скачать</a>' ;
      }

      if (_sizeof($_usl)) $usl=implode(' and ',$_usl) ; else $usl='' ;
      //echo '$usl='.$usl.'<br>' ;
      if (_sizeof($arr_title))
      { ?><h3>Параметры показа:</h3><?
        ?><table class="basic fz_small left"><?
        foreach($arr_title as $title=>$value) {?><tr><td><?echo $title?>:</td><td><strong><?echo $value?></strong></td></tr><?}
        ?></table><br><?
      }
      if ($view_client) $cnt=show_list_items('obj_site_personals_cars',$usl,'aspmo_client/list_cars_full',array('debug'=>0,'panel_select_pages'=>1,'order'=>$_SESSION['list_cars_sort_mode'],'_pages_base_url'=>'/cab/car/')) ;
      else              {?><div class="alert">Автомобилей не найдено</div><?}

      ?></div><?
      return($cnt) ;
}
?>
