public function GetFlightsByCriteria($filterData)
 {
     $filterParams = [];
     if (isset($filterData['fdr']) && !empty($filterData['fdr'])) {
         $FDR = new Bru();
         $FDRinfo = $FDR->GetBruInfoById($filterData['fdr']);
         $filterParams['bruType'] = $FDRinfo['bruType'];
     }
     if (isset($filterData['bort']) && !empty($filterData['bort'])) {
         $filterParams['bort'] = $filterData['bort'];
     }
     if (isset($filterData['voyage']) && !empty($filterData['voyage'])) {
         $filterParams['voyage'] = $filterData['voyage'];
     }
     if (isset($filterData['departureAirport']) && !empty($filterData['departureAirport'])) {
         $filterParams['departureAirport'] = $filterData['departureAirport'];
     }
     if (isset($filterData['arrivalAirport']) && !empty($filterData['arrivalAirport'])) {
         $filterParams['arrivalAirport'] = $filterData['arrivalAirport'];
     }
     if (isset($filterData['aditionalInfo']) && !empty($filterData['aditionalInfo'])) {
         $filterParams['flightAditionalInfo'] = $filterData['aditionalInfo'];
     }
     if (isset($filterData['performer']) && !empty($filterData['performer'])) {
         $filterParams['performer'] = $filterData['performer'];
     }
     if (isset($filterData['flightDateFrom']) && !empty($filterData['flightDateFrom']) && strtotime($filterData['flightDateFrom'])) {
         $filterParams['from'] = strtotime($filterData['flightDateFrom']);
     }
     if (isset($filterData['flightDateTo']) && !empty($filterData['flightDateTo']) && strtotime($filterData['flightDateTo'])) {
         $filterParams['to'] = strtotime($filterData['flightDateTo']);
     }
     $F = new Flight();
     $flights = $F->GetFlightsByFilter($filterParams);
     unset($F);
     return $flights;
 }
 public function copyTemplate($flightId, $oldName)
 {
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     unset($Fl);
     $bruType = $flightInfo['bruType'];
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     $tableName = $bruInfo['paramSetTemplateListTableName'];
     unset($Bru);
     $newName = date('Y-m-d') . '_' . $this->_user->username . '_' . $this->generateRandomString(3);
     $username = $this->_user->username;
     $PSTempl = new PSTempl();
     $tpl = $PSTempl->getTemplate($tableName, $oldName, $username);
     $PSTempl->createTemplate($newName, $tpl, $tableName, $username);
     unset($PSTempl);
     return 'ok';
 }
 public function GetCoordinates($flightId)
 {
     if (!is_int(intval($flightId))) {
         throw new Exception("Incorrect flightId passed into GetCoordinates FlightsController." . $flightId, 1);
     }
     $Fl = new Flight();
     $flight = $Fl->GetFlightInfo($flightId);
     unset($Fl);
     $bruType = $flight['bruType'];
     $apTableName = $flight['apTableName'];
     $bpTableName = $flight['bpTableName'];
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     unset($Bru);
     $kmlScript = $bruInfo['kml_export_script'];
     $kmlScript = str_replace("[ap]", $apTableName, $kmlScript);
     $kmlScript = str_replace("[bp]", $bpTableName, $kmlScript);
     $c = new DataBaseConnector();
     $link = $c->Connect();
     $info = [];
     $averageLat = 0;
     $averageLong = 0;
     if (!$link->multi_query($kmlScript)) {
         //err log
         error_log("Impossible to execute multiquery: (" . $kmlScript . ") " . $link->error);
     }
     do {
         if ($res = $link->store_result()) {
             while ($row = $res->fetch_array()) {
                 $lat = $row['LAT'];
                 $long = $row['LONG'];
                 $h = $row['H'];
                 $averageLat += $lat;
                 $averageLong += $long;
                 $averageLat /= 2;
                 $averageLong /= 2;
                 if ($h < 0) {
                     $h = 10.0;
                 }
                 $h = round($h, 2);
                 $info[] = [$long, $lat, $h];
             }
             $res->free();
         }
     } while ($link->more_results() && $link->next_result());
     $c->Disconnect();
     unset($c);
     return $info;
 }
 public function BuildUpdateUserModal($updatedUsersId)
 {
     $privilege = $this->_user->allPrivilegeArray;
     $authorId = $this->_user->GetUserIdByName($this->_user->username);
     $authorInfo = $this->_user->GetUserInfo($authorId);
     $userInfo = $this->_user->GetUserInfo($updatedUsersId);
     $role = $userInfo['role'];
     $privilege = explode(",", $userInfo['privilege']);
     $form = sprintf("<div id='user-cru-modal'><form id='user-cru-form' enctype='multipart/form-data'>");
     $privilegeOptions = "<tr><td>" . $this->lang->userPrivilege . "</td><td align='center'>";
     $privilegeOptions .= "<select id='privilege' name='privilege[]' multiple size='10' style='width: 335px'>";
     $authorPrivilege = explode(',', $authorInfo['privilege']);
     foreach ($authorPrivilege as $val) {
         $selected = '';
         if (in_array($val, $privilege)) {
             $selected = " selected='selected' ";
         }
         $privilegeOptions .= "<option " . $selected . ">" . $val . "</option>";
     }
     $privilegeOptions .= "</select></td></tr>";
     $roleOptions = '';
     if (User::isAdmin($role)) {
         $roleOptions .= "<tr><td>" . $this->lang->userRole . "</td><td align='center'>";
         $roleOptions .= "<select name='role[]' size='3' style='width: 335px'>";
         foreach (User::$role as $val) {
             $selected = '';
             if ($val == $role) {
                 $selected = " selected='selected' ";
             }
             $roleOptions .= "<option " . $selected . ">" . $val . "</option>";
         }
         $roleOptions .= "</select></td></tr>";
     } else {
         $roleOptions .= "<input type='hidden' name='role' size='50' value='user'>";
     }
     $form .= sprintf("<table align='center'>\r\n            <p class='Label'>%s</p>\r\n            <div class='user-creation-info'><p>%s</p></div>\r\n            <tr><td>%s</td><td>\r\n                <input type='text' name='login' size='50' value='%s' disabled='disabled'>\r\n            </td></tr>\r\n            <tr><td>%s</td><td>\r\n                <input type='text' name='company' size='50' value='%s'>\r\n            </td></tr>\r\n            <tr><td>%s</td><td>\r\n                <input class='user-pwd' type='password' name='pwd' size='50'>\r\n            </td></tr>\r\n            <tr><td>%s</td><td>\r\n                <input class='user-pwd' type='password' name='pwd2' size='50'>\r\n            </td></tr>\r\n                %s\r\n                %s\r\n            <tr><td>%s</td><td align='center'>\r\n                <input type='file' name='logo'>\r\n            </td></tr>\r\n        </table>", $this->lang->userCreationForm, '', $this->lang->userName, $userInfo['login'], $this->lang->company, $userInfo['company'], $this->lang->pass, $this->lang->repeatPass, $privilegeOptions, $roleOptions, $this->lang->userLogo);
     $form .= sprintf("<input type='text' name='action' value='%s' style='visibility:hidden;'/>", $this->userActions["updateUser"]);
     $form .= sprintf("<input type='text' name='data' value='dummy' style='visibility:hidden;'/>");
     $form .= sprintf("<input type='text' name='useridtoupdate' value='%s' style='visibility:hidden;'/>", $updatedUsersId);
     //==========================================
     //access to flights
     //==========================================
     if (in_array(User::$PRIVILEGE_SHARE_FLIGHTS, $this->_user->privilege)) {
         $form .= sprintf("<div><p class='Label'>%s</p></br>", $this->lang->openAccessForFlights);
         $Fl = new Flight();
         $avaliableFlightIds = $this->_user->GetAvaliableFlights($this->_user->username);
         $avaliableFlights = $Fl->PrepareFlightsList($avaliableFlightIds);
         $attachedFlightIds = $this->_user->GetAvaliableFlights($userInfo['login']);
         if (count($avaliableFlights) > 0) {
             $headerLables = [$this->lang->bortNum, $this->lang->voyage, $this->lang->flightDate, $this->lang->bruTypeName, $this->lang->author, $this->lang->departureAirport, $this->lang->arrivalAirport, $this->lang->access];
             $rowsInfoKeys = ['id', 'bort', 'voyage', 'flightDate', 'bruType', 'performer', 'departureAirport', 'arrivalAirport'];
             $form .= $this->printTableAvaliability($headerLables, $avaliableFlights, $rowsInfoKeys, 'flights', $attachedFlightIds);
         } else {
             $form .= sprintf("<div align='center'><p class='SmallLabel' style='color:darkred;'>%s</p></br>", $this->lang->noDataToOpenAccess);
         }
         $form .= sprintf("</div>");
         unset($Fl);
     }
     //==========================================
     //access to brutypes
     //==========================================
     if (in_array(User::$PRIVILEGE_SHARE_BRUTYPES, $this->_user->privilege)) {
         $form .= sprintf("<div><p class='Label'>%s</p></br>", $this->lang->openAccessForBruTypes);
         $Bru = new Bru();
         $avaliableIds = $this->_user->GetAvaliableBruTypes($this->_user->username);
         $avaliableBruTypes = $Bru->GetBruList($avaliableIds);
         $attachedFDRIds = $this->_user->GetAvaliableBruTypes($userInfo['login']);
         if (count($avaliableBruTypes) > 0) {
             $headerLables = [$this->lang->bruTypesName, $this->lang->bruTypesStepLenth, $this->lang->bruTypesFrameLength, $this->lang->bruTypesWordLength, $this->lang->bruTypesAuthor, $this->lang->access];
             $rowsInfoKeys = ['id', 'bruType', 'stepLength', 'frameLength', 'wordLength', 'author'];
             $form .= $this->printTableAvaliability($headerLables, $avaliableBruTypes, $rowsInfoKeys, 'FDRs', $attachedFDRIds);
         } else {
             $form .= sprintf("<div align='center'><p class='SmallLabel' style='color:darkred;'>%s</p></br>", $this->lang->noDataToOpenAccess);
         }
         $form .= sprintf("</div>");
         unset($Bru);
     }
     //==========================================
     //access to users
     //==========================================
     if (in_array(User::$PRIVILEGE_SHARE_USERS, $this->_user->privilege)) {
         $form .= sprintf("<div><p class='Label'>%s</p></br>", $this->lang->openAccessForUsers);
         $avaliableIds = $this->_user->GetAvaliableUsers($this->_user->username);
         $avaliableUsers = $this->_user->GetUsersListByAvaliableIds($avaliableIds);
         $attachedUserIds = $this->_user->GetAvaliableUsers($userInfo['login']);
         if (count($avaliableUsers) > 0) {
             $headerLables = [$this->lang->userLogin, $this->lang->userCompany, $this->lang->userAuthor, $this->lang->access];
             $rowsInfoKeys = ['id', 'login', 'company', 'author'];
             $form .= $this->printTableAvaliability($headerLables, $avaliableUsers, $rowsInfoKeys, 'users', $attachedUserIds);
         } else {
             $form .= sprintf("<div align='center'><p class='SmallLabel' style='color:darkred;'>%s</p></br>", $this->lang->noDataToOpenAccess);
         }
         $form .= sprintf("</div>");
     }
     $form .= '</form></div>';
     return $form;
 }
 public function GetTableStep($flightId)
 {
     $F = new Flight();
     $flightInfo = $F->GetFlightInfo($flightId);
     unset($F);
     $FDR = new Bru();
     $FDRinfo = $FDR->GetBruInfo($flightInfo['bruType']);
     unset($FDR);
     $userId = $this->_user->GetUserIdByName($this->_user->username);
     $O = new UserOptions();
     $step = $O->GetOptionValue($userId, 'printTableStep');
     unset($O);
     if ($step === null) {
         $step = 0;
     } else {
         $step = $step * $FDRinfo['stepDivider'];
     }
     return $step;
 }
 public function ImportFlight($importedFileName)
 {
     $copiedFilesDir = UPLOADED_FILES_PATH;
     $copiedFilePath = $copiedFilesDir . $importedFileName;
     $zip = new ZipArchive();
     $res = $zip->open($copiedFilePath);
     $importFolderName = sprintf("Imported_%s", date('Y-m-d'));
     $needToCreateImportedFolder = true;
     $Fl = new Flight();
     $Bru = new Bru();
     $Fr = new Frame();
     $FlE = new FlightException();
     $Fd = new Folder();
     $folderInfo = [];
     $userId = $this->_user->GetUserIdByName($this->_user->username);
     if ($res === TRUE) {
         $i = 0;
         $headerFiles = [];
         do {
             $fileName = $zip->getNameIndex($i);
             if (strpos($fileName, "header") !== false) {
                 $headerFiles[] = $fileName;
             }
             $i++;
         } while ($i < $zip->numFiles);
         foreach ($headerFiles as $name) {
             $zip->extractTo($copiedFilesDir, $name);
             $json = file_get_contents($copiedFilesDir . "/" . $name);
             unlink($copiedFilesDir . "/" . $name);
             $flightInfoImported = json_decode($json, true);
             $bruType = $flightInfoImported['bruType'];
             $flightId = $Fl->InsertNewFlight($flightInfoImported['bort'], $flightInfoImported['voyage'], $flightInfoImported['startCopyTime'], $flightInfoImported['bruType'], $flightInfoImported['performer'], $flightInfoImported['departureAirport'], $flightInfoImported['arrivalAirport'], $importedFileName, $flightInfoImported['flightAditionalInfo']);
             $flightInfo = $Fl->GetFlightInfo($flightId);
             $tableNameAp = $flightInfo['apTableName'];
             $tableNameBp = $flightInfo['bpTableName'];
             $bruInfo = $Bru->GetBruInfo($bruType);
             $apPrefixes = $Bru->GetBruApCycloPrefixes($bruType);
             $bpPrefixes = $Bru->GetBruBpCycloPrefixes($bruType);
             $apCyclo = $Bru->GetBruApCycloPrefixOrganized($bruType);
             $tables = $Fl->CreateFlightParamTables($flightId, $apCyclo, $bpPrefixes);
             $apTables = $flightInfoImported["apTables"];
             for ($j = 0; $j < count($apTables); $j++) {
                 $zip->extractTo($copiedFilesDir, $apTables[$j]["file"]);
                 if (file_exists($copiedFilesDir . $apTables[$j]["file"])) {
                     $Fr->LoadFileToTable($tableNameAp . "_" . $apTables[$j]["pref"], $copiedFilesDir . $apTables[$j]["file"]);
                     unlink($copiedFilesDir . $apTables[$j]["file"]);
                 }
             }
             $bpTables = $flightInfoImported["bpTables"];
             for ($j = 0; $j < count($bpTables); $j++) {
                 $zip->extractTo($copiedFilesDir, $bpTables[$j]["file"]);
                 if (file_exists($copiedFilesDir . $bpTables[$j]["file"])) {
                     $Fr->LoadFileToTable($tableNameBp . "_" . $bpTables[$j]["pref"], $copiedFilesDir . $bpTables[$j]["file"]);
                     unlink($copiedFilesDir . $bpTables[$j]["file"]);
                 }
             }
             if (isset($flightInfoImported["exTableName"]) && $flightInfoImported["exTableName"] != "") {
                 $tableGuid = substr($tableNameAp, 0, 14);
                 $FlE->CreateFlightExceptionTable($flightId, $tableGuid);
                 $flightInfo = $Fl->GetFlightInfo($flightId);
                 $exTables = $flightInfoImported["exTables"];
                 $zip->extractTo($copiedFilesDir, $exTables);
                 $Fr->LoadFileToTable($flightInfo["exTableName"], $copiedFilesDir . $exTables);
                 if (file_exists($copiedFilesDir . $exTables)) {
                     unlink($copiedFilesDir . $exTables);
                 }
             }
             $this->_user->SetFlightAvaliable($this->_user->username, $flightId);
             if (count($headerFiles) > 1) {
                 if ($needToCreateImportedFolder) {
                     $folderInfo = $Fd->CreateFolder($importFolderName, 0, $userId);
                     $needToCreateImportedFolder = false;
                 }
                 if (isset($folderInfo['folderId'])) {
                     $Fd->PutFlightInFolder($flightId, $folderInfo['folderId'], $userId);
                 } else {
                     $Fd->PutFlightInFolder($flightId, 0, $userId);
                     //we put currently uploaded file in root
                 }
             } else {
                 //into root if only one
                 $Fd->PutFlightInFolder($flightId, 0, $userId);
                 //we put currently uploaded file in root
             }
         }
         $zip->close();
         unlink($copiedFilePath);
         unset($zip);
         unset($Fl);
         unset($FlE);
         unset($Fr);
         unset($Fd);
         unset($Bru);
         if (count($headerFiles) <= 0) {
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
 public function ConstructFlightEventsList($extFlightId, $sections = [], $colored = false)
 {
     $flightId = $extFlightId;
     $user = $this->_user->username;
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     $bruType = $flightInfo['bruType'];
     unset($Fl);
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     $flightApHeaders = $Bru->GetBruApHeaders($bruType);
     $flightBpHeaders = $Bru->GetBruBpHeaders($bruType);
     $prefixArr = $Bru->GetBruApCycloPrefixes($bruType);
     unset($Bru);
     $Frame = new Frame();
     $framesCount = $Frame->GetFramesCount($flightInfo['apTableName'], $prefixArr[0]);
     //giving just some prefix
     unset($Frame);
     // create new PDF document
     $pdf = new TCPDF('L', 'mm', 'A4', true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator($user);
     $pdf->SetAuthor($user);
     $pdf->SetTitle('Flight events list');
     $pdf->SetSubject('Flight events list');
     // $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     $bort = $flightInfo['bort'];
     $voyage = $flightInfo['voyage'];
     $copyDate = date('H:i:s d-m-Y', $flightInfo['startCopyTime']);
     $Fr = new Frame();
     $flightDuration = $Fr->FrameCountToDuration($framesCount, $bruInfo['stepLength']);
     unset($Fr);
     $usrInfo = $this->_user->userInfo;
     $headerStr = $usrInfo['company'];
     $imageFile = '';
     if ($colored && $usrInfo['logo'] != '') {
         $imageFile = SITE_ROOT_DIR . '/fileUploader/files/' . uniqid() . '.png';
         file_put_contents($imageFile, $usrInfo['logo']);
         $img = file_get_contents($imageFile);
         $pdf->SetHeaderData('$' . $img, "20", $headerStr, "", [0, 10, 50], [0, 10, 50]);
     } else {
         // set default header data
         $pdf->SetHeaderData("", "", $headerStr, "", [0, 10, 50], [0, 10, 50]);
     }
     $pdf->setFooterData([0, 10, 50], [0, 10, 50]);
     // set header and footer fonts
     $pdf->setHeaderFont(array('dejavusans', '', 11));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // ---------------------------------------------------------
     // set default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont('dejavusans', '', 12, '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     if ($imageFile !== '') {
         unlink($imageFile);
     }
     // set text shadow effect
     $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => [196, 196, 196], 'opacity' => 1, 'blend_mode' => 'Normal'));
     // Pasport
     $strStyle = "text-align:center; font-size: xx-large; font-weight: bold; color: rgb(0, 10, 64);";
     $str = '<p style="' . $strStyle . '">' . $this->lang->pasport . '</p>';
     $pdf->writeHTML($str, true, false, false, false, '');
     // Pasport info
     $strStyle = "text-align:center;";
     $str = '<p style="' . $strStyle . '">' . $this->lang->bruType . ' - ' . $bruInfo['bruType'] . '. <br>' . $this->lang->bort . ' - ' . $flightInfo['bort'] . '; ' . $this->lang->voyage . ' - ' . $flightInfo['voyage'] . '; ' . $this->lang->route . ' : ' . ($new_string = preg_replace('/[^a-zA-z0-9]/', '', $flightInfo['departureAirport']) . ' - ' . preg_replace('/[^a-zA-z1-9]/', '', $flightInfo['arrivalAirport']) . '. <br>' . $this->lang->flightDate . ' - ' . date('H:i:s d-m-Y', $flightInfo['startCopyTime']) . '; ' . $this->lang->duration . ' - ' . $flightDuration . '. <br>');
     $fileName = date('Y-m-d_H.i.s', $flightInfo['startCopyTime']) . '_' . $flightInfo['bort'] . '_' . $flightInfo['voyage'] . '_' . $bruInfo['bruType'];
     if (strpos($bruInfo['aditionalInfo'], ";") >= 0) {
         $counterNeedBrake = false;
         $aditionalInfoArr = explode(";", $flightInfo['flightAditionalInfo']);
         foreach ($aditionalInfoArr as $aditionalInfo) {
             if ($aditionalInfo != "") {
                 $nameVal = explode(":", $aditionalInfo);
                 if (count($nameVal) > 1) {
                     $name = $nameVal[0];
                     $val = $nameVal[1];
                     if ($counterNeedBrake) {
                         $str .= (isset($this->lang->{$name}) ? $this->lang->{$name} : $name) . " - " . $val . "; </br>";
                         $counterNeedBrake = !$counterNeedBrake;
                     } else {
                         $str .= (isset($this->lang->{$name}) ? $this->lang->{$name} : $name) . " - " . $val . "; ";
                         $counterNeedBrake = !$counterNeedBrake;
                     }
                 }
             }
         }
     }
     $str .= "</p>";
     $pdf->writeHTML($str, true, false, false, false, '');
     if ($flightInfo['exTableName'] != "") {
         $FEx = new FlightException();
         $excEventsList = $FEx->GetFlightEventsList($flightInfo['exTableName']);
         $Frame = new Frame();
         // change frame num to time
         for ($i = 0; $i < count($excEventsList); $i++) {
             $event = $excEventsList[$i];
             $excEventsList[$i]['start'] = date("H:i:s", $excEventsList[$i]['startTime'] / 1000);
             $reliability = "checked";
             // converting false alarm to reliability
             if ($excEventsList[$i]['falseAlarm'] == 0) {
                 $reliability = true;
             } else {
                 $reliability = false;
             }
             $excEventsList[$i]['reliability'] = $reliability;
             $excEventsList[$i]['end'] = date("H:i:s", $excEventsList[$i]['endTime'] / 1000);
             $excEventsList[$i]['duration'] = $Frame->TimeStampToDuration($excEventsList[$i]['endTime'] - $excEventsList[$i]['startTime']);
         }
         unset($Frame);
         // if isset events
         if (!empty($excEventsList)) {
             $pdf->SetFont('dejavusans', '', 9, '', true);
             $strStyle = 'style="text-align:center; font-weight: bold; background-color:#708090; color:#FFF"';
             $str = '<p><table border="1" cellpadding="1" cellspacing="1">' . '<tr ' . $strStyle . '><td width="70"> ' . $this->lang->start . '</td>' . '<td width="70">' . $this->lang->end . '</td>' . '<td width="70">' . $this->lang->duration . '</td>' . '<td width="70">' . $this->lang->code . '</td>' . '<td width="260">' . $this->lang->eventName . '</td>' . '<td width="110">' . $this->lang->algText . '</td>' . '<td width="180">' . $this->lang->aditionalInfo . '</td>' . '<td width="110">' . $this->lang->comment . '</td></tr>';
             for ($i = 0; $i < count($excEventsList); $i++) {
                 $event = $excEventsList[$i];
                 $excInfo = $FEx->GetExcInfo($bruInfo['excListTableName'], $event['refParam'], $event['code']);
                 $codePrefix = substr($event['code'], 0, 3);
                 if ($event['reliability'] && (in_array($codePrefix, $sections) || !preg_match('/00[0-9]/', $codePrefix) && in_array('other', $sections))) {
                     if ($colored && $excInfo['status'] == "C") {
                         $style = "background-color:LightCoral";
                     } else {
                         if ($colored && $excInfo['status'] == "D") {
                             $style = "background-color:LightYellow";
                         } else {
                             if ($colored && $excInfo['status'] == "E") {
                                 $style = "background-color:LightGreen";
                             } else {
                                 $style = "";
                             }
                         }
                     }
                     $excAditionalInfo = $event['excAditionalInfo'];
                     $excAditionalInfo = str_replace(";", ";<br>", $excAditionalInfo);
                     $excInfo['algText'] = str_replace('<', "less", $excInfo['algText']);
                     $str .= '<tr style="' . $style . '" nobr="true">' . '<td width="70" style="text-align:center;">' . $event['start'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['end'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['duration'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['code'] . '</td>' . '<td width="260" style="text-align:center;">' . $excInfo['comment'] . '</td>' . '<td width="110" style="text-align:center;">' . $excInfo['algText'] . '</td>' . '<td width="180" style="text-align:center;">' . $excAditionalInfo . '</td>' . '<td width="110" style="text-align:center;"> ' . $event['userComment'] . '</td></tr>';
                 }
             }
             unset($FEx);
             $str .= "</table></p>";
             $pdf->writeHTML($str, false, false, false, false, '');
             $pdf->SetFont('dejavusans', '', 12, '', true);
             $str = "</br></br>" . $this->lang->performer . ' : ' . '_____________________ ' . $flightInfo['performer'] . ', ' . date('d-m-Y') . '';
             $pdf->writeHTML($str, false, false, false, false, '');
         } else {
             $strStyle = "text-align:center; font-size: xx-large; font-weight: bold; color: rgb(128, 10, 0);";
             $str = '<p style="' . $strStyle . '">' . $this->lang->noEvents . '</p>';
             $pdf->writeHTML($str, false, false, false, false, '');
         }
     }
     $pdf->Output($fileName, 'I');
 }
 public function UpdateParamColor($extFlightId, $extParamCode, $extParamColor)
 {
     $flightId = $extFlightId;
     $paramCode = $extParamCode;
     $color = $extParamColor;
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     $bruType = $flightInfo['bruType'];
     unset($Fl);
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     $cycloApTableName = $bruInfo['gradiApTableName'];
     $cycloBpTableName = $bruInfo['gradiBpTableName'];
     $paramInfo = $Bru->GetParamInfoByCode($cycloApTableName, $cycloBpTableName, $paramCode);
     if ($paramInfo["paramType"] == PARAM_TYPE_AP) {
         $Bru->UpdateParamColor($cycloApTableName, $paramCode, $color);
     } else {
         if ($paramInfo["paramType"] == PARAM_TYPE_BP) {
             $Bru->UpdateParamColor($cycloBpTableName, $paramCode, $color);
         }
     }
     unset($Bru);
 }