:: economy widgets [widget nobr]

<<widget "BrothelStatistics">>
	<<if ($showEconomicDetails)>>
	<<if (!$facility || !$facility.brothel)>>
		<h4>- No statistics for $brothelName gathered this week -</h4>
	<<else>>
		<<set _details = $args[0]>>
		<<set _b = $facility.brothel>>
		<table border="1" style="width: 100%; padding-left: 20px; padding-right: 20px;">
		<tr style="border-bottom: 2px solid white;">
			<th>Items</th>
			<th style="width: 6em">Revenue</th>
			<th style="width: 6em">Expenses</th>
			<th style="width: 6em">Net Income</th>
			<th style="width: 7em">Rep. Change</th>
		</tr>
		<tr>
			<td>Total whoring income</td>
			<td style="padding-right: 2px; text-align: right">@@color:yellowgreen;�<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@color:yellowgreen;�<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right;"><<if (_b.rep > 0)>>@@color:green;+<<= _b.rep.toFixedHTML(1)>>@@<<elseif (_b.rep < 0)>>@@color:red;<<= _b.rep.toFixedHTML(1)>>@@<<else>>�<<= Number(0).toFixedHTML(1)>><</if>></td>
		</tr>
		<tr>
			<td>Total whore living costs</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@color:red;�<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@color:red;�-<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<<if _details>>
		<tr>
			<td colspan="3"><b>Whore details</b>
			<div style="padding-left: 20px; padding-right: 10px;">
			<table style="width: 100%; font-size: 90%; line-height: 110%;">
			<tr>
				<th>Whore</th>
				<th style="width: 5em">Customers</th>
				<th style="width: 20em">Revenue</th>
				<th style="width: 6em">Expenses</th>
				<th style="width: 6em">Net Income</th>
				<th style="width: 7em">Rep. Change</th>
			</tr>
			<<set _slaveDetails = _b.income.values()>>
			<<set _slaveInfo = _slaveDetails.next()>>
			<<for !_slaveInfo.done>>
				<<set _revenue = _slaveInfo.value.income + _slaveInfo.value.adsIncome, _netIncome = _revenue - _slaveInfo.value.cost>>
				<tr>
					<td><<if (_slaveInfo.value.customLabel)>>(@@color:yellow;''_slaveInfo.value.customLabel''@@) <</if>>_slaveInfo.value.slaveName</td>
					<td style="padding-right: 2px; text-align: right"><<if (_slaveInfo.value.customers <= 0)>>@@color:red;none@@<<else>>_slaveInfo.value.customers<</if>></td>
					<td style="padding-right: 2px; text-align: right">@@color:yellowgreen;�<<= _revenue.toFixedHTML(2)>>@@<<if (_slaveInfo.value.adsIncome > 0)>> (@@color:yellowgreen;�<<= _slaveInfo.value.adsIncome.toFixedHTML(2)>>@@ due to advertising)<</if>></td>
					<td style="padding-right: 2px; text-align: right">@@color:red;�<<= _slaveInfo.value.cost.toFixedHTML(2)>>@@</td>
					<td style="padding-right: 2px; text-align: right"><<if (_netIncome > 0)>>@@color:yellowgreen;�<<= _netIncome.toFixedHTML(2)>>@@<<elseif (_netIncome < 0)>>@@color:red;�<<= _netIncome.toFixedHTML(2)>>@@<<else>>�<<= _netIncome.toFixedHTML(2)>><</if>></td>
					<td style="padding-right: 2px; text-align: right;"><<if (_slaveInfo.value.rep > 0)>>@@color:green;+<<= _slaveInfo.value.rep.toFixedHTML(1)>>@@<<elseif (_slaveInfo.value.rep < 0)>>@@color:red;<<= _slaveInfo.value.rep.toFixedHTML(1)>>@@<<else>><</if>></td>
				</tr>
				<<set _slaveInfo = _slaveDetails.next()>>
			<</for>>
			</table></div></td>
			<td></td>
			<td></td>
		</tr>
		<</if>>
		<<if (_b.adsIncome > 0)>>
		<tr>
			<td>Additional income</td>
			<td style="padding-right: 2px; text-align: right">@@color:yellowgreen;�<<= _b.adsIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@color:yellowgreen;�<<= _b.adsIncome.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<</if>>
		<tr>
			<td>Brothel maintenance</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@color:red;�<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@color:red;�-<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<<if (_b.adsCosts > 0)>>
		<tr>
			<td>Advertising program</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@color:red;�<<= _b.adsCosts.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@color:red;�-<<= _b.adsCosts.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<</if>>
		<tr style="border-top: 1px solid white;">
			<td><b>Total</b></td>
			<td style="padding-right: 2px; text-align: right">@@color:yellowgreen;�<<= _b.totalIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@color:red;�<<= _b.totalExpenses.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right"><b><<if (_b.profit > 0)>>@@color:yellowgreen;�<<= _b.profit.toFixedHTML(2)>>@@<<elseif (_b.profit < 0)>>@@color:red;�<<= _b.profit.toFixedHTML(2)>>@@<<else>>�<<= _b.profit.toFixedHTML(2)>><</if>></b></td>
			<td style="padding-right: 2px; text-align: right;"><b><<if (_b.rep > 0)>>@@color:green;+<<= _b.rep.toFixedHTML(1)>>@@<<elseif (_b.rep < 0)>>@@color:red;<<= _b.rep.toFixedHTML(1)>>@@<<else>>�<<= Number(0).toFixedHTML(1)>><</if>></b></td></tr>
		</table>
	<</if>>
	<</if>>
<</widget>>
