:: 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>>
		<<set _b.whoreIncome = (def _b.whoreIncome) ? _b.whoreIncome : 0>>
		<<set _b.rep = (def _b.rep) ? _b.rep : 0>>
		<<set _b.whoreCosts = (def _b.whoreCosts) ? _b.whoreCosts : 0>>
		<<set _b.adsIncome = (def _b.adsIncome) ? _b.adsIncome : 0>>
		<<set _b.maintenance = (def _b.maintenance) ? _b.maintenance : 0>>
		<<set _b.adsCosts = (def _b.adsCosts) ? _b.adsCosts : 0>>
		<<set _b.totalIncome = (def _b.totalIncome) ? _b.totalIncome : 0>>
		<<set _b.totalExpenses = (def _b.totalExpenses) ? _b.totalExpenses : 0>>
		<<set _b.profit = (def _b.profit) ? _b.profit : 0>>
		<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: 20em; text-align: right">Revenue</th>
			<th style="width: 10em; text-align: right">Expenses</th>
			<th style="width: 10em; text-align: right">Net Income</th>
			<th style="width: 10em; text-align: right">Rep. Change</th>
		</tr>
		<tr>
			<td>Total whoring income</td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right;"><<if (_b.rep > 0)>>@@.green;+<<= _b.rep.toFixedHTML(1)>>@@<<elseif (_b.rep < 0)>>@@.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: 3px; text-align: right">@@.red;¤<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤-<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<<if _details>>
		<tr>
			<td colspan="5"><b>Whore details</b>
			<table style="width: 100%; font-size: 90%; line-height: 110%;">
			<tr>
				<th>Whore</th>
				<th style="width: 10em; text-align: right">Customers</th>
				<th style="width: 22em; text-align: right">Revenue</th>
				<th style="width: 11em; text-align: right">Expenses</th>
				<th style="width: 11.5em; text-align: right">Net Income</th>
				<th style="width: 11em; text-align: right">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 style="border-bottom: 1px solid #aaa; border-left: none; border-right: none; border-top: none">
					<td><<if (_slaveInfo.value.customLabel)>>(@@.yellow;''_slaveInfo.value.customLabel''@@) <</if>>_slaveInfo.value.slaveName</td>
					<td style="padding-right: 3px; text-align: right"><<if (_slaveInfo.value.customers <= 0)>>@@.red;none@@<<else>>_slaveInfo.value.customers<</if>></td>
					<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _revenue.toFixedHTML(2)>>@@<<if (_slaveInfo.value.adsIncome > 0)>> (@@.yellowgreen;¤<<= _slaveInfo.value.adsIncome.toFixedHTML(2)>>@@ due to advertising)<</if>></td>
					<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _slaveInfo.value.cost.toFixedHTML(2)>>@@</td>
					<td style="padding-right: 3px; text-align: right"><<if (_netIncome > 0)>>@@.yellowgreen;¤<<= _netIncome.toFixedHTML(2)>>@@<<elseif (_netIncome < 0)>>@@.red;¤<<= _netIncome.toFixedHTML(2)>>@@<<else>>¤<<= _netIncome.toFixedHTML(2)>><</if>></td>
					<td style="padding-right: 3px; text-align: right;"><<if (_slaveInfo.value.rep > 0)>>@@.green;+<<= _slaveInfo.value.rep.toFixedHTML(1)>>@@<<elseif (_slaveInfo.value.rep < 0)>>@@.red;<<= _slaveInfo.value.rep.toFixedHTML(1)>>@@<<else>><</if>></td>
				</tr>
				<<set _slaveInfo = _slaveDetails.next()>>
			<</for>>
			</table>
			</td>
		</tr>
		<</if>>
		<<if (_b.adsIncome > 0)>>
		<tr>
			<td>Additional income</td>
			<td style="padding-right: 2px; text-align: right">@@.yellowgreen;¤<<= _b.adsIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@.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">@@.red;¤<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.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">@@.red;¤<<= _b.adsCosts.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.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">@@.yellowgreen;¤<<= _b.totalIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.totalExpenses.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right"><b><<if (_b.profit > 0)>>@@.yellowgreen;¤<<= _b.profit.toFixedHTML(2)>>@@<<elseif (_b.profit < 0)>>@@.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)>>@@.green;+<<= _b.rep.toFixedHTML(1)>>@@<<elseif (_b.rep < 0)>>@@.red;<<= _b.rep.toFixedHTML(1)>>@@<<else>>±<<= Number(0).toFixedHTML(1)>><</if>></b></td></tr>
		</table>
	<</if>>
	<</if>>
