Files
CatsinHD 7f664eb1eb Stickynotes, Notepads, and Receipts. Some clerical additions (#21775)
Ports stickynotes from bay. They can be stuck to most surfaces, but have
a much smaller character limit. Pads have been placed across the Horizon
and can be ordered from Operations.

Receipt paper and notepad paper was added for visual quality of life.
Point of Sales now use receipt paper where applicable.

Sprites were either created by myself, or modifications of baystation
sprites from this PR:
https://github.com/Baystation12/Baystation12/pull/23109

---------

Signed-off-by: CatsinHD <31459154+CatsinHD@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: FabianK3 <21039694+FabianK3@users.noreply.github.com>
Co-authored-by: Wildkins <john.wildkins@gmail.com>
2026-02-17 15:51:57 +00:00

266 lines
8.2 KiB
Plaintext

/obj/item/quikpay
name = "\improper Idris Quik-Pay"
desc = "Swipe your ID to make direct company purchases."
icon = 'icons/obj/item/eftpos.dmi'
icon_state = "quikpay"
item_state = "electronic"
w_class = WEIGHT_CLASS_SMALL
slot_flags = SLOT_BELT
var/machine_id = ""
var/list/items = list()
var/list/items_to_price = list()
var/list/buying = list()
var/new_item = ""
var/new_price = 0
var/sum = 0
var/editmode = FALSE
var/receipt = ""
var/destinationact = "Service"
var/shop_name = "Quikpay"
/obj/item/quikpay/Initialize()
. = ..()
machine_id = "[station_name()] Idris Quik-Pay #[SSeconomy.num_financial_terminals++]"
//create a short manual as well
var/obj/item/paper/R = new(src.loc)
R.name = "Quik And Easy: How to make a transaction"
R.info += "<b>Quik-Pay setup:</b><br>"
R.info += "<ol><li>Remember your access code included on the paper that is included with your device</li>"
R.info += "<li>Unlock it to be able to add items to the menu</li>"
R.info += "<li>Add items to the menu by typing the item name and its price</li></ol>"
R.info += "<b>When starting a new transaction:</b><br>"
R.info += "<ol><li>Have the customer enter the amount of the item they want and then confirm the purchase.</li>"
R.info += "<li>Allow them to review the sum.</li>"
R.info += "<li>Have them swipe their card to pay for the items.</li></ol>"
//stamp the paper
var/image/stampoverlay = image('icons/obj/bureaucracy.dmi')
stampoverlay.icon_state = "paper_stamp-cent"
if(!R.stamped)
R.stamped = new
R.offset_x += 0
R.offset_y += 0
R.ico += "paper_stamp-cent"
R.stamped += /obj/item/stamp
R.AddOverlays(stampoverlay)
R.stamps += "<HR><i>This paper has been stamped by the Executive Officer's desk.</i>"
/obj/item/quikpay/AltClick(var/mob/user)
var/obj/item/card/id/I = user.GetIdCard()
if(istype(I) && (ACCESS_HEADS in I.access))
editmode = TRUE
to_chat(user, SPAN_NOTICE("Command access granted."))
SStgui.update_uis(src)
/obj/item/quikpay/proc/print_receipt()
var/obj/item/paper/notepad/receipt/R = new(usr.loc)
var/receiptname = "Receipt: [machine_id]"
R.set_content_unsafe(receiptname, receipt, sum)
//stamp the paper
var/image/stampoverlay = image('icons/obj/bureaucracy.dmi')
stampoverlay.icon_state = "paper_stamp-hop"
if(!R.stamped)
R.stamped = new
R.stamped += /obj/item/stamp
R.AddOverlays(stampoverlay)
R.stamps += "<HR><i>This paper has been stamped by the Quik-Pay device.</i>"
R.ripped = TRUE
usr.put_in_any_hand_if_possible(R)
/obj/item/quikpay/attackby(obj/item/attacking_item, mob/user)
if (istype(attacking_item, /obj/item/spacecash/ewallet))
var/obj/item/spacecash/ewallet/E = attacking_item
var/transaction_amount = sum
var/transaction_purpose = "[destinationact] Payment"
var/transaction_terminal = machine_id
if(transaction_amount <= E.worth)
playsound(src, 'sound/machines/chime.ogg', 50, 1)
src.visible_message(SPAN_NOTICE("[icon2html(src, viewers(get_turf(src)))] \The [src] chimes."))
SSeconomy.charge_to_account(SSeconomy.get_department_account(destinationact)?.account_number, E.owner_name, transaction_purpose, transaction_terminal, transaction_amount)
E.worth -= transaction_amount
print_receipt()
sum = 0
receipt = ""
to_chat(user, SPAN_NOTICE("Transaction completed, please return to the home screen."))
else if (transaction_amount > E.worth)
to_chat(user, SPAN_WARNING("[icon2html(src, user)]\The [E] doesn't have that much money!"))
return
var/obj/item/card/id/I = attacking_item.GetID()
if (!istype(attacking_item))
return
var/transaction_amount = sum
var/transaction_purpose = "[destinationact] Payment"
var/transaction_terminal = machine_id
var/transaction = SSeconomy.transfer_money(I.associated_account_number, SSeconomy.get_department_account(destinationact)?.account_number,transaction_purpose,transaction_terminal,transaction_amount,null,usr)
if(transaction)
to_chat(user, SPAN_NOTICE("[icon2html(src, user)]<span class='warning'>[transaction].</span>"))
else
playsound(src, 'sound/machines/chime.ogg', 50, 1)
visible_message(SPAN_NOTICE("[icon2html(src, viewers(get_turf(src)))] \The [src] chimes."))
print_receipt()
sum = 0
receipt = ""
to_chat(user, SPAN_NOTICE("Transaction completed, please return to the home screen."))
/obj/item/quikpay/attack_self(var/mob/user)
ui_interact(user)
/obj/item/quikpay/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "QuikPay", "Idris Quik-Pay", 550, 550)
ui.open()
/obj/item/quikpay/ui_data(var/mob/user)
var/list/data = list()
data["items"] = items
data["buying"] = buying
data["sum"] = sum
data["new_item"] = new_item
data["new_price"] = new_price
data["editmode"] = editmode
data["destinationact"] = destinationact
return data
/obj/item/quikpay/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
switch(action)
if("add")
if(!editmode)
to_chat(usr, SPAN_WARNING("Device locked."))
return FALSE
items += list(list("name" = new_item, "price" = new_price))
items_to_price[new_item] = new_price
. = TRUE
if("remove")
if(!editmode)
to_chat(usr, SPAN_NOTICE("Device locked."))
return FALSE
var/index = 0
for(var/list/L in items)
index++
if(L["name"] == params["removing"])
items.Cut(index, index+1)
. = TRUE
if("set_new_price")
new_price = params["set_new_price"]
. = TRUE
if("set_new_item")
new_item = params["set_new_item"]
. = TRUE
if("clear")
clear_order()
. = TRUE
if("buy")
for(var/list/L in buying)
if(L["name"] == params["buying"])
L["amount"]++
return TRUE
buying += list(list("name" = params["buying"], "amount" = params["amount"], "price" = items_to_price[params["buying"]]))
if("removal")
var/index = 0
for(var/list/L in buying)
index++
if(L["name"] == params["removal"])
if(L["amount"] > 1)
L["amount"]--
else
buying.Cut(index, index+1)
. = TRUE
if("confirm")
// Ensuring it is clear, in case the button is clicked multiple times
receipt = ""
sum = 0
var/obj/item/card/id/id_card = usr.GetIdCard()
var/cashier = id_card? id_card.registered_name : "Unknown"
receipt = "<center><H2>[shop_name] receipt</H2>Today's date: [worlddate2text()]<BR>Cashier: [cashier]</center><HR>Purchased items:<ul>"
for(var/list/bought_item in buying)
var/item_name = bought_item["name"]
var/item_amount = bought_item["amount"]
var/item_price = items_to_price[item_name]
receipt += "<li><b>[item_name]</b>: [item_amount] x [item_price]电: [item_amount * item_price]电<br>"
sum += item_price * item_amount
receipt += "</ul><HR>Total:</b> [sum]电<br>"
playsound(src, 'sound/machines/ping.ogg', 25, 1)
audible_message(SPAN_NOTICE("[icon2html(src, viewers(get_turf(src)))] \The [src] pings."))
. = TRUE
if("locking")
if(editmode)
editmode = FALSE
to_chat(usr, SPAN_NOTICE("Device locked."))
else
if(!editmode)
var/obj/item/card/id/I = usr.GetIdCard()
if(!istype(I))
return
if(check_access(I))
editmode = !editmode
to_chat(usr, SPAN_NOTICE("Device [editmode ? "un" : ""]locked."))
. = TRUE
if("accountselect")
if(!editmode)
to_chat(usr, SPAN_WARNING("Device locked."))
return FALSE
var/dest = tgui_input_list(usr, "What account would you like to select?", "Destination Account", assoc_to_keys(SSeconomy.department_accounts))
if(!dest)
return FALSE
destinationact = dest
return TRUE
/obj/item/quikpay/proc/clear_order()
buying.Cut()
sum = 0
receipt = ""
/obj/item/quikpay/afterattack(atom/target, mob/user, proximity)
if (!proximity) return
if (!istype(target, /obj))
return
if (!editmode)
to_chat(user, SPAN_NOTICE("Unlock \the [src] to add items."))
return
var/obj/O = target
var/name_guess = O.name
var/price_guess = 0
price_guess = text2num(sanitizeSafe( tgui_input_text(user, "Set price for [name_guess]:", "QuikPay", 0, 10), 10))
if(isnull(price_guess) || price_guess == 0)
return
price_guess = max(0, round(price_guess, 0.01))
items += list(list("name" = "[name_guess]", "price" = price_guess))
items_to_price[name_guess] = price_guess
to_chat(user, SPAN_NOTICE("[src]: added '[name_guess]' for [price_guess]."))