// Displays orders in the grid. Allows the user
// to sort the entries, filter their search, and search for a specific person.
// Authors:
// Cameron Hayes
// Mac Stephens

unit View.Orders;

interface

uses
  System.SysUtils, System.Generics.Collections, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
  WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
  WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
  ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
  XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset,
  WEBLib.Grids;

type
  TFViewOrders = class(TWebForm)
    XDataWebClient1: TXDataWebClient;
    xdwdsOrders: TXDataWebDataSet;
    lblEntries: TWebLabel;
    wdsOrders: TWebDataSource;
    xdwdsOrderscompanyName: TStringField;
    xdwdsOrdersjobName: TStringField;
    xdwdsOrdersorderDate: TStringField;
    xdwdsOrdersproofDue: TStringField;
    xdwdsOrdersproofDone: TStringField;
    xdwdsOrdersartDue: TStringField;
    xdwdsOrdersartDone: TStringField;
    xdwdsOrdersmountDue: TStringField;
    xdwdsOrdersmountDone: TStringField;
    xdwdsOrdersshipDue: TStringField;
    xdwdsOrdersshipDone: TStringField;
    xdwdsOrdersprice: TStringField;
    xdwdsOrdersID: TStringField;
    xdwdsOrdersqbRefNum: TStringField;
    xdwdsOrderscolors: TStringField;
    btnAddOrder: TWebButton;
    btnSearch: TWebButton;
    xdwdsOrdersplateDue: TStringField;
    xdwdsOrdersplateDone: TStringField;
    xdwdsOrdersorderType: TStringField;
    WebButton1: TWebButton;
    btnPDF: TWebButton;
    wdsCustomers: TWebDataSource;
    xdwdsCustomers: TXDataWebDataSet;
    xdwdsCustomersNAME: TStringField;
    xdwdsCustomersID: TIntegerField;
    xdwdsCustomersCURR_ID: TIntegerField;
    xdwdsSave: TXDataWebDataSet;
    wdsSave: TWebDataSource;
    xdwdsSaveCURR_ID: TIntegerField;
    wdbtcOrders: TWebDBTableControl;
    wcbPageSize: TWebComboBox;
    wlcbOrderBy: TWebLookupComboBox;
    edtSearch: TWebEdit;
    pnlMessage: TWebPanel;
    lblMessage: TWebLabel;
    btnCloseNotification: TWebButton;
    procedure WebFormCreate(Sender: TObject);
    procedure btnAddOrderClick(Sender: TObject);
    procedure btnSearchClick(Sender: TObject);
    procedure btnCloseNotificationClick(Sender: TObject);
    procedure WebFormShow(Sender: TObject);
    procedure btnPDFClick(Sender: TObject);
    procedure wcbPageSizeChange(Sender: TObject);
    procedure wlcbOrderByChange(Sender: TObject);
    procedure wdbtcOrdersDblClickCell(Sender: TObject; ACol, ARow: Integer);
    procedure wdbtcOrdersClickCell(Sender: TObject; ACol, ARow: Integer);
    procedure WebButton1Click(Sender: TObject);
  private
    FChildForm: TWebForm;
    procedure ClearTable();
    procedure GeneratePagination(TotalPages: Integer);
    function GenerateSearchOptions(): string;
    procedure orderEntry(orderInfo, customerInfo, mode, orderType: string);
    procedure HideNotification();
    procedure ShowNotification(Notification: string);
    procedure ShowAddOrderForm();
    procedure ShowSearchForm();
    procedure ShowSetStatusForm();
    [async] procedure GetOrders(searchOptions: string);
    [async] procedure GenerateReportPDF;
    [async] procedure SetStatus(statusInfo: string);
    var
      PageNumber: integer;
      PageSize: integer;
      TotalPages: integer;
      OrderID: string;
      CompanyID: string;
      JobName: string;
      orderType: string;

      //Status 1
      StartDate1: string;
      EndDate1: string;
      filterType1: string;
      null1: boolean;

      //Status 2
      StartDate2: string;
      EndDate2: string;
      filterType2: string;
      null2: boolean;

      OrderBy: string;
      filters: boolean;
      info: string;
      row: integer;
  public
    class function CreateForm(AElementID, Info: string): TWebForm;

  end;

