-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayOut.php
76 lines (64 loc) · 3.57 KB
/
payOut.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/*
* Copyright (C) 2011 Ryan Holmes
* <http://www.gnu.org/licenses/agpl.html>
*/
require '_.php';
$Page->header('Pay Out');
if (!$User->hasRole('director')){
$Page->errorfooter('Sorry, but only Directors or other trusted members can access the loot container, and thus sell it.'); }
if (filter_has_var(INPUT_POST, 'submitPayed')){
// todo: if refreshed, payment info will be updated again... Don't do that
// Perhaps set, thun unset, some session vars
$DB->e("UPDATE saleHistory SET payer = ?, payedTime = ? WHERE saleID = ?", $User->charID, time(), filter_input(INPUT_POST, 'submitPayed', FILTER_SANITIZE_NUMBER_INT));
echo "
<h2>Payments Complete</h2>
<p>With payment completed, this sale and the operations associated with it will now go into archives. Thank you!</p>";
$Page->footer();
}
else if (filter_has_var(INPUT_POST, 'payout')){
/*
make it so that the checkboxes are REQUIRED
*/
echo "<h2>Pay Out</h2><p>Click name to open Show Info. In the top left corner there's a white box thing. Click it -> Give Money and type in the amount you see here. Checkboxes are provided to help you keep track of who has been payed; they serve no other function. <strong>Remember:</strong> Click the \"Done!\" button when finished to complete payout.</p>
<p><strong>".(TAX*100)."%</strong> corp tax is automatically applied to calculations, which is then added to whatever has been left over from from total profit due to rounding down.</p><hr /><dl>";
$data = $DB->qa("
SELECT *, payout - (payout*?) AS truePayout, (payout*?) as tax
FROM memberPayout
WHERE saleID = ?", array(TAX, TAX, filter_input(INPUT_POST, 'payout', FILTER_SANITIZE_NUMBER_INT)));
$corpTax = $DB->q1("SELECT difference FROM `profit-payout` WHERE saleID = ?", array(filter_input(INPUT_POST, 'payout', FILTER_SANITIZE_NUMBER_INT)));
$class = 'even';
foreach ($data AS $character) {
$class = ($class == 'even' ? 'odd' : 'even');
$corpTax = $corpTax+$character['tax'];
echo "
<dt class='".$class."'><input type='checkbox' /> <img style='vertical-align: middle;' src='http://evefiles.capsuleer.de/icons/16_16/icon09_09.png' />
<a onclick='CCPEVE.showInfo(1377, ".$character['charID'].")'> ".$character['name']."</a></dt><dd class='".$class."'>".number_format($character['truePayout'])."</dd>"; }
echo "
<dt class='".($class == 'even' ? 'odd' : 'even')."'><input type='checkbox' /> <img style='vertical-align: middle;' src='http://evefiles.capsuleer.de/icons/16_16/icon09_09.png' />
<a onclick='CCPEVE.showInfo(2, ".CORPID.")'> ".CORPTIC." ".CORP."</a></dt><dd class='".($class == 'even' ? 'odd' : 'even')."'>".number_format($corpTax)."</dd>
</dl>
<form action='".$_SERVER['PHP_SELF']."' method='post'><p class='submit'>
<button name='submitPayed' value='".filter_input(INPUT_POST, 'payout', FILTER_SANITIZE_NUMBER_INT)."'>Done!</button></p></form>";
}
else {
echo "
<h2>Pay Out</h2>
<p>These loot runs have yet to be payed out. Please choose one to pay out.</p>";
$payouts = $DB->qa("
SELECT saleHistory.*, COUNT(op2sale.opID) AS opCount, memberList.name
FROM saleHistory
NATURAL JOIN op2sale
INNER JOIN memberList ON (saleHistory.seller = memberList.charID)
WHERE payedTime IS NULL
GROUP BY saleID", array());
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'><ul>\n";
foreach ($payouts AS $payout) {
echo "
<li><button type='submit' name='payout' value='".$payout['saleID']."'>Pay</button>
".$payout['name']." sold stuff on ".date('m/d \a\t H:i', $payout['saleTime'])." (# of operations: ".$payout['opCount'].")</li>";
}
echo "</ul></form>";
}
$Page->footer();
?>