diff --git a/code/game/objects/items/devices/uplinks.dm b/code/game/objects/items/devices/uplinks.dm index c8f23054e4d..888dd0bb4de 100644 --- a/code/game/objects/items/devices/uplinks.dm +++ b/code/game/objects/items/devices/uplinks.dm @@ -257,6 +257,16 @@ datum/nano_item_lists if(href_list["menu"]) nanoui_menu = text2num(href_list["menu"]) update_nano_data(href_list["id"]) + if(href_list["contract_interact"]) + var/list/params = list("location" = "contract_details", "contract" = href_list["contract_interact"]) + usr.client.process_webint_link("interface/login/sso_server", list2params(params)) + if(href_list["contract_page"]) + nanoui_data["contracts_current_page"] = text2num(href_list["contract_page"]) + update_nano_data() + if(href_list["contract_view"]) + nanoui_data["contracts_view"] = text2num(href_list["contract_view"]) + nanoui_data["contracts_current_page"] = 1 + update_nano_data() interact(usr) return 1 @@ -292,6 +302,111 @@ datum/nano_item_lists nanoui_data["exploit_exists"] = 1 break + if(nanoui_menu == 2) + nanoui_data["contracts_found"] = 0 + + establish_db_connection(dbcon) + + if (dbcon.IsConnected()) + nanoui_data["contracts"] = list() + + if (!nanoui_data["contracts_current_page"]) + nanoui_data["contracts_current_page"] = 1 + + if (!nanoui_data["contracts_view"]) + nanoui_data["contracts_view"] = 1 + + var/query_details[0] + + switch (nanoui_data["contracts_view"]) + if (1) + query_details[":status"] = "open" + if (2) + query_details[":status"] = "closed" + else + nanoui_data["contracts_view"] = 1 + query_details[":status"] = "open" + + var/DBQuery/index_query = dbcon.NewQuery("SELECT count(*) as Total_Contracts FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status") + index_query.Execute(query_details) + + var/pages = 0 + + if (index_query.NextRow()) + var/total_contracts = text2num(index_query.item[1]) + + pages = total_contracts / 10 + + if (total_contracts % 10) + pages++ + + pages = round(pages) + + var/list/contracts_pages = list() + + for (var/i = 1, i <= pages, i++) + contracts_pages.Add(i) + + for (var/a in contracts_pages) + + nanoui_data["contracts_pages"] = contracts_pages + + if (nanoui_data["contracts_current_page"] > pages) + return + + query_details[":offset"] = (nanoui_data["contracts_current_page"] - 1) * 10 + + var/DBQuery/list_query = dbcon.NewQuery("SELECT contract_id, contractee_name, title FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status LIMIT 10 OFFSET :offset") + list_query.Execute(query_details) + + var/list/contracts = list() + while (list_query.NextRow()) + contracts.Add(list(list("id" = list_query.item[1], + "contractee" = list_query.item[2], + "title" = list_query.item[3]))) + + nanoui_data["contracts"] = contracts + + nanoui_data["contracts_found"] = 1 + + if(nanoui_menu == 21) + nanoui_data["contracts_found"] = 0 + + establish_db_connection(dbcon) + + if (dbcon.IsConnected()) + var/query_details[0] + query_details[":contract_id"] = text2num(id) + + var/DBQuery/select_query = dbcon.NewQuery("SELECT contract_id, contractee_name, status, title, description, reward_other FROM ss13_syndie_contracts WHERE contract_id = :contract_id") + select_query.Execute(query_details) + + if (select_query.NextRow()) + nanoui_data["contracts_found"] = 1 + + var/contract[0] + contract["id"] = select_query.item[1] + contract["contractee"] = select_query.item[2] + + switch (select_query.item[3]) + if ("open") + contract["status"] = "1" + else + contract["status"] = "0" + + contract["title"] = html_encode(select_query.item[4]) + contract["description"] = select_query.item[5] + + var/list/nano_blacklist = list("/" = " ", "_" = " ", "\n" = "
") + + for (var/a in nano_blacklist) + contract["description"] = replacetext(contract["description"], a, nano_blacklist[a]) + + contract["description"] = html_encode(contract["description"]) + contract["reward_other"] = select_query.item[6] + + nanoui_data["contract"] = contract + // I placed this here because of how relevant it is. // You place this in your uplinkable item to check if an uplink is active or not. // If it is, it will display the uplink menu and return 1, else it'll return false. diff --git a/nano/templates/uplink.tmpl b/nano/templates/uplink.tmpl index e981155622d..d51aebcbc3a 100644 --- a/nano/templates/uplink.tmpl +++ b/nano/templates/uplink.tmpl @@ -1,5 +1,5 @@ - @@ -13,12 +13,13 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
{{:helper.link('Request Items', 'gear', {'menu' : 0}, null, 'fixedLeftWider')}} {{:helper.link('Exploitable Information', 'gear', {'menu' : 1}, null, 'fixedLeftWider')}} + {{:helper.link('Extranet Contract Database', 'gear', {'menu' : 2}, null, 'fixedLeftWider')}} {{:helper.link('Return', 'arrowreturn-1-w', {'return' : 1}, null, 'fixedLeft')}} {{:helper.link('Close', 'gear', {'lock' : "1"}, null, 'fixedLeft')}}

- + {{if data.menu == 0}}

Request items:

Each item costs a number of tele-crystals as indicated by the number following their name. @@ -39,7 +40,7 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
{{:helper.link( itemValue.Name, 'gear', {'buy_item' : itemValue.obj_path, 'cost' : itemValue.Cost}, itemValue.Cost > data.crystals ? 'disabled' : null, null)}} - {{:itemValue.Cost}}
- + {{if itemValue.Cost <= data.crystals}}
{{:itemValue.Description}} @@ -52,7 +53,7 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
{{:helper.link('Buy Random (??)' , 'gear', {'buy_item' : 'random'}, data.crystals <= 0 ? 'disabled' : null, null)}}
- + {{else data.menu == 1}}

Information Record List:


@@ -65,7 +66,7 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm {{:helper.link(value.Name, 'gear', {'menu' : 11, 'id' : value.id}, null, null)}}
{{/for}} - + {{else data.menu == 11}}

Information Record:


@@ -96,4 +97,73 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm + +{{else data.menu == 2}} +

Available Contracts:

+
+ {{if data.contracts_found == 1}} +
+
+ + {{if data.contracts_view == 1}} + + {{else}} + + {{/if}} + {{for data.contracts}} + + {{/for}} +
IDContractorTitle
Available Contracts
Closed Contracts
{{:value.id}}{{:value.contractee}}{{:value.title}}{{:helper.link('View', null, {'menu' : 21, 'id' : value.id}, null, 'fixedLeft')}}
+
+
+ {{for data.contracts_pages}} + {{:helper.link(value, null, {'contract_page' : value}, null, null)}} + {{/for}} +

+ {{if data.contracts_view == 1}} + {{:helper.link('View Expired Contracts', 'gear', {'contract_view' : 2}, null, null)}} + {{else}} + {{:helper.link('View Open Contracts', 'gear', {'contract_view' : 1}, null, null)}} + {{/if}} +
+
+
+
+ {{else}} +
+
No Contracts Available.
+
+ {{/if}} + +{{else data.menu == 21}} +

Viewing Contract:

+
+
+
+
+ {{if data.contracts_found == 1}} + ID: #{{:data.contract.id}}
+ Contractee: {{:data.contract.contractee}}
+ Status: + {{if data.contract.status == 1}} + Open
+ {{else}} + Closed
+ {{/if}} + Title: {{:data.contract.title}}
+
+ Description: {{:data.contract.description}}
+ Reward: {{:data.contract.reward_other}}
+ {{else}} + Failed to retreive contract information! + {{/if}} +
+ +
+
+

+ {{if data.contracts_found == 1}} + {{:helper.link('View Reports And Updates', 'extlink', {'contract_interact' : data.contract.id}, null, null)}} + {{/if}} + {{/if}}