<</widget>>

<<widget "ClubStatistics">>
	<<if ($showEconomicDetails)>>
	<<if (!$facility || !$facility.club)>>
		<h4>- No statistics for $clubName gathered this week -</h4>
	<<else>>
		<<set _details = $args[0]>>
		<<set _b = $facility.club>>
		<<set _b.whoreIncome = (def _b.whoreIncome) ? _b.whoreIncome : 0>>
		<<set _b.rep = (def _b.rep) ? _b.rep : 0>>
		<<set _b.whoreCosts = (def _b.whoreCosts) ? _b.whoreCosts : 0>>
		<<set _b.adsIncome = (def _b.adsIncome) ? _b.adsIncome : 0>>
		<<set _b.maintenance = (def _b.maintenance) ? _b.maintenance : 0>>
		<<set _b.adsCosts = (def _b.adsCosts) ? _b.adsCosts : 0>>
		<<set _b.totalIncome = (def _b.totalIncome) ? _b.totalIncome : 0>>
		<<set _b.totalExpenses = (def _b.totalExpenses) ? _b.totalExpenses : 0>>
		<<set _b.profit = (def _b.profit) ? _b.profit : 0>>
		<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: 20em; text-align: right">Rep. Gain</th>
			<th style="width: 10em; text-align: right">Expenses</th>
			<th style="width: 10em; text-align: right">Rep/Expenses</th>
			<th style="width: 10em; text-align: right">Extra Income</th>
		</tr>
		<tr>
			<td>Total whoring income</td>
			<td style="padding-right: 3px; text-align: right">@@.green;+<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td></td>
			<td style="padding-right: 3px; text-align: right;"><<if (_b.rep > 0)>>@@.green;¤<<= _b.rep.toFixedHTML(1)>>@@<<elseif (_b.rep < 0)>>@@.red;¤<<= -_b.rep.toFixedHTML(1)>>@@<</if>></td>
		</tr>
		<tr>
			<td>Total whore living costs</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td></td>
			<td></td>
		</tr>
		<<if _details>>
		<tr>
			<td colspan="5"><b>Whore details</b>
			<table style="width: 100%; font-size: 90%; line-height: 110%;">
			<tr>
				<th>Whore</th>
				<th style="width: 10em; text-align: right">Customers</th>
				<th style="width: 22em; text-align: right">Rep. Gain</th>
				<th style="width: 11em; text-align: right">Expenses</th>
				<th style="width: 11.5em; text-align: right">Rep/Expenses</th>
				<th style="width: 11em; text-align: right">Extra Income</th>
			</tr>
			<<set _slaveDetails = _b.income.values()>>
			<<set _slaveInfo = _slaveDetails.next()>>
			<<for !_slaveInfo.done>>
				<<set _netIncome = _slaveInfo.value.income / _slaveInfo.value.cost>>
				<tr style="border-bottom: 1px solid #aaa; border-left: none; border-right: none; border-top: none">
					<td><<if (_slaveInfo.value.customLabel)>>(@@.yellow;''_slaveInfo.value.customLabel''@@) <</if>>_slaveInfo.value.slaveName</td>
					<td style="padding-right: 3px; text-align: right"><<if (_slaveInfo.value.customers <= 0)>>@@.red;none@@<<else>>_slaveInfo.value.customers<</if>></td>
					<td style="padding-right: 3px; text-align: right">@@.green;+<<= _slaveInfo.value.income.toFixedHTML(2)>>@@</td>
					<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _slaveInfo.value.cost.toFixedHTML(2)>>@@</td>
					<td style="padding-right: 3px; text-align: right">@@.green;<<= _netIncome.toFixedHTML(2)>>@@ rep/¤</td>
					<td style="padding-right: 3px; text-align: right;">@@.yellowgreen;¤<<= _slaveInfo.value.rep.toFixedHTML(1)>>@@</td>
				</tr>
				<<set _slaveInfo = _slaveDetails.next()>>
			<</for>>
			</table>
			</td>
		</tr>
		<</if>>
		<<if (_b.adsIncome > 0)>>
		<tr>
			<td>Additional rep gain</td>
			<td style="padding-right: 2px; text-align: right">@@.green;+<<= _b.adsIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
		<</if>>
		<tr>
			<td>Club maintenance</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td></td>
			<td></td>
		</tr>
		<<if (_b.adsCosts > 0)>>
		<tr>
			<td>Advertising program</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.adsCosts.toFixedHTML(2)>>@@</td>
			<td></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">@@.green;+<<= _b.totalIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.totalExpenses.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right"><b>@@.green;<<= _b.profit.toFixedHTML(2)>>@@ rep/¤</b></td>
			<td style="padding-right: 2px; text-align: right;"><b>@@.green;+<<= _b.rep.toFixedHTML(1)>>@@</b></td></tr>
		</table>
	<</if>>
	<</if>>
