public static function Add($arFields)
 {
     global $DB;
     $tm_user = new CUserReportFull($arFields["USER_ID"]);
     $arReportDate = $tm_user->GetReportInfo();
     if ($arReportDate["IS_REPORT_DAY"] != "Y") {
         return false;
     }
     $arFields["DATE_TO"] = ConvertTimeStamp(MakeTimeStamp($arReportDate["DATE_TO"], TM_SHORT_FORMAT), "SHORT");
     $arFields["DATE_FROM"] = ConvertTimeStamp(MakeTimeStamp($arReportDate["DATE_FROM"], TM_SHORT_FORMAT), "SHORT");
     $arFields["REPORT_DATE"] = ConvertTimeStamp(MakeTimeStamp($arFields["REPORT_DATE"], TM_FULL_FORMAT), "FULL");
     foreach (GetModuleEvents('timeman', 'OnBeforeFullReportAdd', true) as $event) {
         if (false === ExecuteModuleEventEx($event, array(&$arFields))) {
             return false;
         }
     }
     if (!self::CheckFields('ADD', $arFields)) {
         return false;
     }
     //we try to find report with DATE_TO>DATE_FROM-of-current-report
     $dbreport = CTimeManReportFull::GetList(array("DATE_FROM" => "DESC"), array(">=DATE_TO" => $arFields["DATE_FROM"], "USER_ID" => $arFields["USER_ID"], "ACTIVE" => "Y"), array("ID", "DATE_TO"), array("nTopCount" => 1));
     if ($last_report = $dbreport->Fetch()) {
         //if we found it
         //fix date from
         $arFields["DATE_FROM"] = ConvertTimeStamp(strtotime("next day", MakeTimeStamp($last_report["DATE_TO"])), "SHORT");
     }
     if (MakeTimeStamp($arFields["DATE_FROM"]) > MakeTimeStamp($arFields["DATE_TO"])) {
         //fix date to
         $arFields["DATE_TO"] = $arFields["DATE_FROM"];
     }
     CTimeZone::Disable();
     $ID = $DB->Add('b_timeman_report_full', $arFields, array('REPORT', 'TASKS', 'EVENTS', 'FILES'));
     CTimeZone::Enable();
     if ($ID > 0) {
         $last_date = ConvertTimeStampForReport(MakeTimeStamp($arFields["DATE_TO"]), "SHORT");
         $arFields['ID'] = $ID;
         foreach (GetModuleEvents('timeman', 'OnAfterFullReportAdd', true) as $a) {
             ExecuteModuleEventEx($a, array($arFields));
         }
         if ($arFields["ACTIVE"] != "N") {
             $tm_user->SetLastDate($arFields["USER_ID"], $last_date);
         }
     }
     return $ID;
 }