B4J=true Group=Default Group ModulesStructureVersion=1 Type=Class Version=2.9 @EndOfDesignText@ ' MAP ===================================================================== Sub Class_Globals Private ws As WebSocket Type wsConbut (Number As Int) Private state As wsCon ' ======================================================== HTML varibles ' Identified in index becomes a varible that can be ' edited in B4J with Style... ' Private bod As JQueryElement Private bkgrd As JQueryElement Private acctid As JQueryElement Private userpwd As JQueryElement Private username As JQueryElement Private listbox1 As JQueryElement ' Notes Private notesbtn As JQueryElement Private sav_n As JQueryElement Private add_n As JQueryElement Private del_n As JQueryElement ' Appointments Private calendarbtn As JQueryElement Private sav_a As JQueryElement Private add_a As JQueryElement Private del_a As JQueryElement Private apptchg As JQueryElement Private cost As JQueryElement ' Expenses Private expensebtn As JQueryElement Private viw_e As JQueryElement Private add_e As JQueryElement Private del_e As JQueryElement ' Search Private searchbtn As JQueryElement ' Campus Private campusbtn As JQueryElement Private sav_b As JQueryElement Private add_b As JQueryElement Private del_b As JQueryElement Private del_bc As JQueryElement Private savblg As JQueryElement Private chgbldg As JQueryElement Private newname As JQueryElement Private kepbldg As JQueryElement Private campid As JQueryElement Private campname As JQueryElement Private blgid As JQueryElement Private blgname As JQueryElement Private headertext As JQueryElement Private helperFields As JQueryElement Private clickedline,sendclicked As JQueryElement Private caldate As JQueryElement Private thetext,savxx,addxx,delxx As JQueryElement' whereyoutype is not used but thetext is Private cata As JQueryElement ' Timer Dim Timer1,Timer2 As Timer ' Local varibles Private fmsg,fmsgid,fmsgdt,fmsgdtu,havetext As String Private ckpwd,ckname,uname As String Private fPath,sPath As String Private SelLoc As String ' Selected location Building, Office, Desk ... Dim ItemCnt As Int Dim FrSptX As Boolean ' DataBase Connections Private Q_UPDATE = "q_update" As String Private Q_INSERT = "q_insert" As String Private Q_DELETE = "q_delete" As String Dim CON_URL As String Private Get_Notes = "get_notes" As String Private Get_Note = "get_note" As String Private Get_Appts = "get_appts" As String Private Get_Appt = "get_appt" As String Private Get_Expenses = "get_expenses" As String Private Get_Expense = "get_expense" As String Private New_Expense = "new_expense" As String Private New_DT = "new_dt" As String Private Get_Bldgs = "get_bldgs" As String 'Private Get_Offs = "get_offs" As String Private Guest = "guest" As String Private Guest_Name,Guest_ID As String Dim NxtBlgID = "nxtblgid" As String Dim NxtOffID = "nxtoffid" As String Dim NxtDskID = "nxtdskid" As String Dim NextBlgID,NextOffID,NextDskID As String Dim QueryResponse As String ' ====================== Type wsCon (Number As Int) Private state As wsCon ' ====================== Dim Blgtf,Offtf,Dsktf,Fldtf,Spttf,tfRes As String Private SkipIt As Boolean Private ChgDate As Boolean ' ==================================== Private Valid_Acct = "valid_acct" As String End Sub Public Sub Initialize Timer1.Initialize("Timer1",1000) Timer1.Enabled = False Timer2.Initialize("Timer2",1000) Timer2.Enabled = False ChgDate = False End Sub ' The user opens via browser :80. The html file index.html is displayed. localhost:80 ' Confrim astrophe checking (ShowText = ShowText.Replace ("'", "`")) for Update and Inser queries ' The fields BlgNte, OffNte and DskNte from the table ACME_ABOD are now OBE or should be. ' The field of ItemCap from the ACME_Appts table are now OBE or should be. ' The field of FldLbl from the ACME_Folder table are now OBE or should be. ' The field of Title from the ACME_Notes table are now OBE or should be. ' The field of SptName from the ACME_Support table are now OBE or should be. ' ItemCap, FldLbl, Title,, SptName Private Sub WebSocket_Connected (WebSocket1 As WebSocket) Log("Connected") ws = WebSocket1 ' ==================== Dim session As HttpSession = ws.UpgradeRequest.GetSession If session.HasAttribute("state") = False Then state.Initialize state.Number = Rnd(1, 101) session.SetAttribute("state", state) 'sets a reference to the state object. Log($"Creating new state. Number = ${state.Number}"$) Else state = session.GetAttribute("state") Log($"Reusing previous state. Number = ${state.Number}"$) End If ' ==================== Dim demoListObjects As List demoListObjects.Initialize Dim g1 As Int g1 = 0 Dim ShowPWD As String = GetPWD Dim ShowUser As String = GetUser 'headertext.SetHtml("Grok Ver Adv 1.21 written by Bill Cook and Christopher Gumpper.
Grok is data management and organizational tool composed of five catagories (the colored buttons below). These buttons represent a global picture of your Village/Campus. Leave the Login and PWD blank to tour Gilligan's Island.") HideAll ShowBldgs SelLoc = "Nav" listbox1.sethtml("") ' Campus, Building PostData("SELECT accountID,userName,password,HomeDesk,HomePWD,HomeID FROM Acme_Accounts Where userName = " & "'" & ShowUser & "'" & " AND Rank = " & "'" & g1 & "'" & " ",Valid_Acct) End Sub ' =============================== Gather URL Varibles Sub GetId Dim retVal As Future = campid.GetVal fmsgid = retVal.Value Return fmsgid End Sub Sub GetName Dim retVal As Future = campname.GetVal fmsg = retVal.Value Return fmsg End Sub Sub GetText Dim retVal As Future = thetext.GetVal havetext = retVal.value Return havetext End Sub Private Sub GetPWD As String Dim retVal As Future = userpwd.GetVal ckpwd = retVal.Value Return ckpwd End Sub Private Sub GetUser As String Dim retVal As Future = username.GetVal ckname = retVal.Value Return ckname End Sub ' ################################### Sub campname_click(params As Map) cata.SetHtml("List of Buildings") End Sub ' =============================== Private Sub WebSocket_Disconnected 'Not used End Sub ' =============================== Logins Sub GuestDesk Dim ShowPWD As String = GetPWD Dim ShowUser As String = GetUser 'Dim g1 As Int 'g1 = 0 PostData("SELECT acctID,GuestDesk,GuestPWD,DskID,Rank,Parent From Acme_Guest Where Parent = " & "'" & ShowUser & "'" & " ",Guest) End Sub Sub Launch Log("Init Butler") SelLoc = "Bldg" Dim g1 As Int g1 = 0 PostData("SELECT Building as entity,BlgID FROM Acme_ABOD Where Account = " & "'" & Main.FixAcctID & "'" & " AND Rank2 = " & "'" & g1 & "'" & " group by Building",Get_Bldgs) End Sub Sub LaunchGuest Main.CurDskName = Guest_Name ' Guest_ID ws.Eval("window.location.replace('indexhome.html?dskid="&Guest_ID & "&dskname=" &Guest_Name &", Rcd #"&"')", Null) ws.Flush End Sub ' ########################################################################## ' ########################################################################## ' ######################### Selected Dialogs ############################### ' Add Appointment, Change Appointment Date, Add a Building, Delete a Building ' Change Building Name ' ########################################################################## Sub add_a_click(params As Map) ' Add a new Appointment Select Calendar Dim ShowText As String = GetText ShowText = ShowText.Replace ("'", "`") SelLoc = "Appts" Dim tit,f10 As String ' f1 = account, f2 = tit, f3 = havetext,f4 = CreateDT Dim g1 As Int g1 = 0 ' For i = 0 To ShowText.length -1 ' LF = 10, CR = 13 ' If Asc(ShowText.SubString2(i,i+1)) = 10 Then ' Exit ' End If ' Next ' tit = ShowText.SubString2(0,i) ' ItemCap DateTime.DateFormat = "yyyy-MM-dd" f10 = DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) 'If tit.Length > 50 Then tit = tit.SubString2(0,50) PostData("INSERT into Acme_Appts(Account,ItemNote,A_date,CreateDT,Rank)" & " VALUES (" & "'" & Main.FixAcctID & "'" & "," & "'" & ShowText & "'" & "," & "'" & fmsgdtu & "'" & "," & "'" & f10 & "'" & "," & "'" & g1 & "'" & ")",Q_INSERT) ' SELECT ID ItemNote,A_date FROM Acme_Appts WHERE Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by A_date DESC",Get_Appts) thetext.SetVal("Click Calendar to Refresh the Appintment list") Timer1.Enabled = True End Sub Sub apptchg_click(params As Map) ' Appointment Date Change ChgDate = True ws.Alert("Select a date on the Calendar...") End Sub Sub add_b_click(params As Map) ' Add a Building ChgDate = False thetext.SetVal("Overwrite a New Building name here.") add_b.RunMethod("show", Null) sav_b.RunMethod("show", Null) del_b.RunMethod("show", Null) del_bc.RunMethod("hide", Null) chgbldg.RunMethod("show", Null) kepbldg.RunMethod("hide", Null) End Sub Sub del_b_click(params As Map) ' Delete a Building ChgDate = False thetext.SetVal("Select a Building below to Delete.") add_b.RunMethod("show", Null) sav_b.RunMethod("hide", Null) del_b.RunMethod("show", Null) del_bc.RunMethod("show", Null) chgbldg.RunMethod("show", Null) kepbldg.RunMethod("hide", Null) SelLoc = "DelBlg" End Sub Sub chgbldg_click(params As Map) SelLoc = "ChgBlgName" thetext.SetVal("Select a Building below to ReName.") add_b.RunMethod("Show", Null) sav_b.RunMethod("hide", Null) del_b.RunMethod("show", Null) del_bc.RunMethod("hide", Null) chgbldg.RunMethod("show", Null) kepbldg.RunMethod("show", Null) End Sub ' ########################################################################## ' ########################################################################## ' ######### The Buttons Notes, Calendar, Expenses, Search, Campus ######### ' ########################################################################## ' ########################################################################## Sub notesbtn_click(params As Map) ' Only in html Dim g1 As Int g1 = 0 ChgDate = False SelLoc = "Notes" HideAll ShowNotes thetext.SetVal("Note...") listbox1.SetHtml("") ws.Eval("$('#listbox1').removeClass('hidden');",Null) ws.Eval("$('#calendar').addClass('hidden');",Null) PostData("SELECT Caption,ID,CreateDT FROM Acme_Notes WHERE Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by CreateDT DESC ",Get_Notes) End Sub Sub calendarbtn_click(params As Map) Dim g1 As Int g1 = 0 HideAll ShowAppts ChgDate = False thetext.SetVal("Appointments...") cata.SetHtml("List of Appointments") SelLoc = "Appts" savxx.SetHtml("Save Appt Chg") addxx.SetHtml("Add Appt") delxx.SetHtml("Delete Appt") PostData("SELECT ItemNote,ID,A_date FROM Acme_Appts WHERE Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by A_date DESC",Get_Appts) ws.Eval("$('#cata').removeClass();$('#cata').addClass('btn btn-warning');",Null) ws.Eval("$('#calendar').removeClass('hidden');",Null) ' Displays the Calendar you can move this function to the "add an appointment" button End Sub Sub expensebtn_click(params As Map) Dim g1 As Int g1 = 0 HideAll ShowExpense ChgDate = False SelLoc = "Expense" thetext.SetVal("Please select a Expense below to save changes Click Save the ...") listbox1.SetHtml("") Dim f1 As String f1 = DateTime.GetYear(DateTime.Now) PostData("SELECT ResNote,Expense,Mileage,Cost,Hours,Gals,Value,BlgID,ID FROM Acme_Resources WHERE Account = " & "'" & Main.FixAcctID & "'" & "AND Rank = " & "'" & g1 & "'" & " Order by CreateDT",Get_Expenses) ws.Eval("$('#calendar').addClass('hidden');",Null) ws.Eval("$('#cata').removeClass();$('#cata').addClass('btn btn-success');",Null) End Sub Sub searchbtn_click(params As Map) ChgDate = False thetext.SetVal("Searching ...") cata.SetHtml("Search the Campus") SelLoc = "Search" Dim f1,f2 As String f1 = "Campus" f2 = "All Items" ws.Eval("window.open('indexsearch.html?searchid="&f2 & "&searchname=" & f1 &","&"')", Null) ws.Eval("$('#cata').removeClass();$('#cata').addClass('btn btn-danger');",Null) ws.Eval("$('#calendar').addClass('hidden');",Null) End Sub Sub campusbtn_click(params As Map) Dim g1 As Int g1 = 0 HideAll ShowBldgs ChgDate = False thetext.SetVal("View the Building(s) ...") listbox1.SetHtml("") SelLoc = "Campus" savxx.SetHtml("Save New Building") addxx.SetHtml("Add a Bldg") delxx.SetHtml("Delete Bldg") PostData("SELECT Building as entity,BlgID FROM Acme_ABOD Where Account = " & "'" & Main.FixAcctID & "'" & " AND Rank1 = " & "'" & g1 & "'" & "group by Building",Get_Bldgs) ws.Eval("$('#cata').removeClass();$('#cata').addClass('btn btn-info');",Null) ws.Eval("$('#calendar').addClass('hidden');",Null) End Sub ' ########################################################################## ' ########################################################################## ' ################## View other TAB Cost ???? ############################# ' ########################################################################## ' ########################################################################## Sub cost_click(params As Map) ws.Eval("window.open('indexreso.html?resid="&fmsgid & "&resname=" & fmsg &", ID "&"')", Null) ' fmsgid derived from ListBox ws.Flush End Sub Sub viw_e_click(params As Map) ws.Eval( "window.open('indexreso.html?resid="&fmsgid & "&resname=" & fmsg &", Res "&"')", Null) ws.Flush End Sub ' ########################################################################## ' ########################################################################## ' ################# Update Note, Appt, Bldg Name ########################### ' ########################################################################## ' ########################################################################## Sub sav_n_click(params As Map) ' ID,Account,Title,Caption,CreateDT FROM Acme_Notes SelLoc = "Notes" 'Dim tit As String ' f1 = account, f2 = tit, f3 = havetext,f4 = CreateDT Dim ShowText As String = GetText ' For i = 0 To ShowText.length -1 ' LF = 10, CR = 13 ' If Asc(ShowText.SubString2(i,i+1)) = 10 Then ' Exit ' End If ' Next ' tit = ShowText.SubString2(0,i) ' If tit.Length > 50 Then tit = tit.SubString2(0,50) PostData("UPDATE Acme_Notes SET Caption = " & "'" & ShowText & "'" & " WHERE ID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) Timer1.Enabled = True End Sub Sub sav_a_click(params As Map) Dim ShowText As String = GetText ShowText = ShowText.Replace ("'", "`") SelLoc = "Appts" For i = 0 To ShowText.Length - 1 If ShowText.SubString2(i,i+1) = ":" Then havetext = ShowText.SubString2(i+1, ShowText.Length) Exit End If Next PostData("UPDATE Acme_Appts SET ItemNote = " & "'" & havetext & "'" & " WHERE ID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) Timer1.Enabled = True End Sub Sub kepbldg_click(params As Map) SelLoc = "BlgChg" Dim ShowText As String = GetText ShowText = ShowText.Replace ("'", "`") SelLoc = "BlgChg" For i = 0 To ShowText.Length - 1 If ShowText.SubString2(i,i+1) = ":" Then havetext = ShowText.SubString2(i+1, ShowText.Length) Exit End If Next PostData("UPDATE Acme_ABOD SET Building = " & "'" & havetext & "'" & " WHERE BlgID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) Timer1.Enabled = True End Sub ' ########################################################################## ' ########################################################################## ' ################ Insert Note, Expense, Building ########################## ' ########################################################################## ' ########################################################################## Sub add_n_click(params As Map) ' ID,Account,Title,Caption,CreateDT FROM Acme_Notes SelLoc = "Notes" Dim tit,f10 As String ' f1 = account, f2 = tit, f3 = havetext,f4 = CreateDT Dim g1 As Int g1 = 0 Dim ShowText As String = GetText ShowText = ShowText.Replace ("'", "`") ' For i = 0 To ShowText.length -1 ' LF = 10, CR = 13 ' If Asc(ShowText.SubString2(i,i+1)) = 10 Then ' Exit ' End If ' Next ' tit = ShowText.SubString2(0,i) DateTime.DateFormat = "yyyy-MM-dd" f10 = DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) If tit.Length > 50 Then tit = tit.SubString2(0,50) PostData("INSERT into Acme_Notes(Account,Caption,CreateDT,Rank)" & " VALUES (" & "'" & Main.FixAcctID & "'" & "," & "'" & ShowText & "'" & "," & "'" & f10 & "'" & "," & "'" & g1 & "'" & ")",Q_INSERT) ' 1Account,2Caption,3CreateDT,4Rank 1 2 3 Timer1.Enabled = True End Sub Sub add_e_click(params As Map) ' Add expense Dim f1,f2,f3,f4,f5,f6,f7 As String Dim g1 As Int g1 = 0 DateTime.DateFormat = "yyyy-MM-dd" f1 = Main.FixAcctID f2 = "Temp Expense" f3 = "0.00" f4 = "0.0" f5 = DateTime.GetYear(DateTime.Now) f6 = DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) New_DT = f6 f7 = DateTime.GetYear(DateTime.Now) 'PostData("INSERT into Acme_Resources(Account,ResNote,ResCost,ResMileage,Year,CreateDT,ExpYear,Rank)" & " VALUES (" & "'" & f1 & "'" & "," & "'" & f2 & "'" & "," & "'" & f3 & "'" & "," & "'" & f4 & "'" & "," & "'" & f5 & "'" & "," & "'" & f6 & "'" & "," & "'" & f7 & "'" & "," & "'" & g1 & "'" & ")",Q_INSERT) PostData("INSERT into Acme_Resources(Account,ResNote,Cost,Mileage,Year,CreateDT,TransYear,Rank)" & " VALUES (" & "'" & f1 & "'" & "," & "'" & f2 & "'" & "," & "'" & f3 & "'" & "," & "'" & f4 & "'" & "," & "'" & f5 & "'" & "," & "'" & f6 & "'" & "," & "'" & f7 & "'" & "," & "'" & g1 & "'" & ")",Q_INSERT) SelLoc = "Expense" Timer1.Enabled = True End Sub ' ================================== Saving a New Building ====================== Sub sav_b_click(params As Map) GetNextBlgID End Sub Sub GetNextBlgID PostData("Select BlgID from Acme_ABOD ORDER BY BlgID DESC LIMIT 1",NxtBlgID) End Sub ' -------------------- Get the next Office Sub GetNextOffID PostData("Select OffID from Acme_ABOD ORDER BY OffID DESC LIMIT 1",NxtOffID) End Sub ' -------------------- Get the next Desk Sub GetNextDskID ' Determine next DskID and goto Sub AddOff PostData("Select DskID from Acme_ABOD ORDER BY DskID DESC LIMIT 1",NxtDskID) End Sub Sub AddBldg DateTime.DateFormat = "yyyy-MM-dd" Dim ShowText As String = GetText ShowText = ShowText.Replace ("'", "`") addxx.SetVal(ShowText) Dim f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12 As String Dim g1 As Int g1 = 0 f1 = Main.FixAcctID f2 = ShowText f3 = NextBlgID f4 = "acmedfltbuilding.png" f5 = "New Office (Rename)" f6 = NextOffID f7 = "acmedfltoffice.png" f8 = "New Desk (Rename)" f9 = NextDskID f10 = "acmedfltdesk.png" f11 = DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now) f12 = "Building created " & DateTime.Date(DateTime.Now) PostData("INSERT into Acme_ABOD(Account,Building,BlgID,BlgPic,Office,OffID,OffPic,Desk,DskID,DskPic,CreateDT,Rank1,Rank2,Rank3,Rank4)" & " VALUES (" & "'" & f1 & "'" & "," & "'" & f2 & "'" & "," & "'" & f3 & "'" & "," & "'" & f4 & "'" & "," & "'" & f5 & "'" & "," & "'" & f6 & "'" & "," & "'" & f7 & "'" & "," & "'" & f8 & "'" & "," & "'" & f9 & "'" & "," & "'" & f10 & "'" & "," & "'" & f11 & "'" & "," & "'" & g1 & "'" & "," & "'" & g1 & "'" & "," & "'" & g1 & "'" & "," & "'" & g1 & "'" & ")",Q_INSERT) f3 = "Blg" & f3 PostData("INSERT into Acme_NotesBOD(NoteNo,Note,Rank)" & " VALUES (" & "'" & f3 & "'" & "," & "'" & f12 & "'" & "," & "'" & g1 & "'" & ")",Q_INSERT) thetext.SetText("The Building " & f2 & " created along with it's first Office and Desk.") Timer2.Enabled = True End Sub ' ########################################################################## ' ########################################################################## ' ################ Delete Note, Appt, Expense ############################## ' ########################################################################## ' ########################################################################## Sub del_n_click(params As Map) SelLoc = "Notes" Dim g1 As Int g1 = 1 PostData("UPDATE Acme_Notes SET Rank = " & "'" &g1 & "'" & " WHERE ID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) Timer1.Enabled = True End Sub Sub del_a_click(params As Map) SelLoc = "Appts" Dim g1 As Int g1 = 1 PostData("UPDATE Acme_Appts SET Rank = " & "'" & g1 & "'" & " WHERE ID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) Timer1.Enabled = True End Sub Sub del_e_click(params As Map) SelLoc = "Expense" Dim g1 As Int g1 = 1 PostData("UPDATE Acme_Resources SET Rank = " & "'" & g1 & "'" & " WHERE ID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) Timer1.Enabled = True End Sub Sub del_bc_click(params As Map) ws.Alert("Delete Building under construction") del_bc.RunMethod("hide", Null) Dim g1 As Int g1 = 1 PostData("UPDATE Acme_ABOD SET Rank1 = " & "'" & g1 & "'" & ", Rank2 = " & "'" & g1 & "'" & " WHERE BlgID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) Timer1.Enabled = True End Sub ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' ################################ DB Queries Execute Sub PostData(Query As String, JobName As String) ' $username = "cgumpper_cook"; ' $userpassword = "121cook!"; ' $databasename = "cgumpper_cook"; CON_URL = "https://portal.cgumpdesign.com/dev/HyperCG.php" Dim job As HttpJob job.Initialize(JobName, Me) job.PostString(CON_URL, Query) End Sub ' Database Queries: Valid_Acct, Guest, Get_Bldgs, Get_Notes, Get_Note, Get_Appts, Get_Appt, Get_Expenses, Get_Expense, NxtBlgID, NxtOffID, NxtDskID, New_Expense Sub JobDone(job As HttpJob) SkipIt = False If job.Success = True Then Dim res As String ' 1 res = job.GetString ' 2 If res.Length > 21 Then If res.SubString2(12,22) = "returned 0" Then SkipIt = True End If End If Log("Response from server: " & res) ' 3 Dim parser As JSONParser ' 4 parser.Initialize(res) ' 5 Dim ReturnData As List ' Dim Contacts as list ReturnData.Initialize ' contacts.initialize Dim FoundIt As Boolean FoundIt = False Select job.JobName Case Valid_Acct ' accountID,userName,password 'If SkipIt = False Then Dim ShowPWD As String = GetPWD Dim ShowUser As String = GetUser Main.boss = ShowUser ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim f1,f2,f3,f4,f5,f6 As String Dim ValidObjects As List ValidObjects.Initialize Dim M As Map M = ReturnData.Get(0) ValidObjects.Add(M) f1 = M.Get("accountID") f2 = M.Get("password") f3 = M.Get("HomePWD") f4 = M.Get("HomeDesk") f5 = M.Get("HomeID") f6 = M.Get("userName") campid.SetVal(f1) ' Campus AcctID campname.SetVal(f6) ' Campus name AKA username acctid.SetVal(f1) ws.Eval("document.cookie='acctID="&f1&"'",Null) Log("tried to set Cookie " &f1) If f2 = "10" And f6 = "Sample" Then Log("Launch Desk") Main.FixAcctID = M.Get("accountID") Main.filesFolder = "uploaded\acme" & f1 Log(Main.FixAcctID) FoundIt = True Launch ' Sample Data Exit End If If f2 = ShowPWD And f6 = ShowUser Then Main.FixAcctID = f1 Main.filesFolder = "uploaded\acme" & f1 Log(Main.FixAcctID) FoundIt = True Launch ' User Data Else GuestDesk ' Guest Data End If End If Log("1- Check Guest Desks") ' if this is line marked out Bummer Case Guest ReturnData = parser.NextArray If ReturnData.Size > 0 Then Dim FoundIt As Boolean FoundIt = False Dim f1,f2,f3,f4,f5,f6,f7,f8 As String ' accountID,userName,password,HomeDesk,HomePWD,HomeID Dim demoListObjects As List demoListObjects.Initialize For c = 0 To ReturnData.Size - 1 Dim M As Map M = ReturnData.Get(c) f1 = M.Get("Parent") f2 = M.Get("GuestPWD") f3 = M.Get("DskID") Main.FixBlgID = M.Get("BlgID") Main.FixOffID = M.Get("OffID") ' But also needs ' Blgid ' OffID If f1 = ckname And f2 = ckpwd Then FoundIt = True Main.FixAcctID = m.Get("acctID") Main.filesFolder = "uploaded\acme" & M.Get("acctID") Guest_Name = M.Get("GuestDesk") Guest_ID = M.Get("DskID") Log("Launch Guest Desk") LaunchGuest Exit End If Next End If If FoundIt = False Then thetext.SetVal("Improper Login was used. You are being directed to the Sample Data set.") Log("Launch Desk") Main.FixAcctID = "44" Main.filesFolder = "uploaded\acme" & 44 Log(Main.FixAcctID) FoundIt = True Launch ' Sample Data End If Case Get_Bldgs ' Buildings in the Campus ReturnData = parser.NextArray If ReturnData.Size > 0 Then Dim CampusObjects As List CampusObjects.Initialize For c = 0 To ReturnData.Size - 1 Dim M As Map M = ReturnData.Get(c) CampusObjects.Add(M) Next QueryResponse = CampusQuery(CampusObjects) listbox1.SetHtml(QueryResponse) Log("Get_BLDGS"&listbox1.GetHtml.Value) ' if this is line marked out Bummer End If Case Get_Notes 'Try ReturnData = parser.NextArray If ReturnData.Size > 0 Then Dim demoListObjects As List demoListObjects.Initialize For c = 0 To ReturnData.Size - 1 Dim M As Map M = ReturnData.Get(c) demoListObjects.Add(M) Next QueryResponse = NotesQuery(demoListObjects) listbox1.SetHtml(QueryResponse) 'ws.Eval("$('#cata').removeClass();$('#cata').addClass('btn btn-primary');",Null) Log("Get_BLDGS"&listbox1.GetHtml.Value) ' if this is line marked out Bummer End If ' Catch ' ws.Alert("No Notes found...") ' End Try Case Get_Note ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim TheNote As String Dim M As Map M = ReturnData.Get(0) TheNote = M.Get("Caption") thetext.SetVal(TheNote) ' Use .SetVal NOT .SetHtml Log(thetext.GetHtml.Value) ' if this is line marked out - Bummer End If Case Get_Appts ReturnData = parser.NextArray If ReturnData.Size > 0 Then 'thetext.SetVal("Please select a Appointment below. To save changes Click Save Appt Chg.") Dim demoListObjects As List demoListObjects.Initialize For c = 0 To ReturnData.Size - 1 Dim M As Map M = ReturnData.Get(c) demoListObjects.Add(M) Next QueryResponse = ApptQuery(demoListObjects) listbox1.SetHtml(QueryResponse) Log("Get_BLDGS"&listbox1.GetHtml.Value) ' if this is line marked out Bummer End If Case Get_Appt ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim M As Map M = ReturnData.Get(0) TheNote = M.Get("ItemNote") thetext.SetVal(m.Get("A_date") & ": " & TheNote) Log(thetext.GetHtml.Value) ' if this is line marked out - Bummer End If Case Get_Expenses If res.Contains("returned 0") Or res.Length < 2 Then thetext.SetVal("No Expense Found") Else Dim ShowID As String = GetId ReturnData = parser.NextArray If ReturnData.Size > 0 Then Dim ufo As String ufo = ReturnData.size Dim v1,v2,v3,v4,v5,v6,v7 As String Dim c1,c2,c3,c4,c5,c6 As Double Dim g3 As Int c1 = 0 c2 = 0 c3 = 0 c4 = 0 c5 = 0 c6 = 0 g3 = 0 Dim TheExpense,TheMi,TheCost,TheHr,TheGal,TheVal As Float Dim TheCst As String TheExpense = 0 TheMi = 0 TheCost = 0 TheHr = 0 TheGal = 0 TheVal = 0 Dim Expyn As String Dim demoListObjects As List demoListObjects.Initialize Dim bid As String For c = 0 To ReturnData.Size - 1 Dim M As Map M = ReturnData.Get(c) demoListObjects.Add(M) g3 = g3 +1 v7 = M.Get("ResNote") v1 = M.Get("Expense") If v1 = Null Or v1 = "null" Then v1 = 0 Else v1 = M.Get("Expense") End If v2 = M.Get("Mileage") If v2 = Null Or v2 = "null" Then v2 = 0 Else v2 = M.Get("Mileage") End If v3 = M.Get("Cost") If v3 = Null Or v3 = "null" Then v3 = 0 Else v3 = M.Get("Cost") End If v4 = M.Get("Hours") If v4 = Null Or v4 = "null" Then v4 = 0 Else v4 = M.Get("Hours") End If v5 = M.Get("Gals") If v5 = Null Or v5 = "null" Then v5 = 0 Else v5 = M.Get("Gals") End If v6 = M.Get("Value") If v6 = Null Or v6 = "null" Then v6 = 0 Else v6 = M.Get("Value") End If c1 = c1 + v1 c2 = c2 + v2 c3 = c3 + v3 c4 = c4 + v4 c5 = c5 + v5 c6 = c6 + v6 Next c1 = Round2(c1,2) c2 = Round2(c2,2) thetext.SetVal("Summary of " & g3 & " items is: Expenses $" & c1 & ", Mileage is: " & c2 & " miles" & ", cost of $" & c3 & ", Hours used are " & c4 & ", Gallons used are " & c5 & ", Total Value is $" & c6) QueryResponse = ExpenseQuery(demoListObjects) listbox1.SetHtml(QueryResponse) Log("The cost is: " & TheCost & " and the Mileage is: " & TheMi) ' if this is line marked out - Bummer End If End If Case Get_Expense ' ResName,ResNote,ResFile,Cost,Mileage,CreateDT,ExpYear Dim v3,v4,v5,v6,v7 As String ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim M As Map M = ReturnData.Get(0) v1 = M.Get("Expense") ' ResCost v2 = M.Get("Mileage") ' ResMileage v4 = M.Get("ResNote") v5 = M.Get("ResFile") v6 = M.Get("CreateDT") v7 = M.Get("TransYear") v1 = Round2(v1,2) v2 = Round2(v2,2) thetext.SetVal("Expense of " & v3 & " is $" & v1 & " and the Mileage is " & v2 & " miles." & CRLF & "Dated: " & v6 & CRLF & "Note: " & v4 & CRLF & "File: " & v5 ) End If Case NxtBlgID ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim M As Map M = ReturnData.Get(0) NextBlgID = M.Get("BlgID") +1 GetNextOffID End If Case NxtOffID ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim M As Map M = ReturnData.Get(0) NextOffID = M.Get("OffID") +1 GetNextDskID End If Case NxtDskID ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim M As Map M = ReturnData.Get(0) NextDskID = M.Get("DskID") +1 AddBldg End If Case New_Expense ReturnData = parser.NextArray If ReturnData.Size = 1 Then Dim M As Map M = ReturnData.Get(0) Dim f1,f2 As String f1 = M.Get("ID") f2 = "Campus" ws.Eval( "window.open('indexreso.html?resid="&f1 & "&resname=" & f2 &", ID "&"')", Null) ws.Flush End If End Select Else thetext.SetVal("No result in search") End If End Sub ' ################################### Quieries that Populate the ListBoxes ' CampusQuery, BldgQuery, NotesQuery, ApptQuery, ExpenseQuery ' =================================== CampusQuery Sub CampusQuery(thingsInYourList As List) As String Dim retHtml As String retHtml = "" Return(retHtml) End Sub ' =================================== Building Query Sub BldgQuery(thingsInYourList As List) As String ' Office Red 'campname.setHtml("
???") Dim retHtml As String retHtml = "" Return(retHtml) End Sub ' =================================== Notes Query Sub NotesQuery(thingsInYourList As List) As String ' 2 Multi Line Issue 'chgbldg.RunMethod("show", Null) Dim cktng As String Dim retHtml As String retHtml = "" Return(retHtml) End Sub ' ==================================== Appointments Query Sub ApptQuery(thingsInYourList As List) As String ' 3 Multi Line Issue Solved DateTime.DateFormat = "yyyyMMdd" Dim cktng,ckdate,f10,f11 As String f10 = DateTime.Date(DateTime.Now) 'chgbldg.RunMethod("show", Null) Dim retHtml As String retHtml = "" Return(retHtml) End Sub ' =================================== Expense Query Sub ExpenseQuery(thingsInYourList As List) As String ' 4 Multi Line Issue Not Solved problem with ResNote Dim cktng As String Dim retHtml As String retHtml = "" Return(retHtml) 'Dim ufo As String 'ufo = "0" End Sub ' ######################################################################### ' ######################################################################### ' #################################### Clicked Item ####################### ' ######################################################################### ' ######################################################################### Sub sendclicked_click(params As Map) ' clickedline desctrbed in index.html Dim ShowText As String = GetText ShowText = ShowText.Replace ("'", "`") Dim retVal As Future = clickedline.GetVal fmsg = retVal.Value If fmsg.StartsWith("ID =") Then For i = fmsg.Length - 5 To 0 Step -1 If fmsg.SubString2(i,i+5) = "Value" Then fmsgid = fmsg.SubString2(4,i) Exit End If Next End If If fmsg.StartsWith("ID=") Then For i = fmsg.Length - 5 To 0 Step -1 If fmsg.SubString2(i,i+5) = "Value" Then fmsgid = fmsg.SubString2(3,i) Exit End If Next End If If fmsg.StartsWith("BlgID =") Then For i = fmsg.Length - 5 To 0 Step -1 If fmsg.SubString2(i,i+5) = "Value" Then fmsgid = fmsg.SubString2(7,i) Exit End If Next End If fmsgdt = retVal.Value If fmsg.StartsWith("Clicked=date") Then Dim month As String SelLoc = "Calendar" fmsgdt = fmsg.SubString2(21,33) month = fmsgdt.SubString2(1,4) Select Case month Case "Jan" month = "01" Case "Feb" month = "02" Case "Mar" month = "03" Case "Apr" month = "04" Case "May" month = "05" Case "Jun" month = "06" Case "Jul" month = "07" Case "Aug" month = "08" Case "Sep" month = "09" Case "Oct" month = "10" Case "Nov" month = "11" Case "Dec" month = "12" End Select fmsgdtu = fmsgdt.SubString2(8,12) & "/" & month &"/" & fmsgdt.SubString2(5,7) If ChgDate = False Then ws.Alert(fmsgdt & " selected. Now, over write Text and click 'Add Appt' or Click 'Chg Appt Date'") End If listbox1.SetHtml("") End If If fmsg.StartsWith("ResNote") Then ' Just testing some code fmsgid = fmsg End If For i = fmsg.Length To 0 Step -1 If fmsg.SubString2(i-1,i) = "=" Then fmsg = fmsg.SubString2(i,fmsg.Length) Exit End If Next If SelLoc = "Expense" Then ' find second = then the word Value Dim f1 As Int Dim ufo As String ufo = fmsg & " |||||| " & fmsgid fmsg = fmsgid ' For j = 0 To fmsgid.Length -1 ' If fmsgid.SubString2(j,j+3) = "ID=" Then ' f1 = j+3 ' Exit ' End If ' Next ' For j = f1 To fmsgid.Length -1 ' Dim f2 As String ' f2 = fmsgid.SubString2(j,j+6) ' If fmsgid.SubString2(j,j+6) = "Value=" Then ' fmsgid = fmsgid.SubString2(f1,j) ' fmsgid complete ' Exit ' End If ' Next ' ' For i = 0 To fmsg.Length -1 ' If fmsg.SubString2(i,i+1) = "=" Then ' fmsg = fmsg.SubString2(i+1,fmsg.Length) ' Exit ' End If ' Next ' ' For j = 0 To fmsg.Length -1 ' If fmsg.SubString2(j,j+3) = "ID=" Then ' fmsg = fmsg.SubString2(0,j) ' Exit ' End If ' Next End If Select Case SelLoc Case "Bldg" Main.CurBlgName = fmsg Main.FixBlgID = fmsgid blgid.SetHtml(fmsgid) ws.Eval("window.open('indexblg.html?blgid="&fmsgid & "&blgname=" & fmsg &", Blg #"&"')", Null) ws.Flush Case "Campus" Main.CurBlgName = fmsg Main.FixBlgID = fmsgid blgid.SetHtml(fmsgid) 'campname.setHtml("
" & "'" & fmsg & "'" & "") ws.Eval("window.open('indexblg.html?blgid="&fmsgid & "&blgname=" & fmsg &", Blg"&"')",Null) ws.Flush Case "Appts" thetext.SetVal("Appointment List") PostData("SELECT A_date,ItemNote FROM Acme_Appts WHERE ID = " & "'" & fmsgid & "'" & " ",Get_Appt) ' Using "https://portal.cgumpdesign.com/dev/HyperCG.php" Case "Notes" PostData("SELECT Caption FROM Acme_Notes WHERE ID = " & "'" & fmsgid & "'" & " ",Get_Note) ' Using "https://portal.cgumpdesign.com/dev/HyperCG.php" Case "Expense" 'PostData("SELECT ResName,Expense,Mileage,ID,ResFile,CreateDT,ResNote,ResFile,TransYear FROM Acme_Resources where ID = " & "'" & fmsgid & "'" & " ",Get_Expense) ws.Eval("window.open('indexreso.html?resid="&fmsgid & "&resname=" & fmsg &", Res "&"')", Null) ws.Flush Case "Calendar" If ChgDate = True Then ChgDate = False PostData("UPDATE Acme_Appts SET A_date = " & "'" & fmsgdtu & "'" & " WHERE ID = " & "'" & fmsgid & "'" & " ",Q_UPDATE) ws.Alert("Date changed to: " & fmsgdtu) Dim ufo As String ufo = ShowText thetext.SetVal(fmsgdtu & " " & ShowText.SubString2(11,ShowText.Length) ) Timer1.Enabled = True Else thetext.SetVal("New Appointment...") End If Case "ChgBlgName" thetext.SetVal(fmsg) ws.Alert("Overwrite old name then Click Confirm Bldg name change") savxx.SetText("Confirm Bldg name change") SelLoc = "BlgChg" Case "DelBlg" thetext.SetVal(fmsg) End Select End Sub ' ################################ Timers Sub Timer1_tick 'ws.Alert("Timer1 called") Timer1.Enabled = False Dim g1 As Int g1 = 0 kepbldg.RunMethod("hide", Null) Select Case SelLoc Case "Notes" listbox1.SetHtml("") PostData("SELECT Caption,ID,CreateDT FROM Acme_Notes WHERE Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by CreateDT DESC ",Get_Notes) Case "Appts" PostData("SELECT ItemNote,ID,A_date FROM Acme_Appts WHERE Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by A_date DESC",Get_Appts) Case "Calendar" PostData("SELECT ItemNote,ID,A_date FROM Acme_Appts WHERE Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by A_date DESC",Get_Appts) Case "Expense" ' 1 Account,2 ResNote,3 Expense,4 Mileage,5 Year,6 CreateDT,7 TransYear Dim f1 As String f1 = DateTime.GetYear(DateTime.Now) 'PostData("SELECT ResNote,ResCost,ResMileage,ID,CreateDT FROM Acme_Resources where Left(CreateDT,4) = " & "'" & f1 & "'" & " AND Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by CreateDT DESC ",Get_Expenses) PostData("SELECT ResNote,Expense,Mileage,ID,CreateDT FROM Acme_Resources where Left(CreateDT,4) = " & "'" & f1 & "'" & " AND Account = " & "'" & Main.FixAcctID & "'" & " AND Rank = " & "'" & g1 & "'" & " Order by CreateDT DESC ",Get_Expenses) Case "BlgChg" PostData("SELECT Building as entity,BlgID FROM Acme_ABOD Where Account = " & "'" & Main.FixAcctID & "'" & " AND Rank1 = " & "'" & g1 & "'" & "group by Building",Get_Bldgs) End Select End Sub Sub Timer2_tick Timer2.Enabled = False Dim g1 As Int g1 = 0 PostData("SELECT Building as entity,BlgID FROM Acme_ABOD Where Account = " & "'" & Main.FixAcctID & "'" & " AND Rank2 = " & "'" & g1 & "'" & " group by Building",Get_Bldgs) End Sub Sub HideAll ' Notes sav_n.RunMethod("hide", Null) add_n.RunMethod("hide", Null) del_n.RunMethod("hide", Null) ' Appointments sav_a.RunMethod("hide", Null) add_a.RunMethod("hide", Null) del_a.RunMethod("hide", Null) apptchg.RunMethod("hide", Null) cost.RunMethod("hide", Null) ' Expenses viw_e.RunMethod("hide", Null) add_e.RunMethod("hide", Null) del_e.RunMethod("hide", Null) ' Search ' Campus sav_b.RunMethod("hide", Null) add_b.RunMethod("hide", Null) del_b.RunMethod("hide", Null) del_bc.RunMethod("hide", Null) savblg.RunMethod("hide", Null) chgbldg.RunMethod("hide", Null) newname.RunMethod("hide", Null) kepbldg.RunMethod("hide", Null) End Sub Sub ShowNotes sav_n.RunMethod("show", Null) add_n.RunMethod("show", Null) del_n.RunMethod("show", Null) End Sub Sub ShowAppts sav_a.RunMethod("show", Null) add_a.RunMethod("show", Null) del_a.RunMethod("show", Null) apptchg.RunMethod("show", Null) cost.RunMethod("show", Null) End Sub Sub ShowExpense viw_e.RunMethod("show", Null) add_e.RunMethod("show", Null) del_e.RunMethod("show", Null) End Sub Sub ShowBldgs add_b.RunMethod("show", Null) sav_b.RunMethod("hide", Null) del_b.RunMethod("show", Null) del_bc.RunMethod("hide", Null) chgbldg.RunMethod("show", Null) kepbldg.RunMethod("hide", Null) savblg.RunMethod("show", Null) newname.RunMethod("show", Null) End Sub