"
- dat += "For all your monetary needs! "
- dat += "This terminal is [machine_id]. Report this code when contacting IT Support "
-
- if(emagged > 0)
- dat += "Card: LOCKED
"
+/obj/machinery/atm/proc/generate_ui_transaction_log(var/list/transaction_list)
+ var/list/passed_list = list()
+ for(var/datum/transaction/T in transaction_list)
+ var/transaction_num = 0
+ var/list/new_list = list()
+ new_list["target_name"] = T.target_name
+ new_list["purpose"] = T.purpose
+ new_list["amount"] = T.amount
+ new_list["date"] = T.date
+ new_list["time"] = T.time
+ new_list["source_terminal"] = T.source_terminal
+ transaction_num++
+ passed_list["[transaction_num]"] = new_list
+ return passed_list
+
+/obj/machinery/atm/ui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui)
+ . = ..()
+ ui = SStgui.try_update_ui(user, src, ui)
+ if (!ui)
+ ui = new(user, src, "ATM", "[machine_id]")
+ ui.open()
- if(ticks_left_locked_down > 0)
- dat += "Maximum number of pin attempts exceeded! Access to this ATM has been temporarily disabled."
- else if(authenticated_account)
- if(authenticated_account.suspended)
- dat += "Access to this account has been suspended, and the funds within frozen."
- else
- switch(view_screen)
- if(CHANGE_SECURITY_LEVEL)
- dat += "Select a new security level for this account: "
- var/text = "Zero - Either the account number or card is required to access this account. EFTPOS transactions will require a card and ask for a pin, but not verify the pin is correct."
- if(authenticated_account.security_level != 0)
- text = "[text]"
- dat += "[text]"
- text = "One - An account number and pin must be manually entered to access this account and process transactions."
- if(authenticated_account.security_level != 1)
- text = "[text]"
- dat += "[text]"
- text = "Two - In addition to account number and pin, a card is required to access this account and process transactions."
- if(authenticated_account.security_level != 2)
- text = "[text]"
- dat += "[text] "
- dat += "Back"
- if(VIEW_TRANSACTION_LOGS)
- dat += "Transaction logs "
- dat += "Back"
- dat += "
"
- dat += "
"
- dat += "
Date
"
- dat += "
Time
"
- dat += "
Target
"
- dat += "
Purpose
"
- dat += "
Value
"
- dat += "
Source terminal ID
"
- dat += "
"
- for(var/datum/transaction/T in authenticated_account.transaction_log)
- dat += "
"
- dat += "
[T.date]
"
- dat += "
[T.time]
"
- dat += "
[T.target_name]
"
- dat += "
[T.purpose]
"
- dat += "
$[T.amount]
"
- dat += "
[T.source_terminal]
"
- dat += "
"
- dat += "
"
- dat += "Print "
- if(TRANSFER_FUNDS)
- dat += "Account balance: $[authenticated_account.money] "
- dat += "Back
"
- dat += ""
- else
- dat += "Welcome, [authenticated_account.owner_name]. "
- dat += "Account balance: $[authenticated_account.money]"
- dat += ""
- dat += "Change account security level "
- dat += "Make transfer "
- dat += "View transaction log "
- dat += "Print balance statement "
- dat += "Logout "
+/obj/machinery/atm/ui_data(mob/user, datum/tgui/ui, datum/ui_state/state)
+ . = ..()
+ var/data[0]
+
+ data["incorrect_attempts"] = number_incorrect_tries
+ data["max_pin_attempts"] = max_pin_attempts
+ data["ticks_left_locked_down"] = ticks_left_locked_down
+ data["emagged"] = emagged
+ data["authenticated_acc"] = (authenticated_account ? 1 : 0)
+ data["account_name"] = authenticated_account?.owner_name || "UNKWN"
+ data["transaction_log"] = generate_ui_transaction_log(authenticated_account?.transaction_log || list())
+ data["account_security_level"] = account_security_level
+ data["current_account_security_level"] = authenticated_account?.security_level
+ data["acc_suspended"] = authenticated_account?.suspended || 0
+ data["balance"] = authenticated_account?.money || 0
+ data["machine_id"] = machine_id
+ data["card_inserted"] = (held_card ? TRUE : FALSE)
+ data["inserted_card_name"] = (held_card ? held_card.registered_name : "--INSERT CARD--")
+ data["logout_time"] = DisplayTimeText(ticks_left_timeout * 10)
+
+ return data
+
+/obj/machinery/atm/ui_act(action, list/params, datum/tgui/ui)
+ . = ..()
+ var/mob/living/carbon/human/user = usr
+ switch(action)
+ if("attempt_authentication")
+ attempt_authentication(user, text2num(params["pin"]), text2num(params["acc"]))
+ if("eject_card")
+ if(held_card)
+ authenticated_account = null
+ account_security_level = 0
+ release_held_id(user)
else
- if(!account_security_level)
- dat += "To log in to your savings account, press 'submit' with ID clearly displayed. If you wish to log into another account, please enter the account number into the field below or insert a registered ID card into the slot above and then press 'submit'. "
- else if (account_security_level == 1)
- dat += "This account requires a PIN to access. For security reasons the account # will need re-entered or ID bound to this account re-scanned."
+ //this might happen if the user had the browser window open when somebody emagged it
+ if(emagged > 0)
+ to_chat(user, "[icon2html(thing = src, target = user)] The ATM card reader rejected your ID because this machine has been sabotaged!")
else
- dat += "Due to the security settings on this account, all information needs to be re-entered and the ID bound to this account placed in the slot above. "
- dat += ""
-
- user << browse(dat,"window=atm;size=550x650")
- else
- user << browse(null,"window=atm")
-
-/obj/machinery/atm/Topic(var/href, var/href_list)
- if(href_list["choice"])
- switch(href_list["choice"])
- if("transfer")
- if(authenticated_account)
- var/transfer_amount = text2num(href_list["funds_amount"])
- transfer_amount = round(transfer_amount, 0.01)
- if(transfer_amount <= 0)
- alert("That is not a valid amount.")
- else if(transfer_amount <= authenticated_account.money)
- var/target_account_number = text2num(href_list["target_acc_number"])
- var/transfer_purpose = href_list["purpose"]
- if(charge_to_account(target_account_number, authenticated_account.owner_name, transfer_purpose, machine_id, transfer_amount))
- to_chat(usr, "[icon2html(thing = src, target = usr)]Funds transfer successful.")
- authenticated_account.money -= transfer_amount
-
- //create an entry in the account transaction log
- var/datum/transaction/T = new()
- T.target_name = "Account #[target_account_number]"
- T.purpose = transfer_purpose
- T.source_terminal = machine_id
- T.date = GLOB.current_date_string
- T.time = stationtime2text()
- T.amount = "([transfer_amount])"
- authenticated_account.transaction_log.Add(T)
- else
- to_chat(usr, "[icon2html(thing = src, target = usr)]Funds transfer failed.")
-
- else
- to_chat(usr, "[icon2html(thing = src, target = usr)]You don't have enough funds to do that!")
- if("view_screen")
- view_screen = text2num(href_list["view_screen"])
- if("change_security_level")
- if(authenticated_account)
- var/new_sec_level = max( min(text2num(href_list["new_security_level"]), 2), 0)
- authenticated_account.security_level = new_sec_level
- if("attempt_auth")
-
- var/obj/item/card/id/login_card
- if(held_card)
- login_card = held_card
- else
- login_card = scan_user(usr)
-
- if(!ticks_left_locked_down)
- var/tried_account_num = text2num(href_list["account_num"])
- //We WILL need an account number entered manually if security is high enough, do not automagic account number
- if(!tried_account_num && login_card && (account_security_level != 2))
- tried_account_num = login_card.associated_account_number
- var/tried_pin = text2num(href_list["account_pin"])
-
- //We'll need more information if an account's security is greater than zero so let's find out what the security setting is
- var/datum/money_account/D
- //Below is to avoid a runtime
- if(tried_account_num)
- D = get_account(tried_account_num)
-
- if(D)
- account_security_level = D.security_level
-
- authenticated_account = attempt_account_access(tried_account_num, tried_pin, held_card && held_card.associated_account_number == tried_account_num ? 2 : 1)
- if(!authenticated_account)
- number_incorrect_tries++
- if(previous_account_number == tried_account_num)
- if(number_incorrect_tries > max_pin_attempts)
- //lock down the atm
- ticks_left_locked_down = 30
- playsound(src, 'sound/machines/buzz-two.ogg', 50, 1)
-
- //create an entry in the account transaction log
- var/datum/money_account/failed_account = get_account(tried_account_num)
- if(failed_account)
- var/datum/transaction/T = new()
- T.target_name = failed_account.owner_name
- T.purpose = "Unauthorised login attempt"
- T.source_terminal = machine_id
- T.date = GLOB.current_date_string
- T.time = stationtime2text()
- failed_account.transaction_log.Add(T)
- else
- to_chat(usr, "[icon2html(thing = src, target = usr)] Incorrect pin/account combination entered, [max_pin_attempts - number_incorrect_tries] attempts remaining.")
- previous_account_number = tried_account_num
- playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 1)
- else
- to_chat(usr, "[icon2html(thing = src, target = usr)] incorrect pin/account combination entered.")
- number_incorrect_tries = 0
- else
- playsound(src, 'sound/machines/twobeep.ogg', 50, 1)
- ticks_left_timeout = 120
- view_screen = NO_SCREEN
-
- //create a transaction log entry
- var/datum/transaction/T = new()
- T.target_name = authenticated_account.owner_name
- T.purpose = "Remote terminal access"
- T.source_terminal = machine_id
- T.date = GLOB.current_date_string
- T.time = stationtime2text()
- authenticated_account.transaction_log.Add(T)
-
- to_chat(usr, "[icon2html(thing = src, target = usr)] Access granted. Welcome user '[authenticated_account.owner_name].'")
-
- previous_account_number = tried_account_num
- if("e_withdrawal")
- var/amount = max(text2num(href_list["funds_amount"]),0)
- amount = round(amount, 0.01)
- if(amount <= 0)
+ var/obj/item/I = user.get_active_held_item()
+ if (istype(I, /obj/item/card/id))
+ if(!user.attempt_insert_item_for_installation(I, src))
+ return
+ held_card = I
+ if("balance_statement")
+ if(authenticated_account)
+ var/obj/item/paper/R = new(src.loc)
+ R.name = "Account balance: [authenticated_account.owner_name]"
+ R.info = "NT Automated Teller Account Statement