Hi everyone, I just upgraded to the newest version of Anywhere and have started to transition my old stuff.
My biggest hurdle seems to be session variables. I use to use a ton of them that were all set on the first page after login how do I set the session.userid now?
My biggest hurdle seems to be session variables. I use to use a ton of them that were all set on the first page after login how do I set the session.userid now?
Code:
<!doctype html> <html> <head> <%a5 dim nEmid as n = 0 session.__protected__clientSideDateFormat = "MM/dd/yyyy" session.noshift = "Has shift" nEmid = a5_convert_type(session.userid,"N") vTemp=<<%a% SELECT active_status FROM employees WHERE em_id = {nEmid} %a% dim GSVSelect as c dim gsv as SQL::connection dim grs as SQL::ResultSet gsv.open("::name::test") GSVSelect=evaluate_string(vTemp) gsv.Execute(GSVSelect) grs=gsv.ResultSet vStatus=grs.data("active_status") if vStatus=.f. end if vgst=".05" vhst=".13" vpst=".08" session.taxes=vgst+"|"+vpst+"|"+vhst dim GSVSelect as c vTemp=<<%a% SELECT * FROM employees WHERE em_id = {nEmid} %a% GSVSelect=evaluate_string(vTemp) gsv.Execute(GSVSelect) grs=gsv.ResultSet session.emp_email=grs.data("cwcemail") session.fullname=grs.data("em_name") session.storename=grs.data("store") session.badgename=grs.data("badge_name") session.position=grs.data("em_position") session.fdapi=grs.data("freshdesk_api") session.ov_id=grs.data("oneview_id") session.ov_dc=grs.data("oneview_dealer_code") session.ov_pw=grs.data("oneview_password") session.territory = grs.data("territory") session.certx = "" session.invnum as n =0 dim gemailvSelect as c dim gers as SQL::ResultSet gemailvSelect="SELECT mgr_email, store_email, type, storeid,dealercode,distmgremail FROM stores WHERE store_name = '"+session.storename+"'" gsv.Execute(gemailvSelect) gers=gsv.ResultSet session.mgremail=gers.data("mgr_email") session.storemail=gers.data("store_email") session.storeid=gers.data("storeid") session.storetype=gers.data("type") session.dealercode=gers.data("dealercode") session.distmgremail=gers.data("distmgremail") gsv.close() end if session.ipaddress = Request.REMOTE_ADDR sleep(.2) dim conn as SQL::Connection dim rset as SQL::ResultSet dim NumberFound as n = 0 dim SqlInsert as C = "" dim Args as SQL::Arguments dim nfound as n =0 session.test="got_to_first" conn.open("::name::cwc") 'this is where we check to see if they are a manager or higher at a store 'need to check the login to see if its the first login of the day 'if it is then include the todolist page if session.position="Manager" .or. session.userid = "856" .or. session.userid ="891" session.test="got_to_second" dim vTemp12 as c = "" dim Sqllook as C = "" vTemp12=<<%a% SELECT count(userid) as kount12 FROM `login_log` WHERE `userid` = '{session.userid}' AND `created_date` = CURDATE() %a% Sqllook=evaluate_string(vTemp12) conn.Execute(Sqllook) rset=conn.ResultSet dim nfound12 as n = 0 nfound12=rset.data("kount12") if nfound12=0 'include todolistpage a5w_include("todolist.a5w") end if end if 'this is wher we check to see if they are a sales rep. session.test="got_to_second" dim vTemp12 as c = "" dim Sqllook as C = "" vTemp12=<<%a% SELECT count(userid) as kount12 FROM `login_log` WHERE `userid` = '{session.userid}' AND `created_date` = CURDATE() %a% Sqllook=evaluate_string(vTemp12) conn.Execute(Sqllook) rset=conn.ResultSet dim nfound12 as n = 0 nfound12=rset.data("kount12") if nfound12=0 'include todolistpage a5w_include("todolist_employees.a5w") end if vTemp=<<%a% INSERT INTO login_log (userid, ip_address, created, server_ip,server_count,created_date) VALUES ('{session.userid}', '{session.ipaddress}', now(),'{ServerSetting.BindIP}', {Server.SessionCount}, curdate()) %a% SqlInsert=evaluate_string(vTemp) conn.Execute(SqlInsert) args.add("ArgEmp",session.__protected__userid) args.add("Argip",session.ipaddress) '**************check to see if today is a scheduled day for this employee in the time_card table dim sqltimecard as c = "" dim rsettime as SQL::ResultSet dim timefound as n =0 dim timelate as n =0 dim Argstime as SQL::Arguments dim updatebreaks as c = "" session.login_type = "Started" sqltimecard="SELECT count(emp_num) as time_count FROM time_card WHERE emp_num=:ArgEmp AND created =curdate() and logged_in is null" conn.Execute(sqltimecard,Args) rsettime=conn.ResultSet timefound=rsettime.data("time_count") if timefound = 1 session.login_type = "first" dim upd_timecard as c ="" Upd_timecard="UPDATE time_card SET logged_in=now() WHERE emp_num=:ArgEmp AND created =curdate()" conn.Execute(Upd_timecard,Args) sleep(.5) dim late_count as n = 0 sqltimecard="Select count(loggedin_diff) as late_count from timecard_start_diff WHERE emp_num=:ArgEmp AND created =curdate()" conn.Execute(sqltimecard,Args) rsettime=conn.ResultSet late_count=rsettime.data("late_count") sleep(.5) if late_count >0 sqltimecard="Select loggedin_diff from timecard_start_diff WHERE emp_num=:ArgEmp AND created =curdate()" conn.Execute(sqltimecard,Args) rsettime=conn.ResultSet timelate=rsettime.data("loggedin_diff") '******************if they are more than 5 min late then send an email to the employee and manager if timelate >5 dim message as p message.to=session.emp_email message.cc=session.mgremail message.from="[email protected]" message.subject = session.fullname+" Late login" message.message = "You have logged into your shift "+timelate+" minutes late. Your manager has been copied on this email" email_send2(message,"wasemail",.t.,.f.) Upd_timecard="UPDATE time_card SET early_late ='L', mgr_comment='Late login', start_time =now() WHERE emp_num=:ArgEmp AND created =curdate()" conn.Execute(Upd_timecard,Args) end if end if end if '***************check to see if they have an open break and log them back in to close out the break************* dim sqlbreaks as c = "" dim vbcount as n = 0 dim vbreakfound as n = 0 sqlbreaks="SELECT count(emp_num) as vbcount FROM break_view WHERE emp_num=:ArgEmp AND created = curdate() AND backfrombreak is null" conn.Execute(sqlbreaks,Args) rsettime=conn.ResultSet vbreakfound=rsettime.data("vbcount") if vbreakfound >0 dim upd_breaks as c ="" upd_breaks="UPDATE break_view SET backfrombreak=now(), ip_address_return=:Argip WHERE emp_num=:ArgEmp AND created =curdate()" conn.Execute(Upd_breaks,Args) session.login_type = "Break" end if '*********************end break check and update*********** session.pic_login = "" session.pic_logout = "" session.pic_return = "" session.mth = cmonth(date()) session.yr = cyear(date()) '****************************************end of schedule check EndIt: gsv.close() '********Addition of active employee lookup******** ' dim session.activestaff as C="" dim session.mgrlist as C="" if session.position <> "Sales Consultant" 'session.activeemp = "" dim cnx as SQL::Connection dim args as SQL::Arguments dim crs as SQL::ResultSet dim SqlSelect as C = "" dim SqlSelectMan as c = "" dim NumberFoundM as n = 0 dim NumberFound as n = 0 dim kount as n =0 dim kount1 as n =0 dim mgrlist as c ="" args.Add("Argmanager","Manager") SqlSelectman="SELECT count(em_id) as kount1 FROM Employees WHERE active_status = 1 AND em_position=:argmanager and em_id NOT IN ('53', '90', '174', '120', '316', '960')" cnx.open("::name::cwc") cnx.execute(SqlSelectman,args) crs=cnx.ResultSet NumberFoundM=crs.data("kount1") if NumberFoundM >1 SqlSelectman="SELECT em_id FROM Employees WHERE active_status = 1 AND em_position=:argmanager and em_id NOT IN ('53', '90', '174', '120', '316', '960')" cnx.execute(SqlSelectman,args) crs=cnx.ResultSet while crs.nextrow() mgrlist =mgrlist +","+crs.data("em_id") end while session.mgrlist=mgrlist end if args.Add("Argstoreid",session.storename) SqlSelect="SELECT count(em_id) as kount FROM Employees WHERE active_status = 1 AND store=:Argstoreid" cnx.execute(SqlSelect,args) crs=cnx.ResultSet NumberFound=crs.data("kount") if NumberFound >1 dim activestaff as c = "" SqlSelect="SELECT em_id FROM Employees WHERE active_status = 1 AND store=:Argstoreid" cnx.execute(SqlSelect,args) crs=cnx.ResultSet while crs.nextrow() activestaff =activestaff +","+crs.data("em_id") end while session.activestaff=activestaff end if cnx.close() end if 'check and see if employee is logged into the proper store. if session.position = "Sales Consultant" dim conn as SQL::Connection dim rsettime as SQL::ResultSet dim Args as SQL::Arguments dim sqltimecard as c = "" dim timefound as n = 0 nEmid2 = convert_type(session.__protected__userid,"N") conn.open("::name::cwc") Args.Add("ArgEmp2",nEmid2) Args.Add("Argstoreid2",session.storeid) sqltimecard="SELECT count(emp_num) as time_count FROM time_card WHERE emp_num=:ArgEmp2 AND created =curdate() AND storeid=:Argstoreid2" conn.Execute(sqltimecard,Args) rsettime=conn.ResultSet timefound=rsettime.data("time_count") if timefound = 1 session.noshift = "Has shift" else session.noshift = "No Shift" end if end if conn.Close() session.logintime = a5_timestamp() outofhere: '********Finish lookup*********** %> <%a5 Delete tmpl_CWC_MASTER DIM tmpl_CWC_MASTER as P tmpl_CWC_MASTER = a5w_load_component("Cwc_master") ''SYSTEM GENERATED COMMENT - PLEASE DO NOT REMOVE (LOAD:Cwc_master) 'Override settings start ----------------------------------------- with tmpl_CWC_MASTER .alias = "CWC_MASTER" _dialogFilename = "Cwc_master" end with 'Override settings end ----------------------------------------- delete x_CWC_MASTER dim x_CWC_MASTER as p x_CWC_MASTER = a5w_run_Component(tmpl_CWC_MASTER) 'SYSTEM GENERATED COMMENT - PLEASE DO NOT REMOVE (RUN:tmpl) (EDIT:Cwc_master) ?x_CWC_MASTER.Output.Head.JavaScript ?x_CWC_MASTER.Output.Head.CSS_Link ?x_CWC_MASTER.Output.Head.Title %> <!--Alpha Five Temporary Code Start - Will be automatically removed when page is published --> <!--CSS for tmpl --> <link rel="stylesheet" type="text/css" href="file:///C:/Program Files (x86)/a5V12/css/cwcblue/style.css"> <!--Alpha Five Temporary Code End --> <!--Alpha Five Temporary Code Start - Will be automatically removed when page is published --> <!--CSS for tmpl --> <link rel="stylesheet" type="text/css" href="file:///C:/Program Files (x86)/a5V12/css/iOS/style.css"> <!--Alpha Five Temporary Code End --> <!--Alpha Five Temporary Code Start - Will be automatically removed when page is published --> <!--CSS for tmpl --> <link rel="stylesheet" type="text/css" href="file:///C:/Program Files (x86)/a5V12/css/iOS/style.css"> <!--Alpha Five Temporary Code End --> <meta name="generator" content="Alpha Anywhere HTML Editor Version 12 Build 2446-4365"> <!-- must use in order to make XP Themes render --> <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <title></title> </head> <body class="cwcbluePage"> <p align=center> <%a5 ?x_CWC_MASTER.Output.Body.Dialog2_HTML %></p> </body></html>
Comment