var
  FViewOrders: TFViewOrders;

implementation

uses
  XData.Model.Classes, View.Main, View.AddOrder, View.Search, View.SetStatus;

{$R *.dfm}

procedure TFViewOrders.btnPDFClick(Sender: TObject);
begin
  GenerateReportPDF;
end;

[async] procedure TFViewOrders.GenerateReportPDF;
// sends the search to the server which then sends back a pdf of the results
var
  xdcResponse: TXDataClientResponse;
  searchOptions, pdfURL: string;
  jsObject: TJSObject;
begin
  searchOptions := GenerateSearchOptions;

  // Call the server method to generate the PDF
  xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateReportPDF', [searchOptions]));
  jsObject := JS.TJSObject(xdcResponse.Result);
  pdfURL := JS.toString(jsObject.Properties['value']);

  // Open the PDF in a new browser tab without needing a different form
  // This method is much faster too, even for large datasets
  window.open(pdfURL, '_blank');
end;



procedure TFViewOrders.WebButton1Click(Sender: TObject);
begin
  if OrderID <> '' then
    ShowSetStatusForm()
  else
    ShowNotification('Failure:Please select an order');
end;

procedure TFViewOrders.WebFormCreate(Sender: TObject);
// Initializes important values:
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
// TotalPages: Total number of pages returned from the search.
// PageSize: Number of entries per page.
var
  today: TDateTime;
begin
  DMConnection.ApiConnection.Connected := True;
  PageNumber := 1;
  TotalPages := 1; // Initial total pages

  //Status 1
  startDate1 := FormatDateTime('yyyy/mm/dd', 0);
  endDate1 := FormatDateTime('yyyy/mm/dd', 0);
  filterType1 := '';
  null1 := false;

  //Status 2
  startDate2 := FormatDateTime('yyyy/mm/dd', 0);
  endDate2 := FormatDateTime('yyyy/mm/dd', 0);
  filterType2 := '';
  null2 := false;

  orderType := '';

  //today := TDateTime.Today;
  wcbPageSize.Text := '500';
  PageSize := 500;
  wlcbOrderBy.DisplayText := 'Order Date';
  OrderBy := 'o.ORDER_DATE DESC';
  getOrders(GenerateSearchOptions());
end;


procedure TFViewOrders.WebFormShow(Sender: TObject);
begin
  if info <> '' then
    ShowNotification(info)
  else
    HideNotification();
end;


procedure TFViewOrders.wlcbOrderByChange(Sender: TObject);
begin
  OrderBy := wlcbOrderBy.Value;
  getOrders(generateSearchOptions());
end;

class function TFViewOrders.CreateForm(AElementID, Info: string): TWebForm;
var
  localInfo: string;
begin
  localInfo := info;
  Application.CreateForm(TFViewOrders, AElementID, Result,
    procedure(AForm: TObject)
    begin
      with TFViewOrders(AForm) do
      begin
        TFViewOrders(AForm).info := LocalInfo;
      end;
    end
  );
end;


procedure TFViewOrders.ShowAddOrderForm();
// displays the add order pop-up so the user can choose a customer
var
  newform: TFAddOrder;
begin
  newform := TFAddOrder.CreateNew;

  newform.Caption := 'Select Customer and Order Type';
  newForm.Popup := True;
  newForm.Border := fbDialog;

  // used to manage Back button handling to close subform
  window.location.hash := 'subform';

  newform.ShowModal(
    procedure(AValue: TModalResult)
    begin
      if newform.confirm then
      begin
        if newform.cbCorrugatedPlate.Checked then
          orderType := 'corrugated'
        else if newform.cbWebPlate.Checked then
          orderType := 'web'
        else
          orderType := 'cutting';
        orderEntry('', newForm.edtID.Text, 'ADD', orderType);
      end;
    end
  );
end;

