root/dev/common/alliance_detail.php @ 130

Revision 130, 11.0 KB (checked in by exi, 14 years ago)

Moved comments to a small class and made it use smarty.
Fixed an error message output of the parser.

Line 
1<?php
2require_once("db.php");
3require_once("class.page.php");
4require_once("class.corp.php");
5require_once("class.alliance.php");
6require_once("class.killlist.php");
7require_once("class.killlisttable.php");
8require_once("class.killsummarytable.php");
9require_once("class.box.php");
10require_once("class.toplist.php");
11
12$alliance = new Alliance(intval($_GET['all_id']));
13$page = new Page("Alliance details - " . $alliance->getName());
14
15$html .= "<table class=kb-table width=\"100%\" border=\"0\" cellspacing=1><tr class=kb-table-row-even><td rowspan=8 width=128 align=center bgcolor=black>";
16
17if (file_exists("img/alliances/".$alliance->getUnique().".png"))
18{
19    $html .= "<img src=\"".IMG_URL."/alliances/".$alliance->getUnique().".png\" border=\"0\"></td>";
20}
21else
22{
23    $html .= "<img src=\"".IMG_URL."/alliances/default.gif\" border=\"0\"></td>";
24}
25$kill_summary = new KillSummaryTable();
26$kill_summary->addInvolvedAlliance($alliance);
27$kill_summary->setBreak(6);
28$summary_html = $kill_summary->generate();
29
30$html .= "<td class=kb-table-cell width=180><b>Kills:</b></td><td class=kl-kill>".$kill_summary->getTotalKills()."</td></tr>";
31$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>".$kill_summary->getTotalLosses()."</td></tr>";
32$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>".round($kill_summary->getTotalKillISK()/1000000, 2)."M</td></tr>";
33$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".round($kill_summary->getTotalLossISK()/1000000, 2)."M</td></tr>";
34if ($kill_summary->getTotalKillISK())
35{
36    $efficiency = round($kill_summary->getTotalKillISK() / ($kill_summary->getTotalKillISK() + $kill_summary->getTotalLossISK()) * 100, 2);
37}
38else
39{
40    $efficiency = 0;
41}
42
43$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Efficiency:</b></td><td class=kb-table-cell><b>" . $efficiency . "%</b></td></tr>";
44
45$html .= "</table>";
46$html .= "<br/>";
47
48if ($_GET['view'] == "" || $_GET['view'] == "kills" || $_GET['view'] == "losses")
49{
50    $html .= $summary_html;
51}
52
53switch ($_GET['view'])
54{
55    case "":
56        $html .= "<div class=kb-kills-header>10 Most recent kills</div>";
57
58        $list = new KillList();
59        $list->setOrdered(true);
60        $list->setLimit(10);
61        $list->setPodsNoobships(true);
62        $list->addInvolvedAlliance($alliance);
63        if ($_GET['scl_id'])
64            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
65
66        $ktab = new KillListTable($list);
67        $ktab->setLimit(10);
68        $ktab->setDayBreak(false);
69        $html .= $ktab->generate();
70
71        $html .= "<div class=kb-losses-header>10 Most recent losses</div>";
72
73        $list = new KillList();
74        $list->setOrdered(true);
75        $list->setLimit(10);
76        $list->setPodsNoobships(true);
77        $list->addVictimAlliance($alliance);
78        if ($_GET['scl_id'])
79            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
80
81        $ltab = new KillListTable($list);
82        $ltab->setLimit(10);
83        $ltab->setDayBreak(false);
84        $html .= $ltab->generate();
85
86        break;
87    case "kills":
88        $html .= "<div class=kb-kills-header>All kills</div>";
89
90        $list = new KillList();
91        $list->setOrdered(true);
92        $list->addInvolvedAlliance($alliance);
93        if ($_GET['scl_id'])
94            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
95        $pagesplitter = new PageSplitter($list->getCount(), 30);
96        $list->setPageSplitter($pagesplitter);
97        $table = new KillListTable($list);
98        $table->setDayBreak(false);
99        $html .= $table->generate();
100        $html .= $pagesplitter->generate();
101
102        break;
103    case "losses":
104        $html .= "<div class=kb-losses-header>All losses</div>";
105
106        $list = new KillList();
107        $list->setOrdered(true);
108        $list->setPodsNoobships(true);
109        $list->addVictimAlliance($alliance);
110        if ($_GET['scl_id'])
111            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
112        $pagesplitter = new PageSplitter($list->getCount(), 30);
113        $list->setPageSplitter($pagesplitter);
114
115        $table = new KillListTable($list);
116        $table->setDayBreak(false);
117        $html .= $table->generate();
118        $html .= $pagesplitter->generate();
119
120        break;
121    case "corp_kills":
122        $html .= "<div class=block-header2>Top killers</div>";
123
124        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
125        $html .= "<div class=block-header>This month</div>";
126
127        $list = new TopCorpKillsList();
128        $list->addInvolvedAlliance($alliance);
129        $list->setPodsNoobShips(false);
130        $list->setMonth(date("m"));
131        $list->setYear(date("Y"));
132        $table = new TopCorpTable($list, "Kills");
133        $html .= $table->generate();
134
135        $html .= "</td><td valign=top width=400>";
136        $html .= "<div class=block-header>All time</div>";
137
138        $list = new TopCorpKillsList();
139        $list->addInvolvedAlliance($alliance);
140        $list->setPodsNoobShips(false);
141        $table = new TopCorpTable($list, "Kills");
142        $html .= $table->generate();
143
144        $html .= "</td></tr></table>";
145
146        break;
147    case "corp_losses":
148        $html .= "<div class=block-header2>Top losers</div>";
149
150        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
151        $html .= "<div class=block-header>This month</div>";
152
153        $list = new TopCorpLossesList();
154        $list->addVictimAlliance($alliance);
155        $list->setPodsNoobShips(false);
156        $list->setMonth(date("m"));
157        $list->setYear(date("Y"));
158        $table = new TopCorpTable($list, "Losses");
159        $html .= $table->generate();
160
161        $html .= "</td><td valign=top width=400>";
162        $html .= "<div class=block-header>All time</div>";
163
164        $list = new TopCorpLossesList();
165        $list->addVictimAlliance($alliance);
166        $list->setPodsNoobShips(false);
167        $table = new TopCorpTable($list, "Losses");
168        $html .= $table->generate();
169
170        $html .= "</td></tr></table>";
171
172        break;
173    case "pilot_kills":
174        $html .= "<div class=block-header2>Top killers</div>";
175
176        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
177        $html .= "<div class=block-header>This month</div>";
178
179        $list = new TopKillsList();
180        $list->addInvolvedAlliance($alliance);
181        $list->setPodsNoobShips(false);
182        $list->setMonth(date("m"));
183        $list->setYear(date("Y"));
184        $table = new TopPilotTable($list, "Kills");
185        $html .= $table->generate();
186
187        $html .= "</td><td valign=top width=400>";
188        $html .= "<div class=block-header>All time</div>";
189
190        $list = new TopKillsList();
191        $list->addInvolvedAlliance($alliance);
192        $list->setPodsNoobShips(false);
193        $table = new TopPilotTable($list, "Kills");
194        $html .= $table->generate();
195
196        $html .= "</td></tr></table>";
197
198        break;
199    case "pilot_scores":
200        $html .= "<div class=block-header2>Top scorers</div>";
201
202        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
203        $html .= "<div class=block-header>This month</div>";
204
205        $list = new TopScoreList();
206        $list->addInvolvedAlliance($alliance);
207        $list->setPodsNoobShips(true);
208        $list->setMonth(date("m"));
209        $list->setYear(date("Y"));
210        $table = new TopPilotTable($list, "Points");
211        $html .= $table->generate();
212
213        $html .= "</td><td valign=top width=400>";
214        $html .= "<div class=block-header>All time</div>";
215
216        $list = new TopScoreList();
217        $list->addInvolvedAlliance($alliance);
218        $list->setPodsNoobShips(true);
219        $table = new TopPilotTable($list, "Points");
220        $html .= $table->generate();
221
222        $html .= "</td></tr></table>";
223
224        break;
225    case "pilot_losses":
226        $html .= "<div class=block-header2>Top losers</div>";
227
228        $html .= "<table class=kb-subtable><tr><td valign=top width=440>";
229        $html .= "<div class=block-header>This month</div>";
230
231        $list = new TopLossesList();
232        $list->addVictimAlliance($alliance);
233        $list->setPodsNoobShips(false);
234        $list->setMonth(date("m"));
235        $list->setYear(date("Y"));
236        $table = new TopPilotTable($list, "Losses");
237        $html .= $table->generate();
238
239        $html .= "</td><td valign=top width=400>";
240        $html .= "<div class=block-header>All time</div>";
241
242        $list = new TopLossesList();
243        $list->addVictimAlliance($alliance);
244        $list->setPodsNoobShips(false);
245        $table = new TopPilotTable($list, "Losses");
246        $html .= $table->generate();
247
248        $html .= "</td></tr></table>";
249
250        break;
251    case "ships_weapons":
252        $html .= "<div class=block-header2>Ships & weapons used</div>";
253
254        $html .= "<table class=kb-subtable><tr><td valign=top width=400>";
255        $shiplist = new TopShipList();
256        $shiplist->addInvolvedAlliance($alliance);
257        $shiplisttable = new TopShipListTable($shiplist);
258        $html .= $shiplisttable->generate();
259        $html .= "</td><td valign=top align=right width=400>";
260
261        $weaponlist = new TopWeaponList();
262        $weaponlist->addInvolvedAlliance($alliance);
263        $weaponlisttable = new TopWeaponListTable($weaponlist);
264        $html .= $weaponlisttable->generate();
265        $html .= "</td></tr></table>";
266
267        break;
268}
269
270$menubox = new Box("Menu");
271$menubox->setIcon("menu-item.gif");
272$menubox->addOption("caption","Kills & losses");
273$menubox->addOption("link","Recent activity", "?a=alliance_detail&all_id=" . $alliance->getID());
274$menubox->addOption("link","Kills", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=kills");
275$menubox->addOption("link","Losses", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=losses");
276$menubox->addOption("caption","Corp statistics");
277$menubox->addOption("link","Top killers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=corp_kills");
278$menubox->addOption("link","Top losers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=corp_losses");
279
280$menubox->addOption("caption","Pilot statistics");
281$menubox->addOption("link","Top killers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=pilot_kills");
282if ($config->getConfig('kill_points'))
283{
284    $menubox->addOption('link', "Top scorers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=pilot_scores");
285}
286$menubox->addOption("link","Top losers", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=pilot_losses");
287$menubox->addOption("caption","Global statistics");
288$menubox->addOption("link","Ships & weapons", "?a=alliance_detail&all_id=" . $alliance->getID() . "&view=ships_weapons");
289$page->addContext($menubox->generate());
290
291$page->setContent($html);
292$page->generate();
293?>
Note: See TracBrowser for help on using the browser.