root/dev/common/cc_detail.php @ 195

Revision 190, 10.5 KB (checked in by exi, 15 years ago)

This is a big update...
Moved all admin scripts to common/admin.
Moved all includes and classes to common/includes.
Edited all include-paths to reflect the movement.
Fixed a bug with the session system allowing every registered user to access admin pages.
Replaced calls to date() to use a wrapper so gmdate can be used.
Replaced some calls to $config with calls to the static object.
Fixed a big which caused the portrait_grab to not download a new picute.
Added a classified-state to kills.
Removed the sync_server server script in this tree.
Added code to help modules find the includes to index.php.

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