Для cmangos 12843+, перенос почты для заданий.
[cswow.git] / include / report_generator.php
blob7dd8215c9593c5e3ca7374768538b7763bf8066f
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`, `condition_id` 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 `DifficultyEntry1` AS ARRAY_KEY, `Entry` FROM `creature_template` WHERE `DifficultyEntry1` <> 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 `DifficultyEntry2` AS ARRAY_KEY, `Entry` FROM `creature_template` WHERE `DifficultyEntry2` <> 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 `DifficultyEntry3` AS ARRAY_KEY, `Entry` FROM `creature_template` WHERE `DifficultyEntry3` <> 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 $lootcondition=getConditionItem($data['condition_id']);
372 if ($lootcondition)
373 foreach ($lootcondition as $type)
375 switch ($type['type']){
376 case 1: // CONDITION_AURA - spell_id, effindex
377 $spell = getSpell($type['value1'], '`id`, `SpellIconID`');
378 echo $lang['condition1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');
379 break;
380 case 2: // CONDITION_ITEM - item_id, count
381 $item = getItem($type['value1'], '`entry`, `displayid`');
382 echo $lang['condition2'].text_show_item($item['entry'], $item['displayid'], 'quest');
383 if ($type['value2'] > 1) echo 'x'.$type['value2'];
384 break;
385 case 3: // CONDITION_ITEM_EQUIPPED - item_id, 0
386 $item = getItem($type['value1'], '`entry`, `displayid`');
387 echo $lang['condition3'].text_show_item($item['entry'], $item['displayid'], 'quest');
388 break;
389 case 4: // CONDITION_AREAID - area_id 0, 1 (0: in (sub)area, 1: not in (sub)area)
390 if ($type['value2'] > 0 ) echo $lang['condition4_1'].getAreaName($type['value1']);
391 if ($type['value2'] == 0) echo getAreaName($type['value1']);
392 break;
393 case 5: // CONDITION_REPUTATION_RANK_MIN - faction_id, min_rank
394 echo getFactionName($type['value1']).'=>('.getReputationRankName($type['value2']).')';
395 break;
396 case 6: // CONDITION_TEAM player_team, 0 (469 - Alliance 67 - Horde)
397 echo getFactionName($type['value1']);
398 break;
399 case 7: // CONDITION_SKILL skill_id, skill_value
400 echo $lang['condition7'].getSkillName($type['value1']);
401 if ($type['value2'] > 1) echo ' ('.$type['value2'].')';
402 break;
403 case 8: // CONDITION_QUESTREWARDED quest_id, 0
404 echo $lang['condition8'].getQuestName($type['value1']);
405 break;
406 case 9: // CONDITION_QUESTTAKEN quest_id 0, for condition true while quest active.
407 echo $lang['condition9'].getQuestName($type['value1']);
408 break;
409 case 10: // CONDITION_AD_COMMISSION_AURA 0, 0 for condition true while one from AD сommission aura active
410 echo $lang['condition10'];
411 break;
412 case 11: // CONDITION_NO_AURA spell_id, effindex
413 $spell = getSpell($type['value1'], '`id`, `SpellIconID`');
414 echo $lang['condition11']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');
415 break;
416 case 12: // CONDITION_ACTIVE_GAME_EVENT event_id
417 echo $lang['condition12'].getGameEventName($type['value1']);
418 break;
419 case 13: // CONDITION_AREA_FLAG area_flag area_flag_not
420 if ($type['value1'] > 0) echo $lang['condition13_1'].$type['value1'];
421 if ($type['value2'] > 0) echo $lang['condition13_2'].$type['value2'];
422 break;
423 case 14: // CONDITION_RACE_CLASS race_mask class_mask
424 if ($type['value1'] > 0) echo getAllowableRace($type['value1']).'<br>';
425 if ($type['value2'] > 0) echo getAllowableClass($type['value2']);
426 break;
427 case 15: // CONDITION_LEVEL player_level 0, 1 or 2
428 if ($type['value1'] > 0) echo $type['value1'];
429 if (($type['value1'] > 0) && ($type['value2'] == 0)) echo $lang['condition15_1'];
430 if (($type['value1'] > 0) && ($type['value2'] == 1)) echo $lang['condition15_2'];
431 if (($type['value1'] > 0) && ($type['value2'] == 2)) echo $lang['condition15_3'];
432 break;
433 case 16: // CONDITION_NOITEM item_id count
434 $item = getItem($type['value1'], '`entry`, `displayid`');
435 echo $lang['condition16'].text_show_item($item['entry'], $item['displayid'], 'quest');
436 if ($type['value1'] > 1) echo 'x'.$type['value2'];
437 break;
438 case 17: // CONDITION_SPELL spell_id 0, 1 (0: has spell, 1: hasn't spell)
439 $spell = getSpell($type['value1'], '`id`, `SpellIconID`');
440 if ($type['value2'] > 0) { echo $lang['condition17_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
441 else { echo $lang['condition17_2']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
442 break;
443 case 18: // CONDITION_INSTANCE_SCRIPT instance_condition_id 0, 1, 2, 3, 4
444 if ($type['value1'] == 0) echo $lang['condition18_0'];
445 if ($type['value1'] == 1) echo $lang['condition18_1'];
446 if ($type['value1'] == 2) echo $lang['condition18_2'];
447 if ($type['value1'] == 3) echo $lang['condition18_3'];
448 if ($type['value1'] == 4) echo $lang['condition18_4'];
449 break;
450 case 20: // CONDITION_ACHIEVEMENT ach_id 0, 1 (0: has achievement, 1: hasn't achievement) for player
451 if ($type['value2'] > 0) echo $lang['condition20_1'].$type['value1'];
452 else echo $lang['condition20_2'].$type['value1'];
453 break;
454 case 22: // CONDITION_QUEST_NONE quest_id
455 if ($type['value1'] > 0) echo $lang['condition22'].getQuestName($type['value1']);
456 break;
457 case 23: // CONDITION_ITEM_WITH_BANK- item_id, count
458 $item = getItem($type['value1'], '`entry`, `displayid`');
459 echo $lang['condition23'].text_show_item($item['entry'], $item['displayid'], 'quest');
460 if ($type['value2'] > 1) echo 'x'.$type['value2'];
461 break;
462 case 24: // NOITEM_WITH_BANK item_id count
463 $item = getItem($type['value1'], '`entry`, `displayid`');
464 echo $lang['condition24'].text_show_item($item['entry'], $item['displayid'], 'quest');
465 if ($type['value1'] > 1) echo 'x'.$type['value2'];
466 break;
467 case 25: // CONDITION_NOT_ACTIVE_GAME_EVENT event_id
468 echo $lang['condition25'].getGameEventName($type['value1']);
469 break;
470 case 26: // CONDITION_ACTIVE_HOLIDAY holiday_id
471 echo $lang['condition26'].getGameHolidayName($type['value1']);
472 break;
473 case 27: // CONDITION_NOT_ACTIVE_HOLIDAY holiday_id
474 echo $lang['condition27'].getGameHolidayName($type['value1']);
475 break;
476 case 28: // CONDITION_LEARNABLE_ABILITY spell_id 0 or item_id
477 $spell = getSpell($type['value1'], '`id`, `SpellIconID`');
478 if ($type['value2'] > 0) { $item = getItem($type['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');}
479 else {echo $lang['condition28_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
480 break;
481 case 29: // CONDITION_SKILL_BELOW skill_id, skill_value
482 echo $lang['condition29'].getSkillName($type['value1']);
483 if ($type['value2'] > 1) echo ' ('.$type['value2'].')';
484 break;
485 case 30: // CONDITION_REPUTATION_RANK_MAX - faction_id, max_rank
486 echo getFactionName($type['value1']).'<=('.getReputationRankName($type['value2']).')';
487 break;
488 case 32: // CONDITION_SOURCE_AURA - spell_id, effindex
489 $spell = getSpell($type['value1'], '`id`, `SpellIconID`');
490 echo $lang['condition32']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');
491 break;
496 class LootReportGenerator extends ReportGenerator{
497 function LootReportGenerator($type='')
499 global $dDB;
500 $this->db = &$dDB;
501 $this->db_fields = '*';
502 switch ($type){
503 default: $this->table = '`creature_loot_template`'; break;
506 function loadSubList($lootId, $table)
508 $fields= $this->db_fields;
509 $rows = $this->db->select("SELECT $fields FROM $table
510 WHERE `entry` = ?d
511 GROUP BY IF (`mincountOrRef` < 0, `mincountOrRef`, `item`)
512 ORDER BY `groupid`, `ChanceOrQuestChance`>0, ABS(`ChanceOrQuestChance`) DESC", $lootId);
513 if (!$rows)
514 return 0;
515 foreach($rows as &$loot)
517 // Group chance
518 if ($loot['ChanceOrQuestChance'] == 0)
520 $group = $loot['groupid'];
521 $chance = 0; $n = 0;
522 foreach($rows as &$g)
523 if ($g['groupid'] == $group)
525 if ($g['ChanceOrQuestChance']>0) $chance+=$g['ChanceOrQuestChance'];
526 else $n++;
528 $chance = round((100 - $chance) / $n, 3);
529 foreach($rows as &$g)
530 if ($g['groupid'] == $group && $g['ChanceOrQuestChance']==0)
531 $g['ChanceOrQuestChance'] =$chance;
533 if ($loot['mincountOrRef'] < 0)
535 // Получаем список
536 $loot['item'] = $this->loadSubList(-$loot['mincountOrRef'], 'reference_loot_template');
537 $loot['maxcount'] = $this->db->selectCell("SELECT `maxcount` FROM $table WHERE `entry` = ?d AND `mincountOrRef` = ?d", $lootId, $loot['mincountOrRef']);
540 return $rows;
542 function getLootList($lootId)
544 $this->total_data = 0;
545 $this->data_array = $this->loadSubList($lootId, $this->table);
547 function renderSubList($lootList)
549 global $Quality, $lang;
550 if (!$lootList)
551 return;
552 $curloot = -1;
553 foreach ($lootList as $loot)
555 $gtext = "";
556 if ($loot['groupid']!=$curloot)
558 echo "<tr><th colspan = 4>$lang[kill_kredit_group]&nbsp;$loot[groupid]</th></tr>";
559 $curloot = $loot['groupid'];
561 echo "<tr>";
562 if ($loot['mincountOrRef'] > 0)
564 if ($item = getItem($loot['item'],"`entry`, `Quality`, `name`, `displayid`"))
566 echo '<td class=i_ico>';r_itemIcon($item);echo '</td>';
567 echo '<td class=left>';r_itemName($item);echo '</td>';
569 else
570 echo "<td>-</td><td>$lang[item_not_found]&nbsp;$loot[item]</td>";
572 else // Используется список вещей (падает только одна вещь из списка)
574 echo "<td>".$loot['maxcount']."x</td>";
575 echo "<td class=forsub>$gtext<table class=sublist><tbody>";
576 $this->renderSubList($loot['item']);
577 echo "</tbody></table></td>";
579 if ($loot['condition_id']){echo '<td>'; r_lootRequire($loot); echo '</td>';}
580 else echo '<td></td>';
581 if ($loot['ChanceOrQuestChance'] < 0) echo "<td align=center>Q".(-$loot['ChanceOrQuestChance'])."%</td>";
582 else if ($loot['ChanceOrQuestChance'] > 0) echo "<td align=center>".$loot['ChanceOrQuestChance']."%</td>";
583 echo "</tr>";
586 function createReport($header)
588 global $lang;
589 if (!$this->data_array)
590 return;
591 if ($this->ajax_mode==0)
592 echo '<div id="'.$this->mark.'">';
593 echo '<table class=report width=500>';
594 echo '<tbody>';
595 echo '<tr><td colspan=4 class=head>'.$header.'</td></tr>';
596 echo '<tr><th width=1%></th><th>'.$lang['item_name'].'</th><th></th><th>'.$lang['drop'].'%</th></tr>';
597 $this->renderSubList($this->data_array);
598 echo '</tbody></table>';
599 if ($this->ajax_mode==0)
601 echo '</div>';
602 // Cache data
603 $link = $this->createLink($this->page, $this->sort_method);
604 echo "<script type=\"text/javascript\">ajaxCacheHtmlId('$this->mark','$link');</script>";
609 //=================================================================
610 // Item report functions and methods
611 //=================================================================
612 function r_itemIcon($data) {echo text_show_item($data['entry'], $data['displayid']);}
613 function r_itemName($data)
615 global $Quality;
616 echo '<a class="'.$Quality[$data['Quality']].'" href="?item='.$data['entry'].'">'.(@$data['name_loc']?$data['name_loc']:$data['name']).'</a>';
618 function r_itemLevel($data) {echo $data['ItemLevel'];}
619 function r_itemReqLevel($data){echo $data['RequiredLevel'];}
620 function r_itemGemProp($data) {echo ($data['GemProperties']?getGemProperties($data['GemProperties']):'n/a');}
621 function r_itemArmor($data) {echo $data['armor'];}
622 function r_itemBlock($data) {echo $data['block'];}
623 function r_itemDPS($data) {echo $data['dps'] != 0 ? number_format($data['dps'], 2, '.', ''):'n/a';}
624 function r_itemAmmoDPS($data) {echo $data['adps'] != 0 ? number_format($data['adps'], 2, '.', ''):'n/a';}
625 function r_itemSpeed($data) {echo number_format($data['delay']/1000.00, 2, '.', '');}
626 function r_itemSlots($data) {echo $data['ContainerSlots'].' slot';}
627 function r_itemDesc($data) {echo (@$data['description_loc']?$data['description_loc']:$data['description']);}
628 function r_itemSClass($data) {echo getSubclassName($data['class'], $data['subclass'], 0);}
629 function r_itemInvType($data) {echo getInventoryType($data['InventoryType'], 0);}
630 function r_itemRecipe($data) {$ritem = getRecipeItem($data); echo ($ritem ? text_show_item($ritem['entry'], $ritem['displayid']):'-');}
631 function r_itemSpells($data)
633 global $UseorEquip;
634 for ($i=1;$i<=5;$i++)
636 if ($id = $data['spellid_'.$i])
637 if ($desc = get_spell_details($id))
638 echo '<a href="?spell='.$id.'">'.$UseorEquip[$data['spelltrigger_'.$i]].' '.$desc.'</a><br>';
641 function r_itemRepRank($data) {echo $data['RequiredReputationFaction']?getReputationRankName($data['RequiredReputationRank']):'n/a';}
642 function r_itemFlag($data) {echo dechex($data['Flags']);}
644 // Vendor
645 function r_vendorCost($data)
647 $flags2 = getItemFlags2($data['entry']);
648 if ($data['ExtendedCost']>0)
650 $cost = getExtendCost($data['ExtendedCost']);
651 if ($flags2&ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD)
652 echo money($data['BuyPrice']).''.r_excostCost($cost);
653 else
654 r_excostCost($cost);
656 else
657 echo money($data['BuyPrice']);
659 function r_vendorCount($data) {echo $data['sold_count']?$data['sold_count']:'∞';}
660 function r_vendorTime($data) {echo $data['incrtime']?getTimeText($data['incrtime']):'';}
662 // NPC report generator config
663 $item_report = array(
664 'ITEM_REPORT_ICON' =>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemIcon', 'sort_str'=>'', 'fields'=>'`displayid`' ),
665 'ITEM_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['item_name'], 'draw'=>'r_itemName', 'sort_str'=>'`name`', 'fields'=>'`Quality`, `name`'),
666 'ITEM_REPORT_LEVEL' =>array('class'=>'small','sort'=>'i_level', 'text'=>$lang['item_level'], 'draw'=>'r_itemLevel', 'sort_str'=>'`ItemLevel` DESC, `name`', 'fields'=>'`ItemLevel`' ),
667 'ITEM_REPORT_REQLEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['item_req_level'], 'draw'=>'r_itemReqLevel', 'sort_str'=>'`RequiredLevel` DESC, `name`', 'fields'=>'`RequiredLevel`' ),
668 'ITEM_REPORT_GEMPROPETY' =>array('class'=>'left', 'sort'=>'gem_prop','text'=>$lang['item_gem_details'],'draw'=>'r_itemGemProp', 'sort_str'=>'`GemProperties`', 'fields'=>'`GemProperties`'),
669 'ITEM_REPORT_ARMOR' =>array('class'=>'', 'sort'=>'armor', 'text'=>$lang['item_armor'], 'draw'=>'r_itemArmor', 'sort_str'=>'`armor` DESC', 'fields'=>'`armor`'),
670 'ITEM_REPORT_BLOCK' =>array('class'=>'', 'sort'=>'block', 'text'=>$lang['item_block'], 'draw'=>'r_itemBlock', 'sort_str'=>'`block` DESC', 'fields'=>'`block`'),
671 '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`'),
672 '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`'),
673 'ITEM_REPORT_SPEED' =>array('class'=>'', 'sort'=>'speed', 'text'=>$lang['item_speed'], 'draw'=>'r_itemSpeed', 'sort_str'=>'`delay` DESC', 'fields'=>'`delay`'),
674 'ITEM_REPORT_NUM_SLOTS' =>array('class'=>'', 'sort'=>'bag_slot','text'=>$lang['item_slot_num'], 'draw'=>'r_itemSlots', 'sort_str'=>'`ContainerSlots` DESC', 'fields'=>'`ContainerSlots`'),
675 'ITEM_REPORT_DESCRIPTION'=>array('class'=>'left', 'sort'=>'desc', 'text'=>$lang['item_desc'], 'draw'=>'r_itemDesc', 'sort_str'=>'`description` DESC', 'fields'=>'`description`'),
676 'ITEM_REPORT_SUBCLASS' =>array('class'=>'', 'sort'=>'subclass','text'=>$lang['item_type'], 'draw'=>'r_itemSClass', 'sort_str'=>'`subclass` DESC', 'fields'=>'`class`, `subclass`'),
677 'ITEM_REPORT_SLOTTYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['item_slot'], 'draw'=>'r_itemInvType', 'sort_str'=>'`InventoryType` DESC', 'fields'=>'`InventoryType`'),
678 'ITEM_REPORT_RECIPE_ITEM'=>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemRecipe', 'sort_str'=>'', 'fields'=>'`spellid_1`, `spellid_2`, `class`'),
679 '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`'),
680 'ITEM_REPORT_REQREP_RANK'=>array('class'=>'', 'sort'=>'rep_rank','text'=>$lang['item_faction_rank'],'draw'=>'r_itemRepRank', 'sort_str'=>'`RequiredReputationRank` DESC', 'fields'=>'`RequiredReputationFaction`, `RequiredReputationRank`'),
681 'ITEM_REPORT_FLAGS' =>array('class'=>'', 'sort'=>'', 'text'=>'flag', 'draw'=>'r_itemFlag', 'sort_str'=>'', 'fields'=>'`Flags`'),
682 // If set vendor class type
683 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCost', 'sort_str'=>'`ExtendedCost`, `BuyPrice`', 'fields'=>'`ExtendedCost`, `BuyPrice`'),
684 '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`'),
685 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `name`', 'fields'=>'`incrtime`'),
686 // If set loot class type
687 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
688 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
691 // Item localisation flags (for allow disable some fields localisation if need)
692 define('ITEM_LOCALE_NAME', 0x01);
693 define('ITEM_LOCALE_DESCRIPTION', 0x02);
694 define('ITEM_LOCALE_ALL', ITEM_LOCALE_NAME | ITEM_LOCALE_DESCRIPTION);
696 // Item report class
697 class ItemReportGenerator extends ReportGenerator{
698 var $dolocale = ITEM_LOCALE_ALL;
699 function ItemReportGenerator($type='')
701 global $item_report, $dDB;
702 $this->db = &$dDB;
703 $this->column_conf =&$item_report;
704 $this->db_fields = '`item_template`.`entry`';
705 switch ($type){
706 case 'vendor' : $this->table = '(`item_template` join `npc_vendor` ON `item_template`.`entry` = `npc_vendor`.`item`)'; break;
707 case 'loot': $this->table = '(`item_loot_template` right join `item_template` ON `item_template`.`entry` = `item_loot_template`.`entry`)'; break;
708 case 'disenchant':$this->table = '(`disenchant_loot_template` right join `item_template` ON `item_template`.`DisenchantID` = `disenchant_loot_template`.`entry`)'; break;
709 case 'milling': $this->table = '(`milling_loot_template` right join `item_template` ON `item_template`.`entry` = `milling_loot_template`.`entry`)'; break;
710 case 'prospect': $this->table = '(`prospecting_loot_template` right join `item_template` ON `item_template`.`entry` = `prospecting_loot_template`.`entry`)'; break;
711 default: $this->table = '`item_template`'; break;
714 function disableNameLocalisation() {$this->dolocale &= ~ITEM_LOCALE_NAME;}
715 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
717 $tables .= ' LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry`';
718 if ($this->dolocale & ITEM_LOCALE_NAME)
720 $fields = str_replace('`name`','`name`, `locales_item`.`name_loc'.$locale.'` AS `name_loc`', $fields);
721 $sort_str = str_replace('`name`', '`name_loc`, `name`', $sort_str);
723 if ($this->dolocale & ITEM_LOCALE_DESCRIPTION)
725 $fields = str_replace('`description`','`description`, `locales_item`.`description_loc'.$locale."` AS `description_loc`", $fields);
726 $sort_str = str_replace('`description` DESC', '`description_loc` DESC, `name` DESC', $sort_str);
729 function vendorItemList($entry)
731 $this->doRequirest('`npc_vendor`.`entry` = ?d', $entry);
732 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
733 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
735 function useSpell($entry)
737 $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);
739 function recipeSpell($entry)
741 $this->doRequirest('`spellid_1` = 483 AND `spellid_2` = ?d', $entry);
743 function socketBonus($entry)
745 $this->doRequirest('`SocketBonus` = ?d', $entry);
747 function enchantByGems($entry)
749 global $wDB;
750 if ($list = $wDB->selectCol("SELECT `id` FROM `wowd_gemproperties` WHERE `spellitemenchantement` = ?d", $entry))
751 $this->doRequirest('`GemProperties` IN (?a)', $list);
753 function requireReputation($entry)
755 $this->doRequirest('`RequiredReputationFaction` = ?d', $entry);
757 function lootItem($entry)
759 $ref_loot =& getRefrenceItemLoot($entry);
760 $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));
761 $this->removeIfAllZero('condition_id', 'LOOT_REPORT_REQ');
765 //=================================================================
766 // Spell trainer list report functions and methods
767 //=================================================================
768 function r_trainerCost($data) {echo money($data['spellcost']);}
769 function r_trainerSpell($data)
771 if ($spell = getSpell($data['spell']))
773 if (!r_spellCreate($spell))
774 r_spellIcon($spell);
777 function r_trainerNSpell($data)
779 if ($spell = getSpell($data['spell']))
781 echo getSpellName($spell);
784 function r_trainerSkill($data) {if ($data['reqskill']) echo getSkillName($data['reqskill']);}
785 function r_trainerValue($data) {if ($data['reqskill']) echo $data['reqskillvalue'];}
786 function r_trainerSkillReq($data){if ($data['reqskill']) echo getSkillName($data['reqskill']).' ('.$data['reqskillvalue'].')';}
787 function r_trainerLevel($data) {echo $data['reqlevel']?$data['reqlevel']:'';}
789 $train_report = array(
790 'TRAIN_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['trainer_level'], 'draw'=>'r_trainerLevel', 'sort_str'=>'`reqlevel`, `reqskillvalue`', 'fields'=>'`reqlevel`' ),
791 'TRAIN_REPORT_ICON' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_trainerSpell', 'sort_str'=>'', 'fields'=>'`spell`' ),
792 'TRAIN_REPORT_NAME' =>array('class'=>'left', 'sort'=>'spell', 'text'=>$lang['trainer_spell'], 'draw'=>'r_trainerNSpell', 'sort_str'=>'`spell`', 'fields'=>'`spell`' ),
793 'TRAIN_REPORT_COST' =>array('class'=>'cost', 'sort'=>'cost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
794 'TRAIN_REPORT_SKILL' =>array('class'=>'small','sort'=>'skill','text'=>$lang['trainer_skill'], 'draw'=>'r_trainerSkill', 'sort_str'=>'`reqskill`', 'fields'=>'`reqskill`' ),
795 'TRAIN_REPORT_VALUE' =>array('class'=>'small','sort'=>'value','text'=>$lang['trainer_value'], 'draw'=>'r_trainerValue', 'sort_str'=>'`reqskillvalue`','fields'=>'`reqskillvalue`'),
798 class NPCTrainerReportGenerator extends ReportGenerator{
799 // Database depend requirest generator
800 // Select only reuire for report fields from database
801 function NPCTrainerReportGenerator($type='')
803 global $train_report, $dDB;
804 $this->db = &$dDB;
805 $this->column_conf =&$train_report;
806 $this->table = '`npc_trainer`';
807 $this->db_fields = '`entry`';
809 function trainSpell($entry)
811 $this->doRequirest('`entry` = ?d', $entry);
812 $this->removeIfAllZero('reqlevel', 'TRAIN_REPORT_LEVEL');
813 $this->removeIfAllZero('reqskill', 'TRAIN_REPORT_SKILL');
814 $this->removeIfAllZero('reqskillvalue', 'TRAIN_REPORT_VALUE');
818 //=================================================================
819 // Creature list report functions and methods
820 //=================================================================
821 function r_npcLvl($data)
823 echo $data['MaxLevel'];
824 if ($data['Rank'])
825 echo '<br><div class=rank>'.getCreatureRank($data['Rank']).'</div>';
827 function r_npcName($data)
829 $h = getHeroicList();
830 $h1 = getHeroicList1();
831 $h2 = getHeroicList2();
832 if (isset($h[$data['Entry']]))
834 $heroic = getCreature($h[$data['Entry']]);
835 $data['Name']=$heroic['Name'].' (Difficulty1)';
836 $data['name_loc']=$heroic['Name'].' (Difficulty1)';
837 $data['SubName']=$heroic['SubName'];
839 if (isset($h1[$data['Entry']]))
841 $heroic = getCreature($h1[$data['Entry']]);
842 $data['Name']=$heroic['Name'].' (Difficulty2)';
843 $data['name_loc']=$heroic['Name'].' (Difficulty2)';
844 $data['SubName']=$heroic['SubName'];
846 if (isset($h2[$data['Entry']]))
848 $heroic = getCreature($h2[$data['Entry']]);
849 $data['Name']=$heroic['Name'].' (Difficulty3)';
850 $data['name_loc']=$heroic['Name'].' (Difficulty3)';
851 $data['SubName']=$heroic['SubName'];
853 $name = @$data['name_loc'] ? $data['name_loc'] : $data['Name'];
854 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['SubName'];
855 echo '<a href="?npc='.$data['Entry'].'">'.($name ? $name : 'no name').'</a>';
856 if ($subname)
857 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
859 function r_npcRName($data)
861 $h10 = getHeroicList();
862 $h11 = getHeroicList1();
863 $h12 = getHeroicList2();
864 if (isset($h10[$data['Entry']]))
866 $heroic = getCreature($h10[$data['Entry']]);
867 $data['Name']=$heroic['Name'].' (Difficulty1)';
868 $data['name_loc']=$heroic['Name'].' (Difficulty1)';
869 $data['SubName']=$heroic['SubName'];
871 if (isset($h11[$data['Entry']]))
873 $heroic = getCreature($h11[$data['Entry']]);
874 $data['Name']=$heroic['Name'].' (Difficulty2)';
875 $data['name_loc']=$heroic['Name'].' (Difficulty2)';
876 $data['SubName']=$heroic['SubName'];
878 if (isset($h12[$data['Entry']]))
880 $heroic = getCreature($h12[$data['Entry']]);
881 $data['Name']=$heroic['Name'].' (Difficulty3)';
882 $data['name_loc']=$heroic['Name'].' (Difficulty3)';
883 $data['SubName']=$heroic['SubName'];
885 $name = @$data['name_loc'] ? $data['name_loc'] : $data['Name'];
886 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['SubName'];
887 echo '<a href="?npc='.$data['Entry'].'">'.($name ? $name : 'no name').'</a> <font size=-3>('.getLoyality($data['FactionAlliance']).')</font>';
888 if ($subname)
889 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
891 function r_npcReact($data) {echo getLoyality($data['FactionAlliance']);}
892 function r_npcMap($data)
894 global $lang;
895 $h20 = getHeroicList();
896 $h21 = getHeroicList1();
897 $h22 = getHeroicList2();
899 if (isset($h22[$data['Entry']]))
900 echo '<a href="?map&npc='.$h22[$data['Entry']].'">'.$lang['show_map'].'&nbsp;('.getCreatureCount($h22[$data['Entry']]).')</a>';
901 else
902 if (isset($h21[$data['Entry']]))
903 echo '<a href="?map&npc='.$h21[$data['Entry']].'">'.$lang['show_map'].'&nbsp;('.getCreatureCount($h21[$data['Entry']]).')</a>';
904 else
905 if (isset($h20[$data['Entry']]))
906 echo '<a href="?map&npc='.$h20[$data['Entry']].'">'.$lang['show_map'].'&nbsp;('.getCreatureCount($h20[$data['Entry']]).')</a>';
907 else
908 echo '<a href="?map&npc='.$data['Entry'].'">'.$lang['show_map'].'&nbsp;('.getCreatureCount($data['Entry']).')</a>';
910 function r_npcRole($data)
912 $flag = $data['NpcFlags'];
913 if ($flag == 0) {return;}
914 if ($flag&0x00000001) echo '<img src=images/map_points/gossip_icon.png>';
915 if ($flag&0x00000002 && getNpcQuestrelation($data['Entry'])) echo '<img src=images/map_points/available_quest_icon.gif>';
916 if ($flag&0x00000002 && getNpcInvolvedrelation($data['Entry'])) echo '<img src=images/map_points/active_quest_icon.gif>';
917 if ($flag&0x00000070) echo '<img src=images/map_points/trainer_icon.gif>';
918 if ($flag&0x00000F80) echo '<img src=images/map_points/vendor_icon.gif>';
919 if ($flag&0x00001000) echo '<img src=images/map_points/repair.png>';
920 if ($flag&0x00002000) echo '<img src=images/map_points/taxi_icon.gif>';
921 if ($flag&0x00010000) echo '<img src=images/map_points/inn_icon.png>';
922 if ($flag&0x00820000) echo '<img src=images/map_points/banker_icon.gif>';
923 if ($flag&0x00100000) echo '<img src=images/map_points/battle_master_icon.gif>';
924 if ($flag&0x00200000) echo '<img src=images/map_points/banker_icon.gif>';
925 if ($flag&0x000C0000) echo '<img src=images/map_points/tabard_icon.gif>';
927 define('UNIT_NPC_FLAG_SPIRITHEALER', 0x00004000);
928 define('UNIT_NPC_FLAG_SPIRITGUIDE', 0x00008000);
929 define('UNIT_NPC_FLAG_STABLEMASTER', 0x00400000);*/
931 function r_OnKillRep($data)
933 $creature_rate1 = getCreatureRewRate($data['RewOnKillRepFaction1']);
934 $creature_rate2 = getCreatureRewRate($data['RewOnKillRepFaction2']);
935 if ($data['RewOnKillRepFaction1'])
937 echo ($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1.' '.getFactionName($data['RewOnKillRepFaction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
938 $spillover=getRepSpillover($data['RewOnKillRepFaction1']);
939 if ($spillover)
940 foreach ($spillover as $faction)
942 if ($faction['faction1'])
943 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
944 if ($faction['faction2'])
945 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding1']).')';
946 if ($faction['faction3'])
947 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding1']).')';
948 if ($faction['faction4'])
949 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding1']).')';
952 if ($data['RewOnKillRepFaction2'])
954 if ($data['RewOnKillRepFaction1'] == 0)
955 echo ($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
956 else
957 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
958 $spillover=getRepSpillover($data['RewOnKillRepFaction2']);
959 if ($spillover)
960 foreach ($spillover as $faction)
962 if ($faction['faction1'])
963 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding2']).')';
964 if ($faction['faction2'])
965 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
966 if ($faction['faction3'])
967 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding2']).')';
968 if ($faction['faction4'])
969 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding2']).')';
974 function r_vendorCostN($data)
976 $flags2 = getItemFlags2($data['Entry']);
977 if ($data['ExtendedCost']>0)
979 $cost = getExtendCost($data['ExtendedCost']);
980 if ($flags2&ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD)
981 echo money($data['BuyPrice']).''.r_excostCost($cost);
982 else
983 r_excostCost($cost);
985 else
986 echo money($data['BuyPrice']);
989 // NPC report generator config
990 $npc_report = array(
991 'NPC_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['creature_level'], 'draw'=>'r_npcLvl', 'sort_str'=>'`MaxLevel` DESC, `Name`', 'fields'=>'`MaxLevel`, `Rank`'),
992 '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`'),
993 'NPC_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcName', 'sort_str'=>'`Name`', 'fields'=>'`Name`, `SubName`'),
994 'NPC_REPORT_RNAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcRName','sort_str'=>'`Name`', 'fields'=>'`Name`, `SubName`, `FactionAlliance`'),
995 'NPC_REPORT_REACTION'=>array('class'=>'small','sort'=>'', 'text'=>$lang['creature_react'], 'draw'=>'r_npcReact','sort_str'=>'', 'fields'=>'`FactionAlliance`'),
996 'NPC_REPORT_ROLE' =>array('class'=>'', 'sort'=>'role', 'text'=>$lang['creature_role'], 'draw'=>'r_npcRole', 'sort_str'=>'`NpcFlags` DESC', 'fields'=>'`NpcFlags`'),
997 'NPC_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_npcMap', 'sort_str'=>'', 'fields'=>''),
998 // vendor
999 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCostN', 'sort_str'=>'`ExtendedCost`, `Name`', 'fields'=>'`ExtendedCost`'),
1000 '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`'),
1001 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `Name`', 'fields'=>'`incrtime`'),
1002 // trainer
1003 'TRAINER_REPORT_COST' =>array('class'=>'', 'sort'=>'scost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
1004 'TRAINER_REPORT_SPELL'=>array('class'=>'left','sort'=>'', 'text'=>$lang['trainer_spell'],'draw'=>'r_trainerSpell','sort_str'=>'', 'fields'=>'`spell`'),
1005 'TRAINER_REPORT_SKILL'=>array('class'=>'', 'sort'=>'skill', 'text'=>$lang['trainer_skill'],'draw'=>'r_trainerSkillReq','sort_str'=>'`reqskill`, `reqskillvalue`','fields'=>'`reqskill`, `reqskillvalue`'),
1006 'TRAINER_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'slevel','text'=>$lang['trainer_level'],'draw'=>'r_trainerLevel','sort_str'=>'`reqlevel`', 'fields'=>'`reqlevel`'),
1007 // loot
1008 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `Name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1009 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
1010 // reputation
1011 '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`'),
1014 define('NPC_LOCALE_NAME', 0x01);
1015 define('NPC_LOCALE_SUBNAME', 0x02);
1016 define('NPC_LOCALE_ALL', NPC_LOCALE_NAME | NPC_LOCALE_SUBNAME);
1018 // Creature report class
1019 class CreatureReportGenerator extends ReportGenerator{
1020 var $dolocale = NPC_LOCALE_ALL;
1021 function CreatureReportGenerator($type = '')
1023 global $npc_report, $dDB;
1024 $this->db = &$dDB;
1025 $this->column_conf =&$npc_report;
1026 $this->db_fields = '`creature_template`.`Entry`';
1027 switch ($type) {
1028 case 'vendor': $this->table = '(`creature_template` join `npc_vendor` ON `creature_template`.`Entry` = `npc_vendor`.`entry`)'; break;
1029 case 'trainer':$this->table = '(`creature_template` join `npc_trainer` ON `creature_template`.`Entry` = `npc_trainer`.`entry`)'; break;
1030 case 'loot': $this->table = '(`creature_template` join `creature_loot_template` ON `creature_template`.`LootId` = `creature_loot_template`.`entry`)'; break;
1031 case 'pick': $this->table = '(`creature_template` join `pickpocketing_loot_template` ON `creature_template`.`PickpocketLootId` = `pickpocketing_loot_template`.`entry`)'; break;
1032 case 'skin': $this->table = '(`creature_template` join `skinning_loot_template` ON `creature_template`.`SkinningLootId` = `skinning_loot_template`.`entry`)'; break;
1033 case 'position':$this->table ='(`creature_template` join `creature` ON `creature_template`.`Entry` = `creature`.`id`)'; break;
1034 case 'reputation':$this->table ='(`creature_template` join `creature_onkill_reputation` ON `creature_template`.`Entry` = `creature_onkill_reputation`.`creature_id`)'; break;
1035 default: $this->table = '`creature_template`'; break;
1038 function disableNameLocalisation() {$this->dolocale &= ~NPC_LOCALE_NAME;}
1039 function disableSubnameLocalisation() {$this->dolocale &= ~NPC_LOCALE_SUBNAME;}
1040 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1042 $tables.=' LEFT JOIN `locales_creature` ON `creature_template`.`Entry` = `locales_creature`.`entry`';
1043 if ($this->dolocale & NPC_LOCALE_NAME)
1045 $fields = str_replace('`Name`','`Name`, `locales_creature`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1046 $sort_str = str_replace('`Name`','`name_loc`, `Name`', $sort_str);
1048 if ($this->dolocale & NPC_LOCALE_SUBNAME)
1050 $fields = str_replace('`SubName`','`SubName`, `locales_creature`.`subname_loc'.$locale.'` AS `subname_loc`', $fields);
1051 $sort_str = str_replace('`SubName`','`subname_loc`, `SubName`', $sort_str);
1054 function castSpell($entry)
1056 global $dDB;
1057 $rows_1 = $dDB->selectCol('SELECT `entry` FROM `creature_template_spells` WHERE `spell1` = ?d OR `spell2` = ?d OR `spell3` = ?d OR `spell4` = ?d OR `spell5` = ?d OR `spell6` = ?d OR `spell7` = ?d OR `spell8` = ?d', $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1058 $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);
1059 $casters = array_unique(array_merge($rows_1, $rows_2));
1060 if (count($casters))
1061 $this->doRequirest('`creature_template`.`Entry` in (?a)', $casters);
1063 function inFaction($entry)
1065 global $wDB;
1066 if ($templatesId =& getFactionTemplates($entry))
1067 $this->doRequirest('`FactionAlliance` in (?a) OR `FactionHorde` in (?a)', $templatesId, $templatesId);
1069 function soldItem($entry, $price)
1071 $this->db_fields.=', '.$price.' AS `BuyPrice`';
1072 $this->doRequirest('`item` = ?d', $entry);
1073 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
1074 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
1076 function trainSpell($entry)
1078 $this->doRequirest('`spell` = ?d', $entry);
1079 $this->removeIfAllZero('reqskill', 'TRAINER_REPORT_SKILL');
1081 function kreditGroup($entry)
1083 $this->doRequirest('`KillCredit1` = ?d OR `KillCredit2` = ?d', $entry, $entry);
1085 function lootItem($entry)
1087 $ref_loot =& getRefrenceItemLoot($entry);
1088 $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));
1089 $this->removeIfAllZero('condition_id', 'LOOT_REPORT_REQ');
1091 // Position
1092 function onMap($entry)
1094 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1096 function onArea($area_data)
1098 $this->setManualPagenateMode();
1099 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1100 $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]);
1101 $setId = array();
1102 foreach($this->data_array as $id=>$c)
1104 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1105 if ($zone!=$area_data[1] || isset($setId[$c['Entry']]))
1106 unset($this->data_array[$id]);
1107 else
1108 $setId[$c['Entry']] = 1;
1111 // Reputation
1112 function rewardFactionReputation($id)
1114 $this->doRequirest('`RewOnKillRepFaction1` = ?d OR `RewOnKillRepFaction2` = ?d', $id, $id);
1116 function rewardNpcFactionReputation($entry)
1118 $this->doRequirest('`creature_id` = ?d', $entry);
1122 //=================================================================
1123 // Gameobject list report functions and methods
1124 //=================================================================
1125 function r_objName($data)
1127 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
1128 echo '<a href="?object='.$data['entry'].'">'.($name?$name:'no name').'</a>';
1130 function r_objType($data) {echo getGameobjectType($data['type'], 0);}
1131 function r_objMap($data) {global $lang; echo '<a href="?map&obj='.$data['entry'].'">'.$lang['show_map'].'&nbsp;('.getGameobjectCount($data['entry']).')</a>';}
1133 // GO report generator config
1134 $go_report = array(
1135 'GO_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['go_name'], 'draw'=>'r_objName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
1136 'GO_REPORT_TYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['go_type'], 'draw'=>'r_objType', 'sort_str'=>'`type`', 'fields'=>'`type`'),
1137 'GO_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_objMap', 'sort_str'=>'', 'fields'=>''),
1138 // loot
1139 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1140 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
1143 define('GO_LOCALE_NAME', 0x01);
1144 define('GO_LOCALE_ALL', NPC_LOCALE_NAME);
1146 // GO report class
1147 class GameobjectReportGenerator extends ReportGenerator{
1148 var $dolocale = GO_LOCALE_ALL;
1149 function GameobjectReportGenerator($type = '')
1151 global $go_report, $dDB;
1152 $this->db = &$dDB;
1153 $this->column_conf =&$go_report;
1154 $this->db_fields = '`gameobject_template`.`entry`';
1155 switch ($type) {
1156 case 'loot':
1157 $this->table =
1158 '(`gameobject_template`
1159 join
1160 `gameobject_loot_template`
1162 `gameobject_template`.`data1` = `gameobject_loot_template`.`entry` AND
1163 `gameobject_template`.`type` IN (3, 17, 25))';
1164 break;
1165 case 'position':$this->table ='(`gameobject_template` join `gameobject` ON `gameobject_template`.`entry` = `gameobject`.`id`)';break;
1166 default: $this->table = '`gameobject_template`';break;
1169 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1170 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1172 $tables.= ' LEFT JOIN `locales_gameobject` ON `gameobject_template`.`entry` = `locales_gameobject`.`entry`';
1173 if ($this->dolocale & GO_LOCALE_NAME)
1175 $fields = str_replace('`name`', '`name`, `locales_gameobject`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1176 $sort_str= str_replace('`name`', '`name_loc`, `name`', $sort_str);
1178 $fields = str_replace('`castbarcaption`','`castbarcaption`, `locales_gameobject`.`castbarcaption_loc'.$locale.'` AS `castbarcaption_loc`', $fields);
1180 function castSpell($entry)
1182 $this->doRequirest(
1183 '(`type` = ?d AND `data3` = ?d) OR
1184 (`type` = ?d AND `data10` = ?d) OR
1185 (`type` = ?d AND `data1` = ?d) OR
1186 (`type` = ?d AND `data0` = ?d) OR
1187 (`type` = ?d AND (`data2` = ?d OR `data3` = ?d))',
1188 GAMEOBJECT_TYPE_TRAP, $entry,
1189 GAMEOBJECT_TYPE_GOOBER, $entry,
1190 GAMEOBJECT_TYPE_SUMMONING_RITUAL, $entry,
1191 GAMEOBJECT_TYPE_SPELLCASTER, $entry,
1192 GAMEOBJECT_TYPE_AURA_GENERATOR, $entry, $entry);
1194 function inFaction($entry)
1196 global $wDB;
1197 if ($templatesId =& getFactionTemplates($entry))
1198 $this->doRequirest('`faction` in (?a)', $templatesId);
1200 function spellFocus($entry)
1202 $this->doRequirest('`type` = ?d AND `data0` = ?d', GAMEOBJECT_TYPE_SPELL_FOCUS, $entry);
1204 function lootItem($entry)
1206 $ref_loot =& getRefrenceItemLoot($entry);
1207 $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));
1208 $this->removeIfAllZero('condition_id', 'LOOT_REPORT_REQ');
1210 // Position
1211 function onMap($entry)
1213 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1215 function onArea($area_data)
1217 $this->setManualPagenateMode();
1218 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1219 $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]);
1220 $setId = array();
1221 foreach($this->data_array as $id=>$c)
1223 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1224 if ($zone!=$area_data[1] || isset($setId[$c['entry']]))
1225 unset($this->data_array[$id]);
1226 else
1227 $setId[$c['entry']] = 1;
1232 //=================================================================
1233 // Quest list report functions and methods
1234 //=================================================================
1235 function r_questLvl($data) {echo $data['QuestLevel']; if ($data['Type']) echo '<br><font size=-3><b>'.getQuestType($data['Type']).'</b></font>';}
1236 function r_questReqLvl($data) {echo $data['MinLevel'];}
1237 function r_questName($data)
1239 global $lang;
1240 $name = @$data['Title_loc']?$data['Title_loc']:$data['Title'];
1241 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 1101) && ($data['RequiredRaces'] !=1791))
1242 echo "<img width=22 height=22 src='images/player_info/factions_img/alliance.gif'>&nbsp;";
1243 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 690) && ($data['RequiredRaces'] !=1791))
1244 echo "<img width=22 height=22 src='images/player_info/factions_img/horde.gif'>&nbsp;";
1245 echo '<a href="?quest='.$data['entry'].'">'.($name?$name:'no name').'</a><br>';
1246 if ($data['ZoneOrSort']>0)
1247 echo '<div class=areaname><a href="?s=q&ZoneID='.$data['ZoneOrSort'].'">'.getAreaName($data['ZoneOrSort']).'</a></div>';
1248 else
1249 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
1250 (-$data['ZoneOrSort']) == 284 OR (-$data['ZoneOrSort']) == 25 OR (-$data['ZoneOrSort']) == 41 OR (-$data['ZoneOrSort']) < 24))
1251 echo '<div class=areaname><a href="?s=q&SortID='.(-$data['ZoneOrSort']).'">'.getQuestSort(-$data['ZoneOrSort']).'</a></div>';
1252 if ($data['RequiredClasses'])
1253 echo '<div class=classqname>'.getQAllowableClass($data['RequiredClasses']).'</div>';
1254 if ($data['RequiredSkill'])
1255 echo '<div class=areaname><a href="?s=q&SkillID='.($data['RequiredSkill']).'">'.getSkillName($data['RequiredSkill'], 0).'('.$data['RequiredSkillValue'].')</a></div>';
1256 if ($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY)
1257 echo '<div class=areaname><a href="?s=q&Sfm='.($data['SpecialFlags']).'">'.$lang['quest_type3'].'</a></div>';
1258 if ($data['QuestFlags'] & QUEST_FLAGS_WEEKLY)
1259 echo '<div class=areaname><a href="?s=q&Sfw='.($data['QuestFlags']).'">'.$lang['quest_type2'].'</a></div>';
1260 if ($data['QuestFlags'] & QUEST_FLAGS_DAILY)
1261 echo '<div class=areaname><a href="?s=q&Sfd='.($data['QuestFlags']).'">'.$lang['quest_type1'].'</a></div>';
1262 if (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_REPEATABLE) && (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY) ==0) && ($data['QuestFlags'] & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) == 0)
1263 echo '<div class=areaname><a href="?s=q&Sfr='.($data['SpecialFlags']).'">'.$lang['quest_type0'].'</a></div>';
1265 function r_questRelation($data)
1267 global $dDB;
1268 // Search creature quest giver
1269 if ($src = $dDB->select(
1270 'SELECT `Entry`, `Name`, `SubName`, `FactionAlliance`
1271 FROM `creature_template` left join `creature_questrelation` ON `creature_template`.`Entry` = `creature_questrelation`.`id`
1272 WHERE `creature_questrelation`.`quest` = ?d', $data['entry']))
1274 foreach ($src as $creature){localiseCreature($creature);r_npcRName($creature);}
1275 return;
1277 // Search GO quest giver
1278 if ($src = $dDB->select(
1279 'SELECT `entry`, `name`
1280 FROM `gameobject_template` left join `gameobject_questrelation` ON `gameobject_template`.`entry` = `gameobject_questrelation`.`id`
1281 WHERE `gameobject_questrelation`.`quest` = ?d', $data['entry']))
1283 foreach ($src as $go) {localiseGameobject($go); r_objName($go);}
1284 return;
1286 // Search item quest giver
1287 if ($src = $dDB->select("SELECT `entry`, `name`, `Quality` FROM `item_template` WHERE `startquest` = ?d", $data['entry']))
1289 foreach ($src as $item) {localiseItem($item);r_itemName($item);}
1290 return;
1292 echo '---(?)---';
1294 function r_questInvolvedrelation($data)
1296 global $dDB;
1297 // Search creature quest giver
1298 if ($src = $dDB->select(
1299 'SELECT `Entry`, `Name`, `SubName`, `FactionAlliance`
1300 FROM `creature_template` left join `creature_involvedrelation` ON `creature_template`.`Entry` = `creature_involvedrelation`.`id`
1301 WHERE `creature_involvedrelation`.`quest` = ?d', $data['entry']))
1303 foreach ($src as $creature){localiseCreature($creature);r_npcRName($creature);}
1304 return;
1306 // Search GO quest giver
1307 if ($src = $dDB->select(
1308 'SELECT `entry`, `name`
1309 FROM `gameobject_template` left join `gameobject_involvedrelation` ON `gameobject_template`.`entry` = `gameobject_involvedrelation`.`id`
1310 WHERE `gameobject_involvedrelation`.`quest` = ?d', $data['entry']))
1312 foreach ($src as $go) {localiseGameobject($go); r_objName($go);}
1313 return;
1315 echo '---(?)---';
1317 function r_questReward($quest)
1319 global $lang;
1320 if ($quest['RewItemId1'] OR $quest['RewItemId2'] OR $quest['RewItemId3'] OR $quest['RewItemId4'])
1322 // echo $lang['Rew_item'].'<br>';
1323 if ($quest['RewItemId1']) echo text_show_item($quest['RewItemId1'], 0, 'quest');
1324 if ($quest['RewItemId2']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId2'], 0, 'quest');
1325 if ($quest['RewItemId3']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId3'], 0, 'quest');
1326 if ($quest['RewItemId4']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId4'], 0, 'quest');
1327 echo '<br>';
1329 if ($quest['RewChoiceItemId1'] OR $quest['RewChoiceItemId2'] OR $quest['RewChoiceItemId3'] OR
1330 $quest['RewChoiceItemId4'] OR $quest['RewChoiceItemId5'] OR $quest['RewChoiceItemId6'])
1332 echo $lang['Rew_select_item'].'<br>';
1333 if ($quest['RewChoiceItemId1']) echo text_show_item($quest['RewChoiceItemId1'], 0, 'quest');
1334 if ($quest['RewChoiceItemId2']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId2'], 0, 'quest');
1335 if ($quest['RewChoiceItemId3']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId3'], 0, 'quest');
1336 if ($quest['RewChoiceItemId4']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId4'], 0, 'quest');
1337 if ($quest['RewChoiceItemId5']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId5'], 0, 'quest');
1338 if ($quest['RewChoiceItemId6']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId6'], 0, 'quest');
1339 echo "<br>";
1341 if ($quest['RewSpell'] AND $quest['RewSpellCast'])
1343 show_spell($quest['RewSpell'], 0, 'quest');
1344 echo '<br>';
1346 if (!$quest['RewSpell'] AND $quest['RewSpellCast'])
1348 show_spell($quest['RewSpellCast'], 0, 'quest');
1349 echo '<br>';
1351 for ($i = 1; $i <= 5; $i++)
1353 switch (ABS($quest['RewRepValueId'.$i])):
1354 case 1: $RepValueId[$i] = 10; break;
1355 case 2: $RepValueId[$i] = 25; break;
1356 case 3: $RepValueId[$i] = 75; break;
1357 case 4: $RepValueId[$i] = 150; break;
1358 case 5: $RepValueId[$i] = 250; break;
1359 case 6: $RepValueId[$i] = 350; break;
1360 case 7: $RepValueId[$i] = 500; break;
1361 case 8: $RepValueId[$i] = 1000; break;
1362 case 9: $RepValueId[$i] = 5; break;
1363 default: $RepValueId[$i] = 0;
1364 endswitch;
1366 $quest_rate[$i] = getRepRewRate($quest['RewRepFaction'.$i]);
1368 if ($quest['RewRepValueId'.$i] < 0)
1369 $RepValueId[$i] = -$RepValueId[$i];
1371 if ($quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1372 $quest['RewRepValue'.$i] = $quest['RewRepValue'.$i]/100;
1374 if (!$quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1375 $quest['RewRepValue'.$i] = $RepValueId[$i];
1377 $quest['RewRepValue'.$i]=$quest['RewRepValue'.$i]*$quest_rate[$i];
1380 if ($quest['RewRepFaction1'] AND !$quest['RewRepFaction2'] AND
1381 !$quest['RewRepFaction3'] AND !$quest['RewRepFaction4'] AND
1382 !$quest['RewRepFaction5'])
1384 $spillover=getRepSpillover($quest['RewRepFaction1']);
1385 if ($spillover)
1386 foreach ($spillover as $faction)
1388 if ($faction['faction1'])
1390 $quest['RewRepFaction2']=$faction['faction1'];
1391 $quest['RewRepValue2']=$quest['RewRepValue1']*$faction['rate_1'];
1393 if ($faction['faction2'])
1395 $quest['RewRepFaction3']=$faction['faction2'];
1396 $quest['RewRepValue3']=$quest['RewRepValue1']*$faction['rate_2'];
1398 if ($faction['faction3'])
1400 $quest['RewRepFaction4']=$faction['faction3'];
1401 $quest['RewRepValue4']=$quest['RewRepValue1']*$faction['rate_3'];
1403 if ($faction['faction4'])
1405 $quest['RewRepFaction5']=$faction['faction4'];
1406 $quest['RewRepValue5']=$quest['RewRepValue1']*$faction['rate_4'];
1411 if ($quest['RewRepFaction1'] && $quest['RewRepValue1'])echo getFactionName($quest['RewRepFaction1']).':&nbsp;'.$quest['RewRepValue1'].'<br>';
1412 if ($quest['RewRepFaction2'] && $quest['RewRepValue2'])echo getFactionName($quest['RewRepFaction2']).':&nbsp;'.$quest['RewRepValue2'].'<br>';
1413 if ($quest['RewRepFaction3'] && $quest['RewRepValue3'])echo getFactionName($quest['RewRepFaction3']).':&nbsp;'.$quest['RewRepValue3'].'<br>';
1414 if ($quest['RewRepFaction4'] && $quest['RewRepValue4'])echo getFactionName($quest['RewRepFaction4']).':&nbsp;'.$quest['RewRepValue4'].'<br>';
1415 if ($quest['RewRepFaction5'] && $quest['RewRepValue5'])echo getFactionName($quest['RewRepFaction5']).':&nbsp;'.$quest['RewRepValue5'].'<br>';
1416 if ($quest['RewMoneyMaxLevel'])
1417 echo $lang['Rew_XP'].' '.getQuestXPValue($quest).' xp<br>';
1418 if ($quest['RewOrReqMoney'])
1419 echo $lang['Rew_money'].' '.money($quest['RewOrReqMoney'], 7).'<br>';
1422 $quest_reward_fields =
1423 '`RewXPId`, `RewChoiceItemId1`, `RewChoiceItemId2`, `RewChoiceItemId3`, `RewChoiceItemId4`, `RewChoiceItemId5`, `RewChoiceItemId6`,
1424 `RewChoiceItemCount1`, `RewChoiceItemCount2`, `RewChoiceItemCount3`, `RewChoiceItemCount4`, `RewChoiceItemCount5`, `RewChoiceItemCount6`,
1425 `RewItemId1`, `RewItemId2`, `RewItemId3`, `RewItemId4`, `RewItemCount1`, `RewItemCount2`, `RewItemCount3`, `RewItemCount4`,
1426 `RewRepFaction1`, `RewRepFaction2`, `RewRepFaction3`, `RewRepFaction4`, `RewRepFaction5`,
1427 `RewRepValue1`, `RewRepValue2`, `RewRepValue3`, `RewRepValue4`, `RewRepValue5`,
1428 `RewRepValueId1`, `RewRepValueId2`, `RewRepValueId3`, `RewRepValueId4`, `RewRepValueId5`,
1429 `RewOrReqMoney`, `RewMoneyMaxLevel`, `RewSpell`, `RewSpellCast`, `RewMailTemplateId`, `RewMailDelaySecs`';
1431 $quest_report = array(
1432 'QUEST_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['quest_lvl'], 'draw'=>'r_questLvl', 'sort_str'=>'`QuestLevel` DESC', 'fields'=>'`QuestLevel`, `Type`'),
1433 'QUEST_REPORT_REQLEVEL'=>array('class'=>'small','sort'=>'req_lvl','text'=>$lang['quest_reqlvl'], 'draw'=>'r_questReqLvl','sort_str'=>'`MinLevel` DESC', 'fields'=>'`MinLevel`'),
1434 '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`'),
1435 'QUEST_REPORT_GIVER' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['quest_giver'], 'draw'=>'r_questRelation', 'sort_str'=>'', 'fields'=>''),
1436 'QUEST_REPORT_GIVER_END'=>array('class'=>'left', 'sort'=>'', 'text'=>$lang['quest_giver_end'], 'draw'=>'r_questInvolvedrelation', 'sort_str'=>'', 'fields'=>''),
1437 'QUEST_REPORT_REWARD' =>array('class'=>'full', 'sort'=>'reward', 'text'=>$lang['quest_rewards'], 'draw'=>'r_questReward','sort_str'=>'`RewMoneyMaxLevel` DESC','fields'=>&$quest_reward_fields),
1438 // loot
1439 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `Title`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1440 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
1443 define('QUEST_LOCALE_NAME', 0x01);
1444 define('QUEST_LOCALE_ALL', NPC_LOCALE_NAME);
1446 // Quest report class
1447 class QuestReportGenerator extends ReportGenerator{
1448 var $dolocale = QUEST_LOCALE_ALL;
1449 function QuestReportGenerator($type='')
1451 global $quest_report, $dDB;
1452 $this->db = &$dDB;
1453 $this->column_conf =&$quest_report;
1454 switch ($type){
1455 case 'go_giver': $this->table = '(`quest_template` join `gameobject_questrelation` ON `quest_template`.`entry` = `gameobject_questrelation`.`quest`)';break;
1456 case 'go_take': $this->table = '(`quest_template` join `gameobject_involvedrelation` ON `quest_template`.`entry` = `gameobject_involvedrelation`.`quest`)';break;
1457 case 'npc_giver': $this->table = '(`quest_template` join `creature_questrelation` ON `quest_template`.`entry` = `creature_questrelation`.`quest`)';break;
1458 case 'npc_take': $this->table = '(`quest_template` join `creature_involvedrelation` ON `quest_template`.`entry` = `creature_involvedrelation`.`quest`)';break;
1459 case 'mail_loot': $this->table = '(`quest_template` join `mail_loot_template` ON `quest_template`.`RewMailTemplateId` = `mail_loot_template`.`entry`)';break;
1460 default: $this->table = '`quest_template`';break;
1462 $this->db_fields = '`quest_template`.`entry`';
1464 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1465 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1467 $tables.= ' LEFT JOIN `locales_quest` ON `quest_template`.`entry` = `locales_quest`.`entry`';
1468 if ($this->dolocale & QUEST_LOCALE_NAME)
1470 $fields = str_replace('`Title`', '`Title`, `locales_quest`.`Title_loc'.$locale.'` AS `Title_loc`', $fields);
1471 $sort_str = str_replace('`Title`', '`Title_loc`, `Title`', $sort_str);
1474 // Create quest givers/take list by entry
1475 function getGiveTakeList($entry)
1477 $this->doRequirest('`id` = ?d', $entry);
1479 // Create quest list require GO for comlete
1480 function requireGO($entry)
1482 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', -$entry, -$entry, -$entry, -$entry);
1484 // Create quest list require GO for comlete
1485 function requireCreature($entry)
1487 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', $entry, $entry, $entry, $entry);
1489 function oneQuest($entry)
1491 $this->doRequirest('`quest_template`.`entry` = ?d', $entry);
1493 // Create quest list require item for comlete
1494 function requireItem($entry, $giveQuest)
1496 $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);
1498 // Create quest list prowide item at take
1499 function provideItem($entry, $giveQuest)
1501 $this->doRequirest('`SrcItemId` = ?d AND `quest_template`.`entry` <> ?d', $entry, $giveQuest);
1503 // Create quest list reward item
1504 function rewardItem($entry)
1506 $this->doRequirest('`RewItemId1`= ?d OR `RewItemId2`= ?d OR `RewItemId3`= ?d OR `RewItemId4`= ?d OR
1507 `RewChoiceItemId1`= ?d OR`RewChoiceItemId2`= ?d OR `RewChoiceItemId3`= ?d OR `RewChoiceItemId4`= ?d OR `RewChoiceItemId5`= ?d OR `RewChoiceItemId6`= ?d',
1508 $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1510 // Create quest list cast/reward spell
1511 function rewardSpell($entry)
1513 $this->doRequirest('`RewSpell` = ?d OR `RewSpellCast` = ?d', $entry, $entry);
1515 // Return quest list where exist faction reputation reward
1516 function rewardReputation($entry)
1518 $this->doRequirest('`RewRepFaction1`= ?d OR `RewRepFaction2`= ?d OR `RewRepFaction3`= ?d OR `RewRepFaction4`= ?d OR `RewRepFaction5`= ?d', $entry, $entry, $entry, $entry, $entry);
1520 // Mail loot
1521 function lootItem($entry)
1523 $ref_loot =& getRefrenceItemLoot($entry);
1524 $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));
1525 $this->removeIfAllZero('condition_id', 'LOOT_REPORT_REQ');
1530 //=================================================================
1531 // Spell list report functions and methods
1532 //=================================================================
1533 function r_spellLevel($data) {echo $data['spellLevel'];}
1534 function r_spellIcon($data) {show_spell($data['id'], $data['SpellIconID']);}
1535 function r_spellName($data)
1537 echo '<a href="?spell='.$data['id'].'">'.$data['SpellName'].'</a>';
1538 if ($data['Rank'])
1539 echo '<div class=srank>'.$data['Rank'].'</div>';
1541 function r_spellRecipe($data)
1543 r_spellName($data);
1544 if ($skilname = getSkillNameForSpell($data['id']))
1545 echo '<div class=srank>&lt;'.$skilname.'&gt;</div>';
1547 function r_spellSkill($data)
1549 global $lang;
1550 r_spellName($data);
1551 if ($data['RequiresSpellFocus'])
1552 echo '<div class=reqfocus>'.sprintf($lang['spell_req_focus'], getSpellFocusName($data['RequiresSpellFocus'], 2)).'</div>';
1553 if ($data['TotemCategory_1'] OR $data['TotemCategory_2'])
1555 $text= '';
1556 if ($data['TotemCategory_1']) $text = getTotemCategory($data['TotemCategory_1']);
1557 if ($data['TotemCategory_2']) $text.= ", ".getTotemCategory($data['TotemCategory_2']);
1558 echo '<div class=reqfocus>'.sprintf($lang['spell_req_totem'], $text).'</div>';
1561 function r_spellSchool($data){echo getSpellSchool($data['SchoolMask']);}
1562 function r_spellReagents($data)
1564 echo '<table class=reagents><tr>';
1565 for ($i=1;$i<9;$i++)
1566 if ($data['Reagent_'.$i])
1567 echo '<td>'.text_show_item($data['Reagent_'.$i],0,'reagent').'<br>x'.$data['ReagentCount_'.$i].'</td>';
1568 echo "</tr></table>";
1570 function r_spellCreate($data)
1572 if ($data['EffectItemType_1'] == 0 AND $data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1573 return 0;
1574 if ($data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1575 echo text_show_item($data['EffectItemType_1']);
1576 else
1578 echo '<table class=reagents><tr>';
1579 for ($i=1;$i<4;$i++)
1580 if ($data['EffectItemType_'.$i])
1581 echo '<td>'.text_show_item($data['EffectItemType_'.$i], 0, "reagent").($data['EffectBasePoints_'.$i]>0?'<br>x&nbsp;'.($data['EffectBasePoints_'.$i]+1):'').'</td>';
1582 echo '</tr></table>';
1584 return 1;
1586 function r_spellEquiped($data)
1588 echo $data['EquippedItemClass'].'<br />';
1589 echo $data['EquippedItemSubClassMask'].'<br />';
1590 echo $data['EquippedItemInventoryTypeMask'].'<br />';
1592 function r_skillLevel($data) {echo $data['min_value'];}
1593 function r_skillIcon($data)
1595 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1596 r_spellCreate($data);
1597 else
1598 r_spellIcon($data);
1600 $reagents= '`Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,
1601 `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, `ReagentCount_7`, `ReagentCount_8`';
1602 // Spell report generator config
1603 $spell_report = array(
1604 'SPELL_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['spell_level'], 'draw'=>'r_spellLevel', 'sort_str'=>'`spellLevel`', 'fields'=>'`spellLevel`'),
1605 'SPELL_REPORT_ICON' =>array('class'=>'s_ico','sort'=>'icon', 'text'=>'', 'draw'=>'r_spellIcon', 'sort_str'=>'`SpellIconID`', 'fields'=>'`SpellIconID`'),
1606 'SPELL_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['spell_name'], 'draw'=>'r_spellName', 'sort_str'=>'`SpellName`, `id`','fields'=>'`SpellName`, `Rank`'),
1607 '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`'),
1608 'SPELL_REPORT_SCHOOL'=>array('class'=>'', 'sort'=>'school','text'=>$lang['spell_school'], 'draw'=>'r_spellSchool', 'sort_str'=>'`SchoolMask`', 'fields'=>'`SchoolMask`'),
1609 'SPELL_REPORT_REAGENTS'=>array('class'=>'reag','sort'=>'', 'text'=>$lang['spell_reagent'],'draw'=>'r_spellReagents','sort_str'=>'', 'fields'=>&$reagents),
1610 '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`'),
1611 'SPELL_REPORT_EQUIP'=>array('class'=>'left', 'sort'=>'', 'text'=>'', 'draw'=>'r_spellEquiped','sort_str'=>'', 'fields'=>'`EquippedItemClass`, `EquippedItemSubClassMask`, `EquippedItemInventoryTypeMask`'),
1612 // Skill
1613 '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`'),
1614 '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`'),
1615 '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`'),
1618 // Spell report class
1619 class SpellReportGenerator extends ReportGenerator{
1620 function SpellReportGenerator($type='')
1622 global $spell_report, $wDB;
1623 $this->db = &$wDB;
1624 $this->column_conf =&$spell_report;
1625 switch ($type){
1626 case 'skill': $this->table = '(`wowd_spell` join `wowd_skill_line_ability` ON `wowd_skill_line_ability`.`spellId` =`wowd_spell`.`id`)';break;
1627 default: $this->table = '`wowd_spell`';break;
1629 $this->db_fields = '`wowd_spell`.`id`';
1631 function summonGO($entry)
1633 $effList = array(50, 76, 104, 105, 106, 107);
1634 $this->doRequirest(
1635 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1636 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1637 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1639 function summonCreature($entry)
1641 $effList = array(28, 56, 90, 93, 134);
1642 $this->doRequirest(
1643 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1644 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1645 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1647 // List of spells use item as reagent
1648 function useRegent($entry)
1650 $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);
1651 $create = 0;
1652 foreach($this->data_array as &$data)
1653 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1654 $create = 1;
1655 if (!$create) $this->removeField('SPELL_REPORT_CREATE');
1657 // List of spells create this item
1658 function createItem($entry)
1660 $eff_list = array(107, 108, 109, 112);
1661 $this->doRequirest(
1662 '(`EffectItemType_1` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1663 (`EffectItemType_2` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1664 (`EffectItemType_3` = ?d AND EffectApplyAuraName_1 NOT IN (?a))', $entry, $eff_list, $entry, $eff_list, $entry, $eff_list);
1666 // List os spells give faction reputation
1667 function giveReputation($entry)
1669 $this->doRequirest(
1670 '(`EffectMiscValue_1` = ?d AND `Effect_1` = 103) OR
1671 (`EffectMiscValue_2` = ?d AND `Effect_2` = 103) OR
1672 (`EffectMiscValue_3` = ?d AND `Effect_3` = 103)', $entry, $entry, $entry);
1674 function triggerFromSpells($entry)
1676 $this->doRequirest(
1677 '`EffectTriggerSpell_1` = ?d OR
1678 `EffectTriggerSpell_2` = ?d OR
1679 `EffectTriggerSpell_3` = ?d', $entry, $entry, $entry);
1681 function enchantFromSpells($entry)
1683 $effList = array(53, 54, 92);
1684 $this->doRequirest(
1685 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1686 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1687 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1689 function affectedBySpells($family, $maskA, $maskB, $maskC)
1691 $this->doRequirest(
1692 '`SpellFamilyName` = ?d AND
1694 (`EffectApplyAuraName_1` IN (107, 108) AND ( (`EffectSpellClassMaskA_1` & ?d) OR (`EffectSpellClassMaskA_2` & ?d) OR (`EffectSpellClassMaskA_3` & ?d) ) ) OR
1695 (`EffectApplyAuraName_2` IN (107, 108) AND ( (`EffectSpellClassMaskB_1` & ?d) OR (`EffectSpellClassMaskB_2` & ?d) OR (`EffectSpellClassMaskB_3` & ?d) ) ) OR
1696 (`EffectApplyAuraName_3` IN (107, 108) AND ( (`EffectSpellClassMaskC_1` & ?d) OR (`EffectSpellClassMaskC_2` & ?d) OR (`EffectSpellClassMaskC_3` & ?d) ) )
1697 )', $family, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC);
1699 function castByCreature($creature)
1701 global $wDB, $dDB;
1702 $spell_list = array();
1704 // By creature fields
1705 for ($i=1;$i<9;$i++)
1706 $spell_list = array_merge($spell_list, $dDB->selectCol('SELECT `spell'.$i.'` FROM `creature_template_spells` WHERE `entry` = ?d', $creature['Entry']));
1708 // By event AI table
1709 for ($i=1;$i<=3;$i++)
1710 $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']));
1712 if (count($spell_list))
1713 $this->doRequirest('`id` IN (?a)', array_unique($spell_list));
1715 function doSkillList($skill)
1717 if (isset($_REQUEST['guid']))
1719 $spells = getPlayerSpells($_REQUEST['guid']);
1720 $this->rowCallback = 'playerSpellCallback';
1722 $this->doRequirest('`skillId` = ?d', $skill);
1724 function lootItem($entry)
1726 global $dDB;
1727 $ref_loot =& getRefrenceItemLoot($entry);
1728 $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));
1729 if ($spells)
1730 $this->doRequirest('`id` IN (?a)', array_keys($spells));
1734 //=================================================================
1735 // Glyph list report functions and methods
1736 //=================================================================
1737 function r_glyphId($data) {echo $data['id'];}
1738 function r_glyphName($data) {$spell=getSpell($data['SpellId']); echo $spell['SpellName'];}
1739 function r_glyphIcon($data) {echo '<img src="'.getSpellIcon($data['iconId']).'">';}
1741 $glyph_report = array(
1742 'GLYPH_REPORT_ID' =>array('class'=>'small','sort'=>'','text'=>$lang['glyph_id' ], 'draw'=>'r_glyphId', 'sort_str'=>'', 'fields'=>''),
1743 'GLYPH_REPORT_NAME'=>array('class'=>'left', 'sort'=>'','text'=>$lang['glyph_name'], 'draw'=>'r_glyphName','sort_str'=>'', 'fields'=>'`SpellId`'),
1744 'GLYPH_REPORT_ICON'=>array('class'=>'i_ico','sort'=>'','text'=>'', 'draw'=>'r_glyphIcon','sort_str'=>'', 'fields'=>'`iconId`'),
1747 class GlyphReportGenerator extends ReportGenerator{
1748 // Database depend requirest generator
1749 // Select only reuire for report fields from database
1750 function GlyphReportGenerator($type='')
1752 global $glyph_report, $wDB;
1753 $this->db = &$wDB;
1754 $this->column_conf =&$glyph_report;
1755 $this->table = '`wowd_glyphproperties`';
1756 $this->db_fields = '`id`';
1758 function useSpell($entry)
1760 $this->doRequirest('`SpellId` = ?d', $entry);
1764 //=================================================================
1765 // Random Suffix list report functions and methods
1766 //=================================================================
1767 function r_rndSuffId($data) {echo $data['id'];}
1768 function r_rndSuffName($data) {echo '&nbsp;... '.$data['name'];}
1769 function r_rndSuffDetail($data)
1771 for ($j=1;$j<=3;$j++)
1772 if ($data['EnchantID_'.$j])
1773 echo str_ireplace('$i', round($data['Prefix_'.$j]/100, 2).'%', getEnchantmentDesc($data['EnchantID_'.$j]))."<br>";
1776 $rsuff_report = array(
1777 'RSUFF_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndSuffId', 'sort_str'=>'', 'fields'=>''),
1778 'RSUFF_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndSuffName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
1779 '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`'),
1782 class RandomSuffixReportGenerator extends ReportGenerator{
1783 // Database depend requirest generator
1784 // Select only reuire for report fields from database
1785 function RandomSuffixReportGenerator($type='')
1787 global $rsuff_report, $wDB;
1788 $this->db = &$wDB;
1789 $this->column_conf =&$rsuff_report;
1790 $this->table = '`wowd_item_random_suffix`';
1791 $this->db_fields = '`id`';
1793 function enchantFrom($entry)
1795 $this->doRequirest('`EnchantID_1` = ?d OR `EnchantID_2` = ?d OR `EnchantID_3` = ?d', $entry, $entry, $entry);
1799 //=================================================================
1800 // Random Suffix list report functions and methods
1801 //=================================================================
1802 function r_rndPropId($data) {echo $data['id'];}
1803 function r_rndPropName($data) {echo '&nbsp;... '.$data['name'];}
1804 function r_rndPropDetail($data)
1806 for ($j=1;$j<=5;$j++)
1807 if ($data['EnchantID_'.$j])
1808 echo getEnchantmentDesc($data['EnchantID_'.$j])."<br>";
1811 $rprop_report = array(
1812 'RPROP_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndPropId', 'sort_str'=>'', 'fields'=>''),
1813 'RPROP_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndPropName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
1814 '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`'),
1817 class RandomPropetyReportGenerator extends ReportGenerator{
1818 // Database depend requirest generator
1819 // Select only reuire for report fields from database
1820 function RandomPropetyReportGenerator($type='')
1822 global $rprop_report, $wDB;
1823 $this->db = &$wDB;
1824 $this->column_conf =&$rprop_report;
1825 $this->table = '`wowd_item_random_propety`';
1826 $this->db_fields = '`id`';
1828 function enchantFrom($entry)
1830 $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);
1834 //=================================================================
1835 // Lock list report functions and methods
1836 //=================================================================
1837 function r_LockId($data) {echo $data['id'];}
1838 function r_LockKeys($data)
1840 for ($i=0;$i<8;$i++)
1842 switch ($data['keytype_'.$i]){
1843 case 0: continue;
1844 case 1: echo text_show_item($data['key_'.$i], 0, 'cost').($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1845 case 2: echo getLockType($data['key_'.$i]).($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1849 function r_LockProvide($data)
1851 global $lang, $dDB;
1852 if ($items = $dDB->select('SELECT `entry`, `Quality`, `displayid`, `name` FROM `item_template` WHERE `lockid` = ?d', $data['id']))
1853 foreach ($items as $i)
1854 show_item($i['entry'], $i['displayid'], 'sell');
1856 $data0 = array(GAMEOBJECT_TYPE_QUESTGIVER,GAMEOBJECT_TYPE_CHEST,GAMEOBJECT_TYPE_TRAP,GAMEOBJECT_TYPE_GOOBER,GAMEOBJECT_TYPE_CAMERA);
1857 $data1 = array(GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_BUTTON);
1858 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']))
1859 foreach ($go_list as $go)
1861 localiseGameobject($go);
1862 r_objName($go);echo '<br>';
1864 if (count($items) + count($go_list) == 0)
1865 echo $lang['no_found'];
1868 $lock_report = array(
1869 'LOCK_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['lock_id'], 'draw'=>'r_LockId', 'sort_str'=>'', 'fields'=>''),
1870 'LOCK_REPORT_KEY' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['lock_keys'],'draw'=>'r_LockKeys', 'sort_str'=>'', 'fields'=>''),
1871 'LOCK_REPORT_HAVE'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['locked_list'],'draw'=>'r_LockProvide','sort_str'=>'', 'fields'=>''),
1874 class LockReportGenerator extends ReportGenerator{
1875 // Database depend requirest generator
1876 // Select only reuire for report fields from database
1877 function LockReportGenerator($type='')
1879 global $lock_report, $wDB;
1880 $this->db = &$wDB;
1881 $this->column_conf =&$lock_report;
1882 $this->table = '`wowd_lock`';
1883 $this->db_fields = '*';
1885 function haveItemAsKey($entry)
1887 $this->doRequirest(
1888 '(`keytype_0` = 1 AND `key_0` = ?d) OR
1889 (`keytype_1` = 1 AND `key_1` = ?d) OR
1890 (`keytype_2` = 1 AND `key_2` = ?d) OR
1891 (`keytype_3` = 1 AND `key_3` = ?d) OR
1892 (`keytype_4` = 1 AND `key_4` = ?d)', $entry, $entry, $entry, $entry, $entry);
1896 //=================================================================
1897 // Extend cost list report functions and methods
1898 //=================================================================
1899 function r_excostId($data) {echo $data['id'];}
1900 function r_excostCost($data, $side = 0)
1902 if ($side) $side = "images/honor_horde.png";
1903 else $side = "images/honor_alliance.png";
1904 $str='<div class=ex_cost>';
1905 if ($data['reqhonorpoints']) $str.= $data['reqhonorpoints'].'x<img class=cost src='.$side.'>';
1906 if ($data['reqarenapoints']) $str.= $data['reqarenapoints'].'x<img class=cost src=images/arena_points.png>';
1907 for ($i=1;$i<6;$i++)
1908 if ($data['reqitem_'.$i]) $str.= $data['reqitemcount_'.$i].' x '.text_show_item($data['reqitem_'.$i], 0, 'cost');
1909 echo $str.'</div>';
1912 function r_excostItem($data)
1914 global $lang, $dDB;
1915 if ($items = $dDB->selectCol("SELECT `item` FROM `npc_vendor` WHERE ExtendedCost = ?d GROUP BY `item`", $data['id']))
1916 foreach ($items as $itemid)
1917 show_item($itemid, 0, "sell");
1918 else
1919 echo $lang['no_found'];
1921 $excost_report = array(
1922 'EXCOST_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['excost_id'], 'draw'=>'r_excostId', 'sort_str'=>'`id`', 'fields'=>''),
1923 'EXCOST_REPORT_COST'=>array('class'=>'small','sort'=>'cost', 'text'=>$lang['excost_cost'], 'draw'=>'r_excostCost','sort_str'=>'`reqitemcount_1`,`reqitemcount_2`, `reqitemcount_3`', 'fields'=>''),
1924 'EXCOST_REPORT_ITEM'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['excost_items'],'draw'=>'r_excostItem','sort_str'=>'', 'fields'=>''),
1927 class ExCostReportGenerator extends ReportGenerator{
1928 // Database depend requirest generator
1929 // Select only reuire for report fields from database
1930 function ExCostReportGenerator($type='')
1932 global $excost_report, $wDB;
1933 $this->db = &$wDB;
1934 $this->column_conf =&$excost_report;
1935 $this->table = '`wowd_item_ex_cost`';
1936 $this->db_fields = '*';
1938 function useItemAsCost($entry)
1940 $this->doRequirest(
1941 '`reqitem_1` = ?d OR
1942 `reqitem_2` = ?d OR
1943 `reqitem_3` = ?d OR
1944 `reqitem_4` = ?d OR
1945 `reqitem_5` = ?d', $entry, $entry, $entry, $entry, $entry);
1949 //=================================================================
1950 // Item set list report functions and methods
1951 //=================================================================
1952 function r_setId($data) {echo $data['id'];}
1953 function r_setName($data){echo '<a href="?itemset='.$data['id'].'">'.$data['name'].'</a>';}
1954 function r_setItems($data)
1956 for($i=1;$i<18;$i++)
1957 if ($set_item = $data['item_'.$i])
1958 echo '&nbsp;'.text_show_item($set_item).'&nbsp;';
1960 function r_setSpells($data)
1962 for($i=1; $i<9; $i++)
1963 if ($spellID = $data['spell_'.$i])
1964 echo '<a class=spell href="?spell='.$spellID.'">('.$data['count_'.$i].') '.get_spell_details($spellID).'</a><br>';
1966 function r_setClass($data){}
1967 function r_setLevel($data){}
1969 $itemset_report = array(
1970 'SET_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['set_id'], 'draw'=>'r_setId', 'sort_str'=>'`id`', 'fields'=>''),
1971 'SET_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['set_name'], 'draw'=>'r_setName', 'sort_str'=>'`name`','fields'=>''),
1972 'SET_REPORT_ITEM' =>array('class'=>'iset', 'sort'=>'', 'text'=>$lang['set_items'], 'draw'=>'r_setItems', 'sort_str'=>'', 'fields'=>''),
1973 'SET_REPORT_SPELL'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['set_spells'],'draw'=>'r_setSpells','sort_str'=>'', 'fields'=>''),
1974 // Not supported yet
1975 'SET_REPORT_CLASS'=>array('class'=>'', 'sort'=>'class','text'=>$lang['set_class'], 'draw'=>'r_setClass', 'sort_str'=>'', 'fields'=>''),
1976 'SET_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'level','text'=>$lang['set_level'], 'draw'=>'r_setLevel', 'sort_str'=>'', 'fields'=>''),
1979 class ItemSetReportGenerator extends ReportGenerator{
1980 // Database depend requirest generator
1981 // Select only reuire for report fields from database
1982 function ItemSetReportGenerator($type='')
1984 global $itemset_report, $wDB;
1985 $this->db = &$wDB;
1986 $this->column_conf =&$itemset_report;
1987 $this->table = '`wowd_itemset`';
1988 $this->db_fields = '*';
1990 function useSpell($entry)
1992 $this->doRequirest(
1993 '`spell_1` = ?d OR `spell_2` = ?d OR `spell_3` = ?d OR `spell_4` = ?d OR
1994 `spell_5` = ?d OR `spell_6` = ?d OR `spell_7` = ?d OR `spell_8` = ?d', $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1998 //=================================================================
1999 // Faction list report functions and methods
2000 //=================================================================
2001 function r_factionId($data) {echo $data['id'];}
2002 function r_factionName($data) {echo '<a href="?faction='.$data['id'].'">'.$data['name'].'</a>';}
2003 function r_factionDetail($data){echo $data['details'];}
2005 $faction_report = array(
2006 'FACTION_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['faction_id' ], 'draw'=>'r_factionId', 'sort_str'=>'', 'fields'=>''),
2007 'FACTION_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['faction_name'], 'draw'=>'r_factionName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
2008 'FACTION_REPORT_DETAILS' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['faction_details'],'draw'=>'r_factionDetail','sort_str'=>'', 'fields'=>'`details`'),
2011 class FactionReportGenerator extends ReportGenerator{
2012 // Database depend requirest generator
2013 // Select only reuire for report fields from database
2014 function FactionReportGenerator($type='')
2016 global $faction_report, $wDB;
2017 $this->db = &$wDB;
2018 $this->column_conf =&$faction_report;
2019 $this->table = '`wowd_faction`';
2020 $this->db_fields = '`id`';
2024 //=================================================================
2025 // Enchants list report functions and methods
2026 //=================================================================
2027 function r_enchId($data) {echo $data['id'];}
2028 function r_enchName($data) {echo '<a href="?enchant='.$data['id'].'">'.$data['description'].'</a>';}
2029 function r_enchGem($data) { if ($data['GemID']) echo text_show_item($data['GemID']);}
2030 $enchants_report = array(
2031 'ENCH_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['enchant_id'], 'draw'=>'r_enchId', 'sort_str'=>'`id`', 'fields'=>''),
2032 'ENCH_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['enchant_name'],'draw'=>'r_enchName', 'sort_str'=>'`description`','fields'=>'`description`'),
2033 'ENCH_REPORT_GEM' =>array('class'=>'small','sort'=>'', 'text'=>'', 'draw'=>'r_enchGem', 'sort_str'=>'', 'fields'=>'`GemID`'),
2036 class EnchantReportGenerator extends ReportGenerator{
2037 // Database depend requirest generator
2038 // Select only reuire for report fields from database
2039 function EnchantReportGenerator($type='')
2041 global $enchants_report, $wDB;
2042 $this->db = &$wDB;
2043 $this->column_conf =&$enchants_report;
2044 $this->table = '`wowd_item_enchantment`';
2045 $this->db_fields = '`id`';
2047 function useSpell($entry)
2049 $this->doRequirest('`spellid_1` = ?d OR `spellid_2` = ?d OR `spellid_3` = ?d', $entry, $entry, $entry);
2050 $this->removeIfAllZero('GemID', 'ENCH_REPORT_GEM');
2054 //=================================================================
2055 // Talents list report functions and methods
2056 //=================================================================
2057 function r_talentId($data) {echo $data['TalentTab'];}
2058 function r_talentName($data) {echo getTalentName($data['TalentTab']);}
2059 $talent_report = array(
2060 'TALENT_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['talent_id'], 'draw'=>'r_talentId', 'sort_str'=>'', 'fields'=>'`TalentTab`'),
2061 'TALENT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['talent_name'],'draw'=>'r_talentName', 'sort_str'=>'','fields'=>'`TalentTab`'),
2064 class TalentReportGenerator extends ReportGenerator{
2065 // Database depend requirest generator
2066 // Select only reuire for report fields from database
2067 function TalentReportGenerator($type='')
2069 global $talent_report, $wDB;
2070 $this->db = &$wDB;
2071 $this->column_conf =&$talent_report;
2072 $this->table = '`wowd_talents`';
2073 $this->db_fields = '`TalentID`';
2075 function useSpell($entry)
2077 $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);
2080 //=================================================================
2081 // Zones list report functions and methods
2082 //=================================================================
2083 function r_zoneId($data) {echo $data['id'];}
2084 function r_zoneName($data) {echo '<a href="?zone='.$data['id'].'">'.$data['name'].'</a>';}
2085 $zone_report = array(
2086 'ZONE_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['zone_id'], 'draw'=>'r_zoneId', 'sort_str'=>'`id`', 'fields'=>''),
2087 'ZONE_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['zone_name'],'draw'=>'r_zoneName', 'sort_str'=>'`name`','fields'=>'`name`'),
2090 class ZoneReportGenerator extends ReportGenerator{
2091 function ZoneReportGenerator($type='')
2093 global $zone_report, $wDB;
2094 $this->db = &$wDB;
2095 $this->column_conf =&$zone_report;
2096 $this->table = '`wowd_zones`';
2097 $this->db_fields = '`id`';
2099 function parentZone($entry)
2101 $this->doRequirest('`id` = ?d', $entry);
2103 function subZones($entry)
2105 $this->doRequirest('`zone_id` = ?d', $entry);
2109 //=================================================================
2110 // Areatrigger teleport list report functions and methods
2111 //=================================================================
2112 function r_atId($data) {echo $data['id'];}
2113 function r_atName($data) {echo $data['name'];}
2114 function r_atReq($data)
2116 global $lang;
2117 if ($data['required_level'])
2118 echo 'Req level: '.$data['required_level'].'<br>';
2120 if ($data['required_item'] OR $data['required_item2'])
2122 echo 'Req items:<br>';
2123 if ($data['required_item']) echo text_show_item($data['required_item'], 0, 'quest');
2124 if ($data['required_item2']) echo $lang['item_sel_and'].text_show_item($data['required_item2'], 0, 'quest');
2125 echo '<br>';
2127 if ($data['heroic_key'] OR $data['heroic_key2'])
2129 echo 'Heroic key:<br>';
2130 if ($data['heroic_key']) echo text_show_item($data['heroic_key'], 0, 'quest');
2131 if ($data['heroic_key2']) echo $lang['item_sel_and'].text_show_item($data['heroic_key2'], 0, 'quest');
2132 echo '<br>';
2136 $at_report = array(
2137 'AT_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['at_id'], 'draw'=>'r_atId', 'sort_str'=>'`id`', 'fields'=>''),
2138 'AT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['at_name'],'draw'=>'r_atName', 'sort_str'=>'`name`','fields'=>'`name`'),
2139 '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`'),
2142 class AreaTriggerReportGenerator extends ReportGenerator{
2143 function AreaTriggerReportGenerator($type='')
2145 global $at_report, $wDB;
2146 $this->db = &$wDB;
2147 $this->column_conf =&$at_report;
2148 $this->table = '`areatrigger_teleport`';
2149 $this->db_fields = '*';
2151 function onMap($entry)
2153 $this->doRequirest('`target_map` = ?d', $entry);
2155 function onArea($area_data)
2157 $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]);
2161 //=================================================================
2162 // Players list report functions and methods
2163 //=================================================================
2164 function r_plGUID($data) {echo $data['guid'];}
2165 function r_plName($data) {echo '<a href=?player='.$data['guid'].'>'.$data['name'].'</a>';}
2166 function r_plRace($data) {echo '<img src="'.getRaceImage($data['race'],$data['gender']).'">';}
2167 function r_plClass($data) {echo '<img src="'.getClassImage($data['class']).'">';}
2168 function r_plFaction($data){echo '<img src="'.getFactionImage($data['race']).'">';}
2169 function r_plLevel($data) {echo $data['level'];}
2170 function r_plPos($data)
2172 global $config;
2173 $map_name = getMapNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2174 $area_name = getAreaNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2175 $extra_name = "";
2176 if ($area_name)
2178 $extra_name = "<br><font size=-2>".$map_name."</font>";
2179 $map_name = "&bdquo;".str_replace(' ','&nbsp;', $area_name)."&ldquo;";
2181 else
2182 $map_name = "&bdquo;".str_replace(' ','&nbsp;',$map_name)."&ldquo;";
2184 if ($config['show_map_ptr'])
2185 $map_name = "<a href=\"?map&point=$data[map]:$data[position_x]:$data[position_y]:$data[position_z]\">".$map_name."</a>";
2186 echo $map_name.$extra_name;
2188 function r_plGuildNote($data) {echo $data['pnote']."<br>".$data['offnote'];}
2189 function r_plGuildRank($data)
2191 // Получаем названия рангов в гильдии
2192 $rank = getGuildRankList($data['guildid']);
2193 echo @$rank[$data['rank']]['rname'];
2196 function r_plItem($data){show_item_by_data(explode(' ',$data['item_data']));}
2198 $pl_report = array(
2199 'PL_REPORT_GUID' =>array('class'=>'small', 'sort'=>'id', 'text'=>$lang['pl_guid'], 'draw'=>'r_plGUID', 'sort_str'=>'`id`', 'fields'=>''),
2200 'PL_REPORT_NAME' =>array('class'=>'player','sort'=>'name', 'text'=>$lang['pl_name'], 'draw'=>'r_plName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
2201 'PL_REPORT_RACE' =>array('class'=>'i_ico', 'sort'=>'race', 'text'=>$lang['pl_race'], 'draw'=>'r_plRace', 'sort_str'=>'`race`', 'fields'=>'`race`, `gender`'),
2202 'PL_REPORT_CLASS' =>array('class'=>'i_ico', 'sort'=>'class', 'text'=>$lang['pl_class'], 'draw'=>'r_plClass', 'sort_str'=>'`class`', 'fields'=>'`class`'),
2203 'PL_REPORT_FACTION'=>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plFaction','sort_str'=>'', 'fields'=>'`race`'),
2204 'PL_REPORT_LEVEL' =>array('class'=>'small', 'sort'=>'level', 'text'=>$lang['pl_level'], 'draw'=>'r_plLevel', 'sort_str'=>'`level` DESC','fields'=>'`level`'),
2205 '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`'),
2206 // Guild member info
2207 'PL_REPORT_NOTE' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['pl_note'], 'draw'=>'r_plGuildNote','sort_str'=>'', 'fields'=>'`pnote`, `offnote`'),
2208 'PL_REPORT_GRANK' =>array('class'=>'rank', 'sort'=>'rank', 'text'=>$lang['pl_rank'], 'draw'=>'r_plGuildRank','sort_str'=>'`rank`', 'fields'=>'`guildid`,`rank`'),
2209 // Item owner
2210 'PL_REPORT_ITEM' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plItem' ,'sort_str'=>'', 'fields'=>'`item_instance`.`data` AS `item_data`'),
2213 class PlayerReportGenerator extends ReportGenerator{
2214 function PlayerReportGenerator($type='')
2216 global $pl_report, $cDB;
2217 $this->db = &$cDB;
2218 $this->column_conf =&$pl_report;
2219 switch ($type){
2220 case 'guild': $this->table = '(`characters` join `guild_member` ON `guild_member`.`guid` = `characters`.`guid`)';break;
2221 case 'item': $this->table = '(`characters` join `item_instance` ON `characters`.`guid` = `item_instance`.`owner_guid`)';break;
2222 default: $this->table = '`characters`';break;
2225 $this->db_fields = '`characters`.`guid`';
2227 function online()
2229 $this->doRequirest('`online` <> 0 AND NOT `extra_flags`&'.PLAYER_EXTRA_GM_INVISIBLE);
2231 // Select guild members by guild guid
2232 function guildMembers($gguid)
2234 $this->doRequirest('`guildid` = ?d', $gguid);
2236 function itemOwner($id)
2238 $this->doRequirest("(SUBSTRING_INDEX( SUBSTRING_INDEX(`item_instance`.`data` , ' ' , ?d) , ' ' , -1 )+0) = ?d", ITEM_FIELD_ENTRY + 1, $id);