procedure TFViewOrders.ShowSearchForm();
// displays the search pop-up that allows the user to filter the order list
var
  newform: TFSearch;
begin
  newform := TFSearch.CreateNew;

  newform.Caption := 'Input Search Options';
  newForm.Popup := True;
  newForm.Border := fbDialog;
  newForm.searchOptions := generateSearchOptions();

  // used to manage Back button handling to close subform
  window.location.hash := 'subform';

  newform.ShowModal(
    procedure(AValue: TModalResult)
    var
      searchOptions: string;
    begin
      if newform.confirm then
      begin
        pageNumber := 1;

        // Status 1
        startDate1 := FormatDateTime('yyyy/mm/dd', newform.dtpStartDate1.Date);
        endDate1 := FormatDateTime('yyyy/mm/dd', newform.dtpEndDate1.Date);
        filterType1 := newform.wcbFilterType1.Text;
        null1 := newform.cbNull1.Checked;

        // Status 2
        startDate2 := FormatDateTime('yyyy/mm/dd', newform.dtpStartDate2.Date);
        endDate2 := FormatDateTime('yyyy/mm/dd', newform.dtpEndDate2.Date);
        filterType2 := newform.wcbFilterType2.Text;
        null2 := newform.cbNull2.Checked;

        jobName := newform.edtJobName.Text;
        orderID := newform.edtOrderID.Text;
        companyID := newform.edtCompanyID.Text;
        orderType := newform.wcbOrderType.Text;

        searchOptions := generateSearchOptions();
        edtSearch.Text := searchOptions;
        getOrders(searchOptions);
      end;
    end
  );
end;

procedure TFViewOrders.ShowSetStatusForm();
// displays the search pop-up that allows the user to filter the order list
var
  newform: TFSetStatus;
begin
  newform := TFSetStatus.CreateNew;

  newform.Caption := 'Input Search Options';
  newForm.Popup := True;
  newForm.Border := fbDialog;
  newForm.OrderID := OrderID;
  newForm.JobName := wdbtcOrders.Cells[2, row];
  newForm.ShipDue := StrToDateTime(wdbtcOrders.Cells[13, row]);
  newForm.MountDue := StrToDateTime(wdbtcOrders.Cells[11, row]);
  newForm.PlateDue := StrToDateTime(wdbtcOrders.Cells[9, row]);
  newForm.ArtDue := StrToDateTime(wdbtcOrders.Cells[7, row]);

  // used to manage Back button handling to close subform
  window.location.hash := 'subform';

  newform.ShowModal(
    procedure(AValue: TModalResult)
    var
      searchOptions: string;
      StatusJSON: TJSONObject;
    begin
      if newform.confirm then
      begin
        StatusJSON := TJSONObject.Create;
        StatusJSON.AddPair('ORDER_ID', OrderID);
        StatusJSON.AddPair('date', DateTimeToStr(newform.dtpDate.Date));
        StatusJSON.AddPair('status', newform.wlcbStatus.Value);
        StatusJSON.AddPair('USER_ID', 1011);
        StatusJSON.AddPair('mode', 'EDIT');
        StatusJSON.AddPair('staff_fields_ship_date', DateToStr(newForm.dtpNewShipDue.Date));
        StatusJSON.AddPair('staff_fields_mount_due', DateToStr(newForm.dtpNewMountDue.Date));
        StatusJSON.AddPair('staff_fields_plate_due', DateToStr(newForm.dtpNewPlateDue.Date));
        StatusJSON.AddPair('staff_fields_art_due', DateToStr(newForm.dtpNewArtDue.Date));


        SetStatus(StatusJSON.ToString);
        OrderID := '';
        getOrders(GenerateSearchOptions());
      end;
    end
  );
end;

procedure TFViewOrders.SetStatus(statusInfo: string);
var
  xdcResponse: TXDataClientResponse;
  statusOptions: string;
begin
  xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.SetStatus', [statusInfo]));
end;


procedure TFViewOrders.wcbPageSizeChange(Sender: TObject);
begin
  PageSize := StrToInt(wcbPageSize.Text);
  getOrders(generateSearchOptions());
