$UserId=$_SESSION[`UserId`];

$CaseId=str_replace(` `,``,ShowQueryResultScalar(~select concat(UserId,`-vac-`,NOW()) as CaseId from Users where UserId=`$UserId`~));

$Instance=ShowQueryResultScalar(~select rUnique from Responses where CaseID=`$CaseId`~);

if ($Instance==~~)
   {
      ExecuteSQL(~insert into Responses (CaseID,qID,rValue,uID,rInstance,ProjectId) select `$CaseId`,`CaseID`,`$CaseId`,`$UserId`,`1`,`~.$_SESSION[`ProjectId`].~`~);
      ExecuteSQL(~insert into Responses (CaseID,qID,rValue,uID,rInstance,ProjectId) select `$CaseId`,`CaseType`,`M`,`$UserId`,`1`,`~.$_SESSION[`ProjectId`].~`~);

      $Instance=1;
   }
$_SESSION[`Instance`]=$Instance;
$_SESSION[`CaseId`]=$CaseId;
SetForm(`MV_Options`);

$stat=1;