root/dev/mods/forum_post/cc_detail.php @ 227

Revision 227, 10.9 KB (checked in by knifee, 13 years ago)

updated files.

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