From bcd628e6729d7fe35a27c1ce07deb463590b2a0f Mon Sep 17 00:00:00 2001 From: skull132 Date: Mon, 5 Jan 2015 23:10:24 +0200 Subject: [PATCH] Beurocracy Adds the ability to print forms from the request console, and to print them. Lays the groundwork for things to move over into adding more paper shenanigans. --- code/game/machinery/requests_console.dm | 125 +++++++++++++++++++++++- code/modules/paperwork/paperbin.dm | 26 ++--- 2 files changed, 138 insertions(+), 13 deletions(-) diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm index 641a2e77..05e12878 100644 --- a/code/game/machinery/requests_console.dm +++ b/code/game/machinery/requests_console.dm @@ -40,6 +40,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() // 8 = view messages // 9 = authentication before sending // 10 = send announcement + // 11 = form database var/silent = 0 // set to 1 for it not to beep all the time // var/hackState = 0 // 0 = not hacked @@ -54,6 +55,9 @@ var/list/obj/machinery/requests_console/allConsoles = list() var/message = ""; var/dpt = ""; //the department which will be receiving the message var/priority = -1 ; //Priority of the message being sent + var/SQLquery + var/paperstock = 10 + var/lid = 0 luminosity = 0 /obj/machinery/requests_console/power_change() @@ -187,6 +191,38 @@ var/list/obj/machinery/requests_console/allConsoles = list() dat += text("Announce
"); dat += text("
Back
") + if(11) //form database + dat += text("NanoTrasen Corporate Forms

") + + establish_db_connection() + + if(!dbcon.IsConnected()) + dat += text("ERROR: Unable to contact external database. Please contact your system administrator for assistance.") + else + dat += {" + "} + + //For reference: + //Command forms, 01xx series + //Security forms, 02xx series + //Medical forms, 03xx series + //Engineer forms, 04xx series + //Science forms, 05xx series + //Supply forms, 06xx series + //General forms, 10xx series + + var/DBQuery/query = dbcon.NewQuery(SQLquery) + query.Execute() + + while(query.NextRow()) + var/id = query.item[1] + var/name = query.item[2] + var/department = query.item[3] + dat += "" + dat += "
NCF IDForm Name
NCF-[id][name][department]Print
" + dat += text("
Reset Search") + dat += text("
Back
") + else //main menu screen = 0 announceAuth = 0 @@ -198,13 +234,22 @@ var/list/obj/machinery/requests_console/allConsoles = list() dat += text("Request Assistance
") dat += text("Request Supplies
") - dat += text("Relay Anonymous Information

") + dat += text("Relay Anonymous Information
") + dat += text("NanoTrasen Corporate Form Database

") if(announcementConsole) dat += text("Send station-wide announcement