end;

procedure TFViewOrders.wdbtcOrdersClickCell(Sender: TObject; ACol,
  ARow: Integer);
begin
  OrderID := wdbtcOrders.Cells[0, ARow];
  row := ARow;
end;

procedure TFViewOrders.wdbtcOrdersDblClickCell(Sender: TObject; ACol,
  ARow: Integer);
begin
  OrderID := wdbtcOrders.Cells[0, ARow];
  orderType :=  wdbtcOrders.Cells[3, ARow].Split([' '])[0];
  orderEntry(OrderID, '', 'EDIT', orderType);
end;

procedure TFViewOrders.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
var
  PaginationElement, PageItem, PageLink: TJSHTMLElement;
  I, Start, Finish: Integer;
begin
  PaginationElement := TJSHTMLElement(document.getElementById('pagination'));
  PaginationElement.innerHTML := ''; // Clear existing pagination

  // Previous Button
  PageItem := TJSHTMLElement(document.createElement('li'));
  PageItem.className := 'page-item';
  if PageNumber = 1 then
    PageItem.classList.add('disabled');
  PageLink := TJSHTMLElement(document.createElement('a'));
  PageLink.className := 'page-link';
  PageLink.innerText := 'Previous';
  PageLink.setAttribute('href', 'javascript:void(0)');
  PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
  begin
    if PageNumber > 1 then
    begin
      Dec(PageNumber);
      GetOrders(GenerateSearchOptions());
    end;
  end);
  PageItem.appendChild(PageLink);
  PaginationElement.appendChild(PageItem);

  // Page Numbers

  if TotalPages <= 7 then
  begin
    for I := 1  to 7 do
    begin
      if I <= TotalPages then
      begin
        PageItem := TJSHTMLElement(document.createElement('li'));
        PageItem.className := 'page-item';
        if I = PageNumber then
          PageItem.classList.add('selected-number'); // Add the selected-number class
        PageLink := TJSHTMLElement(document.createElement('a'));
        PageLink.className := 'page-link';
        PageLink.innerText := IntToStr(I);
        PageLink.setAttribute('href', 'javascript:void(0)');
        PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
        var
          PageNum: Integer;
        begin
          PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
          PageNumber := PageNum;
          GetOrders(GenerateSearchOptions());
        end);
        PageItem.appendChild(PageLink);
        PaginationElement.appendChild(PageItem);
      end;
    end;
  end
  else
  begin
    if PageNumber <= 4 then
    // If page number is low enough no early elipsis needed
    Begin
      Start := 2;
      Finish := 5;
    End
    else if (PageNumber >= (TotalPages - 3)) then
    // If page number is high enough no late elipsis needed
    begin
      Start := TotalPages - 3;
      Finish := TotalPages - 1;
    end
    else
    begin
      Start := PageNumber - 1;
      Finish := PageNumber + 1;
    end;

    PageItem := TJSHTMLElement(document.createElement('li'));
    PageItem.className := 'page-item';
    if 1 = PageNumber then
      PageItem.classList.add('selected-number'); // Add the selected-number class
    PageLink := TJSHTMLElement(document.createElement('a'));
    PageLink.className := 'page-link';
    PageLink.innerText := '1';
    PageLink.setAttribute('href', 'javascript:void(0)');
    PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
    var
      PageNum: Integer;
    begin
      PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
      PageNumber := PageNum;
      GetOrders(GenerateSearchOptions());
    end);
    PageItem.appendChild(PageLink);
    PaginationElement.appendChild(PageItem);

    // Adds Elipse to pagination if page number is too big
    if PageNumber > 4 then
    begin
      PageItem := TJSHTMLElement(document.createElement('li'));
      PageItem.className := 'page-item';
      PageItem.classList.add('disabled');
      PageLink := TJSHTMLElement(document.createElement('a'));
      PageLink.className := 'page-link';
      PageLink.innerText := '...';
      PageLink.setAttribute('href', 'javascript:void(0)');
      PageItem.appendChild(PageLink);
      PaginationElement.appendChild(PageItem);
    end;


    // Adds Page, page - 1, and page + 1 to pagination
    for I := Start  to Finish do
    begin
      if ( I > 1) and (I < TotalPages) then
      begin
        PageItem := TJSHTMLElement(document.createElement('li'));
        PageItem.className := 'page-item';
        if I = PageNumber then
          PageItem.classList.add('selected-number'); // Add the selected-number class
        PageLink := TJSHTMLElement(document.createElement('a'));
        PageLink.className := 'page-link';
        PageLink.innerText := IntToStr(I);
        PageLink.setAttribute('href', 'javascript:void(0)');
        PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
        var
          PageNum: Integer;
        begin
          PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
          PageNumber := PageNum;
          GetOrders(GenerateSearchOptions());
        end);
        PageItem.appendChild(PageLink);
        PaginationElement.appendChild(PageItem);
      end;
    end;

    // adds ellipse if number is too small
    if PageNumber < TotalPages - 4 then
    begin
      PageItem := TJSHTMLElement(document.createElement('li'));
      PageItem.className := 'page-item';
      PageItem.classList.add('disabled');
      PageLink := TJSHTMLElement(document.createElement('a'));
      PageLink.className := 'page-link';
      PageLink.innerText := '...';
      PageLink.setAttribute('href', 'javascript:void(0)');
      PageItem.appendChild(PageLink);
      PaginationElement.appendChild(PageItem);
    end;

    if TotalPages <> 1 then
    begin
      PageItem := TJSHTMLElement(document.createElement('li'));
      PageItem.className := 'page-item';
      if TotalPages = PageNumber then
            PageItem.classList.add('selected-number');
      PageLink := TJSHTMLElement(document.createElement('a'));
      PageLink.className := 'page-link';
      PageLink.innerText := IntToStr(TotalPages);
      PageLink.setAttribute('href', 'javascript:void(0)');
      PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
      var
        PageNum: Integer;
      begin
        PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
        PageNumber := PageNum;
        GetOrders(generateSearchOptions());
      end);
    end;
    PageItem.appendChild(PageLink);
    PaginationElement.appendChild(PageItem);
  end;

  // Next Button
  PageItem := TJSHTMLElement(document.createElement('li'));
  PageItem.className := 'page-item';
  if PageNumber = TotalPages then
    PageItem.classList.add('disabled');
  PageLink := TJSHTMLElement(document.createElement('a'));
  PageLink.className := 'page-link';
  PageLink.innerText := 'Next';
  PageLink.setAttribute('href', 'javascript:void(0)');
  PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
  begin
    if PageNumber < TotalPages then
    begin
      Inc(PageNumber);
      GetOrders(GenerateSearchOptions());
    end;
  end);
  PageItem.appendChild(PageLink);
  PaginationElement.appendChild(PageItem);

