Опечатка.)
[cswowd.git] / include / report_generator.php
blob93f652afb42f28c8bc8150e194be99817f3a113b
1 <?php
2 include_once("functions.php");
4 // Report generator class (класс генератора отчётов)
5 class ReportGenerator{
6 var $mark = ''; // Report uniquie id
7 var $disable_mark = false;// Disable mark check/add (single report on page)
8 var $ajax_mode = 0; // Report mode direct render / ajax load
9 var $fields = 0; // Columns array
10 var $page = 1; // Report page
11 var $size_limit = 0; // Report row limit
12 var $total_data = 0; // Total rows
13 var $sort_method= 0; // Sort
14 var $sort_default = ''; // Default sort
15 var $r_link = ''; // Base page link
16 var $rowCallback = ''; // Callback function for row render
18 var $column_conf=0; // Report config array
19 // NPC report generator config array, contain elements:
20 // 'field_name' =>array(
21 // 'class'=>'', - cell class (width, align)
22 // 'sort'=>'sort', - column sort type
23 // 'text'=>'text', - column header text
24 // 'draw'=>'r_drawFunc', - cell draw function name
25 // 'sort_str'=>'`name`', - sort require string
26 // 'fields'=>'`name`'); - fields require for draw cell
27 var $db=0; // DB class for get data (filled in
28 var $table = ''; // DB tables
29 var $db_fields = '*'; // DB fields
30 var $query_args = 0; // Helper for expand query placeholders
31 var $data_array = 0; // Report data stored here
32 // Init data for report (return false if no need create it)
33 function Init(&$fields, $link, $report_mark, $limit, $def_sort)
35 global $ajaxmode;
36 // Init data if need directly create report or upload in ajax mode
37 if ($ajaxmode == 0 || $this->disable_mark || $report_mark==@$_REQUEST['mark'])
39 // echo $report_mark."<br />";
40 $this->ajax_mode = $ajaxmode;
41 $this->mark = $report_mark; // This report mark
42 $this->fields =& $fields; // Columns array
43 $this->sort_default = $def_sort; // Default sort
44 $this->size_limit = $limit; // Size limit (max row count)
45 $this->total_data = -1; // Total exist data
46 $this->r_link = $link; // Base page link
47 $this->data_array = 0;
48 // In url exist page, sort for this report store it
49 if ($this->disable_mark || $report_mark==@$_REQUEST['mark'])
51 $this->page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; // Store page
52 $this->sort_method = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : $def_sort; // Store sort method
53 if ($this->page < 1) $this->page = 1;
54 return true;
56 // No data for this report - set default
57 $this->page = 1;
58 $this->offset = 0;
59 $this->sort_method = $def_sort;
60 return true;
62 return false;
64 // Add custom column config
65 function addColumnConfig($name, $conf) {$this->column_conf[$name]=$conf;}
66 // Get total data count in result
67 function getTotalDataCount() {return $this->total_data;}
68 // Disable report mark in link (single report on page)
69 function disableMark() {$this->disable_mark = true;}
70 // Report link generator (for pages, headers)
71 function createLink($page, $sort)
73 $link = $this->r_link;
74 if ($page > 1) $link.='&page='.$page;
75 if ($sort!=$this->sort_default)
76 $link.='&sort='.$sort;
78 if (!$this->disable_mark) $link.='&mark='.$this->mark;
79 return $link;
81 // Create reference to report
82 function createHref($page, $sort, $text)
84 return '<a href="'.$this->createLink($page, $sort).'" onClick="return uploadFromHref(this, \''.$this->mark.'\');">'.$text.'</a>';
86 // Generate report
87 function createReport($header)
89 global $bw_icon_mode;
90 if (!$this->data_array || !$this->total_data || !$this->column_conf) return;
91 $this->slicePage();
92 $columns = count($this->fields);
93 if ($this->ajax_mode==0)
94 echo '<div class=reportContainer id="'.$this->mark.'">';
96 echo '<table class=report width=500>';
97 echo '<thead>';
98 echo '<tr class=head><td colspan='.$columns.'>'.$header.'</td></tr>';
99 echo '<tr>';
100 foreach ($this->fields as $field)
102 $f =& $this->column_conf[$field];
103 echo '<th>';
104 if ($f['sort'] && $this->total_data > 1)
105 echo $this->createHref($this->page, $f['sort'], $f['text']);
106 else
107 echo $f['text'];
108 echo '</th>';
110 echo '</tr>';
111 echo '</thead>';
112 echo '<tbody>';
113 foreach ($this->data_array as &$data)
115 $cb = $this->rowCallback;
116 $class = $cb ? $cb($data) : 0;
117 $row_class = $class ? ' class='.$class : '';
118 echo '<tr'.$row_class.'>';
119 foreach ($this->fields as $field)
121 $f =& $this->column_conf[$field];
122 echo $f['class']?'<td class='.$f['class'].'>' : '<td>';
123 $f['draw']($data);
124 echo '</td>';
126 echo '</tr>';
127 unsetBwIconMode();
129 if ($this->size_limit && $this->total_data > $this->size_limit)
131 $totalPage = floor($this->total_data/$this->size_limit+0.9999);
132 $page = $this->page;
133 echo '<tr><td colspan='.$columns.' class=page>';
134 for ($i=1;$i<=$totalPage;$i++)
136 if ($i!=$page) echo $this->createHref($i, $this->sort_method, $i).' ';
137 else echo '<b><i>'.$i.' </i></b>';
139 echo "</td></tr>";
141 echo '</tbody></table>';
142 if ($this->ajax_mode==0)
144 echo '</div>';
145 // Cache data
146 $link = $this->createLink($this->page, $this->sort_method);
147 echo "<script type=\"text/javascript\">ajaxCacheHtmlId('$this->mark','$link');</script>";
148 $tabName = $this->total_data > 1 ? $header.' ('.$this->total_data.')' : $header;
149 if (!$this->disable_mark) addTab($tabName, $this->mark);
152 // Remove column if all data zero
153 function removeIfAllZero($fname, $field)
155 $set = 0;
156 foreach($this->data_array as &$v) if (!isset($v[$fname]) OR $v[$fname]) {$set = 1;break;}
157 if (!$set) $this->removeField($field);
159 // Remove field
160 function removeField($name)
162 if ($id = array_search($name, $this->fields))
163 unset($this->fields[$id]);
165 // Expand placeholders func
166 function expandPlaceholdersCallback($m)
168 if (!empty($m[2]))
170 $value = array_pop($this->query_args);
171 switch ($m[3]) {
172 case 'a': return join(', ', $value);
173 case 'd': return intval($value);
174 case 'u': return sprintf('%u',$value);
175 case 'f': return str_replace(',', '.', floatval($value));
177 return $value;
179 if (isset($m[1]) && strlen($block=$m[1]))
181 if (current($this->query_args) === DBSIMPLE_SKIP)
183 array_pop($this->query_args);
184 return '';
186 return $this->_doPlaceholders($block);
188 return $m[0];
190 function _doPlaceholders($query)
192 $re = '{(?>\{( (?> (?>[^{}]+) | (?R) )* )\}) | (?>(\?) ( [duaf]? ))}sx';
193 return preg_replace_callback($re, array(&$this,'expandPlaceholdersCallback'), $query);
195 function expandPlaceholders($data)
197 $this->query_args = array_reverse($data);
198 return $this->_doPlaceholders(array_pop($this->query_args));
200 // Database depend requirest generator
201 function doRequirest($where)
203 global $config;
204 $locale = $config['locales_lang'];
205 $where_filter = $this->expandPlaceholders(func_get_args());
206 $tables = $this->table;
207 $fields = $this->getFieldsRequirest();
208 $sort_str= $this->getSortRequirest();
209 if ($locale)
210 $this->localiseRequirest($locale, $tables, $fields, $sort_str);
211 $reqString = 'SELECT '.$fields.' FROM '.$tables.' WHERE '.$where_filter.$sort_str.$this->getLimitRequirest();
212 // echo "<br />".$reqString."<br />";
213 if ($this->size_limit > 0)
214 $this->data_array = $this->db->selectPage($this->total_data, $reqString);
215 else
217 $this->data_array = $this->db->select($reqString);
218 $this->total_data = count($this->data_array);
221 // Manually slice on page
222 function setManualPagenateMode() {if ($this->size_limit >=0) $this->size_limit =-$this->size_limit;}
223 function slicePage()
225 if ($this->size_limit >=0) return;
226 $this->total_data = count($this->data_array);
227 $this->size_limit = -$this->size_limit;
228 $this->data_array = array_slice($this->data_array,($this->page-1)*$this->size_limit, $this->size_limit);
230 // Localise fields requirement and sort
231 function localiseRequirest($locale, &$fields, &$sort){return;}
232 // Build fields list depend from config
233 function getFieldsRequirest()
235 if ($this->db_fields=='*')
236 return '*';
237 $r = $this->db_fields;
238 foreach($this->fields as $f)
239 if ($data = $this->column_conf[$f]['fields'])
240 $r.=', '.$data;
241 return join(',', array_unique(explode(',', $r)));
243 function addFieldsRequirest($f)
245 if ($this->db_fields=='*')
246 return;
247 $this->db_fields.=', '.$f;
249 // Get sort requirest depend from config
250 function getSortRequirest()
252 if ($this->sort_method)
253 foreach($this->column_conf as $c)
254 if ($this->sort_method==$c['sort'])
255 return ' ORDER BY '.$c['sort_str'];
256 return '';
258 // Get limit requirest depend from page and page size
259 function getLimitRequirest()
261 if ($this->size_limit > 0)
262 return ' LIMIT '.(($this->page-1)*$this->size_limit).', '.$this->size_limit;
263 return '';
267 //==============================================================================
268 // Tabbed report functions
269 //==============================================================================
270 $tab_mode = 2; // disabled
271 function createReportTab()
273 global $tab_mode, $config, $ajaxmode;
274 if(!$config['use_tab_mode'] || $ajaxmode)
275 return;
276 echo '<script type="text/javascript">report_hideHeaders()</script>';
277 echo '<br><ul class=my_tabs id="report_tabs"></ul>';
278 $tab_mode = 1; // First page select
280 function addTab($header, $mark)
282 global $tab_mode;
283 if ($tab_mode > 1) return;
284 if (isset($_REQUEST['mark']))
285 $selected = $mark==$_REQUEST['mark'] ? 1 : 0;
286 else
287 $selected = $tab_mode?1:0;
288 echo '<script type="text/javascript">report_addTab("'.$header.'", "'.$mark.'", '.$selected.');</script>';
289 $tab_mode = 0; // disable select page
292 // Get some data
293 function getRefrenceItemLoot($entry)
295 global $dDB;
296 // Получаем рефренс лут
297 return $dDB->select('-- CACHE: 1h
298 SELECT `entry` AS ARRAY_KEY, `ChanceOrQuestChance`, `groupid`, `mincountOrRef`, `maxcount`, `lootcondition`, `condition_value1`, `condition_value2` FROM `reference_loot_template` WHERE `item`=?d', $entry);
300 function getFactionTemplates($entry)
302 global $wDB;
303 return $wDB->selectCol('-- CACHE: 1h
304 SELECT `id` FROM `wowd_faction_template` WHERE `faction` = ?d', $entry);
306 function getPlayerSpells($guid)
308 global $cDB;
309 return $cDB->select('-- CACHE: 1h
310 SELECT `spell` AS ARRAY_KEY FROM `character_spell` WHERE `guid` = ?d AND `disabled` = 0', $guid);
313 $gheroic = 0;
314 function getHeroicList()
316 global $dDB, $gheroic;
317 if (!$gheroic)
318 $gheroic = $dDB->selectCol('-- CACHE: 1h
319 SELECT `difficulty_entry_1` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_1` <> 0');
320 return $gheroic;
323 $gheroic1 = 0;
324 function getHeroicList1()
326 global $dDB, $gheroic1;
327 if (!$gheroic1)
328 $gheroic1 = $dDB->selectCol('-- CACHE: 1h
329 SELECT `difficulty_entry_2` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_2` <> 0');
330 return $gheroic1;
333 $gheroic2 = 0;
334 function getHeroicList2()
336 global $dDB, $gheroic2;
337 if (!$gheroic2)
338 $gheroic2 = $dDB->selectCol('-- CACHE: 1h
339 SELECT `difficulty_entry_3` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_3` <> 0');
340 return $gheroic2;
342 //==============================================================================
343 // Callback functions
344 //==============================================================================
345 function playerSpellCallback($data)
347 $spells = getPlayerSpells($_REQUEST['guid']);
348 if (isset($spells[$data['id']]))
349 return 0;
350 setBwIconMode();
351 return 'notknow';
354 //==============================================================================
355 // Loot
356 //==============================================================================
357 function r_lootChance($data)
359 if ($data['mincountOrRef'] < 0)
361 echo 'R'.($data['ChanceOrQuestChance']).'%';
363 else if ($data['ChanceOrQuestChance'] < 0)
364 echo 'Q'.(-$data['ChanceOrQuestChance']).'%';
365 else
366 echo $data['ChanceOrQuestChance'].'%';
368 function r_lootRequire($data)
370 global $lang;
371 switch ($data['lootcondition']){
372 case 1: // CONDITION_AURA - spell_id, effindex
373 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
374 echo $lang['condition1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');
375 break;
376 case 2: // CONDITION_ITEM - item_id, count
377 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
378 echo $lang['condition2'].text_show_item($item['entry'], $item['displayid'], 'quest');
379 if ($data['condition_value2'] > 1) echo 'x'.$data['condition_value2'];
380 break;
381 case 3: // CONDITION_ITEM_EQUIPPED - item_id, 0
382 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
383 echo $lang['condition3'].text_show_item($item['entry'], $item['displayid'], 'quest');
384 break;
385 case 4: // CONDITION_AREAID - area_id 0, 1 (0: in (sub)area, 1: not in (sub)area)
386 if ($data['condition_value2'] > 0 ) echo $lang['condition4_1'].getAreaName($data['condition_value1']);
387 if ($data['condition_value2'] == 0) echo getAreaName($data['condition_value1']);
388 break;
389 case 5: // CONDITION_REPUTATION_RANK - faction_id, min_rank
390 echo getFactionName($data['condition_value1']).'('.getReputationRankName($data['condition_value2']).')';
391 break;
392 case 6: // CONDITION_TEAM player_team, 0 (469 - Alliance 67 - Horde)
393 echo getFactionName($data['condition_value1']);
394 break;
395 case 7: // CONDITION_SKILL skill_id, skill_value
396 echo getSkillName($data['condition_value1']);
397 if ($data['condition_value2'] > 1) echo ' ('.$data['condition_value2'].')';
398 break;
399 case 8: // CONDITION_QUESTREWARDED quest_id, 0
400 echo $lang['condition8'].getQuestName($data['condition_value1']);
401 break;
402 case 9: // CONDITION_QUESTTAKEN quest_id 0, for condition true while quest active.
403 echo $lang['condition9'].getQuestName($data['condition_value1']);
404 break;
405 case 10: // CONDITION_AD_COMMISSION_AURA 0, 0 for condition true while one from AD сommission aura active
406 echo $lang['condition10'];
407 break;
408 case 11: // CONDITION_NO_AURA spell_id, effindex
409 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
410 echo $lang['condition11']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');
411 break;
412 case 12: // CONDITION_ACTIVE_GAME_EVENT event_id
413 echo $lang['condition12'].getGameEventName($data['condition_value1']);
414 break;
415 case 13: // CONDITION_AREA_FLAG area_flag area_flag_not
416 if ($data['condition_value1'] > 0) echo $lang['condition13_1'].$data['condition_value1'];
417 if ($data['condition_value2'] > 0) echo $lang['condition13_2'].$data['condition_value2'];
418 break;
419 case 14: // CONDITION_RACE_CLASS race_mask class_mask
420 if ($data['condition_value1'] > 0) echo getAllowableRace($data['condition_value1']).'<br>';
421 if ($data['condition_value2'] > 0) echo getAllowableClass($data['condition_value2']);
422 break;
423 case 15: // CONDITION_LEVEL player_level 0, 1 or 2
424 if ($data['condition_value1'] > 0) echo $data['condition_value1'];
425 if (($data['condition_value1'] > 0) && ($data['condition_value2'] == 0)) echo $lang['condition15_1'];
426 if (($data['condition_value1'] > 0) && ($data['condition_value2'] == 1)) echo $lang['condition15_2'];
427 if (($data['condition_value1'] > 0) && ($data['condition_value2'] == 2)) echo $lang['condition15_3'];
428 break;
429 case 16: // CONDITION_NOITEM item_id count
430 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
431 echo $lang['condition16'].text_show_item($item['entry'], $item['displayid'], 'quest');
432 if ($data['condition_value1'] > 1) echo 'x'.$data['condition_value2'];
433 break;
434 case 17: // CONDITION_SPELL spell_id 0, 1 (0: has spell, 1: hasn't spell)
435 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
436 if ($data['condition_value2'] > 0) { echo $lang['condition17_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
437 else { echo $lang['condition17_2']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
438 break;
439 case 20: // CONDITION_ACHIEVEMENT ach_id 0, 1 (0: has achievement, 1: hasn't achievement) for player
440 if ($data['condition_value2'] > 0) echo $lang['condition20_1'].$data['condition_value1'];
441 else echo $lang['condition20_2'].$data['condition_value1'];
442 break;
443 case 22: // CONDITION_QUEST_NONE quest_id
444 if ($data['condition_value1'] > 0) echo $lang['condition22'].getQuestName($data['condition_value1']);
445 break;
446 case 23: // CONDITION_ITEM_WITH_BANK- item_id, count
447 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
448 echo $lang['condition23'].text_show_item($item['entry'], $item['displayid'], 'quest');
449 if ($data['condition_value2'] > 1) echo 'x'.$data['condition_value2'];
450 break;
451 case 24: // NOITEM_WITH_BANK item_id count
452 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
453 echo $lang['condition24'].text_show_item($item['entry'], $item['displayid'], 'quest');
454 if ($data['condition_value1'] > 1) echo 'x'.$data['condition_value2'];
455 break;
456 case 25: // CONDITION_NOT_ACTIVE_GAME_EVENT event_id
457 echo $lang['condition25'].getGameEventName($data['condition_value1']);
458 break;
459 case 26: // CONDITION_ACTIVE_HOLIDAY holiday_id
460 echo $lang['condition26'].getGameHolidayName($data['condition_value1']);
461 break;
462 case 27: // CONDITION_NOT_ACTIVE_HOLIDAY holiday_id
463 echo $lang['condition27'].getGameHolidayName($data['condition_value1']);
464 break;
465 case 28: // CONDITION_LEARNABLE_ABILITY spell_id 0 or item_id
466 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
467 if ($data['condition_value2'] > 0) { $item = getItem($data['condition_value2'], '`entry`, `displayid`'); echo $lang['condition28_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest'); echo $lang['condition28_2'].text_show_item($item['entry'], $item['displayid'], 'quest');}
468 else {echo $lang['condition28_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
469 break;
473 class LootReportGenerator extends ReportGenerator{
474 function LootReportGenerator($type='')
476 global $dDB;
477 $this->db = &$dDB;
478 $this->db_fields = '*';
479 switch ($type){
480 default: $this->table = '`creature_loot_template`'; break;
483 function loadSubList($lootId, $table)
485 $fields= $this->db_fields;
486 $rows = $this->db->select("SELECT $fields FROM $table
487 WHERE `entry` = ?d
488 GROUP BY IF (`mincountOrRef` < 0, `mincountOrRef`, `item`)
489 ORDER BY `groupid`, `ChanceOrQuestChance`>0, ABS(`ChanceOrQuestChance`) DESC", $lootId);
490 if (!$rows)
491 return 0;
492 foreach($rows as &$loot)
494 // Group chance
495 if ($loot['ChanceOrQuestChance'] == 0)
497 $group = $loot['groupid'];
498 $chance = 0; $n = 0;
499 foreach($rows as &$g)
500 if ($g['groupid'] == $group)
502 if ($g['ChanceOrQuestChance']>0) $chance+=$g['ChanceOrQuestChance'];
503 else $n++;
505 $chance = round((100 - $chance) / $n, 3);
506 foreach($rows as &$g)
507 if ($g['groupid'] == $group && $g['ChanceOrQuestChance']==0)
508 $g['ChanceOrQuestChance'] =$chance;
510 if ($loot['mincountOrRef'] < 0)
512 // Получаем список
513 $loot['item'] = $this->loadSubList(-$loot['mincountOrRef'], 'reference_loot_template');
514 $loot['maxcount'] = $this->db->selectCell("SELECT count(*) FROM $table WHERE `entry` = ?d AND `mincountOrRef` = ?d", $lootId, $loot['mincountOrRef']);
517 return $rows;
519 function getLootList($lootId)
521 $this->total_data = 0;
522 $this->data_array = $this->loadSubList($lootId, $this->table);
524 function renderSubList($lootList)
526 global $Quality, $lang;
527 if (!$lootList)
528 return;
529 $curloot = -1;
530 foreach ($lootList as $loot)
532 $gtext = "";
533 if ($loot['groupid']!=$curloot)
535 echo "<tr><th colspan = 4>$lang[kill_kredit_group]&nbsp;$loot[groupid]</th></tr>";
536 $curloot = $loot['groupid'];
538 echo "<tr>";
539 if ($loot['mincountOrRef'] > 0)
541 if ($item = getItem($loot['item'],"`entry`, `Quality`, `name`, `displayid`"))
543 echo '<td class=i_ico>';r_itemIcon($item);echo '</td>';
544 echo '<td class=left>';r_itemName($item);echo '</td>';
546 else
547 echo "<td>-</td><td>$lang[item_not_found]&nbsp;$loot[item]</td>";
549 else // Используется список вещей (падает только одна вещь из списка)
551 echo "<td>".$loot['maxcount']."x</td>";
552 echo "<td class=forsub>$gtext<table class=sublist><tbody>";
553 $this->renderSubList($loot['item']);
554 echo "</tbody></table></td>";
556 if ($loot['lootcondition']){echo '<td>'; r_lootRequire($loot); echo '</td>';}
557 else echo '<td></td>';
558 if ($loot['ChanceOrQuestChance'] < 0) echo "<td align=center>Q".(-$loot['ChanceOrQuestChance'])."%</td>";
559 else if ($loot['ChanceOrQuestChance'] > 0) echo "<td align=center>".$loot['ChanceOrQuestChance']."%</td>";
560 echo "</tr>";
563 function createReport($header)
565 global $lang;
566 if (!$this->data_array)
567 return;
568 if ($this->ajax_mode==0)
569 echo '<div id="'.$this->mark.'">';
570 echo '<table class=report width=500>';
571 echo '<tbody>';
572 echo '<tr><td colspan=4 class=head>'.$header.'</td></tr>';
573 echo '<tr><th width=1%></th><th>'.$lang['item_name'].'</th><th></th><th>'.$lang['drop'].'%</th></tr>';
574 $this->renderSubList($this->data_array);
575 echo '</tbody></table>';
576 if ($this->ajax_mode==0)
578 echo '</div>';
579 // Cache data
580 $link = $this->createLink($this->page, $this->sort_method);
581 echo "<script type=\"text/javascript\">ajaxCacheHtmlId('$this->mark','$link');</script>";
586 //=================================================================
587 // Item report functions and methods
588 //=================================================================
589 function r_itemIcon($data) {echo text_show_item($data['entry'], $data['displayid']);}
590 function r_itemName($data)
592 global $Quality;
593 echo '<a class="'.$Quality[$data['Quality']].'" href="?item='.$data['entry'].'">'.(@$data['name_loc']?$data['name_loc']:$data['name']).'</a>';
595 function r_itemLevel($data) {echo $data['ItemLevel'];}
596 function r_itemReqLevel($data){echo $data['RequiredLevel'];}
597 function r_itemGemProp($data) {echo ($data['GemProperties']?getGemProperties($data['GemProperties']):'n/a');}
598 function r_itemArmor($data) {echo $data['armor'];}
599 function r_itemBlock($data) {echo $data['block'];}
600 function r_itemDPS($data) {echo $data['dps'] != 0 ? number_format($data['dps'], 2, '.', ''):'n/a';}
601 function r_itemAmmoDPS($data) {echo $data['adps'] != 0 ? number_format($data['adps'], 2, '.', ''):'n/a';}
602 function r_itemSpeed($data) {echo number_format($data['delay']/1000.00, 2, '.', '');}
603 function r_itemSlots($data) {echo $data['ContainerSlots'].' slot';}
604 function r_itemDesc($data) {echo (@$data['description_loc']?$data['description_loc']:$data['description']);}
605 function r_itemSClass($data) {echo getSubclassName($data['class'], $data['subclass'], 0);}
606 function r_itemInvType($data) {echo getInventoryType($data['InventoryType'], 0);}
607 function r_itemRecipe($data) {$ritem = getRecipeItem($data); echo ($ritem ? text_show_item($ritem['entry'], $ritem['displayid']):'-');}
608 function r_itemSpells($data)
610 global $UseorEquip;
611 for ($i=1;$i<=5;$i++)
613 if ($id = $data['spellid_'.$i])
614 if ($desc = get_spell_details($id))
615 echo '<a href="?spell='.$id.'">'.$UseorEquip[$data['spelltrigger_'.$i]].' '.$desc.'</a><br>';
618 function r_itemRepRank($data) {echo $data['RequiredReputationFaction']?getReputationRankName($data['RequiredReputationRank']):'n/a';}
619 function r_itemFlag($data) {echo dechex($data['Flags']);}
621 // Vendor
622 function r_vendorCost($data)
624 $flags2 = getItemFlags2($data['entry']);
625 if ($data['ExtendedCost']>0)
627 $cost = getExtendCost($data['ExtendedCost']);
628 if ($flags2&ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD)
629 echo money($data['BuyPrice']).''.r_excostCost($cost);
630 else
631 r_excostCost($cost);
633 else
634 echo money($data['BuyPrice']);
636 function r_vendorCount($data) {echo $data['sold_count']?$data['sold_count']:'∞';}
637 function r_vendorTime($data) {echo $data['incrtime']?getTimeText($data['incrtime']):'';}
639 // NPC report generator config
640 $item_report = array(
641 'ITEM_REPORT_ICON' =>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemIcon', 'sort_str'=>'', 'fields'=>'`displayid`' ),
642 'ITEM_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['item_name'], 'draw'=>'r_itemName', 'sort_str'=>'`name`', 'fields'=>'`Quality`, `name`'),
643 'ITEM_REPORT_LEVEL' =>array('class'=>'small','sort'=>'i_level', 'text'=>$lang['item_level'], 'draw'=>'r_itemLevel', 'sort_str'=>'`ItemLevel` DESC, `name`', 'fields'=>'`ItemLevel`' ),
644 'ITEM_REPORT_REQLEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['item_req_level'], 'draw'=>'r_itemReqLevel', 'sort_str'=>'`RequiredLevel` DESC, `name`', 'fields'=>'`RequiredLevel`' ),
645 'ITEM_REPORT_GEMPROPETY' =>array('class'=>'left', 'sort'=>'gem_prop','text'=>$lang['item_gem_details'],'draw'=>'r_itemGemProp', 'sort_str'=>'`GemProperties`', 'fields'=>'`GemProperties`'),
646 'ITEM_REPORT_ARMOR' =>array('class'=>'', 'sort'=>'armor', 'text'=>$lang['item_armor'], 'draw'=>'r_itemArmor', 'sort_str'=>'`armor` DESC', 'fields'=>'`armor`'),
647 'ITEM_REPORT_BLOCK' =>array('class'=>'', 'sort'=>'block', 'text'=>$lang['item_block'], 'draw'=>'r_itemBlock', 'sort_str'=>'`block` DESC', 'fields'=>'`block`'),
648 'ITEM_REPORT_DPS' =>array('class'=>'', 'sort'=>'dps', 'text'=>$lang['item_dps'], 'draw'=>'r_itemDPS', 'sort_str'=>'`dps` DESC', 'fields'=>'(500*(`dmg_min1`+`dmg_max1`) / `delay`) AS `dps`'),
649 'ITEM_REPORT_AMMO_DPS' =>array('class'=>'', 'sort'=>'adps', 'text'=>$lang['item_dps'], 'draw'=>'r_itemAmmoDPS', 'sort_str'=>'`adps` DESC', 'fields'=>'((`dmg_min1`+`dmg_max1`)/2) AS `adps`'),
650 'ITEM_REPORT_SPEED' =>array('class'=>'', 'sort'=>'speed', 'text'=>$lang['item_speed'], 'draw'=>'r_itemSpeed', 'sort_str'=>'`delay` DESC', 'fields'=>'`delay`'),
651 'ITEM_REPORT_NUM_SLOTS' =>array('class'=>'', 'sort'=>'bag_slot','text'=>$lang['item_slot_num'], 'draw'=>'r_itemSlots', 'sort_str'=>'`ContainerSlots` DESC', 'fields'=>'`ContainerSlots`'),
652 'ITEM_REPORT_DESCRIPTION'=>array('class'=>'left', 'sort'=>'desc', 'text'=>$lang['item_desc'], 'draw'=>'r_itemDesc', 'sort_str'=>'`description` DESC', 'fields'=>'`description`'),
653 'ITEM_REPORT_SUBCLASS' =>array('class'=>'', 'sort'=>'subclass','text'=>$lang['item_type'], 'draw'=>'r_itemSClass', 'sort_str'=>'`subclass` DESC', 'fields'=>'`class`, `subclass`'),
654 'ITEM_REPORT_SLOTTYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['item_slot'], 'draw'=>'r_itemInvType', 'sort_str'=>'`InventoryType` DESC', 'fields'=>'`InventoryType`'),
655 'ITEM_REPORT_RECIPE_ITEM'=>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemRecipe', 'sort_str'=>'', 'fields'=>'`spellid_1`, `spellid_2`, `class`'),
656 'ITEM_REPORT_SPELL' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['item_spells'], 'draw'=>'r_itemSpells', 'sort_str'=>'', 'fields'=>'`spellid_1`, `spelltrigger_1`, `spellid_2`, `spelltrigger_2`, `spellid_3`, `spelltrigger_3`, `spellid_4`, `spelltrigger_4`, `spellid_5`, `spelltrigger_5`'),
657 'ITEM_REPORT_REQREP_RANK'=>array('class'=>'', 'sort'=>'rep_rank','text'=>$lang['item_faction_rank'],'draw'=>'r_itemRepRank', 'sort_str'=>'`RequiredReputationRank` DESC', 'fields'=>'`RequiredReputationFaction`, `RequiredReputationRank`'),
658 'ITEM_REPORT_FLAGS' =>array('class'=>'', 'sort'=>'', 'text'=>'flag', 'draw'=>'r_itemFlag', 'sort_str'=>'', 'fields'=>'`Flags`'),
659 // If set vendor class type
660 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCost', 'sort_str'=>'`ExtendedCost`, `BuyPrice`', 'fields'=>'`ExtendedCost`, `BuyPrice`'),
661 'VENDOR_REPORT_COUNT' =>array('class'=>'', 'sort'=>'count', 'text'=>$lang['item_count'], 'draw'=>'r_vendorCount', 'sort_str'=>'`sold_count`, `name`', 'fields'=>'`npc_vendor`.`maxcount` AS `sold_count`'),
662 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `name`', 'fields'=>'`incrtime`'),
663 // If set loot class type
664 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
665 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
668 // Item localisation flags (for allow disable some fields localisation if need)
669 define('ITEM_LOCALE_NAME', 0x01);
670 define('ITEM_LOCALE_DESCRIPTION', 0x02);
671 define('ITEM_LOCALE_ALL', ITEM_LOCALE_NAME | ITEM_LOCALE_DESCRIPTION);
673 // Item report class
674 class ItemReportGenerator extends ReportGenerator{
675 var $dolocale = ITEM_LOCALE_ALL;
676 function ItemReportGenerator($type='')
678 global $item_report, $dDB;
679 $this->db = &$dDB;
680 $this->column_conf =&$item_report;
681 $this->db_fields = '`item_template`.`entry`';
682 switch ($type){
683 case 'vendor' : $this->table = '(`item_template` join `npc_vendor` ON `item_template`.`entry` = `npc_vendor`.`item`)'; break;
684 case 'loot': $this->table = '(`item_loot_template` right join `item_template` ON `item_template`.`entry` = `item_loot_template`.`entry`)'; break;
685 case 'disenchant':$this->table = '(`disenchant_loot_template` right join `item_template` ON `item_template`.`DisenchantID` = `disenchant_loot_template`.`entry`)'; break;
686 case 'milling': $this->table = '(`milling_loot_template` right join `item_template` ON `item_template`.`entry` = `milling_loot_template`.`entry`)'; break;
687 case 'prospect': $this->table = '(`prospecting_loot_template` right join `item_template` ON `item_template`.`entry` = `prospecting_loot_template`.`entry`)'; break;
688 default: $this->table = '`item_template`'; break;
691 function disableNameLocalisation() {$this->dolocale &= ~ITEM_LOCALE_NAME;}
692 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
694 $tables .= ' LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry`';
695 if ($this->dolocale & ITEM_LOCALE_NAME)
697 $fields = str_replace('`name`','`name`, `locales_item`.`name_loc'.$locale.'` AS `name_loc`', $fields);
698 $sort_str = str_replace('`name`', '`name_loc`, `name`', $sort_str);
700 if ($this->dolocale & ITEM_LOCALE_DESCRIPTION)
702 $fields = str_replace('`description`','`description`, `locales_item`.`description_loc'.$locale."` AS `description_loc`", $fields);
703 $sort_str = str_replace('`description` DESC', '`description_loc` DESC, `name` DESC', $sort_str);
706 function vendorItemList($entry)
708 $this->doRequirest('`npc_vendor`.`entry` = ?d', $entry);
709 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
710 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
712 function useSpell($entry)
714 $this->doRequirest('(`spellid_1` = ?d OR `spellid_2` = ?d OR `spellid_3` = ?d OR `spellid_4` = ?d OR `spellid_5` = ?d) AND `spellid_1` <> 483', $entry, $entry, $entry, $entry, $entry);
716 function recipeSpell($entry)
718 $this->doRequirest('`spellid_1` = 483 AND `spellid_2` = ?d', $entry);
720 function socketBonus($entry)
722 $this->doRequirest('`SocketBonus` = ?d', $entry);
724 function enchantByGems($entry)
726 global $wDB;
727 if ($list = $wDB->selectCol("SELECT `id` FROM `wowd_gemproperties` WHERE `spellitemenchantement` = ?d", $entry))
728 $this->doRequirest('`GemProperties` IN (?a)', $list);
730 function requireReputation($entry)
732 $this->doRequirest('`RequiredReputationFaction` = ?d', $entry);
734 function lootItem($entry)
736 $ref_loot =& getRefrenceItemLoot($entry);
737 $this->doRequirest('(`item` = ?d AND `mincountOrRef` > 0) { OR -`mincountOrRef` IN (?a) } GROUP BY `entry`', $entry, count($ref_loot)==0 ? DBSIMPLE_SKIP:array_keys($ref_loot));
738 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
742 //=================================================================
743 // Spell trainer list report functions and methods
744 //=================================================================
745 function r_trainerCost($data) {echo money($data['spellcost']);}
746 function r_trainerSpell($data)
748 if ($spell = getSpell($data['spell']))
750 if (!r_spellCreate($spell))
751 r_spellIcon($spell);
754 function r_trainerNSpell($data)
756 if ($spell = getSpell($data['spell']))
758 echo getSpellName($spell);
761 function r_trainerSkill($data) {if ($data['reqskill']) echo getSkillName($data['reqskill']);}
762 function r_trainerValue($data) {if ($data['reqskill']) echo $data['reqskillvalue'];}
763 function r_trainerSkillReq($data){if ($data['reqskill']) echo getSkillName($data['reqskill']).' ('.$data['reqskillvalue'].')';}
764 function r_trainerLevel($data) {echo $data['reqlevel']?$data['reqlevel']:'';}
766 $train_report = array(
767 'TRAIN_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['trainer_level'], 'draw'=>'r_trainerLevel', 'sort_str'=>'`reqlevel`, `reqskillvalue`', 'fields'=>'`reqlevel`' ),
768 'TRAIN_REPORT_ICON' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_trainerSpell', 'sort_str'=>'', 'fields'=>'`spell`' ),
769 'TRAIN_REPORT_NAME' =>array('class'=>'left', 'sort'=>'spell', 'text'=>$lang['trainer_spell'], 'draw'=>'r_trainerNSpell', 'sort_str'=>'`spell`', 'fields'=>'`spell`' ),
770 'TRAIN_REPORT_COST' =>array('class'=>'cost', 'sort'=>'cost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
771 'TRAIN_REPORT_SKILL' =>array('class'=>'small','sort'=>'skill','text'=>$lang['trainer_skill'], 'draw'=>'r_trainerSkill', 'sort_str'=>'`reqskill`', 'fields'=>'`reqskill`' ),
772 'TRAIN_REPORT_VALUE' =>array('class'=>'small','sort'=>'value','text'=>$lang['trainer_value'], 'draw'=>'r_trainerValue', 'sort_str'=>'`reqskillvalue`','fields'=>'`reqskillvalue`'),
775 class NPCTrainerReportGenerator extends ReportGenerator{
776 // Database depend requirest generator
777 // Select only reuire for report fields from database
778 function NPCTrainerReportGenerator($type='')
780 global $train_report, $dDB;
781 $this->db = &$dDB;
782 $this->column_conf =&$train_report;
783 $this->table = '`npc_trainer`';
784 $this->db_fields = '`entry`';
786 function trainSpell($entry)
788 $this->doRequirest('`entry` = ?d', $entry);
789 $this->removeIfAllZero('reqlevel', 'TRAIN_REPORT_LEVEL');
790 $this->removeIfAllZero('reqskill', 'TRAIN_REPORT_SKILL');
791 $this->removeIfAllZero('reqskillvalue', 'TRAIN_REPORT_VALUE');
795 //=================================================================
796 // Creature list report functions and methods
797 //=================================================================
798 function r_npcLvl($data)
800 echo $data['maxlevel'];
801 if ($data['rank'])
802 echo '<br><div class=rank>'.getCreatureRank($data['rank']).'</div>';
804 function r_npcName($data)
806 $h = getHeroicList();
807 $h1 = getHeroicList1();
808 $h2 = getHeroicList2();
809 if (isset($h[$data['entry']]))
811 $heroic = getCreature($h[$data['entry']]);
812 $data['name']=$heroic['name'].' (difficulty_1)';
813 $data['name_loc']=$heroic['name'].' (difficulty_1)';
814 $data['subname']=$heroic['subname'];
816 if (isset($h1[$data['entry']]))
818 $heroic = getCreature($h1[$data['entry']]);
819 $data['name']=$heroic['name'].' (difficulty_2)';
820 $data['name_loc']=$heroic['name'].' (difficulty_2)';
821 $data['subname']=$heroic['subname'];
823 if (isset($h2[$data['entry']]))
825 $heroic = getCreature($h2[$data['entry']]);
826 $data['name']=$heroic['name'].' (difficulty_3)';
827 $data['name_loc']=$heroic['name'].' (difficulty_3)';
828 $data['subname']=$heroic['subname'];
830 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
831 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['subname'];
832 echo '<a href="?npc='.$data['entry'].'">'.($name?$name:'no name').'</a>';
833 if ($subname)
834 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
836 function r_npcRName($data)
838 $h = getHeroicList();
839 $h1 = getHeroicList1();
840 $h2 = getHeroicList2();
841 if (isset($h[$data['entry']]))
843 $heroic = getCreature($h[$data['entry']]);
844 $data['name']=$heroic['name'].' (difficulty_1)';
845 $data['name_loc']=$heroic['name'].' (difficulty_1)';
846 $data['subname']=$heroic['subname'];
848 if (isset($h1[$data['entry']]))
850 $heroic = getCreature($h1[$data['entry']]);
851 $data['name']=$heroic['name'].' (difficulty_2)';
852 $data['name_loc']=$heroic['name'].' (difficulty_2)';
853 $data['subname']=$heroic['subname'];
855 if (isset($h2[$data['entry']]))
857 $heroic = getCreature($h2[$data['entry']]);
858 $data['name']=$heroic['name'].' (difficulty_3)';
859 $data['name_loc']=$heroic['name'].' (difficulty_3)';
860 $data['subname']=$heroic['subname'];
862 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
863 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['subname'];
864 echo '<a href="?npc='.$data['entry'].'">'.($name?$name:'no name').'</a> <font size=-3>('.getLoyality($data['faction_A']).')</font>';
865 if ($subname)
866 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
868 function r_npcReact($data) {echo getLoyality($data['faction_A']);}
869 function r_npcMap($data)
871 global $lang;
872 $h = getHeroicList();
873 $h1 = getHeroicList1();
874 $h2 = getHeroicList2();
876 if (isset($h2[$data['entry']]))
877 echo '<a href="?map&npc='.$h2[$data['entry']].'">'.$lang['map'].'</a>';
878 else
879 if (isset($h1[$data['entry']]))
880 echo '<a href="?map&npc='.$h1[$data['entry']].'">'.$lang['map'].'</a>';
881 else
882 if (isset($h[$data['entry']]))
883 echo '<a href="?map&npc='.$h[$data['entry']].'">'.$lang['map'].'</a>';
884 else
885 echo '<a href="?map&npc='.$data['entry'].'">'.$lang['map'].'</a>';
887 function r_npcRole($data)
889 $flag = $data['npcflag'];
890 if ($flag == 0) {return;}
891 if ($flag&0x00000001) echo '<img src=images/map_points/gossip_icon.png>';
892 if ($flag&0x00000002 && getNpcQuestrelation($data['entry'])) echo '<img src=images/map_points/available_quest_icon.gif>';
893 if ($flag&0x00000002 && getNpcInvolvedrelation($data['entry'])) echo '<img src=images/map_points/active_quest_icon.gif>';
894 if ($flag&0x00000070) echo '<img src=images/map_points/trainer_icon.gif>';
895 if ($flag&0x00000F80) echo '<img src=images/map_points/vendor_icon.gif>';
896 // if ($flag&0x00001000) echo '<img src=images/map_points/repair.gif>';
897 if ($flag&0x00002000) echo '<img src=images/map_points/taxi_icon.gif>';
898 if ($flag&0x00010000) echo '<img src=images/map_points/inn_icon.png>';
899 if ($flag&0x00820000) echo '<img src=images/map_points/banker_icon.gif>';
900 if ($flag&0x00100000) echo '<img src=images/map_points/battle_master_icon.gif>';
901 if ($flag&0x00200000) echo '<img src=images/map_points/banker_icon.gif>';
902 if ($flag&0x000C0000) echo '<img src=images/map_points/tabard_icon.gif>';
904 define('UNIT_NPC_FLAG_SPIRITHEALER', 0x00004000);
905 define('UNIT_NPC_FLAG_SPIRITGUIDE', 0x00008000);
906 define('UNIT_NPC_FLAG_STABLEMASTER', 0x00400000);*/
908 function r_OnKillRep($data)
910 $creature_rate1 = getCreatureRewRate($data['RewOnKillRepFaction1']);
911 $creature_rate2 = getCreatureRewRate($data['RewOnKillRepFaction2']);
912 if ($data['RewOnKillRepFaction1'])
914 echo ($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1.' '.getFactionName($data['RewOnKillRepFaction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
915 $spillover=getRepSpillover($data['RewOnKillRepFaction1']);
916 if ($spillover)
917 foreach ($spillover as $faction)
919 if ($faction['faction1'])
920 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
921 if ($faction['faction2'])
922 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding1']).')';
923 if ($faction['faction3'])
924 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding1']).')';
925 if ($faction['faction4'])
926 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding1']).')';
929 if ($data['RewOnKillRepFaction2'])
931 if ($data['RewOnKillRepFaction1'] == 0)
932 echo ($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
933 else
934 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
935 $spillover=getRepSpillover($data['RewOnKillRepFaction2']);
936 if ($spillover)
937 foreach ($spillover as $faction)
939 if ($faction['faction1'])
940 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding2']).')';
941 if ($faction['faction2'])
942 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
943 if ($faction['faction3'])
944 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding2']).')';
945 if ($faction['faction4'])
946 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding2']).')';
950 // NPC report generator config
951 $npc_report = array(
952 'NPC_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['creature_level'], 'draw'=>'r_npcLvl', 'sort_str'=>'`maxlevel` DESC, `name`', 'fields'=>'`maxlevel`, `rank`'),
953 'NPC_REPORT_RANK' =>array('class'=>'small','sort'=>'rank', 'text'=>$lang['creature_level'], 'draw'=>'r_npcLvl', 'sort_str'=>'`rank` DESC, `maxlevel` DESC, `name`', 'fields'=>'`maxlevel`, `rank`'),
954 'NPC_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcName', 'sort_str'=>'`name`', 'fields'=>'`name`, `subname`' ),
955 'NPC_REPORT_RNAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcRName','sort_str'=>'`name`', 'fields'=>'`name`, `subname`, `faction_A`' ),
956 'NPC_REPORT_REACTION'=>array('class'=>'small','sort'=>'', 'text'=>$lang['creature_react'], 'draw'=>'r_npcReact','sort_str'=>'', 'fields'=>'`faction_A`'),
957 'NPC_REPORT_ROLE' =>array('class'=>'', 'sort'=>'role', 'text'=>$lang['creature_role'], 'draw'=>'r_npcRole', 'sort_str'=>'`npcflag` DESC', 'fields'=>'`npcflag`'),
958 'NPC_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_npcMap', 'sort_str'=>'', 'fields'=>''),
959 // vendor
960 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCost', 'sort_str'=>'`ExtendedCost`, `name`', 'fields'=>'`ExtendedCost`'),
961 'VENDOR_REPORT_COUNT' =>array('class'=>'', 'sort'=>'count','text'=>$lang['item_count'], 'draw'=>'r_vendorCount','sort_str'=>'`sold_count`, `name`', 'fields'=>'`npc_vendor`.`maxcount` AS `sold_count`'),
962 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `name`', 'fields'=>'`incrtime`'),
963 // trainer
964 'TRAINER_REPORT_COST' =>array('class'=>'', 'sort'=>'scost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
965 'TRAINER_REPORT_SPELL'=>array('class'=>'left','sort'=>'', 'text'=>$lang['trainer_spell'],'draw'=>'r_trainerSpell','sort_str'=>'', 'fields'=>'`spell`'),
966 'TRAINER_REPORT_SKILL'=>array('class'=>'', 'sort'=>'skill', 'text'=>$lang['trainer_skill'],'draw'=>'r_trainerSkillReq','sort_str'=>'`reqskill`, `reqskillvalue`','fields'=>'`reqskill`, `reqskillvalue`'),
967 'TRAINER_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'slevel','text'=>$lang['trainer_level'],'draw'=>'r_trainerLevel','sort_str'=>'`reqlevel`', 'fields'=>'`reqlevel`'),
968 // loot
969 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
970 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
971 // reputation
972 'ONKILL_REPUTATION' =>array('class'=>'left', 'sort'=>'rep','text'=>$lang['onkill_rep'],'draw'=>'r_OnKillRep','sort_str'=>'`RewOnKillRepValue1` DESC, `RewOnKillRepValue2` DESC', 'fields'=>'`RewOnKillRepFaction1`, `RewOnKillRepValue1`, `MaxStanding1`, `RewOnKillRepValue2`, `RewOnKillRepFaction2`, `MaxStanding2`'),
975 define('NPC_LOCALE_NAME', 0x01);
976 define('NPC_LOCALE_SUBNAME', 0x02);
977 define('NPC_LOCALE_ALL', NPC_LOCALE_NAME | NPC_LOCALE_SUBNAME);
979 // Creature report class
980 class CreatureReportGenerator extends ReportGenerator{
981 var $dolocale = NPC_LOCALE_ALL;
982 function CreatureReportGenerator($type = '')
984 global $npc_report, $dDB;
985 $this->db = &$dDB;
986 $this->column_conf =&$npc_report;
987 $this->db_fields = '`creature_template`.`entry`';
988 switch ($type) {
989 case 'vendor': $this->table = '(`creature_template` join `npc_vendor` ON `creature_template`.`entry` = `npc_vendor`.`entry`)'; break;
990 case 'trainer':$this->table = '(`creature_template` join `npc_trainer` ON `creature_template`.`entry` = `npc_trainer`.`entry`)'; break;
991 case 'loot': $this->table = '(`creature_template` join `creature_loot_template` ON `creature_template`.`lootid` = `creature_loot_template`.`entry`)'; break;
992 case 'pick': $this->table = '(`creature_template` join `pickpocketing_loot_template` ON `creature_template`.`pickpocketloot` = `pickpocketing_loot_template`.`entry`)'; break;
993 case 'skin': $this->table = '(`creature_template` join `skinning_loot_template` ON `creature_template`.`skinloot` = `skinning_loot_template`.`entry`)'; break;
994 case 'position':$this->table ='(`creature_template` join `creature` ON `creature_template`.`entry` = `creature`.`id`)'; break;
995 case 'reputation':$this->table ='(`creature_template` join `creature_onkill_reputation` ON `creature_template`.`entry` = `creature_onkill_reputation`.`creature_id`)'; break;
996 default: $this->table = '`creature_template`'; break;
999 function disableNameLocalisation() {$this->dolocale &= ~NPC_LOCALE_NAME;}
1000 function disableSubnameLocalisation() {$this->dolocale &= ~NPC_LOCALE_SUBNAME;}
1001 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1003 $tables.=' LEFT JOIN `locales_creature` ON `creature_template`.`entry` = `locales_creature`.`entry`';
1004 if ($this->dolocale & NPC_LOCALE_NAME)
1006 $fields = str_replace('`name`','`name`, `locales_creature`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1007 $sort_str = str_replace('`name`','`name_loc`, `name`', $sort_str);
1009 if ($this->dolocale & NPC_LOCALE_SUBNAME)
1011 $fields = str_replace('`subname`','`subname`, `locales_creature`.`subname_loc'.$locale.'` AS `subname_loc`', $fields);
1012 $sort_str = str_replace('`subname`','`subname_loc`, `subname`', $sort_str);
1015 function castSpell($entry)
1017 global $dDB;
1018 $rows_1 = $dDB->selectCol('SELECT `entry` FROM `creature_template` WHERE `spell1` = ?d OR `spell2` = ?d OR `spell3` = ?d OR `spell4` = ?d', $entry, $entry, $entry, $entry);
1019 $rows_2 = $dDB->selectCol('SELECT `creature_id` FROM `creature_ai_scripts` WHERE (`action1_type` = 11 AND `action1_param1`=?d) OR (`action2_type` = 11 AND `action2_param1`=?d) OR (`action3_type` = 11 AND `action3_param1`=?d)', $entry, $entry, $entry);
1020 $casters = array_unique(array_merge($rows_1, $rows_2));
1021 if (count($casters))
1022 $this->doRequirest('`creature_template`.`entry` in (?a)', $casters);
1024 function inFaction($entry)
1026 global $wDB;
1027 if ($templatesId =& getFactionTemplates($entry))
1028 $this->doRequirest('`faction_A` in (?a) OR `faction_H` in (?a)', $templatesId, $templatesId);
1030 function soldItem($entry, $price)
1032 $this->db_fields.=', '.$price.' AS `BuyPrice`';
1033 $this->doRequirest('`item` = ?d', $entry);
1034 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
1035 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
1037 function trainSpell($entry)
1039 $this->doRequirest('`spell` = ?d', $entry);
1040 $this->removeIfAllZero('reqskill', 'TRAINER_REPORT_SKILL');
1042 function kreditGroup($entry)
1044 $this->doRequirest('`KillCredit1` = ?d OR `KillCredit2` = ?d', $entry, $entry);
1046 function lootItem($entry)
1048 $ref_loot =& getRefrenceItemLoot($entry);
1049 $this->doRequirest('(`item` = ?d AND `mincountOrRef` > 0) { OR -`mincountOrRef` IN (?a) } GROUP BY `entry`', $entry, count($ref_loot)==0 ? DBSIMPLE_SKIP:array_keys($ref_loot));
1050 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1052 // Position
1053 function onMap($entry)
1055 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1057 function onArea($area_data)
1059 $this->setManualPagenateMode();
1060 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1061 $this->doRequirest('`map` = ?d AND `position_x` > ?d AND `position_x` < ?d AND `position_y` > ?d AND `position_y` < ?d', $area_data[0], $area_data[5], $area_data[4], $area_data[3], $area_data[2]);
1062 $setId = array();
1063 foreach($this->data_array as $id=>$c)
1065 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1066 if ($zone!=$area_data[1] || isset($setId[$c['entry']]))
1067 unset($this->data_array[$id]);
1068 else
1069 $setId[$c['entry']] = 1;
1072 // Reputation
1073 function rewardFactionReputation($id)
1075 $this->doRequirest('`RewOnKillRepFaction1` = ?d OR `RewOnKillRepFaction2` = ?d', $id, $id);
1077 function rewardNpcFactionReputation($entry)
1079 $this->doRequirest('`creature_id` = ?d', $entry);
1083 //=================================================================
1084 // Gameobject list report functions and methods
1085 //=================================================================
1086 function r_objName($data)
1088 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
1089 echo '<a href="?object='.$data['entry'].'">'.($name?$name:'no name').'</a>';
1091 function r_objType($data) {echo getGameobjectType($data['type'], 0);}
1092 function r_objMap($data) {global $lang; echo '<a href="?map&obj='.$data['entry'].'">'.$lang['map'].'</a>';}
1094 // GO report generator config
1095 $go_report = array(
1096 'GO_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['go_name'], 'draw'=>'r_objName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1097 'GO_REPORT_TYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['go_type'], 'draw'=>'r_objType', 'sort_str'=>'`type`', 'fields'=>'`type`'),
1098 'GO_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_objMap', 'sort_str'=>'', 'fields'=>''),
1099 // loot
1100 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1101 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
1104 define('GO_LOCALE_NAME', 0x01);
1105 define('GO_LOCALE_ALL', NPC_LOCALE_NAME);
1107 // GO report class
1108 class GameobjectReportGenerator extends ReportGenerator{
1109 var $dolocale = GO_LOCALE_ALL;
1110 function GameobjectReportGenerator($type = '')
1112 global $go_report, $dDB;
1113 $this->db = &$dDB;
1114 $this->column_conf =&$go_report;
1115 $this->db_fields = '`gameobject_template`.`entry`';
1116 switch ($type) {
1117 case 'loot':
1118 $this->table =
1119 '(`gameobject_template`
1120 join
1121 `gameobject_loot_template`
1123 `gameobject_template`.`data1` = `gameobject_loot_template`.`entry` AND
1124 `gameobject_template`.`type` IN (3, 17, 25))';
1125 break;
1126 case 'position':$this->table ='(`gameobject_template` join `gameobject` ON `gameobject_template`.`entry` = `gameobject`.`id`)';break;
1127 default: $this->table = '`gameobject_template`';break;
1130 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1131 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1133 $tables.= ' LEFT JOIN `locales_gameobject` ON `gameobject_template`.`entry` = `locales_gameobject`.`entry`';
1134 if ($this->dolocale & GO_LOCALE_NAME)
1136 $fields = str_replace('`name`', '`name`, `locales_gameobject`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1137 $sort_str= str_replace('`name`', '`name_loc`, `name`', $sort_str);
1139 $fields = str_replace('`castbarcaption`','`castbarcaption`, `locales_gameobject`.`castbarcaption_loc'.$locale.'` AS `castbarcaption_loc`', $fields);
1141 function castSpell($entry)
1143 $this->doRequirest(
1144 '(`type` = ?d AND `data3` = ?d) OR
1145 (`type` = ?d AND `data10` = ?d) OR
1146 (`type` = ?d AND `data1` = ?d) OR
1147 (`type` = ?d AND `data0` = ?d) OR
1148 (`type` = ?d AND (`data2` = ?d OR `data3` = ?d))',
1149 GAMEOBJECT_TYPE_TRAP, $entry,
1150 GAMEOBJECT_TYPE_GOOBER, $entry,
1151 GAMEOBJECT_TYPE_SUMMONING_RITUAL, $entry,
1152 GAMEOBJECT_TYPE_SPELLCASTER, $entry,
1153 GAMEOBJECT_TYPE_AURA_GENERATOR, $entry, $entry);
1155 function inFaction($entry)
1157 global $wDB;
1158 if ($templatesId =& getFactionTemplates($entry))
1159 $this->doRequirest('`faction` in (?a)', $templatesId);
1161 function spellFocus($entry)
1163 $this->doRequirest('`type` = ?d AND `data0` = ?d', GAMEOBJECT_TYPE_SPELL_FOCUS, $entry);
1165 function lootItem($entry)
1167 $ref_loot =& getRefrenceItemLoot($entry);
1168 $this->doRequirest('(`item` = ?d AND `mincountOrRef` > 0) { OR -`mincountOrRef` IN (?a) } GROUP BY `entry`', $entry, count($ref_loot)==0 ? DBSIMPLE_SKIP:array_keys($ref_loot));
1169 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1171 // Position
1172 function onMap($entry)
1174 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1176 function onArea($area_data)
1178 $this->setManualPagenateMode();
1179 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1180 $this->doRequirest('`map` = ?d AND `position_x` > ?d AND `position_x` < ?d AND `position_y` > ?d AND `position_y` < ?d', $area_data[0], $area_data[5], $area_data[4], $area_data[3], $area_data[2]);
1181 $setId = array();
1182 foreach($this->data_array as $id=>$c)
1184 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1185 if ($zone!=$area_data[1] || isset($setId[$c['entry']]))
1186 unset($this->data_array[$id]);
1187 else
1188 $setId[$c['entry']] = 1;
1193 //=================================================================
1194 // Quest list report functions and methods
1195 //=================================================================
1196 function r_questLvl($data) {echo $data['QuestLevel'];}
1197 function r_questReqLvl($data) {echo $data['MinLevel'];}
1198 function r_questName($data)
1200 global $lang;
1201 $name = @$data['Title_loc']?$data['Title_loc']:$data['Title'];
1202 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 1101) && ($data['RequiredRaces'] !=1791))
1203 echo "<img width=22 height=22 src='images/player_info/factions_img/alliance.gif'>&nbsp;";
1204 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 690) && ($data['RequiredRaces'] !=1791))
1205 echo "<img width=22 height=22 src='images/player_info/factions_img/horde.gif'>&nbsp;";
1206 echo '<a href="?quest='.$data['entry'].'">'.($name?$name:'no name').'</a><br>';
1207 if ($data['ZoneOrSort']>0)
1208 echo '<div class=areaname><a href="?s=q&ZoneID='.$data['ZoneOrSort'].'">'.getAreaName($data['ZoneOrSort']).'</a></div>';
1209 else
1210 if ($data['ZoneOrSort']<0 AND ((-$data['ZoneOrSort']) >= 374 OR (-$data['ZoneOrSort']) == 221 OR (-$data['ZoneOrSort']) == 241 OR ((-$data['ZoneOrSort']) >= 344 AND (-$data['ZoneOrSort']) < 371) or
1211 (-$data['ZoneOrSort']) == 284 OR (-$data['ZoneOrSort']) == 25 OR (-$data['ZoneOrSort']) == 41 OR (-$data['ZoneOrSort']) < 24))
1212 echo '<div class=areaname><a href="?s=q&SortID='.(-$data['ZoneOrSort']).'">'.getQuestSort(-$data['ZoneOrSort']).'</a></div>';
1213 if ($data['RequiredClasses'])
1214 echo '<div class=classqname>'.getQAllowableClass($data['RequiredClasses']).'</div>';
1215 if ($data['RequiredSkill'])
1216 echo '<div class=areaname><a href="?s=q&SkillID='.($data['RequiredSkill']).'">'.getSkillName($data['RequiredSkill'], 0).'('.$data['RequiredSkillValue'].')</a></div>';
1217 if ($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY)
1218 echo '<div class=areaname><a href="?s=q&Sfm='.($data['SpecialFlags']).'">'.$lang['quest_type3'].'</a></div>';
1219 if ($data['QuestFlags'] & QUEST_FLAGS_WEEKLY)
1220 echo '<div class=areaname><a href="?s=q&Sfw='.($data['QuestFlags']).'">'.$lang['quest_type2'].'</a></div>';
1221 if ($data['QuestFlags'] & QUEST_FLAGS_DAILY)
1222 echo '<div class=areaname><a href="?s=q&Sfd='.($data['QuestFlags']).'">'.$lang['quest_type1'].'</a></div>';
1223 if (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_REPEATABLE) && (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY) ==0) && ($data['QuestFlags'] & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) == 0)
1224 echo '<div class=areaname><a href="?s=q&Sfr='.($data['SpecialFlags']).'">'.$lang['quest_type0'].'</a></div>';
1226 function r_questGiver($data)
1228 global $dDB;
1229 // Search creature quest giver
1230 if ($src = $dDB->select(
1231 'SELECT `entry`, `name`, `subname`, `faction_A`
1232 FROM `creature_template` left join `creature_questrelation` ON `creature_template`.`entry` = `creature_questrelation`.`id`
1233 WHERE `creature_questrelation`.`quest` = ?d', $data['entry']))
1235 foreach ($src as $creature){localiseCreature($creature);r_npcRName($creature);}
1236 return;
1238 // Search GO quest giver
1239 if ($src = $dDB->select(
1240 'SELECT `entry`, `name`
1241 FROM `gameobject_template` left join `gameobject_questrelation` ON `gameobject_template`.`entry` = `gameobject_questrelation`.`id`
1242 WHERE `gameobject_questrelation`.`quest` = ?d', $data['entry']))
1244 foreach ($src as $go) {localiseGameobject($go); r_objName($go);}
1245 return;
1247 // Search item quest giver
1248 if ($src = $dDB->select("SELECT `entry`, `name`, `Quality` FROM `item_template` WHERE `startquest` = ?d", $data['entry']))
1250 foreach ($src as $item) {localiseItem($item);r_itemName($item);}
1251 return;
1253 echo '---(?)---';
1255 function r_questReward($quest)
1257 global $lang;
1258 if ($quest['RewItemId1'] OR $quest['RewItemId2'] OR $quest['RewItemId3'] OR $quest['RewItemId4'])
1260 // echo $lang['Rew_item'].'<br>';
1261 if ($quest['RewItemId1']) echo text_show_item($quest['RewItemId1'], 0, 'quest');
1262 if ($quest['RewItemId2']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId2'], 0, 'quest');
1263 if ($quest['RewItemId3']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId3'], 0, 'quest');
1264 if ($quest['RewItemId4']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId4'], 0, 'quest');
1265 echo '<br>';
1267 if ($quest['RewChoiceItemId1'] OR $quest['RewChoiceItemId2'] OR $quest['RewChoiceItemId3'] OR
1268 $quest['RewChoiceItemId4'] OR $quest['RewChoiceItemId5'] OR $quest['RewChoiceItemId6'])
1270 echo $lang['Rew_select_item'].'<br>';
1271 if ($quest['RewChoiceItemId1']) echo text_show_item($quest['RewChoiceItemId1'], 0, 'quest');
1272 if ($quest['RewChoiceItemId2']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId2'], 0, 'quest');
1273 if ($quest['RewChoiceItemId3']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId3'], 0, 'quest');
1274 if ($quest['RewChoiceItemId4']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId4'], 0, 'quest');
1275 if ($quest['RewChoiceItemId5']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId5'], 0, 'quest');
1276 if ($quest['RewChoiceItemId6']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId6'], 0, 'quest');
1277 echo "<br>";
1279 if ($quest['RewSpell'] AND $quest['RewSpellCast'])
1281 show_spell($quest['RewSpell'], 0, 'quest');
1282 echo '<br>';
1284 if (!$quest['RewSpell'] AND $quest['RewSpellCast'])
1286 show_spell($quest['RewSpellCast'], 0, 'quest');
1287 echo '<br>';
1289 for ($i = 1; $i <= 5; $i++)
1291 switch (ABS($quest['RewRepValueId'.$i])):
1292 case 1: $RepValueId[$i] = 10; break;
1293 case 2: $RepValueId[$i] = 25; break;
1294 case 3: $RepValueId[$i] = 75; break;
1295 case 4: $RepValueId[$i] = 150; break;
1296 case 5: $RepValueId[$i] = 250; break;
1297 case 6: $RepValueId[$i] = 350; break;
1298 case 7: $RepValueId[$i] = 500; break;
1299 case 8: $RepValueId[$i] = 1000; break;
1300 case 9: $RepValueId[$i] = 5; break;
1301 default: $RepValueId[$i] = 0;
1302 endswitch;
1304 $quest_rate[$i] = getRepRewRate($quest['RewRepFaction'.$i]);
1306 if ($quest['RewRepValueId'.$i] < 0)
1307 $RepValueId[$i] = -$RepValueId[$i];
1309 if ($quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1310 $quest['RewRepValue'.$i] = $quest['RewRepValue'.$i]/100;
1312 if (!$quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1313 $quest['RewRepValue'.$i] = $RepValueId[$i];
1315 $quest['RewRepValue'.$i]=$quest['RewRepValue'.$i]*$quest_rate[$i];
1318 if ($quest['RewRepFaction1'] AND !$quest['RewRepFaction2'] AND
1319 !$quest['RewRepFaction3'] AND !$quest['RewRepFaction4'] AND
1320 !$quest['RewRepFaction5'])
1322 $spillover=getRepSpillover($quest['RewRepFaction1']);
1323 if ($spillover)
1324 foreach ($spillover as $faction)
1326 if ($faction['faction1'])
1328 $quest['RewRepFaction2']=$faction['faction1'];
1329 $quest['RewRepValue2']=$quest['RewRepValue1']*$faction['rate_1'];
1331 if ($faction['faction2'])
1333 $quest['RewRepFaction3']=$faction['faction2'];
1334 $quest['RewRepValue3']=$quest['RewRepValue1']*$faction['rate_2'];
1336 if ($faction['faction3'])
1338 $quest['RewRepFaction4']=$faction['faction3'];
1339 $quest['RewRepValue4']=$quest['RewRepValue1']*$faction['rate_3'];
1341 if ($faction['faction4'])
1343 $quest['RewRepFaction5']=$faction['faction4'];
1344 $quest['RewRepValue5']=$quest['RewRepValue1']*$faction['rate_4'];
1349 if ($quest['RewRepFaction1'] && $quest['RewRepValue1'])echo getFactionName($quest['RewRepFaction1']).': '.$quest['RewRepValue1'].'<br>';
1350 if ($quest['RewRepFaction2'] && $quest['RewRepValue2'])echo getFactionName($quest['RewRepFaction2']).': '.$quest['RewRepValue2'].'<br>';
1351 if ($quest['RewRepFaction3'] && $quest['RewRepValue3'])echo getFactionName($quest['RewRepFaction3']).': '.$quest['RewRepValue3'].'<br>';
1352 if ($quest['RewRepFaction4'] && $quest['RewRepValue4'])echo getFactionName($quest['RewRepFaction4']).': '.$quest['RewRepValue4'].'<br>';
1353 if ($quest['RewRepFaction5'] && $quest['RewRepValue5'])echo getFactionName($quest['RewRepFaction5']).': '.$quest['RewRepValue5'].'<br>';
1354 if ($quest['RewMoneyMaxLevel'])
1355 echo $lang['Rew_XP'].' '.getQuestXPValue($quest).' xp<br>';
1356 if ($quest['RewOrReqMoney'])
1357 echo $lang['Rew_money'].' '.money($quest['RewOrReqMoney'], 7).'<br>';
1360 $quest_reward_fields =
1361 '`RewXPId`, `RewChoiceItemId1`, `RewChoiceItemId2`, `RewChoiceItemId3`, `RewChoiceItemId4`, `RewChoiceItemId5`, `RewChoiceItemId6`,
1362 `RewChoiceItemCount1`, `RewChoiceItemCount2`, `RewChoiceItemCount3`, `RewChoiceItemCount4`, `RewChoiceItemCount5`, `RewChoiceItemCount6`,
1363 `RewItemId1`, `RewItemId2`, `RewItemId3`, `RewItemId4`, `RewItemCount1`, `RewItemCount2`, `RewItemCount3`, `RewItemCount4`,
1364 `RewRepFaction1`, `RewRepFaction2`, `RewRepFaction3`, `RewRepFaction4`, `RewRepFaction5`,
1365 `RewRepValue1`, `RewRepValue2`, `RewRepValue3`, `RewRepValue4`, `RewRepValue5`,
1366 `RewRepValueId1`, `RewRepValueId2`, `RewRepValueId3`, `RewRepValueId4`, `RewRepValueId5`,
1367 `RewOrReqMoney`, `RewMoneyMaxLevel`, `RewSpell`, `RewSpellCast`, `RewMailTemplateId`, `RewMailDelaySecs`';
1369 $quest_report = array(
1370 'QUEST_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['quest_lvl'], 'draw'=>'r_questLvl', 'sort_str'=>'`QuestLevel` DESC', 'fields'=>'`QuestLevel`' ),
1371 'QUEST_REPORT_REQLEVEL'=>array('class'=>'small','sort'=>'req_lvl','text'=>$lang['quest_reqlvl'], 'draw'=>'r_questReqLvl','sort_str'=>'`MinLevel` DESC', 'fields'=>'`MinLevel`' ),
1372 'QUEST_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['quest_name'], 'draw'=>'r_questName', 'sort_str'=>'`Title`', 'fields'=>'`Title`, `ZoneOrSort`, `RequiredSkill`, `RequiredSkillValue`, `RequiredClasses`, `RequiredRaces`, `QuestFlags`, `SpecialFlags`'),
1373 'QUEST_REPORT_GIVER' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['quest_giver'], 'draw'=>'r_questGiver', 'sort_str'=>'', 'fields'=>''),
1374 'QUEST_REPORT_REWARD' =>array('class'=>'full', 'sort'=>'reward', 'text'=>$lang['quest_rewards'], 'draw'=>'r_questReward','sort_str'=>'`RewMoneyMaxLevel` DESC','fields'=>&$quest_reward_fields),
1375 // loot
1376 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `Title`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1377 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
1380 define('QUEST_LOCALE_NAME', 0x01);
1381 define('QUEST_LOCALE_ALL', NPC_LOCALE_NAME);
1383 // Quest report class
1384 class QuestReportGenerator extends ReportGenerator{
1385 var $dolocale = QUEST_LOCALE_ALL;
1386 function QuestReportGenerator($type='')
1388 global $quest_report, $dDB;
1389 $this->db = &$dDB;
1390 $this->column_conf =&$quest_report;
1391 switch ($type){
1392 case 'go_giver': $this->table = '(`quest_template` join `gameobject_questrelation` ON `quest_template`.`entry` = `gameobject_questrelation`.`quest`)';break;
1393 case 'go_take': $this->table = '(`quest_template` join `gameobject_involvedrelation` ON `quest_template`.`entry` = `gameobject_involvedrelation`.`quest`)';break;
1394 case 'npc_giver': $this->table = '(`quest_template` join `creature_questrelation` ON `quest_template`.`entry` = `creature_questrelation`.`quest`)';break;
1395 case 'npc_take': $this->table = '(`quest_template` join `creature_involvedrelation` ON `quest_template`.`entry` = `creature_involvedrelation`.`quest`)';break;
1396 case 'mail_loot': $this->table = '(`quest_template` join `mail_loot_template` ON `quest_template`.`RewMailTemplateId` = `mail_loot_template`.`entry`)';break;
1397 default: $this->table = '`quest_template`';break;
1399 $this->db_fields = '`quest_template`.`entry`';
1401 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1402 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1404 $tables.= ' LEFT JOIN `locales_quest` ON `quest_template`.`entry` = `locales_quest`.`entry`';
1405 if ($this->dolocale & QUEST_LOCALE_NAME)
1407 $fields = str_replace('`Title`', '`Title`, `locales_quest`.`Title_loc'.$locale.'` AS `Title_loc`', $fields);
1408 $sort_str = str_replace('`Title`', '`Title_loc`, `Title`', $sort_str);
1411 // Create quest givers/take list by entry
1412 function getGiveTakeList($entry)
1414 $this->doRequirest('`id` = ?d', $entry);
1416 // Create quest list require GO for comlete
1417 function requireGO($entry)
1419 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', -$entry, -$entry, -$entry, -$entry);
1421 // Create quest list require GO for comlete
1422 function requireCreature($entry)
1424 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', $entry, $entry, $entry, $entry);
1426 function oneQuest($entry)
1428 $this->doRequirest('`quest_template`.`entry` = ?d', $entry);
1430 // Create quest list require item for comlete
1431 function requireItem($entry, $giveQuest)
1433 $this->doRequirest('(`ReqItemId1`= ?d OR `ReqItemId2`= ?d OR `ReqItemId3`= ?d OR `ReqItemId4`= ?d OR `ReqItemId5`= ?d OR `ReqItemId6`= ?d OR `ReqSourceId1`= ?d OR `ReqSourceId2`= ?d OR `ReqSourceId3`= ?d OR `ReqSourceId4`= ?d) AND `quest_template`.`entry` <> ?d', $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $giveQuest);
1435 // Create quest list prowide item at take
1436 function provideItem($entry, $giveQuest)
1438 $this->doRequirest('`SrcItemId` = ?d AND `quest_template`.`entry` <> ?d', $entry, $giveQuest);
1440 // Create quest list reward item
1441 function rewardItem($entry)
1443 $this->doRequirest('`RewItemId1`= ?d OR `RewItemId2`= ?d OR `RewItemId3`= ?d OR `RewItemId4`= ?d OR
1444 `RewChoiceItemId1`= ?d OR`RewChoiceItemId2`= ?d OR `RewChoiceItemId3`= ?d OR `RewChoiceItemId4`= ?d OR `RewChoiceItemId5`= ?d OR `RewChoiceItemId6`= ?d',
1445 $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1447 // Create quest list cast/reward spell
1448 function rewardSpell($entry)
1450 $this->doRequirest('`RewSpell` = ?d OR `RewSpellCast` = ?d', $entry, $entry);
1452 // Return quest list where exist faction reputation reward
1453 function rewardReputation($entry)
1455 $this->doRequirest('`RewRepFaction1`= ?d OR `RewRepFaction2`= ?d OR `RewRepFaction3`= ?d OR `RewRepFaction4`= ?d OR `RewRepFaction5`= ?d', $entry, $entry, $entry, $entry, $entry);
1457 // Mail loot
1458 function lootItem($entry)
1460 $ref_loot =& getRefrenceItemLoot($entry);
1461 $this->doRequirest('(`item` = ?d AND `mincountOrRef` > 0) { OR -`mincountOrRef` IN (?a) } GROUP BY `entry`', $entry, count($ref_loot)==0 ? DBSIMPLE_SKIP:array_keys($ref_loot));
1462 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1467 //=================================================================
1468 // Spell list report functions and methods
1469 //=================================================================
1470 function r_spellLevel($data) {echo $data['spellLevel'];}
1471 function r_spellIcon($data) {show_spell($data['id'], $data['SpellIconID']);}
1472 function r_spellName($data)
1474 echo '<a href="?spell='.$data['id'].'">'.$data['SpellName'].'</a>';
1475 if ($data['Rank'])
1476 echo '<div class=srank>'.$data['Rank'].'</div>';
1478 function r_spellRecipe($data)
1480 r_spellName($data);
1481 if ($skilname = getSkillNameForSpell($data['id']))
1482 echo '<div class=srank>&lt;'.$skilname.'&gt;</div>';
1484 function r_spellSkill($data)
1486 global $lang;
1487 r_spellName($data);
1488 if ($data['RequiresSpellFocus'])
1489 echo '<div class=reqfocus>'.sprintf($lang['spell_req_focus'], getSpellFocusName($data['RequiresSpellFocus'], 2)).'</div>';
1490 if ($data['TotemCategory_1'] OR $data['TotemCategory_2'])
1492 $text= '';
1493 if ($data['TotemCategory_1']) $text = getTotemCategory($data['TotemCategory_1']);
1494 if ($data['TotemCategory_2']) $text.= ", ".getTotemCategory($data['TotemCategory_2']);
1495 echo '<div class=reqfocus>'.sprintf($lang['spell_req_totem'], $text).'</div>';
1498 function r_spellSchool($data){echo getSpellSchool($data['SchoolMask']);}
1499 function r_spellReagents($data)
1501 echo '<table class=reagents><tr>';
1502 for ($i=1;$i<9;$i++)
1503 if ($data['Reagent_'.$i])
1504 echo '<td>'.text_show_item($data['Reagent_'.$i],0,'reagent').'<br>x'.$data['ReagentCount_'.$i].'</td>';
1505 echo "</tr></table>";
1507 function r_spellCreate($data)
1509 if ($data['EffectItemType_1'] == 0 AND $data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1510 return 0;
1511 if ($data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1512 echo text_show_item($data['EffectItemType_1']);
1513 else
1515 echo '<table class=reagents><tr>';
1516 for ($i=1;$i<4;$i++)
1517 if ($data['EffectItemType_'.$i])
1518 echo '<td>'.text_show_item($data['EffectItemType_'.$i], 0, "reagent").($data['EffectBasePoints_'.$i]>0?'<br>x&nbsp;'.($data['EffectBasePoints_'.$i]+1):'').'</td>';
1519 echo '</tr></table>';
1521 return 1;
1523 function r_spellEquiped($data)
1525 echo $data['EquippedItemClass'].'<br />';
1526 echo $data['EquippedItemSubClassMask'].'<br />';
1527 echo $data['EquippedItemInventoryTypeMask'].'<br />';
1529 function r_skillLevel($data) {echo $data['min_value'];}
1530 function r_skillIcon($data)
1532 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1533 r_spellCreate($data);
1534 else
1535 r_spellIcon($data);
1537 $reagents= '`Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,
1538 `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, `ReagentCount_7`, `ReagentCount_8`';
1539 // Spell report generator config
1540 $spell_report = array(
1541 'SPELL_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['spell_level'], 'draw'=>'r_spellLevel', 'sort_str'=>'`spellLevel`', 'fields'=>'`spellLevel`' ),
1542 'SPELL_REPORT_ICON' =>array('class'=>'s_ico','sort'=>'icon', 'text'=>'', 'draw'=>'r_spellIcon', 'sort_str'=>'`SpellIconID`', 'fields'=>'`SpellIconID`' ),
1543 'SPELL_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['spell_name'], 'draw'=>'r_spellName', 'sort_str'=>'`SpellName`, `id`','fields'=>'`SpellName`, `Rank`' ),
1544 'SPELL_REPORT_RECIPE'=>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['spell_name'], 'draw'=>'r_spellRecipe', 'sort_str'=>'`SpellName`, `id`','fields'=>'`SpellName`, `Rank`, `RequiresSpellFocus`, `TotemCategory_1`, `TotemCategory_2`'),
1545 'SPELL_REPORT_SCHOOL'=>array('class'=>'', 'sort'=>'school','text'=>$lang['spell_school'], 'draw'=>'r_spellSchool', 'sort_str'=>'`SchoolMask`', 'fields'=>'`SchoolMask`' ),
1546 'SPELL_REPORT_REAGENTS'=>array('class'=>'reag','sort'=>'', 'text'=>$lang['spell_reagent'],'draw'=>'r_spellReagents','sort_str'=>'', 'fields'=>&$reagents),
1547 'SPELL_REPORT_CREATE'=>array('class'=>'skill','sort'=>'', 'text'=>$lang['spell_create'], 'draw'=>'r_spellCreate', 'sort_str'=>'', 'fields'=>'`EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`, `EffectBasePoints_1`, `EffectBasePoints_2`, `EffectBasePoints_3`'),
1548 'SPELL_REPORT_EQUIP'=>array('class'=>'left', 'sort'=>'', 'text'=>'', 'draw'=>'r_spellEquiped','sort_str'=>'', 'fields'=>'`EquippedItemClass`, `EquippedItemSubClassMask`, `EquippedItemInventoryTypeMask`'),
1549 // Skill
1550 'SKILL_REPORT_LEVEL' =>array('class'=>'small','sort'=>'skill_lvl', 'text'=>$lang['spell_level'],'draw'=>'r_skillLevel', 'sort_str'=>'`min_value`, `spellLevel`, `SpellName`, `id`', 'fields'=>'`min_value`'),
1551 'SKILL_REPORT_ICON' =>array('class'=>'skill','sort'=>'skill', 'text'=>'', 'draw'=>'r_skillIcon', 'sort_str'=>'`SpellIconID`', 'fields'=>'`SpellIconID`, `EffectItemType_1`, `EffectItemType_2`, `EffectItemType_3`, `EffectBasePoints_1`, `EffectBasePoints_2`, `EffectBasePoints_3`' ),
1552 'SKILL_REPORT_NAME' =>array('class'=>'left', 'sort'=>'skill_name','text'=>$lang['spell_name'], 'draw'=>'r_spellSkill', 'sort_str'=>'`SpellName`, `id`','fields'=>'`SpellName`, `Rank`, `RequiresSpellFocus`, `TotemCategory_1`, `TotemCategory_2`'),
1555 // Spell report class
1556 class SpellReportGenerator extends ReportGenerator{
1557 function SpellReportGenerator($type='')
1559 global $spell_report, $wDB;
1560 $this->db = &$wDB;
1561 $this->column_conf =&$spell_report;
1562 switch ($type){
1563 case 'skill': $this->table = '(`wowd_spell` join `wowd_skill_line_ability` ON `wowd_skill_line_ability`.`spellId` =`wowd_spell`.`id`)';break;
1564 default: $this->table = '`wowd_spell`';break;
1566 $this->db_fields = '`wowd_spell`.`id`';
1568 function summonGO($entry)
1570 $effList = array(50, 76, 104, 105, 106, 107);
1571 $this->doRequirest(
1572 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1573 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1574 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1576 function summonCreature($entry)
1578 $effList = array(28, 56, 90, 93, 134);
1579 $this->doRequirest(
1580 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1581 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1582 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1584 // List of spells use item as reagent
1585 function useRegent($entry)
1587 $this->doRequirest('`Reagent_1` = ?d OR `Reagent_2`=?d OR `Reagent_3`=?d OR `Reagent_4`=?d OR `Reagent_5`=?d OR `Reagent_6`=?d OR `Reagent_7`=?d OR `Reagent_8`=?d', $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1588 $create = 0;
1589 foreach($this->data_array as &$data)
1590 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1591 $create = 1;
1592 if (!$create) $this->removeField('SPELL_REPORT_CREATE');
1594 // List of spells create this item
1595 function createItem($entry)
1597 $eff_list = array(107, 108, 109, 112);
1598 $this->doRequirest(
1599 '(`EffectItemType_1` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1600 (`EffectItemType_2` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1601 (`EffectItemType_3` = ?d AND EffectApplyAuraName_1 NOT IN (?a))', $entry, $eff_list, $entry, $eff_list, $entry, $eff_list);
1603 // List os spells give faction reputation
1604 function giveReputation($entry)
1606 $this->doRequirest(
1607 '(`EffectMiscValue_1` = ?d AND `Effect_1` = 103) OR
1608 (`EffectMiscValue_2` = ?d AND `Effect_2` = 103) OR
1609 (`EffectMiscValue_3` = ?d AND `Effect_3` = 103)', $entry, $entry, $entry);
1611 function triggerFromSpells($entry)
1613 $this->doRequirest(
1614 '`EffectTriggerSpell_1` = ?d OR
1615 `EffectTriggerSpell_2` = ?d OR
1616 `EffectTriggerSpell_3` = ?d', $entry, $entry, $entry);
1618 function enchantFromSpells($entry)
1620 $effList = array(53, 54, 92);
1621 $this->doRequirest(
1622 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1623 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1624 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1626 function affectedBySpells($family, $maskA, $maskB, $maskC)
1628 $this->doRequirest(
1629 '`SpellFamilyName` = ?d AND
1631 (`EffectApplyAuraName_1` IN (107, 108) AND ( (`EffectSpellClassMaskA_1` & ?d) OR (`EffectSpellClassMaskA_2` & ?d) OR (`EffectSpellClassMaskA_3` & ?d) ) ) OR
1632 (`EffectApplyAuraName_2` IN (107, 108) AND ( (`EffectSpellClassMaskB_1` & ?d) OR (`EffectSpellClassMaskB_2` & ?d) OR (`EffectSpellClassMaskB_3` & ?d) ) ) OR
1633 (`EffectApplyAuraName_3` IN (107, 108) AND ( (`EffectSpellClassMaskC_1` & ?d) OR (`EffectSpellClassMaskC_2` & ?d) OR (`EffectSpellClassMaskC_3` & ?d) ) )
1634 )', $family, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC);
1636 function castByCreature($creature)
1638 global $wDB, $dDB;
1639 // By creature fields
1640 for ($i=1;$i<5;$i++) if ($creature['spell'.$i]) $spell_list[] = $creature['spell'.$i];
1641 // By event AI table
1642 for ($i=1;$i<=3;$i++)
1643 $spell_list = array_merge($spell_list, $dDB->selectCol('SELECT `action1_param'.$i.'` as `id` FROM `creature_ai_scripts` WHERE `creature_id` = ?d AND `action'.$i.'_type` = 11', $creature['entry']));
1644 if (count($spell_list))
1645 $this->doRequirest('`id` IN (?a)', array_unique($spell_list));
1647 function doSkillList($skill)
1649 if (isset($_REQUEST['guid']))
1651 $spells = getPlayerSpells($_REQUEST['guid']);
1652 $this->rowCallback = 'playerSpellCallback';
1654 $this->doRequirest('`skillId` = ?d', $skill);
1656 function lootItem($entry)
1658 global $dDB;
1659 $ref_loot =& getRefrenceItemLoot($entry);
1660 $spells = $dDB->select("SELECT `entry` AS ARRAY_KEY, `ChanceOrQuestChance`, `mincountOrRef` FROM `spell_loot_template` WHERE (`item` = ?d AND `mincountOrRef` > 0) { OR -`mincountOrRef` IN (?a) }", $entry, count($ref_loot)==0 ? DBSIMPLE_SKIP:array_keys($ref_loot));
1661 if ($spells)
1662 $this->doRequirest('`id` IN (?a)', array_keys($spells));
1666 //=================================================================
1667 // Glyph list report functions and methods
1668 //=================================================================
1669 function r_glyphId($data) {echo $data['id'];}
1670 function r_glyphName($data) {$spell=getSpell($data['SpellId']); echo $spell['SpellName'];}
1671 function r_glyphIcon($data) {echo '<img src="'.getSpellIcon($data['iconId']).'">';}
1673 $glyph_report = array(
1674 'GLYPH_REPORT_ID' =>array('class'=>'small','sort'=>'','text'=>$lang['glyph_id' ], 'draw'=>'r_glyphId', 'sort_str'=>'', 'fields'=>'' ),
1675 'GLYPH_REPORT_NAME'=>array('class'=>'left', 'sort'=>'','text'=>$lang['glyph_name'], 'draw'=>'r_glyphName','sort_str'=>'', 'fields'=>'`SpellId`' ),
1676 'GLYPH_REPORT_ICON'=>array('class'=>'i_ico','sort'=>'','text'=>'', 'draw'=>'r_glyphIcon','sort_str'=>'', 'fields'=>'`iconId`'),
1679 class GlyphReportGenerator extends ReportGenerator{
1680 // Database depend requirest generator
1681 // Select only reuire for report fields from database
1682 function GlyphReportGenerator($type='')
1684 global $glyph_report, $wDB;
1685 $this->db = &$wDB;
1686 $this->column_conf =&$glyph_report;
1687 $this->table = '`wowd_glyphproperties`';
1688 $this->db_fields = '`id`';
1690 function useSpell($entry)
1692 $this->doRequirest('`SpellId` = ?d', $entry);
1696 //=================================================================
1697 // Random Suffix list report functions and methods
1698 //=================================================================
1699 function r_rndSuffId($data) {echo $data['id'];}
1700 function r_rndSuffName($data) {echo '&nbsp;... '.$data['name'];}
1701 function r_rndSuffDetail($data)
1703 for ($j=1;$j<=3;$j++)
1704 if ($data['EnchantID_'.$j])
1705 echo str_ireplace('$i', round($data['Prefix_'.$j]/100, 2).'%', getEnchantmentDesc($data['EnchantID_'.$j]))."<br>";
1708 $rsuff_report = array(
1709 'RSUFF_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndSuffId', 'sort_str'=>'', 'fields'=>'' ),
1710 'RSUFF_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndSuffName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1711 'RSUFF_REPORT_ENCHANTS'=>array('class'=>'left', 'sort'=>'', 'text'=>$lang['rand_enchant_details'],'draw'=>'r_rndSuffDetail','sort_str'=>'', 'fields'=>'`Prefix_1`, `Prefix_2`, `Prefix_3`, `EnchantID_1`, `EnchantID_2`, `EnchantID_3`'),
1714 class RandomSuffixReportGenerator extends ReportGenerator{
1715 // Database depend requirest generator
1716 // Select only reuire for report fields from database
1717 function RandomSuffixReportGenerator($type='')
1719 global $rsuff_report, $wDB;
1720 $this->db = &$wDB;
1721 $this->column_conf =&$rsuff_report;
1722 $this->table = '`wowd_item_random_suffix`';
1723 $this->db_fields = '`id`';
1725 function enchantFrom($entry)
1727 $this->doRequirest('`EnchantID_1` = ?d OR `EnchantID_2` = ?d OR `EnchantID_3` = ?d', $entry, $entry, $entry);
1731 //=================================================================
1732 // Random Suffix list report functions and methods
1733 //=================================================================
1734 function r_rndPropId($data) {echo $data['id'];}
1735 function r_rndPropName($data) {echo '&nbsp;... '.$data['name'];}
1736 function r_rndPropDetail($data)
1738 for ($j=1;$j<=5;$j++)
1739 if ($data['EnchantID_'.$j])
1740 echo getEnchantmentDesc($data['EnchantID_'.$j])."<br>";
1743 $rprop_report = array(
1744 'RPROP_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndPropId', 'sort_str'=>'', 'fields'=>'' ),
1745 'RPROP_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndPropName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1746 'RPROP_REPORT_ENCHANTS'=>array('class'=>'left', 'sort'=>'', 'text'=>$lang['rand_enchant_details'],'draw'=>'r_rndPropDetail','sort_str'=>'', 'fields'=>'`EnchantID_1`, `EnchantID_2`, `EnchantID_3`, `EnchantID_4`, `EnchantID_5`'),
1749 class RandomPropetyReportGenerator extends ReportGenerator{
1750 // Database depend requirest generator
1751 // Select only reuire for report fields from database
1752 function RandomPropetyReportGenerator($type='')
1754 global $rprop_report, $wDB;
1755 $this->db = &$wDB;
1756 $this->column_conf =&$rprop_report;
1757 $this->table = '`wowd_item_random_propety`';
1758 $this->db_fields = '`id`';
1760 function enchantFrom($entry)
1762 $this->doRequirest('`EnchantID_1` = ?d OR `EnchantID_2` = ?d OR `EnchantID_3` = ?d OR `EnchantID_4` = ?d OR `EnchantID_5` = ?d', $entry, $entry, $entry, $entry, $entry);
1766 //=================================================================
1767 // Lock list report functions and methods
1768 //=================================================================
1769 function r_LockId($data) {echo $data['id'];}
1770 function r_LockKeys($data)
1772 for ($i=0;$i<8;$i++)
1774 switch ($data['keytype_'.$i]){
1775 case 0: continue;
1776 case 1: echo text_show_item($data['key_'.$i], 0, 'cost').($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1777 case 2: echo getLockType($data['key_'.$i]).($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1781 function r_LockProvide($data)
1783 global $lang, $dDB;
1784 if ($items = $dDB->select('SELECT `entry`, `Quality`, `displayid`, `name` FROM `item_template` WHERE `lockid` = ?d', $data['id']))
1785 foreach ($items as $i)
1786 show_item($i['entry'], $i['displayid'], 'sell');
1788 $data0 = array(GAMEOBJECT_TYPE_QUESTGIVER,GAMEOBJECT_TYPE_CHEST,GAMEOBJECT_TYPE_TRAP,GAMEOBJECT_TYPE_GOOBER,GAMEOBJECT_TYPE_CAMERA);
1789 $data1 = array(GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_BUTTON);
1790 if ($go_list = $dDB->select('SELECT `entry`,`name` FROM `gameobject_template` WHERE (`type` IN (?a) AND `data0` = ?d) OR (`type` IN (?a) AND `data1` = ?d)', $data0, $data['id'], $data1, $data['id']))
1791 foreach ($go_list as $go)
1793 localiseGameobject($go);
1794 r_objName($go);echo '<br>';
1796 if (count($items) + count($go_list) == 0)
1797 echo $lang['no_found'];
1800 $lock_report = array(
1801 'LOCK_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['lock_id'], 'draw'=>'r_LockId', 'sort_str'=>'', 'fields'=>''),
1802 'LOCK_REPORT_KEY' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['lock_keys'],'draw'=>'r_LockKeys', 'sort_str'=>'', 'fields'=>''),
1803 'LOCK_REPORT_HAVE'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['locked_list'],'draw'=>'r_LockProvide','sort_str'=>'', 'fields'=>''),
1806 class LockReportGenerator extends ReportGenerator{
1807 // Database depend requirest generator
1808 // Select only reuire for report fields from database
1809 function LockReportGenerator($type='')
1811 global $lock_report, $wDB;
1812 $this->db = &$wDB;
1813 $this->column_conf =&$lock_report;
1814 $this->table = '`wowd_lock`';
1815 $this->db_fields = '*';
1817 function haveItemAsKey($entry)
1819 $this->doRequirest(
1820 '(`keytype_0` = 1 AND `key_0` = ?d) OR
1821 (`keytype_1` = 1 AND `key_1` = ?d) OR
1822 (`keytype_2` = 1 AND `key_2` = ?d) OR
1823 (`keytype_3` = 1 AND `key_3` = ?d) OR
1824 (`keytype_4` = 1 AND `key_4` = ?d)', $entry, $entry, $entry, $entry, $entry);
1828 //=================================================================
1829 // Extend cost list report functions and methods
1830 //=================================================================
1831 function r_excostId($data) {echo $data['id'];}
1832 function r_excostCost($data, $side = 0)
1834 if ($side) $side = "images/honor_horde.png";
1835 else $side = "images/honor_alliance.png";
1836 $str='<div class=ex_cost>';
1837 if ($data['reqhonorpoints']) $str.= $data['reqhonorpoints'].'x<img class=cost src='.$side.'>';
1838 if ($data['reqarenapoints']) $str.= $data['reqarenapoints'].'x<img class=cost src=images/arena_points.png>';
1839 for ($i=1;$i<6;$i++)
1840 if ($data['reqitem_'.$i]) $str.= $data['reqitemcount_'.$i].' x '.text_show_item($data['reqitem_'.$i], 0, 'cost');
1841 echo $str.'</div>';
1844 function r_excostItem($data)
1846 global $lang, $dDB;
1847 if ($items = $dDB->selectCol("SELECT `item` FROM `npc_vendor` WHERE ExtendedCost = ?d GROUP BY `item`", $data['id']))
1848 foreach ($items as $itemid)
1849 show_item($itemid, 0, "sell");
1850 else
1851 echo $lang['no_found'];
1853 $excost_report = array(
1854 'EXCOST_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['excost_id'], 'draw'=>'r_excostId', 'sort_str'=>'`id`', 'fields'=>''),
1855 'EXCOST_REPORT_COST'=>array('class'=>'small','sort'=>'cost', 'text'=>$lang['excost_cost'], 'draw'=>'r_excostCost','sort_str'=>'`reqitemcount_1`,`reqitemcount_2`, `reqitemcount_3`', 'fields'=>''),
1856 'EXCOST_REPORT_ITEM'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['excost_items'],'draw'=>'r_excostItem','sort_str'=>'', 'fields'=>''),
1859 class ExCostReportGenerator extends ReportGenerator{
1860 // Database depend requirest generator
1861 // Select only reuire for report fields from database
1862 function ExCostReportGenerator($type='')
1864 global $excost_report, $wDB;
1865 $this->db = &$wDB;
1866 $this->column_conf =&$excost_report;
1867 $this->table = '`wowd_item_ex_cost`';
1868 $this->db_fields = '*';
1870 function useItemAsCost($entry)
1872 $this->doRequirest(
1873 '`reqitem_1` = ?d OR
1874 `reqitem_2` = ?d OR
1875 `reqitem_3` = ?d OR
1876 `reqitem_4` = ?d OR
1877 `reqitem_5` = ?d', $entry, $entry, $entry, $entry, $entry);
1881 //=================================================================
1882 // Item set list report functions and methods
1883 //=================================================================
1884 function r_setId($data) {echo $data['id'];}
1885 function r_setName($data){echo '<a href="?itemset='.$data['id'].'">'.$data['name'].'</a>';}
1886 function r_setItems($data)
1888 for($i=1;$i<18;$i++)
1889 if ($set_item = $data['item_'.$i])
1890 echo '&nbsp;'.text_show_item($set_item).'&nbsp;';
1892 function r_setSpells($data)
1894 for($i=1; $i<9; $i++)
1895 if ($spellID = $data['spell_'.$i])
1896 echo '<a class=spell href="?spell='.$spellID.'">('.$data['count_'.$i].') '.get_spell_details($spellID).'</a><br>';
1898 function r_setClass($data){}
1899 function r_setLevel($data){}
1901 $itemset_report = array(
1902 'SET_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['set_id'], 'draw'=>'r_setId', 'sort_str'=>'`id`', 'fields'=>''),
1903 'SET_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['set_name'], 'draw'=>'r_setName', 'sort_str'=>'`name`','fields'=>''),
1904 'SET_REPORT_ITEM' =>array('class'=>'iset', 'sort'=>'', 'text'=>$lang['set_items'], 'draw'=>'r_setItems', 'sort_str'=>'', 'fields'=>''),
1905 'SET_REPORT_SPELL'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['set_spells'],'draw'=>'r_setSpells','sort_str'=>'', 'fields'=>''),
1906 // Not supported yet
1907 'SET_REPORT_CLASS'=>array('class'=>'', 'sort'=>'class','text'=>$lang['set_class'], 'draw'=>'r_setClass', 'sort_str'=>'', 'fields'=>''),
1908 'SET_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'level','text'=>$lang['set_level'], 'draw'=>'r_setLevel', 'sort_str'=>'', 'fields'=>''),
1911 class ItemSetReportGenerator extends ReportGenerator{
1912 // Database depend requirest generator
1913 // Select only reuire for report fields from database
1914 function ItemSetReportGenerator($type='')
1916 global $itemset_report, $wDB;
1917 $this->db = &$wDB;
1918 $this->column_conf =&$itemset_report;
1919 $this->table = '`wowd_itemset`';
1920 $this->db_fields = '*';
1922 function useSpell($entry)
1924 $this->doRequirest(
1925 '`spell_1` = ?d OR `spell_2` = ?d OR `spell_3` = ?d OR `spell_4` = ?d OR
1926 `spell_5` = ?d OR `spell_6` = ?d OR `spell_7` = ?d OR `spell_8` = ?d', $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1930 //=================================================================
1931 // Faction list report functions and methods
1932 //=================================================================
1933 function r_factionId($data) {echo $data['id'];}
1934 function r_factionName($data) {echo '<a href="?faction='.$data['id'].'">'.$data['name'].'</a>';}
1935 function r_factionDetail($data){echo $data['details'];}
1937 $faction_report = array(
1938 'FACTION_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['faction_id' ], 'draw'=>'r_factionId', 'sort_str'=>'', 'fields'=>'' ),
1939 'FACTION_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['faction_name'], 'draw'=>'r_factionName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1940 'FACTION_REPORT_DETAILS' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['faction_details'],'draw'=>'r_factionDetail','sort_str'=>'', 'fields'=>'`details`'),
1943 class FactionReportGenerator extends ReportGenerator{
1944 // Database depend requirest generator
1945 // Select only reuire for report fields from database
1946 function FactionReportGenerator($type='')
1948 global $faction_report, $wDB;
1949 $this->db = &$wDB;
1950 $this->column_conf =&$faction_report;
1951 $this->table = '`wowd_faction`';
1952 $this->db_fields = '`id`';
1956 //=================================================================
1957 // Enchants list report functions and methods
1958 //=================================================================
1959 function r_enchId($data) {echo $data['id'];}
1960 function r_enchName($data) {echo '<a href="?enchant='.$data['id'].'">'.$data['description'].'</a>';}
1961 function r_enchGem($data) { if ($data['GemID']) echo text_show_item($data['GemID']);}
1962 $enchants_report = array(
1963 'ENCH_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['enchant_id'], 'draw'=>'r_enchId', 'sort_str'=>'`id`', 'fields'=>''),
1964 'ENCH_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['enchant_name'],'draw'=>'r_enchName', 'sort_str'=>'`description`','fields'=>'`description`'),
1965 'ENCH_REPORT_GEM' =>array('class'=>'small','sort'=>'', 'text'=>'', 'draw'=>'r_enchGem', 'sort_str'=>'', 'fields'=>'`GemID`'),
1968 class EnchantReportGenerator extends ReportGenerator{
1969 // Database depend requirest generator
1970 // Select only reuire for report fields from database
1971 function EnchantReportGenerator($type='')
1973 global $enchants_report, $wDB;
1974 $this->db = &$wDB;
1975 $this->column_conf =&$enchants_report;
1976 $this->table = '`wowd_item_enchantment`';
1977 $this->db_fields = '`id`';
1979 function useSpell($entry)
1981 $this->doRequirest('`spellid_1` = ?d OR `spellid_2` = ?d OR `spellid_3` = ?d', $entry, $entry, $entry);
1982 $this->removeIfAllZero('GemID', 'ENCH_REPORT_GEM');
1986 //=================================================================
1987 // Talents list report functions and methods
1988 //=================================================================
1989 function r_talentId($data) {echo $data['TalentTab'];}
1990 function r_talentName($data) {echo getTalentName($data['TalentTab']);}
1991 $talent_report = array(
1992 'TALENT_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['talent_id'], 'draw'=>'r_talentId', 'sort_str'=>'', 'fields'=>'`TalentTab`'),
1993 'TALENT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['talent_name'],'draw'=>'r_talentName', 'sort_str'=>'','fields'=>'`TalentTab`'),
1996 class TalentReportGenerator extends ReportGenerator{
1997 // Database depend requirest generator
1998 // Select only reuire for report fields from database
1999 function TalentReportGenerator($type='')
2001 global $talent_report, $wDB;
2002 $this->db = &$wDB;
2003 $this->column_conf =&$talent_report;
2004 $this->table = '`wowd_talents`';
2005 $this->db_fields = '`TalentID`';
2007 function useSpell($entry)
2009 $this->doRequirest('`Rank_1` = ?d OR `Rank_2` = ?d OR `Rank_3` = ?d OR `Rank_4` = ?d OR `Rank_5` = ?d', $entry, $entry, $entry, $entry, $entry);
2012 //=================================================================
2013 // Zones list report functions and methods
2014 //=================================================================
2015 function r_zoneId($data) {echo $data['id'];}
2016 function r_zoneName($data) {echo '<a href="?zone='.$data['id'].'">'.$data['name'].'</a>';}
2017 $zone_report = array(
2018 'ZONE_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['zone_id'], 'draw'=>'r_zoneId', 'sort_str'=>'`id`', 'fields'=>''),
2019 'ZONE_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['zone_name'],'draw'=>'r_zoneName', 'sort_str'=>'`name`','fields'=>'`name`'),
2022 class ZoneReportGenerator extends ReportGenerator{
2023 function ZoneReportGenerator($type='')
2025 global $zone_report, $wDB;
2026 $this->db = &$wDB;
2027 $this->column_conf =&$zone_report;
2028 $this->table = '`wowd_zones`';
2029 $this->db_fields = '`id`';
2031 function parentZone($entry)
2033 $this->doRequirest('`id` = ?d', $entry);
2035 function subZones($entry)
2037 $this->doRequirest('`zone_id` = ?d', $entry);
2041 //=================================================================
2042 // Areatrigger teleport list report functions and methods
2043 //=================================================================
2044 function r_atId($data) {echo $data['id'];}
2045 function r_atName($data) {echo $data['name'];}
2046 function r_atReq($data)
2048 global $lang;
2049 if ($data['required_level'])
2050 echo 'Req level: '.$data['required_level'].'<br>';
2052 if ($data['required_item'] OR $data['required_item2'])
2054 echo 'Req items:<br>';
2055 if ($data['required_item']) echo text_show_item($data['required_item'], 0, 'quest');
2056 if ($data['required_item2']) echo $lang['item_sel_and'].text_show_item($data['required_item2'], 0, 'quest');
2057 echo '<br>';
2059 if ($data['heroic_key'] OR $data['heroic_key2'])
2061 echo 'Heroic key:<br>';
2062 if ($data['heroic_key']) echo text_show_item($data['heroic_key'], 0, 'quest');
2063 if ($data['heroic_key2']) echo $lang['item_sel_and'].text_show_item($data['heroic_key2'], 0, 'quest');
2064 echo '<br>';
2068 $at_report = array(
2069 'AT_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['at_id'], 'draw'=>'r_atId', 'sort_str'=>'`id`', 'fields'=>''),
2070 'AT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['at_name'],'draw'=>'r_atName', 'sort_str'=>'`name`','fields'=>'`name`'),
2071 'AT_REPORT_REQ' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['at_req'], 'draw'=>'r_atReq', 'sort_str'=>'', 'fields'=>'`required_level`, `required_item`, `required_item2`, `heroic_key`, `heroic_key2`, `required_quest_done`, `required_quest_done_heroic`'),
2074 class AreaTriggerReportGenerator extends ReportGenerator{
2075 function AreaTriggerReportGenerator($type='')
2077 global $at_report, $wDB;
2078 $this->db = &$wDB;
2079 $this->column_conf =&$at_report;
2080 $this->table = '`areatrigger_teleport`';
2081 $this->db_fields = '*';
2083 function onMap($entry)
2085 $this->doRequirest('`target_map` = ?d', $entry);
2087 function onArea($area_data)
2089 $this->doRequirest('`target_map` = ?d AND `target_position_x` > ?d AND `target_position_x` < ?d AND `target_position_y` > ?d AND `target_position_y` < ?d', $area_data[0], $area_data[5], $area_data[4], $area_data[3], $area_data[2]);
2093 //=================================================================
2094 // Players list report functions and methods
2095 //=================================================================
2096 function r_plGUID($data) {echo $data['guid'];}
2097 function r_plName($data) {echo '<a href=?player='.$data['guid'].'>'.$data['name'].'</a>';}
2098 function r_plRace($data) {echo '<img src="'.getRaceImage($data['race'],$data['gender']).'">';}
2099 function r_plClass($data) {echo '<img src="'.getClassImage($data['class']).'">';}
2100 function r_plFaction($data){echo '<img src="'.getFactionImage($data['race']).'">';}
2101 function r_plLevel($data) {echo $data['level'];}
2102 function r_plPos($data)
2104 global $config;
2105 $map_name = getMapNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2106 $area_name = getAreaNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2107 $extra_name = "";
2108 if ($area_name)
2110 $extra_name = "<br><font size=-2>".$map_name."</font>";
2111 $map_name = "&bdquo;".str_replace(' ','&nbsp;', $area_name)."&ldquo;";
2113 else
2114 $map_name = "&bdquo;".str_replace(' ','&nbsp;',$map_name)."&ldquo;";
2116 if ($config['show_map_ptr'])
2117 $map_name = "<a href=\"?map&point=$data[map]:$data[position_x]:$data[position_y]:$data[position_z]\">".$map_name."</a>";
2118 echo $map_name.$extra_name;
2120 function r_plGuildNote($data) {echo $data['pnote']."<br>".$data['offnote'];}
2121 function r_plGuildRank($data)
2123 // Получаем названия рангов в гильдии
2124 $rank = getGuildRankList($data['guildid']);
2125 echo @$rank[$data['rank']]['rname'];
2128 function r_plItem($data){show_item_by_data(explode(' ',$data['item_data']));}
2130 $pl_report = array(
2131 'PL_REPORT_GUID' =>array('class'=>'small', 'sort'=>'id', 'text'=>$lang['pl_guid'], 'draw'=>'r_plGUID', 'sort_str'=>'`id`', 'fields'=>''),
2132 'PL_REPORT_NAME' =>array('class'=>'player','sort'=>'name', 'text'=>$lang['pl_name'], 'draw'=>'r_plName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
2133 'PL_REPORT_RACE' =>array('class'=>'i_ico', 'sort'=>'race', 'text'=>$lang['pl_race'], 'draw'=>'r_plRace', 'sort_str'=>'`race`', 'fields'=>'`race`, `gender`'),
2134 'PL_REPORT_CLASS' =>array('class'=>'i_ico', 'sort'=>'class', 'text'=>$lang['pl_class'], 'draw'=>'r_plClass', 'sort_str'=>'`class`', 'fields'=>'`class`'),
2135 'PL_REPORT_FACTION'=>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plFaction','sort_str'=>'', 'fields'=>'`race`'),
2136 'PL_REPORT_LEVEL' =>array('class'=>'small', 'sort'=>'level', 'text'=>$lang['pl_level'], 'draw'=>'r_plLevel', 'sort_str'=>'`level` DESC','fields'=>'`level`'),
2137 'PL_REPORT_POS' =>array('class'=>'zone', 'sort'=>'level', 'text'=>$lang['pl_pos'], 'draw'=>'r_plPos', 'sort_str'=>'', 'fields'=>'`map`, `position_x`, `position_y`, `position_z`'),
2138 // Guild member info
2139 'PL_REPORT_NOTE' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['pl_note'], 'draw'=>'r_plGuildNote','sort_str'=>'', 'fields'=>'`pnote`, `offnote`'),
2140 'PL_REPORT_GRANK' =>array('class'=>'rank', 'sort'=>'rank', 'text'=>$lang['pl_rank'], 'draw'=>'r_plGuildRank','sort_str'=>'`rank`', 'fields'=>'`guildid`,`rank`'),
2141 // Item owner
2142 'PL_REPORT_ITEM' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plItem' ,'sort_str'=>'', 'fields'=>'`item_instance`.`data` AS `item_data`'),
2145 class PlayerReportGenerator extends ReportGenerator{
2146 function PlayerReportGenerator($type='')
2148 global $pl_report, $cDB;
2149 $this->db = &$cDB;
2150 $this->column_conf =&$pl_report;
2151 switch ($type){
2152 case 'guild': $this->table = '(`characters` join `guild_member` ON `guild_member`.`guid` = `characters`.`guid`)';break;
2153 case 'item': $this->table = '(`characters` join `item_instance` ON `characters`.`guid` = `item_instance`.`owner_guid`)';break;
2154 default: $this->table = '`characters`';break;
2157 $this->db_fields = '`characters`.`guid`';
2159 function online()
2161 $this->doRequirest('`online` <> 0 AND NOT `extra_flags`&'.PLAYER_EXTRA_GM_INVISIBLE);
2163 // Select guild members by guild guid
2164 function guildMembers($gguid)
2166 $this->doRequirest('`guildid` = ?d', $gguid);
2168 function itemOwner($id)
2170 $this->doRequirest("(SUBSTRING_INDEX( SUBSTRING_INDEX(`item_instance`.`data` , ' ' , ?d) , ' ' , -1 )+0) = ?d", ITEM_FIELD_ENTRY + 1, $id);