<?php
include_once("c_client.php");
class c_page_cab_client_cars extends c_page_cab_client
{
  public $h1='Справочник автомобилей' ;

  function block_main()
  { $this->page_title() ;
    if ($this->client->main_org_id) $this->panel_list_cars() ;
    else { ?><div class="alert2">Не заполнены <a href="/cab/client/org/">реквизиты</a> организации</div><?}
  }

 function panel_list_cars()
 {  $recs_org=execSQL('select * from obj_site_personals where clss=207 and enabled=1 and client_id='.MEMBER()->id.' order by obj_name') ;
    if (_sizeof($recs_org)) $recs_park=execSQL('select * from obj_site_personals where clss=208 and enabled=1 and parent in ('.implode(',',array_keys($recs_org)).') order by obj_name') ;
    ?><div id=panel_search_member>
            <form>
                <input type="hidden" name="client_id" value="<?echo MEMBER()->id?>">
                <input type="hidden" name="view_ext" value="<?echo $this->view_ext?>">
                <span class="title">ПОИСК:</span>
                <input type="text" name="search_text" data-required> <input type="submit" class="v2 fa fa-search" cmd="aspmo_client/search_cars" value="Искать" validate="form">&nbsp;&nbsp;&nbsp;
                <!--<span class="title">Организация:</span>
                <select name="filter_org" class="v2" cmd="aspmo_client/set_filter_org"><option value="-1"></option>
                        <? if (_sizeof($recs_org)) foreach($recs_org as $rec_org) {?><option value="<?echo $rec_org['pkey']?>" <?if ($_SESSION['list_cars_filter_org']==$rec_org['pkey']) echo 'selected'?>><?echo $rec_org['obj_name']?></option><?}?>
                </select>&nbsp;&nbsp;&nbsp;-->
                <!--<span class="title">АВТОПАРК:</span> <select name="filter_park" class="v2" cmd="aspmo_client/set_filter_park"><option value="-1"></option>
                        <? if (_sizeof($recs_park)) foreach($recs_park as $rec_park) {?><option value="<?echo $rec_park['pkey']?>" <?if ($_SESSION['list_cars_filter_park']==$rec_park['pkey']) echo 'selected'?>><?echo $rec_park['obj_name']?></option><?}?>
                </select>&nbsp;&nbsp;&nbsp;-->
                <span class="title">СОРТИРОВКА:</span> <select name="sort_mode" class="v2" cmd="aspmo_client/change_cars_sort">
                    <option value="obj_name" <?if ($_SESSION['list_cars_sort_mode']=='obj_name') echo 'selected'?>>По номеру</option>
                    <!--<option value="age" <?if ($_SESSION['list_cars_sort_mode']=='age') echo 'selected'?>>По возрасту (возрастание)</option>
                    <option value="age desc" <?if ($_SESSION['list_cars_sort_mode']=='age desc') echo 'selected'?>>По возрасту (убывание)</option>
                    <option value="parent" <?if ($_SESSION['list_cars_sort_mode']=='parent') echo 'selected'?>>По организации и отделу</option>
                    <option value="working" <?if ($_SESSION['list_cars_sort_mode']=='working') echo 'selected'?>>По должности</option>-->
                </select>
            </form>
     </div><?

    $options=array() ;
    $options['client_id']=MEMBER()->id ;
    if ($this->view_ext)                       $options['view_ext']=1;
    if ($_SESSION['list_cars_filter_org'])     $options['org_id']=$_SESSION['list_cars_filter_org'] ;
    if ($_SESSION['list_cars_filter_park'])    $options['park_id']=$_SESSION['list_cars_filter_park'] ;
    include_once(_DIR_EXT.'/aspmo_client/panel_list_cars.php') ;
    panel_list_cars($options) ;
   }

}



?>