<</widget>>

<<widget "DairyStatistics">>
	<<if ($showEconomicDetails)>>
	<<if (!$facility || !$facility.dairy)>>
		<h4>- No statistics for $dairyName gathered this week -</h4>
	<<else>>
		<<set _details = $args[0]>>
		<<set _b = $facility.dairy>>
		<<set _b.whoreIncome = (def _b.whoreIncome) ? _b.whoreIncome : 0>>
		<<set _b.whoreCosts = (def _b.whoreCosts) ? _b.whoreCosts : 0>>
		<<set _b.maintenance = (def _b.maintenance) ? _b.maintenance : 0>>
		<<set _b.totalIncome = (def _b.totalIncome) ? _b.totalIncome : 0>>
		<<set _b.totalExpenses = (def _b.totalExpenses) ? _b.totalExpenses : 0>>
		<<set _b.profit = (def _b.profit) ? _b.profit : 0>>
		<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: 20em; text-align: right">Revenue</th>
			<th style="width: 10em; text-align: right">Expenses</th>
			<th style="width: 10em; text-align: right">Net Income</th>
			<th style="width: 10em; text-align: right">Rep. Change</th>
		</tr>
		<tr>
			<td>Total cow income</td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right;"></td>
		</tr>
		<tr>
			<td>Total cow living costs</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤-<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<<if _details>>
		<tr>
			<td colspan="5"><b>Cow details</b>
			<table style="width: 100%; font-size: 90%; line-height: 110%;">
			<tr>
				<th>Cow</th>
				<th style="width: 10em; text-align: right">Milk/Cum/Fluids</th>
				<th style="width: 22em; text-align: right">Revenue</th>
				<th style="width: 11em; text-align: right">Expenses</th>
				<th style="width: 11.5em; text-align: right">Net Income</th>
				<th style="width: 11em; text-align: right">Rep. Change</th>
			</tr>
			<<set _slaveDetails = _b.income.values()>>
			<<set _slaveInfo = _slaveDetails.next()>>
			<<for !_slaveInfo.done>>
				<<set _revenue = _slaveInfo.value.income, _netIncome = _revenue - _slaveInfo.value.cost>>
				<tr style="border-bottom: 1px solid #aaa; border-left: none; border-right: none; border-top: none">
					<td><<if (_slaveInfo.value.customLabel)>>(@@.yellow;''_slaveInfo.value.customLabel''@@) <</if>>_slaveInfo.value.slaveName</td>
					<td style="padding-right: 3px; text-align: right"><<= _slaveInfo.value.milk>>/<<= _slaveInfo.value.cum>>/<<= _slaveInfo.value.fluid>></td>
					<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _revenue.toFixedHTML(2)>>@@<<if (_slaveInfo.value.adsIncome > 0)>> (@@.yellowgreen;¤<<= _slaveInfo.value.adsIncome.toFixedHTML(2)>>@@ due to advertising)<</if>></td>
					<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _slaveInfo.value.cost.toFixedHTML(2)>>@@</td>
					<td style="padding-right: 3px; text-align: right"><<if (_netIncome > 0)>>@@.yellowgreen;¤<<= _netIncome.toFixedHTML(2)>>@@<<elseif (_netIncome < 0)>>@@.red;¤<<= _netIncome.toFixedHTML(2)>>@@<<else>>¤<<= _netIncome.toFixedHTML(2)>><</if>></td>
					<td style="padding-right: 3px; text-align: right;"></td>
				</tr>
				<<set _slaveInfo = _slaveDetails.next()>>
			<</for>>
			</table>
			</td>
		</tr>
		<</if>>
		<tr>
			<td>Dairy maintenance</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤-<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<tr style="border-top: 1px solid white;">
			<td><b>Total</b></td>
			<td style="padding-right: 2px; text-align: right">@@.yellowgreen;¤<<= _b.totalIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.totalExpenses.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right"><b><<if (_b.profit > 0)>>@@.yellowgreen;¤<<= _b.profit.toFixedHTML(2)>>@@<<elseif (_b.profit < 0)>>@@.red;¤<<= _b.profit.toFixedHTML(2)>>@@<<else>>¤<<= _b.profit.toFixedHTML(2)>><</if>></b></td>
			<td style="padding-right: 2px; text-align: right;"><b></b></td></tr>
		</table>
	<</if>>
	<</if>>