end;


procedure TFViewOrders.GetOrders(searchOptions: string);
// retrieves a list of orders that fit a given search criteria
// searchOptions: search info to be sent to the server
var
  xdcResponse: TXDataClientResponse;
  orderList: TJSObject;
  orderListLength: integer;
  TotalPages: integer;
begin
  if PageNumber > 0 then
  begin
    asm
      startSpinner();
    end;
    xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetOrders', [searchOptions]));
    orderList := TJSObject(xdcResponse.Result);

    // Load data into the dataset
    xdwdsOrders.Close;
    xdwdsOrders.SetJsonData(orderList['data']);
    xdwdsOrders.Open;

    asm
      endSpinner();
    end;

    orderListLength := integer(orderList['count']);
    TotalPages := ( (orderListLength + PageSize - 1) div PageSize);

    if orderListLength = 0 then
    begin
      lblEntries.Caption := 'No entries found';
    end
    else if (PageNumber * PageSize) < orderListLength then
    begin
      lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
                            ' - ' + IntToStr(PageNumber * PageSize) +
                             ' of ' + IntToStr(orderListLength);
    end
    else if (PageNumber * PageSize) >= orderListLength then
    begin
       lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
                            ' - ' + IntToStr(orderListLength) +
                             ' of ' + IntToStr(orderListLength);
    end;

    // Optional: Continue using pagination if needed
    GeneratePagination(TotalPages);
  end;
