Module:NHFurnitureCargoQuery

local p = {} local cargo = mw.ext.cargo local getArgs = require('Module:Arguments').getArgs local currency = require("Module:Currency") local availability = require("Module:Availability") local formatnum = require("Module:Formatnum")

function p.main(frame) local args        = getArgs(frame) local where       = args['where'] or '' local showVariants = args['show-variants'] or '' local groupBy     = args['group by'] or '' local currency2   = args['show-second-currency'] or '' local limit       = args['limit'] or '' local orderBy     = args['order by'] or '' local offset      = args['offset'] or '' local noImage     = args['no image'] or '' return p.outputFurnitureCargo(where, showVariants, groupBy, currency2, limit, orderBy, offset, noImage) end

function p.outputFurnitureCargo(where, showVariants, groupBy, currency2, limit, orderBy, offset, noImage) local function isEmpty(s) return s == nil or s == '' end local print = '' local disableImage = '' local tables = 'nh_furniture,nh_furniture_variation' local fields = "nh_furniture._pageName=pagename,nh_furniture.en_name=name,nh_furniture.catalog_num=catalognum,nh_furniture_variation.variation=variation,nh_furniture_variation.pattern=pattern,nh_furniture_variation.image=image,nh_furniture.buy1_price=buy1price,nh_furniture.buy1_currency=buy1currency,nh_furniture.buy2_price=buy2price,nh_furniture.buy2_currency=buy2currency,nh_furniture.sell=sell,nh_furniture.availability1=availability1,nh_furniture.availability2=availability2,nh_furniture.availability3=availability3,nh_furniture.theme1=theme1,nh_furniture.theme2=theme2,nh_furniture.function1=function1,nh_furniture.function2=function2,nh_furniture.customizable=customizable,nh_furniture.length=length,nh_furniture.width=width" local args = { join = 'nh_furniture_variation.en_name = nh_furniture.en_name', where = where, groupBy = groupBy, orderBy = orderBy, limit = limit, offset = offset, default = '' }   if not isEmpty(noImage) then disableImage = "yes" end local results = cargo.query( tables, fields, args ) for r = 1, #results do print = print .. "| data-sort-value=\"" .. results[r].catalognum .. "\" | " if not isEmpty(results[r].catalognum) then print = print .. formatnum.formatNum(results[r].catalognum,"en") else print = print .. "-"   	end print = print .. "\n" print = print .. "| " .. results[r].name .. "" if not isEmpty(showVariants) and not isEmpty(results[r].variation) then print = print .. " (".. results[r].variation   		if not isEmpty(results[r].pattern) then    			print = print .. " - " .. results[r].pattern    		end    		print = print .. ")" end print = print .. "\n" print = print .. "| \n" print = print .. "| data-sort-value=\"" .. results[r].buy1price .. "\" | " if not isEmpty(results[r].buy1price) then print = print .. currency.outputCurrency(results[r].buy1currency,results[r].buy1price, , , , , '', disableImage) if not isEmpty(currency2) and not isEmpty(results[r].buy2price) then print = print .. " " .. currency.outputCurrency(results[r].buy2currency,results[r].buy2price, , , , , '', disableImage) end else print = print .. "Not for sale" end print = print .. "\n" print = print .. "| data-sort-value=\"" .. results[r].sell .. "\" | " if not isEmpty(results[r].sell) then print = print .. currency.outputCurrency("Bells",results[r].sell, , , , , '', disableImage) else print = print .. "Cannot be sold" end print = print .. "\n" print = print .. "| " .. availability.outputAvailability(results[r].availability1, , , , , , , '', disableImage) if not isEmpty(results[r].availability2) then print = print .. " " .. availability.outputAvailability(results[r].availability2, , , , , , , '', disableImage) end if not isEmpty(results[r].availability3) then print = print .. " " .. availability.outputAvailability(results[r].availability3) end print = print .. "\n" print = print .. "| "   	if not isEmpty(results[r].theme1) then print = print .. results[r].theme1 if not isEmpty(results[r].theme2) then print = print .. " / " .. results[r].theme2 end else print = print .. "-"   	end print = print .. "\n" print = print .. "| "   	if not isEmpty(results[r].function1) then print = print .. results[r].function1 if not isEmpty(results[r].function2) then print = print .. " / " .. results[r].function2 end else print = print .. "-"   	end print = print .. "\n" print = print .. "| "   	if not isEmpty(results[r].customizable) and results[r].customizable == 1 then print = print .. "Yes" else print = print .. "No" end print = print .. "\n" if not isEmpty(disableImage) then print = print .. "| " .. formatnum.formatNum(results[r].length, "en", 1) .. "×" .. formatnum.formatNum(results[r].width, "en", 1) .. "\n" else print = print .. "| \n" end print = print .. "|-\n" end return print end

return p