<</widget>>

<<widget "FarmyardStatistics">>
	<<if ($showEconomicDetails)>>
	<<if (!$facility || !$facility.farmyard)>>
		<h4>- No statistics for $farmyardName gathered this week -</h4>
	<<else>>
		<<set _details = $args[0]>>
		<<set _b = $facility.farmyard>>
		<<set _b.farmhandIncome = (def _b.farmhandIncome) ? _b.farmhandIncome : 0>>
		<<set _b.farmhandCosts = (def _b.farmhandCosts) ? _b.farmhandCosts : 0>>
		<<set _b.maintenance = (def _b.maintenance) ? _b.maintenance : 0>>
		<<set _b.totalIncome = (def _b.totalIncome) ? _b.totalIncome : 0>>
		<<set _b.totalExpenses = (def _b.totalExpenses) ? _b.totalExpenses : 0>>
		<<set _b.food = (def _b.food) ? _b.food : 0>>
		<<set _b.profit = (def _b.profit) ? _b.profit : 0>>
		<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: 20em; text-align: right">Revenue</th>
			<th style="width: 10em; text-align: right">Expenses</th>
			<th style="width: 10em; text-align: right">Net Income</th>
			<th style="width: 10em; text-align: right">Rep. Change</th>
		</tr>
		<tr>
			<td>Total farmhand income</td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.farmhandIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.farmhandIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right;"></td>
		</tr>
		<tr>
			<td>Total farmhand living costs</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _b.farmhandCosts.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤-<<= _b.farmhandCosts.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<<if _details>>
		<tr>
			<td colspan="5"><b>Farmhand details</b>
			<table style="width: 100%; font-size: 90%; line-height: 110%;">
			<tr>
				<th>Farmhand</th>
				<th style="width: 10em; text-align: right">Milk/Cum/Fluids</th>
				<th style="width: 22em; text-align: right">Revenue</th>
				<th style="width: 11em; text-align: right">Expenses</th>
				<th style="width: 11.5em; text-align: right">Net Income</th>
				<th style="width: 11em; text-align: right">Rep. Change</th>
			</tr>
			<<set _slaveDetails = _b.income.values()>>
			<<set _slaveInfo = _slaveDetails.next()>>
			<<for !_slaveInfo.done>>
				<<set _revenue = _slaveInfo.value.income, _netIncome = _revenue - _slaveInfo.value.cost>>
				<tr style="border-bottom: 1px solid #aaa; border-left: none; border-right: none; border-top: none">
					<td><<if (_slaveInfo.value.customLabel)>>(@@.yellow;''_slaveInfo.value.customLabel''@@) <</if>>_slaveInfo.value.slaveName</td>
					<td style="padding-right: 3px; text-align: right"><<= _slaveInfo.value.milk>>/<<= _slaveInfo.value.cum>>/<<= _slaveInfo.value.fluid>></td>
					<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _revenue.toFixedHTML(2)>>@@<<if (_slaveInfo.value.adsIncome > 0)>> (@@.yellowgreen;¤<<= _slaveInfo.value.adsIncome.toFixedHTML(2)>>@@ due to advertising)<</if>></td>
					<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _slaveInfo.value.cost.toFixedHTML(2)>>@@</td>
					<td style="padding-right: 3px; text-align: right"><<if (_netIncome > 0)>>@@.yellowgreen;¤<<= _netIncome.toFixedHTML(2)>>@@<<elseif (_netIncome < 0)>>@@.red;¤<<= _netIncome.toFixedHTML(2)>>@@<<else>>¤<<= _netIncome.toFixedHTML(2)>><</if>></td>
					<td style="padding-right: 3px; text-align: right;"></td>
				</tr>
				<<set _slaveInfo = _slaveDetails.next()>>
			<</for>>
			</table>
			</td>
		</tr>
		<</if>>
		<tr>
			<td>Farmyard maintenance</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤-<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<tr style="border-top: 1px solid white;">
			<td><b>Total</b></td>
			<td style="padding-right: 2px; text-align: right">@@.yellowgreen;¤<<= _b.totalIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.totalExpenses.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right"><b><<if (_b.profit > 0)>>@@.yellowgreen;¤<<= _b.profit.toFixedHTML(2)>>@@<<elseif (_b.profit < 0)>>@@.red;¤<<= _b.profit.toFixedHTML(2)>>@@<<else>>¤<<= _b.profit.toFixedHTML(2)>><</if>></b></td>
			<td style="padding-right: 2px; text-align: right;"><b></b></td></tr>
		</table>
	<</if>>
	<</if>>
