1 | <?php |
---|
2 | require_once('common/includes/class.kill.php'); |
---|
3 | require_once('common/includes/class.pilot.php'); |
---|
4 | require_once('common/includes/class.corp.php'); |
---|
5 | require_once('common/includes/class.alliance.php'); |
---|
6 | |
---|
7 | $page = new Page('Kill details with Fitting MOD'); |
---|
8 | |
---|
9 | if (config::get('item_values')) |
---|
10 | { |
---|
11 | $smarty->assign('item_values', 'true'); |
---|
12 | if ($page->isAdmin()) |
---|
13 | { |
---|
14 | $smarty->assign('admin', 'true'); |
---|
15 | if (isset($_POST['submit']) && $_POST['submit'] == 'UpdateValue') |
---|
16 | { |
---|
17 | // Send new value for item to the database |
---|
18 | $IID = $_POST['IID']; |
---|
19 | $Val = $_POST[$IID]; |
---|
20 | $qry = new DBQuery(); |
---|
21 | $qry->execute("INSERT INTO kb3_item_price (typeID, price) VALUES ('".$IID."', '".$Val."') ON DUPLICATE KEY UPDATE price = '".$Val."'"); |
---|
22 | } |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | if ($page->isAdmin()) |
---|
27 | { |
---|
28 | if (isset($_GET['view']) && $_GET['view']== 'FixSlot') |
---|
29 | { |
---|
30 | $smarty->assign('fixSlot', 'true'); |
---|
31 | } |
---|
32 | |
---|
33 | $smarty->assign('admin', 'true'); |
---|
34 | if (isset($_POST['submit']) && $_POST['submit'] == 'UpdateSlot') |
---|
35 | { |
---|
36 | $IID = $_POST['IID']; |
---|
37 | $KID = $_POST['KID']; |
---|
38 | $Val = $_POST[$IID]; |
---|
39 | $table = $_POST['TYPE']; |
---|
40 | $old = $_POST['OLDSLOT']; |
---|
41 | $qry = new DBQuery(); |
---|
42 | $qry->execute("UPDATE kb3_items_".$table." SET itd_itl_id ='".$Val."' WHERE itd_itm_id=".$IID." AND itd_kll_id = ".$KID." AND itd_itl_id = ".$old); |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | if (!$kll_id = intval($_GET['kll_id'])) |
---|
47 | { |
---|
48 | $html = "No kill id specified."; |
---|
49 | $page->setContent($html); |
---|
50 | $page->generate($html); |
---|
51 | exit; |
---|
52 | } |
---|
53 | |
---|
54 | $kill = new Kill($kll_id); |
---|
55 | if (!$kill->exists()) |
---|
56 | { |
---|
57 | $html = "That kill doesn't exist."; |
---|
58 | $page->setContent($html); |
---|
59 | $page->generate($html); |
---|
60 | exit; |
---|
61 | } |
---|
62 | |
---|
63 | // victim $smarty->assign('',); |
---|
64 | $smarty->assign('KillId', $kill->getID()); |
---|
65 | $smarty->assign('VictimPortrait', $kill->getVictimPortrait(64)); |
---|
66 | $smarty->assign('VictimURL', "?a=pilot_detail&plt_id=".$kill->getVictimID()); |
---|
67 | $smarty->assign('VictimName', $kill->getVictimName()); |
---|
68 | $smarty->assign('VictimCorpURL', "?a=corp_detail&crp_id=".$kill->getVictimCorpID()); |
---|
69 | $smarty->assign('VictimCorpName', $kill->getVictimCorpName()); |
---|
70 | $smarty->assign('VictimAllianceURL', "?a=alliance_detail&all_id=".$kill->getVictimAllianceID()); |
---|
71 | $smarty->assign('VictimAllianceName', $kill->getVictimAllianceName()); |
---|
72 | $smarty->assign('VictimDamageTaken', $kill->VictimDamageTaken); |
---|
73 | |
---|
74 | // involved |
---|
75 | $i = 1; |
---|
76 | $involved = array(); |
---|
77 | foreach ($kill->involvedparties_ as $inv) |
---|
78 | { |
---|
79 | $pilot = new Pilot($inv->getPilotID()); |
---|
80 | $corp = new Corporation($inv->getCorpID()); |
---|
81 | $alliance = new Alliance($inv->getAllianceID()); |
---|
82 | $ship = $inv->getShip(); |
---|
83 | $weapon = $inv->getWeapon(); |
---|
84 | |
---|
85 | $involved[$i]['shipImage'] = $ship->getImage(64); |
---|
86 | $involved[$i]['PilotURL'] = "?a=pilot_detail&plt_id=".$pilot->getID(); |
---|
87 | $involved[$i]['PilotName'] = $pilot->getName(); |
---|
88 | $involved[$i]['CorpURL'] = "?a=corp_detail&crp_id=".$corp->getID(); |
---|
89 | $involved[$i]['CorpName'] = $corp->getName(); |
---|
90 | $involved[$i]['AlliURL'] = "?a=alliance_detail&all_id=".$alliance->getID(); |
---|
91 | $involved[$i]['AlliName'] = $alliance->getName(); |
---|
92 | $involved[$i]['ShipName'] = $ship->getName(); |
---|
93 | $involved[$i]['ShipID'] = $ship->externalid_; |
---|
94 | $involved[$i]['damageDone'] = $inv->dmgdone_; |
---|
95 | |
---|
96 | if ($pilot->getID() == $kill->getFBPilotID()) |
---|
97 | { |
---|
98 | $involved[$i]['FB'] = "true"; |
---|
99 | } |
---|
100 | else |
---|
101 | { |
---|
102 | $involved[$i]['FB'] = "false"; |
---|
103 | } |
---|
104 | |
---|
105 | if ($corp->isNPCCorp()) |
---|
106 | { |
---|
107 | $involved[$i]['portrait'] = $corp->getPortraitURL(64); |
---|
108 | } |
---|
109 | else |
---|
110 | { |
---|
111 | $involved[$i]['portrait'] = $pilot->getPortraitURL(64); |
---|
112 | } |
---|
113 | |
---|
114 | if ($weapon->getName() != "Unknown" && $weapon->getName() != $ship->getName()) |
---|
115 | { |
---|
116 | $involved[$i]['weaponName'] = $weapon->getName(); |
---|
117 | $involved[$i]['weaponID'] = $weapon->row_['itm_externalid']; |
---|
118 | } |
---|
119 | else |
---|
120 | $involved[$i]['weaponName'] = "Unknown"; |
---|
121 | ++$i; |
---|
122 | } |
---|
123 | $smarty->assign_by_ref('involved', $involved); |
---|
124 | |
---|
125 | if (config::get('comments')) |
---|
126 | { |
---|
127 | include('common/comments.php'); |
---|
128 | $smarty->assign('comments', $comment); |
---|
129 | } |
---|
130 | // ship, ship details |
---|
131 | $ship = $kill->getVictimShip(); |
---|
132 | $shipclass = $ship->getClass(); |
---|
133 | $system = $kill->getSystem(); |
---|
134 | |
---|
135 | $smarty->assign('VictimShip', $kill->getVictimShip()); |
---|
136 | $smarty->assign('ShipClass', $ship->getClass()); |
---|
137 | $smarty->assign('ShipImage', $ship->getImage(64)); |
---|
138 | $smarty->assign('ShipName', $ship->getName()); |
---|
139 | $smarty->assign('ShipID', $ship->externalid_); |
---|
140 | $smarty->assign('ClassName', $shipclass->getName()); |
---|
141 | |
---|
142 | if ($kill->isClassified()) |
---|
143 | { |
---|
144 | //Admin is able to see classified Systems |
---|
145 | if ($page->isAdmin()) |
---|
146 | { |
---|
147 | $smarty->assign('System', $system->getName().' (Classified)'); |
---|
148 | $smarty->assign('SystemURL', "?a=system_detail&sys_id=".$system->getID()); |
---|
149 | $smarty->assign('SystemSecurity', $system->getSecurity(true)); |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | $smarty->assign('System', 'Classified'); |
---|
154 | $smarty->assign('SystemURL', ""); |
---|
155 | $smarty->assign('SystemSecurity', '0.0'); |
---|
156 | } |
---|
157 | } |
---|
158 | else |
---|
159 | { |
---|
160 | $smarty->assign('System', $system->getName()); |
---|
161 | $smarty->assign('SystemURL', "?a=system_detail&sys_id=".$system->getID()); |
---|
162 | $smarty->assign('SystemSecurity', $system->getSecurity(true)); |
---|
163 | } |
---|
164 | $smarty->assign('TimeStamp', $kill->getTimeStamp()); |
---|
165 | $smarty->assign('VictimShipImg', $ship->getImage(64)); |
---|
166 | |
---|
167 | // preparing slot layout |
---|
168 | |
---|
169 | $slot_array = array(); |
---|
170 | $slot_array[1] = array('img' => 'icon08_11.png', 'text' => 'Fitted - High slot', 'items' => array()); |
---|
171 | $slot_array[2] = array('img' => 'icon08_10.png', 'text' => 'Fitted - Mid slot', 'items' => array()); |
---|
172 | $slot_array[3] = array('img' => 'icon08_09.png', 'text' => 'Fitted - Low slot', 'items' => array()); |
---|
173 | $slot_array[5] = array('img' => 'icon68_01.png', 'text' => 'Fitted - Rig slot', 'items' => array()); |
---|
174 | $slot_array[6] = array('img' => 'icon02_10.png', 'text' => 'Drone bay', 'items' => array()); |
---|
175 | $slot_array[4] = array('img' => 'icon03_14.png', 'text' => 'Cargo Bay', 'items' => array()); |
---|
176 | |
---|
177 | // ship fitting |
---|
178 | if (count($kill->destroyeditems_) > 0) |
---|
179 | { |
---|
180 | $dest_array = array(); |
---|
181 | foreach($kill->destroyeditems_ as $destroyed) |
---|
182 | { |
---|
183 | $item = $destroyed->getItem(); |
---|
184 | if (config::get('item_values')) |
---|
185 | { |
---|
186 | $value = $destroyed->getValue(); |
---|
187 | $TotalValue += $value*$destroyed->getQuantity(); |
---|
188 | $formatted = $destroyed->getFormatttedValue(); |
---|
189 | } |
---|
190 | $dest_array[$destroyed->getLocationID()][] = array('Icon' => $item->getIcon(32), 'Name' => $item->getName(), 'Quantity' => $destroyed->getQuantity(), 'Value' => $formatted, 'single_unit' => $value, 'itemID' => $item->getID(),'slotID' => $destroyed->getLocationID()); |
---|
191 | |
---|
192 | //Fitting, KE - add destroyed items to an array of all fitted items. |
---|
193 | if(($destroyed->getLocationID() != 4) && ($destroyed->getLocationID() != 6) && ($item->get_used_launcher_group($item->getName()) == 0)) |
---|
194 | { |
---|
195 | for ($count = 0; $count < $destroyed->getQuantity(); $count++) |
---|
196 | { |
---|
197 | $fitting_array[$destroyed->getLocationID()][]=array('Name'=>$item->getName(), 'Icon' => $item->getIcon(32), 'itemID' => $item->getID()); |
---|
198 | } |
---|
199 | } |
---|
200 | //fitting thing end |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | if (count($kill->droppeditems_) > 0) |
---|
205 | { |
---|
206 | $drop_array = array(); |
---|
207 | foreach($kill->droppeditems_ as $dropped) |
---|
208 | { |
---|
209 | $item = $dropped->getItem(); |
---|
210 | if (config::get('item_values')) |
---|
211 | { |
---|
212 | $value = $dropped->getValue(); |
---|
213 | $dropvalue += $value*$dropped->getQuantity(); |
---|
214 | $formatted = $dropped->getFormatttedValue(); |
---|
215 | } |
---|
216 | $drop_array[$dropped->getLocationID()][] = array('Icon' => $item->getIcon(32), 'Name' => $item->getName(), 'Quantity' => $dropped->getQuantity(), 'Value' => $formatted, 'single_unit' => $value, 'itemID' => $item->getID(),'slotID' => $dropped->getLocationID()); |
---|
217 | |
---|
218 | //Fitting -KE, add dropped items to the list |
---|
219 | if(($dropped->getLocationID() != 4) && ($dropped->getLocationID() != 6) && ($item->get_used_launcher_group($item->getName()) == 0)) |
---|
220 | { |
---|
221 | for ($count = 0; $count < $dropped->getQuantity(); $count++) |
---|
222 | { |
---|
223 | $fitting_array[$dropped->getLocationID()][]=array('Name'=>$item->getName(), 'Icon' => $item->getIcon(32), 'itemID' => $item->getID()); |
---|
224 | } |
---|
225 | } |
---|
226 | //fitting thing end |
---|
227 | |
---|
228 | |
---|
229 | } |
---|
230 | } |
---|
231 | |
---|
232 | //Fitting - KE, sort the fitted items into name order, so that several of the same item apear next to each other. |
---|
233 | if(is_array($fitting_array[1])) |
---|
234 | { |
---|
235 | foreach ($fitting_array[1] as $array_rowh) |
---|
236 | { |
---|
237 | $sort_by_nameh["Name"][] = $array_rowh["Name"]; |
---|
238 | } |
---|
239 | array_multisort($sort_by_nameh["Name"],SORT_ASC,$fitting_array[1]); |
---|
240 | } |
---|
241 | |
---|
242 | if(is_array($fitting_array[2])) |
---|
243 | { |
---|
244 | foreach ($fitting_array[2] as $array_rowm) |
---|
245 | { |
---|
246 | $sort_by_namem["Name"][] = $array_rowm["Name"]; |
---|
247 | } |
---|
248 | array_multisort($sort_by_namem["Name"],SORT_ASC,$fitting_array[2]); |
---|
249 | } |
---|
250 | |
---|
251 | if(is_array($fitting_array[3])) |
---|
252 | { |
---|
253 | foreach ($fitting_array[3] as $array_rowl) |
---|
254 | { |
---|
255 | $sort_by_namel["Name"][] = $array_rowl["Name"]; |
---|
256 | } |
---|
257 | array_multisort($sort_by_namel["Name"],SORT_ASC,$fitting_array[3]); |
---|
258 | } |
---|
259 | |
---|
260 | if(is_array($fitting_array[5])) |
---|
261 | { |
---|
262 | foreach ($fitting_array[5] as $array_rowr) |
---|
263 | { |
---|
264 | $sort_by_namer["Name"][] = $array_rowr["Name"]; |
---|
265 | } |
---|
266 | array_multisort($sort_by_namer["Name"],SORT_ASC,$fitting_array[5]); |
---|
267 | } |
---|
268 | |
---|
269 | //Fitting - KE, sort the fitted items into name order, so that several of the same item apear next to each other. -end |
---|
270 | |
---|
271 | |
---|
272 | |
---|
273 | if ($TotalValue >= 0) |
---|
274 | { |
---|
275 | $Formatted = number_format($TotalValue, 2); |
---|
276 | } |
---|
277 | |
---|
278 | // Get Ship Value |
---|
279 | $ShipValue = $ship->getPrice(); |
---|
280 | if (config::get('kd_droptototal')) |
---|
281 | { |
---|
282 | $TotalValue += $dropvalue; |
---|
283 | } |
---|
284 | $TotalLoss = number_format($TotalValue + $ShipValue, 2); |
---|
285 | $ShipValue = number_format($ShipValue, 2); |
---|
286 | $dropvalue = number_format($dropvalue, 2); |
---|
287 | |
---|
288 | $smarty->assign_by_ref('destroyed', $dest_array); |
---|
289 | $smarty->assign_by_ref('dropped', $drop_array); |
---|
290 | $smarty->assign_by_ref('slots', $slot_array); |
---|
291 | $smarty->assign_by_ref('fitting_high', $fitting_array[1]); |
---|
292 | $smarty->assign_by_ref('fitting_med', $fitting_array[2]); |
---|
293 | $smarty->assign_by_ref('fitting_low', $fitting_array[3]); |
---|
294 | $smarty->assign_by_ref('fitting_rig', $fitting_array[5]); |
---|
295 | $smarty->assign('ItemValue', $Formatted); |
---|
296 | $smarty->assign('DropValue', $dropvalue); |
---|
297 | $smarty->assign('ShipValue', $ShipValue); |
---|
298 | $smarty->assign('TotalLoss', $TotalLoss); |
---|
299 | |
---|
300 | $menubox = new Box("Menu"); |
---|
301 | $menubox->setIcon("menu-item.gif"); |
---|
302 | $menubox->addOption("caption", "View"); |
---|
303 | $menubox->addOption("link", "Killmail", "javascript:sndReq('index.php?a=kill_mail&kll_id=".$kill->getID()."');ReverseContentDisplay('popup')"); |
---|
304 | if ($kill->relatedKillCount() > 1 || $kill->relatedLossCount() > 1) |
---|
305 | { |
---|
306 | $menubox->addOption("link", "Related kills (".$kill->relatedKillCount()."/".$kill->relatedLossCount().")", "?a=kill_related&kll_id=".$kill->getID()); |
---|
307 | } |
---|
308 | if ($page->isAdmin()) |
---|
309 | { |
---|
310 | $menubox->addOption("caption", "Admin"); |
---|
311 | $menubox->addOption("link", "Delete", "javascript:openWindow('?a=admin_kill_delete&kll_id=".$kill->getID()."', null, 420, 300, '' );"); |
---|
312 | if (isset($_GET['view']) && $_GET['view'] == 'FixSlot') |
---|
313 | { |
---|
314 | $menubox->addOption("link", "Adjust Values", "?a=kill_detail&kll_id=".$kill->getID().""); |
---|
315 | } |
---|
316 | else |
---|
317 | { |
---|
318 | $menubox->addOption("link", "Fix Slots", "?a=kill_detail&kll_id=".$kill->getID()."&view=FixSlot"); |
---|
319 | } |
---|
320 | } |
---|
321 | $page->addContext($menubox->generate()); |
---|
322 | |
---|
323 | if (config::get('kill_points')) |
---|
324 | { |
---|
325 | $scorebox = new Box("Points"); |
---|
326 | $scorebox->addOption("points", $kill->getKillPoints()); |
---|
327 | $page->addContext($scorebox->generate()); |
---|
328 | } |
---|
329 | |
---|
330 | //Admin is able to see classsiefied systems |
---|
331 | if ((!$kill->isClassified()) || ($page->isAdmin())) |
---|
332 | { |
---|
333 | $mapbox = new Box("Map"); |
---|
334 | $mapbox->addOption("img", "?a=mapview&sys_id=".$system->getID()."&mode=map&size=145"); |
---|
335 | $mapbox->addOption("img", "?a=mapview&sys_id=".$system->getID()."&mode=region&size=145"); |
---|
336 | $mapbox->addOption("img", "?a=mapview&sys_id=".$system->getID()."&mode=cons&size=145"); |
---|
337 | $page->addContext($mapbox->generate()); |
---|
338 | } |
---|
339 | |
---|
340 | $html = $smarty->fetch('../mods/fitting/kill_detail.tpl'); |
---|
341 | $page->setContent($html); |
---|
342 | $page->generate(); |
---|
343 | ?> |
---|