end;


procedure TFViewOrders.btnAddOrderClick(Sender: TObject);
begin
  ShowAddOrderForm();
end;


procedure TFViewOrders.orderEntry(orderInfo, customerInfo, mode, orderType: string);
begin
  if orderType = 'corrugated' then
    FViewMain.ViewOrderEntryCorrugated(orderInfo, customerInfo, mode)
  else if orderType = 'web' then
    FViewMain.ViewOrderEntryWeb(orderInfo, customerInfo, mode)
  else
    FViewMain.ViewOrderEntryCuttingDie(orderInfo, customerInfo, mode);
end;

procedure TFViewOrders.btnCloseNotificationClick(Sender: TObject);
begin
  HideNotification();
end;

procedure TFViewOrders.btnSearchClick(Sender: TObject);
var
filterSection: TJSHTMLElement;
begin
  ShowSearchForm();
end;

procedure TFViewOrders.ClearTable();
// clears the table
var
  tbody: TJSHTMLElement;
begin
  tbody := TJSHTMLElement(document.getElementById('tblPhoneGrid').getElementsByTagName('tbody')[0]);
  tbody.innerHTML := '';
end;


function TFViewOrders.GenerateSearchOptions(): string;
// Generates searchOptions for GetOrders.
var
searchOptions: string;
begin
  searchOptions :=  '&pagenumber=' + IntToStr(PageNumber) +
                    '&pagesize=' + IntToStr(PageSize) +
                    '&orderby=' + OrderBy;

                    //Status 1
                    if ( (filterType1 <> '') and (filterType1 <> 'NONE') ) then
                    begin
                      searchOptions := searchOptions +
                      '&filterType1=' + filterType1 +
                      '&null1=' + BoolToStr(null1);
                      if (not (null1)) then
                      begin
                        searchOptions := searchOptions +
                        '&startDate1=' + startDate1 +
                        '&endDate1=' + endDate1;
                      end;
                    end;


                    // Status2
                    if ( (filterType2 <> '') and (filterType2 <> 'NONE') ) then
                    begin
                      searchOptions := searchOptions +
                      '&filterType2=' + filterType2 +
                      '&null2=' + BoolToStr(null2);
                      if (not (null2)) then
                      begin
                        searchOptions := searchOptions +
                        '&startDate2=' + startDate2 +
                        '&endDate2=' + endDate2;
                      end;
                    end;

                    if ( ( orderType <> '' ) AND ( orderType <> 'Any' ) ) then
                      searchOptions := searchOptions + '&orderType=' + orderType;

                    if jobName <> '' then
                      searchOptions := searchOptions + '&jobName=' + jobName;

                    if companyID <> '' then
                      searchOptions := searchOptions + '&companyID=' + companyID;

                    if orderID <> '' then
                      searchOptions := searchOptions + '&orderID=' + orderID;
  Result := searchOptions;
end;


procedure TFViewOrders.HideNotification;
begin
  pnlMessage.ElementHandle.hidden := True;
  info := '';
end;


procedure TFViewOrders.ShowNotification(Notification: string);
var
  splitNotification: TArray<string>;
begin
  if Notification <> '' then
  begin
    splitNotification := Notification.Split([':']);
    if(splitNotification[0] = 'Success') then
    begin
      asm
        var messageDiv = document.getElementById('view.login.message');
        messageDiv.classList.remove('alert-danger');
        messageDiv.classList.add('alert-success');
      end;
    end
    else
    begin
      asm
        var messageDiv = document.getElementById('view.login.message');
        messageDiv.classList.remove('alert-success');
        messageDiv.classList.add('alert-danger');
      end;
    end;
    lblMessage.Caption := splitNotification[1];
    pnlMessage.ElementHandle.hidden := False;
  end;
end;

end.