<</widget>>

<<widget "ArcadeStatistics">>
	<<if ($showEconomicDetails)>>
	<<if (!$facility || !$facility.arcade)>>
		<h4>- No statistics for $arcadeName gathered this week -</h4>
	<<else>>
		<<set _details = $args[0]>>
		<<set _b = $facility.arcade>>
		<<set _b.whoreIncome = (def _b.whoreIncome) ? _b.whoreIncome : 0>>
		<<set _b.rep = (def _b.rep) ? _b.rep : 0>>
		<<set _b.whoreCosts = (def _b.whoreCosts) ? _b.whoreCosts : 0>>
		<<set _b.maintenance = (def _b.maintenance) ? _b.maintenance : 0>>
		<<set _b.totalIncome = (def _b.totalIncome) ? _b.totalIncome : 0>>
		<<set _b.totalExpenses = (def _b.totalExpenses) ? _b.totalExpenses : 0>>
		<<set _b.profit = (def _b.profit) ? _b.profit : 0>>
		<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: 20em; text-align: right">Revenue</th>
			<th style="width: 10em; text-align: right">Expenses</th>
			<th style="width: 10em; text-align: right">Net Income</th>
			<th style="width: 10em; text-align: right">Rep. Change</th>
		</tr>
		<tr>
			<td>Total income</td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _b.whoreIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right;"><<if (_b.rep > 0)>>@@.green;+<<= _b.rep.toFixedHTML(1)>>@@<<elseif (_b.rep < 0)>>@@.red;<<= _b.rep.toFixedHTML(1)>>@@<<else>>±<<= Number(0).toFixedHTML(1)>><</if>></td>
		</tr>
		<tr>
			<td>Total fuckmeat living costs</td>
			<td></td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 3px; text-align: right">@@.red;¤-<<= _b.whoreCosts.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<<if _details>>
			<tr>
			<td colspan="5"><b>Fuckmeat details</b>
			<table style="width: 100%; font-size: 90%; line-height: 110%;">
			<tr>
				<th>Fuckmeat</th>
				<th style="width: 10em; text-align: right">Customers</th>
				<th style="width: 22em; text-align: right">Revenue</th>
				<th style="width: 11em; text-align: right">Expenses</th>
				<th style="width: 11.5em; text-align: right">Net Income</th>
				<th style="width: 11em; text-align: right">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 style="border-bottom: 1px solid #aaa; border-left: none; border-right: none; border-top: none">
					<td><<if (_slaveInfo.value.customLabel)>>(@@.yellow;''_slaveInfo.value.customLabel''@@) <</if>>_slaveInfo.value.slaveName</td>
					<td style="padding-right: 3px; text-align: right"><<if (_slaveInfo.value.customers <= 0)>>@@.red;none@@<<else>>_slaveInfo.value.customers<</if>></td>
					<td style="padding-right: 3px; text-align: right">@@.yellowgreen;¤<<= _revenue.toFixedHTML(2)>>@@<<if (_slaveInfo.value.adsIncome > 0)>> (@@.yellowgreen;¤<<= _slaveInfo.value.adsIncome.toFixedHTML(2)>>@@ due to advertising)<</if>></td>
					<td style="padding-right: 3px; text-align: right">@@.red;¤<<= _slaveInfo.value.cost.toFixedHTML(2)>>@@</td>
					<td style="padding-right: 3px; text-align: right"><<if (_netIncome > 0)>>@@.yellowgreen;¤<<= _netIncome.toFixedHTML(2)>>@@<<elseif (_netIncome < 0)>>@@.red;¤<<= _netIncome.toFixedHTML(2)>>@@<<else>>¤<<= _netIncome.toFixedHTML(2)>><</if>></td>
					<td style="padding-right: 3px; text-align: right;"><<if (_slaveInfo.value.rep > 0)>>@@.green;+<<= _slaveInfo.value.rep.toFixedHTML(1)>>@@<<elseif (_slaveInfo.value.rep < 0)>>@@.red;<<= _slaveInfo.value.rep.toFixedHTML(1)>>@@<<else>><</if>></td>
				</tr>
				<<set _slaveInfo = _slaveDetails.next()>>
			<</for>>
			</table>
			</td>
			</tr>
		<</if>>
		<tr>
			<td>Arcade maintenance</td>
			<td></td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤-<<= _b.maintenance.toFixedHTML(2)>>@@</td>
			<td></td>
		</tr>
		<tr style="border-top: 1px solid white;">
			<td><b>Total</b></td>
			<td style="padding-right: 2px; text-align: right">@@.yellowgreen;¤<<= _b.totalIncome.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right">@@.red;¤<<= _b.totalExpenses.toFixedHTML(2)>>@@</td>
			<td style="padding-right: 2px; text-align: right"><b><<if (_b.profit > 0)>>@@.yellowgreen;¤<<= _b.profit.toFixedHTML(2)>>@@<<elseif (_b.profit < 0)>>@@.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)>>@@.green;+<<= _b.rep.toFixedHTML(1)>>@@<<elseif (_b.rep < 0)>>@@.red;<<= _b.rep.toFixedHTML(1)>>@@<<else>>±<<= Number(0).toFixedHTML(1)>><</if>></b></td></tr>
		</table>
	<</if>>
	<</if>>
<</widget>>

src/pregmod/widgets/economyWidgets.tw