B4J=true Group=Default Group ModulesStructureVersion=1 Type=Class Version=6.01 @EndOfDesignText@ 'Class module Sub Class_Globals Private ws As WebSocket 'ignore ' will hold our page information Public page As ABMPage ' page theme Private theme As ABMTheme ' to access the constants Private ABM As ABMaterial 'ignore ' name of the page, must be the same as the class name (case sensitive!) Public Name As String = "OtherPrint" Private ABMPageId As String = "" ' your own variables 'Dim ActiveUserId As Int Dim Filter As String = "" Dim ORIGFILTER As String 'Dim LastSort As String Dim UserType As String Dim UserId As Int Dim ActiveWork As String End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize ' build the local structure IMPORTANT! BuildPage End Sub Private Sub WebSocket_Connected (WebSocket1 As WebSocket) '----------------------MODIFICATION------------------------------- Log("Connected") ws = WebSocket1 ABMPageId = ABM.GetPageID(page, Name,ws) Dim session As HttpSession = ABM.GetSession(ws, ABMShared.SessionMaxInactiveIntervalSeconds) If session.IsNew Then session.Invalidate ABMShared.NavigateToPage(ws, "", "./") Return End If If ABMShared.NeedsAuthorization Then If session.GetAttribute2("IsAuthorized", "") = "" Then ABMShared.NavigateToPage(ws, ABMPageId, "../") Return End If End If ABM.UpdateFromCache(Me, ABMShared.CachedPages, ABMPageId, ws) If page.ComesFromPageCache Then ' when we have a page that is cached it doesn't matter if it comes or not from a new connection we serve the cached version. Log("Comes from cache") page.Refresh page.FinishedLoading Else If page.WebsocketReconnected Then Log("Websocket reconnected") ' when we have a client that doesn't have the page in cache and it's websocket reconnected and also it's session is new - basically when the client ' had internet problems and it's session (and also cache) expired before he reconnected so the user has content in the browser but we don't have ' any on the server. So we need to reload the page. ' when a client that doesn't have the page in cache and it's websocket reconnected but it's session is not new - when the client had internet ' problems and when he reconnected it's session was valid but he had no cache for this page we need to reload the page as the user browser has ' content, reconnected but we have no content in cache ABMShared.NavigateToPage (ws, ABMPageId, "./" & page.PageHTMLName) Else ' when the client did not reconnected it doesn't matter if the session was new or not because this is the websockets first connection so no dynamic ' content in the browser ... we are going to serve the dynamic content... Log("Websocket first connection") page.Prepare ConnectPage End If End If Log(ABMPageId) '----------------------MODIFICATION------------------------------- 'only ADMIN can enter this page UserType = session.GetAttribute2("UserType", "0") UserId = session.GetAttribute2("UserID", "0") If UserType<>"ADMIN" Then ABMShared.NavigateToPage(ws, ABMPageId,"../") Return End If Dim SQL As SQL=DBM.GetSQL ORIGFILTER=" WHERE [ΠΟΣΟ ΣΕ ΕΥΡΩ]>0 " Filter=ORIGFILTER ' UserID = page.ws.Session.GetAttribute2("UserID", "0") page.restoreNavigationBarPosition page.savenavigationbarposition page.NavigationBar.Clear ABMShared.UpdateNavigationBar(page, UserType,UserId) page.NavigationBar.REFRESH page.RestoreNavigationBarPosition ' Headers for tblWorks Dim works As List = DBM.SQLSelect(SQL, "SELECT TOP 1 ΠΕΛΑΤΗΣ, ΗΜΕΡΟΜΗΝΙΑ, ΣΧΟΛΙΑ, [ΤΥΠΟΣ ΣΥΝΑΛΛΑΓΗΣ], [ΠΟΣΟ ΣΕ ΕΥΡΩ], [ΕΙΔΟΣ ΠΑΡΑΣΤΑΤΙΚΟΥ], ΠΑΡΑΣΤΑΤΙΚΟ, ΚΑΤΑΣΤΗΜΑ, ΕΠΙΤΑΓΗ, ΜΕΤΡΗΤΟΙΣ FROM [ΣΥΝΠΕΛ365]") Dim tblFields As Map = works.Get(0) Dim i As Int Dim tblWorks As ABMTable = page.Component("tblWorks") Dim Headers(tblFields.Size), Themes(tblFields.Size), Datafields(tblFields.Size) As String Dim Visible(tblFields.Size), Sortable(tblFields.Size) As Boolean Dim Heights(tblFields.Size) As Int Dim coltitle As String For i=0 To tblFields.Size-1 coltitle=tblFields.GetKeyAt(i) Headers(i)=coltitle.ToUpperCase Themes(i)="bg" Heights(i)=0 Visible(i)=True Sortable(i)=False Datafields(i)="" Next tblWorks.SetHeaders(Headers) tblWorks.SetHeaderThemes(Themes) tblWorks.SetHeaderHeights(Heights) tblWorks.SetColumnVisible(Visible) tblWorks.SetColumnSortable(Sortable) tblWorks.SetColumnDataFields(Datafields) DBM.CloseSQL(SQL) ' so it represents the correct values, not the ones saved in the .html file IMPORTANT! LoadWorks(1) End Sub public Sub ConnectPage() Dim tblWorks, tblStages As ABMTable tblWorks.IsResponsive = False tblStages.IsResponsive = False ' IMPORTANT: we set usingQueriesToSort = true because we are going to handle the sorting, not the javascript sorting library ' When using Pagination, the sorting library does not know all the data ' SetColumnDataFields() is used when the user clicks on a column head to sort to return in the SortChanged() event and the GetSortColumn() And SetSortColumn() methods. tblWorks.Initialize(page, "tblWorks", True, True, True, "tbltheme") tblWorks.SetFooter("Σύνολο συναλλαγών: 0", 12,"bg") tblStages.Initialize(page, "tblStages",False,True,True, "tbltheme") page.CellR(1,1).AddComponent(tblWorks) page.CellR(1,1).AddComponent(tblStages) ' refresh the page page.Refresh ' Tell the browser we finished loading page.FinishedLoading ' restoring the navigation bar position page.RestoreNavigationBarPosition 'used to be in the depreciated Page_Ready() event! End Sub Private Sub WebSocket_Disconnected Log("Disconnected") End Sub Sub StagesHeader Dim SQL As SQL=DBM.GetSQL Dim Stages As List = DBM.SQLSelect(SQL, "SELECT TOP 1 [ΠΕΡΙΓΡΑΦΗ ΕΙΔΟΥΣ], ΜΜ, ΠΟΣΟΤΗΤΑ, [ΔΑΠ] FROM TDA2") 'Headers for tblStages Dim tblFields2 As Map = Stages.Get(0) Dim i As Int Dim tblStages As ABMTable = page.Component("tblStages") Dim Headers(tblFields2.Size), Themes(tblFields2.Size), Datafields(tblFields2.Size) As String Dim Visible(tblFields2.Size), Sortable(tblFields2.Size) As Boolean Dim Heights(tblFields2.Size) As Int Dim coltitle As String For i=0 To tblFields2.Size-1 coltitle=tblFields2.GetKeyAt(i) Headers(i)=coltitle.ToUpperCase Themes(i)="bg" Heights(i)=0 Visible(i)=True Sortable(i)=False Datafields(i)="" Next tblStages.SetHeaders(Headers) tblStages.SetHeaderThemes(Themes) tblStages.SetHeaderHeights(Heights) tblStages.SetColumnVisible(Visible) tblStages.SetColumnSortable(Sortable) tblStages.SetColumnDataFields(Datafields) DBM.CloseSQL(SQL) End Sub Sub Page_ParseEvent(Params As Map) Dim eventName As String = Params.Get("eventname") Dim eventParams() As String = Regex.Split(",",Params.Get("eventparams")) Log(eventName) If eventName = "beforeunload" Then Log("preparing for url refresh") ABM.RemoveMeFromCache(ABMShared.CachedPages, ABMPageId) Return End If If SubExists(Me, eventName) Then Params.Remove("eventname") Params.Remove("eventparams") Select Case Params.Size Case 0 CallSub(Me, eventName) Case 1 CallSub2(Me, eventName, Params.Get(eventParams(0))) Case 2 If Params.get(eventParams(0)) = "abmistable" Then Dim PassedTables As List = ABM.ProcessTablesFromTargetName(Params.get(eventParams(1))) CallSub2(Me, eventName, PassedTables) Else CallSub3(Me, eventName, Params.Get(eventParams(0)), Params.Get(eventParams(1))) End If Case Else ' cannot be called diretly, to many param CallSub2(Me, eventName, Params) End Select End If End Sub public Sub BuildTheme() ' start with the base theme defined in ABMShared theme.Initialize("pagetheme") theme.AddABMTheme(ABMShared.MyTheme) ' add additional themes specific for this page theme.AddTableTheme("tbltheme") theme.Table("tbltheme").ZDepth = ABM.ZDEPTH_1 theme.Table("tbltheme").AddCellTheme("bg") theme.Table("tbltheme").Cell("bg").BackColor = ABM.COLOR_BLUEGREY theme.Table("tbltheme").Cell("bg").ForeColor = ABM.COLOR_WHITE theme.Table("tbltheme").AddCellTheme("bgr") theme.Table("tbltheme").Cell("bgr").BackColor = ABM.COLOR_BLUEGREY theme.Table("tbltheme").Cell("bgr").ForeColor = ABM.COLOR_WHITE theme.Table("tbltheme").Cell("bgr").Align = ABM.TABLECELL_HORIZONTALALIGN_RIGHT theme.Table("tbltheme").AddCellTheme("bgc") theme.Table("tbltheme").Cell("bgc").BackColor = ABM.COLOR_BLUEGREY theme.Table("tbltheme").Cell("bgc").ForeColor = ABM.COLOR_WHITE theme.Table("tbltheme").Cell("bgc").Align = ABM.TABLECELL_HORIZONTALALIGN_CENTER theme.Table("tbltheme").AddCellTheme("nocolor") theme.Table("tbltheme").Cell("nocolor").ActiveBackColor = ABM.COLOR_BLUEGREY theme.Table("tbltheme").Cell("nocolor").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN2 theme.Table("tbltheme").AddCellTheme("nocolor0") theme.Table("tbltheme").Cell("nocolor0").ActiveBackColor = ABM.COLOR_CYAN theme.Table("tbltheme").Cell("nocolor0").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN5 theme.Table("tbltheme").Cell("nocolor0").BackColor = ABM.COLOR_CYAN theme.Table("tbltheme").Cell("nocolor0").BackColorIntensity = ABM.INTENSITY_LIGHTEN5 theme.Table("tbltheme").AddCellTheme("nocolor1") theme.Table("tbltheme").Cell("nocolor1").ActiveBackColor = ABM.COLOR_CYAN theme.Table("tbltheme").Cell("nocolor1").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN3 theme.Table("tbltheme").Cell("nocolor1").BackColor = ABM.COLOR_CYAN theme.Table("tbltheme").Cell("nocolor1").BackColorIntensity = ABM.INTENSITY_LIGHTEN3 theme.Table("tbltheme").AddCellTheme("nocolor2") theme.Table("tbltheme").Cell("nocolor2").ActiveBackColor = ABM.COLOR_RED theme.Table("tbltheme").Cell("nocolor2").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN5 theme.Table("tbltheme").Cell("nocolor2").BackColor = ABM.COLOR_RED theme.Table("tbltheme").Cell("nocolor2").BackColorIntensity = ABM.INTENSITY_LIGHTEN5 theme.Table("tbltheme").AddCellTheme("nocolor3") theme.Table("tbltheme").Cell("nocolor3").ActiveBackColor = ABM.COLOR_RED theme.Table("tbltheme").Cell("nocolor3").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN3 theme.Table("tbltheme").Cell("nocolor3").BackColor = ABM.COLOR_RED theme.Table("tbltheme").Cell("nocolor3").BackColorIntensity = ABM.INTENSITY_LIGHTEN3 theme.Table("tbltheme").AddCellTheme("positive") theme.Table("tbltheme").Cell("positive").BackColor = ABM.COLOR_GREEN theme.Table("tbltheme").Cell("positive").BackColorIntensity = ABM.INTENSITY_LIGHTEN3 theme.Table("tbltheme").Cell("positive").ActiveBackColor = ABM.COLOR_GREEN theme.Table("tbltheme").Cell("positive").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN1 'theme.Table("tbltheme").Cell("positive").Align = ABM.TABLECELL_HORIZONTALALIGN_RIGHT theme.Table("tbltheme").AddCellTheme("negative") theme.Table("tbltheme").Cell("negative").BackColor = ABM.COLOR_RED theme.Table("tbltheme").Cell("negative").BackColorIntensity = ABM.INTENSITY_LIGHTEN3 theme.Table("tbltheme").Cell("negative").ActiveBackColor = ABM.COLOR_RED theme.Table("tbltheme").Cell("negative").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN1 'theme.Table("tbltheme").Cell("negative").Align = ABM.TABLECELL_HORIZONTALALIGN_RIGHT theme.Table("tbltheme").AddCellTheme("points") theme.Table("tbltheme").Cell("points").ActiveBackColor = ABM.COLOR_BLUEGREY theme.Table("tbltheme").Cell("points").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN2 theme.Table("tbltheme").Cell("points").Align = ABM.TABLECELL_HORIZONTALALIGN_RIGHT theme.Table("tbltheme").AddCellTheme("openedit") theme.Table("tbltheme").Cell("openedit").ActiveBackColor = ABM.COLOR_BLUEGREY theme.Table("tbltheme").Cell("openedit").ActiveBackColorIntensity = ABM.INTENSITY_LIGHTEN2 theme.Table("tbltheme").Cell("openedit").Align = ABM.TABLECELL_HORIZONTALALIGN_CENTER ' add additional themes specific for this page theme.AddButtonTheme("bigblue") theme.Button("bigblue").BackColor = ABM.COLOR_LIGHTBLUE ' modal sheet theme.AddContainerTheme("modalcontent") theme.Container("modalcontent").BackColor = ABM.COLOR_WHITE ' modal sheet theme.AddContainerTheme("modalfooter") theme.Container("modalfooter").BackColor = ABM.COLOR_LIGHTBLUE End Sub public Sub BuildPage() ' initialize the theme BuildTheme ' initialize this page using our theme page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, 120, theme) page.ShowLoader=True page.PageTitle = "Συναλλαγές Πελατών" page.PageDescription = "Συναλλαγές Πελατών" page.PageHTMLName = "index.html" page.PageKeywords = "" page.PageSiteMapPriority = "" page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY page.PageCharset=Main.charset page.PageLanguage="el" ABMShared.BuildNavigationBar(page, "Συναλλαγές Πελατών", "../images/logo.png", "WorkFlow", "", "") ' create the page grid page.AddRowsM(1,True,0,0, "").AddCells12(1,"") page.AddRows(1,True, "").AddCellsOS(1,0,0,0,10,10,11,"").AddCellsOSMP(1,0,0,0,2,2,1,14,0,0,0,"") page.AddRows(4,True, "").AddCells12(1,"") page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components Dim searchIt As ABMInput searchIt.Initialize(page, "searchIt", ABM.INPUT_TEXT, "Search ...", False, "lightblue") page.CellR(1,1).AddComponent(searchIt) Dim btnSearch As ABMButton btnSearch.InitializeFloating(page, "btnSearch", "mdi-action-search", "") page.CellR(0,2).AddComponent(btnSearch) Dim pagination As ABMPagination pagination.Initialize(page, "pagination", 10, True, True, "") pagination.SetTotalNumberOfPages(0) page.CellR(1,1).AddComponent(pagination) End Sub ' clicked on the navigation bar Sub Page_NavigationbarClicked(Action As String, Value As String) Log(Action) page.SaveNavigationBarPosition If Action = "OtherPrint" Then Return If Action = "LogOff" Then ABMShared.LogOff(page) Return End If ABMShared.NavigateToPage(ws, ABMPageId,Value) End Sub Sub Page_SignedOffSocialNetwork(Network As String, Extra As String) page.ws.Session.SetAttribute("authType", "") page.ws.Session.SetAttribute("authName", "") page.ws.Session.SetAttribute("IsAuthorized", "") page.ws.Session.SetAttribute("UserType", "" ) page.ws.Session.SetAttribute("UserID", "" ) ABMShared.NavigateToPage(page.ws,ABMPageId, "../") End Sub private Sub LoadWorks(fromPage As Int) Dim tblWorks As ABMTable = page.Component("tblWorks") Dim SQL As SQL = DBM.GetSQL Dim numworks As Int = DBM.SQLSelect(SQL, "SELECT * FROM [ΣΥΝΠΕΛ365]" & ORIGFILTER).SIZE Dim works As List = DBM.SQLSelect(SQL, "SELECT ΠΕΛΑΤΗΣ, ΗΜΕΡΟΜΗΝΙΑ, ΣΧΟΛΙΑ, [ΤΥΠΟΣ ΣΥΝΑΛΛΑΓΗΣ], [ΠΟΣΟ ΣΕ ΕΥΡΩ], [ΕΙΔΟΣ ΠΑΡΑΣΤΑΤΙΚΟΥ], ΠΑΡΑΣΤΑΤΙΚΟ, ΚΑΤΑΣΤΗΜΑ, ΕΠΙΤΑΓΗ, ΜΕΤΡΗΤΟΙΣ FROM [ΣΥΝΠΕΛ365] " & Filter & " ORDER BY [ΗΜΕΡΟΜΗΝΙΑ] DESC OFFSET " & ((fromPage - 1) * 10) &" ROWS FETCH NEXT 10 ROWS ONLY") ' Log("size is " & works.Size & " " & numworks) If works.Size = 0 And fromPage > 1 Then ' we are on a page without any lines (maybe removed by other user?) DBM.CloseSQL(SQL) fromPage = fromPage - 1 LoadWorks(fromPage) Return End If tblWorks.SetFooter("Σύνολο συναλλαγών : " & numworks, 12,"bg") tblWorks.Clear Dim DATESTR As String For i = 0 To works.Size - 1 Dim tblFields As Map = works.Get(i) Dim rCellValues As List Dim rCellThemes As List rCellValues.Initialize rCellThemes.Initialize For j=0 To tblFields.Size-1 If tblFields.GetValueAt(j)<>Null Then If tblFields.GetKeyAt(j)="ημερομηνια" Then DATESTR=tblFields.GetValueAt(j) rCellValues.Add(DATESTR.SubString2(8,10) & "-" & DATESTR.SubString2(5,7) & "-" & DATESTR.SubString2(0,4)) Else If tblFields.GetKeyAt(j)="επιταγη" Then If tblFields.GetValueAt(j)=0 Then rCellValues.Add("OXI") Else rCellValues.Add("OXI") End If Else rCellValues.Add(tblFields.GetValueAt(j)) End If 'Log(tblFields.GetKeyAt(j)) Else rCellValues.Add("ΧΩΡΙΣ") End If rCellThemes.Add("nocolor" & (i Mod 2)) Next tblWorks.AddRow("uid" & i, rCellValues) tblWorks.SetRowThemes(rCellThemes) ' make sure you have as many items in rCellThemes as in rCellValues! Must follow IMMEDIATELY AFTER AddRow! Next tblWorks.Refresh DBM.CloseSQL(SQL) Dim pagination As ABMPagination = page.Component("pagination") If (numworks Mod 10 > 0) Or (numworks = 0) Then numworks = numworks/10 + 1 Else numworks = numworks/10 End If pagination.SetTotalNumberOfPages(numworks) pagination.SetActivePage(fromPage) pagination.Refresh Dim tblStages As ABMTable = page.Component("tblStages") tblStages.Clear tblStages.REFRESH End Sub private Sub LoadStages StagesHeader Dim tblStages As ABMTable = page.Component("tblStages") Dim SQL As SQL = DBM.GetSQL Dim WORKSTR As String WORKSTR=ActiveWork Log(WORKSTR) Dim Stages As List = DBM.SQLSelect(SQL, "SELECT [ΠΕΡΙΓΡΑΦΗ ΕΙΔΟΥΣ], ΜΜ, ΠΟΣΟΤΗΤΑ, [ΔΑΠ] FROM TDA2 WHERE REMARKS='" & WORKSTR &"'") 'Log(ActiveWork) 'Log(Stages.Size) tblStages.Clear Dim DATESTR As String For i = 0 To Stages.Size - 1 Dim tblFields As Map = Stages.Get(i) Dim rCellValues As List Dim rCellThemes As List rCellValues.Initialize rCellThemes.Initialize For j=0 To tblFields.Size-1 If tblFields.GetValueAt(j)<>Null Then If tblFields.GetKeyAt(j)="hmep" Then DATESTR=tblFields.GetValueAt(j) rCellValues.Add(DATESTR.SubString2(8,10) & "-" & DATESTR.SubString2(5,7) & "-" & DATESTR.SubString2(0,4)) Else rCellValues.Add(tblFields.GetValueAt(j)) End If 'Log(tblFields.GetKeyAt(j)) Else rCellValues.Add("ΧΩΡΙΣ") End If rCellThemes.Add("nocolor" & ((i Mod 2) +2)) Next tblStages.AddRow("uid" & i, rCellValues) tblStages.SetRowThemes(rCellThemes) ' make sure you have as many items in rCellThemes as in rCellValues! Must follow IMMEDIATELY AFTER AddRow! Next tblStages.Refresh DBM.CloseSQL(SQL) End Sub Sub pagination_PageChanged(OldPage As Int, NewPage As Int) ' do your stuff LoadWorks(NewPage) End Sub Sub tblWorks_Clicked(PassedRowsAndColumns As List) ' fill with the active values Dim tblCellInfo As ABMTableCell = PassedRowsAndColumns.Get(0) Dim TBLWORKS As ABMTable = page.Component(tblCellInfo.TableName) If TBLWORKS.GetString(tblCellInfo.Row, 6) = "ΧΩΡΙΣ" Then ActiveWork= 0 Else ActiveWork= TBLWORKS.GetString(tblCellInfo.Row, 6) End If 'Log(ActiveWork) LoadStages End Sub Sub btnSearch_Clicked(Target As String) DoSearch End Sub Sub searchIt_EnterPressed(Value As String) DoSearch End Sub Sub DoSearch() Dim searchIt As ABMInput = page.Component("searchIt") If searchIt.text <> "" Then If ORIGFILTER="" Then Filter = " WHERE (ΠΕΛΑΤΗΣ LIKE '%" & searchIt.text & "%') " Else Filter= ORIGFILTER & " AND ΠΕΛΑΤΗΣ LIKE '%" & searchIt.text & "%' " End If Else Filter=ORIGFILTER End If ' reload the table LoadWorks(1) End Sub