") if (silent) dat += text("Speaker OFF") else dat += text("Speaker ON") + if(paperstock) + dat += text("
[paperstock] papers in stock.") + else + dat += text("
No paper in stock.") + if(lid) + dat += text("
Paper container lid OPEN.") + else + dat += text("
Paper container lid CLOSE.") user << browse("[dat]", "window=request_console") onclose(user, "req_console") @@ -314,6 +359,57 @@ var/list/obj/machinery/requests_console/allConsoles = list() for (var/mob/O in hearers(4, src.loc)) O.show_message(text("\icon[src] *The Requests Console beeps: 'NOTICE: No server detected!'")) + if(href_list["sort"]) + var/sortdep = sanitizeSQL(href_list["sort"]) + SQLquery += " WHERE department LIKE '%[sortdep]%'" + screen = 11 + + if(href_list["print"]) + var/printid = sanitizeSQL(href_list["print"]) + establish_db_connection() + + if(!dbcon.IsConnected()) + alert("Connection to the database lost. Aborting.") + var/DBQuery/query = dbcon.NewQuery("SELECT id, name, data FROM aurora_forms WHERE id=[printid]") + query.Execute() + + while(query.NextRow()) + var/id = query.item[1] + var/name = query.item[2] + var/data = query.item[3] + var/obj/item/weapon/paper/C = new(src.loc) + + //Let's start the BB >> HTML conversion! + + data = html_encode(data) + data = replacetext(data, "\n", "
") + + C.info += data + C.info = C.parsepencode(C.info) + C.updateinfolinks() + C.name = "NFC-[id] - [name]" + +/* WIP, finish in a further update. + + if(href_list["info"]) + var/whatisname = sanitizeSQL(href_list["info"]) + establish_db_connection() + + if(!dbcon.IsConnected()) + alert("Connection to the database lost. Aborting.") + var/DBQuery/query = dbcon.NewQuery("SELECT id, name, department, info FROM aurora_forms WHERE name=[whatisname]") + query.Execute() + + while(query.NextRow()) + var/id = query.item[1] + var/name = query.item[2] + var/department = query.item[3] + var/info = query.item[1] +*/ + switch( href_list["setLid"] ) + if(null) //skip + if("1") lid = 1 + else lid = 0 //Handle screen switching switch(text2num(href_list["setScreen"])) @@ -339,6 +435,9 @@ var/list/obj/machinery/requests_console/allConsoles = list() if(10) //send announcement if(!announcementConsole) return screen = 10 + if(11) //form database + SQLquery = "SELECT id, name, department FROM aurora_forms" + screen = 11 else //main menu dpt = "" msgVerified = "" @@ -398,8 +497,25 @@ var/list/obj/machinery/requests_console/allConsoles = list() var/obj/item/weapon/stamp/T = O msgStamped = text("Stamped with the [T.name]") updateUsrDialog() + if (istype(O, /obj/item/weapon/paper_bundle)) + if(lid) //More of that restocking business + var/obj/item/weapon/paper_bundle/C = O + paperstock += C.amount + user.drop_item(C) + del(C) + for (var/mob/U in hearers(4, src.loc)) + U.show_message(text("\icon[src] *The Requests Console beeps: 'Paper added.'")) + else + user << "\blue I should open the lid to add more paper, or try faxing one paper at a time." if (istype(O, /obj/item/weapon/paper)) - if(screen == 0) + if(lid) //Stocking them papers + var/obj/item/weapon/paper/C = O + user.drop_item(C) + del(C) + paperstock++ + for (var/mob/U in hearers(4, src.loc)) + U.show_message(text("\icon[src] *The Requests Console beeps: 'Paper added.'")) + else if(screen == 0) //Faxing them papers var/pass = 0 var/sendto = input("Select department.", "Send Fax", null, null) in allConsoles @@ -411,6 +527,9 @@ var/list/obj/machinery/requests_console/allConsoles = list() var/sent = 0 for (var/obj/machinery/requests_console/Console in world) if (Console == sendto) + if(Console.paperstock == 0) + alert("Error! Receiving console out of paper! Aborting!") + return if(!sent) sent = 1 @@ -446,10 +565,12 @@ var/list/obj/machinery/requests_console/allConsoles = list() playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) for (var/mob/player in hearers(4, Console.loc)) player.show_message(text("\icon[Console] *The Requests Console beeps: 'Fax received'")) + Console.paperstock-- if(sent == 1) user.show_message(text("\icon[src] *The Requests Console beeps: 'Message Sent.'")) else user.show_message(text("\icon[src] *The Requests Console beeps: 'NOTICE: No server detected!'")) + return diff --git a/code/modules/paperwork/paperbin.dm b/code/modules/paperwork/paperbin.dm index 03c59d4a..d44e288e 100644 --- a/code/modules/paperwork/paperbin.dm +++ b/code/modules/paperwork/paperbin.dm @@ -70,17 +70,21 @@ return -/obj/item/weapon/paper_bin/attackby(obj/item/weapon/paper/i as obj, mob/user as mob) - if(!istype(i)) - return - - user.drop_item() - i.loc = src - user << "You put [i] in [src]." - papers.Add(i) - amount++ - - +/obj/item/weapon/paper_bin/attackby(obj/item/weapon/O as obj, mob/user as mob) + if(istype(O, /obj/item/weapon/paper)) + var/obj/item/weapon/paper/i = O + user.drop_item() + i.loc = src + user << "You put [i] in [src]." + papers.Add(i) + amount++ +/* if(istype(O, /obj/item/weapon/paper_pack)) WIP written in. + var/obj/item/weapon/paper_bundle/j = O + user.drop_item() + amount += j.amount + user << "You add paper from [j] into [src]." + del(j) +*/ /obj/item/weapon/paper_bin/examine() set src in oview(1)