<?
class c_client
{  public $main_org_id ;
    public $id ;
    function c_client($id=0)
    {
        if ($id) $this->main_org_id=execSQL_value('select pkey from obj_site_personals where clss=207 and enabled=1 and client_id='.$id.' order by c_data limit 1') ;
        $this->id=$id ;
    }

    function get_personal_id_by_number($number)
    { $arr=explode('#',$number) ;
      if (_sizeof($arr)>1) {$car_number=$arr[0] ; $driving=$arr[1] ; }
      else                {$car_number=''; $driving=$arr[0] ;}
      // определяем организацию, к которой принаджежит автомобиль
      $driving=str_replace(array("'",'"','(',')',' ',"\n"),'',$driving) ;
      $car_number=str_replace(array("'",'"','(',')',' ',"\n"),'',$car_number) ;
      $rec_personal=array() ;   $usl_parent='' ;
      if ($car_number)
      { $rec_car=execSQL_van('select pkey,parent,obj_name from obj_site_personals_cars where clss=361 and obj_name="'.$car_number.'" and enabled=1') ;
        if ($rec_car['pkey']) $usl_parent=' parent in ('.PERSONAL()->tree[$rec_car['parent']]->get_list_child().')'  ;
        else $rec_personal['_reason']='Автомобиль не найден' ;
      }

      if (!$rec_personal['_reason'])
      { $rec_personal=PERSONAL()->get_personal_by_propusk($driving,array('set_QR_code'=>$GLOBALS['LS_person_field_to_qrcode'],'dop_usl'=>$usl_parent)) ;
        if (!$rec_personal['pkey']) $rec_personal['_reason']='Сотрудник не найден' ;
      }

      return($rec_personal) ;
    }
}


?>
