1 | <? |
---|
2 | require_once( "db.php" ); |
---|
3 | require_once( "class.page.php" ); |
---|
4 | require_once( "class.ship.php" ); |
---|
5 | require_once( "class.profiler.php" ); |
---|
6 | |
---|
7 | class KillSummaryTable |
---|
8 | { |
---|
9 | function KillSummaryTable( $klist, $llist ) |
---|
10 | { |
---|
11 | $this->klist_ = $klist; |
---|
12 | $this->llist_ = $llist; |
---|
13 | |
---|
14 | $this->verbose_ = false; |
---|
15 | $this->filter_ = true; |
---|
16 | } |
---|
17 | |
---|
18 | function setBreak( $break ) |
---|
19 | { |
---|
20 | $this->break_ = $break; |
---|
21 | } |
---|
22 | |
---|
23 | function setVerbose( $verbose ) |
---|
24 | { |
---|
25 | $this->verbose_ = $verbose; |
---|
26 | } |
---|
27 | |
---|
28 | function setFilter( $filter ) |
---|
29 | { |
---|
30 | $this->filter_ = $filter; |
---|
31 | } |
---|
32 | |
---|
33 | function getTotalKills() |
---|
34 | { |
---|
35 | return $this->tkcount_; |
---|
36 | } |
---|
37 | |
---|
38 | function getTotalLosses() |
---|
39 | { |
---|
40 | return $this->tlcount_; |
---|
41 | } |
---|
42 | |
---|
43 | function getTotalKillPoints() |
---|
44 | { |
---|
45 | return $this->tkpoints_; |
---|
46 | } |
---|
47 | |
---|
48 | function getTotalLossPoints() |
---|
49 | { |
---|
50 | return $this->tlpoints_; |
---|
51 | } |
---|
52 | |
---|
53 | function getTotalKillISK() |
---|
54 | { |
---|
55 | return $this->tkisk_; |
---|
56 | } |
---|
57 | |
---|
58 | function getTotalLossISK() |
---|
59 | { |
---|
60 | return $this->tlisk_; |
---|
61 | } |
---|
62 | |
---|
63 | function generate() |
---|
64 | { |
---|
65 | // build array |
---|
66 | $sql = "select scl_id, scl_class |
---|
67 | from kb3_ship_classes |
---|
68 | where scl_class not in ( 'Drone', 'Unknown' ) |
---|
69 | order by scl_class"; |
---|
70 | |
---|
71 | $qry = new DBQuery(); |
---|
72 | $qry->execute( $sql ) or die( $qry->getErrorMsg() ); |
---|
73 | while ( $row = $qry->getRow() ) { |
---|
74 | if ( !$row['scl_id'] ) |
---|
75 | continue; |
---|
76 | |
---|
77 | $shipclass = new ShipClass( $row['scl_id'] ); |
---|
78 | $shipclass->setName( $row['scl_class'] ); |
---|
79 | |
---|
80 | $entry[$shipclass->getName()]['id'] = $row['scl_id']; |
---|
81 | $entry[$shipclass->getName()]['kills'] = 0; |
---|
82 | $entry[$shipclass->getName()]['kills_isk'] = 0; |
---|
83 | $entry[$shipclass->getName()]['losses'] = 0; |
---|
84 | $entry[$shipclass->getName()]['losses_isk'] = 0; |
---|
85 | } |
---|
86 | |
---|
87 | // kills |
---|
88 | while ( $kill = $this->klist_->getKill() ) { |
---|
89 | $classname = $kill->getVictimShipClassName(); |
---|
90 | $entry[$classname]['kills']++; |
---|
91 | $entry[$classname]['kills_isk']+= $kill->getVictimShipValue(); |
---|
92 | $this->tkcount_++; |
---|
93 | $this->tkisk_ += $kill->getVictimShipValue(); |
---|
94 | } |
---|
95 | |
---|
96 | // losses |
---|
97 | while ( $kill = $this->llist_->getKill() ) { |
---|
98 | $classname = $kill->getVictimShipClassName(); |
---|
99 | $entry[$classname]['losses']++; |
---|
100 | $entry[$classname]['losses_isk']+= $kill->getVictimShipValue(); |
---|
101 | $this->tlcount_++; |
---|
102 | $this->tlisk_ += $kill->getVictimShipValue(); |
---|
103 | } |
---|
104 | |
---|
105 | $odd = false; |
---|
106 | $prevdate = ""; |
---|
107 | $html .= "<table class=kb-subtable width=\"100%\" border=\"0\" cellspacing=0>"; |
---|
108 | if ( $this->break_ ) |
---|
109 | $html .= "<tr><td valign=top><table class=kb-table cellspacing=\"1\" width=\"100%\">"; |
---|
110 | $counter = 1; |
---|
111 | |
---|
112 | if ( $this->verbose_ ) { |
---|
113 | $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=60 align=center>Kills</td><td class=kb-table-cell width=60 align=center>ISK (M)</td><td class=kb-table-cell width=60 align=center>Losses</td><td class=kb-table-cell width=60 align=center>ISK (M)</td></tr>"; |
---|
114 | } |
---|
115 | else { |
---|
116 | $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=30 align=center>K</td><td class=kb-table-cell width=30 align=center>L</td></tr>"; |
---|
117 | } |
---|
118 | $html .= $header; |
---|
119 | |
---|
120 | foreach ( $entry as $k => $v ) { |
---|
121 | if ( !$v['id'] || $v['id'] == 3 ) |
---|
122 | continue; |
---|
123 | if ( $this->break_ && $counter > $this->break_ ) { |
---|
124 | $html .= "</table></td>"; |
---|
125 | $html .= "<td valign=top><table class=kb-table cellspacing=\"1\">"; |
---|
126 | $html .= $header; |
---|
127 | $counter = 1; |
---|
128 | } |
---|
129 | |
---|
130 | |
---|
131 | if ( !$odd ) { |
---|
132 | $odd = true; |
---|
133 | $class = 'kb-table-row-odd'; |
---|
134 | } |
---|
135 | else { |
---|
136 | $odd = false; |
---|
137 | $class = 'kb-table-row-even'; |
---|
138 | } |
---|
139 | |
---|
140 | if ( $_GET['scl_id'] != "" && $v['id'] == $_GET['scl_id'] ) |
---|
141 | $highlight="-hl"; |
---|
142 | else |
---|
143 | $highlight=""; |
---|
144 | |
---|
145 | if ( $v['kills'] == 0 ) |
---|
146 | $kclass = "kl-kill-null"; |
---|
147 | else |
---|
148 | $kclass = "kl-kill"; |
---|
149 | |
---|
150 | if ( $v['losses'] == 0 ) |
---|
151 | $lclass = "kl-loss-null"; |
---|
152 | else |
---|
153 | $lclass = "kl-loss"; |
---|
154 | |
---|
155 | if ( $this->verbose_ ) { |
---|
156 | $kclass .= "-bg"; |
---|
157 | $lclass .= "-bg"; |
---|
158 | } |
---|
159 | |
---|
160 | $html .= "<tr class=".$class.">"; |
---|
161 | |
---|
162 | $qrystring = preg_replace( "/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING'] ); |
---|
163 | $qrystring = preg_replace( "/&page=([0-9]?[0-9])/", "", $qrystring ); |
---|
164 | $html .= "<td class=kb-table-cell><b>"; |
---|
165 | |
---|
166 | if ( $this->filter_ ) $html .= "<a class=kb-shipclass".$highlight." href=\"?".$qrystring."&scl_id=".$v['id']."\">"; |
---|
167 | |
---|
168 | $html .= $k; |
---|
169 | |
---|
170 | if ( $this->filter_ ) $html .= "</a>"; |
---|
171 | |
---|
172 | $html .= "</b></td>"; |
---|
173 | |
---|
174 | $html .= "<td class=".$kclass." align=center>".$v['kills']."</td>"; |
---|
175 | if ( $this->verbose_ ) |
---|
176 | $html .= "<td class=".$kclass." align=center>".$v['kills_isk']."</td>"; |
---|
177 | $html .= "<td class=".$lclass." align=center>".$v['losses']."</td>"; |
---|
178 | if ( $this->verbose_ ) |
---|
179 | $html .= "<td class=".$lclass." align=center>".$v['losses_isk']."</td>"; |
---|
180 | |
---|
181 | $html .= "</tr>"; |
---|
182 | |
---|
183 | $counter++; |
---|
184 | $this->tkcount_ += $kcount; |
---|
185 | $this->tlcount_ += $lcount; |
---|
186 | $this->tkisk_ += $kisk; |
---|
187 | $this->tlisk_ += $lisk; |
---|
188 | $this->tkpoints_ += $kpoints; |
---|
189 | $this->tlpoints_ += $lpoints; |
---|
190 | } |
---|
191 | if ( $this->break_ ) |
---|
192 | $html .= "</table></td>"; |
---|
193 | |
---|
194 | $html .= "</tr></table>"; |
---|
195 | |
---|
196 | if ( $_GET['scl_id'] != "" ) { |
---|
197 | $html .= "<table align=center><tr><td align=center valign=top class=weeknav>"; |
---|
198 | $qrystring = preg_replace( "/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING'] ); $html .= "[<a href=\"?".$qrystring."\">clear filter</a>]</td></tr></table>"; |
---|
199 | } |
---|
200 | |
---|
201 | return $html; |
---|
202 | |
---|
203 | } |
---|
204 | } |
---|
205 | |
---|
206 | ?> |
---|