root/dev/common/cc_detail.php @ 44

Revision 44, 9.4 KB (checked in by exi, 16 years ago)

Changed Synchronization to use http-request class
Changed portrait generation to use http class and fixed some issues there aswell
Ordered Killist on alliance losses / explicit cast to int from URI
Added date support to comments (autoupgrading, just save your settings once again)
Added a combined view to campaigns so you can filter kills and losses for each shipclass on one page
Cast corpid to int from URI
Changed DB, define DB_HALTONERROR in your config to stop page generation on error.
Set minor version to svn revision
Adding base alliance logos as stated on  http://www.eve-dev.net/forums/viewtopic.php?t=35 Thanks to DarkXeRoX for those.

Line 
1<?php
2require_once("db.php");
3require_once("class.page.php");
4require_once("class.killlist.php");
5require_once("class.killlisttable.php");
6require_once("class.killsummarytable.php");
7require_once("class.contract.php");
8require_once("class.box.php");
9require_once("class.toplist.php");
10require_once("class.graph.php");
11
12$ctr_id = $_GET['ctr_id'];
13
14$contract = new Contract($ctr_id);
15
16if ($contract->getCampaign())
17    $title = "Campaign details";
18else
19    $title = "Contract details";
20
21$page = new Page($title . " - " . $contract->getName());
22
23$html .= "<table align=center class=kb-table width=\"100%\" height=\"80\" border=\"0\" cellspacing=1><tr class=kb-table-row-even><td rowspan=5 align=center width=80 height=80>";
24// table class=kb-subtable cellspacing=0><tr class=kb-table-row-even><td width=80 height=80 align=center>";
25if ($contract->getCampaign())
26    $html .= "<img src=\"" . IMG_URL . "/campaign-big.gif\" align=center>";
27else
28    $html .= "<img src=\"" . IMG_URL . "/contract-big.gif\" align=center>";
29
30$html .= "</td>";
31// $html .= "<td valign=top align=left height=80>";
32// $html .= "<table class=kb-subtable width=\"100%\" height=\"100%\" cellspacing=1 border=\"0\">";
33if ($contract->getEndDate() == "")
34    $ended = "Active";
35else
36    $ended = substr($contract->getEndDate(), 0, 10);
37$html .= "<td class=kb-table-cell><b>Start date:</b></td><td class=kb-table-cell width=120><b>" . substr($contract->getStartDate(), 0, 10) . "</b></td><td class=kb-table-cell><b>End date:</b></td><td class=kb-table-cell width=120><b>" . $ended . "</b></td></tr>";
38$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Kills:</b></td><td class=kl-kill>" . $contract->getKills() . "</td><td class=kb-table-cell><b>Losses:</b></td><td class=kl-loss>" . $contract->getLosses() . "</td></tr>";
39$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Damage done (ISK):</b></td><td class=kl-kill>" . $contract->getKillISK() . "M</td><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>" . $contract->getLossISK() . "M</td></tr>";
40$html .= "<tr class=kb-table-row-even><td class=kb-table-cell><b>Runtime:</b></td><td class=kb-table-cell><b>" . $contract->getRunTime() . " days</b></td><td class=kb-table-cell><b>Efficiency:</b></td><td class=kb-table-cell><b>" . $contract->getEfficiency() . "%</b></td></tr>";
41$html .= "</table>";
42// $html .= "</td></tr></table>";
43$klist = $contract->getKillList();
44$llist = $contract->getLossList();
45$killsummary = new KillSummaryTable($klist, $llist);
46$killsummary->setBreak(6);
47if ($_GET['view'] == "")
48    $killsummary->setFilter(false);
49
50$html .= "<br>";
51$html .= $killsummary->generate();
52
53switch ($_GET['view'])
54{
55    case "":
56        while ($target = &$contract->getContractTarget())
57        {
58            $kl = &$target->getKillList();
59            $ll = &$target->getLossList();
60            $summary = new KillSummaryTable($kl, $ll);
61            $summary->setVerbose(true);
62            $summary->setBreak(12);
63            $summary->setView('combined');
64
65            $html .= "<br><div class=kb-contract-target-header>Target " . $target->getType() . " - " . $target->getName() . "</div>";
66            $html .= $summary->generate();
67
68            $html .= "<br><table class=kb-subtable border=\"0\" cellspacing=0 width=\"100%\"><tr><td>";
69
70            if ($summary->getTotalKillISK())
71                $efficiency = round($summary->getTotalKillISK() / ($summary->getTotalKillISK() + $summary->getTotalLossISK()) * 100, 2);
72            else
73                $efficiency = 0;
74
75            $bar = new BarGraph($efficiency, 100, 120);
76            $html .= "<table class=kb-table cellspacing=1 border=\"0\" width=\"100%\"><tr class=kb-table-row-even>";
77            $html .= "<td class=kb-table-cell width=108><b>Totals:</b></td><td class=kl-kill-bg width=60 align=center>" . $summary->getTotalKills() . "</td><td class=kl-kill-bg width=60 align=center>" . $summary->getTotalKillISK() . "M</td>";
78            $html .= "<td class=kl-loss-bg width=64 align=center>" . $summary->getTotalLosses() . "</td><td class=kl-loss-bg width=60 align=center>" . $summary->getTotalLossISK() . "M</td></tr></table>";
79
80            $html .= "</td><td align=left>";
81
82            $html .= "<table class=kb-table cellspacing=1 border=\"0\"><tr class=kb-table-row-even>";
83            $html .= "<td class=kb-table-cell width=108><b>Efficiency:</b></td><td class=kb-table-cell align=center colspan=2 width=120><b>" . $efficiency . "%</b></td>";
84            $html .= "<td class=kb-table-cell colspan=2 width=120>" . $bar->generate() . "</td></tr>";
85            $html .= "</tr></table>";
86
87            $html .= "</td></tr></table>";
88        }
89
90        break;
91    case "recent_activity":
92        $html .= "<div class=kb-kills-header>10 Most recent kills</div>";
93
94        $contract = new Contract($ctr_id);
95        $klist = $contract->getKillList();
96        $klist->setOrdered(true);
97        if ($_GET['scl_id'])
98            $klist->addVictimShipClass(new ShipClass($_GET['scl_id']));
99        else
100            $klist->setPodsNoobShips(false);
101
102        $table = new KillListTable($klist);
103        $table->setLimit(10);
104        $table->setDayBreak(false);
105        $html .= $table->generate();
106
107        $html .= "<div class=kb-losses-header>10 Most recent losses</div>";
108        $llist = $contract->getLossList();
109        $llist->setOrdered(true);
110        if ($_GET['scl_id'])
111            $llist->addVictimShipClass(new ShipClass($_GET['scl_id']));
112        else
113            $llist->setPodsNoobShips(false);
114
115        $table = new KillListTable($llist);
116        $table->setLimit(10);
117        $table->setDayBreak(false);
118        $html .= $table->generate();
119        break;
120    case "kills":
121        $html .= "<div class=kb-kills-header>All kills</div>";
122
123        $contract = new Contract($ctr_id);
124        $list = $contract->getKillList();
125        $list->setOrdered(true);
126        if ($_GET['scl_id'])
127            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
128
129        $pagesplitter = new PageSplitter($list->getCount(), 30);
130        $list->setPageSplitter($pagesplitter);
131        $table = new KillListTable($list);
132        $table->setDayBreak(false);
133        $html .= $table->generate();
134        $html .= $pagesplitter->generate();
135        break;
136    case "losses":
137        $html .= "<div class=kb-losses-header>All losses</div>";
138
139        $contract = new Contract($ctr_id);
140        $llist = $contract->getLossList();
141        $llist->setOrdered(true);
142        if ($_GET['scl_id'])
143            $llist->addVictimShipClass(new ShipClass($_GET['scl_id']));
144
145        $pagesplitter = new PageSplitter($llist->getCount(), 30);
146        $llist->setPageSplitter($pagesplitter);
147        $table = new KillListTable($llist);
148        $table->setDayBreak(false);
149        $html .= $table->generate();
150        $html .= $pagesplitter->generate();
151        break;
152    case "combined":
153        $html .= "<div class=kb-kills-header>All kills</div>";
154
155        $contract = new Contract($ctr_id);
156        $list = $contract->getKillList();
157        $list->setOrdered(true);
158        if ($_GET['scl_id'])
159            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
160
161        $pagesplitter = new PageSplitter($list->getCount(), 20);
162        $list->setPageSplitter($pagesplitter);
163        $table = new KillListTable($list);
164        $table->setDayBreak(false);
165        $html .= $table->generate();
166        $html .= $pagesplitter->generate();
167
168        $html .= "<div class=kb-losses-header>All losses</div>";
169
170        $contract = new Contract($ctr_id);
171        $llist = $contract->getLossList();
172        $llist->setOrdered(true);
173        if ($_GET['scl_id'])
174            $llist->addVictimShipClass(new ShipClass($_GET['scl_id']));
175
176        $pagesplitter = new PageSplitter($llist->getCount(), 20);
177        $llist->setPageSplitter($pagesplitter);
178        $table = new KillListTable($llist);
179        $table->setDayBreak(false);
180        $html .= $table->generate();
181        $html .= $pagesplitter->generate();
182        break;
183}
184
185$menubox = new MenuBox();
186$menubox->addCaption("Overview");
187$menubox->addOption("Target overview", "?a=cc_detail&ctr_id=" . $_GET['ctr_id']);
188$menubox->addCaption("Kills & losses");
189$menubox->addOption("Recent activity", "?a=cc_detail&ctr_id=" . $_GET['ctr_id'] . "&view=recent_activity");
190$menubox->addOption("All kills", "?a=cc_detail&ctr_id=" . $_GET['ctr_id'] . "&view=kills");
191$menubox->addOption("All losses", "?a=cc_detail&ctr_id=" . $_GET['ctr_id'] . "&view=losses");
192
193$page->addContext($menubox->generate());
194
195$tklist = new TopContractKillsList();
196$tklist->setContract(new Contract($ctr_id));
197if (CORP_ID)
198    $tklist->addInvolvedCorp(new Corporation(CORP_ID));
199if (ALLIANCE_ID)
200    $tklist->addInvolvedAlliance(new Alliance(ALLIANCE_ID));
201
202$tklist->generate();
203if ($contract->getCampaign())
204    $campaign = "campaign";
205else
206    $campaign = "contract";
207$tkbox = new AwardBox($tklist, "Top killers", "kills in this " . $campaign, "kills", "eagle");
208
209$page->addContext($tkbox->generate());
210
211$killboard = $page->killboard_;
212$config = $killboard->getConfig();
213if ($config->getKillPoints())
214{
215    $tklist = new TopContractScoreList();
216    $tklist->setContract(new Contract($ctr_id));
217    if (CORP_ID)
218        $tklist->addInvolvedCorp(new Corporation(CORP_ID));
219    if (ALLIANCE_ID)
220        $tklist->addInvolvedAlliance(new Alliance(ALLIANCE_ID));
221
222    $tklist->generate();
223    $tkbox = new AwardBox($tklist, "Top scorers", "points in this " . $campaign, "points", "redcross");
224    $page->addContext($tkbox->generate());
225}
226
227$page->setContent($html);
228$page->generate();
229?>
Note: See TracBrowser for help on using the browser.