root/dev/common/cc_detail.php @ 188

Revision 188, 10.5 KB (checked in by exi, 14 years ago)

Changed default td width for options to 160px.
Added the appropiate timeframe to the fast contractlisttable.
Events now can also return a reference to a variable containing additional information.
Killlists now return a non formatted isk-value for losses/kills, please report any errors on other pages.
Added a custom user menu, able to be shownon every page.
Added some code for user logins, please ignore it for now.
Added a small battle statistics frame to the battle overview.
To login as admin now just leave user blank and use the admin password.

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>".round($contract->getKillISK()/1000000, 2)."M</td><td class=kb-table-cell><b>Damage received (ISK):</b></td><td class=kl-loss>".round($contract->getLossISK()/1000000, 2)."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()." - ";
66            switch ($target->getType()) {
67                case "corp":
68                    $html .= "<a class=kb-contract href=\"?a=".$target->getType()."_detail&crp_id=".$target->getID()."\">".$target->getName()."</a>";
69                    break;
70                case "alliance":
71                    $html .= "<a class=kb-contract href=\"?a=".$target->getType()."_detail&all_id=".$target->getID()."\">".$target->getName()."</a>";
72                    break;
73                case "system":
74                    $html .= "<a class=kb-contract href=\"?a=" .$target->getType()."_detail&sys_id=".$target->getID()."\">".$target->getName()."</a>";
75                    break;
76                case "region":
77                    $html .= $target->getName();
78                    break;
79            }
80            $html .= "</div>";
81            $html .= $summary->generate();
82
83            $html .= "<br><table class=kb-subtable border=\"0\" cellspacing=0 width=\"100%\"><tr><td>";
84
85            if ($summary->getTotalKillISK())
86                $efficiency = round($summary->getTotalKillISK() / ($summary->getTotalKillISK() + $summary->getTotalLossISK()) * 100, 2);
87            else
88                $efficiency = 0;
89
90            $bar = new BarGraph($efficiency, 100, 120);
91            $html .= "<table class=kb-table cellspacing=1 border=\"0\" width=\"100%\"><tr class=kb-table-row-even>";
92            $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>".round($summary->getTotalKillISK()/1000000, 2)."M</td>";
93            $html .= "<td class=kl-loss-bg width=64 align=center>".$summary->getTotalLosses()."</td><td class=kl-loss-bg width=60 align=center>".round($summary->getTotalLossISK()/1000000, 2)."M</td></tr></table>";
94
95            $html .= "</td><td align=left>";
96
97            $html .= "<table class=kb-table cellspacing=1 border=\"0\"><tr class=kb-table-row-even>";
98            $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>";
99            $html .= "<td class=kb-table-cell colspan=2 width=120>".$bar->generate()."</td></tr>";
100            $html .= "</tr></table>";
101
102            $html .= "</td></tr></table>";
103        }
104
105        break;
106    case "recent_activity":
107        $html .= "<div class=kb-kills-header>10 Most recent kills</div>";
108
109        $contract = new Contract($ctr_id);
110        $klist = $contract->getKillList();
111        $klist->setOrdered(true);
112        if ($_GET['scl_id'])
113            $klist->addVictimShipClass(new ShipClass($_GET['scl_id']));
114        else
115            $klist->setPodsNoobShips(false);
116
117        $table = new KillListTable($klist);
118        $table->setLimit(10);
119        $table->setDayBreak(false);
120        $html .= $table->generate();
121
122        $html .= "<div class=kb-losses-header>10 Most recent losses</div>";
123        $llist = $contract->getLossList();
124        $llist->setOrdered(true);
125        if ($_GET['scl_id'])
126            $llist->addVictimShipClass(new ShipClass($_GET['scl_id']));
127        else
128            $llist->setPodsNoobShips(false);
129
130        $table = new KillListTable($llist);
131        $table->setLimit(10);
132        $table->setDayBreak(false);
133        $html .= $table->generate();
134        break;
135    case "kills":
136        $html .= "<div class=kb-kills-header>All kills</div>";
137
138        $contract = new Contract($ctr_id);
139        $list = $contract->getKillList();
140        $list->setOrdered(true);
141        if ($_GET['scl_id'])
142            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
143
144        $pagesplitter = new PageSplitter($list->getCount(), 30);
145        $list->setPageSplitter($pagesplitter);
146        $table = new KillListTable($list);
147        $table->setDayBreak(false);
148        $html .= $table->generate();
149        $html .= $pagesplitter->generate();
150        break;
151    case "losses":
152        $html .= "<div class=kb-losses-header>All losses</div>";
153
154        $contract = new Contract($ctr_id);
155        $llist = $contract->getLossList();
156        $llist->setOrdered(true);
157        if ($_GET['scl_id'])
158            $llist->addVictimShipClass(new ShipClass($_GET['scl_id']));
159
160        $pagesplitter = new PageSplitter($llist->getCount(), 30);
161        $llist->setPageSplitter($pagesplitter);
162        $table = new KillListTable($llist);
163        $table->setDayBreak(false);
164        $html .= $table->generate();
165        $html .= $pagesplitter->generate();
166        break;
167    case "combined":
168        $html .= "<div class=kb-kills-header>All kills</div>";
169
170        $contract = new Contract($ctr_id);
171        $list = $contract->getKillList();
172        $list->setOrdered(true);
173        if ($_GET['scl_id'])
174            $list->addVictimShipClass(new ShipClass($_GET['scl_id']));
175
176        $pagesplitter = new PageSplitter($list->getCount(), 20);
177        $list->setPageSplitter($pagesplitter);
178        $table = new KillListTable($list);
179        $table->setDayBreak(false);
180        $html .= $table->generate();
181        $html .= $pagesplitter->generate();
182
183        $html .= "<div class=kb-losses-header>All losses</div>";
184
185        $contract = new Contract($ctr_id);
186        $llist = $contract->getLossList();
187        $llist->setOrdered(true);
188        if ($_GET['scl_id'])
189            $llist->addVictimShipClass(new ShipClass($_GET['scl_id']));
190
191        $pagesplitter = new PageSplitter($llist->getCount(), 20);
192        $llist->setPageSplitter($pagesplitter);
193        $table = new KillListTable($llist);
194        $table->setDayBreak(false);
195        $html .= $table->generate();
196        $html .= $pagesplitter->generate();
197        break;
198}
199
200$menubox = new box("Menu");
201$menubox->setIcon("menu-item.gif");
202$menubox->addOption("caption","Overview");
203$menubox->addOption("link","Target overview", "?a=cc_detail&ctr_id=".$_GET['ctr_id']);
204$menubox->addOption("caption","Kills & losses");
205$menubox->addOption("link","Recent activity", "?a=cc_detail&ctr_id=".$_GET['ctr_id']."&view=recent_activity");
206$menubox->addOption("link","All kills", "?a=cc_detail&ctr_id=".$_GET['ctr_id']."&view=kills");
207$menubox->addOption("link","All losses", "?a=cc_detail&ctr_id=".$_GET['ctr_id']."&view=losses");
208
209$page->addContext($menubox->generate());
210
211$tklist = new TopContractKillsList();
212$tklist->setContract(new Contract($ctr_id));
213if (CORP_ID)
214    $tklist->addInvolvedCorp(new Corporation(CORP_ID));
215if (ALLIANCE_ID)
216    $tklist->addInvolvedAlliance(new Alliance(ALLIANCE_ID));
217
218$tklist->generate();
219if ($contract->getCampaign())
220    $campaign = "campaign";
221else
222    $campaign = "contract";
223$tkbox = new AwardBox($tklist, "Top killers", "kills in this ".$campaign, "kills", "eagle");
224
225$page->addContext($tkbox->generate());
226
227$killboard = $page->killboard_;
228$config = $killboard->getConfig();
229if ($config->getKillPoints())
230{
231    $tklist = new TopContractScoreList();
232    $tklist->setContract(new Contract($ctr_id));
233    if (CORP_ID)
234        $tklist->addInvolvedCorp(new Corporation(CORP_ID));
235    if (ALLIANCE_ID)
236        $tklist->addInvolvedAlliance(new Alliance(ALLIANCE_ID));
237
238    $tklist->generate();
239    $tkbox = new AwardBox($tklist, "Top scorers", "points in this ".$campaign, "points", "redcross");
240    $page->addContext($tkbox->generate());
241}
242
243$page->setContent($html);
244$page->generate();
245?>
Note: See TracBrowser for help on using the browser.