<?php
/**
 * Created by PhpStorm.
 * User: Александр
 * Date: 26.02.15
 * Time: 16:13
 */
class AccessControlView
{
    public function CreateTesteData($UserID,$Name,$Famili,$PlaceWork,$position,$passportNamber)
    {
        $res=execSQL('Select * from obj_site_zayavka_out_356 where id_personal_data='.$UserID);
            $query="insert into obj_site_zayavka_out_356(id_personal_data,firstName,lastName,job,position,passport_number)
            values('".$UserID."','".$Name."','".$Famili."','".$PlaceWork."','".$position."','".$passportNamber."');";
            execSQL_update($query);

            $query="insert into obj_site_zayavka_out_355(id_request,id_personal_data) values ('".$UserID."','".$UserID."');";
            execSQL_update($query);

            $query="insert into obj_site_zayavka(id_request,passport_number)
            values ('".$UserID."','".$passportNamber."');";

    }

    public function CheckData($UserID)//проверяем разрешение
    {
        $res=execSQL('select * from obj_site_zayavka where id_request=
        select id_request from obj_site_zayavka_out_355 where id_personal_data=
        select id_personal_data from obj_site_zayavka_out_356 where id_personal_data='.$UserID) ;
        return $res.permission;
    }

    public function FixCome($UserID, $PlaceCame)//фиксируем проход
    {
        $query="insert into obj_site_zayavka_out_358(id_personal_data,date_came,place_came)
            values('".$UserID."','".date('Y-m-d H:i:s')."','".$PlaceCame."'); ";
        execSQL_update($query);
    }

    public function FixOut($UserID, $PlaceOut)//фиксируем уход
    {
        $query="update obj_site_zayavka_out_358 set date_out=".date('Y-m-d H:i:s').", place_out=".$PlaceOut."where id_personal_data=".$UserID." and place_out=NULL;";
        execSQL_update($query);
    }
}


?>