Попытка подключения creature_template_spells.))
[cswow.git] / include / report_generator.php
blob1935b2d95acd87a464fb3652f67381ca38ee4cc6
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 `difficulty_entry_1` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_1` <> 0');
320 return $gheroic;
323 $gheroic1 = 0;
324 function getHeroicList1()
326 global $dDB, $gheroic1;
327 if (!$gheroic1)
328 $gheroic1 = $dDB->selectCol('-- CACHE: 1h
329 SELECT `difficulty_entry_2` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_2` <> 0');
330 return $gheroic1;
333 $gheroic2 = 0;
334 function getHeroicList2()
336 global $dDB, $gheroic2;
337 if (!$gheroic2)
338 $gheroic2 = $dDB->selectCol('-- CACHE: 1h
339 SELECT `difficulty_entry_3` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_3` <> 0');
340 return $gheroic2;
342 //==============================================================================
343 // Callback functions
344 //==============================================================================
345 function playerSpellCallback($data)
347 $spells = getPlayerSpells($_REQUEST['guid']);
348 if (isset($spells[$data['id']]))
349 return 0;
350 setBwIconMode();
351 return 'notknow';
354 //==============================================================================
355 // Loot
356 //==============================================================================
357 function r_lootChance($data)
359 if ($data['mincountOrRef'] < 0)
361 echo 'R'.($data['ChanceOrQuestChance']).'%';
363 else if ($data['ChanceOrQuestChance'] < 0)
364 echo 'Q'.(-$data['ChanceOrQuestChance']).'%';
365 else
366 echo $data['ChanceOrQuestChance'].'%';
368 function r_lootRequire($data)
370 global $lang;
371 $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 20: // CONDITION_ACHIEVEMENT ach_id 0, 1 (0: has achievement, 1: hasn't achievement) for player
444 if ($type['value2'] > 0) echo $lang['condition20_1'].$type['value1'];
445 else echo $lang['condition20_2'].$type['value1'];
446 break;
447 case 22: // CONDITION_QUEST_NONE quest_id
448 if ($type['value1'] > 0) echo $lang['condition22'].getQuestName($type['value1']);
449 break;
450 case 23: // CONDITION_ITEM_WITH_BANK- item_id, count
451 $item = getItem($type['value1'], '`entry`, `displayid`');
452 echo $lang['condition23'].text_show_item($item['entry'], $item['displayid'], 'quest');
453 if ($type['value2'] > 1) echo 'x'.$type['value2'];
454 break;
455 case 24: // NOITEM_WITH_BANK item_id count
456 $item = getItem($type['value1'], '`entry`, `displayid`');
457 echo $lang['condition24'].text_show_item($item['entry'], $item['displayid'], 'quest');
458 if ($type['value1'] > 1) echo 'x'.$type['value2'];
459 break;
460 case 25: // CONDITION_NOT_ACTIVE_GAME_EVENT event_id
461 echo $lang['condition25'].getGameEventName($type['value1']);
462 break;
463 case 26: // CONDITION_ACTIVE_HOLIDAY holiday_id
464 echo $lang['condition26'].getGameHolidayName($type['value1']);
465 break;
466 case 27: // CONDITION_NOT_ACTIVE_HOLIDAY holiday_id
467 echo $lang['condition27'].getGameHolidayName($type['value1']);
468 break;
469 case 28: // CONDITION_LEARNABLE_ABILITY spell_id 0 or item_id
470 $spell = getSpell($type['value1'], '`id`, `SpellIconID`');
471 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');}
472 else {echo $lang['condition28_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
473 break;
474 case 29: // CONDITION_SKILL_BELOW skill_id, skill_value
475 echo $lang['condition29'].getSkillName($type['value1']);
476 if ($type['value2'] > 1) echo ' ('.$type['value2'].')';
477 break;
478 case 30: // CONDITION_REPUTATION_RANK_MAX - faction_id, max_rank
479 echo getFactionName($type['value1']).'<=('.getReputationRankName($type['value2']).')';
480 break;
485 class LootReportGenerator extends ReportGenerator{
486 function LootReportGenerator($type='')
488 global $dDB;
489 $this->db = &$dDB;
490 $this->db_fields = '*';
491 switch ($type){
492 default: $this->table = '`creature_loot_template`'; break;
495 function loadSubList($lootId, $table)
497 $fields= $this->db_fields;
498 $rows = $this->db->select("SELECT $fields FROM $table
499 WHERE `entry` = ?d
500 GROUP BY IF (`mincountOrRef` < 0, `mincountOrRef`, `item`)
501 ORDER BY `groupid`, `ChanceOrQuestChance`>0, ABS(`ChanceOrQuestChance`) DESC", $lootId);
502 if (!$rows)
503 return 0;
504 foreach($rows as &$loot)
506 // Group chance
507 if ($loot['ChanceOrQuestChance'] == 0)
509 $group = $loot['groupid'];
510 $chance = 0; $n = 0;
511 foreach($rows as &$g)
512 if ($g['groupid'] == $group)
514 if ($g['ChanceOrQuestChance']>0) $chance+=$g['ChanceOrQuestChance'];
515 else $n++;
517 $chance = round((100 - $chance) / $n, 3);
518 foreach($rows as &$g)
519 if ($g['groupid'] == $group && $g['ChanceOrQuestChance']==0)
520 $g['ChanceOrQuestChance'] =$chance;
522 if ($loot['mincountOrRef'] < 0)
524 // Получаем список
525 $loot['item'] = $this->loadSubList(-$loot['mincountOrRef'], 'reference_loot_template');
526 $loot['maxcount'] = $this->db->selectCell("SELECT `maxcount` FROM $table WHERE `entry` = ?d AND `mincountOrRef` = ?d", $lootId, $loot['mincountOrRef']);
529 return $rows;
531 function getLootList($lootId)
533 $this->total_data = 0;
534 $this->data_array = $this->loadSubList($lootId, $this->table);
536 function renderSubList($lootList)
538 global $Quality, $lang;
539 if (!$lootList)
540 return;
541 $curloot = -1;
542 foreach ($lootList as $loot)
544 $gtext = "";
545 if ($loot['groupid']!=$curloot)
547 echo "<tr><th colspan = 4>$lang[kill_kredit_group]&nbsp;$loot[groupid]</th></tr>";
548 $curloot = $loot['groupid'];
550 echo "<tr>";
551 if ($loot['mincountOrRef'] > 0)
553 if ($item = getItem($loot['item'],"`entry`, `Quality`, `name`, `displayid`"))
555 echo '<td class=i_ico>';r_itemIcon($item);echo '</td>';
556 echo '<td class=left>';r_itemName($item);echo '</td>';
558 else
559 echo "<td>-</td><td>$lang[item_not_found]&nbsp;$loot[item]</td>";
561 else // Используется список вещей (падает только одна вещь из списка)
563 echo "<td>".$loot['maxcount']."x</td>";
564 echo "<td class=forsub>$gtext<table class=sublist><tbody>";
565 $this->renderSubList($loot['item']);
566 echo "</tbody></table></td>";
568 if ($loot['lootcondition']){echo '<td>'; r_lootRequire($loot); echo '</td>';}
569 else echo '<td></td>';
570 if ($loot['ChanceOrQuestChance'] < 0) echo "<td align=center>Q".(-$loot['ChanceOrQuestChance'])."%</td>";
571 else if ($loot['ChanceOrQuestChance'] > 0) echo "<td align=center>".$loot['ChanceOrQuestChance']."%</td>";
572 echo "</tr>";
575 function createReport($header)
577 global $lang;
578 if (!$this->data_array)
579 return;
580 if ($this->ajax_mode==0)
581 echo '<div id="'.$this->mark.'">';
582 echo '<table class=report width=500>';
583 echo '<tbody>';
584 echo '<tr><td colspan=4 class=head>'.$header.'</td></tr>';
585 echo '<tr><th width=1%></th><th>'.$lang['item_name'].'</th><th></th><th>'.$lang['drop'].'%</th></tr>';
586 $this->renderSubList($this->data_array);
587 echo '</tbody></table>';
588 if ($this->ajax_mode==0)
590 echo '</div>';
591 // Cache data
592 $link = $this->createLink($this->page, $this->sort_method);
593 echo "<script type=\"text/javascript\">ajaxCacheHtmlId('$this->mark','$link');</script>";
598 //=================================================================
599 // Item report functions and methods
600 //=================================================================
601 function r_itemIcon($data) {echo text_show_item($data['entry'], $data['displayid']);}
602 function r_itemName($data)
604 global $Quality;
605 echo '<a class="'.$Quality[$data['Quality']].'" href="?item='.$data['entry'].'">'.(@$data['name_loc']?$data['name_loc']:$data['name']).'</a>';
607 function r_itemLevel($data) {echo $data['ItemLevel'];}
608 function r_itemReqLevel($data){echo $data['RequiredLevel'];}
609 function r_itemGemProp($data) {echo ($data['GemProperties']?getGemProperties($data['GemProperties']):'n/a');}
610 function r_itemArmor($data) {echo $data['armor'];}
611 function r_itemBlock($data) {echo $data['block'];}
612 function r_itemDPS($data) {echo $data['dps'] != 0 ? number_format($data['dps'], 2, '.', ''):'n/a';}
613 function r_itemAmmoDPS($data) {echo $data['adps'] != 0 ? number_format($data['adps'], 2, '.', ''):'n/a';}
614 function r_itemSpeed($data) {echo number_format($data['delay']/1000.00, 2, '.', '');}
615 function r_itemSlots($data) {echo $data['ContainerSlots'].' slot';}
616 function r_itemDesc($data) {echo (@$data['description_loc']?$data['description_loc']:$data['description']);}
617 function r_itemSClass($data) {echo getSubclassName($data['class'], $data['subclass'], 0);}
618 function r_itemInvType($data) {echo getInventoryType($data['InventoryType'], 0);}
619 function r_itemRecipe($data) {$ritem = getRecipeItem($data); echo ($ritem ? text_show_item($ritem['entry'], $ritem['displayid']):'-');}
620 function r_itemSpells($data)
622 global $UseorEquip;
623 for ($i=1;$i<=5;$i++)
625 if ($id = $data['spellid_'.$i])
626 if ($desc = get_spell_details($id))
627 echo '<a href="?spell='.$id.'">'.$UseorEquip[$data['spelltrigger_'.$i]].' '.$desc.'</a><br>';
630 function r_itemRepRank($data) {echo $data['RequiredReputationFaction']?getReputationRankName($data['RequiredReputationRank']):'n/a';}
631 function r_itemFlag($data) {echo dechex($data['Flags']);}
633 // Vendor
634 function r_vendorCost($data)
636 $flags2 = getItemFlags2($data['entry']);
637 if ($data['ExtendedCost']>0)
639 $cost = getExtendCost($data['ExtendedCost']);
640 if ($flags2&ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD)
641 echo money($data['BuyPrice']).''.r_excostCost($cost);
642 else
643 r_excostCost($cost);
645 else
646 echo money($data['BuyPrice']);
648 function r_vendorCount($data) {echo $data['sold_count']?$data['sold_count']:'∞';}
649 function r_vendorTime($data) {echo $data['incrtime']?getTimeText($data['incrtime']):'';}
651 // NPC report generator config
652 $item_report = array(
653 'ITEM_REPORT_ICON' =>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemIcon', 'sort_str'=>'', 'fields'=>'`displayid`' ),
654 'ITEM_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['item_name'], 'draw'=>'r_itemName', 'sort_str'=>'`name`', 'fields'=>'`Quality`, `name`'),
655 'ITEM_REPORT_LEVEL' =>array('class'=>'small','sort'=>'i_level', 'text'=>$lang['item_level'], 'draw'=>'r_itemLevel', 'sort_str'=>'`ItemLevel` DESC, `name`', 'fields'=>'`ItemLevel`' ),
656 'ITEM_REPORT_REQLEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['item_req_level'], 'draw'=>'r_itemReqLevel', 'sort_str'=>'`RequiredLevel` DESC, `name`', 'fields'=>'`RequiredLevel`' ),
657 'ITEM_REPORT_GEMPROPETY' =>array('class'=>'left', 'sort'=>'gem_prop','text'=>$lang['item_gem_details'],'draw'=>'r_itemGemProp', 'sort_str'=>'`GemProperties`', 'fields'=>'`GemProperties`'),
658 'ITEM_REPORT_ARMOR' =>array('class'=>'', 'sort'=>'armor', 'text'=>$lang['item_armor'], 'draw'=>'r_itemArmor', 'sort_str'=>'`armor` DESC', 'fields'=>'`armor`'),
659 'ITEM_REPORT_BLOCK' =>array('class'=>'', 'sort'=>'block', 'text'=>$lang['item_block'], 'draw'=>'r_itemBlock', 'sort_str'=>'`block` DESC', 'fields'=>'`block`'),
660 '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`'),
661 '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`'),
662 'ITEM_REPORT_SPEED' =>array('class'=>'', 'sort'=>'speed', 'text'=>$lang['item_speed'], 'draw'=>'r_itemSpeed', 'sort_str'=>'`delay` DESC', 'fields'=>'`delay`'),
663 'ITEM_REPORT_NUM_SLOTS' =>array('class'=>'', 'sort'=>'bag_slot','text'=>$lang['item_slot_num'], 'draw'=>'r_itemSlots', 'sort_str'=>'`ContainerSlots` DESC', 'fields'=>'`ContainerSlots`'),
664 'ITEM_REPORT_DESCRIPTION'=>array('class'=>'left', 'sort'=>'desc', 'text'=>$lang['item_desc'], 'draw'=>'r_itemDesc', 'sort_str'=>'`description` DESC', 'fields'=>'`description`'),
665 'ITEM_REPORT_SUBCLASS' =>array('class'=>'', 'sort'=>'subclass','text'=>$lang['item_type'], 'draw'=>'r_itemSClass', 'sort_str'=>'`subclass` DESC', 'fields'=>'`class`, `subclass`'),
666 'ITEM_REPORT_SLOTTYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['item_slot'], 'draw'=>'r_itemInvType', 'sort_str'=>'`InventoryType` DESC', 'fields'=>'`InventoryType`'),
667 'ITEM_REPORT_RECIPE_ITEM'=>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemRecipe', 'sort_str'=>'', 'fields'=>'`spellid_1`, `spellid_2`, `class`'),
668 '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`'),
669 'ITEM_REPORT_REQREP_RANK'=>array('class'=>'', 'sort'=>'rep_rank','text'=>$lang['item_faction_rank'],'draw'=>'r_itemRepRank', 'sort_str'=>'`RequiredReputationRank` DESC', 'fields'=>'`RequiredReputationFaction`, `RequiredReputationRank`'),
670 'ITEM_REPORT_FLAGS' =>array('class'=>'', 'sort'=>'', 'text'=>'flag', 'draw'=>'r_itemFlag', 'sort_str'=>'', 'fields'=>'`Flags`'),
671 // If set vendor class type
672 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCost', 'sort_str'=>'`ExtendedCost`, `BuyPrice`', 'fields'=>'`ExtendedCost`, `BuyPrice`'),
673 '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`'),
674 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `name`', 'fields'=>'`incrtime`'),
675 // If set loot class type
676 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
677 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
680 // Item localisation flags (for allow disable some fields localisation if need)
681 define('ITEM_LOCALE_NAME', 0x01);
682 define('ITEM_LOCALE_DESCRIPTION', 0x02);
683 define('ITEM_LOCALE_ALL', ITEM_LOCALE_NAME | ITEM_LOCALE_DESCRIPTION);
685 // Item report class
686 class ItemReportGenerator extends ReportGenerator{
687 var $dolocale = ITEM_LOCALE_ALL;
688 function ItemReportGenerator($type='')
690 global $item_report, $dDB;
691 $this->db = &$dDB;
692 $this->column_conf =&$item_report;
693 $this->db_fields = '`item_template`.`entry`';
694 switch ($type){
695 case 'vendor' : $this->table = '(`item_template` join `npc_vendor` ON `item_template`.`entry` = `npc_vendor`.`item`)'; break;
696 case 'loot': $this->table = '(`item_loot_template` right join `item_template` ON `item_template`.`entry` = `item_loot_template`.`entry`)'; break;
697 case 'disenchant':$this->table = '(`disenchant_loot_template` right join `item_template` ON `item_template`.`DisenchantID` = `disenchant_loot_template`.`entry`)'; break;
698 case 'milling': $this->table = '(`milling_loot_template` right join `item_template` ON `item_template`.`entry` = `milling_loot_template`.`entry`)'; break;
699 case 'prospect': $this->table = '(`prospecting_loot_template` right join `item_template` ON `item_template`.`entry` = `prospecting_loot_template`.`entry`)'; break;
700 default: $this->table = '`item_template`'; break;
703 function disableNameLocalisation() {$this->dolocale &= ~ITEM_LOCALE_NAME;}
704 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
706 $tables .= ' LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry`';
707 if ($this->dolocale & ITEM_LOCALE_NAME)
709 $fields = str_replace('`name`','`name`, `locales_item`.`name_loc'.$locale.'` AS `name_loc`', $fields);
710 $sort_str = str_replace('`name`', '`name_loc`, `name`', $sort_str);
712 if ($this->dolocale & ITEM_LOCALE_DESCRIPTION)
714 $fields = str_replace('`description`','`description`, `locales_item`.`description_loc'.$locale."` AS `description_loc`", $fields);
715 $sort_str = str_replace('`description` DESC', '`description_loc` DESC, `name` DESC', $sort_str);
718 function vendorItemList($entry)
720 $this->doRequirest('`npc_vendor`.`entry` = ?d', $entry);
721 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
722 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
724 function useSpell($entry)
726 $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);
728 function recipeSpell($entry)
730 $this->doRequirest('`spellid_1` = 483 AND `spellid_2` = ?d', $entry);
732 function socketBonus($entry)
734 $this->doRequirest('`SocketBonus` = ?d', $entry);
736 function enchantByGems($entry)
738 global $wDB;
739 if ($list = $wDB->selectCol("SELECT `id` FROM `wowd_gemproperties` WHERE `spellitemenchantement` = ?d", $entry))
740 $this->doRequirest('`GemProperties` IN (?a)', $list);
742 function requireReputation($entry)
744 $this->doRequirest('`RequiredReputationFaction` = ?d', $entry);
746 function lootItem($entry)
748 $ref_loot =& getRefrenceItemLoot($entry);
749 $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));
750 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
754 //=================================================================
755 // Spell trainer list report functions and methods
756 //=================================================================
757 function r_trainerCost($data) {echo money($data['spellcost']);}
758 function r_trainerSpell($data)
760 if ($spell = getSpell($data['spell']))
762 if (!r_spellCreate($spell))
763 r_spellIcon($spell);
766 function r_trainerNSpell($data)
768 if ($spell = getSpell($data['spell']))
770 echo getSpellName($spell);
773 function r_trainerSkill($data) {if ($data['reqskill']) echo getSkillName($data['reqskill']);}
774 function r_trainerValue($data) {if ($data['reqskill']) echo $data['reqskillvalue'];}
775 function r_trainerSkillReq($data){if ($data['reqskill']) echo getSkillName($data['reqskill']).' ('.$data['reqskillvalue'].')';}
776 function r_trainerLevel($data) {echo $data['reqlevel']?$data['reqlevel']:'';}
778 $train_report = array(
779 'TRAIN_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['trainer_level'], 'draw'=>'r_trainerLevel', 'sort_str'=>'`reqlevel`, `reqskillvalue`', 'fields'=>'`reqlevel`' ),
780 'TRAIN_REPORT_ICON' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_trainerSpell', 'sort_str'=>'', 'fields'=>'`spell`' ),
781 'TRAIN_REPORT_NAME' =>array('class'=>'left', 'sort'=>'spell', 'text'=>$lang['trainer_spell'], 'draw'=>'r_trainerNSpell', 'sort_str'=>'`spell`', 'fields'=>'`spell`' ),
782 'TRAIN_REPORT_COST' =>array('class'=>'cost', 'sort'=>'cost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
783 'TRAIN_REPORT_SKILL' =>array('class'=>'small','sort'=>'skill','text'=>$lang['trainer_skill'], 'draw'=>'r_trainerSkill', 'sort_str'=>'`reqskill`', 'fields'=>'`reqskill`' ),
784 'TRAIN_REPORT_VALUE' =>array('class'=>'small','sort'=>'value','text'=>$lang['trainer_value'], 'draw'=>'r_trainerValue', 'sort_str'=>'`reqskillvalue`','fields'=>'`reqskillvalue`'),
787 class NPCTrainerReportGenerator extends ReportGenerator{
788 // Database depend requirest generator
789 // Select only reuire for report fields from database
790 function NPCTrainerReportGenerator($type='')
792 global $train_report, $dDB;
793 $this->db = &$dDB;
794 $this->column_conf =&$train_report;
795 $this->table = '`npc_trainer`';
796 $this->db_fields = '`entry`';
798 function trainSpell($entry)
800 $this->doRequirest('`entry` = ?d', $entry);
801 $this->removeIfAllZero('reqlevel', 'TRAIN_REPORT_LEVEL');
802 $this->removeIfAllZero('reqskill', 'TRAIN_REPORT_SKILL');
803 $this->removeIfAllZero('reqskillvalue', 'TRAIN_REPORT_VALUE');
807 //=================================================================
808 // Creature list report functions and methods
809 //=================================================================
810 function r_npcLvl($data)
812 echo $data['maxlevel'];
813 if ($data['rank'])
814 echo '<br><div class=rank>'.getCreatureRank($data['rank']).'</div>';
816 function r_npcName($data)
818 $h = getHeroicList();
819 $h1 = getHeroicList1();
820 $h2 = getHeroicList2();
821 if (isset($h[$data['entry']]))
823 $heroic = getCreature($h[$data['entry']]);
824 $data['name']=$heroic['name'].' (difficulty_1)';
825 $data['name_loc']=$heroic['name'].' (difficulty_1)';
826 $data['subname']=$heroic['subname'];
828 if (isset($h1[$data['entry']]))
830 $heroic = getCreature($h1[$data['entry']]);
831 $data['name']=$heroic['name'].' (difficulty_2)';
832 $data['name_loc']=$heroic['name'].' (difficulty_2)';
833 $data['subname']=$heroic['subname'];
835 if (isset($h2[$data['entry']]))
837 $heroic = getCreature($h2[$data['entry']]);
838 $data['name']=$heroic['name'].' (difficulty_3)';
839 $data['name_loc']=$heroic['name'].' (difficulty_3)';
840 $data['subname']=$heroic['subname'];
842 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
843 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['subname'];
844 echo '<a href="?npc='.$data['entry'].'">'.($name?$name:'no name').'</a>';
845 if ($subname)
846 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
848 function r_npcRName($data)
850 $h = getHeroicList();
851 $h1 = getHeroicList1();
852 $h2 = getHeroicList2();
853 if (isset($h[$data['entry']]))
855 $heroic = getCreature($h[$data['entry']]);
856 $data['name']=$heroic['name'].' (difficulty_1)';
857 $data['name_loc']=$heroic['name'].' (difficulty_1)';
858 $data['subname']=$heroic['subname'];
860 if (isset($h1[$data['entry']]))
862 $heroic = getCreature($h1[$data['entry']]);
863 $data['name']=$heroic['name'].' (difficulty_2)';
864 $data['name_loc']=$heroic['name'].' (difficulty_2)';
865 $data['subname']=$heroic['subname'];
867 if (isset($h2[$data['entry']]))
869 $heroic = getCreature($h2[$data['entry']]);
870 $data['name']=$heroic['name'].' (difficulty_3)';
871 $data['name_loc']=$heroic['name'].' (difficulty_3)';
872 $data['subname']=$heroic['subname'];
874 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
875 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['subname'];
876 echo '<a href="?npc='.$data['entry'].'">'.($name?$name:'no name').'</a> <font size=-3>('.getLoyality($data['faction_A']).')</font>';
877 if ($subname)
878 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
880 function r_npcReact($data) {echo getLoyality($data['faction_A']);}
881 function r_npcMap($data)
883 global $lang;
884 $h = getHeroicList();
885 $h1 = getHeroicList1();
886 $h2 = getHeroicList2();
888 if (isset($h2[$data['entry']]))
889 echo '<a href="?map&npc='.$h2[$data['entry']].'">'.$lang['map'].'</a>';
890 else
891 if (isset($h1[$data['entry']]))
892 echo '<a href="?map&npc='.$h1[$data['entry']].'">'.$lang['map'].'</a>';
893 else
894 if (isset($h[$data['entry']]))
895 echo '<a href="?map&npc='.$h[$data['entry']].'">'.$lang['map'].'</a>';
896 else
897 echo '<a href="?map&npc='.$data['entry'].'">'.$lang['map'].'</a>';
899 function r_npcRole($data)
901 $flag = $data['npcflag'];
902 if ($flag == 0) {return;}
903 if ($flag&0x00000001) echo '<img src=images/map_points/gossip_icon.png>';
904 if ($flag&0x00000002 && getNpcQuestrelation($data['entry'])) echo '<img src=images/map_points/available_quest_icon.gif>';
905 if ($flag&0x00000002 && getNpcInvolvedrelation($data['entry'])) echo '<img src=images/map_points/active_quest_icon.gif>';
906 if ($flag&0x00000070) echo '<img src=images/map_points/trainer_icon.gif>';
907 if ($flag&0x00000F80) echo '<img src=images/map_points/vendor_icon.gif>';
908 // if ($flag&0x00001000) echo '<img src=images/map_points/repair.gif>';
909 if ($flag&0x00002000) echo '<img src=images/map_points/taxi_icon.gif>';
910 if ($flag&0x00010000) echo '<img src=images/map_points/inn_icon.png>';
911 if ($flag&0x00820000) echo '<img src=images/map_points/banker_icon.gif>';
912 if ($flag&0x00100000) echo '<img src=images/map_points/battle_master_icon.gif>';
913 if ($flag&0x00200000) echo '<img src=images/map_points/banker_icon.gif>';
914 if ($flag&0x000C0000) echo '<img src=images/map_points/tabard_icon.gif>';
916 define('UNIT_NPC_FLAG_SPIRITHEALER', 0x00004000);
917 define('UNIT_NPC_FLAG_SPIRITGUIDE', 0x00008000);
918 define('UNIT_NPC_FLAG_STABLEMASTER', 0x00400000);*/
920 function r_OnKillRep($data)
922 $creature_rate1 = getCreatureRewRate($data['RewOnKillRepFaction1']);
923 $creature_rate2 = getCreatureRewRate($data['RewOnKillRepFaction2']);
924 if ($data['RewOnKillRepFaction1'])
926 echo ($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1.' '.getFactionName($data['RewOnKillRepFaction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
927 $spillover=getRepSpillover($data['RewOnKillRepFaction1']);
928 if ($spillover)
929 foreach ($spillover as $faction)
931 if ($faction['faction1'])
932 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
933 if ($faction['faction2'])
934 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding1']).')';
935 if ($faction['faction3'])
936 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding1']).')';
937 if ($faction['faction4'])
938 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding1']).')';
941 if ($data['RewOnKillRepFaction2'])
943 if ($data['RewOnKillRepFaction1'] == 0)
944 echo ($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
945 else
946 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
947 $spillover=getRepSpillover($data['RewOnKillRepFaction2']);
948 if ($spillover)
949 foreach ($spillover as $faction)
951 if ($faction['faction1'])
952 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding2']).')';
953 if ($faction['faction2'])
954 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
955 if ($faction['faction3'])
956 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding2']).')';
957 if ($faction['faction4'])
958 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding2']).')';
962 // NPC report generator config
963 $npc_report = array(
964 'NPC_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['creature_level'], 'draw'=>'r_npcLvl', 'sort_str'=>'`maxlevel` DESC, `name`', 'fields'=>'`maxlevel`, `rank`'),
965 '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`'),
966 'NPC_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcName', 'sort_str'=>'`name`', 'fields'=>'`name`, `subname`' ),
967 'NPC_REPORT_RNAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcRName','sort_str'=>'`name`', 'fields'=>'`name`, `subname`, `faction_A`' ),
968 'NPC_REPORT_REACTION'=>array('class'=>'small','sort'=>'', 'text'=>$lang['creature_react'], 'draw'=>'r_npcReact','sort_str'=>'', 'fields'=>'`faction_A`'),
969 'NPC_REPORT_ROLE' =>array('class'=>'', 'sort'=>'role', 'text'=>$lang['creature_role'], 'draw'=>'r_npcRole', 'sort_str'=>'`npcflag` DESC', 'fields'=>'`npcflag`'),
970 'NPC_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_npcMap', 'sort_str'=>'', 'fields'=>''),
971 // vendor
972 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCost', 'sort_str'=>'`ExtendedCost`, `name`', 'fields'=>'`ExtendedCost`'),
973 '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`'),
974 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `name`', 'fields'=>'`incrtime`'),
975 // trainer
976 'TRAINER_REPORT_COST' =>array('class'=>'', 'sort'=>'scost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
977 'TRAINER_REPORT_SPELL'=>array('class'=>'left','sort'=>'', 'text'=>$lang['trainer_spell'],'draw'=>'r_trainerSpell','sort_str'=>'', 'fields'=>'`spell`'),
978 'TRAINER_REPORT_SKILL'=>array('class'=>'', 'sort'=>'skill', 'text'=>$lang['trainer_skill'],'draw'=>'r_trainerSkillReq','sort_str'=>'`reqskill`, `reqskillvalue`','fields'=>'`reqskill`, `reqskillvalue`'),
979 'TRAINER_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'slevel','text'=>$lang['trainer_level'],'draw'=>'r_trainerLevel','sort_str'=>'`reqlevel`', 'fields'=>'`reqlevel`'),
980 // loot
981 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
982 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
983 // reputation
984 '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`'),
987 define('NPC_LOCALE_NAME', 0x01);
988 define('NPC_LOCALE_SUBNAME', 0x02);
989 define('NPC_LOCALE_ALL', NPC_LOCALE_NAME | NPC_LOCALE_SUBNAME);
991 // Creature report class
992 class CreatureReportGenerator extends ReportGenerator{
993 var $dolocale = NPC_LOCALE_ALL;
994 function CreatureReportGenerator($type = '')
996 global $npc_report, $dDB;
997 $this->db = &$dDB;
998 $this->column_conf =&$npc_report;
999 $this->db_fields = '`creature_template`.`entry`';
1000 switch ($type) {
1001 case 'vendor': $this->table = '(`creature_template` join `npc_vendor` ON `creature_template`.`entry` = `npc_vendor`.`entry`)'; break;
1002 case 'trainer':$this->table = '(`creature_template` join `npc_trainer` ON `creature_template`.`entry` = `npc_trainer`.`entry`)'; break;
1003 case 'loot': $this->table = '(`creature_template` join `creature_loot_template` ON `creature_template`.`lootid` = `creature_loot_template`.`entry`)'; break;
1004 case 'pick': $this->table = '(`creature_template` join `pickpocketing_loot_template` ON `creature_template`.`pickpocketloot` = `pickpocketing_loot_template`.`entry`)'; break;
1005 case 'skin': $this->table = '(`creature_template` join `skinning_loot_template` ON `creature_template`.`skinloot` = `skinning_loot_template`.`entry`)'; break;
1006 case 'position':$this->table ='(`creature_template` join `creature` ON `creature_template`.`entry` = `creature`.`id`)'; break;
1007 case 'reputation':$this->table ='(`creature_template` join `creature_onkill_reputation` ON `creature_template`.`entry` = `creature_onkill_reputation`.`creature_id`)'; break;
1008 default: $this->table = '`creature_template`'; break;
1011 function disableNameLocalisation() {$this->dolocale &= ~NPC_LOCALE_NAME;}
1012 function disableSubnameLocalisation() {$this->dolocale &= ~NPC_LOCALE_SUBNAME;}
1013 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1015 $tables.=' LEFT JOIN `locales_creature` ON `creature_template`.`entry` = `locales_creature`.`entry`';
1016 if ($this->dolocale & NPC_LOCALE_NAME)
1018 $fields = str_replace('`name`','`name`, `locales_creature`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1019 $sort_str = str_replace('`name`','`name_loc`, `name`', $sort_str);
1021 if ($this->dolocale & NPC_LOCALE_SUBNAME)
1023 $fields = str_replace('`subname`','`subname`, `locales_creature`.`subname_loc'.$locale.'` AS `subname_loc`', $fields);
1024 $sort_str = str_replace('`subname`','`subname_loc`, `subname`', $sort_str);
1027 function castSpell($entry)
1029 global $dDB;
1030 $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);
1031 $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);
1032 $casters = array_unique(array_merge($rows_1, $rows_2));
1033 if (count($casters))
1034 $this->doRequirest('`creature_template`.`entry` in (?a)', $casters);
1036 function inFaction($entry)
1038 global $wDB;
1039 if ($templatesId =& getFactionTemplates($entry))
1040 $this->doRequirest('`faction_A` in (?a) OR `faction_H` in (?a)', $templatesId, $templatesId);
1042 function soldItem($entry, $price)
1044 $this->db_fields.=', '.$price.' AS `BuyPrice`';
1045 $this->doRequirest('`item` = ?d', $entry);
1046 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
1047 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
1049 function trainSpell($entry)
1051 $this->doRequirest('`spell` = ?d', $entry);
1052 $this->removeIfAllZero('reqskill', 'TRAINER_REPORT_SKILL');
1054 function kreditGroup($entry)
1056 $this->doRequirest('`KillCredit1` = ?d OR `KillCredit2` = ?d', $entry, $entry);
1058 function lootItem($entry)
1060 $ref_loot =& getRefrenceItemLoot($entry);
1061 $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));
1062 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1064 // Position
1065 function onMap($entry)
1067 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1069 function onArea($area_data)
1071 $this->setManualPagenateMode();
1072 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1073 $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]);
1074 $setId = array();
1075 foreach($this->data_array as $id=>$c)
1077 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1078 if ($zone!=$area_data[1] || isset($setId[$c['entry']]))
1079 unset($this->data_array[$id]);
1080 else
1081 $setId[$c['entry']] = 1;
1084 // Reputation
1085 function rewardFactionReputation($id)
1087 $this->doRequirest('`RewOnKillRepFaction1` = ?d OR `RewOnKillRepFaction2` = ?d', $id, $id);
1089 function rewardNpcFactionReputation($entry)
1091 $this->doRequirest('`creature_id` = ?d', $entry);
1095 //=================================================================
1096 // Gameobject list report functions and methods
1097 //=================================================================
1098 function r_objName($data)
1100 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
1101 echo '<a href="?object='.$data['entry'].'">'.($name?$name:'no name').'</a>';
1103 function r_objType($data) {echo getGameobjectType($data['type'], 0);}
1104 function r_objMap($data) {global $lang; echo '<a href="?map&obj='.$data['entry'].'">'.$lang['map'].'</a>';}
1106 // GO report generator config
1107 $go_report = array(
1108 'GO_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['go_name'], 'draw'=>'r_objName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1109 'GO_REPORT_TYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['go_type'], 'draw'=>'r_objType', 'sort_str'=>'`type`', 'fields'=>'`type`'),
1110 'GO_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_objMap', 'sort_str'=>'', 'fields'=>''),
1111 // loot
1112 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1113 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
1116 define('GO_LOCALE_NAME', 0x01);
1117 define('GO_LOCALE_ALL', NPC_LOCALE_NAME);
1119 // GO report class
1120 class GameobjectReportGenerator extends ReportGenerator{
1121 var $dolocale = GO_LOCALE_ALL;
1122 function GameobjectReportGenerator($type = '')
1124 global $go_report, $dDB;
1125 $this->db = &$dDB;
1126 $this->column_conf =&$go_report;
1127 $this->db_fields = '`gameobject_template`.`entry`';
1128 switch ($type) {
1129 case 'loot':
1130 $this->table =
1131 '(`gameobject_template`
1132 join
1133 `gameobject_loot_template`
1135 `gameobject_template`.`data1` = `gameobject_loot_template`.`entry` AND
1136 `gameobject_template`.`type` IN (3, 17, 25))';
1137 break;
1138 case 'position':$this->table ='(`gameobject_template` join `gameobject` ON `gameobject_template`.`entry` = `gameobject`.`id`)';break;
1139 default: $this->table = '`gameobject_template`';break;
1142 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1143 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1145 $tables.= ' LEFT JOIN `locales_gameobject` ON `gameobject_template`.`entry` = `locales_gameobject`.`entry`';
1146 if ($this->dolocale & GO_LOCALE_NAME)
1148 $fields = str_replace('`name`', '`name`, `locales_gameobject`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1149 $sort_str= str_replace('`name`', '`name_loc`, `name`', $sort_str);
1151 $fields = str_replace('`castbarcaption`','`castbarcaption`, `locales_gameobject`.`castbarcaption_loc'.$locale.'` AS `castbarcaption_loc`', $fields);
1153 function castSpell($entry)
1155 $this->doRequirest(
1156 '(`type` = ?d AND `data3` = ?d) OR
1157 (`type` = ?d AND `data10` = ?d) OR
1158 (`type` = ?d AND `data1` = ?d) OR
1159 (`type` = ?d AND `data0` = ?d) OR
1160 (`type` = ?d AND (`data2` = ?d OR `data3` = ?d))',
1161 GAMEOBJECT_TYPE_TRAP, $entry,
1162 GAMEOBJECT_TYPE_GOOBER, $entry,
1163 GAMEOBJECT_TYPE_SUMMONING_RITUAL, $entry,
1164 GAMEOBJECT_TYPE_SPELLCASTER, $entry,
1165 GAMEOBJECT_TYPE_AURA_GENERATOR, $entry, $entry);
1167 function inFaction($entry)
1169 global $wDB;
1170 if ($templatesId =& getFactionTemplates($entry))
1171 $this->doRequirest('`faction` in (?a)', $templatesId);
1173 function spellFocus($entry)
1175 $this->doRequirest('`type` = ?d AND `data0` = ?d', GAMEOBJECT_TYPE_SPELL_FOCUS, $entry);
1177 function lootItem($entry)
1179 $ref_loot =& getRefrenceItemLoot($entry);
1180 $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));
1181 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1183 // Position
1184 function onMap($entry)
1186 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1188 function onArea($area_data)
1190 $this->setManualPagenateMode();
1191 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1192 $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]);
1193 $setId = array();
1194 foreach($this->data_array as $id=>$c)
1196 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1197 if ($zone!=$area_data[1] || isset($setId[$c['entry']]))
1198 unset($this->data_array[$id]);
1199 else
1200 $setId[$c['entry']] = 1;
1205 //=================================================================
1206 // Quest list report functions and methods
1207 //=================================================================
1208 function r_questLvl($data) {echo $data['QuestLevel'];}
1209 function r_questReqLvl($data) {echo $data['MinLevel'];}
1210 function r_questName($data)
1212 global $lang;
1213 $name = @$data['Title_loc']?$data['Title_loc']:$data['Title'];
1214 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 1101) && ($data['RequiredRaces'] !=1791))
1215 echo "<img width=22 height=22 src='images/player_info/factions_img/alliance.gif'>&nbsp;";
1216 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 690) && ($data['RequiredRaces'] !=1791))
1217 echo "<img width=22 height=22 src='images/player_info/factions_img/horde.gif'>&nbsp;";
1218 echo '<a href="?quest='.$data['entry'].'">'.($name?$name:'no name').'</a><br>';
1219 if ($data['ZoneOrSort']>0)
1220 echo '<div class=areaname><a href="?s=q&ZoneID='.$data['ZoneOrSort'].'">'.getAreaName($data['ZoneOrSort']).'</a></div>';
1221 else
1222 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
1223 (-$data['ZoneOrSort']) == 284 OR (-$data['ZoneOrSort']) == 25 OR (-$data['ZoneOrSort']) == 41 OR (-$data['ZoneOrSort']) < 24))
1224 echo '<div class=areaname><a href="?s=q&SortID='.(-$data['ZoneOrSort']).'">'.getQuestSort(-$data['ZoneOrSort']).'</a></div>';
1225 if ($data['RequiredClasses'])
1226 echo '<div class=classqname>'.getQAllowableClass($data['RequiredClasses']).'</div>';
1227 if ($data['RequiredSkill'])
1228 echo '<div class=areaname><a href="?s=q&SkillID='.($data['RequiredSkill']).'">'.getSkillName($data['RequiredSkill'], 0).'('.$data['RequiredSkillValue'].')</a></div>';
1229 if ($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY)
1230 echo '<div class=areaname><a href="?s=q&Sfm='.($data['SpecialFlags']).'">'.$lang['quest_type3'].'</a></div>';
1231 if ($data['QuestFlags'] & QUEST_FLAGS_WEEKLY)
1232 echo '<div class=areaname><a href="?s=q&Sfw='.($data['QuestFlags']).'">'.$lang['quest_type2'].'</a></div>';
1233 if ($data['QuestFlags'] & QUEST_FLAGS_DAILY)
1234 echo '<div class=areaname><a href="?s=q&Sfd='.($data['QuestFlags']).'">'.$lang['quest_type1'].'</a></div>';
1235 if (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_REPEATABLE) && (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY) ==0) && ($data['QuestFlags'] & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) == 0)
1236 echo '<div class=areaname><a href="?s=q&Sfr='.($data['SpecialFlags']).'">'.$lang['quest_type0'].'</a></div>';
1238 function r_questGiver($data)
1240 global $dDB;
1241 // Search creature quest giver
1242 if ($src = $dDB->select(
1243 'SELECT `entry`, `name`, `subname`, `faction_A`
1244 FROM `creature_template` left join `creature_questrelation` ON `creature_template`.`entry` = `creature_questrelation`.`id`
1245 WHERE `creature_questrelation`.`quest` = ?d', $data['entry']))
1247 foreach ($src as $creature){localiseCreature($creature);r_npcRName($creature);}
1248 return;
1250 // Search GO quest giver
1251 if ($src = $dDB->select(
1252 'SELECT `entry`, `name`
1253 FROM `gameobject_template` left join `gameobject_questrelation` ON `gameobject_template`.`entry` = `gameobject_questrelation`.`id`
1254 WHERE `gameobject_questrelation`.`quest` = ?d', $data['entry']))
1256 foreach ($src as $go) {localiseGameobject($go); r_objName($go);}
1257 return;
1259 // Search item quest giver
1260 if ($src = $dDB->select("SELECT `entry`, `name`, `Quality` FROM `item_template` WHERE `startquest` = ?d", $data['entry']))
1262 foreach ($src as $item) {localiseItem($item);r_itemName($item);}
1263 return;
1265 echo '---(?)---';
1267 function r_questReward($quest)
1269 global $lang;
1270 if ($quest['RewItemId1'] OR $quest['RewItemId2'] OR $quest['RewItemId3'] OR $quest['RewItemId4'])
1272 // echo $lang['Rew_item'].'<br>';
1273 if ($quest['RewItemId1']) echo text_show_item($quest['RewItemId1'], 0, 'quest');
1274 if ($quest['RewItemId2']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId2'], 0, 'quest');
1275 if ($quest['RewItemId3']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId3'], 0, 'quest');
1276 if ($quest['RewItemId4']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId4'], 0, 'quest');
1277 echo '<br>';
1279 if ($quest['RewChoiceItemId1'] OR $quest['RewChoiceItemId2'] OR $quest['RewChoiceItemId3'] OR
1280 $quest['RewChoiceItemId4'] OR $quest['RewChoiceItemId5'] OR $quest['RewChoiceItemId6'])
1282 echo $lang['Rew_select_item'].'<br>';
1283 if ($quest['RewChoiceItemId1']) echo text_show_item($quest['RewChoiceItemId1'], 0, 'quest');
1284 if ($quest['RewChoiceItemId2']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId2'], 0, 'quest');
1285 if ($quest['RewChoiceItemId3']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId3'], 0, 'quest');
1286 if ($quest['RewChoiceItemId4']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId4'], 0, 'quest');
1287 if ($quest['RewChoiceItemId5']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId5'], 0, 'quest');
1288 if ($quest['RewChoiceItemId6']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId6'], 0, 'quest');
1289 echo "<br>";
1291 if ($quest['RewSpell'] AND $quest['RewSpellCast'])
1293 show_spell($quest['RewSpell'], 0, 'quest');
1294 echo '<br>';
1296 if (!$quest['RewSpell'] AND $quest['RewSpellCast'])
1298 show_spell($quest['RewSpellCast'], 0, 'quest');
1299 echo '<br>';
1301 for ($i = 1; $i <= 5; $i++)
1303 switch (ABS($quest['RewRepValueId'.$i])):
1304 case 1: $RepValueId[$i] = 10; break;
1305 case 2: $RepValueId[$i] = 25; break;
1306 case 3: $RepValueId[$i] = 75; break;
1307 case 4: $RepValueId[$i] = 150; break;
1308 case 5: $RepValueId[$i] = 250; break;
1309 case 6: $RepValueId[$i] = 350; break;
1310 case 7: $RepValueId[$i] = 500; break;
1311 case 8: $RepValueId[$i] = 1000; break;
1312 case 9: $RepValueId[$i] = 5; break;
1313 default: $RepValueId[$i] = 0;
1314 endswitch;
1316 $quest_rate[$i] = getRepRewRate($quest['RewRepFaction'.$i]);
1318 if ($quest['RewRepValueId'.$i] < 0)
1319 $RepValueId[$i] = -$RepValueId[$i];
1321 if ($quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1322 $quest['RewRepValue'.$i] = $quest['RewRepValue'.$i]/100;
1324 if (!$quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1325 $quest['RewRepValue'.$i] = $RepValueId[$i];
1327 $quest['RewRepValue'.$i]=$quest['RewRepValue'.$i]*$quest_rate[$i];
1330 if ($quest['RewRepFaction1'] AND !$quest['RewRepFaction2'] AND
1331 !$quest['RewRepFaction3'] AND !$quest['RewRepFaction4'] AND
1332 !$quest['RewRepFaction5'])
1334 $spillover=getRepSpillover($quest['RewRepFaction1']);
1335 if ($spillover)
1336 foreach ($spillover as $faction)
1338 if ($faction['faction1'])
1340 $quest['RewRepFaction2']=$faction['faction1'];
1341 $quest['RewRepValue2']=$quest['RewRepValue1']*$faction['rate_1'];
1343 if ($faction['faction2'])
1345 $quest['RewRepFaction3']=$faction['faction2'];
1346 $quest['RewRepValue3']=$quest['RewRepValue1']*$faction['rate_2'];
1348 if ($faction['faction3'])
1350 $quest['RewRepFaction4']=$faction['faction3'];
1351 $quest['RewRepValue4']=$quest['RewRepValue1']*$faction['rate_3'];
1353 if ($faction['faction4'])
1355 $quest['RewRepFaction5']=$faction['faction4'];
1356 $quest['RewRepValue5']=$quest['RewRepValue1']*$faction['rate_4'];
1361 if ($quest['RewRepFaction1'] && $quest['RewRepValue1'])echo getFactionName($quest['RewRepFaction1']).': '.$quest['RewRepValue1'].'<br>';
1362 if ($quest['RewRepFaction2'] && $quest['RewRepValue2'])echo getFactionName($quest['RewRepFaction2']).': '.$quest['RewRepValue2'].'<br>';
1363 if ($quest['RewRepFaction3'] && $quest['RewRepValue3'])echo getFactionName($quest['RewRepFaction3']).': '.$quest['RewRepValue3'].'<br>';
1364 if ($quest['RewRepFaction4'] && $quest['RewRepValue4'])echo getFactionName($quest['RewRepFaction4']).': '.$quest['RewRepValue4'].'<br>';
1365 if ($quest['RewRepFaction5'] && $quest['RewRepValue5'])echo getFactionName($quest['RewRepFaction5']).': '.$quest['RewRepValue5'].'<br>';
1366 if ($quest['RewMoneyMaxLevel'])
1367 echo $lang['Rew_XP'].' '.getQuestXPValue($quest).' xp<br>';
1368 if ($quest['RewOrReqMoney'])
1369 echo $lang['Rew_money'].' '.money($quest['RewOrReqMoney'], 7).'<br>';
1372 $quest_reward_fields =
1373 '`RewXPId`, `RewChoiceItemId1`, `RewChoiceItemId2`, `RewChoiceItemId3`, `RewChoiceItemId4`, `RewChoiceItemId5`, `RewChoiceItemId6`,
1374 `RewChoiceItemCount1`, `RewChoiceItemCount2`, `RewChoiceItemCount3`, `RewChoiceItemCount4`, `RewChoiceItemCount5`, `RewChoiceItemCount6`,
1375 `RewItemId1`, `RewItemId2`, `RewItemId3`, `RewItemId4`, `RewItemCount1`, `RewItemCount2`, `RewItemCount3`, `RewItemCount4`,
1376 `RewRepFaction1`, `RewRepFaction2`, `RewRepFaction3`, `RewRepFaction4`, `RewRepFaction5`,
1377 `RewRepValue1`, `RewRepValue2`, `RewRepValue3`, `RewRepValue4`, `RewRepValue5`,
1378 `RewRepValueId1`, `RewRepValueId2`, `RewRepValueId3`, `RewRepValueId4`, `RewRepValueId5`,
1379 `RewOrReqMoney`, `RewMoneyMaxLevel`, `RewSpell`, `RewSpellCast`, `RewMailTemplateId`, `RewMailDelaySecs`';
1381 $quest_report = array(
1382 'QUEST_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['quest_lvl'], 'draw'=>'r_questLvl', 'sort_str'=>'`QuestLevel` DESC', 'fields'=>'`QuestLevel`' ),
1383 'QUEST_REPORT_REQLEVEL'=>array('class'=>'small','sort'=>'req_lvl','text'=>$lang['quest_reqlvl'], 'draw'=>'r_questReqLvl','sort_str'=>'`MinLevel` DESC', 'fields'=>'`MinLevel`' ),
1384 '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`'),
1385 'QUEST_REPORT_GIVER' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['quest_giver'], 'draw'=>'r_questGiver', 'sort_str'=>'', 'fields'=>''),
1386 'QUEST_REPORT_REWARD' =>array('class'=>'full', 'sort'=>'reward', 'text'=>$lang['quest_rewards'], 'draw'=>'r_questReward','sort_str'=>'`RewMoneyMaxLevel` DESC','fields'=>&$quest_reward_fields),
1387 // loot
1388 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `Title`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1389 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`condition_id`'),
1392 define('QUEST_LOCALE_NAME', 0x01);
1393 define('QUEST_LOCALE_ALL', NPC_LOCALE_NAME);
1395 // Quest report class
1396 class QuestReportGenerator extends ReportGenerator{
1397 var $dolocale = QUEST_LOCALE_ALL;
1398 function QuestReportGenerator($type='')
1400 global $quest_report, $dDB;
1401 $this->db = &$dDB;
1402 $this->column_conf =&$quest_report;
1403 switch ($type){
1404 case 'go_giver': $this->table = '(`quest_template` join `gameobject_questrelation` ON `quest_template`.`entry` = `gameobject_questrelation`.`quest`)';break;
1405 case 'go_take': $this->table = '(`quest_template` join `gameobject_involvedrelation` ON `quest_template`.`entry` = `gameobject_involvedrelation`.`quest`)';break;
1406 case 'npc_giver': $this->table = '(`quest_template` join `creature_questrelation` ON `quest_template`.`entry` = `creature_questrelation`.`quest`)';break;
1407 case 'npc_take': $this->table = '(`quest_template` join `creature_involvedrelation` ON `quest_template`.`entry` = `creature_involvedrelation`.`quest`)';break;
1408 case 'mail_loot': $this->table = '(`quest_template` join `mail_loot_template` ON `quest_template`.`RewMailTemplateId` = `mail_loot_template`.`entry`)';break;
1409 default: $this->table = '`quest_template`';break;
1411 $this->db_fields = '`quest_template`.`entry`';
1413 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1414 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1416 $tables.= ' LEFT JOIN `locales_quest` ON `quest_template`.`entry` = `locales_quest`.`entry`';
1417 if ($this->dolocale & QUEST_LOCALE_NAME)
1419 $fields = str_replace('`Title`', '`Title`, `locales_quest`.`Title_loc'.$locale.'` AS `Title_loc`', $fields);
1420 $sort_str = str_replace('`Title`', '`Title_loc`, `Title`', $sort_str);
1423 // Create quest givers/take list by entry
1424 function getGiveTakeList($entry)
1426 $this->doRequirest('`id` = ?d', $entry);
1428 // Create quest list require GO for comlete
1429 function requireGO($entry)
1431 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', -$entry, -$entry, -$entry, -$entry);
1433 // Create quest list require GO for comlete
1434 function requireCreature($entry)
1436 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', $entry, $entry, $entry, $entry);
1438 function oneQuest($entry)
1440 $this->doRequirest('`quest_template`.`entry` = ?d', $entry);
1442 // Create quest list require item for comlete
1443 function requireItem($entry, $giveQuest)
1445 $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);
1447 // Create quest list prowide item at take
1448 function provideItem($entry, $giveQuest)
1450 $this->doRequirest('`SrcItemId` = ?d AND `quest_template`.`entry` <> ?d', $entry, $giveQuest);
1452 // Create quest list reward item
1453 function rewardItem($entry)
1455 $this->doRequirest('`RewItemId1`= ?d OR `RewItemId2`= ?d OR `RewItemId3`= ?d OR `RewItemId4`= ?d OR
1456 `RewChoiceItemId1`= ?d OR`RewChoiceItemId2`= ?d OR `RewChoiceItemId3`= ?d OR `RewChoiceItemId4`= ?d OR `RewChoiceItemId5`= ?d OR `RewChoiceItemId6`= ?d',
1457 $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1459 // Create quest list cast/reward spell
1460 function rewardSpell($entry)
1462 $this->doRequirest('`RewSpell` = ?d OR `RewSpellCast` = ?d', $entry, $entry);
1464 // Return quest list where exist faction reputation reward
1465 function rewardReputation($entry)
1467 $this->doRequirest('`RewRepFaction1`= ?d OR `RewRepFaction2`= ?d OR `RewRepFaction3`= ?d OR `RewRepFaction4`= ?d OR `RewRepFaction5`= ?d', $entry, $entry, $entry, $entry, $entry);
1469 // Mail loot
1470 function lootItem($entry)
1472 $ref_loot =& getRefrenceItemLoot($entry);
1473 $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));
1474 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1479 //=================================================================
1480 // Spell list report functions and methods
1481 //=================================================================
1482 function r_spellLevel($data) {echo $data['spellLevel'];}
1483 function r_spellIcon($data) {show_spell($data['id'], $data['SpellIconID']);}
1484 function r_spellName($data)
1486 echo '<a href="?spell='.$data['id'].'">'.$data['SpellName'].'</a>';
1487 if ($data['Rank'])
1488 echo '<div class=srank>'.$data['Rank'].'</div>';
1490 function r_spellRecipe($data)
1492 r_spellName($data);
1493 if ($skilname = getSkillNameForSpell($data['id']))
1494 echo '<div class=srank>&lt;'.$skilname.'&gt;</div>';
1496 function r_spellSkill($data)
1498 global $lang;
1499 r_spellName($data);
1500 if ($data['RequiresSpellFocus'])
1501 echo '<div class=reqfocus>'.sprintf($lang['spell_req_focus'], getSpellFocusName($data['RequiresSpellFocus'], 2)).'</div>';
1502 if ($data['TotemCategory_1'] OR $data['TotemCategory_2'])
1504 $text= '';
1505 if ($data['TotemCategory_1']) $text = getTotemCategory($data['TotemCategory_1']);
1506 if ($data['TotemCategory_2']) $text.= ", ".getTotemCategory($data['TotemCategory_2']);
1507 echo '<div class=reqfocus>'.sprintf($lang['spell_req_totem'], $text).'</div>';
1510 function r_spellSchool($data){echo getSpellSchool($data['SchoolMask']);}
1511 function r_spellReagents($data)
1513 echo '<table class=reagents><tr>';
1514 for ($i=1;$i<9;$i++)
1515 if ($data['Reagent_'.$i])
1516 echo '<td>'.text_show_item($data['Reagent_'.$i],0,'reagent').'<br>x'.$data['ReagentCount_'.$i].'</td>';
1517 echo "</tr></table>";
1519 function r_spellCreate($data)
1521 if ($data['EffectItemType_1'] == 0 AND $data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1522 return 0;
1523 if ($data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1524 echo text_show_item($data['EffectItemType_1']);
1525 else
1527 echo '<table class=reagents><tr>';
1528 for ($i=1;$i<4;$i++)
1529 if ($data['EffectItemType_'.$i])
1530 echo '<td>'.text_show_item($data['EffectItemType_'.$i], 0, "reagent").($data['EffectBasePoints_'.$i]>0?'<br>x&nbsp;'.($data['EffectBasePoints_'.$i]+1):'').'</td>';
1531 echo '</tr></table>';
1533 return 1;
1535 function r_spellEquiped($data)
1537 echo $data['EquippedItemClass'].'<br />';
1538 echo $data['EquippedItemSubClassMask'].'<br />';
1539 echo $data['EquippedItemInventoryTypeMask'].'<br />';
1541 function r_skillLevel($data) {echo $data['min_value'];}
1542 function r_skillIcon($data)
1544 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1545 r_spellCreate($data);
1546 else
1547 r_spellIcon($data);
1549 $reagents= '`Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,
1550 `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, `ReagentCount_7`, `ReagentCount_8`';
1551 // Spell report generator config
1552 $spell_report = array(
1553 'SPELL_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['spell_level'], 'draw'=>'r_spellLevel', 'sort_str'=>'`spellLevel`', 'fields'=>'`spellLevel`' ),
1554 'SPELL_REPORT_ICON' =>array('class'=>'s_ico','sort'=>'icon', 'text'=>'', 'draw'=>'r_spellIcon', 'sort_str'=>'`SpellIconID`', 'fields'=>'`SpellIconID`' ),
1555 'SPELL_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['spell_name'], 'draw'=>'r_spellName', 'sort_str'=>'`SpellName`, `id`','fields'=>'`SpellName`, `Rank`' ),
1556 '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`'),
1557 'SPELL_REPORT_SCHOOL'=>array('class'=>'', 'sort'=>'school','text'=>$lang['spell_school'], 'draw'=>'r_spellSchool', 'sort_str'=>'`SchoolMask`', 'fields'=>'`SchoolMask`' ),
1558 'SPELL_REPORT_REAGENTS'=>array('class'=>'reag','sort'=>'', 'text'=>$lang['spell_reagent'],'draw'=>'r_spellReagents','sort_str'=>'', 'fields'=>&$reagents),
1559 '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`'),
1560 'SPELL_REPORT_EQUIP'=>array('class'=>'left', 'sort'=>'', 'text'=>'', 'draw'=>'r_spellEquiped','sort_str'=>'', 'fields'=>'`EquippedItemClass`, `EquippedItemSubClassMask`, `EquippedItemInventoryTypeMask`'),
1561 // Skill
1562 '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`'),
1563 '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`' ),
1564 '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`'),
1567 // Spell report class
1568 class SpellReportGenerator extends ReportGenerator{
1569 function SpellReportGenerator($type='')
1571 global $spell_report, $wDB;
1572 $this->db = &$wDB;
1573 $this->column_conf =&$spell_report;
1574 switch ($type){
1575 case 'skill': $this->table = '(`wowd_spell` join `wowd_skill_line_ability` ON `wowd_skill_line_ability`.`spellId` =`wowd_spell`.`id`)';break;
1576 default: $this->table = '`wowd_spell`';break;
1578 $this->db_fields = '`wowd_spell`.`id`';
1580 function summonGO($entry)
1582 $effList = array(50, 76, 104, 105, 106, 107);
1583 $this->doRequirest(
1584 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1585 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1586 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1588 function summonCreature($entry)
1590 $effList = array(28, 56, 90, 93, 134);
1591 $this->doRequirest(
1592 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1593 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1594 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1596 // List of spells use item as reagent
1597 function useRegent($entry)
1599 $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);
1600 $create = 0;
1601 foreach($this->data_array as &$data)
1602 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1603 $create = 1;
1604 if (!$create) $this->removeField('SPELL_REPORT_CREATE');
1606 // List of spells create this item
1607 function createItem($entry)
1609 $eff_list = array(107, 108, 109, 112);
1610 $this->doRequirest(
1611 '(`EffectItemType_1` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1612 (`EffectItemType_2` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1613 (`EffectItemType_3` = ?d AND EffectApplyAuraName_1 NOT IN (?a))', $entry, $eff_list, $entry, $eff_list, $entry, $eff_list);
1615 // List os spells give faction reputation
1616 function giveReputation($entry)
1618 $this->doRequirest(
1619 '(`EffectMiscValue_1` = ?d AND `Effect_1` = 103) OR
1620 (`EffectMiscValue_2` = ?d AND `Effect_2` = 103) OR
1621 (`EffectMiscValue_3` = ?d AND `Effect_3` = 103)', $entry, $entry, $entry);
1623 function triggerFromSpells($entry)
1625 $this->doRequirest(
1626 '`EffectTriggerSpell_1` = ?d OR
1627 `EffectTriggerSpell_2` = ?d OR
1628 `EffectTriggerSpell_3` = ?d', $entry, $entry, $entry);
1630 function enchantFromSpells($entry)
1632 $effList = array(53, 54, 92);
1633 $this->doRequirest(
1634 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1635 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1636 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1638 function affectedBySpells($family, $maskA, $maskB, $maskC)
1640 $this->doRequirest(
1641 '`SpellFamilyName` = ?d AND
1643 (`EffectApplyAuraName_1` IN (107, 108) AND ( (`EffectSpellClassMaskA_1` & ?d) OR (`EffectSpellClassMaskA_2` & ?d) OR (`EffectSpellClassMaskA_3` & ?d) ) ) OR
1644 (`EffectApplyAuraName_2` IN (107, 108) AND ( (`EffectSpellClassMaskB_1` & ?d) OR (`EffectSpellClassMaskB_2` & ?d) OR (`EffectSpellClassMaskB_3` & ?d) ) ) OR
1645 (`EffectApplyAuraName_3` IN (107, 108) AND ( (`EffectSpellClassMaskC_1` & ?d) OR (`EffectSpellClassMaskC_2` & ?d) OR (`EffectSpellClassMaskC_3` & ?d) ) )
1646 )', $family, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC);
1648 function castByCreature($creature)
1650 global $wDB, $dDB;
1651 $spell_list = array();
1653 // By creature fields
1654 for ($i=1;$i<9;$i++)
1655 $spell_list = array_merge($spell_list, $dDB->selectCol('SELECT `spell'.$i.'` FROM `creature_template_spells` WHERE `entry` = ?d', $creature['entry']));
1657 // By event AI table
1658 for ($i=1;$i<=3;$i++)
1659 $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']));
1661 if (count($spell_list))
1662 $this->doRequirest('`id` IN (?a)', array_unique($spell_list));
1664 function doSkillList($skill)
1666 if (isset($_REQUEST['guid']))
1668 $spells = getPlayerSpells($_REQUEST['guid']);
1669 $this->rowCallback = 'playerSpellCallback';
1671 $this->doRequirest('`skillId` = ?d', $skill);
1673 function lootItem($entry)
1675 global $dDB;
1676 $ref_loot =& getRefrenceItemLoot($entry);
1677 $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));
1678 if ($spells)
1679 $this->doRequirest('`id` IN (?a)', array_keys($spells));
1683 //=================================================================
1684 // Glyph list report functions and methods
1685 //=================================================================
1686 function r_glyphId($data) {echo $data['id'];}
1687 function r_glyphName($data) {$spell=getSpell($data['SpellId']); echo $spell['SpellName'];}
1688 function r_glyphIcon($data) {echo '<img src="'.getSpellIcon($data['iconId']).'">';}
1690 $glyph_report = array(
1691 'GLYPH_REPORT_ID' =>array('class'=>'small','sort'=>'','text'=>$lang['glyph_id' ], 'draw'=>'r_glyphId', 'sort_str'=>'', 'fields'=>'' ),
1692 'GLYPH_REPORT_NAME'=>array('class'=>'left', 'sort'=>'','text'=>$lang['glyph_name'], 'draw'=>'r_glyphName','sort_str'=>'', 'fields'=>'`SpellId`' ),
1693 'GLYPH_REPORT_ICON'=>array('class'=>'i_ico','sort'=>'','text'=>'', 'draw'=>'r_glyphIcon','sort_str'=>'', 'fields'=>'`iconId`'),
1696 class GlyphReportGenerator extends ReportGenerator{
1697 // Database depend requirest generator
1698 // Select only reuire for report fields from database
1699 function GlyphReportGenerator($type='')
1701 global $glyph_report, $wDB;
1702 $this->db = &$wDB;
1703 $this->column_conf =&$glyph_report;
1704 $this->table = '`wowd_glyphproperties`';
1705 $this->db_fields = '`id`';
1707 function useSpell($entry)
1709 $this->doRequirest('`SpellId` = ?d', $entry);
1713 //=================================================================
1714 // Random Suffix list report functions and methods
1715 //=================================================================
1716 function r_rndSuffId($data) {echo $data['id'];}
1717 function r_rndSuffName($data) {echo '&nbsp;... '.$data['name'];}
1718 function r_rndSuffDetail($data)
1720 for ($j=1;$j<=3;$j++)
1721 if ($data['EnchantID_'.$j])
1722 echo str_ireplace('$i', round($data['Prefix_'.$j]/100, 2).'%', getEnchantmentDesc($data['EnchantID_'.$j]))."<br>";
1725 $rsuff_report = array(
1726 'RSUFF_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndSuffId', 'sort_str'=>'', 'fields'=>'' ),
1727 'RSUFF_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndSuffName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1728 '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`'),
1731 class RandomSuffixReportGenerator extends ReportGenerator{
1732 // Database depend requirest generator
1733 // Select only reuire for report fields from database
1734 function RandomSuffixReportGenerator($type='')
1736 global $rsuff_report, $wDB;
1737 $this->db = &$wDB;
1738 $this->column_conf =&$rsuff_report;
1739 $this->table = '`wowd_item_random_suffix`';
1740 $this->db_fields = '`id`';
1742 function enchantFrom($entry)
1744 $this->doRequirest('`EnchantID_1` = ?d OR `EnchantID_2` = ?d OR `EnchantID_3` = ?d', $entry, $entry, $entry);
1748 //=================================================================
1749 // Random Suffix list report functions and methods
1750 //=================================================================
1751 function r_rndPropId($data) {echo $data['id'];}
1752 function r_rndPropName($data) {echo '&nbsp;... '.$data['name'];}
1753 function r_rndPropDetail($data)
1755 for ($j=1;$j<=5;$j++)
1756 if ($data['EnchantID_'.$j])
1757 echo getEnchantmentDesc($data['EnchantID_'.$j])."<br>";
1760 $rprop_report = array(
1761 'RPROP_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndPropId', 'sort_str'=>'', 'fields'=>'' ),
1762 'RPROP_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndPropName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1763 '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`'),
1766 class RandomPropetyReportGenerator extends ReportGenerator{
1767 // Database depend requirest generator
1768 // Select only reuire for report fields from database
1769 function RandomPropetyReportGenerator($type='')
1771 global $rprop_report, $wDB;
1772 $this->db = &$wDB;
1773 $this->column_conf =&$rprop_report;
1774 $this->table = '`wowd_item_random_propety`';
1775 $this->db_fields = '`id`';
1777 function enchantFrom($entry)
1779 $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);
1783 //=================================================================
1784 // Lock list report functions and methods
1785 //=================================================================
1786 function r_LockId($data) {echo $data['id'];}
1787 function r_LockKeys($data)
1789 for ($i=0;$i<8;$i++)
1791 switch ($data['keytype_'.$i]){
1792 case 0: continue;
1793 case 1: echo text_show_item($data['key_'.$i], 0, 'cost').($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1794 case 2: echo getLockType($data['key_'.$i]).($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1798 function r_LockProvide($data)
1800 global $lang, $dDB;
1801 if ($items = $dDB->select('SELECT `entry`, `Quality`, `displayid`, `name` FROM `item_template` WHERE `lockid` = ?d', $data['id']))
1802 foreach ($items as $i)
1803 show_item($i['entry'], $i['displayid'], 'sell');
1805 $data0 = array(GAMEOBJECT_TYPE_QUESTGIVER,GAMEOBJECT_TYPE_CHEST,GAMEOBJECT_TYPE_TRAP,GAMEOBJECT_TYPE_GOOBER,GAMEOBJECT_TYPE_CAMERA);
1806 $data1 = array(GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_BUTTON);
1807 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']))
1808 foreach ($go_list as $go)
1810 localiseGameobject($go);
1811 r_objName($go);echo '<br>';
1813 if (count($items) + count($go_list) == 0)
1814 echo $lang['no_found'];
1817 $lock_report = array(
1818 'LOCK_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['lock_id'], 'draw'=>'r_LockId', 'sort_str'=>'', 'fields'=>''),
1819 'LOCK_REPORT_KEY' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['lock_keys'],'draw'=>'r_LockKeys', 'sort_str'=>'', 'fields'=>''),
1820 'LOCK_REPORT_HAVE'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['locked_list'],'draw'=>'r_LockProvide','sort_str'=>'', 'fields'=>''),
1823 class LockReportGenerator extends ReportGenerator{
1824 // Database depend requirest generator
1825 // Select only reuire for report fields from database
1826 function LockReportGenerator($type='')
1828 global $lock_report, $wDB;
1829 $this->db = &$wDB;
1830 $this->column_conf =&$lock_report;
1831 $this->table = '`wowd_lock`';
1832 $this->db_fields = '*';
1834 function haveItemAsKey($entry)
1836 $this->doRequirest(
1837 '(`keytype_0` = 1 AND `key_0` = ?d) OR
1838 (`keytype_1` = 1 AND `key_1` = ?d) OR
1839 (`keytype_2` = 1 AND `key_2` = ?d) OR
1840 (`keytype_3` = 1 AND `key_3` = ?d) OR
1841 (`keytype_4` = 1 AND `key_4` = ?d)', $entry, $entry, $entry, $entry, $entry);
1845 //=================================================================
1846 // Extend cost list report functions and methods
1847 //=================================================================
1848 function r_excostId($data) {echo $data['id'];}
1849 function r_excostCost($data, $side = 0)
1851 if ($side) $side = "images/honor_horde.png";
1852 else $side = "images/honor_alliance.png";
1853 $str='<div class=ex_cost>';
1854 if ($data['reqhonorpoints']) $str.= $data['reqhonorpoints'].'x<img class=cost src='.$side.'>';
1855 if ($data['reqarenapoints']) $str.= $data['reqarenapoints'].'x<img class=cost src=images/arena_points.png>';
1856 for ($i=1;$i<6;$i++)
1857 if ($data['reqitem_'.$i]) $str.= $data['reqitemcount_'.$i].' x '.text_show_item($data['reqitem_'.$i], 0, 'cost');
1858 echo $str.'</div>';
1861 function r_excostItem($data)
1863 global $lang, $dDB;
1864 if ($items = $dDB->selectCol("SELECT `item` FROM `npc_vendor` WHERE ExtendedCost = ?d GROUP BY `item`", $data['id']))
1865 foreach ($items as $itemid)
1866 show_item($itemid, 0, "sell");
1867 else
1868 echo $lang['no_found'];
1870 $excost_report = array(
1871 'EXCOST_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['excost_id'], 'draw'=>'r_excostId', 'sort_str'=>'`id`', 'fields'=>''),
1872 'EXCOST_REPORT_COST'=>array('class'=>'small','sort'=>'cost', 'text'=>$lang['excost_cost'], 'draw'=>'r_excostCost','sort_str'=>'`reqitemcount_1`,`reqitemcount_2`, `reqitemcount_3`', 'fields'=>''),
1873 'EXCOST_REPORT_ITEM'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['excost_items'],'draw'=>'r_excostItem','sort_str'=>'', 'fields'=>''),
1876 class ExCostReportGenerator extends ReportGenerator{
1877 // Database depend requirest generator
1878 // Select only reuire for report fields from database
1879 function ExCostReportGenerator($type='')
1881 global $excost_report, $wDB;
1882 $this->db = &$wDB;
1883 $this->column_conf =&$excost_report;
1884 $this->table = '`wowd_item_ex_cost`';
1885 $this->db_fields = '*';
1887 function useItemAsCost($entry)
1889 $this->doRequirest(
1890 '`reqitem_1` = ?d OR
1891 `reqitem_2` = ?d OR
1892 `reqitem_3` = ?d OR
1893 `reqitem_4` = ?d OR
1894 `reqitem_5` = ?d', $entry, $entry, $entry, $entry, $entry);
1898 //=================================================================
1899 // Item set list report functions and methods
1900 //=================================================================
1901 function r_setId($data) {echo $data['id'];}
1902 function r_setName($data){echo '<a href="?itemset='.$data['id'].'">'.$data['name'].'</a>';}
1903 function r_setItems($data)
1905 for($i=1;$i<18;$i++)
1906 if ($set_item = $data['item_'.$i])
1907 echo '&nbsp;'.text_show_item($set_item).'&nbsp;';
1909 function r_setSpells($data)
1911 for($i=1; $i<9; $i++)
1912 if ($spellID = $data['spell_'.$i])
1913 echo '<a class=spell href="?spell='.$spellID.'">('.$data['count_'.$i].') '.get_spell_details($spellID).'</a><br>';
1915 function r_setClass($data){}
1916 function r_setLevel($data){}
1918 $itemset_report = array(
1919 'SET_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['set_id'], 'draw'=>'r_setId', 'sort_str'=>'`id`', 'fields'=>''),
1920 'SET_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['set_name'], 'draw'=>'r_setName', 'sort_str'=>'`name`','fields'=>''),
1921 'SET_REPORT_ITEM' =>array('class'=>'iset', 'sort'=>'', 'text'=>$lang['set_items'], 'draw'=>'r_setItems', 'sort_str'=>'', 'fields'=>''),
1922 'SET_REPORT_SPELL'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['set_spells'],'draw'=>'r_setSpells','sort_str'=>'', 'fields'=>''),
1923 // Not supported yet
1924 'SET_REPORT_CLASS'=>array('class'=>'', 'sort'=>'class','text'=>$lang['set_class'], 'draw'=>'r_setClass', 'sort_str'=>'', 'fields'=>''),
1925 'SET_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'level','text'=>$lang['set_level'], 'draw'=>'r_setLevel', 'sort_str'=>'', 'fields'=>''),
1928 class ItemSetReportGenerator extends ReportGenerator{
1929 // Database depend requirest generator
1930 // Select only reuire for report fields from database
1931 function ItemSetReportGenerator($type='')
1933 global $itemset_report, $wDB;
1934 $this->db = &$wDB;
1935 $this->column_conf =&$itemset_report;
1936 $this->table = '`wowd_itemset`';
1937 $this->db_fields = '*';
1939 function useSpell($entry)
1941 $this->doRequirest(
1942 '`spell_1` = ?d OR `spell_2` = ?d OR `spell_3` = ?d OR `spell_4` = ?d OR
1943 `spell_5` = ?d OR `spell_6` = ?d OR `spell_7` = ?d OR `spell_8` = ?d', $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1947 //=================================================================
1948 // Faction list report functions and methods
1949 //=================================================================
1950 function r_factionId($data) {echo $data['id'];}
1951 function r_factionName($data) {echo '<a href="?faction='.$data['id'].'">'.$data['name'].'</a>';}
1952 function r_factionDetail($data){echo $data['details'];}
1954 $faction_report = array(
1955 'FACTION_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['faction_id' ], 'draw'=>'r_factionId', 'sort_str'=>'', 'fields'=>'' ),
1956 'FACTION_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['faction_name'], 'draw'=>'r_factionName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1957 'FACTION_REPORT_DETAILS' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['faction_details'],'draw'=>'r_factionDetail','sort_str'=>'', 'fields'=>'`details`'),
1960 class FactionReportGenerator extends ReportGenerator{
1961 // Database depend requirest generator
1962 // Select only reuire for report fields from database
1963 function FactionReportGenerator($type='')
1965 global $faction_report, $wDB;
1966 $this->db = &$wDB;
1967 $this->column_conf =&$faction_report;
1968 $this->table = '`wowd_faction`';
1969 $this->db_fields = '`id`';
1973 //=================================================================
1974 // Enchants list report functions and methods
1975 //=================================================================
1976 function r_enchId($data) {echo $data['id'];}
1977 function r_enchName($data) {echo '<a href="?enchant='.$data['id'].'">'.$data['description'].'</a>';}
1978 function r_enchGem($data) { if ($data['GemID']) echo text_show_item($data['GemID']);}
1979 $enchants_report = array(
1980 'ENCH_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['enchant_id'], 'draw'=>'r_enchId', 'sort_str'=>'`id`', 'fields'=>''),
1981 'ENCH_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['enchant_name'],'draw'=>'r_enchName', 'sort_str'=>'`description`','fields'=>'`description`'),
1982 'ENCH_REPORT_GEM' =>array('class'=>'small','sort'=>'', 'text'=>'', 'draw'=>'r_enchGem', 'sort_str'=>'', 'fields'=>'`GemID`'),
1985 class EnchantReportGenerator extends ReportGenerator{
1986 // Database depend requirest generator
1987 // Select only reuire for report fields from database
1988 function EnchantReportGenerator($type='')
1990 global $enchants_report, $wDB;
1991 $this->db = &$wDB;
1992 $this->column_conf =&$enchants_report;
1993 $this->table = '`wowd_item_enchantment`';
1994 $this->db_fields = '`id`';
1996 function useSpell($entry)
1998 $this->doRequirest('`spellid_1` = ?d OR `spellid_2` = ?d OR `spellid_3` = ?d', $entry, $entry, $entry);
1999 $this->removeIfAllZero('GemID', 'ENCH_REPORT_GEM');
2003 //=================================================================
2004 // Talents list report functions and methods
2005 //=================================================================
2006 function r_talentId($data) {echo $data['TalentTab'];}
2007 function r_talentName($data) {echo getTalentName($data['TalentTab']);}
2008 $talent_report = array(
2009 'TALENT_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['talent_id'], 'draw'=>'r_talentId', 'sort_str'=>'', 'fields'=>'`TalentTab`'),
2010 'TALENT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['talent_name'],'draw'=>'r_talentName', 'sort_str'=>'','fields'=>'`TalentTab`'),
2013 class TalentReportGenerator extends ReportGenerator{
2014 // Database depend requirest generator
2015 // Select only reuire for report fields from database
2016 function TalentReportGenerator($type='')
2018 global $talent_report, $wDB;
2019 $this->db = &$wDB;
2020 $this->column_conf =&$talent_report;
2021 $this->table = '`wowd_talents`';
2022 $this->db_fields = '`TalentID`';
2024 function useSpell($entry)
2026 $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);
2029 //=================================================================
2030 // Zones list report functions and methods
2031 //=================================================================
2032 function r_zoneId($data) {echo $data['id'];}
2033 function r_zoneName($data) {echo '<a href="?zone='.$data['id'].'">'.$data['name'].'</a>';}
2034 $zone_report = array(
2035 'ZONE_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['zone_id'], 'draw'=>'r_zoneId', 'sort_str'=>'`id`', 'fields'=>''),
2036 'ZONE_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['zone_name'],'draw'=>'r_zoneName', 'sort_str'=>'`name`','fields'=>'`name`'),
2039 class ZoneReportGenerator extends ReportGenerator{
2040 function ZoneReportGenerator($type='')
2042 global $zone_report, $wDB;
2043 $this->db = &$wDB;
2044 $this->column_conf =&$zone_report;
2045 $this->table = '`wowd_zones`';
2046 $this->db_fields = '`id`';
2048 function parentZone($entry)
2050 $this->doRequirest('`id` = ?d', $entry);
2052 function subZones($entry)
2054 $this->doRequirest('`zone_id` = ?d', $entry);
2058 //=================================================================
2059 // Areatrigger teleport list report functions and methods
2060 //=================================================================
2061 function r_atId($data) {echo $data['id'];}
2062 function r_atName($data) {echo $data['name'];}
2063 function r_atReq($data)
2065 global $lang;
2066 if ($data['required_level'])
2067 echo 'Req level: '.$data['required_level'].'<br>';
2069 if ($data['required_item'] OR $data['required_item2'])
2071 echo 'Req items:<br>';
2072 if ($data['required_item']) echo text_show_item($data['required_item'], 0, 'quest');
2073 if ($data['required_item2']) echo $lang['item_sel_and'].text_show_item($data['required_item2'], 0, 'quest');
2074 echo '<br>';
2076 if ($data['heroic_key'] OR $data['heroic_key2'])
2078 echo 'Heroic key:<br>';
2079 if ($data['heroic_key']) echo text_show_item($data['heroic_key'], 0, 'quest');
2080 if ($data['heroic_key2']) echo $lang['item_sel_and'].text_show_item($data['heroic_key2'], 0, 'quest');
2081 echo '<br>';
2085 $at_report = array(
2086 'AT_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['at_id'], 'draw'=>'r_atId', 'sort_str'=>'`id`', 'fields'=>''),
2087 'AT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['at_name'],'draw'=>'r_atName', 'sort_str'=>'`name`','fields'=>'`name`'),
2088 '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`'),
2091 class AreaTriggerReportGenerator extends ReportGenerator{
2092 function AreaTriggerReportGenerator($type='')
2094 global $at_report, $wDB;
2095 $this->db = &$wDB;
2096 $this->column_conf =&$at_report;
2097 $this->table = '`areatrigger_teleport`';
2098 $this->db_fields = '*';
2100 function onMap($entry)
2102 $this->doRequirest('`target_map` = ?d', $entry);
2104 function onArea($area_data)
2106 $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]);
2110 //=================================================================
2111 // Players list report functions and methods
2112 //=================================================================
2113 function r_plGUID($data) {echo $data['guid'];}
2114 function r_plName($data) {echo '<a href=?player='.$data['guid'].'>'.$data['name'].'</a>';}
2115 function r_plRace($data) {echo '<img src="'.getRaceImage($data['race'],$data['gender']).'">';}
2116 function r_plClass($data) {echo '<img src="'.getClassImage($data['class']).'">';}
2117 function r_plFaction($data){echo '<img src="'.getFactionImage($data['race']).'">';}
2118 function r_plLevel($data) {echo $data['level'];}
2119 function r_plPos($data)
2121 global $config;
2122 $map_name = getMapNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2123 $area_name = getAreaNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2124 $extra_name = "";
2125 if ($area_name)
2127 $extra_name = "<br><font size=-2>".$map_name."</font>";
2128 $map_name = "&bdquo;".str_replace(' ','&nbsp;', $area_name)."&ldquo;";
2130 else
2131 $map_name = "&bdquo;".str_replace(' ','&nbsp;',$map_name)."&ldquo;";
2133 if ($config['show_map_ptr'])
2134 $map_name = "<a href=\"?map&point=$data[map]:$data[position_x]:$data[position_y]:$data[position_z]\">".$map_name."</a>";
2135 echo $map_name.$extra_name;
2137 function r_plGuildNote($data) {echo $data['pnote']."<br>".$data['offnote'];}
2138 function r_plGuildRank($data)
2140 // Получаем названия рангов в гильдии
2141 $rank = getGuildRankList($data['guildid']);
2142 echo @$rank[$data['rank']]['rname'];
2145 function r_plItem($data){show_item_by_data(explode(' ',$data['item_data']));}
2147 $pl_report = array(
2148 'PL_REPORT_GUID' =>array('class'=>'small', 'sort'=>'id', 'text'=>$lang['pl_guid'], 'draw'=>'r_plGUID', 'sort_str'=>'`id`', 'fields'=>''),
2149 'PL_REPORT_NAME' =>array('class'=>'player','sort'=>'name', 'text'=>$lang['pl_name'], 'draw'=>'r_plName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
2150 'PL_REPORT_RACE' =>array('class'=>'i_ico', 'sort'=>'race', 'text'=>$lang['pl_race'], 'draw'=>'r_plRace', 'sort_str'=>'`race`', 'fields'=>'`race`, `gender`'),
2151 'PL_REPORT_CLASS' =>array('class'=>'i_ico', 'sort'=>'class', 'text'=>$lang['pl_class'], 'draw'=>'r_plClass', 'sort_str'=>'`class`', 'fields'=>'`class`'),
2152 'PL_REPORT_FACTION'=>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plFaction','sort_str'=>'', 'fields'=>'`race`'),
2153 'PL_REPORT_LEVEL' =>array('class'=>'small', 'sort'=>'level', 'text'=>$lang['pl_level'], 'draw'=>'r_plLevel', 'sort_str'=>'`level` DESC','fields'=>'`level`'),
2154 '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`'),
2155 // Guild member info
2156 'PL_REPORT_NOTE' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['pl_note'], 'draw'=>'r_plGuildNote','sort_str'=>'', 'fields'=>'`pnote`, `offnote`'),
2157 'PL_REPORT_GRANK' =>array('class'=>'rank', 'sort'=>'rank', 'text'=>$lang['pl_rank'], 'draw'=>'r_plGuildRank','sort_str'=>'`rank`', 'fields'=>'`guildid`,`rank`'),
2158 // Item owner
2159 'PL_REPORT_ITEM' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plItem' ,'sort_str'=>'', 'fields'=>'`item_instance`.`data` AS `item_data`'),
2162 class PlayerReportGenerator extends ReportGenerator{
2163 function PlayerReportGenerator($type='')
2165 global $pl_report, $cDB;
2166 $this->db = &$cDB;
2167 $this->column_conf =&$pl_report;
2168 switch ($type){
2169 case 'guild': $this->table = '(`characters` join `guild_member` ON `guild_member`.`guid` = `characters`.`guid`)';break;
2170 case 'item': $this->table = '(`characters` join `item_instance` ON `characters`.`guid` = `item_instance`.`owner_guid`)';break;
2171 default: $this->table = '`characters`';break;
2174 $this->db_fields = '`characters`.`guid`';
2176 function online()
2178 $this->doRequirest('`online` <> 0 AND NOT `extra_flags`&'.PLAYER_EXTRA_GM_INVISIBLE);
2180 // Select guild members by guild guid
2181 function guildMembers($gguid)
2183 $this->doRequirest('`guildid` = ?d', $gguid);
2185 function itemOwner($id)
2187 $this->doRequirest("(SUBSTRING_INDEX( SUBSTRING_INDEX(`item_instance`.`data` , ' ' , ?d) , ' ' , -1 )+0) = ?d", ITEM_FIELD_ENTRY + 1, $id);